changeset 4688:53daaad8f532

Merge
author duke
date Wed, 05 Jul 2017 17:06:00 +0200
parents 0c8ad4a8e25b 6b7dbe4cbf14
children 53755addd6d3
files hotspot/src/share/vm/gc_implementation/g1/ptrQueue.inline.hpp jdk/make/java/redist/FILES.gmk jdk/make/sun/nio/FILES_java.gmk jdk/src/solaris/classes/sun/nio/ch/SctpSocketDispatcher.java
diffstat 261 files changed, 4417 insertions(+), 1591 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags-top-repo	Thu Jan 21 11:12:31 2010 -0800
+++ b/.hgtags-top-repo	Wed Jul 05 17:06:00 2017 +0200
@@ -54,3 +54,4 @@
 1f17ca8353babb13f4908c1f87d11508232518c8 jdk7-b77
 ab4ae8f4514693a9fe17ca2fec0239d8f8450d2c jdk7-b78
 20aeeb51713990dbea6929a2e100a8bbf5df70d4 jdk7-b79
+a3242906c7747b5d9bcc3d118c7c3c69aa40f4b7 jdk7-b80
--- a/corba/.hgtags	Thu Jan 21 11:12:31 2010 -0800
+++ b/corba/.hgtags	Wed Jul 05 17:06:00 2017 +0200
@@ -54,3 +54,4 @@
 6881f0383f623394b5ec73f27a5f329ff55d0467 jdk7-b77
 a7f7276b48cd74d8eb1baa83fbf3d1ef4a2603c8 jdk7-b78
 ec0421b5703b677e2226cf4bf7ae4eaafd8061c5 jdk7-b79
+0336e70ca0aeabc783cc01658f36cb6e27ea7934 jdk7-b80
--- a/hotspot/.hgtags	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/.hgtags	Wed Jul 05 17:06:00 2017 +0200
@@ -54,3 +54,4 @@
 455105fc81d941482f8f8056afaa7aa0949c9300 jdk7-b77
 e703499b4b51e3af756ae77c3d5e8b3058a14e4e jdk7-b78
 a5a6adfca6ecefb5894a848debabfe442ff50e25 jdk7-b79
+3003ddd1d4330b06cb4691ae74d600d3685899eb jdk7-b80
--- a/hotspot/make/hotspot_version	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/make/hotspot_version	Wed Jul 05 17:06:00 2017 +0200
@@ -35,7 +35,7 @@
 
 HS_MAJOR_VER=17
 HS_MINOR_VER=0
-HS_BUILD_NUMBER=07
+HS_BUILD_NUMBER=08
 
 JDK_MAJOR_VER=1
 JDK_MINOR_VER=7
--- a/hotspot/src/cpu/sparc/vm/interpreter_sparc.cpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/cpu/sparc/vm/interpreter_sparc.cpp	Wed Jul 05 17:06:00 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-2010 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -394,6 +394,11 @@
 }
 
 
+bool AbstractInterpreter::can_be_compiled(methodHandle m) {
+  // No special entry points that preclude compilation
+  return true;
+}
+
 // This method tells the deoptimizer how big an interpreted frame must be:
 int AbstractInterpreter::size_activation(methodOop method,
                                          int tempcount,
--- a/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp	Wed Jul 05 17:06:00 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-2010 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -2862,6 +2862,9 @@
 
     // arraycopy stubs used by compilers
     generate_arraycopy_stubs();
+
+    // Don't initialize the platform math functions since sparc
+    // doesn't have intrinsics for these operations.
   }
 
 
--- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp	Wed Jul 05 17:06:00 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1999-2010 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -2030,6 +2030,54 @@
                                entry_checkcast_arraycopy);
   }
 
+  void generate_math_stubs() {
+    {
+      StubCodeMark mark(this, "StubRoutines", "log");
+      StubRoutines::_intrinsic_log = (double (*)(double)) __ pc();
+
+      __ fld_d(Address(rsp, 4));
+      __ flog();
+      __ ret(0);
+    }
+    {
+      StubCodeMark mark(this, "StubRoutines", "log10");
+      StubRoutines::_intrinsic_log10 = (double (*)(double)) __ pc();
+
+      __ fld_d(Address(rsp, 4));
+      __ flog10();
+      __ ret(0);
+    }
+    {
+      StubCodeMark mark(this, "StubRoutines", "sin");
+      StubRoutines::_intrinsic_sin = (double (*)(double))  __ pc();
+
+      __ fld_d(Address(rsp, 4));
+      __ trigfunc('s');
+      __ ret(0);
+    }
+    {
+      StubCodeMark mark(this, "StubRoutines", "cos");
+      StubRoutines::_intrinsic_cos = (double (*)(double)) __ pc();
+
+      __ fld_d(Address(rsp, 4));
+      __ trigfunc('c');
+      __ ret(0);
+    }
+    {
+      StubCodeMark mark(this, "StubRoutines", "tan");
+      StubRoutines::_intrinsic_tan = (double (*)(double)) __ pc();
+
+      __ fld_d(Address(rsp, 4));
+      __ trigfunc('t');
+      __ ret(0);
+    }
+
+    // The intrinsic version of these seem to return the same value as
+    // the strict version.
+    StubRoutines::_intrinsic_exp = SharedRuntime::dexp;
+    StubRoutines::_intrinsic_pow = SharedRuntime::dpow;
+  }
+
  public:
   // Information about frame layout at time of blocking runtime call.
   // Note that we only have to preserve callee-saved registers since
@@ -2228,6 +2276,8 @@
         MethodHandles::generate_method_handle_stub(_masm, ek);
       }
     }
+
+    generate_math_stubs();
   }
 
 
--- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp	Wed Jul 05 17:06:00 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2003-2010 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -2731,6 +2731,79 @@
     StubRoutines::_arrayof_oop_arraycopy             = StubRoutines::_oop_arraycopy;
   }
 
+  void generate_math_stubs() {
+    {
+      StubCodeMark mark(this, "StubRoutines", "log");
+      StubRoutines::_intrinsic_log = (double (*)(double)) __ pc();
+
+      __ subq(rsp, 8);
+      __ movdbl(Address(rsp, 0), xmm0);
+      __ fld_d(Address(rsp, 0));
+      __ flog();
+      __ fstp_d(Address(rsp, 0));
+      __ movdbl(xmm0, Address(rsp, 0));
+      __ addq(rsp, 8);
+      __ ret(0);
+    }
+    {
+      StubCodeMark mark(this, "StubRoutines", "log10");
+      StubRoutines::_intrinsic_log10 = (double (*)(double)) __ pc();
+
+      __ subq(rsp, 8);
+      __ movdbl(Address(rsp, 0), xmm0);
+      __ fld_d(Address(rsp, 0));
+      __ flog10();
+      __ fstp_d(Address(rsp, 0));
+      __ movdbl(xmm0, Address(rsp, 0));
+      __ addq(rsp, 8);
+      __ ret(0);
+    }
+    {
+      StubCodeMark mark(this, "StubRoutines", "sin");
+      StubRoutines::_intrinsic_sin = (double (*)(double)) __ pc();
+
+      __ subq(rsp, 8);
+      __ movdbl(Address(rsp, 0), xmm0);
+      __ fld_d(Address(rsp, 0));
+      __ trigfunc('s');
+      __ fstp_d(Address(rsp, 0));
+      __ movdbl(xmm0, Address(rsp, 0));
+      __ addq(rsp, 8);
+      __ ret(0);
+    }
+    {
+      StubCodeMark mark(this, "StubRoutines", "cos");
+      StubRoutines::_intrinsic_cos = (double (*)(double)) __ pc();
+
+      __ subq(rsp, 8);
+      __ movdbl(Address(rsp, 0), xmm0);
+      __ fld_d(Address(rsp, 0));
+      __ trigfunc('c');
+      __ fstp_d(Address(rsp, 0));
+      __ movdbl(xmm0, Address(rsp, 0));
+      __ addq(rsp, 8);
+      __ ret(0);
+    }
+    {
+      StubCodeMark mark(this, "StubRoutines", "tan");
+      StubRoutines::_intrinsic_tan = (double (*)(double)) __ pc();
+
+      __ subq(rsp, 8);
+      __ movdbl(Address(rsp, 0), xmm0);
+      __ fld_d(Address(rsp, 0));
+      __ trigfunc('t');
+      __ fstp_d(Address(rsp, 0));
+      __ movdbl(xmm0, Address(rsp, 0));
+      __ addq(rsp, 8);
+      __ ret(0);
+    }
+
+    // The intrinsic version of these seem to return the same value as
+    // the strict version.
+    StubRoutines::_intrinsic_exp = SharedRuntime::dexp;
+    StubRoutines::_intrinsic_pow = SharedRuntime::dpow;
+  }
+
 #undef __
 #define __ masm->
 
@@ -2945,6 +3018,8 @@
         MethodHandles::generate_method_handle_stub(_masm, ek);
       }
     }
+
+    generate_math_stubs();
   }
 
  public:
--- a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp	Wed Jul 05 17:06:00 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-2010 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1431,6 +1431,23 @@
 
 }
 
+// These should never be compiled since the interpreter will prefer
+// the compiled version to the intrinsic version.
+bool AbstractInterpreter::can_be_compiled(methodHandle m) {
+  switch (method_kind(m)) {
+    case Interpreter::java_lang_math_sin     : // fall thru
+    case Interpreter::java_lang_math_cos     : // fall thru
+    case Interpreter::java_lang_math_tan     : // fall thru
+    case Interpreter::java_lang_math_abs     : // fall thru
+    case Interpreter::java_lang_math_log     : // fall thru
+    case Interpreter::java_lang_math_log10   : // fall thru
+    case Interpreter::java_lang_math_sqrt    :
+      return false;
+    default:
+      return true;
+  }
+}
+
 // How much stack a method activation needs in words.
 int AbstractInterpreter::size_top_interpreter_activation(methodOop method) {
 
--- a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp	Wed Jul 05 17:06:00 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2003-2010 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1456,6 +1456,23 @@
                                 generate_normal_entry(synchronized);
 }
 
+// These should never be compiled since the interpreter will prefer
+// the compiled version to the intrinsic version.
+bool AbstractInterpreter::can_be_compiled(methodHandle m) {
+  switch (method_kind(m)) {
+    case Interpreter::java_lang_math_sin     : // fall thru
+    case Interpreter::java_lang_math_cos     : // fall thru
+    case Interpreter::java_lang_math_tan     : // fall thru
+    case Interpreter::java_lang_math_abs     : // fall thru
+    case Interpreter::java_lang_math_log     : // fall thru
+    case Interpreter::java_lang_math_log10   : // fall thru
+    case Interpreter::java_lang_math_sqrt    :
+      return false;
+    default:
+      return true;
+  }
+}
+
 // How much stack a method activation needs in words.
 int AbstractInterpreter::size_top_interpreter_activation(methodOop method) {
   const int entry_size = frame::interpreter_frame_monitor_size();
--- a/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp	Wed Jul 05 17:06:00 2017 +0200
@@ -1,6 +1,6 @@
 /*
  * Copyright 2003-2007 Sun Microsystems, Inc.  All Rights Reserved.
- * Copyright 2007, 2008 Red Hat, Inc.
+ * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -239,7 +239,21 @@
 }
 
 bool os::is_allocatable(size_t bytes) {
-  ShouldNotCallThis();
+#ifdef _LP64
+  return true;
+#else
+  if (bytes < 2 * G) {
+    return true;
+  }
+
+  char* addr = reserve_memory(bytes, NULL);
+
+  if (addr != NULL) {
+    release_memory(addr, bytes);
+  }
+
+  return addr != NULL;
+#endif // _LP64
 }
 
 ///////////////////////////////////////////////////////////////////////////////
--- a/hotspot/src/share/vm/c1/c1_LIR.hpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/c1/c1_LIR.hpp	Wed Jul 05 17:06:00 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2000-2010 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -2000,7 +2000,7 @@
   typedef enum { inputMode, firstMode = inputMode, tempMode, outputMode, numModes, invalidMode = -1 } OprMode;
 
   enum {
-    maxNumberOfOperands = 14,
+    maxNumberOfOperands = 16,
     maxNumberOfInfos = 4
   };
 
--- a/hotspot/src/share/vm/ci/ciField.cpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/ci/ciField.cpp	Wed Jul 05 17:06:00 2017 +0200
@@ -161,6 +161,18 @@
          "bootstrap classes must not create & cache unshared fields");
 }
 
+static bool trust_final_non_static_fields(ciInstanceKlass* holder) {
+  if (holder == NULL)
+    return false;
+  if (holder->name() == ciSymbol::java_lang_System())
+    // Never trust strangely unstable finals:  System.out, etc.
+    return false;
+  // Even if general trusting is disabled, trust system-built closures in these packages.
+  if (holder->is_in_package("java/dyn") || holder->is_in_package("sun/dyn"))
+    return true;
+  return TrustFinalNonStaticFields;
+}
+
 void ciField::initialize_from(fieldDescriptor* fd) {
   // Get the flags, offset, and canonical holder of the field.
   _flags = ciFlags(fd->access_flags());
@@ -172,7 +184,7 @@
     if (!this->is_static()) {
       // A field can be constant if it's a final static field or if it's
       // a final non-static field of a trusted class ({java,sun}.dyn).
-      if (_holder->is_in_package("java/dyn") || _holder->is_in_package("sun/dyn")) {
+      if (trust_final_non_static_fields(_holder)) {
         _is_constant = true;
         return;
       }
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Wed Jul 05 17:06:00 2017 +0200
@@ -1441,6 +1441,7 @@
 }
 
 jint G1CollectedHeap::initialize() {
+  CollectedHeap::pre_initialize();
   os::enable_vtime();
 
   // Necessary to satisfy locking discipline assertions.
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp	Wed Jul 05 17:06:00 2017 +0200
@@ -1007,6 +1007,10 @@
     return true;
   }
 
+  virtual bool card_mark_must_follow_store() const {
+    return true;
+  }
+
   bool is_in_young(oop obj) {
     HeapRegion* hr = heap_region_containing(obj);
     return hr != NULL && hr->is_young();
--- a/hotspot/src/share/vm/gc_implementation/g1/ptrQueue.cpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/ptrQueue.cpp	Wed Jul 05 17:06:00 2017 +0200
@@ -73,7 +73,12 @@
 
 void PtrQueue::locking_enqueue_completed_buffer(void** buf) {
   assert(_lock->owned_by_self(), "Required.");
+
+  // We have to unlock _lock (which may be Shared_DirtyCardQ_lock) before
+  // we acquire DirtyCardQ_CBL_mon inside enqeue_complete_buffer as they
+  // have the same rank and we may get the "possible deadlock" message
   _lock->unlock();
+
   qset()->enqueue_complete_buffer(buf);
   // We must relock only because the caller will unlock, for the normal
   // case.
@@ -140,7 +145,36 @@
   // holding the lock if there is one).
   if (_buf != NULL) {
     if (_lock) {
-      locking_enqueue_completed_buffer(_buf);
+      assert(_lock->owned_by_self(), "Required.");
+
+      // The current PtrQ may be the shared dirty card queue and
+      // may be being manipulated by more than one worker thread
+      // during a pause. Since the enqueuing of the completed
+      // buffer unlocks the Shared_DirtyCardQ_lock more than one
+      // worker thread can 'race' on reading the shared queue attributes
+      // (_buf and _index) and multiple threads can call into this
+      // routine for the same buffer. This will cause the completed
+      // buffer to be added to the CBL multiple times.
+
+      // We "claim" the current buffer by caching value of _buf in
+      // a local and clearing the field while holding _lock. When
+      // _lock is released (while enqueueing the completed buffer)
+      // the thread that acquires _lock will skip this code,
+      // preventing the subsequent the multiple enqueue, and
+      // install a newly allocated buffer below.
+
+      void** buf = _buf;   // local pointer to completed buffer
+      _buf = NULL;         // clear shared _buf field
+
+      locking_enqueue_completed_buffer(buf);  // enqueue completed buffer
+
+      // While the current thread was enqueuing the buffer another thread
+      // may have a allocated a new buffer and inserted it into this pointer
+      // queue. If that happens then we just return so that the current
+      // thread doesn't overwrite the buffer allocated by the other thread
+      // and potentially losing some dirtied cards.
+
+      if (_buf != NULL) return;
     } else {
       if (qset()->process_or_enqueue_complete_buffer(_buf)) {
         // Recycle the buffer. No allocation.
--- a/hotspot/src/share/vm/gc_implementation/g1/ptrQueue.inline.hpp	Thu Jan 21 11:12:31 2010 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright 2001-2007 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-void PtrQueue::handle_zero_index() {
-  assert(0 == _index, "Precondition.");
-  // This thread records the full buffer and allocates a new one (while
-  // holding the lock if there is one).
-  void** buf = _buf;
-  _buf = qset()->allocate_buffer();
-  _sz = qset()->buffer_size();
-  _index = _sz;
-  assert(0 <= _index && _index <= _sz, "Invariant.");
-  if (buf != NULL) {
-    if (_lock) {
-      locking_enqueue_completed_buffer(buf);
-    } else {
-      qset()->enqueue_complete_buffer(buf);
-    }
-  }
-}
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp	Wed Jul 05 17:06:00 2017 +0200
@@ -51,6 +51,8 @@
 }
 
 jint ParallelScavengeHeap::initialize() {
+  CollectedHeap::pre_initialize();
+
   // Cannot be initialized until after the flags are parsed
   GenerationSizer flag_parser;
 
@@ -717,10 +719,6 @@
   return young_gen()->allocate(size, true);
 }
 
-void ParallelScavengeHeap::fill_all_tlabs(bool retire) {
-  CollectedHeap::fill_all_tlabs(retire);
-}
-
 void ParallelScavengeHeap::accumulate_statistics_all_tlabs() {
   CollectedHeap::accumulate_statistics_all_tlabs();
 }
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp	Wed Jul 05 17:06:00 2017 +0200
@@ -54,7 +54,6 @@
  protected:
   static inline size_t total_invocations();
   HeapWord* allocate_new_tlab(size_t size);
-  void fill_all_tlabs(bool retire);
 
  public:
   ParallelScavengeHeap() : CollectedHeap() {
@@ -191,6 +190,10 @@
     return true;
   }
 
+  virtual bool card_mark_must_follow_store() const {
+    return false;
+  }
+
   // Return true if we don't we need a store barrier for
   // initializing stores to an object at this address.
   virtual bool can_elide_initializing_store_barrier(oop new_obj);
--- a/hotspot/src/share/vm/gc_interface/collectedHeap.cpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/gc_interface/collectedHeap.cpp	Wed Jul 05 17:06:00 2017 +0200
@@ -59,8 +59,18 @@
                 PerfDataManager::create_string_variable(SUN_GC, "lastCause",
                              80, GCCause::to_string(_gc_lastcause), CHECK);
   }
+  _defer_initial_card_mark = false; // strengthened by subclass in pre_initialize() below.
 }
 
+void CollectedHeap::pre_initialize() {
+  // Used for ReduceInitialCardMarks (when COMPILER2 is used);
+  // otherwise remains unused.
+#ifdef COMPLER2
+  _defer_initial_card_mark = ReduceInitialCardMarks && (DeferInitialCardMark || card_mark_must_follow_store());
+#else
+  assert(_defer_initial_card_mark == false, "Who would set it?");
+#endif
+}
 
 #ifndef PRODUCT
 void CollectedHeap::check_for_bad_heap_word_value(HeapWord* addr, size_t size) {
@@ -140,12 +150,13 @@
 void CollectedHeap::flush_deferred_store_barrier(JavaThread* thread) {
   MemRegion deferred = thread->deferred_card_mark();
   if (!deferred.is_empty()) {
+    assert(_defer_initial_card_mark, "Otherwise should be empty");
     {
       // Verify that the storage points to a parsable object in heap
       DEBUG_ONLY(oop old_obj = oop(deferred.start());)
       assert(is_in(old_obj), "Not in allocated heap");
       assert(!can_elide_initializing_store_barrier(old_obj),
-             "Else should have been filtered in defer_store_barrier()");
+             "Else should have been filtered in new_store_pre_barrier()");
       assert(!is_in_permanent(old_obj), "Sanity: not expected");
       assert(old_obj->is_oop(true), "Not an oop");
       assert(old_obj->is_parsable(), "Will not be concurrently parsable");
@@ -174,9 +185,7 @@
 //     so long as the card-mark is completed before the next
 //     scavenge. For all these cases, we can do a card mark
 //     at the point at which we do a slow path allocation
-//     in the old gen. For uniformity, however, we end
-//     up using the same scheme (see below) for all three
-//     cases (deferring the card-mark appropriately).
+//     in the old gen, i.e. in this call.
 // (b) GenCollectedHeap(ConcurrentMarkSweepGeneration) requires
 //     in addition that the card-mark for an old gen allocated
 //     object strictly follow any associated initializing stores.
@@ -199,12 +208,13 @@
 //     but, like in CMS, because of the presence of concurrent refinement
 //     (much like CMS' precleaning), must strictly follow the oop-store.
 //     Thus, using the same protocol for maintaining the intended
-//     invariants turns out, serendepitously, to be the same for all
-//     three collectors/heap types above.
+//     invariants turns out, serendepitously, to be the same for both
+//     G1 and CMS.
 //
-// For each future collector, this should be reexamined with
-// that specific collector in mind.
-oop CollectedHeap::defer_store_barrier(JavaThread* thread, oop new_obj) {
+// For any future collector, this code should be reexamined with
+// that specific collector in mind, and the documentation above suitably
+// extended and updated.
+oop CollectedHeap::new_store_pre_barrier(JavaThread* thread, oop new_obj) {
   // If a previous card-mark was deferred, flush it now.
   flush_deferred_store_barrier(thread);
   if (can_elide_initializing_store_barrier(new_obj)) {
@@ -212,10 +222,17 @@
     // following the flush above.
     assert(thread->deferred_card_mark().is_empty(), "Error");
   } else {
-    // Remember info for the newly deferred store barrier
-    MemRegion deferred = MemRegion((HeapWord*)new_obj, new_obj->size());
-    assert(!deferred.is_empty(), "Error");
-    thread->set_deferred_card_mark(deferred);
+    MemRegion mr((HeapWord*)new_obj, new_obj->size());
+    assert(!mr.is_empty(), "Error");
+    if (_defer_initial_card_mark) {
+      // Defer the card mark
+      thread->set_deferred_card_mark(mr);
+    } else {
+      // Do the card mark
+      BarrierSet* bs = barrier_set();
+      assert(bs->has_write_region_opt(), "No write_region() on BarrierSet");
+      bs->write_region(mr);
+    }
   }
   return new_obj;
 }
@@ -241,9 +258,9 @@
   assert(Universe::heap()->is_in_reserved(start + words - 1), "not in heap");
 }
 
-void CollectedHeap::zap_filler_array(HeapWord* start, size_t words)
+void CollectedHeap::zap_filler_array(HeapWord* start, size_t words, bool zap)
 {
-  if (ZapFillerObjects) {
+  if (ZapFillerObjects && zap) {
     Copy::fill_to_words(start + filler_array_hdr_size(),
                         words - filler_array_hdr_size(), 0XDEAFBABE);
   }
@@ -251,7 +268,7 @@
 #endif // ASSERT
 
 void
-CollectedHeap::fill_with_array(HeapWord* start, size_t words)
+CollectedHeap::fill_with_array(HeapWord* start, size_t words, bool zap)
 {
   assert(words >= filler_array_min_size(), "too small for an array");
   assert(words <= filler_array_max_size(), "too big for a single object");
@@ -262,16 +279,16 @@
   // Set the length first for concurrent GC.
   ((arrayOop)start)->set_length((int)len);
   post_allocation_setup_common(Universe::intArrayKlassObj(), start, words);
-  DEBUG_ONLY(zap_filler_array(start, words);)
+  DEBUG_ONLY(zap_filler_array(start, words, zap);)
 }
 
 void
-CollectedHeap::fill_with_object_impl(HeapWord* start, size_t words)
+CollectedHeap::fill_with_object_impl(HeapWord* start, size_t words, bool zap)
 {
   assert(words <= filler_array_max_size(), "too big for a single object");
 
   if (words >= filler_array_min_size()) {
-    fill_with_array(start, words);
+    fill_with_array(start, words, zap);
   } else if (words > 0) {
     assert(words == min_fill_size(), "unaligned size");
     post_allocation_setup_common(SystemDictionary::Object_klass(), start,
@@ -279,14 +296,14 @@
   }
 }
 
-void CollectedHeap::fill_with_object(HeapWord* start, size_t words)
+void CollectedHeap::fill_with_object(HeapWord* start, size_t words, bool zap)
 {
   DEBUG_ONLY(fill_args_check(start, words);)
   HandleMark hm;  // Free handles before leaving.
-  fill_with_object_impl(start, words);
+  fill_with_object_impl(start, words, zap);
 }
 
-void CollectedHeap::fill_with_objects(HeapWord* start, size_t words)
+void CollectedHeap::fill_with_objects(HeapWord* start, size_t words, bool zap)
 {
   DEBUG_ONLY(fill_args_check(start, words);)
   HandleMark hm;  // Free handles before leaving.
@@ -299,13 +316,13 @@
   const size_t max = filler_array_max_size();
   while (words > max) {
     const size_t cur = words - max >= min ? max : max - min;
-    fill_with_array(start, cur);
+    fill_with_array(start, cur, zap);
     start += cur;
     words -= cur;
   }
 #endif
 
-  fill_with_object_impl(start, words);
+  fill_with_object_impl(start, words, zap);
 }
 
 HeapWord* CollectedHeap::allocate_new_tlab(size_t size) {
@@ -313,22 +330,6 @@
   return NULL;
 }
 
-void CollectedHeap::fill_all_tlabs(bool retire) {
-  assert(UseTLAB, "should not reach here");
-  // See note in ensure_parsability() below.
-  assert(SafepointSynchronize::is_at_safepoint() ||
-         !is_init_completed(),
-         "should only fill tlabs at safepoint");
-  // The main thread starts allocating via a TLAB even before it
-  // has added itself to the threads list at vm boot-up.
-  assert(Threads::first() != NULL,
-         "Attempt to fill tlabs before main thread has been added"
-         " to threads list is doomed to failure!");
-  for(JavaThread *thread = Threads::first(); thread; thread = thread->next()) {
-     thread->tlab().make_parsable(retire);
-  }
-}
-
 void CollectedHeap::ensure_parsability(bool retire_tlabs) {
   // The second disjunct in the assertion below makes a concession
   // for the start-up verification done while the VM is being
@@ -343,8 +344,24 @@
          "Should only be called at a safepoint or at start-up"
          " otherwise concurrent mutator activity may make heap "
          " unparsable again");
-  if (UseTLAB) {
-    fill_all_tlabs(retire_tlabs);
+  const bool use_tlab = UseTLAB;
+  const bool deferred = _defer_initial_card_mark;
+  // The main thread starts allocating via a TLAB even before it
+  // has added itself to the threads list at vm boot-up.
+  assert(!use_tlab || Threads::first() != NULL,
+         "Attempt to fill tlabs before main thread has been added"
+         " to threads list is doomed to failure!");
+  for (JavaThread *thread = Threads::first(); thread; thread = thread->next()) {
+     if (use_tlab) thread->tlab().make_parsable(retire_tlabs);
+#ifdef COMPILER2
+     // The deferred store barriers must all have been flushed to the
+     // card-table (or other remembered set structure) before GC starts
+     // processing the card-table (or other remembered set).
+     if (deferred) flush_deferred_store_barrier(thread);
+#else
+     assert(!deferred, "Should be false");
+     assert(thread->deferred_card_mark().is_empty(), "Should be empty");
+#endif
   }
 }
 
--- a/hotspot/src/share/vm/gc_interface/collectedHeap.hpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/gc_interface/collectedHeap.hpp	Wed Jul 05 17:06:00 2017 +0200
@@ -51,6 +51,9 @@
   // Used for filler objects (static, but initialized in ctor).
   static size_t _filler_array_max_size;
 
+  // Used in support of ReduceInitialCardMarks; only consulted if COMPILER2 is being used
+  bool _defer_initial_card_mark;
+
  protected:
   MemRegion _reserved;
   BarrierSet* _barrier_set;
@@ -70,13 +73,16 @@
   // Constructor
   CollectedHeap();
 
+  // Do common initializations that must follow instance construction,
+  // for example, those needing virtual calls.
+  // This code could perhaps be moved into initialize() but would
+  // be slightly more awkward because we want the latter to be a
+  // pure virtual.
+  void pre_initialize();
+
   // Create a new tlab
   virtual HeapWord* allocate_new_tlab(size_t size);
 
-  // Fix up tlabs to make the heap well-formed again,
-  // optionally retiring the tlabs.
-  virtual void fill_all_tlabs(bool retire);
-
   // Accumulate statistics on all tlabs.
   virtual void accumulate_statistics_all_tlabs();
 
@@ -127,14 +133,14 @@
   static inline size_t filler_array_max_size();
 
   DEBUG_ONLY(static void fill_args_check(HeapWord* start, size_t words);)
-  DEBUG_ONLY(static void zap_filler_array(HeapWord* start, size_t words);)
+  DEBUG_ONLY(static void zap_filler_array(HeapWord* start, size_t words, bool zap = true);)
 
   // Fill with a single array; caller must ensure filler_array_min_size() <=
   // words <= filler_array_max_size().
-  static inline void fill_with_array(HeapWord* start, size_t words);
+  static inline void fill_with_array(HeapWord* start, size_t words, bool zap = true);
 
   // Fill with a single object (either an int array or a java.lang.Object).
-  static inline void fill_with_object_impl(HeapWord* start, size_t words);
+  static inline void fill_with_object_impl(HeapWord* start, size_t words, bool zap = true);
 
   // Verification functions
   virtual void check_for_bad_heap_word_value(HeapWord* addr, size_t size)
@@ -338,14 +344,14 @@
     return size_t(align_object_size(oopDesc::header_size()));
   }
 
-  static void fill_with_objects(HeapWord* start, size_t words);
+  static void fill_with_objects(HeapWord* start, size_t words, bool zap = true);
 
-  static void fill_with_object(HeapWord* start, size_t words);
-  static void fill_with_object(MemRegion region) {
-    fill_with_object(region.start(), region.word_size());
+  static void fill_with_object(HeapWord* start, size_t words, bool zap = true);
+  static void fill_with_object(MemRegion region, bool zap = true) {
+    fill_with_object(region.start(), region.word_size(), zap);
   }
-  static void fill_with_object(HeapWord* start, HeapWord* end) {
-    fill_with_object(start, pointer_delta(end, start));
+  static void fill_with_object(HeapWord* start, HeapWord* end, bool zap = true) {
+    fill_with_object(start, pointer_delta(end, start), zap);
   }
 
   // Some heaps may offer a contiguous region for shared non-blocking
@@ -431,14 +437,25 @@
   // promises to call this function on such a slow-path-allocated
   // object before performing initializations that have elided
   // store barriers. Returns new_obj, or maybe a safer copy thereof.
-  virtual oop defer_store_barrier(JavaThread* thread, oop new_obj);
+  virtual oop new_store_pre_barrier(JavaThread* thread, oop new_obj);
 
   // Answers whether an initializing store to a new object currently
-  // allocated at the given address doesn't need a (deferred) store
+  // allocated at the given address doesn't need a store
   // barrier. Returns "true" if it doesn't need an initializing
   // store barrier; answers "false" if it does.
   virtual bool can_elide_initializing_store_barrier(oop new_obj) = 0;
 
+  // If a compiler is eliding store barriers for TLAB-allocated objects,
+  // we will be informed of a slow-path allocation by a call
+  // to new_store_pre_barrier() above. Such a call precedes the
+  // initialization of the object itself, and no post-store-barriers will
+  // be issued. Some heap types require that the barrier strictly follows
+  // the initializing stores. (This is currently implemented by deferring the
+  // barrier until the next slow-path allocation or gc-related safepoint.)
+  // This interface answers whether a particular heap type needs the card
+  // mark to be thus strictly sequenced after the stores.
+  virtual bool card_mark_must_follow_store() const = 0;
+
   // If the CollectedHeap was asked to defer a store barrier above,
   // this informs it to flush such a deferred store barrier to the
   // remembered set.
--- a/hotspot/src/share/vm/includeDB_compiler2	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/includeDB_compiler2	Wed Jul 05 17:06:00 2017 +0200
@@ -601,6 +601,7 @@
 
 loopTransform.cpp                       addnode.hpp
 loopTransform.cpp                       allocation.inline.hpp
+loopTransform.cpp                       callnode.hpp
 loopTransform.cpp                       connode.hpp
 loopTransform.cpp                       compileLog.hpp
 loopTransform.cpp                       divnode.hpp
--- a/hotspot/src/share/vm/interpreter/abstractInterpreter.hpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/interpreter/abstractInterpreter.hpp	Wed Jul 05 17:06:00 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-2010 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -109,6 +109,8 @@
 
   static void       print_method_kind(MethodKind kind)          PRODUCT_RETURN;
 
+  static bool       can_be_compiled(methodHandle m);
+
   // Runtime support
 
   // length = invoke bytecode length (to advance to next bytecode)
--- a/hotspot/src/share/vm/memory/genCollectedHeap.cpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/memory/genCollectedHeap.cpp	Wed Jul 05 17:06:00 2017 +0200
@@ -51,6 +51,8 @@
 }
 
 jint GenCollectedHeap::initialize() {
+  CollectedHeap::pre_initialize();
+
   int i;
   _n_gens = gen_policy()->number_of_generations();
 
@@ -129,6 +131,7 @@
 
   _rem_set = collector_policy()->create_rem_set(_reserved, n_covered_regions);
   set_barrier_set(rem_set()->bs());
+
   _gch = this;
 
   for (i = 0; i < _n_gens; i++) {
--- a/hotspot/src/share/vm/memory/genCollectedHeap.hpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/memory/genCollectedHeap.hpp	Wed Jul 05 17:06:00 2017 +0200
@@ -260,6 +260,10 @@
     return true;
   }
 
+  virtual bool card_mark_must_follow_store() const {
+    return UseConcMarkSweepGC;
+  }
+
   // We don't need barriers for stores to objects in the
   // young gen and, a fortiori, for initializing stores to
   // objects therein. This applies to {DefNew,ParNew}+{Tenured,CMS}
--- a/hotspot/src/share/vm/memory/threadLocalAllocBuffer.cpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/memory/threadLocalAllocBuffer.cpp	Wed Jul 05 17:06:00 2017 +0200
@@ -100,7 +100,7 @@
 void ThreadLocalAllocBuffer::make_parsable(bool retire) {
   if (end() != NULL) {
     invariants();
-    CollectedHeap::fill_with_object(top(), hard_end());
+    CollectedHeap::fill_with_object(top(), hard_end(), retire);
 
     if (retire || ZeroTLAB) {  // "Reset" the TLAB
       set_start(NULL);
--- a/hotspot/src/share/vm/memory/threadLocalAllocBuffer.inline.hpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/memory/threadLocalAllocBuffer.inline.hpp	Wed Jul 05 17:06:00 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,8 +27,13 @@
   HeapWord* obj = top();
   if (pointer_delta(end(), obj) >= size) {
     // successful thread-local allocation
-
-    DEBUG_ONLY(Copy::fill_to_words(obj, size, badHeapWordVal));
+#ifdef ASSERT
+    // Skip mangling the space corresponding to the object header to
+    // ensure that the returned space is not considered parsable by
+    // any concurrent GC thread.
+    size_t hdr_size = CollectedHeap::min_fill_size();
+    Copy::fill_to_words(obj + hdr_size, size - hdr_size, badHeapWordVal);
+#endif // ASSERT
     // This addition is safe because we know that top is
     // at least size below end, so the add can't wrap.
     set_top(obj + size);
--- a/hotspot/src/share/vm/opto/c2_globals.hpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/opto/c2_globals.hpp	Wed Jul 05 17:06:00 2017 +0200
@@ -154,6 +154,12 @@
   notproduct(bool, TraceProfileTripCount, false,                            \
           "Trace profile loop trip count information")                      \
                                                                             \
+  product(bool, UseLoopPredicate, true,                                     \
+          "Generate a predicate to select fast/slow loop versions")         \
+                                                                            \
+  develop(bool, TraceLoopPredicate, false,                                  \
+          "Trace generation of loop predicates")                            \
+                                                                            \
   develop(bool, OptoCoalesce, true,                                         \
           "Use Conservative Copy Coalescing in the Register Allocator")     \
                                                                             \
--- a/hotspot/src/share/vm/opto/compile.cpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/opto/compile.cpp	Wed Jul 05 17:06:00 2017 +0200
@@ -932,6 +932,7 @@
 
   _intrinsics = NULL;
   _macro_nodes = new GrowableArray<Node*>(comp_arena(), 8,  0, NULL);
+  _predicate_opaqs = new GrowableArray<Node*>(comp_arena(), 8,  0, NULL);
   register_library_intrinsics();
 }
 
@@ -1553,6 +1554,19 @@
   }
 }
 
+//---------------------cleanup_loop_predicates-----------------------
+// Remove the opaque nodes that protect the predicates so that all unused
+// checks and uncommon_traps will be eliminated from the ideal graph
+void Compile::cleanup_loop_predicates(PhaseIterGVN &igvn) {
+  if (predicate_count()==0) return;
+  for (int i = predicate_count(); i > 0; i--) {
+    Node * n = predicate_opaque1_node(i-1);
+    assert(n->Opcode() == Op_Opaque1, "must be");
+    igvn.replace_node(n, n->in(1));
+  }
+  assert(predicate_count()==0, "should be clean!");
+  igvn.optimize();
+}
 
 //------------------------------Optimize---------------------------------------
 // Given a graph, optimize it.
@@ -1594,7 +1608,7 @@
   if((loop_opts_cnt > 0) && (has_loops() || has_split_ifs())) {
     {
       TracePhase t2("idealLoop", &_t_idealLoop, true);
-      PhaseIdealLoop ideal_loop( igvn, true );
+      PhaseIdealLoop ideal_loop( igvn, true, UseLoopPredicate);
       loop_opts_cnt--;
       if (major_progress()) print_method("PhaseIdealLoop 1", 2);
       if (failing())  return;
@@ -1602,7 +1616,7 @@
     // Loop opts pass if partial peeling occurred in previous pass
     if(PartialPeelLoop && major_progress() && (loop_opts_cnt > 0)) {
       TracePhase t3("idealLoop", &_t_idealLoop, true);
-      PhaseIdealLoop ideal_loop( igvn, false );
+      PhaseIdealLoop ideal_loop( igvn, false, UseLoopPredicate);
       loop_opts_cnt--;
       if (major_progress()) print_method("PhaseIdealLoop 2", 2);
       if (failing())  return;
@@ -1610,7 +1624,7 @@
     // Loop opts pass for loop-unrolling before CCP
     if(major_progress() && (loop_opts_cnt > 0)) {
       TracePhase t4("idealLoop", &_t_idealLoop, true);
-      PhaseIdealLoop ideal_loop( igvn, false );
+      PhaseIdealLoop ideal_loop( igvn, false, UseLoopPredicate);
       loop_opts_cnt--;
       if (major_progress()) print_method("PhaseIdealLoop 3", 2);
     }
@@ -1648,13 +1662,21 @@
   // peeling, unrolling, etc.
   if(loop_opts_cnt > 0) {
     debug_only( int cnt = 0; );
+    bool loop_predication = UseLoopPredicate;
     while(major_progress() && (loop_opts_cnt > 0)) {
       TracePhase t2("idealLoop", &_t_idealLoop, true);
       assert( cnt++ < 40, "infinite cycle in loop optimization" );
-      PhaseIdealLoop ideal_loop( igvn, true );
+      PhaseIdealLoop ideal_loop( igvn, true, loop_predication);
       loop_opts_cnt--;
       if (major_progress()) print_method("PhaseIdealLoop iterations", 2);
       if (failing())  return;
+      // Perform loop predication optimization during first iteration after CCP.
+      // After that switch it off and cleanup unused loop predicates.
+      if (loop_predication) {
+        loop_predication = false;
+        cleanup_loop_predicates(igvn);
+        if (failing())  return;
+      }
     }
   }
 
--- a/hotspot/src/share/vm/opto/compile.hpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/opto/compile.hpp	Wed Jul 05 17:06:00 2017 +0200
@@ -38,6 +38,7 @@
 class OptoReg;
 class PhaseCFG;
 class PhaseGVN;
+class PhaseIterGVN;
 class PhaseRegAlloc;
 class PhaseCCP;
 class PhaseCCP_DCE;
@@ -172,6 +173,7 @@
   const char*           _failure_reason;        // for record_failure/failing pattern
   GrowableArray<CallGenerator*>* _intrinsics;   // List of intrinsics.
   GrowableArray<Node*>* _macro_nodes;           // List of nodes which need to be expanded before matching.
+  GrowableArray<Node*>* _predicate_opaqs;       // List of Opaque1 nodes for the loop predicates.
   ConnectionGraph*      _congraph;
 #ifndef PRODUCT
   IdealGraphPrinter*    _printer;
@@ -351,7 +353,9 @@
   }
 
   int           macro_count()                   { return _macro_nodes->length(); }
+  int           predicate_count()               { return _predicate_opaqs->length();}
   Node*         macro_node(int idx)             { return _macro_nodes->at(idx); }
+  Node*         predicate_opaque1_node(int idx) { return _predicate_opaqs->at(idx);}
   ConnectionGraph* congraph()                   { return _congraph;}
   void add_macro_node(Node * n) {
     //assert(n->is_macro(), "must be a macro node");
@@ -363,7 +367,19 @@
     // that the node is in the array before attempting to remove it
     if (_macro_nodes->contains(n))
       _macro_nodes->remove(n);
+    // remove from _predicate_opaqs list also if it is there
+    if (predicate_count() > 0 && _predicate_opaqs->contains(n)){
+      _predicate_opaqs->remove(n);
+    }
   }
+  void add_predicate_opaq(Node * n) {
+    assert(!_predicate_opaqs->contains(n), " duplicate entry in predicate opaque1");
+    assert(_macro_nodes->contains(n), "should have already been in macro list");
+    _predicate_opaqs->append(n);
+  }
+  // remove the opaque nodes that protect the predicates so that the unused checks and
+  // uncommon traps will be eliminated from the graph.
+  void cleanup_loop_predicates(PhaseIterGVN &igvn);
 
   // Compilation environment.
   Arena*            comp_arena()                { return &_comp_arena; }
--- a/hotspot/src/share/vm/opto/graphKit.cpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/opto/graphKit.cpp	Wed Jul 05 17:06:00 2017 +0200
@@ -3259,9 +3259,10 @@
   if (use_ReduceInitialCardMarks()
       && obj == just_allocated_object(control())) {
     // We can skip marks on a freshly-allocated object in Eden.
-    // Keep this code in sync with maybe_defer_card_mark() in runtime.cpp.
-    // That routine informs GC to take appropriate compensating steps
-    // so as to make this card-mark elision safe.
+    // Keep this code in sync with new_store_pre_barrier() in runtime.cpp.
+    // That routine informs GC to take appropriate compensating steps,
+    // upon a slow-path allocation, so as to make this card-mark
+    // elision safe.
     return;
   }
 
--- a/hotspot/src/share/vm/opto/loopTransform.cpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/opto/loopTransform.cpp	Wed Jul 05 17:06:00 2017 +0200
@@ -549,6 +549,10 @@
       // Comparing trip+off vs limit
       Node *bol = iff->in(1);
       if( bol->req() != 2 ) continue; // dead constant test
+      if (!bol->is_Bool()) {
+        assert(UseLoopPredicate && bol->Opcode() == Op_Conv2B, "predicate check only");
+        continue;
+      }
       Node *cmp = bol->in(1);
 
       Node *rc_exp = cmp->in(1);
@@ -875,7 +879,7 @@
 //------------------------------is_invariant-----------------------------
 // Return true if n is invariant
 bool IdealLoopTree::is_invariant(Node* n) const {
-  Node *n_c = _phase->get_ctrl(n);
+  Node *n_c = _phase->has_ctrl(n) ? _phase->get_ctrl(n) : n;
   if (n_c->is_top()) return false;
   return !is_member(_phase->get_loop(n_c));
 }
@@ -1594,7 +1598,7 @@
 bool IdealLoopTree::iteration_split_impl( PhaseIdealLoop *phase, Node_List &old_new ) {
   // Check and remove empty loops (spam micro-benchmarks)
   if( policy_do_remove_empty_loop(phase) )
-    return true;                     // Here we removed an empty loop
+    return true;  // Here we removed an empty loop
 
   bool should_peel = policy_peeling(phase); // Should we peel?
 
@@ -1688,8 +1692,8 @@
     // an even number of trips).  If we are peeling, we might enable some RCE
     // and we'd rather unroll the post-RCE'd loop SO... do not unroll if
     // peeling.
-    if( should_unroll && !should_peel )
-      phase->do_unroll(this,old_new, true);
+      if( should_unroll && !should_peel )
+        phase->do_unroll(this,old_new, true);
 
     // Adjust the pre-loop limits to align the main body
     // iterations.
@@ -1731,9 +1735,9 @@
       _allow_optimizations &&
       !tail()->is_top() ) {     // Also ignore the occasional dead backedge
     if (!_has_call) {
-      if (!iteration_split_impl( phase, old_new )) {
-        return false;
-      }
+        if (!iteration_split_impl( phase, old_new )) {
+          return false;
+        }
     } else if (policy_unswitching(phase)) {
       phase->do_unswitching(this, old_new);
     }
@@ -1746,3 +1750,576 @@
     return false;
   return true;
 }
+
+//-------------------------------is_uncommon_trap_proj----------------------------
+// Return true if proj is the form of "proj->[region->..]call_uct"
+bool PhaseIdealLoop::is_uncommon_trap_proj(ProjNode* proj, bool must_reason_predicate) {
+  int path_limit = 10;
+  assert(proj, "invalid argument");
+  Node* out = proj;
+  for (int ct = 0; ct < path_limit; ct++) {
+    out = out->unique_ctrl_out();
+    if (out == NULL || out->is_Root() || out->is_Start())
+      return false;
+    if (out->is_CallStaticJava()) {
+      int req = out->as_CallStaticJava()->uncommon_trap_request();
+      if (req != 0) {
+        Deoptimization::DeoptReason reason = Deoptimization::trap_request_reason(req);
+        if (!must_reason_predicate || reason == Deoptimization::Reason_predicate){
+           return true;
+        }
+      }
+      return false; // don't do further after call
+    }
+  }
+  return false;
+}
+
+//-------------------------------is_uncommon_trap_if_pattern-------------------------
+// Return true  for "if(test)-> proj -> ...
+//                          |
+//                          V
+//                      other_proj->[region->..]call_uct"
+//
+// "must_reason_predicate" means the uct reason must be Reason_predicate
+bool PhaseIdealLoop::is_uncommon_trap_if_pattern(ProjNode *proj, bool must_reason_predicate) {
+  Node *in0 = proj->in(0);
+  if (!in0->is_If()) return false;
+  IfNode* iff = in0->as_If();
+
+  // we need "If(Conv2B(Opaque1(...)))" pattern for must_reason_predicate
+  if (must_reason_predicate) {
+    if (iff->in(1)->Opcode() != Op_Conv2B ||
+       iff->in(1)->in(1)->Opcode() != Op_Opaque1) {
+      return false;
+    }
+  }
+
+  ProjNode* other_proj = iff->proj_out(1-proj->_con)->as_Proj();
+  return is_uncommon_trap_proj(other_proj, must_reason_predicate);
+}
+
+//------------------------------create_new_if_for_predicate------------------------
+// create a new if above the uct_if_pattern for the predicate to be promoted.
+//
+//          before                                after
+//        ----------                           ----------
+//           ctrl                                 ctrl
+//            |                                     |
+//            |                                     |
+//            v                                     v
+//           iff                                 new_iff
+//          /    \                                /      \
+//         /      \                              /        \
+//        v        v                            v          v
+//  uncommon_proj cont_proj                   if_uct     if_cont
+// \      |        |                           |          |
+//  \     |        |                           |          |
+//   v    v        v                           |          v
+//     rgn       loop                          |         iff
+//      |                                      |        /     \
+//      |                                      |       /       \
+//      v                                      |      v         v
+// uncommon_trap                               | uncommon_proj cont_proj
+//                                           \  \    |           |
+//                                            \  \   |           |
+//                                             v  v  v           v
+//                                               rgn           loop
+//                                                |
+//                                                |
+//                                                v
+//                                           uncommon_trap
+//
+//
+// We will create a region to guard the uct call if there is no one there.
+// The true projecttion (if_cont) of the new_iff is returned.
+ProjNode* PhaseIdealLoop::create_new_if_for_predicate(ProjNode* cont_proj) {
+  assert(is_uncommon_trap_if_pattern(cont_proj, true), "must be a uct if pattern!");
+  IfNode* iff = cont_proj->in(0)->as_If();
+
+  ProjNode *uncommon_proj = iff->proj_out(1 - cont_proj->_con);
+  Node     *rgn   = uncommon_proj->unique_ctrl_out();
+  assert(rgn->is_Region() || rgn->is_Call(), "must be a region or call uct");
+
+  if (!rgn->is_Region()) { // create a region to guard the call
+    assert(rgn->is_Call(), "must be call uct");
+    CallNode* call = rgn->as_Call();
+    rgn = new (C, 1) RegionNode(1);
+    _igvn.set_type(rgn, rgn->bottom_type());
+    rgn->add_req(uncommon_proj);
+    set_idom(rgn, idom(uncommon_proj), dom_depth(uncommon_proj)+1);
+    _igvn.hash_delete(call);
+    call->set_req(0, rgn);
+  }
+
+  // Create new_iff
+  uint  iffdd  = dom_depth(iff);
+  IdealLoopTree* lp = get_loop(iff);
+  IfNode *new_iff = new (C, 2) IfNode(iff->in(0), NULL, iff->_prob, iff->_fcnt);
+  register_node(new_iff, lp, idom(iff), iffdd);
+  Node *if_cont = new (C, 1) IfTrueNode(new_iff);
+  Node *if_uct  = new (C, 1) IfFalseNode(new_iff);
+  if (cont_proj->is_IfFalse()) {
+    // Swap
+    Node* tmp = if_uct; if_uct = if_cont; if_cont = tmp;
+  }
+  register_node(if_cont, lp, new_iff, iffdd);
+  register_node(if_uct, get_loop(rgn), new_iff, iffdd);
+
+  // if_cont to iff
+  _igvn.hash_delete(iff);
+  iff->set_req(0, if_cont);
+  set_idom(iff, if_cont, dom_depth(iff));
+
+  // if_uct to rgn
+  _igvn.hash_delete(rgn);
+  rgn->add_req(if_uct);
+  Node* ridom = idom(rgn);
+  Node* nrdom = dom_lca(ridom, new_iff);
+  set_idom(rgn, nrdom, dom_depth(rgn));
+
+  // rgn must have no phis
+  assert(!rgn->as_Region()->has_phi(), "region must have no phis");
+
+  return if_cont->as_Proj();
+}
+
+//------------------------------find_predicate_insertion_point--------------------------
+// Find a good location to insert a predicate
+ProjNode* PhaseIdealLoop::find_predicate_insertion_point(Node* start_c) {
+  if (start_c == C->root() || !start_c->is_Proj())
+    return NULL;
+  if (is_uncommon_trap_if_pattern(start_c->as_Proj(), true/*Reason_Predicate*/)) {
+    return start_c->as_Proj();
+  }
+  return NULL;
+}
+
+//------------------------------Invariance-----------------------------------
+// Helper class for loop_predication_impl to compute invariance on the fly and
+// clone invariants.
+class Invariance : public StackObj {
+  VectorSet _visited, _invariant;
+  Node_Stack _stack;
+  VectorSet _clone_visited;
+  Node_List _old_new; // map of old to new (clone)
+  IdealLoopTree* _lpt;
+  PhaseIdealLoop* _phase;
+
+  // Helper function to set up the invariance for invariance computation
+  // If n is a known invariant, set up directly. Otherwise, look up the
+  // the possibility to push n onto the stack for further processing.
+  void visit(Node* use, Node* n) {
+    if (_lpt->is_invariant(n)) { // known invariant
+      _invariant.set(n->_idx);
+    } else if (!n->is_CFG()) {
+      Node *n_ctrl = _phase->ctrl_or_self(n);
+      Node *u_ctrl = _phase->ctrl_or_self(use); // self if use is a CFG
+      if (_phase->is_dominator(n_ctrl, u_ctrl)) {
+        _stack.push(n, n->in(0) == NULL ? 1 : 0);
+      }
+    }
+  }
+
+  // Compute invariance for "the_node" and (possibly) all its inputs recursively
+  // on the fly
+  void compute_invariance(Node* n) {
+    assert(_visited.test(n->_idx), "must be");
+    visit(n, n);
+    while (_stack.is_nonempty()) {
+      Node*  n = _stack.node();
+      uint idx = _stack.index();
+      if (idx == n->req()) { // all inputs are processed
+        _stack.pop();
+        // n is invariant if it's inputs are all invariant
+        bool all_inputs_invariant = true;
+        for (uint i = 0; i < n->req(); i++) {
+          Node* in = n->in(i);
+          if (in == NULL) continue;
+          assert(_visited.test(in->_idx), "must have visited input");
+          if (!_invariant.test(in->_idx)) { // bad guy
+            all_inputs_invariant = false;
+            break;
+          }
+        }
+        if (all_inputs_invariant) {
+          _invariant.set(n->_idx); // I am a invariant too
+        }
+      } else { // process next input
+        _stack.set_index(idx + 1);
+        Node* m = n->in(idx);
+        if (m != NULL && !_visited.test_set(m->_idx)) {
+          visit(n, m);
+        }
+      }
+    }
+  }
+
+  // Helper function to set up _old_new map for clone_nodes.
+  // If n is a known invariant, set up directly ("clone" of n == n).
+  // Otherwise, push n onto the stack for real cloning.
+  void clone_visit(Node* n) {
+    assert(_invariant.test(n->_idx), "must be invariant");
+    if (_lpt->is_invariant(n)) { // known invariant
+      _old_new.map(n->_idx, n);
+    } else{ // to be cloned
+      assert (!n->is_CFG(), "should not see CFG here");
+      _stack.push(n, n->in(0) == NULL ? 1 : 0);
+    }
+  }
+
+  // Clone "n" and (possibly) all its inputs recursively
+  void clone_nodes(Node* n, Node* ctrl) {
+    clone_visit(n);
+    while (_stack.is_nonempty()) {
+      Node*  n = _stack.node();
+      uint idx = _stack.index();
+      if (idx == n->req()) { // all inputs processed, clone n!
+        _stack.pop();
+        // clone invariant node
+        Node* n_cl = n->clone();
+        _old_new.map(n->_idx, n_cl);
+        _phase->register_new_node(n_cl, ctrl);
+        for (uint i = 0; i < n->req(); i++) {
+          Node* in = n_cl->in(i);
+          if (in == NULL) continue;
+          n_cl->set_req(i, _old_new[in->_idx]);
+        }
+      } else { // process next input
+        _stack.set_index(idx + 1);
+        Node* m = n->in(idx);
+        if (m != NULL && !_clone_visited.test_set(m->_idx)) {
+          clone_visit(m); // visit the input
+        }
+      }
+    }
+  }
+
+ public:
+  Invariance(Arena* area, IdealLoopTree* lpt) :
+    _lpt(lpt), _phase(lpt->_phase),
+    _visited(area), _invariant(area), _stack(area, 10 /* guess */),
+    _clone_visited(area), _old_new(area)
+  {}
+
+  // Map old to n for invariance computation and clone
+  void map_ctrl(Node* old, Node* n) {
+    assert(old->is_CFG() && n->is_CFG(), "must be");
+    _old_new.map(old->_idx, n); // "clone" of old is n
+    _invariant.set(old->_idx);  // old is invariant
+    _clone_visited.set(old->_idx);
+  }
+
+  // Driver function to compute invariance
+  bool is_invariant(Node* n) {
+    if (!_visited.test_set(n->_idx))
+      compute_invariance(n);
+    return (_invariant.test(n->_idx) != 0);
+  }
+
+  // Driver function to clone invariant
+  Node* clone(Node* n, Node* ctrl) {
+    assert(ctrl->is_CFG(), "must be");
+    assert(_invariant.test(n->_idx), "must be an invariant");
+    if (!_clone_visited.test(n->_idx))
+      clone_nodes(n, ctrl);
+    return _old_new[n->_idx];
+  }
+};
+
+//------------------------------is_range_check_if -----------------------------------
+// Returns true if the predicate of iff is in "scale*iv + offset u< load_range(ptr)" format
+// Note: this function is particularly designed for loop predication. We require load_range
+//       and offset to be loop invariant computed on the fly by "invar"
+bool IdealLoopTree::is_range_check_if(IfNode *iff, PhaseIdealLoop *phase, Invariance& invar) const {
+  if (!is_loop_exit(iff)) {
+    return false;
+  }
+  if (!iff->in(1)->is_Bool()) {
+    return false;
+  }
+  const BoolNode *bol = iff->in(1)->as_Bool();
+  if (bol->_test._test != BoolTest::lt) {
+    return false;
+  }
+  if (!bol->in(1)->is_Cmp()) {
+    return false;
+  }
+  const CmpNode *cmp = bol->in(1)->as_Cmp();
+  if (cmp->Opcode() != Op_CmpU ) {
+    return false;
+  }
+  if (cmp->in(2)->Opcode() != Op_LoadRange) {
+    return false;
+  }
+  LoadRangeNode* lr = (LoadRangeNode*)cmp->in(2);
+  if (!invar.is_invariant(lr)) { // loadRange must be invariant
+    return false;
+  }
+  Node *iv     = _head->as_CountedLoop()->phi();
+  int   scale  = 0;
+  Node *offset = NULL;
+  if (!phase->is_scaled_iv_plus_offset(cmp->in(1), iv, &scale, &offset)) {
+    return false;
+  }
+  if(offset && !invar.is_invariant(offset)) { // offset must be invariant
+    return false;
+  }
+  return true;
+}
+
+//------------------------------rc_predicate-----------------------------------
+// Create a range check predicate
+//
+// for (i = init; i < limit; i += stride) {
+//    a[scale*i+offset]
+// }
+//
+// Compute max(scale*i + offset) for init <= i < limit and build the predicate
+// as "max(scale*i + offset) u< a.length".
+//
+// There are two cases for max(scale*i + offset):
+// (1) stride*scale > 0
+//   max(scale*i + offset) = scale*(limit-stride) + offset
+// (2) stride*scale < 0
+//   max(scale*i + offset) = scale*init + offset
+BoolNode* PhaseIdealLoop::rc_predicate(Node* ctrl,
+                                       int scale, Node* offset,
+                                       Node* init, Node* limit, Node* stride,
+                                       Node* range) {
+  Node* max_idx_expr  = init;
+  int stride_con = stride->get_int();
+  if ((stride_con > 0) == (scale > 0)) {
+    max_idx_expr = new (C, 3) SubINode(limit, stride);
+    register_new_node(max_idx_expr, ctrl);
+  }
+
+  if (scale != 1) {
+    ConNode* con_scale = _igvn.intcon(scale);
+    max_idx_expr = new (C, 3) MulINode(max_idx_expr, con_scale);
+    register_new_node(max_idx_expr, ctrl);
+  }
+
+  if (offset && (!offset->is_Con() || offset->get_int() != 0)){
+    max_idx_expr = new (C, 3) AddINode(max_idx_expr, offset);
+    register_new_node(max_idx_expr, ctrl);
+  }
+
+  CmpUNode* cmp = new (C, 3) CmpUNode(max_idx_expr, range);
+  register_new_node(cmp, ctrl);
+  BoolNode* bol = new (C, 2) BoolNode(cmp, BoolTest::lt);
+  register_new_node(bol, ctrl);
+  return bol;
+}
+
+//------------------------------ loop_predication_impl--------------------------
+// Insert loop predicates for null checks and range checks
+bool PhaseIdealLoop::loop_predication_impl(IdealLoopTree *loop) {
+  if (!UseLoopPredicate) return false;
+
+  // Too many traps seen?
+  bool tmt = C->too_many_traps(C->method(), 0, Deoptimization::Reason_predicate);
+  int tc = C->trap_count(Deoptimization::Reason_predicate);
+  if (tmt || tc > 0) {
+    if (TraceLoopPredicate) {
+      tty->print_cr("too many predicate traps: %d", tc);
+      C->method()->print(); // which method has too many predicate traps
+      tty->print_cr("");
+    }
+    return false;
+  }
+
+  CountedLoopNode *cl = NULL;
+  if (loop->_head->is_CountedLoop()) {
+    cl = loop->_head->as_CountedLoop();
+    // do nothing for iteration-splitted loops
+    if(!cl->is_normal_loop()) return false;
+  }
+
+  LoopNode *lpn  = loop->_head->as_Loop();
+  Node* entry = lpn->in(LoopNode::EntryControl);
+
+  ProjNode *predicate_proj = find_predicate_insertion_point(entry);
+  if (!predicate_proj){
+#ifndef PRODUCT
+    if (TraceLoopPredicate) {
+      tty->print("missing predicate:");
+      loop->dump_head();
+    }
+#endif
+    return false;
+  }
+
+  ConNode* zero = _igvn.intcon(0);
+  set_ctrl(zero, C->root());
+  Node *cond_false = new (C, 2) Conv2BNode(zero);
+  register_new_node(cond_false, C->root());
+  ConNode* one = _igvn.intcon(1);
+  set_ctrl(one, C->root());
+  Node *cond_true = new (C, 2) Conv2BNode(one);
+  register_new_node(cond_true, C->root());
+
+  ResourceArea *area = Thread::current()->resource_area();
+  Invariance invar(area, loop);
+
+  // Create list of if-projs such that a newer proj dominates all older
+  // projs in the list, and they all dominate loop->tail()
+  Node_List if_proj_list(area);
+  LoopNode *head  = loop->_head->as_Loop();
+  Node *current_proj = loop->tail(); //start from tail
+  while ( current_proj != head ) {
+    if (loop == get_loop(current_proj) && // still in the loop ?
+        current_proj->is_Proj()        && // is a projection  ?
+        current_proj->in(0)->Opcode() == Op_If) { // is a if projection ?
+      if_proj_list.push(current_proj);
+    }
+    current_proj = idom(current_proj);
+  }
+
+  bool hoisted = false; // true if at least one proj is promoted
+  while (if_proj_list.size() > 0) {
+    // Following are changed to nonnull when a predicate can be hoisted
+    ProjNode* new_predicate_proj = NULL;
+    BoolNode* new_predicate_bol   = NULL;
+
+    ProjNode* proj = if_proj_list.pop()->as_Proj();
+    IfNode*   iff  = proj->in(0)->as_If();
+
+    if (!is_uncommon_trap_if_pattern(proj)) {
+      if (loop->is_loop_exit(iff)) {
+        // stop processing the remaining projs in the list because the execution of them
+        // depends on the condition of "iff" (iff->in(1)).
+        break;
+      } else {
+        // Both arms are inside the loop. There are two cases:
+        // (1) there is one backward branch. In this case, any remaining proj
+        //     in the if_proj list post-dominates "iff". So, the condition of "iff"
+        //     does not determine the execution the remining projs directly, and we
+        //     can safely continue.
+        // (2) both arms are forwarded, i.e. a diamond shape. In this case, "proj"
+        //     does not dominate loop->tail(), so it can not be in the if_proj list.
+        continue;
+      }
+    }
+
+    Node*     test = iff->in(1);
+    if (!test->is_Bool()){ //Conv2B, ...
+      continue;
+    }
+    BoolNode* bol = test->as_Bool();
+    if (invar.is_invariant(bol)) {
+      // Invariant test
+      new_predicate_proj = create_new_if_for_predicate(predicate_proj);
+      Node* ctrl = new_predicate_proj->in(0)->as_If()->in(0);
+      new_predicate_bol  = invar.clone(bol, ctrl)->as_Bool();
+      if (TraceLoopPredicate) tty->print("invariant");
+    } else if (cl != NULL && loop->is_range_check_if(iff, this, invar)) {
+      // Range check (only for counted loops)
+      new_predicate_proj = create_new_if_for_predicate(predicate_proj);
+      Node *ctrl = new_predicate_proj->in(0)->as_If()->in(0);
+      const Node*    cmp    = bol->in(1)->as_Cmp();
+      Node*          idx    = cmp->in(1);
+      assert(!invar.is_invariant(idx), "index is variant");
+      assert(cmp->in(2)->Opcode() == Op_LoadRange, "must be");
+      LoadRangeNode* ld_rng = (LoadRangeNode*)cmp->in(2); // LoadRangeNode
+      assert(invar.is_invariant(ld_rng), "load range must be invariant");
+      ld_rng = (LoadRangeNode*)invar.clone(ld_rng, ctrl);
+      int scale    = 1;
+      Node* offset = zero;
+      bool ok = is_scaled_iv_plus_offset(idx, cl->phi(), &scale, &offset);
+      assert(ok, "must be index expression");
+      if (offset && offset != zero) {
+        assert(invar.is_invariant(offset), "offset must be loop invariant");
+        offset = invar.clone(offset, ctrl);
+      }
+      Node* init    = cl->init_trip();
+      Node* limit   = cl->limit();
+      Node* stride  = cl->stride();
+      new_predicate_bol = rc_predicate(ctrl, scale, offset, init, limit, stride, ld_rng);
+      if (TraceLoopPredicate) tty->print("range check");
+    }
+
+    if (new_predicate_proj == NULL) {
+      // The other proj of the "iff" is a uncommon trap projection, and we can assume
+      // the other proj will not be executed ("executed" means uct raised).
+      continue;
+    } else {
+      // Success - attach condition (new_predicate_bol) to predicate if
+      invar.map_ctrl(proj, new_predicate_proj); // so that invariance test can be appropriate
+      IfNode* new_iff = new_predicate_proj->in(0)->as_If();
+
+      // Negate test if necessary
+      if (proj->_con != predicate_proj->_con) {
+        new_predicate_bol = new (C, 2) BoolNode(new_predicate_bol->in(1), new_predicate_bol->_test.negate());
+        register_new_node(new_predicate_bol, new_iff->in(0));
+        if (TraceLoopPredicate) tty->print_cr(" if negated: %d", iff->_idx);
+      } else {
+        if (TraceLoopPredicate) tty->print_cr(" if: %d", iff->_idx);
+      }
+
+      _igvn.hash_delete(new_iff);
+      new_iff->set_req(1, new_predicate_bol);
+
+      _igvn.hash_delete(iff);
+      iff->set_req(1, proj->is_IfFalse() ? cond_false : cond_true);
+
+      Node* ctrl = new_predicate_proj; // new control
+      ProjNode* dp = proj;     // old control
+      assert(get_loop(dp) == loop, "guarenteed at the time of collecting proj");
+      // Find nodes (depends only on the test) off the surviving projection;
+      // move them outside the loop with the control of proj_clone
+      for (DUIterator_Fast imax, i = dp->fast_outs(imax); i < imax; i++) {
+        Node* cd = dp->fast_out(i); // Control-dependent node
+        if (cd->depends_only_on_test()) {
+          assert(cd->in(0) == dp, "");
+          _igvn.hash_delete(cd);
+          cd->set_req(0, ctrl); // ctrl, not NULL
+          set_early_ctrl(cd);
+          _igvn._worklist.push(cd);
+          IdealLoopTree *new_loop = get_loop(get_ctrl(cd));
+          if (new_loop != loop) {
+            if (!loop->_child) loop->_body.yank(cd);
+            if (!new_loop->_child ) new_loop->_body.push(cd);
+          }
+          --i;
+          --imax;
+        }
+      }
+
+      hoisted = true;
+      C->set_major_progress();
+    }
+  } // end while
+
+#ifndef PRODUCT
+    // report that the loop predication has been actually performed
+    // for this loop
+    if (TraceLoopPredicate && hoisted) {
+      tty->print("Loop Predication Performed:");
+      loop->dump_head();
+    }
+#endif
+
+  return hoisted;
+}
+
+//------------------------------loop_predication--------------------------------
+// driver routine for loop predication optimization
+bool IdealLoopTree::loop_predication( PhaseIdealLoop *phase) {
+  bool hoisted = false;
+  // Recursively promote predicates
+  if ( _child ) {
+    hoisted = _child->loop_predication( phase);
+  }
+
+  // self
+  if (!_irreducible && !tail()->is_top()) {
+    hoisted |= phase->loop_predication_impl(this);
+  }
+
+  if ( _next ) { //sibling
+    hoisted |= _next->loop_predication( phase);
+  }
+
+  return hoisted;
+}
--- a/hotspot/src/share/vm/opto/loopnode.cpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/opto/loopnode.cpp	Wed Jul 05 17:06:00 2017 +0200
@@ -1420,11 +1420,57 @@
   }
 }
 
+//---------------------collect_potentially_useful_predicates-----------------------
+// Helper function to collect potentially useful predicates to prevent them from
+// being eliminated by PhaseIdealLoop::eliminate_useless_predicates
+void PhaseIdealLoop::collect_potentially_useful_predicates(
+                         IdealLoopTree * loop, Unique_Node_List &useful_predicates) {
+  if (loop->_child) { // child
+    collect_potentially_useful_predicates(loop->_child, useful_predicates);
+  }
+
+  // self (only loops that we can apply loop predication may use their predicates)
+  if (loop->_head->is_Loop()     &&
+      !loop->_irreducible        &&
+      !loop->tail()->is_top()) {
+    LoopNode *lpn  = loop->_head->as_Loop();
+    Node* entry = lpn->in(LoopNode::EntryControl);
+    ProjNode *predicate_proj = find_predicate_insertion_point(entry);
+    if (predicate_proj != NULL ) { // right pattern that can be used by loop predication
+      assert(entry->in(0)->in(1)->in(1)->Opcode()==Op_Opaque1, "must be");
+      useful_predicates.push(entry->in(0)->in(1)->in(1)); // good one
+    }
+  }
+
+  if ( loop->_next ) { // sibling
+    collect_potentially_useful_predicates(loop->_next, useful_predicates);
+  }
+}
+
+//------------------------eliminate_useless_predicates-----------------------------
+// Eliminate all inserted predicates if they could not be used by loop predication.
+void PhaseIdealLoop::eliminate_useless_predicates() {
+  if (C->predicate_count() == 0) return; // no predicate left
+
+  Unique_Node_List useful_predicates; // to store useful predicates
+  if (C->has_loops()) {
+    collect_potentially_useful_predicates(_ltree_root->_child, useful_predicates);
+  }
+
+  for (int i = C->predicate_count(); i > 0; i--) {
+     Node * n = C->predicate_opaque1_node(i-1);
+     assert(n->Opcode() == Op_Opaque1, "must be");
+     if (!useful_predicates.member(n)) { // not in the useful list
+       _igvn.replace_node(n, n->in(1));
+     }
+  }
+}
+
 //=============================================================================
 //----------------------------build_and_optimize-------------------------------
 // Create a PhaseLoop.  Build the ideal Loop tree.  Map each Ideal Node to
 // its corresponding LoopNode.  If 'optimize' is true, do some loop cleanups.
-void PhaseIdealLoop::build_and_optimize(bool do_split_ifs) {
+void PhaseIdealLoop::build_and_optimize(bool do_split_ifs, bool do_loop_pred) {
   int old_progress = C->major_progress();
 
   // Reset major-progress flag for the driver's heuristics
@@ -1577,6 +1623,12 @@
     return;
   }
 
+  // some parser-inserted loop predicates could never be used by loop
+  // predication. Eliminate them before loop optimization
+  if (UseLoopPredicate) {
+    eliminate_useless_predicates();
+  }
+
   // clear out the dead code
   while(_deadlist.size()) {
     _igvn.remove_globally_dead_node(_deadlist.pop());
@@ -1603,7 +1655,7 @@
       // Because RCE opportunities can be masked by split_thru_phi,
       // look for RCE candidates and inhibit split_thru_phi
       // on just their loop-phi's for this pass of loop opts
-      if( SplitIfBlocks && do_split_ifs ) {
+      if (SplitIfBlocks && do_split_ifs) {
         if (lpt->policy_range_check(this)) {
           lpt->_rce_candidate = 1; // = true
         }
@@ -1619,12 +1671,17 @@
     NOT_PRODUCT( if( VerifyLoopOptimizations ) verify(); );
   }
 
+  // Perform loop predication before iteration splitting
+  if (do_loop_pred && C->has_loops() && !C->major_progress()) {
+    _ltree_root->_child->loop_predication(this);
+  }
+
   // Perform iteration-splitting on inner loops.  Split iterations to avoid
   // range checks or one-shot null checks.
 
   // If split-if's didn't hack the graph too bad (no CFG changes)
   // then do loop opts.
-  if( C->has_loops() && !C->major_progress() ) {
+  if (C->has_loops() && !C->major_progress()) {
     memset( worklist.adr(), 0, worklist.Size()*sizeof(Node*) );
     _ltree_root->_child->iteration_split( this, worklist );
     // No verify after peeling!  GCM has hoisted code out of the loop.
@@ -1636,7 +1693,7 @@
   // Do verify graph edges in any case
   NOT_PRODUCT( C->verify_graph_edges(); );
 
-  if( !do_split_ifs ) {
+  if (!do_split_ifs) {
     // We saw major progress in Split-If to get here.  We forced a
     // pass with unrolling and not split-if, however more split-if's
     // might make progress.  If the unrolling didn't make progress
@@ -2763,6 +2820,22 @@
   Node *legal = LCA;            // Walk 'legal' up the IDOM chain
   Node *least = legal;          // Best legal position so far
   while( early != legal ) {     // While not at earliest legal
+#ifdef ASSERT
+    if (legal->is_Start() && !early->is_Root()) {
+      // Bad graph. Print idom path and fail.
+      tty->print_cr( "Bad graph detected in build_loop_late");
+      tty->print("n: ");n->dump(); tty->cr();
+      tty->print("early: ");early->dump(); tty->cr();
+      int ct = 0;
+      Node *dbg_legal = LCA;
+      while(!dbg_legal->is_Start() && ct < 100) {
+        tty->print("idom[%d] ",ct); dbg_legal->dump(); tty->cr();
+        ct++;
+        dbg_legal = idom(dbg_legal);
+      }
+      assert(false, "Bad graph detected in build_loop_late");
+    }
+#endif
     // Find least loop nesting depth
     legal = idom(legal);        // Bump up the IDOM tree
     // Check for lower nesting depth
--- a/hotspot/src/share/vm/opto/loopnode.hpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/opto/loopnode.hpp	Wed Jul 05 17:06:00 2017 +0200
@@ -30,6 +30,7 @@
 class Node;
 class PhaseIdealLoop;
 class VectorSet;
+class Invariance;
 struct small_cache;
 
 //
@@ -325,6 +326,10 @@
   // Returns TRUE if loop tree is structurally changed.
   bool beautify_loops( PhaseIdealLoop *phase );
 
+  // Perform optimization to use the loop predicates for null checks and range checks.
+  // Applies to any loop level (not just the innermost one)
+  bool loop_predication( PhaseIdealLoop *phase);
+
   // Perform iteration-splitting on inner loops.  Split iterations to
   // avoid range checks or one-shot null checks.  Returns false if the
   // current round of loop opts should stop.
@@ -395,6 +400,9 @@
   // into longer memory ops, we may want to increase alignment.
   bool policy_align( PhaseIdealLoop *phase ) const;
 
+  // Return TRUE if "iff" is a range check.
+  bool is_range_check_if(IfNode *iff, PhaseIdealLoop *phase, Invariance& invar) const;
+
   // Compute loop trip count from profile data
   void compute_profile_trip_cnt( PhaseIdealLoop *phase );
 
@@ -521,9 +529,6 @@
   }
   Node *dom_lca_for_get_late_ctrl_internal( Node *lca, Node *n, Node *tag );
 
-  // true if CFG node d dominates CFG node n
-  bool is_dominator(Node *d, Node *n);
-
   // Helper function for directing control inputs away from CFG split
   // points.
   Node *find_non_split_ctrl( Node *ctrl ) const {
@@ -572,6 +577,17 @@
     assert(n == find_non_split_ctrl(n), "must return legal ctrl" );
     return n;
   }
+  // true if CFG node d dominates CFG node n
+  bool is_dominator(Node *d, Node *n);
+  // return get_ctrl for a data node and self(n) for a CFG node
+  Node* ctrl_or_self(Node* n) {
+    if (has_ctrl(n))
+      return get_ctrl(n);
+    else {
+      assert (n->is_CFG(), "must be a CFG node");
+      return n;
+    }
+  }
 
 private:
   Node *get_ctrl_no_update( Node *i ) const {
@@ -600,7 +616,7 @@
   // Lazy-dazy update of 'get_ctrl' and 'idom_at' mechanisms.  Replace
   // the 'old_node' with 'new_node'.  Kill old-node.  Add a reference
   // from old_node to new_node to support the lazy update.  Reference
-  // replaces loop reference, since that is not neede for dead node.
+  // replaces loop reference, since that is not needed for dead node.
 public:
   void lazy_update( Node *old_node, Node *new_node ) {
     assert( old_node != new_node, "no cycles please" );
@@ -679,11 +695,11 @@
     _dom_lca_tags(C->comp_arena()),
     _verify_me(NULL),
     _verify_only(true) {
-    build_and_optimize(false);
+    build_and_optimize(false, false);
   }
 
   // build the loop tree and perform any requested optimizations
-  void build_and_optimize(bool do_split_if);
+  void build_and_optimize(bool do_split_if, bool do_loop_pred);
 
 public:
   // Dominators for the sea of nodes
@@ -694,13 +710,13 @@
   Node *dom_lca_internal( Node *n1, Node *n2 ) const;
 
   // Compute the Ideal Node to Loop mapping
-  PhaseIdealLoop( PhaseIterGVN &igvn, bool do_split_ifs) :
+  PhaseIdealLoop( PhaseIterGVN &igvn, bool do_split_ifs, bool do_loop_pred) :
     PhaseTransform(Ideal_Loop),
     _igvn(igvn),
     _dom_lca_tags(C->comp_arena()),
     _verify_me(NULL),
     _verify_only(false) {
-    build_and_optimize(do_split_ifs);
+    build_and_optimize(do_split_ifs, do_loop_pred);
   }
 
   // Verify that verify_me made the same decisions as a fresh run.
@@ -710,7 +726,7 @@
     _dom_lca_tags(C->comp_arena()),
     _verify_me(verify_me),
     _verify_only(false) {
-    build_and_optimize(false);
+    build_and_optimize(false, false);
   }
 
   // Build and verify the loop tree without modifying the graph.  This
@@ -790,6 +806,30 @@
   // Return true if exp is a scaled induction var plus (or minus) constant
   bool is_scaled_iv_plus_offset(Node* exp, Node* iv, int* p_scale, Node** p_offset, int depth = 0);
 
+  // Return true if proj is for "proj->[region->..]call_uct"
+  bool is_uncommon_trap_proj(ProjNode* proj, bool must_reason_predicate = false);
+  // Return true for    "if(test)-> proj -> ...
+  //                          |
+  //                          V
+  //                      other_proj->[region->..]call_uct"
+  bool is_uncommon_trap_if_pattern(ProjNode* proj, bool must_reason_predicate = false);
+  // Create a new if above the uncommon_trap_if_pattern for the predicate to be promoted
+  ProjNode* create_new_if_for_predicate(ProjNode* cont_proj);
+  // Find a good location to insert a predicate
+  ProjNode* find_predicate_insertion_point(Node* start_c);
+  // Construct a range check for a predicate if
+  BoolNode* rc_predicate(Node* ctrl,
+                         int scale, Node* offset,
+                         Node* init, Node* limit, Node* stride,
+                         Node* range);
+
+  // Implementation of the loop predication to promote checks outside the loop
+  bool loop_predication_impl(IdealLoopTree *loop);
+
+  // Helper function to collect predicate for eliminating the useless ones
+  void collect_potentially_useful_predicates(IdealLoopTree *loop, Unique_Node_List &predicate_opaque1);
+  void eliminate_useless_predicates();
+
   // Eliminate range-checks and other trip-counter vs loop-invariant tests.
   void do_range_check( IdealLoopTree *loop, Node_List &old_new );
 
@@ -906,7 +946,6 @@
   const TypeInt* filtered_type_from_dominators( Node* val, Node *val_ctrl);
 
   // Helper functions
-  void register_new_node( Node *n, Node *blk );
   Node *spinup( Node *iff, Node *new_false, Node *new_true, Node *region, Node *phi, small_cache *cache );
   Node *find_use_block( Node *use, Node *def, Node *old_false, Node *new_false, Node *old_true, Node *new_true );
   void handle_use( Node *use, Node *def, small_cache *cache, Node *region_dom, Node *new_false, Node *new_true, Node *old_false, Node *old_true );
@@ -918,6 +957,7 @@
 public:
   void set_created_loop_node() { _created_loop_node = true; }
   bool created_loop_node()     { return _created_loop_node; }
+  void register_new_node( Node *n, Node *blk );
 
 #ifndef PRODUCT
   void dump( ) const;
--- a/hotspot/src/share/vm/opto/parse.hpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/opto/parse.hpp	Wed Jul 05 17:06:00 2017 +0200
@@ -430,6 +430,11 @@
     }
   }
 
+  // Return true if the parser should add a loop predicate
+  bool should_add_predicate(int target_bci);
+  // Insert a loop predicate into the graph
+  void add_predicate();
+
   // Note:  Intrinsic generation routines may be found in library_call.cpp.
 
   // Helper function to setup Ideal Call nodes
@@ -491,7 +496,7 @@
 
   void    do_ifnull(BoolTest::mask btest, Node* c);
   void    do_if(BoolTest::mask btest, Node* c);
-  void    repush_if_args();
+  int     repush_if_args();
   void    adjust_map_after_if(BoolTest::mask btest, Node* c, float prob,
                               Block* path, Block* other_path);
   IfNode* jump_if_fork_int(Node* a, Node* b, BoolTest::mask mask);
--- a/hotspot/src/share/vm/opto/parse1.cpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/opto/parse1.cpp	Wed Jul 05 17:06:00 2017 +0200
@@ -1383,6 +1383,10 @@
     set_parse_bci(iter().cur_bci());
 
     if (bci() == block()->limit()) {
+      // insert a predicate if it falls through to a loop head block
+      if (should_add_predicate(bci())){
+        add_predicate();
+      }
       // Do not walk into the next block until directed by do_all_blocks.
       merge(bci());
       break;
@@ -2083,6 +2087,37 @@
   }
 }
 
+//------------------------------should_add_predicate--------------------------
+bool Parse::should_add_predicate(int target_bci) {
+  if (!UseLoopPredicate) return false;
+  Block* target = successor_for_bci(target_bci);
+  if (target != NULL          &&
+      target->is_loop_head()  &&
+      block()->rpo() < target->rpo()) {
+    return true;
+  }
+  return false;
+}
+
+//------------------------------add_predicate---------------------------------
+void Parse::add_predicate() {
+  assert(UseLoopPredicate,"use only for loop predicate");
+  Node *cont    = _gvn.intcon(1);
+  Node* opq     = _gvn.transform(new (C, 2) Opaque1Node(C, cont));
+  Node *bol     = _gvn.transform(new (C, 2) Conv2BNode(opq));
+  IfNode* iff   = create_and_map_if(control(), bol, PROB_MAX, COUNT_UNKNOWN);
+  Node* iffalse = _gvn.transform(new (C, 1) IfFalseNode(iff));
+  C->add_predicate_opaq(opq);
+  {
+    PreserveJVMState pjvms(this);
+    set_control(iffalse);
+    uncommon_trap(Deoptimization::Reason_predicate,
+                  Deoptimization::Action_maybe_recompile);
+  }
+  Node* iftrue = _gvn.transform(new (C, 1) IfTrueNode(iff));
+  set_control(iftrue);
+}
+
 #ifndef PRODUCT
 //------------------------show_parse_info--------------------------------------
 void Parse::show_parse_info() {
--- a/hotspot/src/share/vm/opto/parse2.cpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/opto/parse2.cpp	Wed Jul 05 17:06:00 2017 +0200
@@ -278,6 +278,11 @@
   if (len < 1) {
     // If this is a backward branch, add safepoint
     maybe_add_safepoint(default_dest);
+    if (should_add_predicate(default_dest)){
+      _sp += 1; // set original stack for use by uncommon_trap
+      add_predicate();
+      _sp -= 1;
+    }
     merge(default_dest);
     return;
   }
@@ -324,6 +329,11 @@
 
   if (len < 1) {    // If this is a backward branch, add safepoint
     maybe_add_safepoint(default_dest);
+    if (should_add_predicate(default_dest)){
+      _sp += 1; // set original stack for use by uncommon_trap
+      add_predicate();
+      _sp -= 1;
+    }
     merge(default_dest);
     return;
   }
@@ -731,6 +741,9 @@
   push(_gvn.makecon(ret_addr));
 
   // Flow to the jsr.
+  if (should_add_predicate(jsr_bci)){
+    add_predicate();
+  }
   merge(jsr_bci);
 }
 
@@ -881,7 +894,7 @@
 
 //-------------------------------repush_if_args--------------------------------
 // Push arguments of an "if" bytecode back onto the stack by adjusting _sp.
-inline void Parse::repush_if_args() {
+inline int Parse::repush_if_args() {
 #ifndef PRODUCT
   if (PrintOpto && WizardMode) {
     tty->print("defending against excessive implicit null exceptions on %s @%d in ",
@@ -895,6 +908,7 @@
   assert(argument(0) != NULL, "must exist");
   assert(bc_depth == 1 || argument(1) != NULL, "two must exist");
   _sp += bc_depth;
+  return bc_depth;
 }
 
 //----------------------------------do_ifnull----------------------------------
@@ -954,8 +968,14 @@
       // Update method data
       profile_taken_branch(target_bci);
       adjust_map_after_if(btest, c, prob, branch_block, next_block);
-      if (!stopped())
+      if (!stopped()) {
+        if (should_add_predicate(target_bci)){ // add a predicate if it branches to a loop
+          int nargs = repush_if_args(); // set original stack for uncommon_trap
+          add_predicate();
+          _sp -= nargs;
+        }
         merge(target_bci);
+      }
     }
   }
 
@@ -1076,8 +1096,14 @@
       // Update method data
       profile_taken_branch(target_bci);
       adjust_map_after_if(taken_btest, c, prob, branch_block, next_block);
-      if (!stopped())
+      if (!stopped()) {
+        if (should_add_predicate(target_bci)){ // add a predicate if it branches to a loop
+          int nargs = repush_if_args(); // set original stack for the uncommon_trap
+          add_predicate();
+          _sp -= nargs;
+        }
         merge(target_bci);
+      }
     }
   }
 
@@ -2080,6 +2106,10 @@
     // Update method data
     profile_taken_branch(target_bci);
 
+    // Add loop predicate if it goes to a loop
+    if (should_add_predicate(target_bci)){
+      add_predicate();
+    }
     // Merge the current control into the target basic block
     merge(target_bci);
 
--- a/hotspot/src/share/vm/opto/runtime.cpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/opto/runtime.cpp	Wed Jul 05 17:06:00 2017 +0200
@@ -143,7 +143,7 @@
 // We failed the fast-path allocation.  Now we need to do a scavenge or GC
 // and try allocation again.
 
-void OptoRuntime::maybe_defer_card_mark(JavaThread* thread) {
+void OptoRuntime::new_store_pre_barrier(JavaThread* thread) {
   // After any safepoint, just before going back to compiled code,
   // we inform the GC that we will be doing initializing writes to
   // this object in the future without emitting card-marks, so
@@ -156,7 +156,7 @@
   assert(Universe::heap()->can_elide_tlab_store_barriers(),
          "compiler must check this first");
   // GC may decide to give back a safer copy of new_obj.
-  new_obj = Universe::heap()->defer_store_barrier(thread, new_obj);
+  new_obj = Universe::heap()->new_store_pre_barrier(thread, new_obj);
   thread->set_vm_result(new_obj);
 }
 
@@ -200,7 +200,7 @@
 
   if (GraphKit::use_ReduceInitialCardMarks()) {
     // inform GC that we won't do card marks for initializing writes.
-    maybe_defer_card_mark(thread);
+    new_store_pre_barrier(thread);
   }
 JRT_END
 
@@ -239,7 +239,7 @@
 
   if (GraphKit::use_ReduceInitialCardMarks()) {
     // inform GC that we won't do card marks for initializing writes.
-    maybe_defer_card_mark(thread);
+    new_store_pre_barrier(thread);
   }
 JRT_END
 
--- a/hotspot/src/share/vm/opto/runtime.hpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/opto/runtime.hpp	Wed Jul 05 17:06:00 2017 +0200
@@ -133,8 +133,9 @@
   // Allocate storage for a objArray or typeArray
   static void new_array_C(klassOopDesc* array_klass, int len, JavaThread *thread);
 
-  // Post-slow-path-allocation step for implementing ReduceInitialCardMarks:
-  static void maybe_defer_card_mark(JavaThread* thread);
+  // Post-slow-path-allocation, pre-initializing-stores step for
+  // implementing ReduceInitialCardMarks
+  static void new_store_pre_barrier(JavaThread* thread);
 
   // Allocate storage for a multi-dimensional arrays
   // Note: needs to be fixed for arbitrary number of dimensions
--- a/hotspot/src/share/vm/opto/split_if.cpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/opto/split_if.cpp	Wed Jul 05 17:06:00 2017 +0200
@@ -219,6 +219,7 @@
 
 //------------------------------register_new_node------------------------------
 void PhaseIdealLoop::register_new_node( Node *n, Node *blk ) {
+  assert(!n->is_CFG(), "must be data node");
   _igvn.register_new_node_with_optimizer(n);
   set_ctrl(n, blk);
   IdealLoopTree *loop = get_loop(blk);
--- a/hotspot/src/share/vm/opto/subnode.cpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/opto/subnode.cpp	Wed Jul 05 17:06:00 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-2010 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1244,8 +1244,7 @@
   if( t1 == Type::TOP ) return Type::TOP;
   if( t1->base() != Type::DoubleCon ) return Type::DOUBLE;
   double d = t1->getd();
-  if( d < 0.0 ) return Type::DOUBLE;
-  return TypeD::make( SharedRuntime::dcos( d ) );
+  return TypeD::make( StubRoutines::intrinsic_cos( d ) );
 }
 
 //=============================================================================
@@ -1256,8 +1255,7 @@
   if( t1 == Type::TOP ) return Type::TOP;
   if( t1->base() != Type::DoubleCon ) return Type::DOUBLE;
   double d = t1->getd();
-  if( d < 0.0 ) return Type::DOUBLE;
-  return TypeD::make( SharedRuntime::dsin( d ) );
+  return TypeD::make( StubRoutines::intrinsic_sin( d ) );
 }
 
 //=============================================================================
@@ -1268,8 +1266,7 @@
   if( t1 == Type::TOP ) return Type::TOP;
   if( t1->base() != Type::DoubleCon ) return Type::DOUBLE;
   double d = t1->getd();
-  if( d < 0.0 ) return Type::DOUBLE;
-  return TypeD::make( SharedRuntime::dtan( d ) );
+  return TypeD::make( StubRoutines::intrinsic_tan( d ) );
 }
 
 //=============================================================================
@@ -1280,8 +1277,7 @@
   if( t1 == Type::TOP ) return Type::TOP;
   if( t1->base() != Type::DoubleCon ) return Type::DOUBLE;
   double d = t1->getd();
-  if( d < 0.0 ) return Type::DOUBLE;
-  return TypeD::make( SharedRuntime::dlog( d ) );
+  return TypeD::make( StubRoutines::intrinsic_log( d ) );
 }
 
 //=============================================================================
@@ -1292,8 +1288,7 @@
   if( t1 == Type::TOP ) return Type::TOP;
   if( t1->base() != Type::DoubleCon ) return Type::DOUBLE;
   double d = t1->getd();
-  if( d < 0.0 ) return Type::DOUBLE;
-  return TypeD::make( SharedRuntime::dlog10( d ) );
+  return TypeD::make( StubRoutines::intrinsic_log10( d ) );
 }
 
 //=============================================================================
@@ -1304,8 +1299,7 @@
   if( t1 == Type::TOP ) return Type::TOP;
   if( t1->base() != Type::DoubleCon ) return Type::DOUBLE;
   double d = t1->getd();
-  if( d < 0.0 ) return Type::DOUBLE;
-  return TypeD::make( SharedRuntime::dexp( d ) );
+  return TypeD::make( StubRoutines::intrinsic_exp( d ) );
 }
 
 
@@ -1323,5 +1317,5 @@
   double d2 = t2->getd();
   if( d1 < 0.0 ) return Type::DOUBLE;
   if( d2 < 0.0 ) return Type::DOUBLE;
-  return TypeD::make( SharedRuntime::dpow( d1, d2 ) );
+  return TypeD::make( StubRoutines::intrinsic_pow( d1, d2 ) );
 }
--- a/hotspot/src/share/vm/runtime/compilationPolicy.cpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/runtime/compilationPolicy.cpp	Wed Jul 05 17:06:00 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2000-2010 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -74,6 +74,16 @@
   if (m->is_abstract()) return false;
   if (DontCompileHugeMethods && m->code_size() > HugeMethodLimit) return false;
 
+  // Math intrinsics should never be compiled as this can lead to
+  // monotonicity problems because the interpreter will prefer the
+  // compiled code to the intrinsic version.  This can't happen in
+  // production because the invocation counter can't be incremented
+  // but we shouldn't expose the system to this problem in testing
+  // modes.
+  if (!AbstractInterpreter::can_be_compiled(m)) {
+    return false;
+  }
+
   return !m->is_not_compilable();
 }
 
--- a/hotspot/src/share/vm/runtime/deoptimization.cpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/runtime/deoptimization.cpp	Wed Jul 05 17:06:00 2017 +0200
@@ -1672,7 +1672,8 @@
   "unhandled",
   "constraint",
   "div0_check",
-  "age"
+  "age",
+  "predicate"
 };
 const char* Deoptimization::_trap_action_name[Action_LIMIT] = {
   // Note:  Keep this in sync. with enum DeoptAction.
--- a/hotspot/src/share/vm/runtime/deoptimization.hpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/runtime/deoptimization.hpp	Wed Jul 05 17:06:00 2017 +0200
@@ -46,6 +46,7 @@
     Reason_constraint,            // arbitrary runtime constraint violated
     Reason_div0_check,            // a null_check due to division by zero
     Reason_age,                   // nmethod too old; tier threshold reached
+    Reason_predicate,             // compiler generated predicate failed
     Reason_LIMIT,
     // Note:  Keep this enum in sync. with _trap_reason_name.
     Reason_RECORDED_LIMIT = Reason_unloaded   // some are not recorded per bc
--- a/hotspot/src/share/vm/runtime/globals.hpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/runtime/globals.hpp	Wed Jul 05 17:06:00 2017 +0200
@@ -2012,6 +2012,10 @@
   diagnostic(bool, GCParallelVerificationEnabled, true,                     \
           "Enable parallel memory system verification")                     \
                                                                             \
+  diagnostic(bool, DeferInitialCardMark, false,                             \
+          "When +ReduceInitialCardMarks, explicitly defer any that "        \
+           "may arise from new_pre_store_barrier")                          \
+                                                                            \
   diagnostic(bool, VerifyRememberedSets, false,                             \
           "Verify GC remembered sets")                                      \
                                                                             \
@@ -3456,6 +3460,9 @@
   diagnostic(bool, OptimizeMethodHandles, true,                             \
           "when constructing method handles, try to improve them")          \
                                                                             \
+  experimental(bool, TrustFinalNonStaticFields, false,                      \
+          "trust final non-static declarations for constant folding")       \
+                                                                            \
   experimental(bool, EnableInvokeDynamic, false,                            \
           "recognize the invokedynamic instruction")                        \
                                                                             \
--- a/hotspot/src/share/vm/runtime/stubRoutines.cpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/runtime/stubRoutines.cpp	Wed Jul 05 17:06:00 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-2010 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -97,6 +97,14 @@
 address StubRoutines::_unsafe_arraycopy                  = NULL;
 address StubRoutines::_generic_arraycopy                 = NULL;
 
+double (* StubRoutines::_intrinsic_log   )(double) = NULL;
+double (* StubRoutines::_intrinsic_log10 )(double) = NULL;
+double (* StubRoutines::_intrinsic_exp   )(double) = NULL;
+double (* StubRoutines::_intrinsic_pow   )(double, double) = NULL;
+double (* StubRoutines::_intrinsic_sin   )(double) = NULL;
+double (* StubRoutines::_intrinsic_cos   )(double) = NULL;
+double (* StubRoutines::_intrinsic_tan   )(double) = NULL;
+
 // Initialization
 //
 // Note: to break cycle with universe initialization, stubs are generated in two phases.
--- a/hotspot/src/share/vm/runtime/stubRoutines.hpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/runtime/stubRoutines.hpp	Wed Jul 05 17:06:00 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-2010 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -148,6 +148,20 @@
   static address _unsafe_arraycopy;
   static address _generic_arraycopy;
 
+  // These are versions of the java.lang.Math methods which perform
+  // the same operations as the intrinsic version.  They are used for
+  // constant folding in the compiler to ensure equivalence.  If the
+  // intrinsic version returns the same result as the strict version
+  // then they can be set to the appropriate function from
+  // SharedRuntime.
+  static double (*_intrinsic_log)(double);
+  static double (*_intrinsic_log10)(double);
+  static double (*_intrinsic_exp)(double);
+  static double (*_intrinsic_pow)(double, double);
+  static double (*_intrinsic_sin)(double);
+  static double (*_intrinsic_cos)(double);
+  static double (*_intrinsic_tan)(double);
+
  public:
   // Initialization/Testing
   static void    initialize1();                            // must happen before universe::genesis
@@ -245,6 +259,35 @@
   static address unsafe_arraycopy()        { return _unsafe_arraycopy; }
   static address generic_arraycopy()       { return _generic_arraycopy; }
 
+  static double  intrinsic_log(double d) {
+    assert(_intrinsic_log != NULL, "must be defined");
+    return _intrinsic_log(d);
+  }
+  static double  intrinsic_log10(double d) {
+    assert(_intrinsic_log != NULL, "must be defined");
+    return _intrinsic_log10(d);
+  }
+  static double  intrinsic_exp(double d) {
+    assert(_intrinsic_exp != NULL, "must be defined");
+    return _intrinsic_exp(d);
+  }
+  static double  intrinsic_pow(double d, double d2) {
+    assert(_intrinsic_pow != NULL, "must be defined");
+    return _intrinsic_pow(d, d2);
+  }
+  static double  intrinsic_sin(double d) {
+    assert(_intrinsic_sin != NULL, "must be defined");
+    return _intrinsic_sin(d);
+  }
+  static double  intrinsic_cos(double d) {
+    assert(_intrinsic_cos != NULL, "must be defined");
+    return _intrinsic_cos(d);
+  }
+  static double  intrinsic_tan(double d) {
+    assert(_intrinsic_tan != NULL, "must be defined");
+    return _intrinsic_tan(d);
+  }
+
   //
   // Default versions of the above arraycopy functions for platforms which do
   // not have specialized versions
--- a/hotspot/src/share/vm/runtime/thread.cpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/runtime/thread.cpp	Wed Jul 05 17:06:00 2017 +0200
@@ -2357,9 +2357,8 @@
 };
 
 void JavaThread::oops_do(OopClosure* f, CodeBlobClosure* cf) {
-  // Flush deferred store-barriers, if any, associated with
-  // initializing stores done by this JavaThread in the current epoch.
-  Universe::heap()->flush_deferred_store_barrier(this);
+  // Verify that the deferred card marks have been flushed.
+  assert(deferred_card_mark().is_empty(), "Should be empty during GC");
 
   // The ThreadProfiler oops_do is done from FlatProfiler::oops_do
   // since there may be more than one thread using each ThreadProfiler.
--- a/hotspot/src/share/vm/runtime/vmStructs.cpp	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/src/share/vm/runtime/vmStructs.cpp	Wed Jul 05 17:06:00 2017 +0200
@@ -309,6 +309,7 @@
   nonstatic_field(CollectedHeap,               _reserved,                                     MemRegion)                             \
   nonstatic_field(SharedHeap,                  _perm_gen,                                     PermGen*)                              \
   nonstatic_field(CollectedHeap,               _barrier_set,                                  BarrierSet*)                           \
+  nonstatic_field(CollectedHeap,               _defer_initial_card_mark,                      bool)                                  \
   nonstatic_field(CollectedHeap,               _is_gc_active,                                 bool)                                  \
   nonstatic_field(CompactibleSpace,            _compaction_top,                               HeapWord*)                             \
   nonstatic_field(CompactibleSpace,            _first_dead,                                   HeapWord*)                             \
--- a/hotspot/test/compiler/6877254/Test.java	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/test/compiler/6877254/Test.java	Wed Jul 05 17:06:00 2017 +0200
@@ -26,7 +26,7 @@
  * @bug 6877254
  * @summary Implement StoreCMNode::Ideal to promote its OopStore above the MergeMem
  *
- * @run main/othervm -server -Xcomp -XX:+UseConcMarkSweepGC Test
+ * @run main/othervm -Xcomp Test
  */
 
 public class Test {
--- a/hotspot/test/compiler/6895383/Test.java	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/test/compiler/6895383/Test.java	Wed Jul 05 17:06:00 2017 +0200
@@ -30,6 +30,9 @@
  * @run main/othervm -Xcomp Test
  */
 
+import java.util.*;
+import java.util.concurrent.*;
+
 public class Test {
     public static void main(String argv[]) {
         Test test = new Test();
--- a/hotspot/test/compiler/6896727/Test.java	Thu Jan 21 11:12:31 2010 -0800
+++ b/hotspot/test/compiler/6896727/Test.java	Wed Jul 05 17:06:00 2017 +0200
@@ -26,7 +26,7 @@
  * @test
  * @bug 6896727
  * @summary nsk/logging/LoggingPermission/LoggingPermission/logperm002 fails with G1, EscapeAnalisys w/o COOPs
- * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -Xcomp -XX:+DoEscapeAnalysis -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC Test
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -Xcomp -XX:+DoEscapeAnalysis Test
  */
 
 public class Test {
--- a/jdk/.hgtags	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/.hgtags	Wed Jul 05 17:06:00 2017 +0200
@@ -54,3 +54,4 @@
 e6a5d095c356a547cf5b3c8885885aca5e91e09b jdk7-b77
 1143e498f813b8223b5e3a696d79da7ff7c25354 jdk7-b78
 918920710d65432a2d54fdf407c1524a5571c4ad jdk7-b79
+049cfaaa9a7374e3768a79969a799e8b59ad52fa jdk7-b80
--- a/jdk/make/com/sun/crypto/provider/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/com/sun/crypto/provider/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -249,7 +249,7 @@
 else
 $(JAR_DESTFILE): $(SIGNED_DIR)/sunjce_provider.jar
 endif
-	$(install-file)
+	$(install-non-module-file)
 
 ifndef OPENJDK
 install-prebuilt:
--- a/jdk/make/com/sun/java/pack/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/com/sun/java/pack/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../../../..
+MODULE  = pack200
 PACKAGE = com.sun.java.util.jar.pack
 LIBRARY = unpack
 PRODUCT = sun
@@ -123,11 +124,14 @@
 
 all: build
 
-build: prop
+build: prop pack200-tool
 
 prop:
 	$(MAKE) -C prop
 
+pack200-tool:
+	$(call make-launcher, pack200, com.sun.java.util.jar.pack.Driver, , --pack)
+
 unpacker:
 	$(MAKE) $(UNPACK_EXE) STANDALONE=true LDMAPFLAGS_OPT= LDMAPFLAGS_DBG=
 
@@ -151,6 +155,7 @@
 	$(MT) /manifest $(TEMPDIR)/unpack200$(EXE_SUFFIX).manifest /outputresource:$(TEMPDIR)/unpack200$(EXE_SUFFIX);#1
 endif
 	$(CP) $(TEMPDIR)/unpack200$(EXE_SUFFIX) $(UNPACK_EXE)
+	$(install-module-file)
 
 ifeq ($(PLATFORM), windows) 
 $(RES):: $(VERSIONINFO_RESOURCE)
--- a/jdk/make/com/sun/java/pack/prop/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/com/sun/java/pack/prop/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -29,6 +29,7 @@
 # to a collision of rules with Classes.gmk and Library.gmk
 
 BUILDDIR = ../../../../..
+MODULE  = pack200
 PACKAGE = com.sun.java.util.jar.pack
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/com/sun/jndi/cosnaming/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/com/sun/jndi/cosnaming/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../../../..
+MODULE  = jndi-cosnaming
 PACKAGE = com.sun.jndi.cosnaming
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/com/sun/jndi/dns/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/com/sun/jndi/dns/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../../../..
+MODULE  = jndi-dns
 PACKAGE = com.sun.jndi.dns
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/com/sun/jndi/ldap/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/com/sun/jndi/ldap/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../../../..
+MODULE  = jndi-ldap
 PACKAGE = com.sun.jndi.ldap
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/com/sun/jndi/rmi/registry/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/com/sun/jndi/rmi/registry/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../../../../..
+MODULE  = jndi-rmiregistry
 PACKAGE = com.sun.jndi.rmi.registry
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/com/sun/nio/sctp/FILES_java.gmk	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/com/sun/nio/sctp/FILES_java.gmk	Wed Jul 05 17:06:00 2017 +0200
@@ -57,8 +57,7 @@
 	sun/nio/ch/SctpResultContainer.java \
 	sun/nio/ch/SctpSendFailed.java \
 	sun/nio/ch/SctpServerChannelImpl.java \
-	sun/nio/ch/SctpShutdown.java \
-	sun/nio/ch/SctpSocketDispatcher.java
+	sun/nio/ch/SctpShutdown.java
 else
 FILES_java += \
 	sun/nio/ch/SctpChannelImpl.java \
--- a/jdk/make/com/sun/nio/sctp/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/com/sun/nio/sctp/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../../../..
+MODULE  = sctp
 PACKAGE = com.sun.nio.sctp
 LIBRARY = sctp
 PRODUCT = sun
--- a/jdk/make/com/sun/nio/sctp/mapfile-vers	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/com/sun/nio/sctp/mapfile-vers	Wed Jul 05 17:06:00 2017 +0200
@@ -25,9 +25,14 @@
 
 SUNWprivate_1.1 {
 	global:
+		Java_sun_nio_ch_SctpNet_init;
 		Java_sun_nio_ch_SctpNet_socket0;
 		Java_sun_nio_ch_SctpNet_bindx;
 		Java_sun_nio_ch_SctpNet_branch0;
+		Java_sun_nio_ch_SctpNet_listen0;
+		Java_sun_nio_ch_SctpNet_connect0;
+		Java_sun_nio_ch_SctpNet_close0;
+		Java_sun_nio_ch_SctpNet_preClose0;
 		Java_sun_nio_ch_SctpNet_getLocalAddresses0;
 		Java_sun_nio_ch_SctpNet_getRemoteAddresses0;
 		Java_sun_nio_ch_SctpNet_getPrimAddrOption0;
--- a/jdk/make/com/sun/org/apache/xml/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/com/sun/org/apache/xml/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../../../../..
+MODULE  = security-xmldsig
 PACKAGE = com.sun.org.apache.xml
 PRODUCT = xml
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/com/sun/rowset/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/com/sun/rowset/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../../..
+MODULE  = jdbc-enterprise
 PACKAGE = com.sun.rowset
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/com/sun/script/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/com/sun/script/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -25,6 +25,7 @@
 
 
 BUILDDIR = ../../..
+MODULE  = scripting-rhino
 PACKAGE = com.sun.script
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/com/sun/security/auth/module/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/com/sun/security/auth/module/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -26,6 +26,7 @@
 # Makefile for building auth modules.
 
 BUILDDIR = ../../../../..
+MODULE  = security-auth
 PACKAGE = com.sun.security.auth.module
 PRODUCT = sun
 
--- a/jdk/make/com/sun/servicetag/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/com/sun/servicetag/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -22,6 +22,7 @@
 # have any questions.
 
 BUILDDIR = ../../..
+MODULE  = servicetag
 PACKAGE = com.sun.servicetag
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
@@ -68,7 +69,7 @@
 
 $(SERVICETAG_LIBDIR)/jdk_header.png: $(SHARE_SRC)/classes/com/sun/servicetag/resources/jdk_header.png
 	$(install-file)
-	$(CHMOD) 444 $@
+	$(call chmod-file, 444)
 
 install-servicetag-lib:
 	@$(RM) -rf $(SERVICETAG_LIBDIR)
--- a/jdk/make/com/sun/tools/attach/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/com/sun/tools/attach/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -25,6 +25,7 @@
 
 
 BUILDDIR = ../../../..
+MODULE  = attach
 PACKAGE = com.sun.tools.attach
 LIBRARY = attach
 PRODUCT = sun
@@ -65,6 +66,7 @@
 	@$(MKDIR) -p $(@D)
 	@$(RM) $@
 	@$(CAT) $< | $(SED) -e "s/^#\[$(PLATFORM)\]//" > $@
+	@$(install-module-file)
                                                                                                 
 .PHONY: copy-files
 
--- a/jdk/make/common/Defs.gmk	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/common/Defs.gmk	Wed Jul 05 17:06:00 2017 +0200
@@ -225,12 +225,6 @@
     endif
   endif 
 
-  ifeq ($(PLATFORM), windows)
-    FREETYPE_LIB = $(FREETYPE_LIB_PATH)/freetype.lib
-  else
-    FREETYPE_LIB = -L$(FREETYPE_LIB_PATH) -lfreetype
-  endif
-
   ifdef ALT_FREETYPE_HEADERS_PATH
     FREETYPE_HEADERS_PATH = $(ALT_FREETYPE_HEADERS_PATH)
   else
@@ -313,6 +307,9 @@
 # for generated class files
 CLASSBINDIR         = $(OUTPUTDIR)/classes
 DEMOCLASSDIR        = $(OUTPUTDIR)/democlasses
+# for modules
+MODULES_DIR         = $(OUTPUTDIR)/modules
+ABS_MODULES_DIR     = $(ABS_OUTPUTDIR)/modules
 # for generated tool class files
 BUILDTOOLCLASSDIR   = $(OUTPUTDIR)/btclasses
 # for build tool jar files
@@ -388,6 +385,22 @@
   UNIQUE_LOCATION_STRING += /$(THREADDIR)
 endif
 
+#
+# Build units may or may not define MODULE.  Default to "other".
+#
+# MODULE variable defines the lowest-level module name that
+# might or might not be the name of the modules created in
+# the modules build (see make/modules/modules.config and
+# modules.group).
+#
+MODULES_TEMPDIR     = $(OUTPUTDIR)/tmp/modules
+ABS_MODULES_TEMPDIR = $(ABS_OUTPUTDIR)/tmp/modules
+
+ifndef MODULE
+  MODULE = other
+endif
+override MODULE_DEST_DIR = $(MODULES_TEMPDIR)/$(MODULE)
+
 # the use of += above makes a space separated list which we need to 
 # remove for filespecs.
 #
@@ -498,6 +511,58 @@
 include $(JDK_MAKE_SHARED_DIR)/Defs-java.gmk
 
 #
+# Macros to find the module that $@ belongs to
+#
+
+UNIQUE_PATH_PATTERN = $(subst /,.,$(UNIQUE_PATH))
+MODULE_PATH_PATTERN = -e 's%.*\/classes\/%classes\/%' \
+		      -e 's%.*\/$(UNIQUE_PATH_PATTERN)\/%classes\/%' \
+		      -e 's%.*\/lib\/%lib\/%' \
+	              -e 's%.*\/bin\/%bin\/%' \
+	              -e 's%.*\/include\/%include\/%' \
+		      -e 's%.*\/demo\/%demo\/%' \
+		      -e 's%.*\/sample\/%sample\/%'
+
+# Install a file to its module
+define install-module-file
+dest=`echo $(@D)/ | $(SED) $(MODULE_PATH_PATTERN)` ; \
+$(MKDIR) -p $(MODULE_DEST_DIR)/$$dest; \
+$(CP) -f $@ $(MODULE_DEST_DIR)/$$dest
+endef
+
+# Install all files from the directory to its module
+define install-module-dir
+dest=`echo $(@D)/ | $(SED) $(MODULE_PATH_PATTERN)` ; \
+$(MKDIR) -p $(MODULE_DEST_DIR)/$$dest; \
+$(CP) -rf $(@D)/* $(MODULE_DEST_DIR)/$$dest
+endef
+
+# chmod the file in its module
+define chmod-module-file
+dest=`echo $@ | $(SED) $(MODULE_PATH_PATTERN)` ; \
+$(CHMOD) $1 $(MODULE_DEST_DIR)/$$dest
+endef
+
+# install a sym link in its module
+define install-module-sym-link
+dest=`echo $@ | $(SED) $(MODULE_PATH_PATTERN)` ; \
+$(LN) -sf $1 $(MODULE_DEST_DIR)/$$dest
+endef
+
+
+# Run MAKE $@ for a launcher:
+#   $(call make-launcher, name, mainclass, java-args, main-args)
+define make-launcher
+$(CD) $(BUILDDIR)/launchers && \
+$(MAKE) -f Makefile.launcher \
+        MODULE=$(MODULE) \
+        PROGRAM=$(strip $1) \
+        MAIN_CLASS=$(strip $2) \
+        MAIN_JAVA_ARGS="$(strip $3)" \
+        MAIN_ARGS="$(strip $4)"
+endef
+
+#
 # Convenient macros
 #
 
@@ -511,6 +576,28 @@
 define install-file
 $(prep-target)
 $(CP) $< $@
+$(install-module-file)
+endef
+
+define chmod-file
+$(CHMOD) $1 $@
+$(call chmod-module-file, $1)
+endef
+
+define install-sym-link
+$(LN) -s $1 $@
+$(call install-module-sym-link, $1)
+endef
+
+#
+# Marcos for files not belonging to any module 
+define install-non-module-file
+$(prep-target)
+$(CP) $< $@
+endef
+
+define install-manifest-file
+$(install-non-module-file)
 endef
 
 # Cleanup rule for after debug java run (hotspot.log file is left around)
@@ -712,7 +799,7 @@
 endif
 
 # Install of imported file (JDK_IMPORT_PATH, or some other external location)
-define install-import-file
+define install-importonly-file
 @$(ECHO) "ASSEMBLY_IMPORT: $@"
 $(prep-target)
 $(CP) $< $@
@@ -730,4 +817,9 @@
 fi
 endef
 
+define install-import-file
+$(install-importonly-file)
+$(install-module-file)
+endef
+
 .PHONY: all build clean clobber
--- a/jdk/make/common/Demo.gmk	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/common/Demo.gmk	Wed Jul 05 17:06:00 2017 +0200
@@ -25,6 +25,8 @@
 
 # JDK Demo building jar file.
   
+MODULE = demos
+
 # Some names are defined with LIBRARY inside the Defs.gmk file
 LIBRARY=$(DEMONAME)
 OBJDIR=$(TEMPDIR)/$(DEMONAME)
--- a/jdk/make/common/Library.gmk	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/common/Library.gmk	Wed Jul 05 17:06:00 2017 +0200
@@ -193,9 +193,18 @@
 	$(MT) /manifest $(OBJDIR)/$(@F).manifest /outputresource:$(OBJDIR)/$(@F);#2
 endif
 	$(CP) $(OBJDIR)/$(@F) $@
+	$(install-module-file)
 	$(CP) $(OBJDIR)/$(LIBRARY).map $(@D)
 	$(CP) $(OBJDIR)/$(LIBRARY).pdb $(@D)
 
+$(ACTUAL_LIBRARY):: $(ACTUAL_LIBRARY_DIR)/$(LIBRARY).map $(ACTUAL_LIBRARY_DIR)/$(LIBRARY).pdb
+
+$(ACTUAL_LIBRARY_DIR)/%.map: FORCE
+	$(install-module-file)
+
+$(ACTUAL_LIBRARY_DIR)/%.pdb: FORCE
+	$(install-module-file)
+
 endif # LIBRARY
 
 $(OBJDIR)/$(LIBRARY).lcf: $(OBJDIR)/$(LIBRARY).res $(COMPILE_FILES_o) $(FILES_m)
@@ -250,6 +259,7 @@
 	$(AR) -r $@ $(FILES_o)
 else # LIBRARY
 	$(LINKER) $(SHARED_LIBRARY_FLAG) -o $@ $(FILES_o) $(LDLIBS)
+	$(install-module-file)
 ifeq ($(WRITE_LIBVERSION),true)
 	$(MCS) -d -a "$(FULL_VERSION)" $@
 endif # WRITE_LIBVERSION
@@ -353,5 +363,7 @@
 openjdk:
 	$(MAKE) OPENJDK=true build
 
+FORCE:
+
 .PHONY: all build debug fastdebug
 
--- a/jdk/make/common/Modules.gmk	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/common/Modules.gmk	Wed Jul 05 17:06:00 2017 +0200
@@ -34,12 +34,10 @@
 #
 # Open issues that need further investigation:
 # 1. Classes in jre/lib/ext/dnsns.jar are currently put in jre/lib/jndi-dns
-#    module.
+#    module.  META-INF/services file is not installed.
 # 2. Signed jars
 #    For JDK build, signed jars are copied to the build.
 #    All jars in the module image are unsigned.
-# 3. jre/lib/security/US_export_policy.jar and local_policy.jar
-#    are not included in the module image yet.
 
 MODULE_IMAGEBINDIR = bin
 
@@ -63,7 +61,8 @@
 	@$(ECHO) ">>>Making "$@" @ `$(DATE)` ..."
 
 # Order is important here, trim jre after jdk image is created
-modules:: sanity-module-images post-sanity-module-images  \
+modules:: gen-modules \
+	 sanity-module-images post-sanity-module-images  \
 	 $(INITIAL_MODULE_IMAGE_JRE) $(INITIAL_MODULE_IMAGE_JDK) \
 	 trim-module-image-jre trim-module-image-jdk \
 	 process-module-image-jre process-module-image-jdk
@@ -122,8 +121,33 @@
 # JRE Image
 ######################################################
 
-MODULES_TEMPDIR=$(ABS_TEMPDIR)/modules
-MODULES_LIB = $(ABS_OUTPUTDIR)/modules
+MODULES_LIST = $(MODULES_TEMPDIR)/classlist/modules.list
+
+# Modules in the jre/lib/security directory
+POLICY_MODULES = US_export_policy local_policy
+
+# Modules in the modules/ext directory
+EXT_MODULES = localedata security-sunec security-sunjce
+
+# Build PKCS#11 on all platforms except 64-bit Windows.
+PKCS11 = security-sunpkcs11
+ifeq ($(ARCH_DATA_MODEL), 64)
+  ifeq ($(PLATFORM), windows)
+    PKCS11 =
+  endif
+endif
+
+EXT_MODULES += $(PKCS11)
+
+# Build Microsoft CryptoAPI provider only on (non-64-bit) Windows platform.
+ifeq ($(PLATFORM), windows)
+  ifneq ($(ARCH_DATA_MODEL), 64)
+    EXT_MODULES += security-sunmscapi
+  endif
+endif
+
+# Modules for JDK only
+JDK_MODULES = tools
 
 gen-modules:
 	$(CD) modules; $(MAKE) all
@@ -151,7 +175,6 @@
 # Construct an initial jre image (initial jdk jre) no trimming or stripping
 initial-module-image-jre:: initial-module-image-jre-setup \
 		    $(JRE_LICENSES) $(JRE_MODULE_DOCFILES) \
-		    gen-modules \
 		    $(BUILDMETAINDEX_JARFILE)
 	@# Copy in bin directory
 	$(CD) $(OUTPUTDIR) && $(FIND) bin -depth | $(CPIO) -pdum $(JRE_MODULE_IMAGE_DIR)
@@ -162,7 +185,21 @@
 	@#
 	@# copy modules to jre/lib
 	@#
-	$(CP) -rf $(MODULES_LIB)/jre/lib/* $(JRE_MODULE_IMAGE_DIR)/lib 
+	for m in `$(NAWK) '{print $$1}' $(MODULES_LIST)` ; do \
+	    $(CP) $(MODULES_DIR)/$$m/lib/$$m.jar $(JRE_MODULE_IMAGE_DIR)/lib ; \
+	done
+	$(MKDIR) -p $(JRE_MODULE_IMAGE_DIR)/lib/ext
+	for m in $(EXT_MODULES) ; do \
+           $(MV) $(JRE_MODULE_IMAGE_DIR)/lib/$$m.jar $(JRE_MODULE_IMAGE_DIR)/lib/ext ; \
+        done
+	for m in $(POLICY_MODULES) ; do \
+           $(MV) $(JRE_MODULE_IMAGE_DIR)/lib/$$m.jar $(JRE_MODULE_IMAGE_DIR)/lib/security; \
+        done
+	@# Remove jdk modules
+	for m in $(JDK_MODULES) ; do \
+           $(RM) $(JRE_MODULE_IMAGE_DIR)/lib/$$m.jar ; \
+        done
+
 	@# Make sure all directories are read/execute for everyone
 	$(CHMOD) a+rx `$(FIND) $(JRE_MODULE_IMAGE_DIR) -type d`
 	@# Remove some files from the jre area
@@ -304,7 +341,9 @@
 	@# copy jdk modules to jdk/lib
 	@#
 	$(MKDIR) -p $(JDK_MODULE_IMAGE_DIR)/lib
-	$(CP) -rf $(MODULES_LIB)/lib/* $(JDK_MODULE_IMAGE_DIR)/lib 
+	for m in $(JDK_MODULES) ; do \
+	    $(CP) $(MODULES_DIR)/$$m/lib/$$m.jar $(JDK_MODULE_IMAGE_DIR)/lib ; \
+        done
   ifeq ($(PLATFORM), windows)
 	@#
 	@# lib/
--- a/jdk/make/common/Program.gmk	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/common/Program.gmk	Wed Jul 05 17:06:00 2017 +0200
@@ -50,8 +50,6 @@
 ACTUAL_PROGRAM_DIR  = $(BINDIR)
 ACTUAL_PROGRAM      = $(ACTUAL_PROGRAM_DIR)/$(ACTUAL_PROGRAM_NAME)
 
-JVMCFG = $(LIBDIR)/$(LIBARCH)/jvm.cfg
-
 # Make sure the default rule is all
 program_default_rule: all
 
@@ -116,7 +114,7 @@
 
 ifeq ($(COMPILE_IT),true)
 
-$(ACTUAL_PROGRAM):: classes $(JVMCFG) $(INIT) 
+$(ACTUAL_PROGRAM):: classes $(INIT) 
 
 #
 # Windows only
@@ -190,12 +188,13 @@
 	@$(MKDIR) -p $(TEMPDIR)
 	$(LINK_PRE_CMD) $(CC) $(CC_OBJECT_OUTPUT_FLAG)$@ $(LDFLAGS) \
 	    $(FILES_o) $(THREADLIBS) $(LDLIBS)
+	$(install-module-file)
 
 endif # PLATFORM
 
 else  # COMPILE_IT
 
-$(ACTUAL_PROGRAM):: $(JVMCFG)
+$(ACTUAL_PROGRAM)::
 
 # Copies in the file from the JDK_IMPORT_PATH area
 $(ACTUAL_PROGRAM_DIR)/%: $(JDK_IMPORT_PATH)/jre/bin/%
@@ -272,18 +271,6 @@
 		$(VERSION_DEFINES) $<
 
 #
-# How to install jvm.cfg. 
-#
-ifeq ($(ZERO_BUILD), true)
-JVMCFG_ARCH = zero
-else
-JVMCFG_ARCH = $(ARCH)
-endif
-
-$(JVMCFG): $(LAUNCHER_PLATFORM_SRC)/bin/$(JVMCFG_ARCH)/jvm.cfg 
-	$(install-file)
-
-#
 # Default dependencies
 #
 
--- a/jdk/make/common/internal/BinaryPlugs.gmk	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/common/internal/BinaryPlugs.gmk	Wed Jul 05 17:06:00 2017 +0200
@@ -116,7 +116,7 @@
 
 define import-binary-plug-file
 @$(ECHO) "PLUG IMPORT: $(@F)"
-$(install-file)
+$(install-non-module-file)
 endef # import-binary-plug-file
 
 # Import classes command
@@ -184,7 +184,7 @@
 
 define export-binary-plug-file
 @$(ECHO) "PLUG EXPORT: $(@F)"
-$(install-file)
+$(install-non-module-file)
 endef # export-binary-plug-file
 
 # OpenJDK Binary Plug License
--- a/jdk/make/common/internal/Resources.gmk	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/common/internal/Resources.gmk	Wed Jul 05 17:06:00 2017 +0200
@@ -139,7 +139,7 @@
 STRIP_PROP_options=$(TEMPDIR)/strip_prop_options
 define install-properties-file
 $(install-file)
-$(CHMOD) a+rw $@
+$(call chmod-file, a+rw)
 @$(ECHO) "# Adding to strip properties list: $@"
 $(ECHO) "$@" >> $(STRIP_PROP_options)
 endef
--- a/jdk/make/common/shared/Sanity.gmk	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/common/shared/Sanity.gmk	Wed Jul 05 17:06:00 2017 +0200
@@ -1117,7 +1117,7 @@
 #    be checked when this represents a full control build (i.e. the
 #    HOTSPOT_IMPORT_PATH includes these files in it's 'include' directory).
 $(TEMPDIR)/%.h: $(SHARE_SRC)/javavm/export/%.h
-	@$(install-file)
+	@$(install-non-module-file)
 	@$(RM) $@.IMPORT
 	@if [ -r $(HOTSPOT_IMPORT_PATH)/include/$(@F) ]; then \
 	  $(CP) $(HOTSPOT_IMPORT_PATH)/include/$(@F) $@.IMPORT ; \
@@ -1131,7 +1131,7 @@
 	fi
 
 $(TEMPDIR)/%.h: $(PLATFORM_SRC)/javavm/export/%.h
-	@$(install-file)
+	@$(install-non-module-file)
 	@$(RM) $@.IMPORT
 	@if [ -r $(HOTSPOT_IMPORT_PATH)/include/$(PLATFORM_INCLUDE_NAME)/$(@F) ]; then \
 	  $(CP) $(HOTSPOT_IMPORT_PATH)/include/$(PLATFORM_INCLUDE_NAME)/$(@F) $@.IMPORT ; \
--- a/jdk/make/java/awt/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/java/awt/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = awt
 PACKAGE = java.awt
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/java/fdlibm/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/java/fdlibm/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -31,6 +31,7 @@
 #
 
 BUILDDIR     = ../..
+MODULE       = base
 LIBRARY      = fdlibm
 PRODUCT      = java
 
--- a/jdk/make/java/hpi/native/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/java/hpi/native/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR     = ../../..
+MODULE       = base
 LIBRARY      = hpi
 PRODUCT      = java
 THREADDIR    = native_threads
--- a/jdk/make/java/hpi/windows/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/java/hpi/windows/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -26,8 +26,9 @@
 #
 # Makefile for Windows HPI DLL
 #
-BUILDDIR = ../../..
-LIBRARY   = hpi
+BUILDDIR     = ../../..
+MODULE       = base
+LIBRARY      = hpi
 PRODUCT      = java
 THREADDIR    = windows_threads
 LIB_LOCATION = $(BINDIR)
--- a/jdk/make/java/instrument/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/java/instrument/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -27,6 +27,7 @@
 # agent, supporting java.lang.instrument
 
 BUILDDIR = ../..
+MODULE  = instrument
 PACKAGE = sun.instrument
 LIBRARY = instrument
 PRODUCT = sun
--- a/jdk/make/java/java/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/java/java/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -29,6 +29,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = base
 PACKAGE = java.lang
 LIBRARY = java
 PRODUCT = java
@@ -241,7 +242,7 @@
 
 $(GENSRCDIR)/java/lang/UNIXProcess.java: \
     $(PLATFORM_SRC)/classes/java/lang/UNIXProcess.java.$(PLATFORM)
-	$(install-file)
+	$(install-non-module-file)
 
 clean:: 
 	$(RM) $(GENSRCDIR)/java/lang/UNIXProcess.java
@@ -285,7 +286,7 @@
 
 $(TZMAP): $(TZMAPFILE)
 	$(install-file)
-	$(CHMOD) 444 $@
+	$(call chmod-file, 444)
 endif
 
 build: $(LIBDIR)/$(PROPS) $(LIBDIR)/$(CAL_PROPS) $(TZMAP)
@@ -315,7 +316,8 @@
 	$(BOOT_JAVA_CMD) -jar $(GENERATECURRENCYDATA_JARFILE) -o $@.temp \
 		< $(SHARE_SRC)/classes/java/util/CurrencyData.properties
 	$(MV) $@.temp $@
-	$(CHMOD) 444 $@
+	$(install-module-file)
+	$(call chmod-file, 444)
 
 clean:: 
 	$(RM) $(CURDATA)
@@ -369,7 +371,7 @@
 		-usecharforbyte 11 4 1
 
 $(GENSRCDIR)/java/lang/%.java : $(CHARACTERDATA)/%.java.template
-	$(install-file)
+	$(install-non-module-file)
 
 clean::
 	$(RM) $(GENSRCDIR)/java/lang/CharacterDataLatin1.java 
--- a/jdk/make/java/java_crw_demo/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/java/java_crw_demo/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,8 @@
 #
 
 BUILDDIR = ../..
+
+MODULE  = demos
 LIBRARY = java_crw_demo
 PRODUCT = sun
 LIBRARY_OUTPUT = java_crw_demo
--- a/jdk/make/java/java_hprof_demo/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/java/java_hprof_demo/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = instrument
 LIBRARY = hprof
 PRODUCT = sun
 LIBRARY_OUTPUT = hprof_jvmti
--- a/jdk/make/java/jli/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/java/jli/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -30,6 +30,7 @@
 # its manifestations (java, javaw, javac, ...).
 #
 BUILDDIR = ../..
+MODULE  = base
 LIBRARY = jli
 PRODUCT = java
 
--- a/jdk/make/java/jvm/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/java/jvm/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,8 @@
 #
 
 BUILDDIR = ../..
+MODULE   = base
+
 include $(BUILDDIR)/common/Defs.gmk
 
 #
@@ -36,15 +38,29 @@
 	  $(INCLUDEDIR)/classfile_constants.h
 
 $(INCLUDEDIR)/%.h: $(SHARE_SRC)/javavm/export/%.h
-	$(install-file)
+	$(install-non-module-file)
 
 $(PLATFORM_INCLUDE)/%.h: $(PLATFORM_SRC)/javavm/export/%.h
+	$(install-non-module-file)
+
+JVMCFG = $(LIBDIR)/$(LIBARCH)/jvm.cfg
+
+#
+# How to install jvm.cfg.
+#
+ifeq ($(ZERO_BUILD), true)
+JVMCFG_ARCH = zero
+else
+JVMCFG_ARCH = $(ARCH)
+endif
+
+$(JVMCFG): $(PLATFORM_SRC)/bin/$(JVMCFG_ARCH)/jvm.cfg
 	$(install-file)
 
 all: build
 
-build: $(FILES_h)
+build: $(FILES_h) $(JVMCFG)
 
 clean clobber:: 
-	$(RM) $(FILES_h)
+	$(RM) $(FILES_h) $(JVMCFG)
 
--- a/jdk/make/java/logging/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/java/logging/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = logging
 PACKAGE = java.util.logging
 PRODUCT = java
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/java/main/java/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/java/main/java/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,7 @@
 #
 
 BUILDDIR = ../../..
+MODULE  = base
 PROGRAM = java
 PRODUCT = java
 
--- a/jdk/make/java/main/javaw/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/java/main/javaw/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../../..
+MODULE  = base
 PROGRAM = javaw
 PRODUCT = java
 
--- a/jdk/make/java/management/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/java/management/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = management
 PACKAGE = java.lang.management
 LIBRARY = management
 PRODUCT = java
@@ -99,7 +100,7 @@
 	@$(java-vm-cleanup)
 
 $(TEMPDIR)/manifest: $(MANIFEST)
-	$(install-file)
+	$(install-manifest-file)
 
 build: $(AGENTJAR)
 
--- a/jdk/make/java/net/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/java/net/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = base
 PACKAGE = java.net
 LIBRARY = net
 PRODUCT = sun
@@ -111,8 +112,7 @@
 MISC_FILES = $(LIBDIR) $(LIBDIR)/net.properties
 
 $(LIBDIR)/net.properties: $(SHARE_SRC)/lib/net.properties
-	@$(RM) $@
-	$(CP) $< $@
+	$(install-file)
 
 # 
 # SDP configuration template
--- a/jdk/make/java/nio/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/java/nio/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = nio
 PACKAGE = java.nio
 LIBRARY = nio
 PRODUCT = java
@@ -816,7 +817,7 @@
 	$(NAWK) '/^.*Copyright.*Sun/ { print $$3 }') 
 
 $(TEMPDIR)/$(GENSOR_SRC) : $(GENSOR_SRC)
-	$(install-file)
+	$(install-non-module-file)
 
 $(GENSOR_EXE) : $(TEMPDIR)/$(GENSOR_SRC)
 	$(prep-target)
--- a/jdk/make/java/npt/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/java/npt/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,9 @@
 #
 
 BUILDDIR = ../..
+
+# It's currently used by jpda and hprof.  Put it in base module for now.
+MODULE  = base
 LIBRARY = npt
 PRODUCT = sun
 LIBRARY_OUTPUT = npt
--- a/jdk/make/java/redist/FILES.gmk	Thu Jan 21 11:12:31 2010 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-#
-# Copyright 1998-2003 Sun Microsystems, Inc.  All Rights Reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.  Sun designates this
-# particular file as subject to the "Classpath" exception as provided
-# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
-# CA 95054 USA or visit www.sun.com if you need additional information or
-# have any questions.
-#
-
-#
-# List of lucida font files that we redistribute.
-#
-
-SHARED_FONTFILES =					\
-	$(LIBDIR)/fonts/LucidaTypewriterRegular.ttf	\
-	$(LIBDIR)/fonts/LucidaTypewriterBold.ttf        \
-	$(LIBDIR)/fonts/LucidaBrightRegular.ttf         \
-	$(LIBDIR)/fonts/LucidaBrightDemiBold.ttf        \
-	$(LIBDIR)/fonts/LucidaBrightItalic.ttf          \
-	$(LIBDIR)/fonts/LucidaBrightDemiItalic.ttf	\
-	$(LIBDIR)/fonts/LucidaSansRegular.ttf       	\
-	$(LIBDIR)/fonts/LucidaSansDemiBold.ttf       	\
-
-ifeq ($(PLATFORM), linux)
-
-# The oblique versions of the font are derived from the base versions
-# and since 2D can do this derivation on the fly at run time there is no
-# need to redistribute the fonts. An exception to this is on Linux.
-# The reason is that the Lucidas are specified in the font.properties files
-# on Linux, and so AWT/Motif components expect to be able to ask the Xserver
-# for these oblique fonts, but the Xserver cannot do the same derivation as
-# 2D can.
-
-OBLIQUE_FONTFILES =                                             \
-	$(LIBDIR)/oblique-fonts/LucidaTypewriterOblique.ttf     \
-	$(LIBDIR)/oblique-fonts/LucidaTypewriterBoldOblique.ttf \
-	$(LIBDIR)/oblique-fonts/LucidaSansOblique.ttf       	\
-	$(LIBDIR)/oblique-fonts/LucidaSansDemiOblique.ttf       \
-
-endif
--- a/jdk/make/java/redist/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/java/redist/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -35,6 +35,7 @@
 # 
 
 BUILDDIR = ../..
+MODULE   = base
 PRODUCT  = java
 include $(BUILDDIR)/common/Defs.gmk
 
@@ -61,7 +62,11 @@
 # Needed to do file copy
 ABS_BUILDDIR :=$(call FullPath,$(BUILDDIR))
 
-all: build
+SUBDIRS = fonts sajdi
+all clean clobber::
+	$(SUBDIRS-loop)
+
+all:: build
 
 # List of files created here or coming from BUILDDIR area (this workspace)
 INTERNAL_IMPORT_LIST = $(LIBDIR)/classlist
@@ -70,30 +75,6 @@
 IMPORT_LIST = $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVM_NAME) \
               $(LIB_LOCATION)/$(SERVER_LOCATION)/Xusage.txt
 
-# INCLUDE_SA is false on platforms where SA is not supported.
-# On platforms where it is supported, we want to allow it to
-# not be present, at least temporarily.  So,
-# if the SA files (well, just sa-jdi.jar) do not exist 
-# in the HOTSPOT_IMPORT_PATH, then we won't build SA.
-SA_EXISTS := $(shell if [ -r $(HOTSPOT_IMPORT_PATH)/lib/sa-jdi.jar ] ; then \
-                          $(ECHO) true; \
-                        else \
-                          $(ECHO) false; \
-                        fi)
-
-ifeq ($(SA_EXISTS), false)
-  INCLUDE_SA := false
-endif
-
-ifeq ($(INCLUDE_SA), true)
-  IMPORT_LIST += $(LIBDIR)/sa-jdi.jar \
-                 $(LIB_LOCATION)/$(SALIB_NAME)
-  ifeq ($(PLATFORM), windows)
-    IMPORT_LIST += $(LIB_LOCATION)/$(SAMAP_NAME) \
-                   $(LIB_LOCATION)/$(SAPDB_NAME)
-  endif
-endif # INCLUDE_SA
-
 # Hotspot client is only available on 32-bit non-Zero builds
 ifneq ($(ZERO_BUILD), true)
 ifeq ($(ARCH_DATA_MODEL), 32)
@@ -110,10 +91,10 @@
 # NOTE: These might actually come from BUILDDIR, depends on the settings.
 $(BINDIR)/msvcrt.dll: $(MSVCRT_DLL_PATH)/msvcrt.dll
 	$(install-import-file)
-	$(CHMOD) a+x $@
+	$(call chmod-file, a+x)
 $(BINDIR)/$(MSVCRNN_DLL): $(MSVCRNN_DLL_PATH)/$(MSVCRNN_DLL)
 	$(install-import-file)
-	$(CHMOD) a+x $@
+	$(call chmod-file, a+x)
 
 # Get the hotspot .map and .pdb files for client and server
 IMPORT_LIST += \
@@ -140,26 +121,32 @@
 $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMMAP_NAME):
 	@$(prep-target)
 	-$(CP) $(HOTSPOT_CLIENT_PATH)/$(JVMMAP_NAME)  $@
+	@$(install-module-file)
 
 $(LIB_LOCATION)/$(KERNEL_LOCATION)/$(JVMMAP_NAME):
 	@$(prep-target)
 	-$(CP) $(HOTSPOT_KERNEL_PATH)/$(JVMMAP_NAME)  $@
+	@$(install-module-file)
 
 $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMMAP_NAME):
 	@$(prep-target)
 	-$(CP) $(HOTSPOT_SERVER_PATH)/$(JVMMAP_NAME) $@
+	@$(install-module-file)
 
 $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMPDB_NAME):
 	@$(prep-target)
 	-$(CP) $(HOTSPOT_CLIENT_PATH)/$(JVMPDB_NAME)  $@
+	@$(install-module-file)
 
 $(LIB_LOCATION)/$(KERNEL_LOCATION)/$(JVMPDB_NAME):
 	@$(prep-target)
 	-$(CP) $(HOTSPOT_KERNEL_PATH)/$(JVMPDB_NAME)  $@
+	@$(install-module-file)
 
 $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMPDB_NAME): 
 	@$(prep-target)
 	-$(CP) $(HOTSPOT_SERVER_PATH)/$(JVMPDB_NAME) $@
+	@$(install-module-file)
 
 #  Windows     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  Windows
 else # PLATFORM
@@ -220,7 +207,7 @@
 $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(LIBJSIG_NAME) \
 $(LIB_LOCATION)/$(SERVER_LOCATION)/$(LIBJSIG_NAME):
 	@$(prep-target)
-	$(LN) -s ../$(LIBJSIG_NAME) $@
+	$(call install-sym-link, ../$(LIBJSIG_NAME))
 
 $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMDB_NAME): $(HOTSPOT_CLIENT_PATH)/$(JVMDB_NAME)
 	$(install-import-file)
@@ -246,28 +233,6 @@
 $(LIB_LOCATION)/$(KERNEL_LOCATION)/Xusage.txt : $(HOTSPOT_KERNEL_PATH)/Xusage.txt
 	$(install-file)
 
-ifeq ($(INCLUDE_SA), true)
-# The Serviceability Agent is built in the Hotspot workspace.
-# It contains two files:
-#  - sa-jdi.jar:  This goes into the same dir as tools.jar.
-#  - a shared library:  sawindbg.dll on windows / libproc.sa on unix
-#		        This goes into the same dir as the other
-#			shared libs, eg. libjdwp.so.
-$(LIBDIR)/sa-jdi.jar: $(HOTSPOT_IMPORT_PATH)/lib/sa-jdi.jar
-	$(install-import-file)
-
-$(LIB_LOCATION)/$(SALIB_NAME): $(HOTSPOT_SALIB_PATH)/$(SALIB_NAME)
-	$(install-import-file)
-
-ifeq ($(PLATFORM), windows)
-$(LIB_LOCATION)/$(SAPDB_NAME): $(HOTSPOT_SALIB_PATH)/$(SAPDB_NAME)
-	$(install-import-file)
-
-$(LIB_LOCATION)/$(SAMAP_NAME): $(HOTSPOT_SALIB_PATH)/$(SAMAP_NAME)
-	$(install-import-file)
-endif # windows
-endif # INCLUDE_SA
-
 #
 # Specific to OpenJDK building
 #
@@ -288,7 +253,7 @@
 
 $(LIBDIR)/jce.jar: \
 	    $(BUILDDIR)/closed/tools/crypto/jce/jce.jar
-	$(install-file)
+	$(install-non-module-file)
 $(LIBDIR)/security/US_export_policy.jar: \
 	    $(BUILDDIR)/closed/tools/crypto/jce/US_export_policy.jar
 	$(install-file)
@@ -310,46 +275,6 @@
 	    $(CLASSSHARINGDATA_DIR)/classlist.$(PLATFORM) $@.temp
 	$(MV) $@.temp $@
 
-ifndef OPENJDK
-
-# Lucida font files are not included in the OpenJDK distribution.
-# Get names of font files
-include FILES.gmk
-
-# Copy font files into OUTPUTDIR area
-
-FONTFILES = $(SHARED_FONTFILES)
-FONTSDIR  = $(LIBDIR)/fonts
-FONTSDIRFILE  = $(FONTSDIR)/fonts.dir
-INTERNAL_IMPORT_LIST += $(FONTFILES) 
-
-ifneq ($(PLATFORM), windows)
-  INTERNAL_IMPORT_LIST += $(FONTSDIRFILE)
-endif
-
-$(LIBDIR)/fonts/%.ttf: $(CLOSED_SRC)/share/lib/fonts/%.ttf
-	$(install-file)
-
-$(FONTSDIRFILE): $(PLATFORM_SRC)/classes/sun/awt/motif/java.fonts.dir
-	$(install-file)
-
-ifeq ($(PLATFORM), linux)
-
-# The oblique fonts are only needed/wanted on Linux.
-
-OBLFONTSDIR  = $(LIBDIR)/oblique-fonts
-OBLFONTSDIRFILE	 = $(OBLFONTSDIR)/fonts.dir
-INTERNAL_IMPORT_LIST += $(OBLIQUE_FONTFILES) $(OBLFONTSDIRFILE)
-
-$(LIBDIR)/oblique-fonts/%.ttf: $(CLOSED_SRC)/share/lib/fonts/oblique/%.ttf
-	$(install-file)
-
-$(OBLFONTSDIRFILE): $(PLATFORM_SRC)/classes/sun/awt/motif/java.oblique-fonts.dir
-	$(install-file)
-
-endif # linux
-endif # !OPENJDK
-
 # Import internal files (ones that are stashed in this source tree)
 import_internal_files : $(INTERNAL_IMPORT_LIST)
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/make/java/redist/fonts/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -0,0 +1,111 @@
+#
+# Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Sun designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+
+BUILDDIR = ../../..
+MODULE   = font
+PRODUCT  = java
+include $(BUILDDIR)/common/Defs.gmk
+
+
+#
+# List of lucida font files that we redistribute.
+#
+
+SHARED_FONTFILES =					\
+	$(LIBDIR)/fonts/LucidaTypewriterRegular.ttf	\
+	$(LIBDIR)/fonts/LucidaTypewriterBold.ttf        \
+	$(LIBDIR)/fonts/LucidaBrightRegular.ttf         \
+	$(LIBDIR)/fonts/LucidaBrightDemiBold.ttf        \
+	$(LIBDIR)/fonts/LucidaBrightItalic.ttf          \
+	$(LIBDIR)/fonts/LucidaBrightDemiItalic.ttf	\
+	$(LIBDIR)/fonts/LucidaSansRegular.ttf       	\
+	$(LIBDIR)/fonts/LucidaSansDemiBold.ttf       	\
+
+ifeq ($(PLATFORM), linux)
+
+# The oblique versions of the font are derived from the base versions
+# and since 2D can do this derivation on the fly at run time there is no
+# need to redistribute the fonts. An exception to this is on Linux.
+# The reason is that the Lucidas are specified in the font.properties files
+# on Linux, and so AWT/Motif components expect to be able to ask the Xserver
+# for these oblique fonts, but the Xserver cannot do the same derivation as
+# 2D can.
+
+OBLIQUE_FONTFILES =                                             \
+	$(LIBDIR)/oblique-fonts/LucidaTypewriterOblique.ttf     \
+	$(LIBDIR)/oblique-fonts/LucidaTypewriterBoldOblique.ttf \
+	$(LIBDIR)/oblique-fonts/LucidaSansOblique.ttf       	\
+	$(LIBDIR)/oblique-fonts/LucidaSansDemiOblique.ttf       \
+
+endif
+
+ifndef OPENJDK
+
+# Lucida font files are not included in the OpenJDK distribution.
+# Get names of font files
+
+# Copy font files into OUTPUTDIR area
+
+FONTFILES = $(SHARED_FONTFILES)
+FONTSDIR  = $(LIBDIR)/fonts
+FONTSDIRFILE  = $(FONTSDIR)/fonts.dir
+INTERNAL_IMPORT_LIST = $(FONTFILES) 
+
+ifneq ($(PLATFORM), windows)
+  INTERNAL_IMPORT_LIST += $(FONTSDIRFILE)
+endif
+
+$(LIBDIR)/fonts/%.ttf: $(CLOSED_SRC)/share/lib/fonts/%.ttf
+	$(install-file)
+
+$(FONTSDIRFILE): $(PLATFORM_SRC)/classes/sun/awt/motif/java.fonts.dir
+	$(install-file)
+
+ifeq ($(PLATFORM), linux)
+
+# The oblique fonts are only needed/wanted on Linux.
+
+OBLFONTSDIR  = $(LIBDIR)/oblique-fonts
+OBLFONTSDIRFILE	 = $(OBLFONTSDIR)/fonts.dir
+INTERNAL_IMPORT_LIST += $(OBLIQUE_FONTFILES) $(OBLFONTSDIRFILE)
+
+$(LIBDIR)/oblique-fonts/%.ttf: $(CLOSED_SRC)/share/lib/fonts/oblique/%.ttf
+	$(install-file)
+
+$(OBLFONTSDIRFILE): $(PLATFORM_SRC)/classes/sun/awt/motif/java.oblique-fonts.dir
+	$(install-file)
+
+endif # linux
+
+all build : $(INTERNAL_IMPORT_LIST)
+
+clean clobber::
+	$(RM) $(INTERNAL_IMPORT_LIST)
+
+else 
+
+all build clean clobber :
+
+endif # !OPENJDK
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/make/java/redist/sajdi/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -0,0 +1,87 @@
+#
+# Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Sun designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+
+BUILDDIR = ../../..
+MODULE   = sajdi
+PRODUCT  = java
+include $(BUILDDIR)/common/Defs.gmk
+
+ifeq ($(PLATFORM), windows)
+  LIB_LOCATION = $(BINDIR)
+else
+  LIB_LOCATION = $(LIBDIR)/$(LIBARCH)
+endif
+
+# INCLUDE_SA is false on platforms where SA is not supported.
+# On platforms where it is supported, we want to allow it to
+# not be present, at least temporarily.  So,
+# if the SA files (well, just sa-jdi.jar) do not exist
+# in the HOTSPOT_IMPORT_PATH, then we won't build SA.
+SA_EXISTS := $(shell if [ -r $(HOTSPOT_IMPORT_PATH)/lib/sa-jdi.jar ] ; then \
+                          $(ECHO) true; \
+                        else \
+                          $(ECHO) false; \
+                        fi)
+
+ifeq ($(SA_EXISTS), false)
+  INCLUDE_SA := false
+endif
+
+IMPORT_LIST =
+ifeq ($(INCLUDE_SA), true)
+  IMPORT_LIST += $(LIBDIR)/sa-jdi.jar \
+                 $(LIB_LOCATION)/$(SALIB_NAME)
+  ifeq ($(PLATFORM), windows)
+    IMPORT_LIST += $(LIB_LOCATION)/$(SAMAP_NAME) \
+                   $(LIB_LOCATION)/$(SAPDB_NAME)
+  endif
+endif # INCLUDE_SA
+
+
+ifeq ($(INCLUDE_SA), true)
+# The Serviceability Agent is built in the Hotspot workspace.
+# It contains two files:
+#  - sa-jdi.jar:  This goes into the same dir as tools.jar.
+#  - a shared library:  sawindbg.dll on windows / libproc.sa on unix
+#		        This goes into the same dir as the other
+#			shared libs, eg. libjdwp.so.
+$(LIBDIR)/sa-jdi.jar: $(HOTSPOT_IMPORT_PATH)/lib/sa-jdi.jar
+	$(install-importonly-file)
+
+$(LIB_LOCATION)/$(SALIB_NAME): $(HOTSPOT_SALIB_PATH)/$(SALIB_NAME)
+	$(install-import-file)
+
+ifeq ($(PLATFORM), windows)
+$(LIB_LOCATION)/$(SAPDB_NAME): $(HOTSPOT_SALIB_PATH)/$(SAPDB_NAME)
+	$(install-import-file)
+
+$(LIB_LOCATION)/$(SAMAP_NAME): $(HOTSPOT_SALIB_PATH)/$(SAMAP_NAME)
+	$(install-import-file)
+endif # windows
+endif # INCLUDE_SA
+
+all: $(IMPORT_LIST)
+
+clean clobber::
--- a/jdk/make/java/security/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/java/security/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = base
 PACKAGE = java.security
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
@@ -38,11 +39,9 @@
 #
 
 PROPS_SRC   = $(TOPDIR)/src/share/lib/security/java.security
-SUNPKCS11   =
 
 ifeq ($(PLATFORM), solaris)
 PROPS_SRC   = $(TOPDIR)/src/share/lib/security/java.security-solaris
-SUNPKCS11   = sunpkcs11
 
 else # PLATFORM
 
@@ -57,9 +56,6 @@
 
 PROPS_BUILD = $(LIBDIR)/security/java.security
 
-SUNPKCS11_SRC   = $(TOPDIR)/src/share/lib/security/sunpkcs11-solaris.cfg
-SUNPKCS11_BUILD = $(LIBDIR)/security/sunpkcs11-solaris.cfg
-
 POLICY_SRC =	$(TOPDIR)/src/share/lib/security/java.policy
 POLICY_BUILD = $(LIBDIR)/security/java.policy
 
@@ -73,14 +69,12 @@
 #
 include $(BUILDDIR)/common/Rules.gmk
 
-build: properties $(SUNPKCS11) policy cacerts
+build: properties policy cacerts
 
 install: all
 
 properties: classes  $(PROPS_BUILD)
 
-sunpkcs11: classes $(SUNPKCS11_BUILD)
-
 policy: classes  $(POLICY_BUILD)
 
 cacerts: classes $(CACERTS_BUILD)
@@ -88,9 +82,6 @@
 $(PROPS_BUILD): $(PROPS_SRC)
 	$(install-file)
 
-$(SUNPKCS11_BUILD): $(SUNPKCS11_SRC)
-	$(install-file)
-
 $(POLICY_BUILD): $(POLICY_SRC)
 	$(install-file)
 
@@ -99,7 +90,7 @@
 
 clean clobber:: .delete.classlist
 	$(RM) -r $(CLASSBINDIR)/java/security
-	$(RM) $(PROPS_BUILD) $(POLICY_BUILD) $(CACERTS_BUILD) $(SUNPKCS11_BUILD)
+	$(RM) $(PROPS_BUILD) $(POLICY_BUILD) $(CACERTS_BUILD)
 
 # Additional Rule for building sun.security.util
 $(CLASSBINDIR)/%.class: $(SHARE_SRC)/sun/%.java
--- a/jdk/make/java/sql/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/java/sql/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = jdbc-base
 PACKAGE = java.sql
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/java/text/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/java/text/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,7 +24,7 @@
 #
 
 BUILDDIR = ../..
-
+MODULE  = base
 PACKAGE = java.text
 PRODUCT = sun
 
--- a/jdk/make/java/verify/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/java/verify/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = base
 PRODUCT = java
 LIBRARY = verify
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/java/zip/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/java/zip/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -25,6 +25,7 @@
 
 
 BUILDDIR = ../..
+MODULE  = base
 PACKAGE = java.util.zip
 LIBRARY = zip
 PRODUCT = sun
--- a/jdk/make/javax/crypto/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/javax/crypto/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -108,6 +108,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = base
 PACKAGE = javax.crypto
 PRODUCT = sun
 
@@ -293,7 +294,7 @@
 
 $(UNSIGNED_POLICY_BUILDDIR)/limited/US_export_policy.jar:		\
 	    $(UNSIGNED_POLICY_BUILDDIR)/unlimited/US_export_policy.jar
-	$(install-file)
+	$(install-non-module-file)
 
 $(UNSIGNED_POLICY_BUILDDIR)/limited/local_policy.jar:			\
 	    policy/limited/default_local.policy				\
@@ -414,7 +415,7 @@
 else
 $(JAR_DESTFILE): $(SIGNED_DIR)/jce.jar
 endif
-	$(install-file)
+	$(install-non-module-file)
 
 #
 # Install the appropriate policy file, depending on the type of build.
@@ -425,7 +426,7 @@
 INSTALL_POLICYDIR = $(SIGNED_POLICY_BUILDDIR)
 endif
 
-install-limited: \
+install-limited-jars: \
 	    $(INSTALL_POLICYDIR)/limited/US_export_policy.jar	\
 	    $(INSTALL_POLICYDIR)/limited/local_policy.jar
 	$(MKDIR) -p $(POLICY_DESTDIR)
@@ -433,24 +434,28 @@
 	    $(POLICY_DESTDIR)/US_export_policy.jar		\
 	    $(POLICY_DESTDIR)/local_policy.jar
 	$(CP) $^ $(POLICY_DESTDIR)
+
+install-limited: install-limited-jars install-module-files
 ifndef OPENJDK
 	$(release-warning)
 endif
 
-install-unlimited: \
+install-unlimited-jars: \
 	    $(INSTALL_POLICYDIR)/unlimited/US_export_policy.jar	\
-	    $(INSTALL_POLICYDIR)/unlimited/local_policy.jar
+	    $(INSTALL_POLICYDIR)/unlimited/local_policy.jar 
 	$(MKDIR) -p $(POLICY_DESTDIR)
 	$(RM) \
 	    $(POLICY_DESTDIR)/US_export_policy.jar		\
 	    $(POLICY_DESTDIR)/local_policy.jar
 	$(CP) $^ $(POLICY_DESTDIR)
+
+install-unlimited: install-unlimited-jars install-module-files
 ifndef OPENJDK
 	$(release-warning)
 endif
 
 ifndef OPENJDK
-install-prebuilt:
+install-prebuilt-jars:
 	@$(ECHO) "\n>>>Installing prebuilt JCE framework..."
 	$(RM) $(JAR_DESTFILE) \
 	    $(POLICY_DESTDIR)/US_export_policy.jar \
@@ -460,8 +465,16 @@
 	    $(PREBUILT_DIR)/jce/US_export_policy.jar \
 	    $(PREBUILT_DIR)/jce/local_policy.jar \
 	    $(POLICY_DESTDIR)
+
+install-prebuilt: install-prebuilt-jars install-module-files
 endif
 
+install-module-files: \
+	   $(POLICY_DESTDIR)/US_export_policy.jar \
+	   $(POLICY_DESTDIR)/local_policy.jar
+
+$(POLICY_DESTDIR)/%.jar :
+	$(install-module-file)
 
 # =====================================================
 # Support routines.
--- a/jdk/make/javax/imageio/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/javax/imageio/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = imageio
 PACKAGE = javax.imageio
 PRODUCT = jiio
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/javax/print/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/javax/print/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = print
 PACKAGE = javax.print
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/javax/sound/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/javax/sound/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -26,6 +26,7 @@
 # WARNING: Make sure the OPENJDK plugs are up-to-date, see make/common/internal/BinaryPlugs.gmk
 
 BUILDDIR = ../..
+MODULE  = sound
 PACKAGE = javax.sound
 LIBRARY = jsound
 PRODUCT = sun
--- a/jdk/make/javax/sound/jsoundalsa/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/javax/sound/jsoundalsa/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,7 @@
 #
 
 BUILDDIR = ../../..
+MODULE  = sound
 PACKAGE = javax.sound
 LIBRARY = jsoundalsa
 PRODUCT = sun
--- a/jdk/make/javax/sound/jsoundds/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/javax/sound/jsoundds/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,7 @@
 #
 
 BUILDDIR = ../../..
+MODULE  = sound
 PACKAGE = javax.sound
 LIBRARY = jsoundds
 PRODUCT = sun
--- a/jdk/make/javax/sql/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/javax/sql/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = jdbc-enterprise
 PACKAGE = javax.sql
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/javax/swing/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/javax/swing/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,7 @@
 #
 
 BUILDDIR  = ../..
+MODULE    = swing
 PACKAGE   = javax.swing
 PRODUCT   = com
 SWING_SRC = $(SHARE_SRC)/classes/javax/swing
--- a/jdk/make/javax/swing/plaf/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/javax/swing/plaf/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,7 @@
 #
 
 BUILDDIR  = ../../..
+MODULE    = swing
 PACKAGE   = javax.swing.plaf
 PRODUCT   = com
 SWING_SRC = $(SHARE_SRC)/classes/javax/swing
--- a/jdk/make/jpda/back/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/jpda/back/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = debugging
 LIBRARY = jdwp
 PRODUCT = jpda
 
--- a/jdk/make/jpda/transport/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/jpda/transport/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = debugging
 PRODUCT = jpda
 include $(BUILDDIR)/common/Defs.gmk
 
--- a/jdk/make/jpda/transport/shmem/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/jpda/transport/shmem/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../../..
+MODULE   = debugging
 LIBRARY  = dt_shmem
 PRODUCT = jbug
 
--- a/jdk/make/jpda/transport/socket/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/jpda/transport/socket/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../../..
+MODULE  = debugging
 LIBRARY = dt_socket
 PRODUCT = jbug
 
--- a/jdk/make/jpda/tty/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/jpda/tty/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = jdb
 PACKAGE = com.sun.tools.example.debug.tty
 PRODUCT = jpda
 PROGRAM = jdb
--- a/jdk/make/launchers/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/launchers/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,33 +28,23 @@
 #
 
 BUILDDIR = ..
+MODULE  = tools
 PACKAGE = launchers
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
 
-# Run MAKE $@ for a launcher: 
+# Run MAKE $@ for a launcher for the corba module:
 #   $(call make-launcher, name, mainclass, java-args, main-args)
-define make-launcher
+define make-corba-launcher
+$(CD) $(BUILDDIR)/launchers && \
 $(MAKE) -f Makefile.launcher \
-	PROGRAM=$(strip $1) \
-	MAIN_CLASS=$(strip $2) \
-	MAIN_JAVA_ARGS="$(strip $3)" \
-	MAIN_ARGS="$(strip $4)" $@
+        MODULE=corba \
+        PROGRAM=$(strip $1) \
+        MAIN_CLASS=$(strip $2) \
+        MAIN_JAVA_ARGS="$(strip $3)" \
+        MAIN_ARGS="$(strip $4)"
 endef
 
-# Run MAKE $@ for all launchers
-ifeq ($(PLATFORM),windows)
-# Run MAKE $@ for all platform specific launchers
-define make-platform-specific-launchers
-$(call make-launcher, kinit, sun.security.krb5.internal.tools.Kinit, , )
-$(call make-launcher, klist, sun.security.krb5.internal.tools.Klist, , )
-$(call make-launcher, ktab, sun.security.krb5.internal.tools.Ktab, , )
-endef
-else
-# Run MAKE $@ for all platform specific launchers
-define make-platform-specific-launchers
-endef
-endif
 # Run MAKE $@ for all generic launchers
 define make-all-launchers
 $(call make-launcher, appletviewer, sun.applet.Main, , )
@@ -85,36 +75,29 @@
   -J-Dsun.jvm.hotspot.debugger.useWindbgDebugger, )
 $(call make-launcher, jstat, sun.tools.jstat.Jstat, , )
 $(call make-launcher, jstatd, sun.tools.jstatd.Jstatd, , )
-$(call make-launcher, keytool, sun.security.tools.KeyTool, , )
 $(call make-launcher, native2ascii, sun.tools.native2ascii.Main, , )
-$(call make-launcher, orbd, com.sun.corba.se.impl.activation.ORBD, \
+$(call make-launcher, rmic, sun.rmi.rmic.Main, , )
+$(call make-launcher, schemagen, com.sun.tools.internal.jxc.SchemaGenerator, , )
+$(call make-launcher, serialver, sun.tools.serialver.SerialVer, , )
+$(call make-launcher, xjc, com.sun.tools.internal.xjc.Driver, , )
+$(call make-launcher, wsgen, com.sun.tools.internal.ws.WsGen, , )
+$(call make-launcher, wsimport, com.sun.tools.internal.ws.WsImport, , )
+$(call make-corba-launcher, orbd, com.sun.corba.se.impl.activation.ORBD, \
   -J-Dcom.sun.CORBA.activation.DbDir=./orb.db \
   -J-Dcom.sun.CORBA.activation.Port=1049 \
   -J-Dcom.sun.CORBA.POA.ORBServerId=1, )
-$(call make-launcher, pack200, com.sun.java.util.jar.pack.Driver, , --pack)
-$(call make-launcher, policytool, sun.security.tools.PolicyTool, , )
-$(call make-launcher, rmic, sun.rmi.rmic.Main, , )
-$(call make-launcher, rmid, sun.rmi.server.Activation, , )
-$(call make-launcher, rmiregistry, sun.rmi.registry.RegistryImpl, , )
-$(call make-launcher, schemagen, com.sun.tools.internal.jxc.SchemaGenerator, , )
-$(call make-launcher, serialver, sun.tools.serialver.SerialVer, , )
-$(call make-launcher, servertool, com.sun.corba.se.impl.activation.ServerTool, , )
-$(call make-launcher, tnameserv, com.sun.corba.se.impl.naming.cosnaming.TransientNameServer, \
+$(call make-corba-launcher, servertool, com.sun.corba.se.impl.activation.ServerTool, , )
+$(call make-corba-launcher, tnameserv, com.sun.corba.se.impl.naming.cosnaming.TransientNameServer, \
   -J-Dcom.sun.CORBA.activation.DbDir=./orb.db \
   -J-Djava.util.logging.LoggingPermission=contol \
   -J-Dcom.sun.CORBA.POA.ORBServerId=1, )
-$(call make-launcher, wsgen, com.sun.tools.internal.ws.WsGen, , )
-$(call make-launcher, wsimport, com.sun.tools.internal.ws.WsImport, , )
-$(call make-launcher, xjc, com.sun.tools.internal.xjc.Driver, , )
 endef
 
 build:
 	$(make-all-launchers)
-	$(make-platform-specific-launchers)
 
 clean clobber::
 	$(make-all-launchers)
-	$(make-platform-specific-launchers)
 
 include $(BUILDDIR)/common/Rules.gmk
 
--- a/jdk/make/mkdemo/jvmti/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/mkdemo/jvmti/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = demos
 PRODUCT = demos
 include $(BUILDDIR)/common/Defs.gmk
 
--- a/jdk/make/mkdemo/management/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/mkdemo/management/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = demos
 PRODUCT = demos
 include $(BUILDDIR)/common/Defs.gmk
 
--- a/jdk/make/mksample/dtrace/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/mksample/dtrace/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -29,6 +29,7 @@
 
 BUILDDIR = ../..
 
+MODULE  = samples
 PRODUCT = java
 
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/mksample/jmx/jmx-scandir/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/mksample/jmx/jmx-scandir/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -29,6 +29,7 @@
 
 BUILDDIR = ../../..
 
+MODULE  = samples
 PRODUCT = java
 
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/mksample/nbproject/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/mksample/nbproject/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -29,6 +29,7 @@
 
 BUILDDIR = ../..
 
+MODULE  = samples
 PRODUCT = java
 
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/mksample/nio/file/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/mksample/nio/file/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -29,6 +29,7 @@
 
 BUILDDIR = ../../..
 
+MODULE  = samples
 PRODUCT = java
 
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/mksample/nio/multicast/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/mksample/nio/multicast/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -29,6 +29,7 @@
 
 BUILDDIR = ../../..
 
+MODULE  = samples
 PRODUCT = java
 
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/mksample/nio/server/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/mksample/nio/server/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -29,6 +29,7 @@
 
 BUILDDIR = ../../..
 
+MODULE  = samples
 PRODUCT = java
 
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/mksample/scripting/scriptpad/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/mksample/scripting/scriptpad/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -29,6 +29,7 @@
 
 BUILDDIR = ../../..
 
+MODULE  = samples
 PRODUCT = java
 
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/mksample/webservices/EbayClient/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/mksample/webservices/EbayClient/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -29,6 +29,7 @@
 
 BUILDDIR = ../../..
 
+MODULE  = samples
 PRODUCT = java
 
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/mksample/webservices/EbayServer/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/mksample/webservices/EbayServer/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -29,6 +29,7 @@
 
 BUILDDIR = ../../..
 
+MODULE  = samples
 PRODUCT = java
 
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/modules/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/modules/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -23,115 +23,106 @@
 # have any questions.
 #
 
-#
-# Modularizing the JDK
-#
-
 BUILDDIR = ..
 include $(BUILDDIR)/common/Defs.gmk
 
-CLASSANALYZER_JAR=$(BUILDTOOLJARDIR)/classanalyzer.jar
-JAVA_FLAGS=$(JAVA_TOOLS_FLAGS) -Xbootclasspath:$(CLASSBINDIR)
+#
+# Modularizing the JDK
+# - Post jdk build process until the source tree is restructured
+#   for modules build
+# - <outputdir>/modules/<module> will be created for each module.
+#
+# Steps:
+# 0. During jdk build before this makefile is invoked, classes, 
+#    resource files, and other non-class files such as native libraries,
+#    properties file, images, etc are created.
+#
+#    Non-class files are copied to <outputdir>/tmp/modules/<MODULE>
+#    directory in this step to prepare for the post-build modularization. 
+#
+#    The MODULE variable defined in other makefiles specifies 
+#    the lowest-level module that the non-class files belong to.
+#    The name might or might not be the same as the name of the modules 
+#    in the resulting <outputdir>/modules directory.
+#    
+# 1. Unpack all jars in the <builddir>/lib directory to a temporary 
+#    location (<outputdir>/tmp/modules/classes) to prepare for modules
+#    creation.
+#
+# 2. Run ClassAnalyzer tool to analyze all jdk classes and generate
+#    class list for all modules and also perform dependency analysis. 
+#
+#    Input configuration files :-
+#
+#    modules.config : defines the low-level modules and specifies 
+#       what classes and resource files each module includes.
+#    modules.group  : defines the module groups and its members.
+#    jdk7.depconfig : lists the dynamic dependencies including
+#       use of reflection Class.forName and JNI FindClass and
+#       service provider.
+#    optional.depconfig : lists the optional dependencies
+#
+# 3. Create one directory for each module (<outputdir>/modules/<module>)
+#    based on the output files from (2).
+#       
+#    modules.list lists the modules to be created for the modules
+#    build and its members. For each module (m) in modules.list,
+#    a. create $m/lib/$m.jar with all classes and resource files
+#       listed in $m.classlist and $m.resources respectively.
+#    b. copy all non-class files from its members to 
+#       <outputdir>/modules/$m.
 
-MODULE_LIB = $(ABS_OUTPUTDIR)/modules
+
 MAINMANIFEST=$(JDK_TOPDIR)/make/tools/manifest.mf
 MODULE_JAR_MANIFEST_FILE=$(ABS_TEMPDIR)/manifest.tmp
 
-TMP=$(ABS_TEMPDIR)/modules
-MODULE_CLASSLIST = $(TMP)/classlist
-MODULE_CLASSES = $(TMP)/classes
-MODULE_LIST = $(MODULE_CLASSLIST)/modules.list
-
-# Modules in the modules/ext directory
-EXT_MODULES = localedata security-sunec security-sunjce
-
-# Build PKCS#11 on all platforms except 64-bit Windows.
-# We exclude windows-amd64 because we don't have any
-# 64-bit PKCS#11 implementations to test with on that platform.
-PKCS11 = security-sunpkcs11
-ifeq ($(ARCH_DATA_MODEL), 64)
-  ifeq ($(PLATFORM), windows)
-    PKCS11 =
-  endif
-endif
-
-EXT_MODULES += $(PKCS11)
-
-# Build Microsoft CryptoAPI provider only on (non-64-bit) Windows platform.
-ifeq ($(PLATFORM), windows)
-  ifneq ($(ARCH_DATA_MODEL), 64)
-    EXT_MODULES += security-sunmscapi
-  endif
-endif
-
-
-JDK_MODULES = tools
-
-SUBDIRS = tools
-all build clean clobber::
-	$(SUBDIRS-loop)
+TMP = $(ABS_MODULES_TEMPDIR)
+MODULE_CLASSLIST = $(ABS_MODULES_TEMPDIR)/classlist
+MODULE_CLASSES = $(ABS_MODULES_TEMPDIR)/classes
+MODULES_LIST = $(MODULE_CLASSLIST)/modules.list
 
 all:: unpack-jars gen-classlist modularize
 
-$(CLASSANALYZER_JAR):
-	$(CD) tools && $(MAKE) all
-
-JAR_LIST := $(shell $(FIND) $(ABS_OUTPUTDIR)/lib -name \*.jar -depth) 
+JAR_LIST := $(shell $(FIND) $(ABS_OUTPUTDIR)/lib -name \*.jar -print) 
 unpack-jars:
+	@$(ECHO) ">>>Making "$@" @ `$(DATE)` ..."
 	$(RM) -rf $(MODULE_CLASSES)
 	$(MKDIR) -p $(MODULE_CLASSES)
 	$(CP) -rf $(CLASSBINDIR)/* $(MODULE_CLASSES)
-	for jf in  $(JAR_LIST) ; do \
+	@for jf in  $(JAR_LIST) ; do \
 	   $(CD) $(MODULE_CLASSES) && $(BOOT_JAR_CMD) xf $$jf $(BOOT_JAR_JFLAGS);\
 	done
+	@$(ECHO) ">>>Finished making "$@" @ `$(DATE)` ..."
 
-gen-classlist: $(CLASSANALYZER_JAR)
-	@$(ECHO) ">>>Making "$@" @ `$(DATE)` ..."
-	@$(RM) -rf $(MODULE_CLASSLIST)
-	@$(MKDIR) -p $(MODULE_CLASSLIST)
-
-	@# Use java in the default tool directory.
-	@# OUTPUTDIR for solaris 64-bit doesn't have the tools.
-	$(JAVA_TOOLS_DIR)/java $(JAVA_FLAGS) \
-		-Dclassanalyzer.debug \
-		-jar $(CLASSANALYZER_JAR) \
-		-jdkhome $(OUTPUTDIR) \
-	        -config modules.config \
-	        -config modules.group \
-		-depconfig jdk7.depconfig \
-		-depconfig optional.depconfig \
-		-showdynamic \
-		-output $(MODULE_CLASSLIST)
-	@$(ECHO) ">>>Finished making "$@" @ `$(DATE)` ..."
+gen-classlist:
+	$(CD) tools && $(MAKE) all
 
 modularize: $(MODULE_JAR_MANIFEST_FILE)
 	@$(ECHO) ">>>Making "$@" @ `$(DATE)` ..."
-	@$(RM) -rf $(MODULE_LIB)
-	@$(MKDIR) -p $(MODULE_LIB)/lib
-	@$(MKDIR) -p $(MODULE_LIB)/jre/lib/ext
+	@$(RM) -rf $(MODULES_DIR)
 
-	@# create modules
-	for m in `$(NAWK) '{print $$1}' $(MODULE_LIST)` ; do \
+	@# create jar file for modules and
+	@# copy other files from all members of this module 
+	for m in `$(NAWK) '{print $$1}' $(MODULES_LIST)` ; do \
    	   $(ECHO) "Creating module $$m" ; \
    	   $(SED) -e 's%\\%\/%g' < $(MODULE_CLASSLIST)/$$m.classlist > $(TMP)/tmp.cf ; \
 	   if [ -f $(MODULE_CLASSLIST)/$$m.resources ] ; then \
    	       $(SED) -e 's%\\%\/%g' < $(MODULE_CLASSLIST)/$$m.resources >> $(TMP)/tmp.cf ; \
            fi ; \
+           $(MKDIR) -p $(ABS_MODULES_DIR)/$$m/lib; \
 	   $(CD) $(MODULE_CLASSES) && \
                $(BOOT_JAR_CMD) c0mf $(MODULE_JAR_MANIFEST_FILE) \
-		   $(MODULE_LIB)/$$m.jar \
-		   @$(TMP)/tmp.cf \
-                   $(BOOT_JAR_JFLAGS) ; \
-	done
+		   $(ABS_MODULES_DIR)/$$m/lib/$$m.jar \
+	           @$(TMP)/tmp.cf \
+                   $(BOOT_JAR_JFLAGS); \
+	   for s in `$(GREP) "^$$m" $(MODULES_LIST)` ; do \
+               if [ -d $(TMP)/$$s ] ; then \
+               	   $(CP) -rf $(TMP)/$$s/*  $(ABS_MODULES_DIR)/$$m; \
+		   $(RM) -rf $(ABS_MODULES_DIR)/$$m/classes; \
+	       fi \
+	   done \
+        done
 	@$(CD) $(MODULE_CLASSES) && $(java-vm-cleanup)
-	@# move modules to lib, jre/lib, or jre/lib/ext
-	for m in $(EXT_MODULES) ; do \
-	   $(MV) $(MODULE_LIB)/$$m.jar $(MODULE_LIB)/jre/lib/ext ; \
-	done
-	for m in $(JDK_MODULES) ; do \
-	   $(MV) $(MODULE_LIB)/$$m.jar $(MODULE_LIB)/lib ; \
-	done
-	$(MV) $(MODULE_LIB)/*.jar $(MODULE_LIB)/jre/lib
 	@$(ECHO) ">>>Finished making "$@" @ `$(DATE)` ..."
 
 $(MODULE_JAR_MANIFEST_FILE):
@@ -139,7 +130,5 @@
 
 clean clobber::
 	$(RM) -rf $(MODULE_CLASSLIST)
-	$(RM) -rf $(MODULE_LIB)
-	$(RM) -f $(MODULE_JAR_MANIFEST_FILE)
-	$(RM) -f $(CLASSANALYZER_JAR)
-
+	$(RM) -rf $(MODULES_DIR)
+	$(RM) $(MODULE_JAR_MANIFEST_FILE)
--- a/jdk/make/modules/modules.config	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/modules/modules.config	Wed Jul 05 17:06:00 2017 +0200
@@ -372,15 +372,19 @@
 
 /**************************************************************************/
 
+module tracing {
+    // tracing
+    include com.sun.tracing.**, sun.tracing.**;
+}
+
 module instrument {
     // java.lang.instrument
     include java.lang.instrument.*, sun.instrument.*;
 
-    // tracing
-    include com.sun.tracing.**, sun.tracing.**;
-
     // HPROF support
     include com.sun.demo.jvmti.hprof.*;
+
+    include tracing;
 }
 
 /**************************************************************************/
@@ -391,15 +395,17 @@
             sun.rmi.server.InactiveGroupException;
 }
 
+module rmic {
+    // rmic is included in tools
+    include sun.rmi.rmic.**;
+}
+
 module rmi {
     include java.rmi.**, sun.rmi.**, com.sun.rmi.**;
 
     // SSL factories are in rmi
     include javax.rmi.ssl.**;
 
-    // rmic is in tools
-    exclude sun.rmi.rmic.**;
-
     // supporting classes in sun.misc and dependencies
     include sun.misc.GC;
 }
@@ -468,9 +474,14 @@
     include javax.smartcardio.**, sun.security.smartcardio.**;
 }
 
+module security-auth {
+    include com.sun.security.auth.**, sun.security.util.AuthResources_*;
+}
+
 module security-misc {
-    include com.sun.security.auth.**, sun.security.util.AuthResources_*,
-            sun.security.pkcs.*,
+    include security-auth;
+
+    include sun.security.pkcs.*,
             sun.security.pkcs12.*;
 
     // this class is a candidate to be removed.
@@ -500,9 +511,8 @@
 }
 
 module jndi-dns {
+    include net-dns;
     include com.sun.jndi.dns.**, com.sun.jndi.url.dns.**;
-    include sun.net.dns.**;                 // to access DNS config.
-    include sun.net.spi.nameservice.dns.**; // for DNS-only name service.
 }
 
 module jndi-cosnaming {
@@ -677,31 +687,69 @@
 
 /**************************************************************************/
 
+module applet {
+    include java.applet.**,
+            sun.applet.**;
+}
+
+module awt {
+    include java.awt.**,
+            sun.awt.**,
+            com.sun.awt.**;
+}
+
+module font {
+    include sun.font.**;
+}
+
+module imageio {
+    include javax.imageio.**,
+            com.sun.imageio.**;
+}
+
+module java2d {
+    include sun.dc.**,
+            sun.java2d.**,
+            com.sun.image.**;
+}
+
+module media {
+    include com.sun.media.**;
+}
+
+module print {
+    include javax.print.**,
+            sun.print.**;
+}
+
+module sound {
+    include javax.sound.**;
+}
+
+module swing {
+    include javax.swing.**,
+            sun.swing.**,
+            // sajdi also contains classes in subpackages of com.sun.java.swing;
+            // so use '*' instead of '**' 
+            com.sun.java.swing.*,
+            com.sun.java.swing.plaf.**,
+            com.sun.swing.**;
+}
+
 module client {
-    include java.applet.**,
-            java.awt.**,
-            javax.accessibility.*,
-            javax.imageio.**,
-            javax.print.**,
-            javax.sound.**,
-            javax.swing.**,
-            sun.applet.**,
+    include applet,
+            awt,
+            font,
+            imageio,
+            java2d,
+            media,
+            print,
+            sound,
+            swing;
+
+    include javax.accessibility.*,
             sun.audio.**,
-            sun.awt.**,
-            sun.dc.**,
-            sun.font.**,
-            sun.java2d.**,
-            sun.print.**,
-            sun.swing.**,
-            com.sun.accessibility.**,
-            com.sun.awt.**,
-            com.sun.image.**,
-            com.sun.imageio.**,
-            com.sun.java.swing.*,       // sajdi also contains classes in a subpackage;
-                                        // so use '*' instead of '**' 
-            com.sun.java.swing.plaf.**,
-            com.sun.media.**,
-            com.sun.swing.**;
+            com.sun.accessibility.**;
 
     // Bidi class in client module for now
     include java.text.Bidi, sun.text.bidi.*;
@@ -723,7 +771,13 @@
 
 /**************************************************************************/
 
+module jkernel {
+    include sun.jkernel.*;
+}
+
 module deploy {
+    include jkernel;
+
     // For now, all plugin and JNLP
     include com.sun.java.browser.**,
             netscape.**,
@@ -732,8 +786,7 @@
             com.sun.deploy.**,
             com.sun.javaws.**,
             javax.jnlp.*,
-            com.sun.jnlp.*,
-            sun.jkernel.*;
+            com.sun.jnlp.*;
 
     // Hook for http authentication
     include sun.net.www.protocol.http.AuthCacheBridge;
@@ -741,6 +794,11 @@
 
 /**************************************************************************/
 
+module net-dns {
+    include sun.net.dns.**;                 // to access DNS config.
+    include sun.net.spi.nameservice.dns.**; // for DNS-only name service.
+}
+
 module net-compat {
     // NTLM authentication support
     include sun.net.www.protocol.http.ntlm.*;
@@ -824,6 +882,7 @@
             debugging,
             jaxws-tools,
             jdb,
+            rmic,
             sajdi;
 
     // include gui-tools in tools module unless the tool binaries
@@ -834,8 +893,7 @@
             com.sun.jarsigner.**,
             com.sun.javac.**,
             com.sun.javadoc.**, com.sun.source.**,
-            sun.jvmstat.**,
-            sun.rmi.rmic.**;
+            sun.jvmstat.**;
 }
 
 /**************************************************************************/
@@ -853,6 +911,19 @@
 
 /**************************************************************************/
 
+// Workaround for US export and local policy files 
+// They are currently in signed jars under the jre/lib/security directory
+module US_export_policy {
+    include default_US_export.policy;
+}
+
+module local_policy {
+    include default_local.policy,
+            exempt_local.policy;
+}
+
+/**************************************************************************/
+
 module other {
     include **;
 }
--- a/jdk/make/modules/optional.depconfig	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/modules/optional.depconfig	Wed Jul 05 17:06:00 2017 +0200
@@ -1,3 +1,28 @@
+#
+# Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Sun designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+
 # public final java.nio.channels.SocketChannel getChannel()
 @Optional
   sun.security.ssl.BaseSSLSocketImpl -> java.nio.channels.SocketChannel
--- a/jdk/make/modules/tools/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/modules/tools/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,58 +28,128 @@
 #
 
 BUILDDIR = ../..
-PACKAGE = com.sun.classanalyzer
-PRODUCT = tools
-PROGRAM = classanalyzer
 include $(BUILDDIR)/common/Defs.gmk
 
+PKGDIR = com/sun/classanalyzer
 BUILDTOOL_SOURCE_ROOT = src
 BUILDTOOL_MAIN        = $(PKGDIR)/ClassAnalyzer.java
 BUILTTOOL_MAINCLASS   = $(subst /,.,$(BUILDTOOL_MAIN:%.java=%))
 
 BUILDTOOL_MAIN_SOURCE_FILE = $(BUILDTOOL_SOURCE_ROOT)/$(BUILDTOOL_MAIN)
-BUILDTOOL_MANIFEST_FILE    = $(BUILDTOOLCLASSDIR)/$(PROGRAM)_manifest.mf
-BUILDTOOL_JAR_FILE         = $(BUILDTOOLJARDIR)/$(PROGRAM).jar
+BUILDTOOL_MANIFEST_FILE    = $(BUILDTOOLCLASSDIR)/classanalyzer_manifest.mf
 
 FILES_java := $(shell $(CD) $(BUILDTOOL_SOURCE_ROOT) \
-    && $(FIND) $(PKGDIR) $(SCM_DIRS_prune) -o -type f -print)
+    && $(FIND) $(PKGDIR) -type f -print)
+
 FILES_class = $(FILES_java:%.java=$(BUILDTOOLCLASSDIR)/%.class)
 
-all build: $(BUILDTOOL_JAR_FILE) tool_info
+CLASSANALYZER_JAR_FILE     = $(BUILDTOOLJARDIR)/classanalyzer.jar
+
+#
+# ClassAnalyzer depends on the com.sun.tools.classfile API.
+# The tool is compiled with the latest version of the classfile 
+# library in the langtools repo to make sure that synchronized
+# change is made if the classfile API is changed. 
+#
+# If langtools repo exists, build its own copy of the
+# classfile library and use it for compile time and runtime.
+# If not exist (the top level repo is not a forest), use 
+# the built jdk tools that imports tools.jar from the latest
+# promoted build.
+#
+# If the classfile API is changed but not yet in a promoted build,
+# the build might fail and the tool would need the langtools repo
+# to build in that case.
+#
+ifndef LANGTOOLS_TOPDIR
+  LANGTOOLS_TOPDIR=$(JDK_TOPDIR)/../langtools
+endif
+
+LANGTOOLS_TOPDIR_EXISTS := $(shell \
+  if [ -d $(LANGTOOLS_TOPDIR) ] ; then \
+    echo true; \
+  else \
+    echo false; \
+  fi)
+
+CLASSFILE_SRC = $(LANGTOOLS_TOPDIR)/src/share/classes
+CLASSFILE_PKGDIR = com/sun/tools/classfile
+
+ifeq ($(LANGTOOLS_TOPDIR_EXISTS), true)
+  FILES_classfile_java := $(shell \
+       $(CD) $(CLASSFILE_SRC) && \
+           $(FIND) $(CLASSFILE_PKGDIR) -name '*.java' -print)
+  FILES_classfile_class = $(FILES_classfile_java:%.java=$(BUILDTOOLCLASSDIR)/%.class)
+  CLASSFILE_JAR_FILE = $(BUILDTOOLJARDIR)/classfile.jar
+  BUILDTOOL_JAVAC    = $(BOOT_JAVAC_CMD) $(JAVAC_JVM_FLAGS) \
+                          $(BOOT_JAVACFLAGS) -classpath $(CLASSFILE_JAR_FILE)
+  BUILDTOOL_JAVA     = $(BOOT_JAVA_CMD) $(JAVA_TOOLS_FLAGS) \
+                          -Xbootclasspath/p:$(CLASSFILE_JAR_FILE)
+else
+  # if langtools doesn't exist, use tools from the built jdk
+  BUILDTOOL_JAVAC = $(BINDIR)/javac $(JAVAC_JVM_FLAGS) \
+                       $(BOOT_JAVACFLAGS)
+  BUILDTOOL_JAVA  = $(BINDIR)/java $(JAVA_TOOLS_FLAGS)
+endif
+
+# Location of the output modules.list, <module>.classlist
+# and other output files generated by the class analyzer tool.
+#
+MODULE_CLASSLIST = $(MODULES_TEMPDIR)/classlist
+
+all build: classanalyzer gen-classlist
+
+classanalyzer: $(CLASSFILE_JAR_FILE) $(CLASSANALYZER_JAR_FILE) 
+
+gen-classlist:
+	@$(ECHO) ">>>Making "$@" @ `$(DATE)` ..."
+	@$(RM) -rf $(MODULE_CLASSLIST)
+	@$(MKDIR) -p $(MODULE_CLASSLIST)
+	$(BUILDTOOL_JAVA) \
+                -Dclassanalyzer.debug \
+                -jar $(CLASSANALYZER_JAR_FILE) \
+                -jdkhome $(OUTPUTDIR) \
+                -config ../modules.config \
+                -config ../modules.group \
+                -depconfig ../jdk7.depconfig \
+                -depconfig ../optional.depconfig \
+                -showdynamic \
+                -output $(MODULE_CLASSLIST)
+	@$(ECHO) ">>>Finished making "$@" @ `$(DATE)` ..."
 
 $(BUILDTOOL_MANIFEST_FILE): $(BUILDTOOL_MAIN_SOURCE_FILE)
 	@$(prep-target)
 	$(ECHO) "Main-Class: $(BUILTTOOL_MAINCLASS)" > $@
 
+$(BUILDTOOLCLASSDIR)/$(CLASSFILE_PKGDIR)/%.class : $(CLASSFILE_SRC)/$(CLASSFILE_PKGDIR)/%.java
+	@$(prep-target)
+	@$(BUILDTOOL_JAVAC) \
+            -sourcepath $(CLASSFILE_SRC) \
+            -d $(BUILDTOOLCLASSDIR) $<
+
 $(BUILDTOOLCLASSDIR)/%.class : $(BUILDTOOL_SOURCE_ROOT)/%.java
 	@$(prep-target)
-	$(JAVAC_CMD) \
+	$(BUILDTOOL_JAVAC) \
             -sourcepath $(BUILDTOOL_SOURCE_ROOT) \
             -d $(BUILDTOOLCLASSDIR) $<
 
-$(BUILDTOOL_JAR_FILE): $(BUILDTOOL_MANIFEST_FILE) $(FILES_class)
+$(CLASSANALYZER_JAR_FILE): $(BUILDTOOL_MANIFEST_FILE) $(FILES_class)
 	@$(prep-target)
-	$(BOOT_JAR_CMD) cfm $@ $(BUILDTOOL_MANIFEST_FILE) \
-	    -C $(BUILDTOOLCLASSDIR) $(PKGDIR) \
-	    $(BOOT_JAR_JFLAGS) || $(RM) $@
-	$(java-vm-cleanup)
+	$(CD) $(BUILDTOOLCLASSDIR) && \
+	    $(BOOT_JAR_CMD) cfm $@ $(BUILDTOOL_MANIFEST_FILE) \
+	       $(PKGDIR) $(BOOT_JAR_JFLAGS) || $(RM) $@
+	@$(java-vm-cleanup)
 
-# Printing out a build tool information line
-define printBuildToolSetting
-if [ "$2" != "" ] ; then $(PRINTF) "%-25s %s\n" "$1:" "$2"; fi
-endef
-
-# Print out the build tool information
-tool_info:
-	@$(ECHO) "========================================================="
-	@$(call printBuildToolSetting,BUILDTOOL,$(PROGRAM))
-	@$(call printBuildToolSetting,PACKAGE,$(PACKAGE))
-	@$(call printBuildToolSetting,BUILDTOOL_SOURCE_ROOT,$(BUILDTOOL_SOURCE_ROOT))
-	@$(call printBuildToolSetting,BUILTTOOL_MAINCLASS,$(BUILTTOOL_MAINCLASS))
-	@$(call printBuildToolSetting,BUILDTOOL_JAR_FILE,$(BUILDTOOL_JAR_FILE))
-	@$(ECHO) "========================================================="
+$(BUILDTOOLJARDIR)/classfile.jar: $(FILES_classfile_class)
+	@$(prep-target)
+	$(CD) $(BUILDTOOLCLASSDIR) && \
+	    $(BOOT_JAR_CMD) cf $@ \
+	        $(CLASSFILE_PKGDIR) $(BOOT_JAR_JFLAGS) || $(RM) $@
+	@$(java-vm-cleanup)
 
 clean clobber::
 	@$(RM) -rf $(BUILDTOOLCLASSDIR)/$(PKGDIR)
+	@$(RM) -rf $(BUILDTOOLCLASSDIR)/$(CLASSFILE_PKGDIR)
 	@$(RM) $(BUILDTOOL_MANIFEST_FILE)
-	@$(RM) $(BUILDTOOL_JAR_FILE)
+	@$(RM) $(CLASSANALYZER_JAR_FILE)
+	@$(RM) $(CLASSFILE_JAR_FILE)
--- a/jdk/make/modules/tools/build.xml	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/modules/tools/build.xml	Wed Jul 05 17:06:00 2017 +0200
@@ -1,32 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
 <!--
- Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
+  Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
+  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
+  This code is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License version 2 only, as
+  published by the Free Software Foundation.  Sun designates this
+  particular file as subject to the "Classpath" exception as provided
+  by Sun in the LICENSE file that accompanied this code.
 
-   - Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
+  This code is distributed in the hope that it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+  version 2 for more details (a copy is included in the LICENSE file that
+  accompanied this code).
 
-   - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in the
-     documentation and/or other materials provided with the distribution.
+  You should have received a copy of the GNU General Public License version
+  2 along with this work; if not, write to the Free Software Foundation,
+  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 
-   - Neither the name of Sun Microsystems nor the names of its
-     contributors may be used to endorse or promote products derived
-     from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+  Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+  CA 95054 USA or visit www.sun.com if you need additional information or
+  have any questions.
 -->
 
 <project name="classanalyzer" default="build" basedir=".">
--- a/jdk/make/modules/tools/nbproject/project.properties	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/modules/tools/nbproject/project.properties	Wed Jul 05 17:06:00 2017 +0200
@@ -1,32 +1,26 @@
 #
 # Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Sun designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Sun in the LICENSE file that accompanied this code.
 #
-#   - Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
 #
-#   - Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-#   - Neither the name of Sun Microsystems nor the names of its
-#     contributors may be used to endorse or promote products derived
-#     from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
 #
 
 application.title=classanalyzer
--- a/jdk/make/modules/tools/nbproject/project.xml	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/modules/tools/nbproject/project.xml	Wed Jul 05 17:06:00 2017 +0200
@@ -1,35 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
 <!--
- Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
-   - Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-
-   - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in the
-     documentation and/or other materials provided with the distribution.
-
-   - Neither the name of Sun Microsystems nor the names of its
-     contributors may be used to endorse or promote products derived
-     from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+  Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
+  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ 
+  This code is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License version 2 only, as
+  published by the Free Software Foundation.  Sun designates this
+  particular file as subject to the "Classpath" exception as provided
+  by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+  CA 95054 USA or visit www.sun.com if you need additional information or
+  have any questions.
 -->
 
-<?xml version="1.0" encoding="UTF-8"?>
 <project xmlns="http://www.netbeans.org/ns/project/1">
     <type>org.netbeans.modules.java.j2seproject</type>
     <configuration>
--- a/jdk/make/modules/tools/src/com/sun/classanalyzer/Module.java	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/modules/tools/src/com/sun/classanalyzer/Module.java	Wed Jul 05 17:06:00 2017 +0200
@@ -444,8 +444,8 @@
     }
 
     void printClassListTo(String output) throws IOException {
-        // no file created if the module doesn't have any class
-        if (classes.isEmpty()) {
+        // no file created if the module doesn't have any class nor resource
+        if (isEmpty()) {
             return;
         }
 
@@ -482,7 +482,7 @@
 
     void printDependenciesTo(String output, boolean showDynamic) throws IOException {
         // no file created if the module doesn't have any class
-        if (classes.isEmpty()) {
+        if (isEmpty()) {
             return;
         }
 
--- a/jdk/make/sun/applet/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/applet/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = applet
 PACKAGE = sun.applet
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/sun/awt/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/awt/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = awt
 PACKAGE = sun.awt
 LIBRARY = awt
 PRODUCT = sun
@@ -312,15 +313,15 @@
 
 $(LIBDIR)/$(LIBARCH)/libxinerama.so: $(CLOSED_SRC)/solaris/lib/$(ARCH)/libxinerama.so
 	$(install-file)
-	$(CHMOD) a+x $@
+	$(call chmod-file, a+x)
 
 $(LIBDIR)/$(LIBARCH)/libjdgaSUNW%.so: $(CLOSED_SRC)/solaris/lib/$(ARCH)/libjdgaSUNW%.so
 	$(install-file)
-	$(CHMOD) a+x $@
+	$(call chmod-file, a+x)
 
 $(LIBDIR)/$(LIBARCH)/libjdgaSUNWafb.so: $(LIBDIR)/$(LIBARCH)/libjdgaSUNWffb.so
 	$(prep-target)
-	$(LN) -s libjdgaSUNWffb.so $(LIBDIR)/$(LIBARCH)/libjdgaSUNWafb.so
+	$(call install-sym-link, libjdgaSUNWffb.so)
 
 clean:: dgalib.clean
 
@@ -404,7 +405,8 @@
     $(COMPILEFONTCONFIG_JARFILE)
 	$(prep-target)
 	$(BOOT_JAVA_CMD) -jar $(COMPILEFONTCONFIG_JARFILE) $< $@
-	$(CHMOD) 444 $(@)
+	$(install-module-file)
+	$(call chmod-file, 444)
 	@$(java-vm-cleanup)
 
 fontconfigs.clean :
--- a/jdk/make/sun/cmm/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/cmm/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,7 @@
 #
 
 BUILDDIR = ../..
+MODULE   = java2d
 PRODUCT  = sun
 include $(BUILDDIR)/common/Defs.gmk
 
@@ -45,34 +46,24 @@
 	     $(ICCPROFILE_DEST_DIR)/LINEAR_RGB.pf
 
 $(ICCPROFILE_DEST_DIR)/sRGB.pf: $(ICCPROFILE_SRC_DIR)/sRGB.pf
-	$(RM) $(ICCPROFILE_DEST_DIR)/sRGB.pf
-	-$(MKDIR) -p $(ICCPROFILE_DEST_DIR)
-	$(CP) $(ICCPROFILE_SRC_DIR)/sRGB.pf $(ICCPROFILE_DEST_DIR)
-	$(CHMOD) 444 $(ICCPROFILE_DEST_DIR)/sRGB.pf
+	$(install-file)
+	$(call chmod-file, 444)
 
 $(ICCPROFILE_DEST_DIR)/GRAY.pf: $(ICCPROFILE_SRC_DIR)/GRAY.pf
-	$(RM) $(ICCPROFILE_DEST_DIR)/GRAY.pf
-	-$(MKDIR) -p $(ICCPROFILE_DEST_DIR)
-	$(CP) $(ICCPROFILE_SRC_DIR)/GRAY.pf $(ICCPROFILE_DEST_DIR)
-	$(CHMOD) 444 $(ICCPROFILE_DEST_DIR)/GRAY.pf
+	$(install-file)
+	$(call chmod-file, 444)
 
 $(ICCPROFILE_DEST_DIR)/CIEXYZ.pf: $(ICCPROFILE_SRC_DIR)/CIEXYZ.pf
-	$(RM) $(ICCPROFILE_DEST_DIR)/CIEXYZ.pf
-	-$(MKDIR) -p $(ICCPROFILE_DEST_DIR)
-	$(CP) $(ICCPROFILE_SRC_DIR)/CIEXYZ.pf $(ICCPROFILE_DEST_DIR)
-	$(CHMOD) 444 $(ICCPROFILE_DEST_DIR)/CIEXYZ.pf
+	$(install-file)
+	$(call chmod-file, 444)
 
 $(ICCPROFILE_DEST_DIR)/PYCC.pf: $(ICCPROFILE_SRC_DIR)/PYCC.pf
-	$(RM) $(ICCPROFILE_DEST_DIR)/PYCC.pf
-	-$(MKDIR) -p $(ICCPROFILE_DEST_DIR)
-	$(CP) $(ICCPROFILE_SRC_DIR)/PYCC.pf $(ICCPROFILE_DEST_DIR)
-	$(CHMOD) 444 $(ICCPROFILE_DEST_DIR)/PYCC.pf
+	$(install-file)
+	$(call chmod-file, 444)
 
 $(ICCPROFILE_DEST_DIR)/LINEAR_RGB.pf: $(ICCPROFILE_SRC_DIR)/LINEAR_RGB.pf
-	$(RM) $(ICCPROFILE_DEST_DIR)/LINEAR_RGB.pf
-	-$(MKDIR) -p $(ICCPROFILE_DEST_DIR)
-	$(CP) $(ICCPROFILE_SRC_DIR)/LINEAR_RGB.pf $(ICCPROFILE_DEST_DIR)
-	$(CHMOD) 444 $(ICCPROFILE_DEST_DIR)/LINEAR_RGB.pf
+	$(install-file)
+	$(call chmod-file, 444)
 
 iccprofiles.clean:
 	$(RM) -r $(ICCPROFILE_DEST_DIR)
--- a/jdk/make/sun/cmm/kcms/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/cmm/kcms/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,7 @@
 #
 
 BUILDDIR = ../../..
+MODULE  = java2d
 PACKAGE = sun.java2d.cmm.kcms
 LIBRARY = kcms
 PRODUCT = sun
--- a/jdk/make/sun/cmm/lcms/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/cmm/lcms/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,7 @@
 #
 
 BUILDDIR = ../../..
+MODULE  = java2d
 PACKAGE = sun.java2d.cmm.lcms
 LIBRARY = lcms
 PRODUCT = sun
--- a/jdk/make/sun/dcpr/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/dcpr/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -26,6 +26,7 @@
 # WARNING: Make sure the OPENJDK plugs are up-to-date, see make/common/internal/BinaryPlugs.gmk
 
 BUILDDIR = ../..
+MODULE  = java2d
 PACKAGE = sun.dc
 LIBRARY = dcpr
 PRODUCT = sun
--- a/jdk/make/sun/font/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/font/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = font
 PACKAGE = sun.font
 LIBRARY = fontmanager
 PRODUCT = sun
@@ -121,16 +122,21 @@
 #
 #TODO: rework this to avoid hardcoding library name in the makefile
 #
-library:: $(LIB_LOCATION)/$(LIB_PREFIX)freetype.$(LIBRARY_SUFFIX)
-
-$(LIB_LOCATION)/$(LIB_PREFIX)freetype.$(LIBRARY_SUFFIX):
 ifeq ($(PLATFORM), windows)
-	$(CP) $(FREETYPE_LIB_PATH)/$(LIB_PREFIX)freetype.$(LIBRARY_SUFFIX) $@
+    FREETYPE_LIB = $(LIB_LOCATION)/$(LIB_PREFIX)freetype.$(LIBRARY_SUFFIX)
+    OTHER_LDLIBS += $(FREETYPE_LIB_PATH)/freetype.lib
 else 
   ifeq ($(USING_SYSTEM_FT_LIB), false)
-	$(CP) $(FREETYPE_LIB_PATH)/$(LIB_PREFIX)freetype.$(LIBRARY_SUFFIX) $@.6
+    FREETYPE_LIB = $(LIB_LOCATION)/$(LIB_PREFIX)freetype.$(LIBRARY_SUFFIX).6
   endif
+  OTHER_LDLIBS += -L$(FREETYPE_LIB_PATH) -lfreetype
 endif 
+
+library:: $(FREETYPE_LIB)
+
+$(FREETYPE_LIB):
+	$(CP) $(FREETYPE_LIB_PATH)/$(LIB_PREFIX)freetype.$(LIBRARY_SUFFIX) $@
+	$(install-module-file)
 endif
 
 #ifeq ($(PLATFORM), solaris)
@@ -158,7 +164,6 @@
   CPPFLAGS += -I$(CLOSED_SRC)/share/native/$(PKGDIR)/t2k
 else
   CPPFLAGS += -I$(FREETYPE_HEADERS_PATH) -I$(FREETYPE_HEADERS_PATH)/freetype2
-  OTHER_LDLIBS += $(FREETYPE_LIB)
 endif
 
 ifeq ($(PLATFORM), windows)
--- a/jdk/make/sun/font/t2k/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/font/t2k/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -30,6 +30,7 @@
 #
 
 BUILDDIR = ../../..
+MODULE  = font
 PACKAGE = sun.font
 LIBRARY = t2k
 PRODUCT = sun
--- a/jdk/make/sun/headless/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/headless/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -30,6 +30,7 @@
 MOTIF_VERSION_STRING=none
 LIB_LOCATION = $(LIBDIR)/$(LIBARCH)/headless
 
+MODULE  = awt
 PACKAGE = sun.awt
 LIBRARY = mawt
 LIBRARY_OUTPUT = headless
--- a/jdk/make/sun/image/generic/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/image/generic/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../../..
+MODULE  = media
 PACKAGE = sun.awt.medialib
 LIBRARY = mlib_image
 PRODUCT = sun
--- a/jdk/make/sun/image/vis/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/image/vis/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -27,6 +27,7 @@
 # Makefile for building the VIS (solaris-only) version of medialib
 #
 BUILDDIR = ../../..
+MODULE  = media
 PACKAGE = sun.awt.medialib
 LIBRARY = mlib_image_v
 PRODUCT = sun
--- a/jdk/make/sun/jar/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/jar/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = jar-tool
 PACKAGE = sun.tools
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/sun/javazic/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/javazic/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -27,6 +27,7 @@
 
 
 BUILDDIR = ../..
+MODULE  = base
 PACKAGE = sun.javazic
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
@@ -69,6 +70,7 @@
 	$(RM) -r $(@D)
 	$(prep-target)
 	$(CP) -r $(WORKDIR)/* $(@D)
+	$(install-module-dir)
 
 clean clobber::
 	$(RM) -r $(TEMPDIR) $(INSTALLDIR)
--- a/jdk/make/sun/jawt/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/jawt/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = awt
 PACKAGE = sun.awt
 LIBRARY = jawt
 PRODUCT = sun
--- a/jdk/make/sun/jconsole/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/jconsole/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = jconsole
 PACKAGE = sun.tools.jconsole
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
@@ -79,7 +80,7 @@
 	$(install-file)
 
 $(TEMPDIR)/manifest: $(SHARE_SRC)/classes/$(PKGDIR)/manifest
-	$(install-file)
+	$(install-manifest-file)
 
 #
 # Extra rule to build jconsole.jar
--- a/jdk/make/sun/jdbc/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/jdbc/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -33,6 +33,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = jdbc-odbc
 PACKAGE = sun.jdbc.odbc
 LIBRARY = JdbcOdbc
 PRODUCT = sun
--- a/jdk/make/sun/jdga/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/jdga/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -25,6 +25,7 @@
 
 
 BUILDDIR = ../..
+MODULE  = java2d
 PACKAGE = sun.jdga
 LIBRARY = sunwjdga
 PRODUCT = sun
--- a/jdk/make/sun/jkernel/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/jkernel/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = jkernel
 PACKAGE = sun.jkernel
 LIBRARY = jkernel
 PRODUCT = sun
--- a/jdk/make/sun/jpeg/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/jpeg/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = java2d
 PACKAGE = sun.awt
 LIBRARY = jpeg
 PRODUCT = sun
--- a/jdk/make/sun/launcher/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/launcher/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = base
 PACKAGE = sun.launcher
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/sun/management/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/management/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,8 @@
 #
 
 BUILDDIR = ../..
+MODULE   = management
+
 include $(BUILDDIR)/common/Defs.gmk
 
 MGMT_LIBDIR = $(LIBDIR)/management
@@ -56,17 +58,17 @@
 
 $(MGMT_LIBDIR)/management.properties: $(MGMT_LIB_SRC)/management.properties
 	$(install-file)
-	$(CHMOD) 644 $@
+	$(call chmod-file, 644)
 
 $(MGMT_LIBDIR)/snmp.acl.template: $(MGMT_LIB_SRC)/snmp.acl.template
 	$(install-file)
-	$(CHMOD) 444 $@
+	$(call chmod-file, 444)
 
 $(MGMT_LIBDIR)/jmxremote.password.template: $(MGMT_LIB_SRC)/jmxremote.password.template
 	$(install-file)
-	$(CHMOD) 444 $@
+	$(call chmod-file, 444)
 
 $(MGMT_LIBDIR)/jmxremote.access: $(MGMT_LIB_SRC)/jmxremote.access 
 	$(install-file)
-	$(CHMOD) 644 $@
+	$(call chmod-file, 644)
 
--- a/jdk/make/sun/native2ascii/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/native2ascii/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = tools
 PACKAGE = sun.tools.native2ascii
 PRODUCT = sun
 OTHER_JAVACFLAGS += -Xlint:serial -Werror
--- a/jdk/make/sun/net/others/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/net/others/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,7 @@
 #
 
 BUILDDIR = ../../..
+MODULE  = base
 PACKAGE = sun.net
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/sun/net/spi/nameservice/dns/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/net/spi/nameservice/dns/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,9 @@
 #
 
 BUILDDIR = ../../../../..
+
+# dns should probably be its own module
+MODULE  = net-dns
 PACKAGE = sun.net.spi.nameservice.dns
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/sun/nio/FILES_java.gmk	Thu Jan 21 11:12:31 2010 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,400 +0,0 @@
-#
-# Copyright 2005-2006 Sun Microsystems, Inc.  All Rights Reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.  Sun designates this
-# particular file as subject to the "Classpath" exception as provided
-# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
-# CA 95054 USA or visit www.sun.com if you need additional information or
-# have any questions.
-#
-
-#
-# Character converters for lib/charsets.jar
-#
-# Core character converters are built from make/java/java.
-#
-
-FILES_src = \
-	sun/io/ByteToCharDoubleByte.java \
-	sun/io/ByteToCharDBCS_ASCII.java \
-	sun/io/ByteToCharDBCS_EBCDIC.java \
-	sun/io/ByteToCharEUC.java \
-	sun/io/CharToByteDoubleByte.java \
-	sun/io/CharToByteDBCS_ASCII.java \
-	sun/io/CharToByteDBCS_EBCDIC.java \
-	sun/io/CharToByteEUC.java \
-	sun/io/ByteToCharBig5.java \
-	sun/io/ByteToCharBig5_Solaris.java \
-	sun/io/ByteToCharBig5_HKSCS.java \
-	sun/io/ByteToCharMS950_HKSCS.java \
-	sun/io/ByteToCharHKSCS.java \
-	sun/io/ByteToCharHKSCS_2001.java \
-	sun/io/ByteToCharGB18030.java \
-	sun/io/ByteToCharGB18030DB.java \
-	sun/io/ByteToCharCp037.java \
-	sun/io/ByteToCharCp1006.java \
-	sun/io/ByteToCharCp1025.java \
-	sun/io/ByteToCharCp1026.java \
-	sun/io/ByteToCharCp1046.java \
-	sun/io/ByteToCharCp1047.java \
-	sun/io/ByteToCharCp1097.java \
-	sun/io/ByteToCharCp1098.java \
-	sun/io/ByteToCharCp1112.java \
-	sun/io/ByteToCharCp1122.java \
-	sun/io/ByteToCharCp1123.java \
-	sun/io/ByteToCharCp1124.java \
-	sun/io/ByteToCharCp1140.java \
-	sun/io/ByteToCharCp1141.java \
-	sun/io/ByteToCharCp1142.java \
-	sun/io/ByteToCharCp1143.java \
-	sun/io/ByteToCharCp1144.java \
-	sun/io/ByteToCharCp1145.java \
-	sun/io/ByteToCharCp1146.java \
-	sun/io/ByteToCharCp1147.java \
-	sun/io/ByteToCharCp1148.java \
-	sun/io/ByteToCharCp1149.java \
-	sun/io/ByteToCharCp1255.java \
-	sun/io/ByteToCharCp1256.java \
-	sun/io/ByteToCharCp1258.java \
-	sun/io/ByteToCharCp1381.java \
-	sun/io/ByteToCharCp1383.java \
-	sun/io/ByteToCharCp273.java \
-	sun/io/ByteToCharCp277.java \
-	sun/io/ByteToCharCp278.java \
-	sun/io/ByteToCharCp280.java \
-	sun/io/ByteToCharCp284.java \
-	sun/io/ByteToCharCp285.java \
-	sun/io/ByteToCharCp297.java \
-	sun/io/ByteToCharCp33722.java \
-	sun/io/ByteToCharCp420.java \
-	sun/io/ByteToCharCp424.java \
-	sun/io/ByteToCharCp437.java \
-	sun/io/ByteToCharCp500.java \
-	sun/io/ByteToCharCp737.java \
-	sun/io/ByteToCharCp775.java \
-	sun/io/ByteToCharCp834.java \
-	sun/io/ByteToCharCp838.java \
-	sun/io/ByteToCharCp850.java \
-	sun/io/ByteToCharCp852.java \
-	sun/io/ByteToCharCp855.java \
-	sun/io/ByteToCharCp856.java \
-	sun/io/ByteToCharCp857.java \
-	sun/io/ByteToCharCp858.java \
-	sun/io/ByteToCharCp860.java \
-	sun/io/ByteToCharCp861.java \
-	sun/io/ByteToCharCp862.java \
-	sun/io/ByteToCharCp863.java \
-	sun/io/ByteToCharCp864.java \
-	sun/io/ByteToCharCp865.java \
-	sun/io/ByteToCharCp866.java \
-	sun/io/ByteToCharCp868.java \
-	sun/io/ByteToCharCp869.java \
-	sun/io/ByteToCharCp870.java \
-	sun/io/ByteToCharCp871.java \
-	sun/io/ByteToCharCp874.java \
-	sun/io/ByteToCharCp875.java \
-	sun/io/ByteToCharCp918.java \
-	sun/io/ByteToCharCp921.java \
-	sun/io/ByteToCharCp922.java \
-	sun/io/ByteToCharCp930.java \
-	sun/io/ByteToCharCp933.java \
-	sun/io/ByteToCharCp935.java \
-	sun/io/ByteToCharCp937.java \
-	sun/io/ByteToCharCp939.java \
-	sun/io/ByteToCharCp942.java \
-	sun/io/ByteToCharCp942C.java \
-	sun/io/ByteToCharCp943.java \
-	sun/io/ByteToCharCp943C.java \
-	sun/io/ByteToCharCp948.java \
-	sun/io/ByteToCharCp949.java \
-	sun/io/ByteToCharCp949C.java \
-	sun/io/ByteToCharCp950.java \
-	sun/io/ByteToCharCp964.java \
-	sun/io/ByteToCharCp970.java \
-	sun/io/ByteToCharJIS0201.java \
-	sun/io/ByteToCharJIS0208.java \
-	sun/io/ByteToCharJIS0208_Solaris.java \
-	sun/io/ByteToCharJIS0212.java \
-	sun/io/ByteToCharJIS0212_Solaris.java \
-	sun/io/ByteToCharEUC_CN.java \
-	sun/io/ByteToCharEUC_JP.java \
-	sun/io/ByteToCharEUC_JP_LINUX.java \
-	sun/io/ByteToCharEUC_JP_Solaris.java \
-	sun/io/ByteToCharEUC_KR.java \
-	sun/io/ByteToCharEUC_TW.java \
-	sun/io/ByteToCharSJIS.java \
-	sun/io/ByteToCharPCK.java \
-	sun/io/ByteToCharGBK.java \
-	sun/io/ByteToCharISCII91.java \
-	sun/io/ByteToCharISO2022.java \
-	sun/io/ByteToCharISO2022CN.java \
-	sun/io/ByteToCharISO2022JP.java \
-	sun/io/ByteToCharISO2022KR.java \
-	sun/io/ByteToCharISO8859_3.java \
-	sun/io/ByteToCharISO8859_6.java \
-	sun/io/ByteToCharISO8859_8.java \
-	sun/io/ByteToCharJISAutoDetect.java \
-	sun/io/ByteToCharJohab.java \
-	sun/io/ByteToCharMS874.java \
-	sun/io/ByteToCharMS932.java \
-	sun/io/ByteToCharMS936.java \
-	sun/io/ByteToCharMS949.java \
-	sun/io/ByteToCharMS950.java \
-	sun/io/ByteToCharMacArabic.java \
-	sun/io/ByteToCharMacCentralEurope.java \
-	sun/io/ByteToCharMacCroatian.java \
-	sun/io/ByteToCharMacCyrillic.java \
-	sun/io/ByteToCharMacDingbat.java \
-	sun/io/ByteToCharMacGreek.java \
-	sun/io/ByteToCharMacHebrew.java \
-	sun/io/ByteToCharMacIceland.java \
-	sun/io/ByteToCharMacRoman.java \
-	sun/io/ByteToCharMacRomania.java \
-	sun/io/ByteToCharMacSymbol.java \
-	sun/io/ByteToCharMacThai.java \
-	sun/io/ByteToCharMacTurkish.java \
-	sun/io/ByteToCharMacUkraine.java \
-	sun/io/ByteToCharTIS620.java \
-	sun/io/CharToByteBig5.java \
-	sun/io/CharToByteBig5_Solaris.java \
-	sun/io/CharToByteBig5_HKSCS.java \
-	sun/io/CharToByteHKSCS.java \
-	sun/io/CharToByteHKSCS_2001.java \
-	sun/io/CharToByteMS950_HKSCS.java \
-	sun/io/CharToByteGB18030.java \
-	sun/io/CharToByteCp037.java \
-	sun/io/CharToByteCp1006.java \
-	sun/io/CharToByteCp1025.java \
-	sun/io/CharToByteCp1026.java \
-	sun/io/CharToByteCp1046.java \
-	sun/io/CharToByteCp1047.java \
-	sun/io/CharToByteCp1097.java \
-	sun/io/CharToByteCp1098.java \
-	sun/io/CharToByteCp1112.java \
-	sun/io/CharToByteCp1122.java \
-	sun/io/CharToByteCp1123.java \
-	sun/io/CharToByteCp1124.java \
-	sun/io/CharToByteCp1140.java \
-	sun/io/CharToByteCp1141.java \
-	sun/io/CharToByteCp1142.java \
-	sun/io/CharToByteCp1143.java \
-	sun/io/CharToByteCp1144.java \
-	sun/io/CharToByteCp1145.java \
-	sun/io/CharToByteCp1146.java \
-	sun/io/CharToByteCp1147.java \
-	sun/io/CharToByteCp1148.java \
-	sun/io/CharToByteCp1149.java \
-	sun/io/CharToByteCp1255.java \
-	sun/io/CharToByteCp1256.java \
-	sun/io/CharToByteCp1258.java \
-	sun/io/CharToByteCp1381.java \
-	sun/io/CharToByteCp1383.java \
-	sun/io/CharToByteCp273.java \
-	sun/io/CharToByteCp277.java \
-	sun/io/CharToByteCp278.java \
-	sun/io/CharToByteCp280.java \
-	sun/io/CharToByteCp284.java \
-	sun/io/CharToByteCp285.java \
-	sun/io/CharToByteCp297.java \
-	sun/io/CharToByteCp33722.java \
-	sun/io/CharToByteCp420.java \
-	sun/io/CharToByteCp424.java \
-	sun/io/CharToByteCp437.java \
-	sun/io/CharToByteCp500.java \
-	sun/io/CharToByteCp737.java \
-	sun/io/CharToByteCp775.java \
-	sun/io/CharToByteCp834.java \
-	sun/io/CharToByteCp838.java \
-	sun/io/CharToByteCp850.java \
-	sun/io/CharToByteCp852.java \
-	sun/io/CharToByteCp855.java \
-	sun/io/CharToByteCp856.java \
-	sun/io/CharToByteCp857.java \
-	sun/io/CharToByteCp858.java \
-	sun/io/CharToByteCp860.java \
-	sun/io/CharToByteCp861.java \
-	sun/io/CharToByteCp862.java \
-	sun/io/CharToByteCp863.java \
-	sun/io/CharToByteCp864.java \
-	sun/io/CharToByteCp865.java \
-	sun/io/CharToByteCp866.java \
-	sun/io/CharToByteCp868.java \
-	sun/io/CharToByteCp869.java \
-	sun/io/CharToByteCp870.java \
-	sun/io/CharToByteCp871.java \
-	sun/io/CharToByteCp874.java \
-	sun/io/CharToByteCp875.java \
-	sun/io/CharToByteCp918.java \
-	sun/io/CharToByteCp921.java \
-	sun/io/CharToByteCp922.java \
-	sun/io/CharToByteCp930.java \
-	sun/io/CharToByteCp933.java \
-	sun/io/CharToByteCp935.java \
-	sun/io/CharToByteCp937.java \
-	sun/io/CharToByteCp939.java \
-	sun/io/CharToByteCp942.java \
-	sun/io/CharToByteCp942C.java \
-	sun/io/CharToByteCp943.java \
-	sun/io/CharToByteCp943C.java \
-	sun/io/CharToByteCp948.java \
-	sun/io/CharToByteCp949.java \
-	sun/io/CharToByteCp949C.java \
-	sun/io/CharToByteCp950.java \
-	sun/io/CharToByteCp964.java \
-	sun/io/CharToByteCp970.java \
-	sun/io/CharToByteJIS0201.java \
-	sun/io/CharToByteJIS0208.java \
-	sun/io/CharToByteJIS0208_Solaris.java \
-	sun/io/CharToByteJIS0212.java \
-	sun/io/CharToByteJIS0212_Solaris.java \
-	sun/io/CharToByteEUC_CN.java \
-	sun/io/CharToByteEUC_JP.java \
-	sun/io/CharToByteEUC_JP_LINUX.java \
-	sun/io/CharToByteEUC_JP_Solaris.java \
-	sun/io/CharToByteEUC_KR.java \
-	sun/io/CharToByteEUC_TW.java \
-	sun/io/CharToByteSJIS.java \
-	sun/io/CharToBytePCK.java \
-	sun/io/CharToByteGBK.java \
-	sun/io/CharToByteISCII91.java \
-	sun/io/CharToByteISO2022.java \
-	sun/io/CharToByteISO2022CN_CNS.java \
-	sun/io/CharToByteISO2022CN_GB.java \
-	sun/io/CharToByteISO2022JP.java \
-	sun/io/CharToByteISO2022KR.java \
-	sun/io/CharToByteISO8859_3.java \
-	sun/io/CharToByteISO8859_6.java \
-	sun/io/CharToByteISO8859_8.java \
-	sun/io/CharToByteJohab.java \
-	sun/io/CharToByteMS874.java \
-	sun/io/CharToByteMS932.java \
-	sun/io/CharToByteMS936.java \
-	sun/io/CharToByteMS949.java \
-	sun/io/CharToByteMS950.java \
-	sun/io/CharToByteMacArabic.java \
-	sun/io/CharToByteMacCentralEurope.java \
-	sun/io/CharToByteMacCroatian.java \
-	sun/io/CharToByteMacCyrillic.java \
-	sun/io/CharToByteMacDingbat.java \
-	sun/io/CharToByteMacGreek.java \
-	sun/io/CharToByteMacHebrew.java \
-	sun/io/CharToByteMacIceland.java \
-	sun/io/CharToByteMacRoman.java \
-	sun/io/CharToByteMacRomania.java \
-	sun/io/CharToByteMacSymbol.java \
-	sun/io/CharToByteMacThai.java \
-	sun/io/CharToByteMacTurkish.java \
-	sun/io/CharToByteMacUkraine.java \
-	sun/io/CharToByteTIS620.java
-
-FILES_gen_extcs = \
-	sun/nio/cs/ext/IBM037.java \
-	sun/nio/cs/ext/IBM1006.java \
-	sun/nio/cs/ext/IBM1025.java \
-	sun/nio/cs/ext/IBM1026.java \
-	sun/nio/cs/ext/IBM1046.java \
-	sun/nio/cs/ext/IBM1047.java \
-	sun/nio/cs/ext/IBM1097.java \
-	sun/nio/cs/ext/IBM1098.java \
-	sun/nio/cs/ext/IBM1112.java \
-	sun/nio/cs/ext/IBM1122.java \
-	sun/nio/cs/ext/IBM1123.java \
-	sun/nio/cs/ext/IBM1124.java \
-	sun/nio/cs/ext/IBM1140.java \
-	sun/nio/cs/ext/IBM1141.java \
-	sun/nio/cs/ext/IBM1142.java \
-	sun/nio/cs/ext/IBM1143.java \
-	sun/nio/cs/ext/IBM1144.java \
-	sun/nio/cs/ext/IBM1145.java \
-	sun/nio/cs/ext/IBM1146.java \
-	sun/nio/cs/ext/IBM1147.java \
-	sun/nio/cs/ext/IBM1148.java \
-	sun/nio/cs/ext/IBM1149.java \
-	sun/nio/cs/ext/IBM273.java \
-	sun/nio/cs/ext/IBM277.java \
-	sun/nio/cs/ext/IBM278.java \
-	sun/nio/cs/ext/IBM280.java \
-	sun/nio/cs/ext/IBM284.java \
-	sun/nio/cs/ext/IBM285.java \
-	sun/nio/cs/ext/IBM297.java \
-	sun/nio/cs/ext/IBM420.java \
-	sun/nio/cs/ext/IBM424.java \
-	sun/nio/cs/ext/IBM500.java \
-	sun/nio/cs/ext/IBM838.java \
-	sun/nio/cs/ext/IBM856.java \
-	sun/nio/cs/ext/IBM860.java \
-	sun/nio/cs/ext/IBM861.java \
-	sun/nio/cs/ext/IBM863.java \
-	sun/nio/cs/ext/IBM864.java \
-	sun/nio/cs/ext/IBM865.java \
-	sun/nio/cs/ext/IBM868.java \
-	sun/nio/cs/ext/IBM869.java \
-	sun/nio/cs/ext/IBM870.java \
-	sun/nio/cs/ext/IBM871.java \
-	sun/nio/cs/ext/IBM875.java \
-	sun/nio/cs/ext/IBM918.java \
-	sun/nio/cs/ext/IBM921.java \
-	sun/nio/cs/ext/IBM922.java \
-	sun/nio/cs/ext/ISO_8859_11.java \
-	sun/nio/cs/ext/ISO_8859_3.java \
-	sun/nio/cs/ext/ISO_8859_6.java \
-	sun/nio/cs/ext/ISO_8859_8.java \
-	sun/nio/cs/ext/MS1255.java \
-	sun/nio/cs/ext/MS1256.java \
-	sun/nio/cs/ext/MS1258.java \
-	sun/nio/cs/ext/MS874.java \
-	sun/nio/cs/ext/MacArabic.java \
-	sun/nio/cs/ext/MacCentralEurope.java \
-	sun/nio/cs/ext/MacCroatian.java \
-	sun/nio/cs/ext/MacCyrillic.java \
-	sun/nio/cs/ext/MacDingbat.java \
-	sun/nio/cs/ext/MacGreek.java \
-	sun/nio/cs/ext/MacHebrew.java \
-	sun/nio/cs/ext/MacIceland.java \
-	sun/nio/cs/ext/MacRoman.java \
-	sun/nio/cs/ext/MacRomania.java \
-	sun/nio/cs/ext/MacSymbol.java \
-	sun/nio/cs/ext/MacThai.java \
-	sun/nio/cs/ext/MacTurkish.java \
-	sun/nio/cs/ext/MacUkraine.java \
-	sun/nio/cs/ext/TIS_620.java \
-        sun/nio/cs/ext/EUC_TWMapping.java \
-	sun/nio/cs/ext/IBM1381.java \
-	sun/nio/cs/ext/IBM1383.java \
-	sun/nio/cs/ext/IBM930.java \
-	sun/nio/cs/ext/IBM933.java \
-	sun/nio/cs/ext/IBM935.java \
-	sun/nio/cs/ext/IBM937.java \
-	sun/nio/cs/ext/IBM939.java \
-	sun/nio/cs/ext/IBM942.java \
-	sun/nio/cs/ext/IBM943.java \
-	sun/nio/cs/ext/IBM948.java \
-	sun/nio/cs/ext/IBM949.java \
-	sun/nio/cs/ext/IBM950.java \
-	sun/nio/cs/ext/IBM970.java \
-	sun/nio/cs/ext/EUC_CN.java \
-	sun/nio/cs/ext/EUC_KR.java \
-	sun/nio/cs/ext/Johab.java \
-	sun/nio/cs/ext/MS932.java \
-	sun/nio/cs/ext/MS936.java \
-	sun/nio/cs/ext/MS949.java \
-	sun/nio/cs/ext/MS950.java \
-	sun/nio/cs/ext/GBK.java
-
-FILES_java = $(FILES_src) $(FILES_gen_extcs)
-
--- a/jdk/make/sun/nio/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/nio/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright 1996-2008 Sun Microsystems, Inc.  All Rights Reserved.
+# Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -23,88 +23,12 @@
 # have any questions.
 #
 
-#
-# Makefile for character converters.
-#
-
 BUILDDIR = ../..
-
 PACKAGE = sun.nio
 PRODUCT = sun
-
-# This re-directs all the class files to a separate location
-CLASSDESTDIR = $(TEMPDIR)/classes
-
-OTHER_JAVACFLAGS += -Xlint:serial -Werror
 include $(BUILDDIR)/common/Defs.gmk
 
-#
-# Files
-#
-include FILES_java.gmk
-AUTO_FILES_JAVA_DIRS = sun/nio/cs/ext
+SUBDIRS = cs
+all build clean clobber::
+	$(SUBDIRS-loop)
 
-# For Cygwin, command line arguments that are paths must be converted to
-# windows style paths. These paths cannot be used as targets, however, because 
-# the ":" in them  will interfere with GNU Make rules, generating "multiple
-# target pattern" errors.
-
-# this define is for the rule:
-CHARSETS_JAR = $(LIBDIR)/charsets.jar
-
-# extcs
-FILES_genout_extcs = $(FILES_gen_extcs:%.java=$(GENSRCDIR)/%.java)
-
-#
-# Rules
-#
-include $(BUILDDIR)/common/Classes.gmk
-
-build: $(FILES_genout_extcs) $(CHARSETS_JAR)
-
-#
-# Extra rules to build character converters.
-
-SERVICE_DESCRIPTION = java.nio.charset.spi.CharsetProvider
-SERVICE_DESCRIPTION_PATH = META-INF/services/$(SERVICE_DESCRIPTION)
-
-GENCSDATASRC = $(BUILDDIR)/tools/CharsetMapping
-GENCSSRCDIR = $(BUILDDIR)/tools/src/build/tools/charsetmapping
-GENCSEXT = $(GENSRCDIR)/sun/nio/cs/ext
-
-FILES_MAP = $(GENCSDATASRC)/sjis0213.map
-FILES_DAT = $(CLASSDESTDIR)/sun/nio/cs/ext/sjis0213.dat
-CHARSETMAPPING_JARFILE = $(BUILDTOOLJARDIR)/charsetmapping.jar
-
-$(FILES_DAT): $(FILES_MAP)
-	@$(prep-target)
-	$(BOOT_JAVA_CMD) -jar $(CHARSETMAPPING_JARFILE) \
-		$(FILES_MAP) $(FILES_DAT) sjis0213
-
-
-$(FILES_genout_extcs): \
-                $(GENCSDATASRC)/SingleByte-X.java.template  \
-		$(GENCSDATASRC)/DoubleByte-X.java.template \
-		$(GENCSDATASRC)/extsbcs $(GENCSDATASRC)/dbcs
-	@$(prep-target)
-	$(RM) -r $(GENCSEXT)
-	$(MKDIR) -p $(GENCSEXT)
-	$(BOOT_JAVA_CMD) -jar $(CHARSETMAPPING_JARFILE)	$(GENCSDATASRC) $(GENCSEXT) extsbcs
-	$(BOOT_JAVA_CMD) -jar $(CHARSETMAPPING_JARFILE) $(GENCSDATASRC) $(GENCSEXT) euctw \
-		$(GENCSSRCDIR)/GenerateEUC_TW.java
-	$(BOOT_JAVA_CMD) -jar $(CHARSETMAPPING_JARFILE) $(GENCSDATASRC) $(GENCSEXT) dbcs
-
-$(CLASSDESTDIR)/$(SERVICE_DESCRIPTION_PATH): \
-  $(SHARE_SRC)/classes/sun/nio/cs/ext/$(SERVICE_DESCRIPTION_PATH)
-	$(install-file)
-
-$(CHARSETS_JAR): $(FILES_class) $(CLASSDESTDIR)/$(SERVICE_DESCRIPTION_PATH) $(FILES_DAT)
-	$(BOOT_JAR_CMD) cf0 $(CHARSETS_JAR) \
-	      -C $(CLASSDESTDIR) sun \
-	      -C $(CLASSDESTDIR) $(SERVICE_DESCRIPTION_PATH)  \
-	      $(BOOT_JAR_JFLAGS)
-	@$(java-vm-cleanup)
-
-clean::
-	$(RM) -r $(CLASSDESTDIR)
-	$(RM) $(CHARSETS_JAR)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/make/sun/nio/cs/FILES_java.gmk	Wed Jul 05 17:06:00 2017 +0200
@@ -0,0 +1,400 @@
+#
+# Copyright 2005-2006 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Sun designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+
+#
+# Character converters for lib/charsets.jar
+#
+# Core character converters are built from make/java/java.
+#
+
+FILES_src = \
+	sun/io/ByteToCharDoubleByte.java \
+	sun/io/ByteToCharDBCS_ASCII.java \
+	sun/io/ByteToCharDBCS_EBCDIC.java \
+	sun/io/ByteToCharEUC.java \
+	sun/io/CharToByteDoubleByte.java \
+	sun/io/CharToByteDBCS_ASCII.java \
+	sun/io/CharToByteDBCS_EBCDIC.java \
+	sun/io/CharToByteEUC.java \
+	sun/io/ByteToCharBig5.java \
+	sun/io/ByteToCharBig5_Solaris.java \
+	sun/io/ByteToCharBig5_HKSCS.java \
+	sun/io/ByteToCharMS950_HKSCS.java \
+	sun/io/ByteToCharHKSCS.java \
+	sun/io/ByteToCharHKSCS_2001.java \
+	sun/io/ByteToCharGB18030.java \
+	sun/io/ByteToCharGB18030DB.java \
+	sun/io/ByteToCharCp037.java \
+	sun/io/ByteToCharCp1006.java \
+	sun/io/ByteToCharCp1025.java \
+	sun/io/ByteToCharCp1026.java \
+	sun/io/ByteToCharCp1046.java \
+	sun/io/ByteToCharCp1047.java \
+	sun/io/ByteToCharCp1097.java \
+	sun/io/ByteToCharCp1098.java \
+	sun/io/ByteToCharCp1112.java \
+	sun/io/ByteToCharCp1122.java \
+	sun/io/ByteToCharCp1123.java \
+	sun/io/ByteToCharCp1124.java \
+	sun/io/ByteToCharCp1140.java \
+	sun/io/ByteToCharCp1141.java \
+	sun/io/ByteToCharCp1142.java \
+	sun/io/ByteToCharCp1143.java \
+	sun/io/ByteToCharCp1144.java \
+	sun/io/ByteToCharCp1145.java \
+	sun/io/ByteToCharCp1146.java \
+	sun/io/ByteToCharCp1147.java \
+	sun/io/ByteToCharCp1148.java \
+	sun/io/ByteToCharCp1149.java \
+	sun/io/ByteToCharCp1255.java \
+	sun/io/ByteToCharCp1256.java \
+	sun/io/ByteToCharCp1258.java \
+	sun/io/ByteToCharCp1381.java \
+	sun/io/ByteToCharCp1383.java \
+	sun/io/ByteToCharCp273.java \
+	sun/io/ByteToCharCp277.java \
+	sun/io/ByteToCharCp278.java \
+	sun/io/ByteToCharCp280.java \
+	sun/io/ByteToCharCp284.java \
+	sun/io/ByteToCharCp285.java \
+	sun/io/ByteToCharCp297.java \
+	sun/io/ByteToCharCp33722.java \
+	sun/io/ByteToCharCp420.java \
+	sun/io/ByteToCharCp424.java \
+	sun/io/ByteToCharCp437.java \
+	sun/io/ByteToCharCp500.java \
+	sun/io/ByteToCharCp737.java \
+	sun/io/ByteToCharCp775.java \
+	sun/io/ByteToCharCp834.java \
+	sun/io/ByteToCharCp838.java \
+	sun/io/ByteToCharCp850.java \
+	sun/io/ByteToCharCp852.java \
+	sun/io/ByteToCharCp855.java \
+	sun/io/ByteToCharCp856.java \
+	sun/io/ByteToCharCp857.java \
+	sun/io/ByteToCharCp858.java \
+	sun/io/ByteToCharCp860.java \
+	sun/io/ByteToCharCp861.java \
+	sun/io/ByteToCharCp862.java \
+	sun/io/ByteToCharCp863.java \
+	sun/io/ByteToCharCp864.java \
+	sun/io/ByteToCharCp865.java \
+	sun/io/ByteToCharCp866.java \
+	sun/io/ByteToCharCp868.java \
+	sun/io/ByteToCharCp869.java \
+	sun/io/ByteToCharCp870.java \
+	sun/io/ByteToCharCp871.java \
+	sun/io/ByteToCharCp874.java \
+	sun/io/ByteToCharCp875.java \
+	sun/io/ByteToCharCp918.java \
+	sun/io/ByteToCharCp921.java \
+	sun/io/ByteToCharCp922.java \
+	sun/io/ByteToCharCp930.java \
+	sun/io/ByteToCharCp933.java \
+	sun/io/ByteToCharCp935.java \
+	sun/io/ByteToCharCp937.java \
+	sun/io/ByteToCharCp939.java \
+	sun/io/ByteToCharCp942.java \
+	sun/io/ByteToCharCp942C.java \
+	sun/io/ByteToCharCp943.java \
+	sun/io/ByteToCharCp943C.java \
+	sun/io/ByteToCharCp948.java \
+	sun/io/ByteToCharCp949.java \
+	sun/io/ByteToCharCp949C.java \
+	sun/io/ByteToCharCp950.java \
+	sun/io/ByteToCharCp964.java \
+	sun/io/ByteToCharCp970.java \
+	sun/io/ByteToCharJIS0201.java \
+	sun/io/ByteToCharJIS0208.java \
+	sun/io/ByteToCharJIS0208_Solaris.java \
+	sun/io/ByteToCharJIS0212.java \
+	sun/io/ByteToCharJIS0212_Solaris.java \
+	sun/io/ByteToCharEUC_CN.java \
+	sun/io/ByteToCharEUC_JP.java \
+	sun/io/ByteToCharEUC_JP_LINUX.java \
+	sun/io/ByteToCharEUC_JP_Solaris.java \
+	sun/io/ByteToCharEUC_KR.java \
+	sun/io/ByteToCharEUC_TW.java \
+	sun/io/ByteToCharSJIS.java \
+	sun/io/ByteToCharPCK.java \
+	sun/io/ByteToCharGBK.java \
+	sun/io/ByteToCharISCII91.java \
+	sun/io/ByteToCharISO2022.java \
+	sun/io/ByteToCharISO2022CN.java \
+	sun/io/ByteToCharISO2022JP.java \
+	sun/io/ByteToCharISO2022KR.java \
+	sun/io/ByteToCharISO8859_3.java \
+	sun/io/ByteToCharISO8859_6.java \
+	sun/io/ByteToCharISO8859_8.java \
+	sun/io/ByteToCharJISAutoDetect.java \
+	sun/io/ByteToCharJohab.java \
+	sun/io/ByteToCharMS874.java \
+	sun/io/ByteToCharMS932.java \
+	sun/io/ByteToCharMS936.java \
+	sun/io/ByteToCharMS949.java \
+	sun/io/ByteToCharMS950.java \
+	sun/io/ByteToCharMacArabic.java \
+	sun/io/ByteToCharMacCentralEurope.java \
+	sun/io/ByteToCharMacCroatian.java \
+	sun/io/ByteToCharMacCyrillic.java \
+	sun/io/ByteToCharMacDingbat.java \
+	sun/io/ByteToCharMacGreek.java \
+	sun/io/ByteToCharMacHebrew.java \
+	sun/io/ByteToCharMacIceland.java \
+	sun/io/ByteToCharMacRoman.java \
+	sun/io/ByteToCharMacRomania.java \
+	sun/io/ByteToCharMacSymbol.java \
+	sun/io/ByteToCharMacThai.java \
+	sun/io/ByteToCharMacTurkish.java \
+	sun/io/ByteToCharMacUkraine.java \
+	sun/io/ByteToCharTIS620.java \
+	sun/io/CharToByteBig5.java \
+	sun/io/CharToByteBig5_Solaris.java \
+	sun/io/CharToByteBig5_HKSCS.java \
+	sun/io/CharToByteHKSCS.java \
+	sun/io/CharToByteHKSCS_2001.java \
+	sun/io/CharToByteMS950_HKSCS.java \
+	sun/io/CharToByteGB18030.java \
+	sun/io/CharToByteCp037.java \
+	sun/io/CharToByteCp1006.java \
+	sun/io/CharToByteCp1025.java \
+	sun/io/CharToByteCp1026.java \
+	sun/io/CharToByteCp1046.java \
+	sun/io/CharToByteCp1047.java \
+	sun/io/CharToByteCp1097.java \
+	sun/io/CharToByteCp1098.java \
+	sun/io/CharToByteCp1112.java \
+	sun/io/CharToByteCp1122.java \
+	sun/io/CharToByteCp1123.java \
+	sun/io/CharToByteCp1124.java \
+	sun/io/CharToByteCp1140.java \
+	sun/io/CharToByteCp1141.java \
+	sun/io/CharToByteCp1142.java \
+	sun/io/CharToByteCp1143.java \
+	sun/io/CharToByteCp1144.java \
+	sun/io/CharToByteCp1145.java \
+	sun/io/CharToByteCp1146.java \
+	sun/io/CharToByteCp1147.java \
+	sun/io/CharToByteCp1148.java \
+	sun/io/CharToByteCp1149.java \
+	sun/io/CharToByteCp1255.java \
+	sun/io/CharToByteCp1256.java \
+	sun/io/CharToByteCp1258.java \
+	sun/io/CharToByteCp1381.java \
+	sun/io/CharToByteCp1383.java \
+	sun/io/CharToByteCp273.java \
+	sun/io/CharToByteCp277.java \
+	sun/io/CharToByteCp278.java \
+	sun/io/CharToByteCp280.java \
+	sun/io/CharToByteCp284.java \
+	sun/io/CharToByteCp285.java \
+	sun/io/CharToByteCp297.java \
+	sun/io/CharToByteCp33722.java \
+	sun/io/CharToByteCp420.java \
+	sun/io/CharToByteCp424.java \
+	sun/io/CharToByteCp437.java \
+	sun/io/CharToByteCp500.java \
+	sun/io/CharToByteCp737.java \
+	sun/io/CharToByteCp775.java \
+	sun/io/CharToByteCp834.java \
+	sun/io/CharToByteCp838.java \
+	sun/io/CharToByteCp850.java \
+	sun/io/CharToByteCp852.java \
+	sun/io/CharToByteCp855.java \
+	sun/io/CharToByteCp856.java \
+	sun/io/CharToByteCp857.java \
+	sun/io/CharToByteCp858.java \
+	sun/io/CharToByteCp860.java \
+	sun/io/CharToByteCp861.java \
+	sun/io/CharToByteCp862.java \
+	sun/io/CharToByteCp863.java \
+	sun/io/CharToByteCp864.java \
+	sun/io/CharToByteCp865.java \
+	sun/io/CharToByteCp866.java \
+	sun/io/CharToByteCp868.java \
+	sun/io/CharToByteCp869.java \
+	sun/io/CharToByteCp870.java \
+	sun/io/CharToByteCp871.java \
+	sun/io/CharToByteCp874.java \
+	sun/io/CharToByteCp875.java \
+	sun/io/CharToByteCp918.java \
+	sun/io/CharToByteCp921.java \
+	sun/io/CharToByteCp922.java \
+	sun/io/CharToByteCp930.java \
+	sun/io/CharToByteCp933.java \
+	sun/io/CharToByteCp935.java \
+	sun/io/CharToByteCp937.java \
+	sun/io/CharToByteCp939.java \
+	sun/io/CharToByteCp942.java \
+	sun/io/CharToByteCp942C.java \
+	sun/io/CharToByteCp943.java \
+	sun/io/CharToByteCp943C.java \
+	sun/io/CharToByteCp948.java \
+	sun/io/CharToByteCp949.java \
+	sun/io/CharToByteCp949C.java \
+	sun/io/CharToByteCp950.java \
+	sun/io/CharToByteCp964.java \
+	sun/io/CharToByteCp970.java \
+	sun/io/CharToByteJIS0201.java \
+	sun/io/CharToByteJIS0208.java \
+	sun/io/CharToByteJIS0208_Solaris.java \
+	sun/io/CharToByteJIS0212.java \
+	sun/io/CharToByteJIS0212_Solaris.java \
+	sun/io/CharToByteEUC_CN.java \
+	sun/io/CharToByteEUC_JP.java \
+	sun/io/CharToByteEUC_JP_LINUX.java \
+	sun/io/CharToByteEUC_JP_Solaris.java \
+	sun/io/CharToByteEUC_KR.java \
+	sun/io/CharToByteEUC_TW.java \
+	sun/io/CharToByteSJIS.java \
+	sun/io/CharToBytePCK.java \
+	sun/io/CharToByteGBK.java \
+	sun/io/CharToByteISCII91.java \
+	sun/io/CharToByteISO2022.java \
+	sun/io/CharToByteISO2022CN_CNS.java \
+	sun/io/CharToByteISO2022CN_GB.java \
+	sun/io/CharToByteISO2022JP.java \
+	sun/io/CharToByteISO2022KR.java \
+	sun/io/CharToByteISO8859_3.java \
+	sun/io/CharToByteISO8859_6.java \
+	sun/io/CharToByteISO8859_8.java \
+	sun/io/CharToByteJohab.java \
+	sun/io/CharToByteMS874.java \
+	sun/io/CharToByteMS932.java \
+	sun/io/CharToByteMS936.java \
+	sun/io/CharToByteMS949.java \
+	sun/io/CharToByteMS950.java \
+	sun/io/CharToByteMacArabic.java \
+	sun/io/CharToByteMacCentralEurope.java \
+	sun/io/CharToByteMacCroatian.java \
+	sun/io/CharToByteMacCyrillic.java \
+	sun/io/CharToByteMacDingbat.java \
+	sun/io/CharToByteMacGreek.java \
+	sun/io/CharToByteMacHebrew.java \
+	sun/io/CharToByteMacIceland.java \
+	sun/io/CharToByteMacRoman.java \
+	sun/io/CharToByteMacRomania.java \
+	sun/io/CharToByteMacSymbol.java \
+	sun/io/CharToByteMacThai.java \
+	sun/io/CharToByteMacTurkish.java \
+	sun/io/CharToByteMacUkraine.java \
+	sun/io/CharToByteTIS620.java
+
+FILES_gen_extcs = \
+	sun/nio/cs/ext/IBM037.java \
+	sun/nio/cs/ext/IBM1006.java \
+	sun/nio/cs/ext/IBM1025.java \
+	sun/nio/cs/ext/IBM1026.java \
+	sun/nio/cs/ext/IBM1046.java \
+	sun/nio/cs/ext/IBM1047.java \
+	sun/nio/cs/ext/IBM1097.java \
+	sun/nio/cs/ext/IBM1098.java \
+	sun/nio/cs/ext/IBM1112.java \
+	sun/nio/cs/ext/IBM1122.java \
+	sun/nio/cs/ext/IBM1123.java \
+	sun/nio/cs/ext/IBM1124.java \
+	sun/nio/cs/ext/IBM1140.java \
+	sun/nio/cs/ext/IBM1141.java \
+	sun/nio/cs/ext/IBM1142.java \
+	sun/nio/cs/ext/IBM1143.java \
+	sun/nio/cs/ext/IBM1144.java \
+	sun/nio/cs/ext/IBM1145.java \
+	sun/nio/cs/ext/IBM1146.java \
+	sun/nio/cs/ext/IBM1147.java \
+	sun/nio/cs/ext/IBM1148.java \
+	sun/nio/cs/ext/IBM1149.java \
+	sun/nio/cs/ext/IBM273.java \
+	sun/nio/cs/ext/IBM277.java \
+	sun/nio/cs/ext/IBM278.java \
+	sun/nio/cs/ext/IBM280.java \
+	sun/nio/cs/ext/IBM284.java \
+	sun/nio/cs/ext/IBM285.java \
+	sun/nio/cs/ext/IBM297.java \
+	sun/nio/cs/ext/IBM420.java \
+	sun/nio/cs/ext/IBM424.java \
+	sun/nio/cs/ext/IBM500.java \
+	sun/nio/cs/ext/IBM838.java \
+	sun/nio/cs/ext/IBM856.java \
+	sun/nio/cs/ext/IBM860.java \
+	sun/nio/cs/ext/IBM861.java \
+	sun/nio/cs/ext/IBM863.java \
+	sun/nio/cs/ext/IBM864.java \
+	sun/nio/cs/ext/IBM865.java \
+	sun/nio/cs/ext/IBM868.java \
+	sun/nio/cs/ext/IBM869.java \
+	sun/nio/cs/ext/IBM870.java \
+	sun/nio/cs/ext/IBM871.java \
+	sun/nio/cs/ext/IBM875.java \
+	sun/nio/cs/ext/IBM918.java \
+	sun/nio/cs/ext/IBM921.java \
+	sun/nio/cs/ext/IBM922.java \
+	sun/nio/cs/ext/ISO_8859_11.java \
+	sun/nio/cs/ext/ISO_8859_3.java \
+	sun/nio/cs/ext/ISO_8859_6.java \
+	sun/nio/cs/ext/ISO_8859_8.java \
+	sun/nio/cs/ext/MS1255.java \
+	sun/nio/cs/ext/MS1256.java \
+	sun/nio/cs/ext/MS1258.java \
+	sun/nio/cs/ext/MS874.java \
+	sun/nio/cs/ext/MacArabic.java \
+	sun/nio/cs/ext/MacCentralEurope.java \
+	sun/nio/cs/ext/MacCroatian.java \
+	sun/nio/cs/ext/MacCyrillic.java \
+	sun/nio/cs/ext/MacDingbat.java \
+	sun/nio/cs/ext/MacGreek.java \
+	sun/nio/cs/ext/MacHebrew.java \
+	sun/nio/cs/ext/MacIceland.java \
+	sun/nio/cs/ext/MacRoman.java \
+	sun/nio/cs/ext/MacRomania.java \
+	sun/nio/cs/ext/MacSymbol.java \
+	sun/nio/cs/ext/MacThai.java \
+	sun/nio/cs/ext/MacTurkish.java \
+	sun/nio/cs/ext/MacUkraine.java \
+	sun/nio/cs/ext/TIS_620.java \
+        sun/nio/cs/ext/EUC_TWMapping.java \
+	sun/nio/cs/ext/IBM1381.java \
+	sun/nio/cs/ext/IBM1383.java \
+	sun/nio/cs/ext/IBM930.java \
+	sun/nio/cs/ext/IBM933.java \
+	sun/nio/cs/ext/IBM935.java \
+	sun/nio/cs/ext/IBM937.java \
+	sun/nio/cs/ext/IBM939.java \
+	sun/nio/cs/ext/IBM942.java \
+	sun/nio/cs/ext/IBM943.java \
+	sun/nio/cs/ext/IBM948.java \
+	sun/nio/cs/ext/IBM949.java \
+	sun/nio/cs/ext/IBM950.java \
+	sun/nio/cs/ext/IBM970.java \
+	sun/nio/cs/ext/EUC_CN.java \
+	sun/nio/cs/ext/EUC_KR.java \
+	sun/nio/cs/ext/Johab.java \
+	sun/nio/cs/ext/MS932.java \
+	sun/nio/cs/ext/MS936.java \
+	sun/nio/cs/ext/MS949.java \
+	sun/nio/cs/ext/MS950.java \
+	sun/nio/cs/ext/GBK.java
+
+FILES_java = $(FILES_src) $(FILES_gen_extcs)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/make/sun/nio/cs/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -0,0 +1,112 @@
+#
+# Copyright 1996-2008 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Sun designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+
+#
+# Makefile for character converters.
+#
+
+BUILDDIR = ../../..
+
+# charsets should be separated from nio module 
+MODULE  = charsets
+PACKAGE = sun.nio
+PRODUCT = sun
+
+# This re-directs all the class files to a separate location
+CLASSDESTDIR = $(TEMPDIR)/classes
+
+OTHER_JAVACFLAGS += -Xlint:serial -Werror
+include $(BUILDDIR)/common/Defs.gmk
+
+#
+# Files
+#
+include FILES_java.gmk
+AUTO_FILES_JAVA_DIRS = sun/nio/cs/ext
+
+# For Cygwin, command line arguments that are paths must be converted to
+# windows style paths. These paths cannot be used as targets, however, because 
+# the ":" in them  will interfere with GNU Make rules, generating "multiple
+# target pattern" errors.
+
+# this define is for the rule:
+CHARSETS_JAR = $(LIBDIR)/charsets.jar
+
+# extcs
+FILES_genout_extcs = $(FILES_gen_extcs:%.java=$(GENSRCDIR)/%.java)
+
+#
+# Rules
+#
+include $(BUILDDIR)/common/Classes.gmk
+
+build: $(FILES_genout_extcs) $(CHARSETS_JAR)
+
+#
+# Extra rules to build character converters.
+
+SERVICE_DESCRIPTION = java.nio.charset.spi.CharsetProvider
+SERVICE_DESCRIPTION_PATH = META-INF/services/$(SERVICE_DESCRIPTION)
+
+GENCSDATASRC = $(BUILDDIR)/tools/CharsetMapping
+GENCSSRCDIR = $(BUILDDIR)/tools/src/build/tools/charsetmapping
+GENCSEXT = $(GENSRCDIR)/sun/nio/cs/ext
+
+FILES_MAP = $(GENCSDATASRC)/sjis0213.map
+FILES_DAT = $(CLASSDESTDIR)/sun/nio/cs/ext/sjis0213.dat
+CHARSETMAPPING_JARFILE = $(BUILDTOOLJARDIR)/charsetmapping.jar
+
+$(FILES_DAT): $(FILES_MAP)
+	@$(prep-target)
+	$(BOOT_JAVA_CMD) -jar $(CHARSETMAPPING_JARFILE) \
+		$(FILES_MAP) $(FILES_DAT) sjis0213
+
+
+$(FILES_genout_extcs): \
+                $(GENCSDATASRC)/SingleByte-X.java.template  \
+		$(GENCSDATASRC)/DoubleByte-X.java.template \
+		$(GENCSDATASRC)/extsbcs $(GENCSDATASRC)/dbcs
+	@$(prep-target)
+	$(RM) -r $(GENCSEXT)
+	$(MKDIR) -p $(GENCSEXT)
+	$(BOOT_JAVA_CMD) -jar $(CHARSETMAPPING_JARFILE)	$(GENCSDATASRC) $(GENCSEXT) extsbcs
+	$(BOOT_JAVA_CMD) -jar $(CHARSETMAPPING_JARFILE) $(GENCSDATASRC) $(GENCSEXT) euctw \
+		$(GENCSSRCDIR)/GenerateEUC_TW.java
+	$(BOOT_JAVA_CMD) -jar $(CHARSETMAPPING_JARFILE) $(GENCSDATASRC) $(GENCSEXT) dbcs
+
+$(CLASSDESTDIR)/$(SERVICE_DESCRIPTION_PATH): \
+  $(SHARE_SRC)/classes/sun/nio/cs/ext/$(SERVICE_DESCRIPTION_PATH)
+	$(install-file)
+
+$(CHARSETS_JAR): $(FILES_class) $(CLASSDESTDIR)/$(SERVICE_DESCRIPTION_PATH) $(FILES_DAT)
+	$(BOOT_JAR_CMD) cf0 $(CHARSETS_JAR) \
+	      -C $(CLASSDESTDIR) sun \
+	      -C $(CLASSDESTDIR) $(SERVICE_DESCRIPTION_PATH)  \
+	      $(BOOT_JAR_JFLAGS)
+	@$(java-vm-cleanup)
+
+clean::
+	$(RM) -r $(CLASSDESTDIR)
+	$(RM) $(CHARSETS_JAR)
--- a/jdk/make/sun/org/mozilla/javascript/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/org/mozilla/javascript/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../../../..
+MODULE  = scripting-rhino
 PACKAGE = sun.org.mozilla.javascript.internal
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/sun/pisces/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/pisces/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = java2d
 PACKAGE = sun.pisces
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/sun/rmi/cgi/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/rmi/cgi/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,8 @@
 #
 
 BUILDDIR = ../../..
+# java-rmi.cgi is a JDK tool
+MODULE  = tools
 PACKAGE = sun.rmi
 PRODUCT = sun
 PROGRAM = java-rmi
--- a/jdk/make/sun/rmi/oldtools/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/rmi/oldtools/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../../..
+MODULE   = oldjavac
 PRODUCT	 = oldjavac
 
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/sun/rmi/registry/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/rmi/registry/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../../..
+MODULE  = rmi
 PACKAGE = sun.rmi.registry
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
@@ -48,3 +49,7 @@
 #
 include $(BUILDDIR)/common/Classes.gmk
 
+build: rmiregistry
+
+rmiregistry:
+	$(call make-launcher, rmiregistry, sun.rmi.registry.RegistryImpl, , )
--- a/jdk/make/sun/rmi/rmi/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/rmi/rmi/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../../..
+MODULE  = rmi
 PACKAGE = sun.rmi
 PRODUCT = sun
 LIBRARY = rmi
@@ -124,7 +125,7 @@
 
 $(BINDIR)/java-rmi.cgi: $(PLATFORM_SRC)/bin/java-rmi.cgi.sh
 	$(install-file)
-	$(CHMOD) a+x $@
+	$(call chmod-file, a+x)
 
 bin.clean:
 	$(RM) $(BINDIR)/java-rmi.cgi
--- a/jdk/make/sun/rmi/rmic/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/rmi/rmic/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../../..
+MODULE  = rmic
 PACKAGE = sun.rmi.rmic
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/sun/rmi/rmid/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/rmi/rmid/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -29,11 +29,12 @@
 #
 
 BUILDDIR = ../../..
+MODULE  = rmi-activation
 PACKAGE = sun.rmi.activation
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
 
-build: stubs 
+build: stubs rmid
 
 #
 # Resources
@@ -75,4 +76,5 @@
 #
 include $(BUILDDIR)/common/Classes.gmk
 
-
+rmid:
+	$(call make-launcher, rmid, sun.rmi.server.Activation, , )
--- a/jdk/make/sun/security/ec/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/security/ec/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -89,6 +89,7 @@
 #
 
 BUILDDIR = ../../..
+MODULE  = security-sunec
 PACKAGE = sun.security.ec
 PRODUCT = sun
 
@@ -308,7 +309,7 @@
 else
 $(JAR_DESTFILE): $(SIGNED_DIR)/sunec.jar
 endif
-	$(install-file)
+	$(install-non-module-file)
 
 ifndef OPENJDK
 install-prebuilt:
--- a/jdk/make/sun/security/jgss/wrapper/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/security/jgss/wrapper/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,7 @@
 #
 
 BUILDDIR = ../../../..
+MODULE  = security-kerberos
 PACKAGE = sun.security.jgss.wrapper
 PRODUCT = sun
 
--- a/jdk/make/sun/security/krb5/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/security/krb5/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,7 @@
 #
 
 BUILDDIR = ../../..
+MODULE  = security-kerberos
 PACKAGE = sun.security.krb5
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
@@ -77,3 +78,10 @@
 else
   OTHER_LDLIBS = -ldl $(JVMLIB)
 endif
+
+build:
+ifeq ($(PLATFORM),windows)
+	$(call make-launcher, kinit, sun.security.krb5.internal.tools.Kinit, , )
+	$(call make-launcher, klist, sun.security.krb5.internal.tools.Klist, , )
+	$(call make-launcher, ktab, sun.security.krb5.internal.tools.Ktab, , )
+endif
--- a/jdk/make/sun/security/mscapi/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/security/mscapi/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -89,6 +89,7 @@
 #
 
 BUILDDIR = ../../..
+MODULE  = security-sunmscapi
 PACKAGE = sun.security.mscapi
 LIBRARY = sunmscapi
 PRODUCT = sun
@@ -271,7 +272,7 @@
 else
 $(JAR_DESTFILE): $(SIGNED_DIR)/sunmscapi.jar
 endif
-	$(install-file)
+	$(install-non-module-file)
 
 ifndef OPENJDK
 install-prebuilt:
--- a/jdk/make/sun/security/pkcs11/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/security/pkcs11/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -89,6 +89,7 @@
 #
 
 BUILDDIR = ../../..
+MODULE  = security-sunpkcs11
 PACKAGE = sun.security.pkcs11
 LIBRARY = j2pkcs11
 PRODUCT = sun
@@ -161,6 +162,16 @@
   OTHER_LDLIBS = -ldl $(JVMLIB)
 endif
 
+# Other config files
+SUNPKCS11_CFG   =
+
+ifeq ($(PLATFORM), solaris)
+SUNPKCS11_CFG   = sunpkcs11-cfg
+endif # PLATFORM
+
+SUNPKCS11_CFG_SRC   = $(TOPDIR)/src/share/lib/security/sunpkcs11-solaris.cfg
+SUNPKCS11_CFG_BUILD = $(LIBDIR)/security/sunpkcs11-solaris.cfg
+
 #
 # We use a variety of subdirectories in the $(TEMPDIR) depending on what
 # part of the build we're doing.  Both OPENJDK/JDK builds are initially
@@ -174,12 +185,17 @@
 #
 
 ifdef OPENJDK
-all: build-jar install-jar
+all: $(SUNPKCS11_CFG) build-jar install-jar
 else
-all: build-jar install-prebuilt
+all: $(SUNPKCS11_CFG) build-jar install-prebuilt
 	$(build-warning)
 endif
 
+sunpkcs11-cfg: $(SUNPKCS11_CFG_BUILD)
+
+$(SUNPKCS11_CFG_BUILD): $(SUNPKCS11_CFG_SRC)
+	$(install-file)
+
 include $(BUILDDIR)/javax/crypto/Defs-jce.gmk
 
 
@@ -271,7 +287,7 @@
 else
 $(JAR_DESTFILE): $(SIGNED_DIR)/sunpkcs11.jar
 endif
-	$(install-file)
+	$(install-non-module-file)
 
 ifndef OPENJDK
 install-prebuilt:
@@ -287,6 +303,7 @@
 
 clobber clean::
 	$(RM) -r $(JAR_DESTFILE) $(TEMPDIR) $(JCE_BUILD_DIR)
+	$(RM) $(SUNPKCS11_CFG_BUILD) 
 
 .PHONY: build-jar jar install-jar
 ifndef OPENJDK
--- a/jdk/make/sun/security/smartcardio/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/security/smartcardio/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,7 @@
 #
 
 BUILDDIR = ../../..
+MODULE  = security-smartcardio
 PACKAGE = sun.security.smartcardio
 LIBRARY = j2pcsc
 PRODUCT = sun
--- a/jdk/make/sun/security/tools/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/security/tools/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,7 @@
 #
 
 BUILDDIR = ../../..
+MODULE  = security-tools
 PACKAGE = sun.security.tools
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
@@ -44,3 +45,7 @@
 #
 include $(BUILDDIR)/common/Classes.gmk
 
+build:
+	$(call make-launcher, keytool, sun.security.tools.KeyTool, , )
+	$(call make-launcher, policytool, sun.security.tools.PolicyTool, , )
+
--- a/jdk/make/sun/serialver/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/serialver/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = serialver
 PACKAGE = sun.tools.serialver
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/sun/splashscreen/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/splashscreen/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = awt
 PACKAGE = sun.awt
 LIBRARY = splashscreen
 PRODUCT = sun
--- a/jdk/make/sun/text/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/text/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -29,6 +29,7 @@
 
 BUILDDIR = ../..
 
+MODULE  = localedata
 PACKAGE = sun.text
 PRODUCT = sun
 
--- a/jdk/make/sun/tools/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/tools/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -28,6 +28,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = tools
 PACKAGE = sun.tools
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/sun/tracing/dtrace/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/tracing/dtrace/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -27,6 +27,7 @@
 # Makefile for building dtrace extension
 #
 BUILDDIR = ../../..
+MODULE  = tracing
 PACKAGE = sun.tracing.dtrace
 LIBRARY = jsdt
 PRODUCT = sun
--- a/jdk/make/sun/xawt/Makefile	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/make/sun/xawt/Makefile	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,7 @@
 #
 
 BUILDDIR = ../..
+MODULE  = awt
 PACKAGE = sun.awt.X11
 LIBRARY = mawt
 LIBRARY_OUTPUT = xawt
--- a/jdk/src/share/classes/java/lang/Deprecated.java	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/src/share/classes/java/lang/Deprecated.java	Wed Jul 05 17:06:00 2017 +0200
@@ -26,6 +26,7 @@
 package java.lang;
 
 import java.lang.annotation.*;
+import static java.lang.annotation.ElementType.*;
 
 /**
  * A program element annotated &#64;Deprecated is one that programmers
@@ -38,5 +39,6 @@
  */
 @Documented
 @Retention(RetentionPolicy.RUNTIME)
+@Target(value={CONSTRUCTOR, FIELD, LOCAL_VARIABLE, METHOD, PACKAGE, PARAMETER, TYPE})
 public @interface Deprecated {
 }
--- a/jdk/src/share/classes/java/lang/Error.java	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/src/share/classes/java/lang/Error.java	Wed Jul 05 17:06:00 2017 +0200
@@ -26,27 +26,31 @@
 package java.lang;
 
 /**
- * An <code>Error</code> is a subclass of <code>Throwable</code>
+ * An {@code Error} is a subclass of {@code Throwable}
  * that indicates serious problems that a reasonable application
  * should not try to catch. Most such errors are abnormal conditions.
- * The <code>ThreadDeath</code> error, though a "normal" condition,
- * is also a subclass of <code>Error</code> because most applications
+ * The {@code ThreadDeath} error, though a "normal" condition,
+ * is also a subclass of {@code Error} because most applications
  * should not try to catch it.
  * <p>
- * A method is not required to declare in its <code>throws</code>
- * clause any subclasses of <code>Error</code> that might be thrown
+ * A method is not required to declare in its {@code throws}
+ * clause any subclasses of {@code Error} that might be thrown
  * during the execution of the method but not caught, since these
  * errors are abnormal conditions that should never occur.
  *
+ * That is, {@code Error} and its subclasses are regarded as unchecked
+ * exceptions for the purposes of compile-time checking of exceptions.
+ *
  * @author  Frank Yellin
  * @see     java.lang.ThreadDeath
+ * @jls3 11.2 Compile-Time Checking of Exceptions
  * @since   JDK1.0
  */
 public class Error extends Throwable {
     static final long serialVersionUID = 4980196508277280342L;
 
     /**
-     * Constructs a new error with <code>null</code> as its detail message.
+     * Constructs a new error with {@code null} as its detail message.
      * The cause is not initialized, and may subsequently be initialized by a
      * call to {@link #initCause}.
      */
@@ -69,7 +73,7 @@
     /**
      * Constructs a new error with the specified detail message and
      * cause.  <p>Note that the detail message associated with
-     * <code>cause</code> is <i>not</i> automatically incorporated in
+     * {@code cause} is <i>not</i> automatically incorporated in
      * this error's detail message.
      *
      * @param  message the detail message (which is saved for later retrieval
--- a/jdk/src/share/classes/java/lang/Exception.java	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/src/share/classes/java/lang/Exception.java	Wed Jul 05 17:06:00 2017 +0200
@@ -26,19 +26,27 @@
 package java.lang;
 
 /**
- * The class <code>Exception</code> and its subclasses are a form of
- * <code>Throwable</code> that indicates conditions that a reasonable
+ * The class {@code Exception} and its subclasses are a form of
+ * {@code Throwable} that indicates conditions that a reasonable
  * application might want to catch.
  *
+ * <p>The class {@code Exception} and any subclasses that are not also
+ * subclasses of {@link RuntimeException} are <em>checked
+ * exceptions</em>.  Checked exceptions need to be declared in a
+ * method or constructor's {@code throws} clause if they can be thrown
+ * by the execution of the method or constructor and propagate outside
+ * the method or constructor boundary.
+ *
  * @author  Frank Yellin
  * @see     java.lang.Error
+ * @jls3 11.2 Compile-Time Checking of Exceptions
  * @since   JDK1.0
  */
 public class Exception extends Throwable {
     static final long serialVersionUID = -3387516993124229948L;
 
     /**
-     * Constructs a new exception with <code>null</code> as its detail message.
+     * Constructs a new exception with {@code null} as its detail message.
      * The cause is not initialized, and may subsequently be initialized by a
      * call to {@link #initCause}.
      */
@@ -61,7 +69,7 @@
     /**
      * Constructs a new exception with the specified detail message and
      * cause.  <p>Note that the detail message associated with
-     * <code>cause</code> is <i>not</i> automatically incorporated in
+     * {@code cause} is <i>not</i> automatically incorporated in
      * this exception's detail message.
      *
      * @param  message the detail message (which is saved for later retrieval
--- a/jdk/src/share/classes/java/lang/RuntimeException.java	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/src/share/classes/java/lang/RuntimeException.java	Wed Jul 05 17:06:00 2017 +0200
@@ -26,22 +26,24 @@
 package java.lang;
 
 /**
- * <code>RuntimeException</code> is the superclass of those
+ * {@code RuntimeException} is the superclass of those
  * exceptions that can be thrown during the normal operation of the
  * Java Virtual Machine.
- * <p>
- * A method is not required to declare in its <code>throws</code>
- * clause any subclasses of <code>RuntimeException</code> that might
- * be thrown during the execution of the method but not caught.
  *
+ * <p>{@code RuntimeException} and its subclasses are <em>unchecked
+ * exceptions</em>.  Unchecked exceptions do <em>not</em> need to be
+ * declared in a method or constructor's {@code throws} clause if they
+ * can be thrown by the execution of the method or constructor and
+ * propagate outside the method or constructor boundary.
  *
  * @author  Frank Yellin
+ * @jls3 11.2 Compile-Time Checking of Exceptions
  * @since   JDK1.0
  */
 public class RuntimeException extends Exception {
     static final long serialVersionUID = -7034897190745766939L;
 
-    /** Constructs a new runtime exception with <code>null</code> as its
+    /** Constructs a new runtime exception with {@code null} as its
      * detail message.  The cause is not initialized, and may subsequently be
      * initialized by a call to {@link #initCause}.
      */
@@ -63,7 +65,7 @@
     /**
      * Constructs a new runtime exception with the specified detail message and
      * cause.  <p>Note that the detail message associated with
-     * <code>cause</code> is <i>not</i> automatically incorporated in
+     * {@code cause} is <i>not</i> automatically incorporated in
      * this runtime exception's detail message.
      *
      * @param  message the detail message (which is saved for later retrieval
--- a/jdk/src/share/classes/java/lang/SuppressWarnings.java	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/src/share/classes/java/lang/SuppressWarnings.java	Wed Jul 05 17:06:00 2017 +0200
@@ -26,7 +26,6 @@
 package java.lang;
 
 import java.lang.annotation.*;
-import java.lang.annotation.ElementType;
 import static java.lang.annotation.ElementType.*;
 
 /**
@@ -45,7 +44,7 @@
  * @since 1.5
  * @author Josh Bloch
  */
-@Target({TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE})
+@Target({TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE, TYPE_PARAMETER})
 @Retention(RetentionPolicy.SOURCE)
 public @interface SuppressWarnings {
     /**
--- a/jdk/src/share/classes/java/lang/Throwable.java	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/src/share/classes/java/lang/Throwable.java	Wed Jul 05 17:06:00 2017 +0200
@@ -34,6 +34,11 @@
  * this class or one of its subclasses can be the argument type in a
  * <code>catch</code> clause.
  *
+ * For the purposes of compile-time checking of exceptions, {@code
+ * Throwable} and any subclass of {@code Throwable} that is not also a
+ * subclass of either {@link RuntimeException} or {@link Error} are
+ * regarded as checked exceptions.
+ *
  * <p>Instances of two subclasses, {@link java.lang.Error} and
  * {@link java.lang.Exception}, are conventionally used to indicate
  * that exceptional situations have occurred. Typically, these instances
@@ -142,6 +147,7 @@
  * @author  unascribed
  * @author  Josh Bloch (Added exception chaining and programmatic access to
  *          stack trace in 1.4.)
+ * @jls3 11.2 Compile-Time Checking of Exceptions
  * @since JDK1.0
  */
 public class Throwable implements Serializable {
--- a/jdk/src/share/classes/java/util/NavigableMap.java	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/src/share/classes/java/util/NavigableMap.java	Wed Jul 05 17:06:00 2017 +0200
@@ -298,7 +298,7 @@
      * Returns a view of the portion of this map whose keys range from
      * {@code fromKey} to {@code toKey}.  If {@code fromKey} and
      * {@code toKey} are equal, the returned map is empty unless
-     * {@code fromExclusive} and {@code toExclusive} are both true.  The
+     * {@code fromInclusive} and {@code toInclusive} are both true.  The
      * returned map is backed by this map, so changes in the returned map are
      * reflected in this map, and vice-versa.  The returned map supports all
      * optional map operations that this map supports.
--- a/jdk/src/share/classes/java/util/NavigableSet.java	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/src/share/classes/java/util/NavigableSet.java	Wed Jul 05 17:06:00 2017 +0200
@@ -192,7 +192,7 @@
      * Returns a view of the portion of this set whose elements range from
      * {@code fromElement} to {@code toElement}.  If {@code fromElement} and
      * {@code toElement} are equal, the returned set is empty unless {@code
-     * fromExclusive} and {@code toExclusive} are both true.  The returned set
+     * fromInclusive} and {@code toInclusive} are both true.  The returned set
      * is backed by this set, so changes in the returned set are reflected in
      * this set, and vice-versa.  The returned set supports all optional set
      * operations that this set supports.
--- a/jdk/src/share/classes/sun/nio/fs/AbstractPath.java	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/src/share/classes/sun/nio/fs/AbstractPath.java	Wed Jul 05 17:06:00 2017 +0200
@@ -256,8 +256,8 @@
                 }
                 if (option == null)
                     throw new NullPointerException();
-                throw new IllegalArgumentException("'" + option +
-                    "' is not a valid copy option");
+                throw new UnsupportedOperationException("'" + option +
+                    "' is not a recognized copy option");
             }
             return result;
         }
@@ -279,9 +279,21 @@
         if (attrs.isSymbolicLink())
             throw new IOException("Copying of symbolic links not supported");
 
-        // delete target file
-        if (opts.replaceExisting)
-            target.deleteIfExists();
+        // check if target exists
+        boolean exists;
+        if (opts.replaceExisting) {
+            try {
+                target.deleteIfExists();
+                exists = false;
+            } catch (DirectoryNotEmptyException x) {
+                // let exception translate to FileAlreadyExistsException (6895012)
+                exists = true;
+            }
+        } else {
+            exists = target.exists();
+        }
+        if (exists)
+            throw new FileAlreadyExistsException(target.toString());
 
         // create directory or file
         if (attrs.isDirectory()) {
@@ -318,7 +330,7 @@
         ReadableByteChannel rbc = newByteChannel();
         try {
             // open target file for writing
-            SeekableByteChannel sbc = target.newByteChannel(CREATE, WRITE);
+            SeekableByteChannel sbc = target.newByteChannel(CREATE_NEW, WRITE);
 
             // simple copy loop
             try {
--- a/jdk/src/share/classes/sun/nio/fs/AbstractWatchKey.java	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/src/share/classes/sun/nio/fs/AbstractWatchKey.java	Wed Jul 05 17:06:00 2017 +0200
@@ -88,27 +88,25 @@
     final void signalEvent(WatchEvent.Kind<?> kind, Object context) {
         synchronized (this) {
             int size = events.size();
-            if (size > 1) {
-                // don't let list get too big
+            if (size > 0) {
+                // if the previous event is an OVERFLOW event or this is a
+                // repeated event then we simply increment the counter
+                WatchEvent<?> prev = events.get(size-1);
+                if ((prev.kind() == StandardWatchEventKind.OVERFLOW) ||
+                    ((kind == prev.kind() &&
+                     Objects.equals(context, prev.context()))))
+                {
+                    ((Event<?>)prev).increment();
+                    return;
+                }
+
+                // if the list has reached the limit then drop pending events
+                // and queue an OVERFLOW event
                 if (size >= MAX_EVENT_LIST_SIZE) {
+                    events.clear();
                     kind = StandardWatchEventKind.OVERFLOW;
                     context = null;
                 }
-
-                // repeated event
-                WatchEvent<?> prev = events.get(size-1);
-                if (kind == prev.kind()) {
-                    boolean isRepeat;
-                    if (context == null) {
-                        isRepeat = (prev.context() == null);
-                    } else {
-                        isRepeat = context.equals(prev.context());
-                    }
-                    if (isRepeat) {
-                        ((Event<?>)prev).increment();
-                        return;
-                    }
-                }
             }
 
             // non-repeated event
--- a/jdk/src/share/classes/sun/security/krb5/internal/ktab/KeyTabEntry.java	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/src/share/classes/sun/security/krb5/internal/ktab/KeyTabEntry.java	Wed Jul 05 17:06:00 2017 +0200
@@ -75,7 +75,7 @@
     public String getKeyString() {
         StringBuffer sb = new StringBuffer("0x");
         for (int i = 0; i < keyblock.length; i++) {
-            sb.append(Integer.toHexString(keyblock[i]&0xff));
+            sb.append(String.format("%02x", keyblock[i]&0xff));
         }
         return sb.toString();
     }
--- a/jdk/src/share/classes/sun/security/provider/certpath/OCSPResponse.java	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/src/share/classes/sun/security/provider/certpath/OCSPResponse.java	Wed Jul 05 17:06:00 2017 +0200
@@ -574,10 +574,18 @@
                             (singleExtDer.length);
                     for (int i = 0; i < singleExtDer.length; i++) {
                         Extension ext = new Extension(singleExtDer[i]);
-                        singleExtensions.put(ext.getId(), ext);
                         if (DEBUG != null) {
                             DEBUG.println("OCSP single extension: " + ext);
                         }
+                        // We don't support any extensions yet. Therefore, if it
+                        // is critical we must throw an exception because we
+                        // don't know how to process it.
+                        if (ext.isCritical()) {
+                            throw new IOException(
+                                "Unsupported OCSP critical extension: " +
+                                ext.getExtensionId());
+                        }
+                        singleExtensions.put(ext.getId(), ext);
                     }
                 } else {
                     singleExtensions = Collections.emptyMap();
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpChannelImpl.java	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/src/solaris/classes/sun/nio/ch/SctpChannelImpl.java	Wed Jul 05 17:06:00 2017 +0200
@@ -38,7 +38,6 @@
 import java.nio.channels.ClosedChannelException;
 import java.nio.channels.ConnectionPendingException;
 import java.nio.channels.NoConnectionPendingException;
-import java.nio.channels.AlreadyBoundException;
 import java.nio.channels.AlreadyConnectedException;
 import java.nio.channels.NotYetBoundException;
 import java.nio.channels.NotYetConnectedException;
@@ -54,7 +53,6 @@
 import com.sun.nio.sctp.NotificationHandler;
 import com.sun.nio.sctp.SctpChannel;
 import com.sun.nio.sctp.SctpSocketOption;
-import sun.nio.ch.NativeDispatcher;
 import sun.nio.ch.PollArrayWrapper;
 import sun.nio.ch.SelChImpl;
 import static com.sun.nio.sctp.SctpStandardSocketOption.*;
@@ -69,9 +67,6 @@
 public class SctpChannelImpl extends SctpChannel
     implements SelChImpl
 {
-    /* Used to make native close and preClose calls */
-    private static NativeDispatcher nd;
-
     private final FileDescriptor fd;
 
     private final int fdVal;
@@ -182,7 +177,7 @@
                 synchronized (stateLock) {
                     ensureOpenAndUnconnected();
                     if (isBound())
-                        throw new AlreadyBoundException();
+                        SctpNet.throwAlreadyBoundException();
                     InetSocketAddress isa = (local == null) ?
                         new InetSocketAddress(0) : Net.checkAddress(local);
                     Net.bind(fd, isa.getAddress(), isa.getPort());
@@ -234,7 +229,7 @@
                     if (add) {
                         for (InetSocketAddress addr : localAddresses) {
                             if (addr.getAddress().equals(address)) {
-                                throw new AlreadyBoundException();
+                                SctpNet.throwAlreadyBoundException();
                             }
                         }
                     } else { /*removing */
@@ -370,7 +365,7 @@
                                 InetAddress ia = isa.getAddress();
                                 if (ia.isAnyLocalAddress())
                                     ia = InetAddress.getLocalHost();
-                                n = Net.connect(fd, ia, isa.getPort());
+                                n = SctpNet.connect(fdVal, ia, isa.getPort());
                                 if (  (n == IOStatus.INTERRUPTED)
                                       && isOpen())
                                     continue;
@@ -556,7 +551,7 @@
     @Override
     public void implCloseSelectableChannel() throws IOException {
         synchronized (stateLock) {
-            nd.preClose(fd);
+            SctpNet.preClose(fdVal);
 
             if (receiverThread != 0)
                 NativeThread.signal(receiverThread);
@@ -662,7 +657,7 @@
             /* Postpone the kill if there is a waiting reader
              * or writer thread. */
             if (receiverThread == 0 && senderThread == 0) {
-                nd.close(fd);
+                SctpNet.close(fdVal);
                 state = ChannelState.KILLED;
             } else {
                 state = ChannelState.KILLPENDING;
@@ -874,8 +869,8 @@
         public HandlerResult handleNotification(
                 AssociationChangeNotification not, T unused) {
             if (not.event().equals(
-                    AssociationChangeNotification.AssocChangeEvent.COMM_UP)) {
-                assert association == null;
+                    AssociationChangeNotification.AssocChangeEvent.COMM_UP) &&
+                    association == null) {
                 SctpAssocChange sac = (SctpAssocChange) not;
                 association = new SctpAssociationImpl
                        (sac.assocId(), sac.maxInStreams(), sac.maxOutStreams());
@@ -987,17 +982,17 @@
         SocketAddress target = messageInfo.address();
         boolean unordered = messageInfo.isUnordered();
         int ppid = messageInfo.payloadProtocolID();
-        int pos = src.position();
-        int lim = src.limit();
-
-        assert (pos <= lim && streamNumber >= 0);
-        int rem = (pos <= lim ? lim - pos : 0);
 
         if (src instanceof DirectBuffer)
-            return sendFromNativeBuffer(fd, src, rem, pos, target, streamNumber,
+            return sendFromNativeBuffer(fd, src, target, streamNumber,
                     unordered, ppid);
 
         /* Substitute a native buffer */
+        int pos = src.position();
+        int lim = src.limit();
+        assert (pos <= lim && streamNumber >= 0);
+
+        int rem = (pos <= lim ? lim - pos : 0);
         ByteBuffer bb = Util.getTemporaryDirectBuffer(rem);
         try {
             bb.put(src);
@@ -1005,7 +1000,7 @@
             /* Do not update src until we see how many bytes were written */
             src.position(pos);
 
-            int n = sendFromNativeBuffer(fd, bb, rem, pos, target, streamNumber,
+            int n = sendFromNativeBuffer(fd, bb, target, streamNumber,
                     unordered, ppid);
             if (n > 0) {
                 /* now update src */
@@ -1019,13 +1014,16 @@
 
     private int sendFromNativeBuffer(int fd,
                                      ByteBuffer bb,
-                                     int rem,
-                                     int pos,
                                      SocketAddress target,
                                      int streamNumber,
                                      boolean unordered,
                                      int ppid)
             throws IOException {
+        int pos = bb.position();
+        int lim = bb.limit();
+        assert (pos <= lim);
+        int rem = (pos <= lim ? lim - pos : 0);
+
         int written = send0(fd, ((DirectBuffer)bb).address() + pos,
                             rem, target, -1 /*121*/, streamNumber, unordered, ppid);
         if (written > 0)
@@ -1097,6 +1095,5 @@
         java.security.AccessController.doPrivileged(
                 new sun.security.action.LoadLibraryAction("sctp"));
         initIDs();
-        nd = new SctpSocketDispatcher();
     }
 }
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpMultiChannelImpl.java	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/src/solaris/classes/sun/nio/ch/SctpMultiChannelImpl.java	Wed Jul 05 17:06:00 2017 +0200
@@ -38,7 +38,6 @@
 import java.util.HashMap;
 import java.nio.ByteBuffer;
 import java.nio.channels.SelectionKey;
-import java.nio.channels.AlreadyBoundException;
 import java.nio.channels.ClosedChannelException;
 import java.nio.channels.NotYetBoundException;
 import java.nio.channels.spi.SelectorProvider;
@@ -63,9 +62,6 @@
 public class SctpMultiChannelImpl extends SctpMultiChannel
     implements SelChImpl
 {
-    /* Used to make native close and preClose calls */
-    private static NativeDispatcher nd;
-
     private final FileDescriptor fd;
 
     private final int fdVal;
@@ -140,7 +136,7 @@
                 synchronized (stateLock) {
                     ensureOpen();
                     if (isBound())
-                        throw new AlreadyBoundException();
+                        SctpNet.throwAlreadyBoundException();
                     InetSocketAddress isa = (local == null) ?
                         new InetSocketAddress(0) : Net.checkAddress(local);
 
@@ -155,7 +151,7 @@
                     if (isa.getAddress().isAnyLocalAddress())
                         wildcard = true;
 
-                    Net.listen(fd, backlog < 1 ? 50 : backlog);
+                    SctpNet.listen(fdVal, backlog < 1 ? 50 : backlog);
                 }
             }
         }
@@ -196,7 +192,7 @@
                     if (add) {
                         for (InetSocketAddress addr : localAddresses) {
                             if (addr.getAddress().equals(address)) {
-                                throw new AlreadyBoundException();
+                                SctpNet.throwAlreadyBoundException();
                             }
                         }
                     } else { /*removing */
@@ -284,7 +280,7 @@
     @Override
     public void implCloseSelectableChannel() throws IOException {
         synchronized (stateLock) {
-            nd.preClose(fd);
+            SctpNet.preClose(fdVal);
 
             if (receiverThread != 0)
                 NativeThread.signal(receiverThread);
@@ -375,7 +371,7 @@
 
             /* Postpone the kill if there is a thread sending or receiving. */
             if (receiverThread == 0 && senderThread == 0) {
-                nd.close(fd);
+                SctpNet.close(fdVal);
                 state = ChannelState.KILLED;
             } else {
                 state = ChannelState.KILLPENDING;
@@ -846,16 +842,17 @@
         int streamNumber = messageInfo.streamNumber();
         boolean unordered = messageInfo.isUnordered();
         int ppid = messageInfo.payloadProtocolID();
+
+        if (src instanceof DirectBuffer)
+            return sendFromNativeBuffer(fd, src, target, assocId,
+                    streamNumber, unordered, ppid);
+
+        /* Substitute a native buffer */
         int pos = src.position();
         int lim = src.limit();
         assert (pos <= lim && streamNumber >= 0);
+
         int rem = (pos <= lim ? lim - pos : 0);
-
-        if (src instanceof DirectBuffer)
-            return sendFromNativeBuffer(fd, src, rem, pos, target, assocId,
-                    streamNumber, unordered, ppid);
-
-        /* Substitute a native buffer */
         ByteBuffer bb = Util.getTemporaryDirectBuffer(rem);
         try {
             bb.put(src);
@@ -863,7 +860,7 @@
             /* Do not update src until we see how many bytes were written */
             src.position(pos);
 
-            int n = sendFromNativeBuffer(fd, bb, rem, pos, target, assocId,
+            int n = sendFromNativeBuffer(fd, bb, target, assocId,
                     streamNumber, unordered, ppid);
             if (n > 0) {
                 /* now update src */
@@ -877,14 +874,17 @@
 
     private int sendFromNativeBuffer(int fd,
                                      ByteBuffer bb,
-                                     int rem,
-                                     int pos,
                                      SocketAddress target,
                                      int assocId,
                                      int streamNumber,
                                      boolean unordered,
                                      int ppid)
             throws IOException {
+        int pos = bb.position();
+        int lim = bb.limit();
+        assert (pos <= lim);
+        int rem = (pos <= lim ? lim - pos : 0);
+
         int written = send0(fd, ((DirectBuffer)bb).address() + pos,
                             rem, target, assocId, streamNumber, unordered, ppid);
         if (written > 0)
@@ -981,6 +981,5 @@
         Util.load();   /* loads nio & net native libraries */
         java.security.AccessController.doPrivileged(
                 new sun.security.action.LoadLibraryAction("sctp"));
-        nd = new SctpSocketDispatcher();
     }
 }
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpNet.java	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/src/solaris/classes/sun/nio/ch/SctpNet.java	Wed Jul 05 17:06:00 2017 +0200
@@ -29,6 +29,7 @@
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.SocketAddress;
+import java.nio.channels.AlreadyBoundException;
 import java.util.Set;
 import java.util.HashSet;
 import java.security.AccessController;
@@ -52,8 +53,29 @@
         return false;
     }
 
+    static boolean throwAlreadyBoundException() throws IOException {
+        throw new AlreadyBoundException();
+    }
+
+    static void listen(int fd, int backlog) throws IOException {
+        listen0(fd, backlog);
+    }
+
+    static int connect(int fd, InetAddress remote, int remotePort)
+            throws IOException {
+        return connect0(fd, remote, remotePort);
+    }
+
+    static void close(int fd) throws IOException {
+        close0(fd);
+    }
+
+    static void preClose(int fd) throws IOException {
+        preClose0(fd);
+    }
+
     /**
-     * @param  oneToone
+     * @param  oneToOne
      *         if {@code true} returns a one-to-one sctp socket, otherwise
      *         returns a one-to-many sctp socket
      */
@@ -240,6 +262,15 @@
     /* Native Methods */
     static native int socket0(boolean oneToOne) throws IOException;
 
+    static native void listen0(int fd, int backlog) throws IOException;
+
+    static native int connect0(int fd, InetAddress remote, int remotePort)
+        throws IOException;
+
+    static native void close0(int fd) throws IOException;
+
+    static native void preClose0(int fd) throws IOException;
+
     static native void bindx(int fd, InetAddress[] addrs, int port, int length,
             boolean add, boolean preferIPv6) throws IOException;
 
@@ -271,5 +302,11 @@
             throws IOException;
 
     static native void shutdown0(int fd, int assocId);
+
+    static native void init();
+
+    static {
+        init();
+    }
 }
 
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpServerChannelImpl.java	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/src/solaris/classes/sun/nio/ch/SctpServerChannelImpl.java	Wed Jul 05 17:06:00 2017 +0200
@@ -33,7 +33,6 @@
 import java.util.Set;
 import java.util.HashSet;
 import java.nio.channels.SelectionKey;
-import java.nio.channels.AlreadyBoundException;
 import java.nio.channels.ClosedChannelException;
 import java.nio.channels.NotYetBoundException;
 import java.nio.channels.spi.SelectorProvider;
@@ -49,9 +48,6 @@
 public class SctpServerChannelImpl extends SctpServerChannel
     implements SelChImpl
 {
-    /* Used to make native close and preClose calls */
-    private static NativeDispatcher nd;
-
     private final FileDescriptor fd;
 
     private final int fdVal;
@@ -103,7 +99,7 @@
                 if (!isOpen())
                     throw new ClosedChannelException();
                 if (isBound())
-                    throw new AlreadyBoundException();
+                    SctpNet.throwAlreadyBoundException();
 
                 InetSocketAddress isa = (local == null) ?
                     new InetSocketAddress(0) : Net.checkAddress(local);
@@ -118,7 +114,7 @@
                     if (isa.getAddress().isAnyLocalAddress())
                         wildcard = true;
 
-                Net.listen(fd, backlog < 1 ? 50 : backlog);
+                SctpNet.listen(fdVal, backlog < 1 ? 50 : backlog);
             }
         }
         return this;
@@ -156,7 +152,7 @@
                 if (add) {
                     for (InetSocketAddress addr : localAddresses) {
                         if (addr.getAddress().equals(address)) {
-                            throw new AlreadyBoundException();
+                            SctpNet.throwAlreadyBoundException();
                         }
                     }
                 } else { /*removing */
@@ -261,7 +257,7 @@
     @Override
     public void implCloseSelectableChannel() throws IOException {
         synchronized (stateLock) {
-            nd.preClose(fd);
+            SctpNet.preClose(fdVal);
             if (thread != 0)
                 NativeThread.signal(thread);
             if (!isRegistered())
@@ -282,7 +278,7 @@
 
             // Postpone the kill if there is a thread in accept
             if (thread == 0) {
-                nd.close(fd);
+                SctpNet.close(fdVal);
                 state = ChannelState.KILLED;
             } else {
                 state = ChannelState.KILLPENDING;
@@ -423,7 +419,6 @@
         Util.load();   // loads nio & net native libraries
         java.security.AccessController.doPrivileged(
                 new sun.security.action.LoadLibraryAction("sctp"));
-        nd = new SctpSocketDispatcher();
         initIDs();
     }
 }
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpSocketDispatcher.java	Thu Jan 21 11:12:31 2010 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-package sun.nio.ch;
-
-import java.io.IOException;
-import java.io.FileDescriptor;
-
-/**
- * Only used for {@code close} and {@code preclose}. All other methods
- * throw {@code IOException}.
- */
-class SctpSocketDispatcher extends NativeDispatcher {
-    @Override
-    @SuppressWarnings("unused")
-    int read(FileDescriptor fd, long address, int len) throws IOException {
-         throw new IOException("Operation Unsupported");
-    }
-
-    @Override
-    @SuppressWarnings("unused")
-    long readv(FileDescriptor fd, long address, int len) throws IOException {
-         throw new IOException("Operation Unsupported");
-    }
-
-    @Override
-    @SuppressWarnings("unused")
-    int write(FileDescriptor fd, long address, int len) throws IOException {
-         throw new IOException("Operation Unsupported");
-    }
-
-    @Override
-    @SuppressWarnings("unused")
-    long writev(FileDescriptor fd, long address, int len) throws IOException {
-         throw new IOException("Operation Unsupported");
-    }
-
-    @Override
-    void close(FileDescriptor fd) throws IOException {
-        FileDispatcherImpl.close0(fd);
-    }
-
-    @Override
-    void preClose(FileDescriptor fd) throws IOException {
-        FileDispatcherImpl.preClose0(fd);
-    }
-}
--- a/jdk/src/solaris/native/sun/nio/ch/SctpNet.c	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/src/solaris/native/sun/nio/ch/SctpNet.c	Wed Jul 05 17:06:00 2017 +0200
@@ -48,6 +48,9 @@
     return JNI_VERSION_1_2;
 }
 
+static int preCloseFD = -1;     /* File descriptor to which we dup other fd's
+                                   before closing them for real */
+
 /**
  * Loads the native sctp library that contains the socket extension
  * functions, as well as locating the individual functions.
@@ -107,6 +110,55 @@
     return JNI_TRUE;
 }
 
+jint
+handleSocketError(JNIEnv *env, jint errorValue)
+{
+    char *xn;
+    switch (errorValue) {
+        case EINPROGRESS:     /* Non-blocking connect */
+            return 0;
+        case EPROTO:
+            xn= JNU_JAVANETPKG "ProtocolException";
+            break;
+        case ECONNREFUSED:
+            xn = JNU_JAVANETPKG "ConnectException";
+            break;
+        case ETIMEDOUT:
+            xn = JNU_JAVANETPKG "ConnectException";
+            break;
+        case EHOSTUNREACH:
+            xn = JNU_JAVANETPKG "NoRouteToHostException";
+            break;
+        case EADDRINUSE:  /* Fall through */
+        case EADDRNOTAVAIL:
+            xn = JNU_JAVANETPKG "BindException";
+            break;
+        default:
+            xn = JNU_JAVANETPKG "SocketException";
+            break;
+    }
+    errno = errorValue;
+    JNU_ThrowByNameWithLastError(env, xn, "NioSocketError");
+    return IOS_THROWN;
+}
+
+/*
+ * Class:     sun_nio_ch_SctpNet
+ * Method:    init
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL
+Java_sun_nio_ch_SctpNet_init
+  (JNIEnv *env, jclass cl) {
+    int sp[2];
+    if (socketpair(PF_UNIX, SOCK_STREAM, 0, sp) < 0) {
+        JNU_ThrowIOExceptionWithLastError(env, "socketpair failed");
+        return;
+    }
+    preCloseFD = sp[0];
+    close(sp[1]);
+}
+
 /*
  * Class:     sun_nio_ch_SctpNet
  * Method:    socket0
@@ -184,6 +236,76 @@
     free(sap);
 }
 
+/*
+ * Class:     sun_nio_ch_SctpNet
+ * Method:    listen0
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL
+Java_sun_nio_ch_SctpNet_listen0
+  (JNIEnv *env, jclass cl, jint fd, jint backlog) {
+    if (listen(fd, backlog) < 0)
+        handleSocketError(env, errno);
+}
+
+/*
+ * Class:     sun_nio_ch_SctpNet
+ * Method:    connect0
+ * Signature: (ILjava/net/InetAddress;I)I
+ */
+JNIEXPORT jint JNICALL
+Java_sun_nio_ch_SctpNet_connect0
+  (JNIEnv *env, jclass clazz, int fd, jobject iao, jint port) {
+    SOCKADDR sa;
+    int sa_len = SOCKADDR_LEN;
+    int rv;
+
+    if (NET_InetAddressToSockaddr(env, iao, port, (struct sockaddr *) &sa,
+                                  &sa_len, JNI_TRUE) != 0) {
+        return IOS_THROWN;
+    }
+
+    rv = connect(fd, (struct sockaddr *)&sa, sa_len);
+    if (rv != 0) {
+        if (errno == EINPROGRESS) {
+            return IOS_UNAVAILABLE;
+        } else if (errno == EINTR) {
+            return IOS_INTERRUPTED;
+        }
+        return handleSocketError(env, errno);
+    }
+    return 1;
+}
+
+/*
+ * Class:     sun_nio_ch_SctpNet
+ * Method:    close0
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL
+Java_sun_nio_ch_SctpNet_close0
+  (JNIEnv *env, jclass clazz, jint fd) {
+    if (fd != -1) {
+        int rv = close(fd);
+        if (rv < 0)
+            JNU_ThrowIOExceptionWithLastError(env, "Close failed");
+    }
+}
+
+/*
+ * Class:     sun_nio_ch_SctpNet
+ * Method:    preClose0
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL
+Java_sun_nio_ch_SctpNet_preClose0
+  (JNIEnv *env, jclass clazz, jint fd) {
+    if (preCloseFD >= 0) {
+        if (dup2(preCloseFD, fd) < 0)
+            JNU_ThrowIOExceptionWithLastError(env, "dup2 failed");
+    }
+}
+
 void initializeISA
   (JNIEnv* env) {
     if (isaCls == 0) {
@@ -394,7 +516,7 @@
         arglen = sizeof(arg);
     }
 
-    if (setsockopt(fd, klevel, kopt, parg, arglen) < 0) {
+    if (NET_SetSockOpt(fd, klevel, kopt, parg, arglen) < 0) {
         JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
                                      "sun_nio_ch_SctpNet.setIntOption0");
     }
@@ -427,7 +549,7 @@
         arglen = sizeof(result);
     }
 
-    if (getsockopt(fd, klevel, kopt, arg, &arglen) < 0) {
+    if (NET_GetSockOpt(fd, klevel, kopt, arg, &arglen) < 0) {
         JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
                                      "sun.nio.ch.Net.getIntOption");
         return -1;
--- a/jdk/src/windows/classes/sun/nio/ch/WindowsAsynchronousFileChannelImpl.java	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/src/windows/classes/sun/nio/ch/WindowsAsynchronousFileChannelImpl.java	Wed Jul 05 17:06:00 2017 +0200
@@ -445,20 +445,17 @@
                 // allocate OVERLAPPED
                 overlapped = ioCache.add(result);
 
-                // synchronize on result to allow this thread handle the case
-                // where the read completes immediately.
-                synchronized (result) {
-                    n = readFile(handle, address, rem, position, overlapped);
-                    if (n == IOStatus.UNAVAILABLE) {
-                        // I/O is pending
-                        return;
-                    }
-                    // read completed immediately:
-                    // 1. update buffer position
-                    // 2. release waiters
-                    updatePosition(n);
+                // initiate read
+                n = readFile(handle, address, rem, position, overlapped);
+                if (n == IOStatus.UNAVAILABLE) {
+                    // I/O is pending
+                    return;
+                } else if (n == IOStatus.EOF) {
                     result.setResult(n);
+                } else {
+                    throw new InternalError("Unexpected result: " + n);
                 }
+
             } catch (Throwable x) {
                 // failed to initiate read
                 result.setFailure(toIOException(x));
@@ -466,12 +463,9 @@
                 end();
             }
 
-            // read failed or EOF so completion port will not be notified
-            if (n < 0 && overlapped != 0L) {
+            // release resources
+            if (overlapped != 0L)
                 ioCache.remove(overlapped);
-            }
-
-            // return direct buffer to cache if substituted
             releaseBufferIfSubstituted();
 
             // invoke completion handler
@@ -634,20 +628,15 @@
                 // allocate an OVERLAPPED structure
                 overlapped = ioCache.add(result);
 
-                // synchronize on result to allow this thread handle the case
-                // where the read completes immediately.
-                synchronized (result) {
-                    n = writeFile(handle, address, rem, position, overlapped);
-                    if (n == IOStatus.UNAVAILABLE) {
-                        // I/O is pending
-                        return;
-                    }
-                    // read completed immediately:
-                    // 1. update buffer position
-                    // 2. release waiters
-                    updatePosition(n);
-                    result.setResult(n);
+                // initiate the write
+                n = writeFile(handle, address, rem, position, overlapped);
+                if (n == IOStatus.UNAVAILABLE) {
+                    // I/O is pending
+                    return;
+                } else {
+                    throw new InternalError("Unexpected result: " + n);
                 }
+
             } catch (Throwable x) {
                 // failed to initiate read:
                 result.setFailure(toIOException(x));
--- a/jdk/src/windows/native/sun/nio/ch/WindowsAsynchronousFileChannelImpl.c	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/src/windows/native/sun/nio/ch/WindowsAsynchronousFileChannelImpl.c	Wed Jul 05 17:06:00 2017 +0200
@@ -39,7 +39,6 @@
     jlong handle, jlong address, jint len, jlong offset, jlong ov)
 {
     BOOL res;
-    DWORD nread = 0;
 
     OVERLAPPED* lpOverlapped = (OVERLAPPED*)jlong_to_ptr(ov);
     lpOverlapped->Offset = (DWORD)offset;
@@ -49,7 +48,7 @@
     res = ReadFile((HANDLE) jlong_to_ptr(handle),
                    (LPVOID) jlong_to_ptr(address),
                    (DWORD)len,
-                   &nread,
+                   NULL,
                    lpOverlapped);
 
     if (res == 0) {
@@ -62,7 +61,7 @@
         return IOS_THROWN;
     }
 
-    return (jint)nread;
+    return IOS_UNAVAILABLE;
 }
 
 JNIEXPORT jint JNICALL
@@ -70,7 +69,6 @@
     jlong handle, jlong address, jint len, jlong offset, jlong ov)
 {
     BOOL res;
-    DWORD nwritten = 0;
 
     OVERLAPPED* lpOverlapped = (OVERLAPPED*)jlong_to_ptr(ov);
     lpOverlapped->Offset = (DWORD)offset;
@@ -80,18 +78,18 @@
     res = WriteFile((HANDLE)jlong_to_ptr(handle),
                    (LPVOID) jlong_to_ptr(address),
                    (DWORD)len,
-                   &nwritten,
+                   NULL,
                    lpOverlapped);
 
     if (res == 0) {
         int error = GetLastError();
-        if (error == ERROR_IO_PENDING) {
+        if (error == ERROR_IO_PENDING)
             return IOS_UNAVAILABLE;
-        }
         JNU_ThrowIOExceptionWithLastError(env, "WriteFile failed");
         return IOS_THROWN;
     }
-    return (jint)nwritten;
+
+    return IOS_UNAVAILABLE;
 }
 
 JNIEXPORT jint JNICALL
--- a/jdk/test/com/sun/jdi/ProcessAttachTest.sh	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/test/com/sun/jdi/ProcessAttachTest.sh	Wed Jul 05 17:06:00 2017 +0200
@@ -54,10 +54,14 @@
 OS=`uname -s`
 
 case "$OS" in
-  Windows* | CYGWIN_NT*)
+  Windows*)
     PS=";"
     OS="Windows"
     ;;
+  CYGWIN*)
+    PS=";"
+    OS="CYGWIN"
+    ;;
   * )
     PS=":"
     ;;
@@ -67,16 +71,23 @@
 {
   OUTPUTFILE=${TESTCLASSES}/Debuggee.out
   ${JAVA} "$@" > ${OUTPUTFILE} &
-  pid="$!"
+  startpid="$!"
+  pid="${startpid}"
                                                                                                      
+  # CYGWIN startpid is not the native windows PID we want, get the WINPID
+  if [ "${OS}" = "CYGWIN" ]; then
+    sleep 2
+    ps -l -p ${startpid}
+    pid=`ps -l -p ${startpid} | tail -1 | awk '{print $4;}'`
+  fi
+  
   # MKS creates an intermediate shell to launch ${JAVA} so
-  # ${pid} is not the actual pid. We have put in a small sleep
+  # ${startpid} is not the actual pid. We have put in a small sleep
   # to give the intermediate shell process time to launch the
   # "java" process.
   if [ "$OS" = "Windows" ]; then
     sleep 2
-    realpid=`ps -o pid,ppid,comm|grep ${pid}|grep "java"|cut -c1-6`
-    pid=${realpid}
+    pid=`ps -o pid,ppid,comm|grep ${startpid}|grep "java"|cut -c1-6`
   fi
                                                                                                      
   echo "Waiting for Debuggee to initialize..."
@@ -91,7 +102,7 @@
     echo "Waiting $attempts second(s) ..."
   done
 
-  echo "Debuggee is process $pid"
+  echo "Debuggee is process $pid (startpid=${startpid})"
 }
 
 stopDebuggee()
@@ -100,7 +111,7 @@
   if [ $? != 0 ] ; then
     echo "Error: ShutdownDebuggee failed"
     failures=`expr $failures + 1`
-    kill -9 $pid
+    kill -9 ${startpid}
   fi
 }
 
@@ -123,7 +134,7 @@
   -agentlib:jdwp=transport=dt_socket,server=y,suspend=n \
   -classpath "${TESTCLASSES}" ProcessAttachDebuggee "${PORTFILE}"
 
-$JAVA -classpath ${TESTCLASSES}${PS}${TESTJAVA}/lib/tools.jar \
+$JAVA -classpath "${TESTCLASSES}${PS}${TESTJAVA}/lib/tools.jar" \
   ProcessAttachDebugger $pid 2>&1
 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
 
@@ -141,7 +152,7 @@
   -agentlib:jdwp=transport=dt_socket,server=y,suspend=y \
   -classpath "${TESTCLASSES}" ProcessAttachDebuggee "${PORTFILE}"
 
-$JAVA -classpath ${TESTCLASSES}${PS}${TESTJAVA}/lib/tools.jar \
+$JAVA -classpath "${TESTCLASSES}${PS}${TESTJAVA}/lib/tools.jar" \
   ProcessAttachDebugger $pid 2>&1
 
 # The debuggee is suspended and doesn't run until the debugger
--- a/jdk/test/com/sun/jdi/connect/spi/JdiLoadedByCustomLoader.sh	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/test/com/sun/jdi/connect/spi/JdiLoadedByCustomLoader.sh	Wed Jul 05 17:06:00 2017 +0200
@@ -51,7 +51,7 @@
   Linux )
     PS=":"
     ;;
-  Windows* )
+  Windows* | CYGWIN*)
     PS=";"
     ;;
   * )
@@ -71,7 +71,7 @@
 $JAVAC -d "${TESTCLASSES}" "${TESTSRC}"/JdiLoadedByCustomLoader.java
 
 mkdir "${SOMEOTHERDIR}"
-$JAVAC -d "${SOMEOTHERDIR}" -classpath ${TESTSRC}${PS}${TESTJAVA}/lib/tools.jar \
+$JAVAC -d "${SOMEOTHERDIR}" -classpath "${TESTSRC}${PS}${TESTJAVA}/lib/tools.jar" \
     "${TESTSRC}"/ListConnectors.java
 
 # Run the test 
--- a/jdk/test/com/sun/nio/sctp/SctpChannel/Connect.java	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/test/com/sun/nio/sctp/SctpChannel/Connect.java	Wed Jul 05 17:06:00 2017 +0200
@@ -192,6 +192,18 @@
             testCCE(new Callable<Void>() {
                 public Void call() throws IOException {
                     cceChannel.finishConnect(); return null; } });
+
+            /* TEST 8: IOException: Connection refused. Exercises handleSocketError.
+             *         Assumption: no sctp socket listening on 3456 */
+            SocketAddress addr = new InetSocketAddress("localhost", 3456);
+            channel = SctpChannel.open();
+            try {
+                channel.connect(addr);
+                fail("should have thrown ConnectException: Connection refused");
+            } catch (IOException ioe) {
+                pass();
+            }
+
         } catch (IOException ioe) {
             unexpected(ioe);
         } finally {
--- a/jdk/test/com/sun/nio/sctp/SctpChannel/Send.java	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/test/com/sun/nio/sctp/SctpChannel/Send.java	Wed Jul 05 17:06:00 2017 +0200
@@ -112,9 +112,6 @@
             /* Receive CommUp */
             channel.receive(buffer, null, handler);
 
-            /* save for TEST 8 */
-            Association association = channel.association();
-
             /* TEST 2: send small message */
             int streamNumber = 0;
             debug("sending on stream number: " + streamNumber);
@@ -250,6 +247,29 @@
                 pass();
                 debug("OK, caught " + e);
             }
+
+            /* TEST 9: Send from heap buffer to force implementation to
+             * substitute with a native buffer, then check that its position
+             * is updated correctly */
+            buffer.clear();
+            info = MessageInfo.createOutgoing(null, 0);
+            buffer.put(Util.SMALL_MESSAGE.getBytes("ISO-8859-1"));
+            buffer.flip();
+            final int offset = 1;
+            buffer.position(offset);
+            remaining = buffer.remaining();
+
+            debug("sending small message: " + buffer);
+            try {
+                sent = channel.send(buffer, info);
+
+                check(sent == remaining, "sent should be equal to remaining");
+                check(buffer.position() == (offset + sent),
+                        "buffers position should have been incremented by sent");
+            } catch (IllegalArgumentException iae) {
+                fail(iae + ", Error updating buffers position");
+            }
+
         } catch (IOException ioe) {
             unexpected(ioe);
         } finally {
@@ -335,6 +355,30 @@
                 /* TEST 7 ++ */
                 sc2 = ssc.accept();
 
+                /* TEST 9 */
+                ByteBuffer expected = ByteBuffer.allocate(Util.SMALL_BUFFER);
+                expected.put(Util.SMALL_MESSAGE.getBytes("ISO-8859-1"));
+                expected.flip();
+                final int offset = 1;
+                expected.position(offset);
+                buffer.clear();
+                do {
+                    info = sc2.receive(buffer, null, null);
+                    if (info == null) {
+                        fail("Server: unexpected null from receive");
+                        return;
+                    }
+                } while (!info.isComplete());
+
+                buffer.flip();
+                check(info != null, "info is null");
+                check(info.streamNumber() == 0, "message not sent on the correct stream");
+                check(info.bytes() == expected.remaining(),
+                      "bytes received not equal to message length");
+                check(info.bytes() == buffer.remaining(), "bytes != remaining");
+                check(expected.equals(buffer),
+                    "received message not the same as sent message");
+
                 clientFinishedLatch.await(10L, TimeUnit.SECONDS);
                 serverFinishedLatch.countDown();
             } catch (IOException ioe) {
--- a/jdk/test/com/sun/nio/sctp/SctpChannel/SocketOptionTests.java	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/test/com/sun/nio/sctp/SctpChannel/SocketOptionTests.java	Wed Jul 05 17:06:00 2017 +0200
@@ -104,7 +104,9 @@
             sc.setOption(SCTP_NODELAY, true);
             checkOption(sc, SCTP_NODELAY, true);
             sc.setOption(SO_SNDBUF, 16*1024);
+            checkOption(sc, SO_SNDBUF, 16*1024);
             sc.setOption(SO_RCVBUF, 16*1024);
+            checkOption(sc, SO_RCVBUF, 16*1024);
             checkOption(sc, SO_LINGER, -1);  /* default should be negative */
             sc.setOption(SO_LINGER, 2000);
             checkOption(sc, SO_LINGER, 2000);
--- a/jdk/test/com/sun/nio/sctp/SctpMultiChannel/Send.java	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/test/com/sun/nio/sctp/SctpMultiChannel/Send.java	Wed Jul 05 17:06:00 2017 +0200
@@ -185,6 +185,27 @@
             /* TEST 5: getRemoteAddresses(Association) */
             channel.getRemoteAddresses(assoc);
 
+            /* TEST 6: Send from heap buffer to force implementation to
+             * substitute with a native buffer, then check that its position
+             * is updated correctly */
+            info = MessageInfo.createOutgoing(assoc, null, 0);
+            buffer.clear();
+            buffer.put(Util.SMALL_MESSAGE.getBytes("ISO-8859-1"));
+            buffer.flip();
+            final int offset = 1;
+            buffer.position(offset);
+            remaining = buffer.remaining();
+
+            try {
+                sent = channel.send(buffer, info);
+
+                check(sent == remaining, "sent should be equal to remaining");
+                check(buffer.position() == (offset + sent),
+                        "buffers position should have been incremented by sent");
+            } catch (IllegalArgumentException iae) {
+                fail(iae + ", Error updating buffers position");
+            }
+
         } catch (IOException ioe) {
             unexpected(ioe);
         } finally {
@@ -284,6 +305,30 @@
                 bytes = serverChannel.send(buffer, info);
                 debug("Server: sent " + bytes + "bytes");
 
+                /* TEST 6 */
+                ByteBuffer expected = ByteBuffer.allocate(Util.SMALL_BUFFER);
+                expected.put(Util.SMALL_MESSAGE.getBytes("ISO-8859-1"));
+                expected.flip();
+                final int offset = 1;
+                expected.position(offset);
+                buffer.clear();
+                do {
+                    info = serverChannel.receive(buffer, null, null);
+                    if (info == null) {
+                        fail("Server: unexpected null from receive");
+                        return;
+                    }
+                } while (!info.isComplete());
+
+                buffer.flip();
+                check(info != null, "info is null");
+                check(info.streamNumber() == 0, "message not sent on the correct stream");
+                check(info.bytes() == expected.remaining(),
+                    "bytes received not equal to message length");
+                check(info.bytes() == buffer.remaining(), "bytes != remaining");
+                check(expected.equals(buffer),
+                    "received message not the same as sent message");
+
                 clientFinishedLatch.await(10L, TimeUnit.SECONDS);
                 serverFinishedLatch.countDown();
             } catch (IOException ioe) {
--- a/jdk/test/com/sun/tools/attach/ApplicationSetup.sh	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/test/com/sun/tools/attach/ApplicationSetup.sh	Wed Jul 05 17:06:00 2017 +0200
@@ -49,7 +49,11 @@
   # "java" process.
   if [ "$OS" = "Windows" ]; then
     sleep 2
-    realpid=`ps -o pid,ppid,comm|grep ${pid}|grep "java"|cut -c1-6`
+    if [ "${isCygwin}" = "true" ] ; then
+      realpid=`ps -p ${pid} | tail -1 | awk '{print $4;}'`
+    else
+      realpid=`ps -o pid,ppid,comm|grep ${pid}|grep "java"|cut -c1-6`
+    fi
     pid=${realpid}
   fi
                                                                                                                   
@@ -57,7 +61,7 @@
   attempts=0
   while true; do
     sleep 1
-    port=`tail -1 ${OUTPUTFILE}`
+    port=`tail -1 ${OUTPUTFILE} | sed -e 's@\\r@@g' `
     if [ ! -z "$port" ]; then
       # In case of errors wait time for output to be flushed
       sleep 1
--- a/jdk/test/com/sun/tools/attach/BasicTests.sh	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/test/com/sun/tools/attach/BasicTests.sh	Wed Jul 05 17:06:00 2017 +0200
@@ -48,7 +48,7 @@
 
 echo "Running tests ..."
 
-$JAVA -classpath ${TESTCLASSES}${PS}${TESTJAVA}/lib/tools.jar \
+$JAVA -classpath "${TESTCLASSES}${PS}${TESTJAVA}/lib/tools.jar" \
   BasicTests $pid $agent $badagent $redefineagent 2>&1
 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
 
--- a/jdk/test/com/sun/tools/attach/CommonSetup.sh	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/test/com/sun/tools/attach/CommonSetup.sh	Wed Jul 05 17:06:00 2017 +0200
@@ -49,6 +49,12 @@
     OS="Windows"
     FS="\\"
     ;;
+  CYGWIN* )
+    PS=";"
+    OS="Windows"
+    FS="\\"
+    isCygwin=true
+    ;;
   * )
     echo "Unrecognized system!"
     exit 1;
--- a/jdk/test/com/sun/tools/attach/PermissionTests.sh	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/test/com/sun/tools/attach/PermissionTests.sh	Wed Jul 05 17:06:00 2017 +0200
@@ -48,7 +48,7 @@
 
 echo "Deny test"
 # deny 
-$JAVA -classpath ${TESTCLASSES}${PS}${TESTJAVA}/lib/tools.jar \
+$JAVA -classpath "${TESTCLASSES}${PS}${TESTJAVA}/lib/tools.jar" \
     -Djava.security.manager \
     -Djava.security.policy=${TESTSRC}/java.policy.deny \
     PermissionTest $pid true 2>&1
@@ -56,7 +56,7 @@
 
 # allow
 echo "Allow test"
-$JAVA -classpath ${TESTCLASSES}${PS}${TESTJAVA}/lib/tools.jar \
+$JAVA -classpath "${TESTCLASSES}${PS}${TESTJAVA}/lib/tools.jar" \
     -Djava.security.manager \
     -Djava.security.policy=${TESTSRC}/java.policy.allow \
     PermissionTest $pid false 2>&1 
--- a/jdk/test/com/sun/tools/attach/ProviderTests.sh	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/test/com/sun/tools/attach/ProviderTests.sh	Wed Jul 05 17:06:00 2017 +0200
@@ -46,6 +46,6 @@
 echo "Running test ..."
 
 $JAVA -classpath \
-  ${TESTCLASSES}${PS}${TESTCLASSES}/SimpleProvider.jar${PS}${TESTJAVA}/lib/tools.jar \
+  "${TESTCLASSES}${PS}${TESTCLASSES}/SimpleProvider.jar${PS}${TESTJAVA}/lib/tools.jar" \
   ProviderTest
 
--- a/jdk/test/java/beans/Introspector/Test5102804.java	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/test/java/beans/Introspector/Test5102804.java	Wed Jul 05 17:06:00 2017 +0200
@@ -24,6 +24,7 @@
 /*
  * @test
  * @bug 5102804
+ * @ignore This test is not predictable with regards to GC
  * @summary Tests memory leak
  * @author Sergey Malenkov
  */
--- a/jdk/test/java/io/File/Basic.java	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/test/java/io/File/Basic.java	Wed Jul 05 17:06:00 2017 +0200
@@ -75,7 +75,7 @@
         if (!f.canRead()) fail(f, "is not readable");
         if (f.canWrite() != writeable)
             fail(f, writeable ? "is not writeable" : "is writeable");
-        int rwLen = (File.separatorChar == '/' ? 6 : 7);
+        int rwLen = 6;
         if (f.length() != length) fail(f, "has wrong length");
     }
 
@@ -89,7 +89,7 @@
         if (nonExistantFile.exists()) fail(nonExistantFile, "exists");
 
         show(rwFile);
-        testFile(rwFile, true, File.separatorChar == '/' ? 6 : 7);
+        testFile(rwFile, true, 6);
         rwFile.delete();
         if (rwFile.exists())
             fail(rwFile, "could not delete");
--- a/jdk/test/java/io/File/basic.sh	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/test/java/io/File/basic.sh	Wed Jul 05 17:06:00 2017 +0200
@@ -32,10 +32,10 @@
 
 rm -rf x.Basic.*
 rm -f x.Basic.non
-echo xyzzy > x.Basic.rw
+printf "%s" "xyzzyN" > x.Basic.rw
 touch x.Basic.ro; chmod ugo-w x.Basic.ro
 mkdir x.Basic.dir
-if $TESTJAVA/bin/java $* -classpath $TESTCLASSES Basic; then
+if $TESTJAVA/bin/java $* -classpath "$TESTCLASSES" Basic; then
   [ -f x.Basic.rw ] && (echo "x.Basic.rw not deleted"; exit 1)
   ([ -d x.Basic.dir ] || [ \! -d x.Basic.dir2 ]) \
     && (echo "x.Basic.dir not renamed"; exit 1)
--- a/jdk/test/java/io/Serializable/evolution/RenamePackage/run.sh	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/test/java/io/Serializable/evolution/RenamePackage/run.sh	Wed Jul 05 17:06:00 2017 +0200
@@ -43,7 +43,7 @@
 case "$OS" in
 SunOS | Linux )
   PS=":"  ;;
-Windows* )
+Windows* | CYGWIN* )
   PS=";"  ;;
 * )
   echo "Unrecognized system!"
@@ -85,14 +85,14 @@
 ${JAVAC} -d ${TESTCLASSES}/nclasses ${TESTSRC}/install/SerialDriver.java
 
 # Run Case 1. Map test.SerialDriver within stream to install.SerialDriver.
-CLASSPATH=${TESTCLASSES}/oclasses${PS}${TESTCLASSES}/share; export CLASSPATH;
+CLASSPATH="${TESTCLASSES}/oclasses${PS}${TESTCLASSES}/share"; export CLASSPATH;
 ${JAVA} test.SerialDriver -s
-CLASSPATH=${TESTCLASSES}/nclasses${PS}${TESTCLASSES}/share; export CLASSPATH;
+CLASSPATH="${TESTCLASSES}/nclasses${PS}${TESTCLASSES}/share"; export CLASSPATH;
 ${JAVA} install.SerialDriver -d
 rm stream.ser
 
 # Run Case 2. Map install.SerialDriver within stream to test.SerialDriver.
-CLASSPATH=${TESTCLASSES}/nclasses${PS}${TESTCLASSES}/share; export CLASSPATH;
+CLASSPATH="${TESTCLASSES}/nclasses${PS}${TESTCLASSES}/share"; export CLASSPATH;
 ${JAVA} install.SerialDriver -s
-CLASSPATH=${TESTCLASSES}/oclasses${PS}${TESTCLASSES}/share; export CLASSPATH;
+CLASSPATH="${TESTCLASSES}/oclasses${PS}${TESTCLASSES}/share"; export CLASSPATH;
 ${JAVA} test.SerialDriver -d
--- a/jdk/test/java/io/Serializable/serialver/classpath/run.sh	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/test/java/io/Serializable/serialver/classpath/run.sh	Wed Jul 05 17:06:00 2017 +0200
@@ -49,7 +49,7 @@
 case "$OS" in
   SunOS | Linux )
     PS=":"    ;;
-  Windows* )
+  Windows* | CYGWIN* )
     PS=";"    ;;
   * )
     echo "Unrecognized system!"
--- a/jdk/test/java/io/Serializable/serialver/nested/run.sh	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/test/java/io/Serializable/serialver/nested/run.sh	Wed Jul 05 17:06:00 2017 +0200
@@ -49,7 +49,7 @@
 case "$OS" in
   SunOS | Linux )
     PS=":"    ;;
-  Windows* )
+  Windows* | CYGWIN* )
     PS=";"    ;;
   * )
     echo "Unrecognized system!"
--- a/jdk/test/java/lang/ClassLoader/deadlock/TestOneWayDelegate.sh	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/test/java/lang/ClassLoader/deadlock/TestOneWayDelegate.sh	Wed Jul 05 17:06:00 2017 +0200
@@ -55,7 +55,7 @@
   Linux )
     FS="/"
     ;;
-  Windows* )
+  Windows* | CYGWIN* )
     FS="\\"
     ;;
 esac
--- a/jdk/test/java/lang/StringCoding/CheckEncodings.sh	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/test/java/lang/StringCoding/CheckEncodings.sh	Wed Jul 05 17:06:00 2017 +0200
@@ -31,7 +31,7 @@
 OS=`uname -s`
 case "$OS" in
   SunOS | Linux ) ;;
-  Windows* )
+  Windows* | CYGWIN* )
     echo "Passed"; exit 0 ;;
   * ) echo "Unrecognized system!" ;  exit 1 ;;
 esac
--- a/jdk/test/java/lang/System/finalization/FinExit.sh	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/test/java/lang/System/finalization/FinExit.sh	Wed Jul 05 17:06:00 2017 +0200
@@ -24,7 +24,9 @@
 #
 
 #
-x=`$TESTJAVA/bin/java -cp $TESTCLASSES FinExit`
+
+# We only want the first character, Windows might add CRLF
+x=`$TESTJAVA/bin/java -cp "$TESTCLASSES" FinExit | cut -c1`
 echo $x
 if [ "x$x" != "x1" ]; then
   echo On-exit finalizer invoked twice
--- a/jdk/test/java/lang/annotation/loaderLeak/LoaderLeak.sh	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/test/java/lang/annotation/loaderLeak/LoaderLeak.sh	Wed Jul 05 17:06:00 2017 +0200
@@ -49,6 +49,11 @@
     PS=":"
     FS="/"
     ;;
+  CYGWIN* )
+    NULL=/dev/null
+    PS=";"
+    FS="/"
+    ;;
   Windows* )
     NULL=NUL
     PS=";"
--- a/jdk/test/java/lang/instrument/appendToClassLoaderSearch/CommonSetup.sh	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/test/java/lang/instrument/appendToClassLoaderSearch/CommonSetup.sh	Wed Jul 05 17:06:00 2017 +0200
@@ -43,11 +43,17 @@
     PS=":"
     FS="/"
     ;;
-  Windows* | CYGWIN*)
+  Windows*)
     PS=";"
     OS="Windows"
     FS="\\"
     ;;
+  CYGWIN*)
+    PS=";"
+    OS="Windows"
+    FS="\\"
+    isCygwin=true
+    ;;
   * )
     echo "Unrecognized system!"
     exit 1;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/nio/channels/AsynchronousFileChannel/LotsOfWrites.java	Wed Jul 05 17:06:00 2017 +0200
@@ -0,0 +1,162 @@
+/*
+ * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+ * @bug 6913877
+ * @summary Stress AsynchronousFileChannel.write
+ */
+
+import java.io.*;
+import java.nio.ByteBuffer;
+import static java.nio.file.StandardOpenOption.*;
+import java.nio.channels.*;
+import java.util.Random;
+import java.util.concurrent.CountDownLatch;
+
+public class LotsOfWrites {
+    static final Random rand = new Random();
+
+    /**
+     * Asynchronously writes a known pattern to a file up to a given size,
+     * counting down a latch to release waiters when done.
+     */
+    static class Writer implements CompletionHandler<Integer,ByteBuffer> {
+        private final File file;
+        private final long size;
+        private final CountDownLatch latch;
+        private final AsynchronousFileChannel channel;
+
+        private volatile long position;
+        private volatile byte nextByte;
+
+        private long updatePosition(long nwrote) {
+            position += nwrote;
+            return position;
+        }
+
+        private ByteBuffer genNextBuffer() {
+            int n = Math.min(8192 + rand.nextInt(8192), (int)(size - position));
+            ByteBuffer buf = ByteBuffer.allocate(n);
+            for (int i=0; i<n; i++) {
+                buf.put(nextByte++);
+            }
+            buf.flip();
+            return buf;
+        }
+
+        // close channel and release any waiters
+        private void done() {
+            try {
+                channel.close();
+            } catch (IOException ignore) { }
+            latch.countDown();
+        }
+
+        Writer(File file, long size, CountDownLatch latch) throws IOException {
+            this.file = file;
+            this.size = size;
+            this.latch = latch;
+            this.channel = AsynchronousFileChannel.open(file.toPath(), WRITE);
+        }
+
+        File file() {
+            return file;
+        }
+
+        long size() {
+            return size;
+        }
+
+        // initiate first write
+        void start() {
+            ByteBuffer buf = genNextBuffer();
+            channel.write(buf, 0L, buf, this);
+        }
+
+        @Override
+        public void completed(Integer nwrote, ByteBuffer buf) {
+            long pos = updatePosition(nwrote);
+            if (!buf.hasRemaining()) {
+                // buffer has been completely written; decide if we need to
+                // write more
+                if (position >= size) {
+                    done();
+                    return;
+                }
+                buf = genNextBuffer();
+            }
+            channel.write(buf, pos, buf, this);
+        }
+
+        @Override
+        public void failed(Throwable exc, ByteBuffer buf) {
+            exc.printStackTrace();
+            done();
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        // random number of writers
+        int count = 20 + rand.nextInt(16);
+        Writer[] writers = new Writer[count];
+        CountDownLatch latch = new CountDownLatch(count);
+
+        // initiate writing to each file
+        for (int i=0; i<count; i++) {
+            long size = 512*1024 + rand.nextInt(512*1024);
+            File blah = File.createTempFile("blah", null);
+            blah.deleteOnExit();
+            Writer writer = new Writer(blah, size, latch);
+            writers[i] = writer;
+            writer.start();
+        }
+
+        // wait for writing to complete
+        latch.await();
+
+        // verify content of each file
+        byte[] buf = new byte[8192];
+        for (int i=0; i<count ;i++) {
+            Writer writer = writers[i];
+            FileInputStream in = new FileInputStream(writer.file());
+            try {
+                long size = 0L;
+                byte expected = 0;
+                int nread = in.read(buf);
+                while (nread > 0) {
+                    for (int j=0; j<nread; j++) {
+                        if (buf[j] != expected)
+                            throw new RuntimeException("Unexpected byte");
+                        expected++;
+                    }
+                    size += nread;
+                    nread = in.read(buf);
+                }
+                if (size != writer.size())
+                    throw new RuntimeException("Unexpected size");
+            } finally {
+                in.close();
+            }
+        }
+    }
+}
--- a/jdk/test/java/nio/channels/Selector/lots_of_updates.sh	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/test/java/nio/channels/Selector/lots_of_updates.sh	Wed Jul 05 17:06:00 2017 +0200
@@ -30,7 +30,7 @@
 
 OS=`uname -s`
 case "$OS" in
-    Windows_* )
+    Windows_* | CYGWIN* )
         echo "ulimit not on Windows"
         exit 0
         ;;
--- a/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/custom_provider.sh	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/custom_provider.sh	Wed Jul 05 17:06:00 2017 +0200
@@ -38,7 +38,7 @@
 
 OS=`uname -s`
 case "$OS" in
-    Windows_* )
+    Windows_* | CYGWIN* )
         CLASSPATH="${TESTCLASSES};${TESTSRC}"
         ;;
     * )
--- a/jdk/test/java/nio/file/Files/walk_file_tree.sh	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/test/java/nio/file/Files/walk_file_tree.sh	Wed Jul 05 17:06:00 2017 +0200
@@ -39,7 +39,7 @@
 
 OS=`uname -s`
 case "$OS" in
-    Windows_* )
+    Windows_* | CYGWIN* )
         echo "This test does not run on Windows" 
         exit 0
         ;;
--- a/jdk/test/java/nio/file/Path/CopyAndMove.java	Thu Jan 21 11:12:31 2010 -0800
+++ b/jdk/test/java/nio/file/Path/CopyAndMove.java	Wed Jul 05 17:06:00 2017 +0200
@@ -22,10 +22,10 @@
  */
 
 /* @test
- * @bug 4313887 6838333
+ * @bug 4313887 6838333 6917021
  * @summary Unit test for java.nio.file.Path copyTo/moveTo methods
  * @library ..
- * @build CopyAndMove
+ * @build CopyAndMove PassThroughFileSystem
  * @run main/othervm CopyAndMove
  */
 
@@ -40,22 +40,31 @@
 public class CopyAndMove {
     static final Random rand = new Random();
     static boolean heads() { return rand.nextBoolean(); }
-    static boolean supportsLinks;
 
     public static void main(String[] args) throws Exception {
         Path dir1 = TestUtil.createTemporaryDirectory();
         try {
-            supportsLinks = TestUtil.supportsLinks(dir1);
+            // Same directory
+            doCopyTests(dir1, dir1, TestUtil.supportsLinks(dir1));
+            doMoveTests(dir1, dir1, TestUtil.supportsLinks(dir1));
 
-            // Exercise copyTo
-            doCopyTests(dir1);
+            // Different directories. Use test.dir if possible as it might be
+            // a different volume/file system and so improve test coverage.
+            String testDir = System.getProperty("test.dir", ".");
+            Path dir2 = TestUtil.createTemporaryDirectory(testDir);
+            try {
+                boolean testSymbolicLinks =
+                    TestUtil.supportsLinks(dir1) && TestUtil.supportsLinks(dir2);
+                doCopyTests(dir1, dir2, testSymbolicLinks);
+                doMoveTests(dir1, dir2, testSymbolicLinks);
+            } finally {
+                TestUtil.removeAll(dir2);
+            }
 
-            // Exercise moveTo
-            // if test.dir differs to temporary file system then can test
-            // moving between devices
-            String testDir = System.getProperty("test.dir");
-            Path dir2 = (testDir != null) ? Paths.get(testDir) : dir1;
-            doMoveTests(dir1, dir2);
+            // Target is location associated with custom provider
+            Path dir3 = PassThroughFileSystem.create().getPath(dir1.toString());
+            doCopyTests(dir1, dir3, false);
+            doMoveTests(dir1, dir3, false);
 
         } finally {
             TestUtil.removeAll(dir1);
@@ -186,30 +195,37 @@
         checkBasicAttributes(basicAttributes,
             Attributes.readBasicFileAttributes(target, NOFOLLOW_LINKS));
 
-        // verify POSIX attributes
-        if (posixAttributes != null && !basicAttributes.isSymbolicLink()) {
-            checkPosixAttributes(posixAttributes,
-                Attributes.readPosixFileAttributes(target, NOFOLLOW_LINKS));
-        }
+        // verify other attributes when same provider
+        if (source.getFileSystem().provider() == target.getFileSystem().provider()) {
 
-        // verify DOS attributes
-        if (dosAttributes != null && !basicAttributes.isSymbolicLink()) {
-            checkDosAttributes(dosAttributes,
-                Attributes.readDosFileAttributes(target, NOFOLLOW_LINKS));
-        }
+            // verify POSIX attributes
+            if (posixAttributes != null && !basicAttributes.isSymbolicLink()) {
+                checkPosixAttributes(posixAttributes,
+                    Attributes.readPosixFileAttributes(target, NOFOLLOW_LINKS));
+            }
 
-        // verify named attributes
-        if (namedAttributes != null &&
-            target.getFileStore().supportsFileAttributeView("xattr"))
-        {
-            checkUserDefinedFileAttributes(namedAttributes, readUserDefinedFileAttributes(target));
+            // verify DOS attributes
+            if (dosAttributes != null && !basicAttributes.isSymbolicLink()) {
+                checkDosAttributes(dosAttributes,
+                    Attributes.readDosFileAttributes(target, NOFOLLOW_LINKS));
+            }
+
+            // verify named attributes
+            if (namedAttributes != null &&
+                target.getFileStore().supportsFileAttributeView("xattr"))
+            {
+                checkUserDefinedFileAttributes(namedAttributes,
+                                               readUserDefinedFileAttributes(target));
+            }
         }
     }
 
     /**
      * Tests all possible ways to invoke moveTo
      */
-    static void doMoveTests(Path dir1, Path dir2) throws IOException {
+    static void doMoveTests(Path dir1, Path dir2, boolean supportsLinks)
+        throws IOException
+    {
         Path source, target, entry;
 
         boolean sameDevice = dir1.getFileStore().equals(dir2.getFileStore());
@@ -220,7 +236,7 @@
          * Test: move regular file, target does not exist
          */
         source = createSourceFile(dir1);
-        target = getTargetFile(dir1);
+        target = getTargetFile(dir2);
         moveAndVerify(source, target);
         target.delete();
 
@@ -228,7 +244,7 @@
          * Test: move regular file, target exists
          */
         source = createSourceFile(dir1);
-        target = getTargetFile(dir1).createFile();
+        target = getTargetFile(dir2).createFile();
         try {
             moveAndVerify(source, target);
             throw new RuntimeException("FileAlreadyExistsException expected");
@@ -248,7 +264,7 @@
          * Test: move regular file, target does not exist
          */
         source = createSourceFile(dir1);
-        target = getTargetFile(dir1);
+        target = getTargetFile(dir2);
         moveAndVerify(source, target, REPLACE_EXISTING);
         target.delete();
 
@@ -256,7 +272,7 @@
          * Test: move regular file, target exists
          */
         source = createSourceFile(dir1);
-        target = getTargetFile(dir1).createFile();
+        target = getTargetFile(dir2).createFile();
         moveAndVerify(source, target, REPLACE_EXISTING);
         target.delete();
 
@@ -264,7 +280,7 @@
          * Test: move regular file, target exists and is empty directory
          */
         source = createSourceFile(dir1);
-        target = getTargetFile(dir1).createDirectory();
+        target = getTargetFile(dir2).createDirectory();
         moveAndVerify(source, target, REPLACE_EXISTING);
         target.delete();
 
@@ -272,7 +288,7 @@
          * Test: move regular file, target exists and is non-empty directory
          */
         source = createSourceFile(dir1);
-        target = getTargetFile(dir1).createDirectory();
+        target = getTargetFile(dir2).createDirectory();
         entry = target.resolve("foo").createFile();
         try {
             moveAndVerify(source, target);
@@ -311,7 +327,7 @@
          * Test: move empty directory, target does not exist
          */
         source = createSourceDirectory(dir1);
-        target = getTargetFile(dir1);
+        target = getTargetFile(dir2);
         moveAndVerify(source, target);
         target.delete();
 
@@ -319,7 +335,7 @@
          * Test: move empty directory, target exists
          */
         source = createSourceDirectory(dir1);
-        target = getTargetFile(dir1).createFile();
+        target = getTargetFile(dir2).createFile();
         try {
             moveAndVerify(source, target);
             throw new RuntimeException("FileAlreadyExistsException expected");
@@ -339,7 +355,7 @@
          * Test: move empty directory, target does not exist
          */
         source = createSourceDirectory(dir1);
-        target = getTargetFile(dir1);
+        target = getTargetFile(dir2);
         moveAndVerify(source, target, REPLACE_EXISTING);
         target.delete();
 
@@ -347,7 +363,7 @@
          * Test: move empty directory, target exists
          */
         source = createSourceDirectory(dir1);
-        target = getTargetFile(dir1).createFile();
+        target = getTargetFile(dir2).createFile();
         moveAndVerify(source, target, REPLACE_EXISTING);
         target.delete();
 
@@ -355,7 +371,7 @@
          * Test: move empty, target exists and is empty directory
          */
         source = createSourceDirectory(dir1);
-        target = getTargetFile(dir1).createDirectory();
+        target = getTargetFile(dir2).createDirectory();
         moveAndVerify(source, target, REPLACE_EXISTING);
         target.delete();
 
@@ -363,7 +379,7 @@
          * Test: move empty directory, target exists and is non-empty directory
          */
         source = createSourceDirectory(dir1);
-        target = getTargetFile(dir1).createDirectory();
+        target = getTargetFile(dir2).createDirectory();
         entry = target.resolve("foo").createFile();
         try {
             moveAndVerify(source, target, REPLACE_EXISTING);
@@ -418,7 +434,7 @@
         if (supportsLinks) {
             Path tmp = createSourceFile(dir1);
             source = dir1.resolve("link").createSymbolicLink(tmp);
-            target = getTargetFile(dir1);
+            target = getTargetFile(dir2);
             moveAndVerify(source, target);
             target.delete();
             tmp.delete();
@@ -429,7 +445,7 @@
          */
         if (supportsLinks) {
             source = dir1.resolve("link").createSymbolicLink(dir2);
-            target = getTargetFile(dir1);
+            target = getTargetFile(dir2);
             moveAndVerify(source, target);
             target.delete();
         }
@@ -440,7 +456,7 @@
         if (supportsLinks) {
             Path tmp = Paths.get("doesnotexist");
             source = dir1.resolve("link").createSymbolicLink(tmp);
-            target = getTargetFile(dir1);
+            target = getTargetFile(dir2);
             moveAndVerify(source, target);
             target.delete();
         }
@@ -450,7 +466,7 @@
          */
         if (supportsLinks) {
             source = dir1.resolve("link").createSymbolicLink(dir2);
-            target = getTargetFile(dir1).createFile();
+            target = getTargetFile(dir2).createFile();
             try {
                 moveAndVerify(source, target);
                 throw new RuntimeException("FileAlreadyExistsException expected");
@@ -465,7 +481,7 @@
          */
         if (supportsLinks) {
             source = dir1.resolve("link").createSymbolicLink(dir2);
-            target = getTargetFile(dir1).createFile();
+            target = getTargetFile(dir2).createFile();
             moveAndVerify(source, target, REPLACE_EXISTING);
             target.delete();
         }
@@ -475,7 +491,7 @@
          */
         if (supportsLinks) {
             source = dir1.resolve("link").createSymbolicLink(dir2);
-            target = getTargetFile(dir1).createDirectory();
+            target = getTargetFile(dir2).createDirectory();
             moveAndVerify(source, target, REPLACE_EXISTING);
             target.delete();
         }
@@ -485,7 +501,7 @@
          */
         if (supportsLinks) {
             source = dir1.resolve("link").createSymbolicLink(dir2);
-            target = getTargetFile(dir1).createDirectory();
+            target = getTargetFile(dir2).createDirectory();
             entry = target.resolve("foo").createFile();
             try {
                 moveAndVerify(source, target);
@@ -502,7 +518,7 @@
          */
         if (supportsLinks) {
             source = dir1.resolve("link").createSymbolicLink(dir1);
-            target = getTargetFile(dir1).createFile();
+            target = getTargetFile(dir2).createFile();
             moveAndVerify(source, target, REPLACE_EXISTING);
             target.delete();
         }
@@ -513,7 +529,7 @@
          * Test nulls
          */
         source = createSourceFile(dir1);
-        target = getTargetFile(dir1);
+        target = getTargetFile(dir2);
         try {
             source.moveTo(null);
             throw new RuntimeException("NullPointerException expected");
@@ -533,7 +549,7 @@
          * Test UOE
          */
         source = createSourceFile(dir1);
-        target = getTargetFile(dir1);
+        target = getTargetFile(dir2);
         try {
             source.moveTo(target, new CopyOption() { });
         } catch (UnsupportedOperationException x) { }
@@ -577,28 +593,32 @@
             checkBasicAttributes(basicAttributes,
                 Attributes.readBasicFileAttributes(source, linkOptions));
 
-            // check POSIX attributes are copied
-            String os = System.getProperty("os.name");
-            if (os.equals("SunOS") || os.equals("Linux")) {
-                checkPosixAttributes(
-                    Attributes.readPosixFileAttributes(source, linkOptions),
-                    Attributes.readPosixFileAttributes(target, linkOptions));
-            }
+            // verify other attributes when same provider
+            if (source.getFileSystem().provider() == target.getFileSystem().provider()) {
 
-            // check DOS attributes are copied
-            if (os.startsWith("Windows")) {
-                checkDosAttributes(
-                    Attributes.readDosFileAttributes(source, linkOptions),
-                    Attributes.readDosFileAttributes(target, linkOptions));
-            }
+                // check POSIX attributes are copied
+                String os = System.getProperty("os.name");
+                if (os.equals("SunOS") || os.equals("Linux")) {
+                    checkPosixAttributes(
+                        Attributes.readPosixFileAttributes(source, linkOptions),
+                        Attributes.readPosixFileAttributes(target, linkOptions));
+                }
 
-            // check named attributes are copied
-            if (followLinks &&
-                source.getFileStore().supportsFileAttributeView("xattr") &&
-                target.getFileStore().supportsFileAttributeView("xattr"))
-            {
-                checkUserDefinedFileAttributes(readUserDefinedFileAttributes(source),
-                                     readUserDefinedFileAttributes(target));
+                // check DOS attributes are copied
+                if (os.startsWith("Windows")) {
+                    checkDosAttributes(
+                        Attributes.readDosFileAttributes(source, linkOptions),
+                        Attributes.readDosFileAttributes(target, linkOptions));
+                }
+
+                // check named attributes are copied
+                if (followLinks &&
+                    source.getFileStore().supportsFileAttributeView("xattr") &&
+                    target.getFileStore().supportsFileAttributeView("xattr"))
+                {
+                    checkUserDefinedFileAttributes(readUserDefinedFileAttributes(source),
+                                                   readUserDefinedFileAttributes(target));
+                }
             }
         }
     }
@@ -606,7 +626,9 @@
     /**
      * Tests all possible ways to invoke copyTo
      */
-    static void doCopyTests(Path dir) throws IOException {
+    static void doCopyTests(Path dir1, Path dir2, boolean supportsLinks)
+        throws IOException
+    {
         Path source, target, link, entry;
 
         // -- regular file --
@@ -614,8 +636,8 @@
         /**
          * Test: move regular file, target does not exist
          */
-        source = createSourceFile(dir);
-        target = getTargetFile(dir);
+        source = createSourceFile(dir1);
+        target = getTargetFile(dir2);
         copyAndVerify(source, target);
         source.delete();
         target.delete();
@@ -623,8 +645,8 @@
         /**
          * Test: copy regular file, target exists
          */
-        source = createSourceFile(dir);
-        target = getTargetFile(dir).createFile();
+        source = createSourceFile(dir1);
+        target = getTargetFile(dir2).createFile();
         try {
             copyAndVerify(source, target);
             throw new RuntimeException("FileAlreadyExistsException expected");
@@ -643,8 +665,8 @@
         /**
          * Test: copy regular file, target does not exist
          */
-        source = createSourceFile(dir);
-        target = getTargetFile(dir);
+        source = createSourceFile(dir1);
+        target = getTargetFile(dir2);
         copyAndVerify(source, target, REPLACE_EXISTING);
         source.delete();
         target.delete();
@@ -652,8 +674,8 @@
         /**
          * Test: copy regular file, target exists
          */
-        source = createSourceFile(dir);
-        target = getTargetFile(dir).createFile();
+        source = createSourceFile(dir1);
+        target = getTargetFile(dir2).createFile();
         copyAndVerify(source, target, REPLACE_EXISTING);
         source.delete();
         target.delete();
@@ -661,8 +683,8 @@
         /**
          * Test: copy regular file, target exists and is empty directory
          */
-        source = createSourceFile(dir);
-        target = getTargetFile(dir).createDirectory();
+        source = createSourceFile(dir1);
+        target = getTargetFile(dir2).createDirectory();
         copyAndVerify(source, target, REPLACE_EXISTING);
         source.delete();
         target.delete();
@@ -670,8 +692,8 @@
         /**
          * Test: copy regular file, target exists and is non-empty directory
          */
-        source = createSourceFile(dir);
-        target = getTargetFile(dir).createDirectory();
+        source = createSourceFile(dir1);
+        target = getTargetFile(dir2).createDirectory();
         entry = target.resolve("foo").createFile();
         try {
             copyAndVerify(source, target);
@@ -685,8 +707,8 @@
         /**
          * Test: copy regular file + attributes
          */
-        source = createSourceFile(dir);
-        target = getTargetFile(dir);
+        source = createSourceFile(dir1);
+        target = getTargetFile(dir2);
         copyAndVerify(source, target, COPY_ATTRIBUTES);
         source.delete();
         target.delete();
@@ -697,8 +719,8 @@
         /*
          * Test: copy directory, target does not exist
          */
-        source = createSourceDirectory(dir);
-        target = getTargetFile(dir);
+        source = createSourceDirectory(dir1);
+        target = getTargetFile(dir2);
         copyAndVerify(source, target);
         source.delete();
         target.delete();
@@ -706,8 +728,8 @@
         /**
          * Test: copy directory, target exists
          */
-        source = createSourceDirectory(dir);
-        target = getTargetFile(dir).createFile();
+        source = createSourceDirectory(dir1);
+        target = getTargetFile(dir2).createFile();
         try {
             copyAndVerify(source, target);
             throw new RuntimeException("FileAlreadyExistsException expected");
@@ -726,8 +748,8 @@
         /**
          * Test: copy directory, target does not exist
          */
-        source = createSourceDirectory(dir);
-        target = getTargetFile(dir);
+        source = createSourceDirectory(dir1);
+        target = getTargetFile(dir2);
         copyAndVerify(source, target, REPLACE_EXISTING);
         source.delete();
         target.delete();
@@ -735,8 +757,8 @@
         /**
          * Test: copy directory, target exists
          */
-        source = createSourceDirectory(dir);
-        target = getTargetFile(dir).createFile();
+        source = createSourceDirectory(dir1);
+        target = getTargetFile(dir2).createFile();
         copyAndVerify(source, target, REPLACE_EXISTING);
         source.delete();
         target.delete();
@@ -744,8 +766,8 @@
         /**
          * Test: copy directory, target exists and is empty directory
          */
-        source = createSourceDirectory(dir);
-        target = getTargetFile(dir).createDirectory();
+        source = createSourceDirectory(dir1);
+        target = getTargetFile(dir2).createDirectory();
         copyAndVerify(source, target, REPLACE_EXISTING);
         source.delete();
         target.delete();
@@ -753,8 +775,8 @@
         /**
          * Test: copy directory, target exists and is non-empty directory
          */
-        source = createSourceDirectory(dir);
-        target = getTargetFile(dir).createDirectory();
+        source = createSourceDirectory(dir1);
+        target = getTargetFile(dir2).createDirectory();
         entry = target.resolve("foo").createFile();
         try {
             copyAndVerify(source, target, REPLACE_EXISTING);
@@ -768,8 +790,8 @@
         /*
          * Test: copy directory + attributes
          */
-        source = createSourceDirectory(dir);
-        target = getTargetFile(dir);
+        source = createSourceDirectory(dir1);
+        target = getTargetFile(dir2);
         copyAndVerify(source, target, COPY_ATTRIBUTES);
         source.delete();
         target.delete();
@@ -780,9 +802,9 @@
          * Test: Follow link
          */
         if (supportsLinks) {
-            source = createSourceFile(dir);
-            link = dir.resolve("link").createSymbolicLink(source);
-            target = getTargetFile(dir);
+            source = createSourceFile(dir1);
+            link = dir1.resolve("link").createSymbolicLink(source);
+            target = getTargetFile(dir2);
             copyAndVerify(link, target);
             link.delete();
             source.delete();
@@ -792,9 +814,9 @@
          * Test: Copy link (to file)
          */
         if (supportsLinks) {
-            source = createSourceFile(dir);
-            link = dir.resolve("link").createSymbolicLink(source);
-            target = getTargetFile(dir);
+            source = createSourceFile(dir1);
+            link = dir1.resolve("link").createSymbolicLink(source);
+            target = getTargetFile(dir2);
             copyAndVerify(link, target, NOFOLLOW_LINKS);
             link.delete();
             source.delete();
@@ -804,9 +826,9 @@
          * Test: Copy link (to directory)
          */
         if (supportsLinks) {
-            source = dir.resolve("mydir").createDirectory();
-            link = dir.resolve("link").createSymbolicLink(source);
-            target = getTargetFile(dir);
+            source = dir1.resolve("mydir").createDirectory();
+            link = dir1.resolve("link").createSymbolicLink(source);
+            target = getTargetFile(dir2);
             copyAndVerify(link, target, NOFOLLOW_LINKS);
             link.delete();
             source.delete();
@@ -817,8 +839,8 @@
          */
         if (supportsLinks) {
             assertTrue(source.notExists());
-            link = dir.resolve("link").createSymbolicLink(source);
-            target = getTargetFile(dir);
+            link = dir1.resolve("link").createSymbolicLink(source);
+            target = getTargetFile(dir2);
             copyAndVerify(link, target, NOFOLLOW_LINKS);
             link.delete();
         }
@@ -830,8 +852,8 @@
             System.getProperty("os.name").startsWith("Windows"))
         {
             Path unc = Paths.get("\\\\rialto\\share\\file");
-            link = dir.resolve("link").createSymbolicLink(unc);
-            target = getTargetFile(dir);
+            link = dir1.resolve("link").createSymbolicLink(unc);
+            target = getTargetFile(dir2);
             copyAndVerify(link, target, NOFOLLOW_LINKS);
             link.delete();
         }
@@ -841,8 +863,8 @@
         /**
          * Test nulls
          */
-        source = createSourceFile(dir);
-        target = getTargetFile(dir);
+        source = createSourceFile(dir1);
+        target = getTargetFile(dir2);
         try {
             source.copyTo(null);
             throw new RuntimeException("NullPointerException expected");
@@ -861,8 +883,8 @@
         /**
          * Test UOE
          */
-        source = createSourceFile(dir);
-        target = getTargetFile(dir);
+        source = createSourceFile(dir1);
+        target = getTargetFile(dir2);
         try {
             source.copyTo(target, new CopyOption() { });
         } catch (UnsupportedOperationException x) { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/nio/file/Path/PassThroughFileSystem.java	Wed Jul 05 17:06:00 2017 +0200
@@ -0,0 +1,554 @@
+/*
+ * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+import java.nio.file.*;
+import java.nio.file.attribute.*;
+import java.nio.file.spi.FileSystemProvider;
+import java.nio.channels.SeekableByteChannel;
+import java.net.URI;
+import java.util.*;
+import java.io.*;
+
+/**
+ * A "pass through" file system implementation that passes through, or delegates,
+ * everything to the default file system.
+ */
+
+class PassThroughFileSystem extends FileSystem {
+    private final FileSystemProvider provider;
+    private final FileSystem delegate;
+
+    PassThroughFileSystem(FileSystemProvider provider, FileSystem delegate) {
+        this.provider = provider;
+        this.delegate = delegate;
+    }
+
+    /**
+     * Creates a new "pass through" file system. Useful for test environments
+     * where the provider might not be deployed.
+     */
+    static FileSystem create() throws IOException {
+        FileSystemProvider provider = new PassThroughProvider();
+        Map<String,?> env = Collections.emptyMap();
+        URI uri = URI.create("pass:///");
+        return provider.newFileSystem(uri, env);
+    }
+
+    @Override
+    public FileSystemProvider provider() {
+        return provider;
+    }
+
+    @Override
+    public void close() throws IOException {
+        delegate.close();
+    }
+
+    @Override
+    public boolean isOpen() {
+        return delegate.isOpen();
+    }
+
+    @Override
+    public boolean isReadOnly() {
+        return delegate.isReadOnly();
+    }
+
+    @Override
+    public String getSeparator() {
+        return delegate.getSeparator();
+    }
+
+    @Override
+    public Iterable<Path> getRootDirectories() {
+        final Iterable<Path> roots = delegate.getRootDirectories();
+        return new Iterable<Path>() {
+            @Override
+            public Iterator<Path> iterator() {
+                final Iterator<Path> itr = roots.iterator();
+                return new Iterator<Path>() {
+                    @Override
+                    public boolean hasNext() {
+                        return itr.hasNext();
+                    }
+                    @Override
+                    public Path next() {
+                        return new PassThroughPath(delegate, itr.next());
+                    }
+                    @Override
+                    public void remove() {
+                        itr.remove();
+                    }
+                };
+            }
+        };
+    }
+
+    @Override
+    public Iterable<FileStore> getFileStores() {
+        // assume that unwrapped objects aren't exposed
+        return delegate.getFileStores();
+    }
+
+    @Override
+    public Set<String> supportedFileAttributeViews() {
+        // assume that unwrapped objects aren't exposed
+        return delegate.supportedFileAttributeViews();
+    }
+
+    @Override
+    public Path getPath(String path) {
+        return new PassThroughPath(this, delegate.getPath(path));
+    }
+
+    @Override
+    public PathMatcher getPathMatcher(String syntaxAndPattern) {
+        final PathMatcher matcher = delegate.getPathMatcher(syntaxAndPattern);
+        return new PathMatcher() {
+            @Override
+            public boolean matches(Path path) {
+                return matcher.matches(PassThroughPath.unwrap(path));
+            }
+        };
+    }
+
+    @Override
+    public UserPrincipalLookupService getUserPrincipalLookupService() {
+        // assume that unwrapped objects aren't exposed
+        return delegate.getUserPrincipalLookupService();
+    }
+
+    @Override
+    public WatchService newWatchService() throws IOException {
+        // to keep it simple
+        throw new UnsupportedOperationException();
+    }
+
+    static class PassThroughProvider extends FileSystemProvider {
+        private static final String SCHEME = "pass";
+        private static volatile PassThroughFileSystem delegate;
+
+        public PassThroughProvider() { }
+
+        @Override
+        public String getScheme() {
+            return SCHEME;
+        }
+
+        private void checkScheme(URI uri) {
+            if (!uri.getScheme().equalsIgnoreCase(SCHEME))
+                throw new IllegalArgumentException();
+        }
+
+        private void checkUri(URI uri) {
+            checkScheme(uri);
+            if (!uri.getSchemeSpecificPart().equals("///"))
+                throw new IllegalArgumentException();
+        }
+
+        @Override
+        public FileSystem newFileSystem(URI uri, Map<String,?> env)
+            throws IOException
+        {
+            checkUri(uri);
+            synchronized (PassThroughProvider.class) {
+                if (delegate != null)
+                    throw new FileSystemAlreadyExistsException();
+                PassThroughFileSystem result =
+                    new PassThroughFileSystem(this, FileSystems.getDefault());
+                delegate = result;
+                return result;
+            }
+        }
+
+        @Override
+        public FileSystem getFileSystem(URI uri) {
+            checkUri(uri);
+            FileSystem result = delegate;
+            if (result == null)
+                throw new FileSystemNotFoundException();
+            return result;
+        }
+
+        @Override
+        public Path getPath(URI uri) {
+            checkScheme(uri);
+            if (delegate == null)
+                throw new FileSystemNotFoundException();
+            uri = URI.create(delegate.provider().getScheme() + ":" +
+                             uri.getSchemeSpecificPart());
+            return new PassThroughPath(delegate, delegate.provider().getPath(uri));
+        }
+    }
+
+    static class PassThroughPath extends Path {
+        private final FileSystem fs;
+        private final Path delegate;
+
+        PassThroughPath(FileSystem fs, Path delegate) {
+            this.fs = fs;
+            this.delegate = delegate;
+        }
+
+        private Path wrap(Path path) {
+            return (path != null) ? new PassThroughPath(fs, path) : null;
+        }
+
+        static Path unwrap(Path wrapper) {
+            if (!(wrapper instanceof PassThroughPath))
+                throw new ProviderMismatchException();
+            return ((PassThroughPath)wrapper).delegate;
+        }
+
+        @Override
+        public FileSystem getFileSystem() {
+            return fs;
+        }
+
+        @Override
+        public boolean isAbsolute() {
+            return delegate.isAbsolute();
+        }
+
+        @Override
+        public Path getRoot() {
+            return wrap(delegate.getRoot());
+        }
+
+
+        @Override
+        public Path getName() {
+            return wrap(delegate.getName());
+        }
+
+        @Override
+        public Path getParent() {
+            return wrap(delegate.getParent());
+        }
+
+        @Override
+        public int getNameCount() {
+            return delegate.getNameCount();
+        }
+
+        @Override
+        public Path getName(int index) {
+            return wrap(delegate.getName(index));
+        }
+
+        @Override
+        public Path subpath(int beginIndex, int endIndex) {
+            return wrap(delegate.subpath(beginIndex, endIndex));
+        }
+
+        @Override
+        public boolean startsWith(Path other) {
+            return delegate.startsWith(unwrap(other));
+        }
+
+        @Override
+        public boolean endsWith(Path other) {
+            return delegate.endsWith(unwrap(other));
+        }
+
+        @Override
+        public Path normalize() {
+