Merge
authorprr
Mon, 28 Mar 2016 08:41:54 -0700
changeset 36786 8f9057195e73
parent 36785 458d52e5d1d5 (current diff)
parent 36720 7359994942f8 (diff)
child 36787 402e5e40f6e5
Merge
hotspot/test/compiler/compilercontrol/jcmd/StressAddSequentiallyTest.java
jdk/make/src/native/genconstants/ch/genSocketOptionRegistry.c
jdk/make/src/native/genconstants/fs/genSolarisConstants.c
jdk/make/src/native/genconstants/fs/genUnixConstants.c
jdk/src/java.base/share/classes/sun/misc/Resource.java
jdk/src/java.base/share/classes/sun/misc/URLClassPath.java
jdk/src/java.base/unix/classes/sun/misc/FileURLMapper.java
jdk/src/java.base/windows/classes/sun/misc/FileURLMapper.java
jdk/src/jdk.deploy.osx/macosx/classes/module-info.java
nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/messages.properties
--- a/.hgtags	Thu Mar 24 02:04:14 2016 +0300
+++ b/.hgtags	Mon Mar 28 08:41:54 2016 -0700
@@ -353,3 +353,4 @@
 257b579d813201682931d6b42f0445ffe5b4210d jdk-9+108
 c870cb782aca71093d2584376f27f0cfbfec0e3a jdk-9+109
 4a95f4b1bd8bfce85dc02a593896749feab96c34 jdk-9+110
+a6614ff7bf09da74be1d0ef3d9755090d244697a jdk-9+111
--- a/.hgtags-top-repo	Thu Mar 24 02:04:14 2016 +0300
+++ b/.hgtags-top-repo	Mon Mar 28 08:41:54 2016 -0700
@@ -353,3 +353,4 @@
 c7be2a78c31b3b6132f2f5e9e4b3d3bb1c20245c jdk-9+108
 1787bdaabb2b6f4193406e25a50cb0419ea8e8f3 jdk-9+109
 925be13b3740d07a5958ccb5ab3c0ae1baba7055 jdk-9+110
+f900d5afd9c83a0df8f36161c27c5e4c86a66f4c jdk-9+111
--- a/common/autoconf/generated-configure.sh	Thu Mar 24 02:04:14 2016 +0300
+++ b/common/autoconf/generated-configure.sh	Mon Mar 28 08:41:54 2016 -0700
@@ -4950,7 +4950,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1458558778
+DATE_WHEN_GENERATED=1458755892
 
 ###############################################################################
 #
@@ -61707,10 +61707,10 @@
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for which zlib to use" >&5
 $as_echo_n "checking for which zlib to use... " >&6; }
 
-  DEFAULT_ZLIB=bundled
-  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
-    # On macosx default is system...on others default is bundled
-    DEFAULT_ZLIB=system
+  DEFAULT_ZLIB=system
+  if test "x$OPENJDK_TARGET_OS" = xwindows; then
+    # On windows default is bundled...on others default is system
+    DEFAULT_ZLIB=bundled
   fi
 
   if test "x${ZLIB_FOUND}" != "xyes"; then
--- a/common/autoconf/lib-bundled.m4	Thu Mar 24 02:04:14 2016 +0300
+++ b/common/autoconf/lib-bundled.m4	Mon Mar 28 08:41:54 2016 -0700
@@ -157,10 +157,10 @@
 
   AC_MSG_CHECKING([for which zlib to use])
 
-  DEFAULT_ZLIB=bundled
-  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
-    # On macosx default is system...on others default is bundled
-    DEFAULT_ZLIB=system
+  DEFAULT_ZLIB=system
+  if test "x$OPENJDK_TARGET_OS" = xwindows; then
+    # On windows default is bundled...on others default is system
+    DEFAULT_ZLIB=bundled
   fi
 
   if test "x${ZLIB_FOUND}" != "xyes"; then
--- a/common/conf/jib-profiles.js	Thu Mar 24 02:04:14 2016 +0300
+++ b/common/conf/jib-profiles.js	Mon Mar 28 08:41:54 2016 -0700
@@ -242,6 +242,7 @@
             target_cpu: "x64",
             dependencies: concat(common.dependencies, "devkit"),
             configure_args: common.configure_args,
+	    configure_args: concat(common.configure_args, "--with-zlib=system"),
             make_args: common.make_args
         },
 
@@ -251,6 +252,7 @@
             build_cpu: "x64",
             dependencies: concat(common.dependencies, "devkit"),
             configure_args: concat(common.configure_args, common.configure_args_32bit),
+	    configure_args: concat(common.configure_args, "--with-zlib=system"),
             make_args: common.make_args
         },
 
@@ -259,6 +261,7 @@
             target_cpu: "x64",
             dependencies: concat(common.dependencies, "devkit"),
             configure_args: common.configure_args,
+	    configure_args: concat(common.configure_args, "--with-zlib=system"),
             make_args: common.make_args
         },
 
@@ -267,6 +270,7 @@
             target_cpu: "x64",
             dependencies: concat(common.dependencies, "devkit", "cups"),
             configure_args: common.configure_args,
+	    configure_args: concat(common.configure_args, "--with-zlib=system"),
             make_args: common.make_args
         },
 
@@ -275,6 +279,7 @@
             target_cpu: "sparcv9",
             dependencies: concat(common.dependencies, "devkit", "cups"),
             configure_args: common.configure_args,
+	    configure_args: concat(common.configure_args, "--with-zlib=system"),
             make_args: common.make_args
         },
 
--- a/corba/.hgtags	Thu Mar 24 02:04:14 2016 +0300
+++ b/corba/.hgtags	Mon Mar 28 08:41:54 2016 -0700
@@ -353,3 +353,4 @@
 84f2862a25eb3232ff36c376b4e2bf2a83dfced3 jdk-9+108
 b75afa17aefe480c23c616a6a2497063312f7189 jdk-9+109
 9666775734fb6028ee86df9972626b3667b6a318 jdk-9+110
+2bb92dd44275679edb29fdbffc3b7cbebc9a6bf0 jdk-9+111
--- a/hotspot/.hgtags	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/.hgtags	Mon Mar 28 08:41:54 2016 -0700
@@ -513,3 +513,4 @@
 934f6793f5f7dca44f69b4559d525fa64b31840d jdk-9+108
 7e7e50ac4faf19899fc811569e32cfa478759ebb jdk-9+109
 2f5d1578b24060ea06bd1f340a124db95d1475b2 jdk-9+110
+c558850fac5750d8ca98a45180121980f57cdd28 jdk-9+111
--- a/hotspot/make/lib/Lib-jdk.hotspot.agent.gmk	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/make/lib/Lib-jdk.hotspot.agent.gmk	Mon Mar 28 08:41:54 2016 -0700
@@ -91,7 +91,7 @@
   ifeq ($(OPENJDK_TARGET_CPU), x86_64)
     SA_CXXFLAGS += -DWIN64
   else
-    SA_CXXFLAGS += -RTC1 -ZI
+    SA_CXXFLAGS += -RTC1
     SA_LDFLAGS += -SAFESEH
   endif
 endif
--- a/hotspot/src/cpu/aarch64/vm/aarch64.ad	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/aarch64/vm/aarch64.ad	Mon Mar 28 08:41:54 2016 -0700
@@ -3425,9 +3425,6 @@
 // false => size gets scaled to BytesPerLong, ok.
 const bool Matcher::init_array_count_is_in_bytes = false;
 
-// Threshold size for cleararray.
-const int Matcher::init_array_short_size = 18 * BytesPerLong;
-
 // Use conditional move (CMOVL)
 const int Matcher::long_cmove_cost() {
   // long cmoves are no more expensive than int cmoves
@@ -4135,14 +4132,14 @@
     MacroAssembler _masm(&cbuf);
     guarantee($mem$$index == -1 && $mem$$disp == 0, "impossible encoding");
     __ cmpxchg($mem$$base$$Register, $oldval$$Register, $newval$$Register,
-               &Assembler::ldxr, &MacroAssembler::cmp, &Assembler::stlxr);
+               Assembler::xword, /*acquire*/ false, /*release*/ true);
   %}
 
   enc_class aarch64_enc_cmpxchgw(memory mem, iRegINoSp oldval, iRegINoSp newval) %{
     MacroAssembler _masm(&cbuf);
     guarantee($mem$$index == -1 && $mem$$disp == 0, "impossible encoding");
     __ cmpxchg($mem$$base$$Register, $oldval$$Register, $newval$$Register,
-               &Assembler::ldxrw, &MacroAssembler::cmpw, &Assembler::stlxrw);
+               Assembler::word, /*acquire*/ false, /*release*/ true);
   %}
 
 
@@ -4154,14 +4151,14 @@
     MacroAssembler _masm(&cbuf);
     guarantee($mem$$index == -1 && $mem$$disp == 0, "impossible encoding");
     __ cmpxchg($mem$$base$$Register, $oldval$$Register, $newval$$Register,
-               &Assembler::ldaxr, &MacroAssembler::cmp, &Assembler::stlxr);
+               Assembler::xword, /*acquire*/ true, /*release*/ true);
   %}
 
   enc_class aarch64_enc_cmpxchgw_acq(memory mem, iRegINoSp oldval, iRegINoSp newval) %{
     MacroAssembler _masm(&cbuf);
     guarantee($mem$$index == -1 && $mem$$disp == 0, "impossible encoding");
     __ cmpxchg($mem$$base$$Register, $oldval$$Register, $newval$$Register,
-               &Assembler::ldaxrw, &MacroAssembler::cmpw, &Assembler::stlxrw);
+               Assembler::word, /*acquire*/ true, /*release*/ true);
   %}
 
 
@@ -4679,8 +4676,14 @@
 
     // Compare object markOop with mark and if equal exchange scratch1
     // with object markOop.
-    {
+    if (UseLSE) {
+      __ mov(tmp, disp_hdr);
+      __ casal(Assembler::xword, tmp, box, oop);
+      __ cmp(tmp, disp_hdr);
+      __ br(Assembler::EQ, cont);
+    } else {
       Label retry_load;
+      __ prfm(Address(oop), PSTL1STRM);
       __ bind(retry_load);
       __ ldaxr(tmp, oop);
       __ cmp(tmp, disp_hdr);
@@ -4729,8 +4732,13 @@
       __ add(tmp, disp_hdr, (ObjectMonitor::owner_offset_in_bytes()-markOopDesc::monitor_value));
       __ mov(disp_hdr, zr);
 
-      {
+      if (UseLSE) {
+        __ mov(rscratch1, disp_hdr);
+        __ casal(Assembler::xword, rscratch1, rthread, tmp);
+        __ cmp(rscratch1, disp_hdr);
+      } else {
         Label retry_load, fail;
+        __ prfm(Address(tmp), PSTL1STRM);
         __ bind(retry_load);
         __ ldaxr(rscratch1, tmp);
         __ cmp(disp_hdr, rscratch1);
@@ -4818,8 +4826,13 @@
     // see the stack address of the basicLock in the markOop of the
     // object.
 
-      {
+      if (UseLSE) {
+        __ mov(tmp, box);
+        __ casl(Assembler::xword, tmp, disp_hdr, oop);
+        __ cmp(tmp, box);
+      } else {
         Label retry_load;
+        __ prfm(Address(oop), PSTL1STRM);
         __ bind(retry_load);
         __ ldxr(tmp, oop);
         __ cmp(box, tmp);
--- a/hotspot/src/cpu/aarch64/vm/assembler_aarch64.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/aarch64/vm/assembler_aarch64.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -972,7 +972,7 @@
 
   // System
   void system(int op0, int op1, int CRn, int CRm, int op2,
-              Register rt = (Register)0b11111)
+              Register rt = dummy_reg)
   {
     starti;
     f(0b11010101000, 31, 21);
@@ -1082,7 +1082,7 @@
 
 #define INSN(NAME, opc)                         \
   void NAME() {                 \
-    branch_reg((Register)0b11111, opc);         \
+    branch_reg(dummy_reg, opc);         \
   }
 
   INSN(eret, 0b0100);
@@ -1094,10 +1094,22 @@
   enum operand_size { byte, halfword, word, xword };
 
   void load_store_exclusive(Register Rs, Register Rt1, Register Rt2,
-    Register Rn, enum operand_size sz, int op, int o0) {
+    Register Rn, enum operand_size sz, int op, bool ordered) {
     starti;
     f(sz, 31, 30), f(0b001000, 29, 24), f(op, 23, 21);
-    rf(Rs, 16), f(o0, 15), rf(Rt2, 10), rf(Rn, 5), rf(Rt1, 0);
+    rf(Rs, 16), f(ordered, 15), rf(Rt2, 10), rf(Rn, 5), rf(Rt1, 0);
+  }
+
+  void load_exclusive(Register dst, Register addr,
+                      enum operand_size sz, bool ordered) {
+    load_store_exclusive(dummy_reg, dst, dummy_reg, addr,
+                         sz, 0b010, ordered);
+  }
+
+  void store_exclusive(Register status, Register new_val, Register addr,
+                       enum operand_size sz, bool ordered) {
+    load_store_exclusive(status, new_val, dummy_reg, addr,
+                         sz, 0b000, ordered);
   }
 
 #define INSN4(NAME, sz, op, o0) /* Four registers */                    \
@@ -1109,19 +1121,19 @@
 #define INSN3(NAME, sz, op, o0) /* Three registers */                   \
   void NAME(Register Rs, Register Rt, Register Rn) {                    \
     guarantee(Rs != Rn && Rs != Rt, "unpredictable instruction");       \
-    load_store_exclusive(Rs, Rt, (Register)0b11111, Rn, sz, op, o0);    \
+    load_store_exclusive(Rs, Rt, dummy_reg, Rn, sz, op, o0); \
   }
 
 #define INSN2(NAME, sz, op, o0) /* Two registers */                     \
   void NAME(Register Rt, Register Rn) {                                 \
-    load_store_exclusive((Register)0b11111, Rt, (Register)0b11111,      \
+    load_store_exclusive(dummy_reg, Rt, dummy_reg, \
                          Rn, sz, op, o0);                               \
   }
 
 #define INSN_FOO(NAME, sz, op, o0) /* Three registers, encoded differently */ \
   void NAME(Register Rt1, Register Rt2, Register Rn) {                  \
     guarantee(Rt1 != Rt2, "unpredictable instruction");                 \
-    load_store_exclusive((Register)0b11111, Rt1, Rt2, Rn, sz, op, o0);  \
+    load_store_exclusive(dummy_reg, Rt1, Rt2, Rn, sz, op, o0);          \
   }
 
   // bytes
@@ -1169,6 +1181,46 @@
 #undef INSN4
 #undef INSN_FOO
 
+  // 8.1 Compare and swap extensions
+  void lse_cas(Register Rs, Register Rt, Register Rn,
+                        enum operand_size sz, bool a, bool r, bool not_pair) {
+    starti;
+    if (! not_pair) { // Pair
+      assert(sz == word || sz == xword, "invalid size");
+      /* The size bit is in bit 30, not 31 */
+      sz = (operand_size)(sz == word ? 0b00:0b01);
+    }
+    f(sz, 31, 30), f(0b001000, 29, 24), f(1, 23), f(a, 22), f(1, 21);
+    rf(Rs, 16), f(r, 15), f(0b11111, 14, 10), rf(Rn, 5), rf(Rt, 0);
+  }
+
+  // CAS
+#define INSN(NAME, a, r)                                                \
+  void NAME(operand_size sz, Register Rs, Register Rt, Register Rn) {   \
+    assert(Rs != Rn && Rs != Rt, "unpredictable instruction");          \
+    lse_cas(Rs, Rt, Rn, sz, a, r, true);                                \
+  }
+  INSN(cas,    false, false)
+  INSN(casa,   true,  false)
+  INSN(casl,   false, true)
+  INSN(casal,  true,  true)
+#undef INSN
+
+  // CASP
+#define INSN(NAME, a, r)                                                \
+  void NAME(operand_size sz, Register Rs, Register Rs1,                 \
+            Register Rt, Register Rt1, Register Rn) {                   \
+    assert((Rs->encoding() & 1) == 0 && (Rt->encoding() & 1) == 0 &&    \
+           Rs->successor() == Rs1 && Rt->successor() == Rt1 &&          \
+           Rs != Rn && Rs1 != Rn && Rs != Rt, "invalid registers");     \
+    lse_cas(Rs, Rt, Rn, sz, a, r, false);                               \
+  }
+  INSN(casp,    false, false)
+  INSN(caspa,   true,  false)
+  INSN(caspl,   false, true)
+  INSN(caspal,  true,  true)
+#undef INSN
+
   // Load register (literal)
 #define INSN(NAME, opc, V)                                              \
   void NAME(Register Rt, address dest) {                                \
--- a/hotspot/src/cpu/aarch64/vm/c1_LIRAssembler_aarch64.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/aarch64/vm/c1_LIRAssembler_aarch64.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -1556,38 +1556,54 @@
 }
 
 void LIR_Assembler::casw(Register addr, Register newval, Register cmpval) {
-  Label retry_load, nope;
-  // flush and load exclusive from the memory location
-  // and fail if it is not what we expect
-  __ bind(retry_load);
-  __ ldaxrw(rscratch1, addr);
-  __ cmpw(rscratch1, cmpval);
-  __ cset(rscratch1, Assembler::NE);
-  __ br(Assembler::NE, nope);
-  // if we store+flush with no intervening write rscratch1 wil be zero
-  __ stlxrw(rscratch1, newval, addr);
-  // retry so we only ever return after a load fails to compare
-  // ensures we don't return a stale value after a failed write.
-  __ cbnzw(rscratch1, retry_load);
-  __ bind(nope);
+  if (UseLSE) {
+    __ mov(rscratch1, cmpval);
+    __ casal(Assembler::word, rscratch1, newval, addr);
+    __ cmpw(rscratch1, cmpval);
+    __ cset(rscratch1, Assembler::NE);
+  } else {
+    Label retry_load, nope;
+    // flush and load exclusive from the memory location
+    // and fail if it is not what we expect
+    __ prfm(Address(addr), PSTL1STRM);
+    __ bind(retry_load);
+    __ ldaxrw(rscratch1, addr);
+    __ cmpw(rscratch1, cmpval);
+    __ cset(rscratch1, Assembler::NE);
+    __ br(Assembler::NE, nope);
+    // if we store+flush with no intervening write rscratch1 wil be zero
+    __ stlxrw(rscratch1, newval, addr);
+    // retry so we only ever return after a load fails to compare
+    // ensures we don't return a stale value after a failed write.
+    __ cbnzw(rscratch1, retry_load);
+    __ bind(nope);
+  }
   __ membar(__ AnyAny);
 }
 
 void LIR_Assembler::casl(Register addr, Register newval, Register cmpval) {
-  Label retry_load, nope;
-  // flush and load exclusive from the memory location
-  // and fail if it is not what we expect
-  __ bind(retry_load);
-  __ ldaxr(rscratch1, addr);
-  __ cmp(rscratch1, cmpval);
-  __ cset(rscratch1, Assembler::NE);
-  __ br(Assembler::NE, nope);
-  // if we store+flush with no intervening write rscratch1 wil be zero
-  __ stlxr(rscratch1, newval, addr);
-  // retry so we only ever return after a load fails to compare
-  // ensures we don't return a stale value after a failed write.
-  __ cbnz(rscratch1, retry_load);
-  __ bind(nope);
+  if (UseLSE) {
+    __ mov(rscratch1, cmpval);
+    __ casal(Assembler::xword, rscratch1, newval, addr);
+    __ cmp(rscratch1, cmpval);
+    __ cset(rscratch1, Assembler::NE);
+  } else {
+    Label retry_load, nope;
+    // flush and load exclusive from the memory location
+    // and fail if it is not what we expect
+    __ prfm(Address(addr), PSTL1STRM);
+    __ bind(retry_load);
+    __ ldaxr(rscratch1, addr);
+    __ cmp(rscratch1, cmpval);
+    __ cset(rscratch1, Assembler::NE);
+    __ br(Assembler::NE, nope);
+    // if we store+flush with no intervening write rscratch1 wil be zero
+    __ stlxr(rscratch1, newval, addr);
+    // retry so we only ever return after a load fails to compare
+    // ensures we don't return a stale value after a failed write.
+    __ cbnz(rscratch1, retry_load);
+    __ bind(nope);
+  }
   __ membar(__ AnyAny);
 }
 
@@ -3156,6 +3172,7 @@
       }
       Label again;
       __ lea(tmp, addr);
+      __ prfm(Address(tmp), PSTL1STRM);
       __ bind(again);
       (_masm->*lda)(dst, tmp);
       (_masm->*add)(rscratch1, dst, inc);
@@ -3175,6 +3192,7 @@
       assert_different_registers(obj, addr.base(), tmp, rscratch2, dst);
       Label again;
       __ lea(tmp, addr);
+      __ prfm(Address(tmp), PSTL1STRM);
       __ bind(again);
       (_masm->*lda)(dst, tmp);
       (_masm->*stl)(rscratch2, obj, tmp);
--- a/hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -76,6 +76,8 @@
 // avoid biased locking while we are bootstrapping the aarch64 build
 define_pd_global(bool, UseBiasedLocking, false);
 
+define_pd_global(intx, InitArrayShortSize, 18*BytesPerLong);
+
 #if defined(COMPILER1) || defined(COMPILER2)
 define_pd_global(intx, InlineSmallCode,          1000);
 #endif
@@ -101,9 +103,13 @@
                                                                         \
   product(bool, UseCRC32, false,                                        \
           "Use CRC32 instructions for CRC32 computation")               \
+                                                                        \
+  product(bool, UseLSE, false,                                          \
+          "Use LSE instructions")                                       \
 
 // Don't attempt to use Neon on builtin sim until builtin sim supports it
 #define UseCRC32 false
+#define UseSIMDForMemoryOps    false
 
 #else
 #define UseBuiltinSim           false
@@ -121,6 +127,10 @@
           "Use Neon for CRC32 computation")                             \
   product(bool, UseCRC32, false,                                        \
           "Use CRC32 instructions for CRC32 computation")               \
+  product(bool, UseSIMDForMemoryOps, false,                             \
+          "Use SIMD instructions in generated memory move code")        \
+  product(bool, UseLSE, false,                                          \
+          "Use LSE instructions")                                       \
   product(bool, TraceTraps, false, "Trace all traps the signal handler")
 
 #endif
--- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -1638,6 +1638,7 @@
 
 void MacroAssembler::atomic_incw(Register counter_addr, Register tmp, Register tmp2) {
   Label retry_load;
+  prfm(Address(counter_addr), PSTL1STRM);
   bind(retry_load);
   // flush and load exclusive from the memory location
   ldxrw(tmp, counter_addr);
@@ -2070,25 +2071,32 @@
   // oldv holds comparison value
   // newv holds value to write in exchange
   // addr identifies memory word to compare against/update
-  // tmp returns 0/1 for success/failure
-  Label retry_load, nope;
-
-  bind(retry_load);
-  // flush and load exclusive from the memory location
-  // and fail if it is not what we expect
-  ldaxr(tmp, addr);
-  cmp(tmp, oldv);
-  br(Assembler::NE, nope);
-  // if we store+flush with no intervening write tmp wil be zero
-  stlxr(tmp, newv, addr);
-  cbzw(tmp, succeed);
-  // retry so we only ever return after a load fails to compare
-  // ensures we don't return a stale value after a failed write.
-  b(retry_load);
-  // if the memory word differs we return it in oldv and signal a fail
-  bind(nope);
-  membar(AnyAny);
-  mov(oldv, tmp);
+  if (UseLSE) {
+    mov(tmp, oldv);
+    casal(Assembler::xword, oldv, newv, addr);
+    cmp(tmp, oldv);
+    br(Assembler::EQ, succeed);
+    membar(AnyAny);
+  } else {
+    Label retry_load, nope;
+    prfm(Address(addr), PSTL1STRM);
+    bind(retry_load);
+    // flush and load exclusive from the memory location
+    // and fail if it is not what we expect
+    ldaxr(tmp, addr);
+    cmp(tmp, oldv);
+    br(Assembler::NE, nope);
+    // if we store+flush with no intervening write tmp wil be zero
+    stlxr(tmp, newv, addr);
+    cbzw(tmp, succeed);
+    // retry so we only ever return after a load fails to compare
+    // ensures we don't return a stale value after a failed write.
+    b(retry_load);
+    // if the memory word differs we return it in oldv and signal a fail
+    bind(nope);
+    membar(AnyAny);
+    mov(oldv, tmp);
+  }
   if (fail)
     b(*fail);
 }
@@ -2099,28 +2107,64 @@
   // newv holds value to write in exchange
   // addr identifies memory word to compare against/update
   // tmp returns 0/1 for success/failure
-  Label retry_load, nope;
-
-  bind(retry_load);
-  // flush and load exclusive from the memory location
-  // and fail if it is not what we expect
-  ldaxrw(tmp, addr);
-  cmp(tmp, oldv);
-  br(Assembler::NE, nope);
-  // if we store+flush with no intervening write tmp wil be zero
-  stlxrw(tmp, newv, addr);
-  cbzw(tmp, succeed);
-  // retry so we only ever return after a load fails to compare
-  // ensures we don't return a stale value after a failed write.
-  b(retry_load);
-  // if the memory word differs we return it in oldv and signal a fail
-  bind(nope);
-  membar(AnyAny);
-  mov(oldv, tmp);
+  if (UseLSE) {
+    mov(tmp, oldv);
+    casal(Assembler::word, oldv, newv, addr);
+    cmp(tmp, oldv);
+    br(Assembler::EQ, succeed);
+    membar(AnyAny);
+  } else {
+    Label retry_load, nope;
+    prfm(Address(addr), PSTL1STRM);
+    bind(retry_load);
+    // flush and load exclusive from the memory location
+    // and fail if it is not what we expect
+    ldaxrw(tmp, addr);
+    cmp(tmp, oldv);
+    br(Assembler::NE, nope);
+    // if we store+flush with no intervening write tmp wil be zero
+    stlxrw(tmp, newv, addr);
+    cbzw(tmp, succeed);
+    // retry so we only ever return after a load fails to compare
+    // ensures we don't return a stale value after a failed write.
+    b(retry_load);
+    // if the memory word differs we return it in oldv and signal a fail
+    bind(nope);
+    membar(AnyAny);
+    mov(oldv, tmp);
+  }
   if (fail)
     b(*fail);
 }
 
+// A generic CAS; success or failure is in the EQ flag.
+void MacroAssembler::cmpxchg(Register addr, Register expected,
+                             Register new_val,
+                             enum operand_size size,
+                             bool acquire, bool release,
+                             Register tmp) {
+  if (UseLSE) {
+    mov(tmp, expected);
+    lse_cas(tmp, new_val, addr, size, acquire, release, /*not_pair*/ true);
+    cmp(tmp, expected);
+  } else {
+    BLOCK_COMMENT("cmpxchg {");
+    Label retry_load, done;
+    prfm(Address(addr), PSTL1STRM);
+    bind(retry_load);
+    load_exclusive(tmp, addr, size, acquire);
+    if (size == xword)
+      cmp(tmp, expected);
+    else
+      cmpw(tmp, expected);
+    br(Assembler::NE, done);
+    store_exclusive(tmp, new_val, addr, size, release);
+    cbnzw(tmp, retry_load);
+    bind(done);
+    BLOCK_COMMENT("} cmpxchg");
+  }
+}
+
 static bool different(Register a, RegisterOrConstant b, Register c) {
   if (b.is_constant())
     return a != c;
@@ -2135,6 +2179,7 @@
     result = different(prev, incr, addr) ? prev : rscratch2;            \
                                                                         \
   Label retry_load;                                                     \
+  prfm(Address(addr), PSTL1STRM);                                       \
   bind(retry_load);                                                     \
   LDXR(result, addr);                                                   \
   OP(rscratch1, result, incr);                                          \
@@ -2157,6 +2202,7 @@
     result = different(prev, newv, addr) ? prev : rscratch2;            \
                                                                         \
   Label retry_load;                                                     \
+  prfm(Address(addr), PSTL1STRM);                                       \
   bind(retry_load);                                                     \
   LDXR(result, addr);                                                   \
   STXR(rscratch1, newv, addr);                                          \
--- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -971,21 +971,10 @@
   }
 
   // A generic CAS; success or failure is in the EQ flag.
-  template <typename T1, typename T2>
   void cmpxchg(Register addr, Register expected, Register new_val,
-               T1 load_insn,
-               void (MacroAssembler::*cmp_insn)(Register, Register),
-               T2 store_insn,
-               Register tmp = rscratch1) {
-    Label retry_load, done;
-    bind(retry_load);
-    (this->*load_insn)(tmp, addr);
-    (this->*cmp_insn)(tmp, expected);
-    br(Assembler::NE, done);
-    (this->*store_insn)(tmp, new_val, addr);
-    cbnzw(tmp, retry_load);
-    bind(done);
-  }
+               enum operand_size size,
+               bool acquire, bool release,
+               Register tmp = rscratch1);
 
   // Calls
 
--- a/hotspot/src/cpu/aarch64/vm/register_aarch64.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/aarch64/vm/register_aarch64.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -107,6 +107,9 @@
 CONSTANT_REGISTER_DECLARATION(Register, zr,  (32));
 CONSTANT_REGISTER_DECLARATION(Register, sp,  (33));
 
+// Used as a filler in instructions where a register field is unused.
+const Register dummy_reg = r31_sp;
+
 // Use FloatRegister as shortcut
 class FloatRegisterImpl;
 typedef FloatRegisterImpl* FloatRegister;
--- a/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -729,7 +729,7 @@
   //
   // count is a count of words.
   //
-  // Precondition: count >= 2
+  // Precondition: count >= 8
   //
   // Postconditions:
   //
@@ -741,6 +741,7 @@
   void generate_copy_longs(Label &start, Register s, Register d, Register count,
                            copy_direction direction) {
     int unit = wordSize * direction;
+    int bias = (UseSIMDForMemoryOps ? 4:2) * wordSize;
 
     int offset;
     const Register t0 = r3, t1 = r4, t2 = r5, t3 = r6,
@@ -750,7 +751,7 @@
     assert_different_registers(rscratch1, t0, t1, t2, t3, t4, t5, t6, t7);
     assert_different_registers(s, d, count, rscratch1);
 
-    Label again, large, small;
+    Label again, drain;
     const char *stub_name;
     if (direction == copy_forwards)
       stub_name = "foward_copy_longs";
@@ -759,57 +760,35 @@
     StubCodeMark mark(this, "StubRoutines", stub_name);
     __ align(CodeEntryAlignment);
     __ bind(start);
-    __ cmp(count, 8);
-    __ br(Assembler::LO, small);
     if (direction == copy_forwards) {
-      __ sub(s, s, 2 * wordSize);
-      __ sub(d, d, 2 * wordSize);
+      __ sub(s, s, bias);
+      __ sub(d, d, bias);
     }
-    __ subs(count, count, 16);
-    __ br(Assembler::GE, large);
-
-    // 8 <= count < 16 words.  Copy 8.
-    __ ldp(t0, t1, Address(s, 2 * unit));
-    __ ldp(t2, t3, Address(s, 4 * unit));
-    __ ldp(t4, t5, Address(s, 6 * unit));
-    __ ldp(t6, t7, Address(__ pre(s, 8 * unit)));
-
-    __ stp(t0, t1, Address(d, 2 * unit));
-    __ stp(t2, t3, Address(d, 4 * unit));
-    __ stp(t4, t5, Address(d, 6 * unit));
-    __ stp(t6, t7, Address(__ pre(d, 8 * unit)));
-
-    if (direction == copy_forwards) {
-      __ add(s, s, 2 * wordSize);
-      __ add(d, d, 2 * wordSize);
-    }
-
+
+#ifdef ASSERT
+    // Make sure we are never given < 8 words
     {
-      Label L1, L2;
-      __ bind(small);
-      __ tbz(count, exact_log2(4), L1);
-      __ ldp(t0, t1, Address(__ adjust(s, 2 * unit, direction == copy_backwards)));
-      __ ldp(t2, t3, Address(__ adjust(s, 2 * unit, direction == copy_backwards)));
-      __ stp(t0, t1, Address(__ adjust(d, 2 * unit, direction == copy_backwards)));
-      __ stp(t2, t3, Address(__ adjust(d, 2 * unit, direction == copy_backwards)));
-      __ bind(L1);
-
-      __ tbz(count, 1, L2);
-      __ ldp(t0, t1, Address(__ adjust(s, 2 * unit, direction == copy_backwards)));
-      __ stp(t0, t1, Address(__ adjust(d, 2 * unit, direction == copy_backwards)));
-      __ bind(L2);
+      Label L;
+      __ cmp(count, 8);
+      __ br(Assembler::GE, L);
+      __ stop("genrate_copy_longs called with < 8 words");
+      __ bind(L);
     }
-
-    __ ret(lr);
-
-    __ align(CodeEntryAlignment);
-    __ bind(large);
+#endif
 
     // Fill 8 registers
-    __ ldp(t0, t1, Address(s, 2 * unit));
-    __ ldp(t2, t3, Address(s, 4 * unit));
-    __ ldp(t4, t5, Address(s, 6 * unit));
-    __ ldp(t6, t7, Address(__ pre(s, 8 * unit)));
+    if (UseSIMDForMemoryOps) {
+      __ ldpq(v0, v1, Address(s, 4 * unit));
+      __ ldpq(v2, v3, Address(__ pre(s, 8 * unit)));
+    } else {
+      __ ldp(t0, t1, Address(s, 2 * unit));
+      __ ldp(t2, t3, Address(s, 4 * unit));
+      __ ldp(t4, t5, Address(s, 6 * unit));
+      __ ldp(t6, t7, Address(__ pre(s, 8 * unit)));
+    }
+
+    __ subs(count, count, 16);
+    __ br(Assembler::LO, drain);
 
     int prefetch = PrefetchCopyIntervalInBytes;
     bool use_stride = false;
@@ -824,38 +803,56 @@
     if (PrefetchCopyIntervalInBytes > 0)
       __ prfm(use_stride ? Address(s, stride) : Address(s, prefetch), PLDL1KEEP);
 
-    __ stp(t0, t1, Address(d, 2 * unit));
-    __ ldp(t0, t1, Address(s, 2 * unit));
-    __ stp(t2, t3, Address(d, 4 * unit));
-    __ ldp(t2, t3, Address(s, 4 * unit));
-    __ stp(t4, t5, Address(d, 6 * unit));
-    __ ldp(t4, t5, Address(s, 6 * unit));
-    __ stp(t6, t7, Address(__ pre(d, 8 * unit)));
-    __ ldp(t6, t7, Address(__ pre(s, 8 * unit)));
+    if (UseSIMDForMemoryOps) {
+      __ stpq(v0, v1, Address(d, 4 * unit));
+      __ ldpq(v0, v1, Address(s, 4 * unit));
+      __ stpq(v2, v3, Address(__ pre(d, 8 * unit)));
+      __ ldpq(v2, v3, Address(__ pre(s, 8 * unit)));
+    } else {
+      __ stp(t0, t1, Address(d, 2 * unit));
+      __ ldp(t0, t1, Address(s, 2 * unit));
+      __ stp(t2, t3, Address(d, 4 * unit));
+      __ ldp(t2, t3, Address(s, 4 * unit));
+      __ stp(t4, t5, Address(d, 6 * unit));
+      __ ldp(t4, t5, Address(s, 6 * unit));
+      __ stp(t6, t7, Address(__ pre(d, 8 * unit)));
+      __ ldp(t6, t7, Address(__ pre(s, 8 * unit)));
+    }
 
     __ subs(count, count, 8);
     __ br(Assembler::HS, again);
 
     // Drain
-    __ stp(t0, t1, Address(d, 2 * unit));
-    __ stp(t2, t3, Address(d, 4 * unit));
-    __ stp(t4, t5, Address(d, 6 * unit));
-    __ stp(t6, t7, Address(__ pre(d, 8 * unit)));
-
-    if (direction == copy_forwards) {
-      __ add(s, s, 2 * wordSize);
-      __ add(d, d, 2 * wordSize);
+    __ bind(drain);
+    if (UseSIMDForMemoryOps) {
+      __ stpq(v0, v1, Address(d, 4 * unit));
+      __ stpq(v2, v3, Address(__ pre(d, 8 * unit)));
+    } else {
+      __ stp(t0, t1, Address(d, 2 * unit));
+      __ stp(t2, t3, Address(d, 4 * unit));
+      __ stp(t4, t5, Address(d, 6 * unit));
+      __ stp(t6, t7, Address(__ pre(d, 8 * unit)));
     }
 
     {
       Label L1, L2;
       __ tbz(count, exact_log2(4), L1);
-      __ ldp(t0, t1, Address(__ adjust(s, 2 * unit, direction == copy_backwards)));
-      __ ldp(t2, t3, Address(__ adjust(s, 2 * unit, direction == copy_backwards)));
-      __ stp(t0, t1, Address(__ adjust(d, 2 * unit, direction == copy_backwards)));
-      __ stp(t2, t3, Address(__ adjust(d, 2 * unit, direction == copy_backwards)));
+      if (UseSIMDForMemoryOps) {
+        __ ldpq(v0, v1, Address(__ pre(s, 4 * unit)));
+        __ stpq(v0, v1, Address(__ pre(d, 4 * unit)));
+      } else {
+        __ ldp(t0, t1, Address(s, 2 * unit));
+        __ ldp(t2, t3, Address(__ pre(s, 4 * unit)));
+        __ stp(t0, t1, Address(d, 2 * unit));
+        __ stp(t2, t3, Address(__ pre(d, 4 * unit)));
+      }
       __ bind(L1);
 
+      if (direction == copy_forwards) {
+        __ add(s, s, bias);
+        __ add(d, d, bias);
+      }
+
       __ tbz(count, 1, L2);
       __ ldp(t0, t1, Address(__ adjust(s, 2 * unit, direction == copy_backwards)));
       __ stp(t0, t1, Address(__ adjust(d, 2 * unit, direction == copy_backwards)));
@@ -931,16 +928,135 @@
     int granularity = uabs(step);
     const Register t0 = r3, t1 = r4;
 
+    // <= 96 bytes do inline. Direction doesn't matter because we always
+    // load all the data before writing anything
+    Label copy4, copy8, copy16, copy32, copy80, copy128, copy_big, finish;
+    const Register t2 = r5, t3 = r6, t4 = r7, t5 = r8;
+    const Register t6 = r9, t7 = r10, t8 = r11, t9 = r12;
+    const Register send = r17, dend = r18;
+
+    if (PrefetchCopyIntervalInBytes > 0)
+      __ prfm(Address(s, 0), PLDL1KEEP);
+    __ cmp(count, (UseSIMDForMemoryOps ? 96:80)/granularity);
+    __ br(Assembler::HI, copy_big);
+
+    __ lea(send, Address(s, count, Address::lsl(exact_log2(granularity))));
+    __ lea(dend, Address(d, count, Address::lsl(exact_log2(granularity))));
+
+    __ cmp(count, 16/granularity);
+    __ br(Assembler::LS, copy16);
+
+    __ cmp(count, 64/granularity);
+    __ br(Assembler::HI, copy80);
+
+    __ cmp(count, 32/granularity);
+    __ br(Assembler::LS, copy32);
+
+    // 33..64 bytes
+    if (UseSIMDForMemoryOps) {
+      __ ldpq(v0, v1, Address(s, 0));
+      __ ldpq(v2, v3, Address(send, -32));
+      __ stpq(v0, v1, Address(d, 0));
+      __ stpq(v2, v3, Address(dend, -32));
+    } else {
+      __ ldp(t0, t1, Address(s, 0));
+      __ ldp(t2, t3, Address(s, 16));
+      __ ldp(t4, t5, Address(send, -32));
+      __ ldp(t6, t7, Address(send, -16));
+
+      __ stp(t0, t1, Address(d, 0));
+      __ stp(t2, t3, Address(d, 16));
+      __ stp(t4, t5, Address(dend, -32));
+      __ stp(t6, t7, Address(dend, -16));
+    }
+    __ b(finish);
+
+    // 17..32 bytes
+    __ bind(copy32);
+    __ ldp(t0, t1, Address(s, 0));
+    __ ldp(t2, t3, Address(send, -16));
+    __ stp(t0, t1, Address(d, 0));
+    __ stp(t2, t3, Address(dend, -16));
+    __ b(finish);
+
+    // 65..80/96 bytes
+    // (96 bytes if SIMD because we do 32 byes per instruction)
+    __ bind(copy80);
+    if (UseSIMDForMemoryOps) {
+      __ ldpq(v0, v1, Address(s, 0));
+      __ ldpq(v2, v3, Address(s, 32));
+      __ ldpq(v4, v5, Address(send, -32));
+      __ stpq(v0, v1, Address(d, 0));
+      __ stpq(v2, v3, Address(d, 32));
+      __ stpq(v4, v5, Address(dend, -32));
+    } else {
+      __ ldp(t0, t1, Address(s, 0));
+      __ ldp(t2, t3, Address(s, 16));
+      __ ldp(t4, t5, Address(s, 32));
+      __ ldp(t6, t7, Address(s, 48));
+      __ ldp(t8, t9, Address(send, -16));
+
+      __ stp(t0, t1, Address(d, 0));
+      __ stp(t2, t3, Address(d, 16));
+      __ stp(t4, t5, Address(d, 32));
+      __ stp(t6, t7, Address(d, 48));
+      __ stp(t8, t9, Address(dend, -16));
+    }
+    __ b(finish);
+
+    // 0..16 bytes
+    __ bind(copy16);
+    __ cmp(count, 8/granularity);
+    __ br(Assembler::LO, copy8);
+
+    // 8..16 bytes
+    __ ldr(t0, Address(s, 0));
+    __ ldr(t1, Address(send, -8));
+    __ str(t0, Address(d, 0));
+    __ str(t1, Address(dend, -8));
+    __ b(finish);
+
+    if (granularity < 8) {
+      // 4..7 bytes
+      __ bind(copy8);
+      __ tbz(count, 2 - exact_log2(granularity), copy4);
+      __ ldrw(t0, Address(s, 0));
+      __ ldrw(t1, Address(send, -4));
+      __ strw(t0, Address(d, 0));
+      __ strw(t1, Address(dend, -4));
+      __ b(finish);
+      if (granularity < 4) {
+        // 0..3 bytes
+        __ bind(copy4);
+        __ cbz(count, finish); // get rid of 0 case
+        if (granularity == 2) {
+          __ ldrh(t0, Address(s, 0));
+          __ strh(t0, Address(d, 0));
+        } else { // granularity == 1
+          // Now 1..3 bytes. Handle the 1 and 2 byte case by copying
+          // the first and last byte.
+          // Handle the 3 byte case by loading and storing base + count/2
+          // (count == 1 (s+0)->(d+0), count == 2,3 (s+1) -> (d+1))
+          // This does means in the 1 byte case we load/store the same
+          // byte 3 times.
+          __ lsr(count, count, 1);
+          __ ldrb(t0, Address(s, 0));
+          __ ldrb(t1, Address(send, -1));
+          __ ldrb(t2, Address(s, count));
+          __ strb(t0, Address(d, 0));
+          __ strb(t1, Address(dend, -1));
+          __ strb(t2, Address(d, count));
+        }
+        __ b(finish);
+      }
+    }
+
+    __ bind(copy_big);
     if (is_backwards) {
       __ lea(s, Address(s, count, Address::lsl(exact_log2(-step))));
       __ lea(d, Address(d, count, Address::lsl(exact_log2(-step))));
     }
 
-    Label tail;
-
-    __ cmp(count, 16/granularity);
-    __ br(Assembler::LO, tail);
-
     // Now we've got the small case out of the way we can align the
     // source address on a 2-word boundary.
 
@@ -986,8 +1102,6 @@
 #endif
     }
 
-    __ cmp(count, 16/granularity);
-    __ br(Assembler::LT, tail);
     __ bind(aligned);
 
     // s is now 2-word-aligned.
@@ -1001,9 +1115,11 @@
       __ bl(copy_b);
 
     // And the tail.
-
-    __ bind(tail);
     copy_memory_small(s, d, count, tmp, step);
+
+    if (granularity >= 8) __ bind(copy8);
+    if (granularity >= 4) __ bind(copy4);
+    __ bind(finish);
   }
 
 
--- a/hotspot/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -1984,6 +1984,7 @@
   __ push(rscratch3);
   Label L;
   __ mov(rscratch2, (address) &BytecodeCounter::_counter_value);
+  __ prfm(Address(rscratch2), PSTL1STRM);
   __ bind(L);
   __ ldxr(rscratch1, rscratch2);
   __ add(rscratch1, rscratch1, 1);
--- a/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -61,6 +61,10 @@
 #define HWCAP_CRC32 (1<<7)
 #endif
 
+#ifndef HWCAP_ATOMICS
+#define HWCAP_ATOMICS (1<<8)
+#endif
+
 int VM_Version::_cpu;
 int VM_Version::_model;
 int VM_Version::_model2;
@@ -172,6 +176,7 @@
   if (auxv & HWCAP_AES)   strcat(buf, ", aes");
   if (auxv & HWCAP_SHA1)  strcat(buf, ", sha1");
   if (auxv & HWCAP_SHA2)  strcat(buf, ", sha256");
+  if (auxv & HWCAP_ATOMICS) strcat(buf, ", lse");
 
   _features_string = os::strdup(buf);
 
@@ -191,6 +196,15 @@
     FLAG_SET_DEFAULT(UseVectorizedMismatchIntrinsic, false);
   }
 
+  if (auxv & HWCAP_ATOMICS) {
+    if (FLAG_IS_DEFAULT(UseLSE))
+      FLAG_SET_DEFAULT(UseLSE, true);
+  } else {
+    if (UseLSE) {
+      warning("UseLSE specified, but not supported on this CPU");
+    }
+  }
+
   if (auxv & HWCAP_AES) {
     UseAES = UseAES || FLAG_IS_DEFAULT(UseAES);
     UseAESIntrinsics =
--- a/hotspot/src/cpu/ppc/vm/globalDefinitions_ppc.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/ppc/vm/globalDefinitions_ppc.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -47,7 +47,7 @@
 // The expected size in bytes of a cache line, used to pad data structures.
 #define DEFAULT_CACHE_LINE_SIZE 128
 
-#if defined(COMPILER2) && defined(AIX)
+#if defined(COMPILER2) && (defined(AIX) || defined(linux))
 // Include Transactional Memory lock eliding optimization
 #define INCLUDE_RTM_OPT 1
 #endif
--- a/hotspot/src/cpu/ppc/vm/globals_ppc.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/ppc/vm/globals_ppc.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -76,6 +76,8 @@
 
 define_pd_global(bool, CompactStrings, true);
 
+define_pd_global(intx, InitArrayShortSize, 8*BytesPerLong);
+
 // Platform dependent flag handling: flags only defined on this platform.
 #define ARCH_FLAGS(develop, product, diagnostic, experimental, notproduct, range, constraint)  \
                                                                             \
--- a/hotspot/src/cpu/ppc/vm/ppc.ad	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/ppc/vm/ppc.ad	Mon Mar 28 08:41:54 2016 -0700
@@ -2137,8 +2137,6 @@
   return decode;
 }
 */
-// Threshold size for cleararray.
-const int Matcher::init_array_short_size = 8 * BytesPerLong;
 
 // false => size gets scaled to BytesPerLong, ok.
 const bool Matcher::init_array_count_is_in_bytes = false;
--- a/hotspot/src/cpu/ppc/vm/vm_version_ppc.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/ppc/vm/vm_version_ppc.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -255,7 +255,16 @@
     }
 #endif
 #ifdef linux
-    // TODO: check kernel version (we currently have too old versions only)
+    // At least Linux kernel 4.2, as the problematic behavior of syscalls
+    // being called in the middle of a transaction has been addressed.
+    // Please, refer to commit b4b56f9ecab40f3b4ef53e130c9f6663be491894
+    // in Linux kernel source tree: https://goo.gl/Kc5i7A
+    if (os::Linux::os_version_is_known()) {
+      if (os::Linux::os_version() >= 0x040200)
+        os_too_old = false;
+    } else {
+      vm_exit_during_initialization("RTM can not be enabled: kernel version is unknown.");
+    }
 #endif
     if (os_too_old) {
       vm_exit_during_initialization("RTM is not supported on this OS version.");
--- a/hotspot/src/cpu/sparc/vm/globals_sparc.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/sparc/vm/globals_sparc.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -90,6 +90,8 @@
 
 define_pd_global(bool, CompactStrings, true);
 
+define_pd_global(intx, InitArrayShortSize, 8*BytesPerLong);
+
 #define ARCH_FLAGS(develop, product, diagnostic, experimental, notproduct, range, constraint) \
                                                                             \
   product(intx, UseVIS, 99,                                                 \
--- a/hotspot/src/cpu/sparc/vm/sparc.ad	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/sparc/vm/sparc.ad	Mon Mar 28 08:41:54 2016 -0700
@@ -1980,9 +1980,6 @@
 // No scaling for the parameter the ClearArray node.
 const bool Matcher::init_array_count_is_in_bytes = true;
 
-// Threshold size for cleararray.
-const int Matcher::init_array_short_size = 8 * BytesPerLong;
-
 // No additional cost for CMOVL.
 const int Matcher::long_cmove_cost() { return 0; }
 
--- a/hotspot/src/cpu/x86/vm/assembler_x86.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/assembler_x86.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -777,6 +777,7 @@
     case 0x6E: // movd
     case 0x7E: // movd
     case 0xAE: // ldmxcsr, stmxcsr, fxrstor, fxsave, clflush
+    case 0xFE: // paddd
       debug_only(has_disp32 = true);
       break;
 
@@ -926,6 +927,7 @@
     ip++; // skip P2, move to opcode
     // To find the end of instruction (which == end_pc_operand).
     switch (0xFF & *ip) {
+    case 0x22: // pinsrd r, r/a, #8
     case 0x61: // pcmpestri r, r/a, #8
     case 0x70: // pshufd r, r/a, #8
     case 0x73: // psrldq r, #8
@@ -3953,6 +3955,83 @@
   emit_int8((unsigned char)(0xC0 | encode));
 }
 
+void Assembler::palignr(XMMRegister dst, XMMRegister src, int imm8) {
+  assert(VM_Version::supports_ssse3(), "");
+  InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ false, /* uses_vl */ false);
+  int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
+  emit_int8((unsigned char)0x0F);
+  emit_int8((unsigned char)(0xC0 | encode));
+  emit_int8(imm8);
+}
+
+void Assembler::pblendw(XMMRegister dst, XMMRegister src, int imm8) {
+  assert(VM_Version::supports_sse4_1(), "");
+  InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ false, /* uses_vl */ false);
+  int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
+  emit_int8((unsigned char)0x0E);
+  emit_int8((unsigned char)(0xC0 | encode));
+  emit_int8(imm8);
+}
+
+void Assembler::sha1rnds4(XMMRegister dst, XMMRegister src, int imm8) {
+  assert(VM_Version::supports_sha(), "");
+  InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ false, /* uses_vl */ false);
+  int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_NONE, VEX_OPCODE_0F_3A, &attributes);
+  emit_int8((unsigned char)0xCC);
+  emit_int8((unsigned char)(0xC0 | encode));
+  emit_int8((unsigned char)imm8);
+}
+
+void Assembler::sha1nexte(XMMRegister dst, XMMRegister src) {
+  assert(VM_Version::supports_sha(), "");
+  InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ false, /* uses_vl */ false);
+  int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_NONE, VEX_OPCODE_0F_38, &attributes);
+  emit_int8((unsigned char)0xC8);
+  emit_int8((unsigned char)(0xC0 | encode));
+}
+
+void Assembler::sha1msg1(XMMRegister dst, XMMRegister src) {
+  assert(VM_Version::supports_sha(), "");
+  InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ false, /* uses_vl */ false);
+  int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_NONE, VEX_OPCODE_0F_38, &attributes);
+  emit_int8((unsigned char)0xC9);
+  emit_int8((unsigned char)(0xC0 | encode));
+}
+
+void Assembler::sha1msg2(XMMRegister dst, XMMRegister src) {
+  assert(VM_Version::supports_sha(), "");
+  InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ false, /* uses_vl */ false);
+  int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_NONE, VEX_OPCODE_0F_38, &attributes);
+  emit_int8((unsigned char)0xCA);
+  emit_int8((unsigned char)(0xC0 | encode));
+}
+
+// xmm0 is implicit additional source to this instruction.
+void Assembler::sha256rnds2(XMMRegister dst, XMMRegister src) {
+  assert(VM_Version::supports_sha(), "");
+  InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ false, /* uses_vl */ false);
+  int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_NONE, VEX_OPCODE_0F_38, &attributes);
+  emit_int8((unsigned char)0xCB);
+  emit_int8((unsigned char)(0xC0 | encode));
+}
+
+void Assembler::sha256msg1(XMMRegister dst, XMMRegister src) {
+  assert(VM_Version::supports_sha(), "");
+  InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ false, /* uses_vl */ false);
+  int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_NONE, VEX_OPCODE_0F_38, &attributes);
+  emit_int8((unsigned char)0xCC);
+  emit_int8((unsigned char)(0xC0 | encode));
+}
+
+void Assembler::sha256msg2(XMMRegister dst, XMMRegister src) {
+  assert(VM_Version::supports_sha(), "");
+  InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ false, /* uses_vl */ false);
+  int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_NONE, VEX_OPCODE_0F_38, &attributes);
+  emit_int8((unsigned char)0xCD);
+  emit_int8((unsigned char)(0xC0 | encode));
+}
+
+
 void Assembler::shll(Register dst, int imm8) {
   assert(isShiftCount(imm8), "illegal shift count");
   int encode = prefix_and_encode(dst->encoding());
@@ -4931,6 +5010,15 @@
   emit_int8((unsigned char)(0xC0 | encode));
 }
 
+void Assembler::paddd(XMMRegister dst, Address src) {
+  NOT_LP64(assert(VM_Version::supports_sse2(), ""));
+  InstructionMark im(this);
+  InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
+  simd_prefix(dst, xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes);
+  emit_int8((unsigned char)0xFE);
+  emit_operand(dst, src);
+}
+
 void Assembler::paddq(XMMRegister dst, XMMRegister src) {
   NOT_LP64(assert(VM_Version::supports_sse2(), ""));
   InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
@@ -5611,8 +5699,9 @@
 }
 
 
-void Assembler::vinsertf128h(XMMRegister dst, XMMRegister nds, XMMRegister src) {
+void Assembler::vinsertf128(XMMRegister dst, XMMRegister nds, XMMRegister src, uint8_t imm8) {
   assert(VM_Version::supports_avx(), "");
+  assert(imm8 <= 0x01, "imm8: %u", imm8);
   int vector_len = VM_Version::supports_evex() ? AVX_512bit : AVX_256bit;
   InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   int nds_enc = nds->is_valid() ? nds->encoding() : 0;
@@ -5621,11 +5710,12 @@
   emit_int8((unsigned char)(0xC0 | encode));
   // 0x00 - insert into lower 128 bits
   // 0x01 - insert into upper 128 bits
-  emit_int8(0x01);
-}
-
-void Assembler::vinsertf64x4h(XMMRegister dst, XMMRegister nds, XMMRegister src, int value) {
+  emit_int8(imm8 & 0x01);
+}
+
+void Assembler::vinsertf64x4(XMMRegister dst, XMMRegister nds, XMMRegister src, uint8_t imm8) {
   assert(VM_Version::supports_evex(), "");
+  assert(imm8 <= 0x01, "imm8: %u", imm8);
   InstructionAttr attributes(AVX_512bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   int nds_enc = nds->is_valid() ? nds->encoding() : 0;
   int encode = vex_prefix_and_encode(dst->encoding(), nds_enc, src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
@@ -5633,26 +5723,29 @@
   emit_int8((unsigned char)(0xC0 | encode));
   // 0x00 - insert into lower 256 bits
   // 0x01 - insert into upper 256 bits
-  emit_int8(value & 0x01);
-}
-
-void Assembler::vinsertf64x4h(XMMRegister dst, Address src, int value) {
+  emit_int8(imm8 & 0x01);
+}
+
+void Assembler::vinsertf64x4(XMMRegister dst, XMMRegister nds, Address src, uint8_t imm8) {
   assert(VM_Version::supports_evex(), "");
   assert(dst != xnoreg, "sanity");
+  assert(imm8 <= 0x01, "imm8: %u", imm8);
   InstructionMark im(this);
   InstructionAttr attributes(AVX_512bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
+  int nds_enc = nds->is_valid() ? nds->encoding() : 0;
   attributes.set_address_attributes(/* tuple_type */ EVEX_T4, /* input_size_in_bits */ EVEX_64bit);
   // swap src<->dst for encoding
-  vex_prefix(src, dst->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
+  vex_prefix(src, nds_enc, dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
   emit_int8(0x1A);
   emit_operand(dst, src);
   // 0x00 - insert into lower 256 bits
-  // 0x01 - insert into upper 128 bits
-  emit_int8(value & 0x01);
-}
-
-void Assembler::vinsertf32x4h(XMMRegister dst, XMMRegister nds, XMMRegister src, int value) {
+  // 0x01 - insert into upper 256 bits
+  emit_int8(imm8 & 0x01);
+}
+
+void Assembler::vinsertf32x4(XMMRegister dst, XMMRegister nds, XMMRegister src, uint8_t imm8) {
   assert(VM_Version::supports_evex(), "");
+  assert(imm8 <= 0x03, "imm8: %u", imm8);
   InstructionAttr attributes(AVX_512bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   int nds_enc = nds->is_valid() ? nds->encoding() : 0;
   int encode = vex_prefix_and_encode(dst->encoding(), nds_enc, src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
@@ -5662,57 +5755,64 @@
   // 0x01 - insert into q1 128 bits (128..255)
   // 0x02 - insert into q2 128 bits (256..383)
   // 0x03 - insert into q3 128 bits (384..511)
-  emit_int8(value & 0x3);
-}
-
-void Assembler::vinsertf32x4h(XMMRegister dst, Address src, int value) {
+  emit_int8(imm8 & 0x03);
+}
+
+void Assembler::vinsertf32x4(XMMRegister dst, XMMRegister nds, Address src, uint8_t imm8) {
   assert(VM_Version::supports_avx(), "");
   assert(dst != xnoreg, "sanity");
+  assert(imm8 <= 0x03, "imm8: %u", imm8);
   int vector_len = VM_Version::supports_evex() ? AVX_512bit : AVX_256bit;
+  int nds_enc = nds->is_valid() ? nds->encoding() : 0;
   InstructionMark im(this);
   InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   attributes.set_address_attributes(/* tuple_type */ EVEX_T4, /* input_size_in_bits */ EVEX_32bit);
   // swap src<->dst for encoding
-  vex_prefix(src, dst->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
+  vex_prefix(src, nds_enc, dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
   emit_int8(0x18);
   emit_operand(dst, src);
   // 0x00 - insert into q0 128 bits (0..127)
   // 0x01 - insert into q1 128 bits (128..255)
   // 0x02 - insert into q2 128 bits (256..383)
   // 0x03 - insert into q3 128 bits (384..511)
-  emit_int8(value & 0x3);
-}
-
-void Assembler::vinsertf128h(XMMRegister dst, Address src) {
+  emit_int8(imm8 & 0x03);
+}
+
+void Assembler::vinsertf128(XMMRegister dst, XMMRegister nds, Address src, uint8_t imm8) {
   assert(VM_Version::supports_avx(), "");
   assert(dst != xnoreg, "sanity");
+  assert(imm8 <= 0x01, "imm8: %u", imm8);
   int vector_len = VM_Version::supports_evex() ? AVX_512bit : AVX_256bit;
+  int nds_enc = nds->is_valid() ? nds->encoding() : 0;
   InstructionMark im(this);
   InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   attributes.set_address_attributes(/* tuple_type */ EVEX_T4, /* input_size_in_bits */ EVEX_32bit);
   // swap src<->dst for encoding
-  vex_prefix(src, dst->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
+  vex_prefix(src, nds_enc, dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
   emit_int8(0x18);
   emit_operand(dst, src);
+  // 0x00 - insert into lower 128 bits
   // 0x01 - insert into upper 128 bits
-  emit_int8(0x01);
-}
-
-void Assembler::vextractf128h(XMMRegister dst, XMMRegister src) {
+  emit_int8(imm8 & 0x01);
+}
+
+void Assembler::vextractf128(XMMRegister dst, XMMRegister src, uint8_t imm8) {
   assert(VM_Version::supports_avx(), "");
+  assert(imm8 <= 0x01, "imm8: %u", imm8);
   int vector_len = VM_Version::supports_evex() ? AVX_512bit : AVX_256bit;
   InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   int encode = vex_prefix_and_encode(src->encoding(), 0, dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
   emit_int8(0x19);
   emit_int8((unsigned char)(0xC0 | encode));
-  // 0x00 - insert into lower 128 bits
-  // 0x01 - insert into upper 128 bits
-  emit_int8(0x01);
-}
-
-void Assembler::vextractf128h(Address dst, XMMRegister src) {
+  // 0x00 - extract from lower 128 bits
+  // 0x01 - extract from upper 128 bits
+  emit_int8(imm8 & 0x01);
+}
+
+void Assembler::vextractf128(Address dst, XMMRegister src, uint8_t imm8) {
   assert(VM_Version::supports_avx(), "");
   assert(src != xnoreg, "sanity");
+  assert(imm8 <= 0x01, "imm8: %u", imm8);
   int vector_len = VM_Version::supports_evex() ? AVX_512bit : AVX_256bit;
   InstructionMark im(this);
   InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
@@ -5720,12 +5820,14 @@
   vex_prefix(dst, 0, src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
   emit_int8(0x19);
   emit_operand(src, dst);
+  // 0x00 - extract from lower 128 bits
   // 0x01 - extract from upper 128 bits
-  emit_int8(0x01);
-}
-
-void Assembler::vinserti128h(XMMRegister dst, XMMRegister nds, XMMRegister src) {
+  emit_int8(imm8 & 0x01);
+}
+
+void Assembler::vinserti128(XMMRegister dst, XMMRegister nds, XMMRegister src, uint8_t imm8) {
   assert(VM_Version::supports_avx2(), "");
+  assert(imm8 <= 0x01, "imm8: %u", imm8);
   int vector_len = VM_Version::supports_evex() ? AVX_512bit : AVX_256bit;
   InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   int nds_enc = nds->is_valid() ? nds->encoding() : 0;
@@ -5734,11 +5836,12 @@
   emit_int8((unsigned char)(0xC0 | encode));
   // 0x00 - insert into lower 128 bits
   // 0x01 - insert into upper 128 bits
-  emit_int8(0x01);
-}
-
-void Assembler::vinserti64x4h(XMMRegister dst, XMMRegister nds, XMMRegister src, int value) {
+  emit_int8(imm8 & 0x01);
+}
+
+void Assembler::vinserti64x4(XMMRegister dst, XMMRegister nds, XMMRegister src, uint8_t imm8) {
   assert(VM_Version::supports_evex(), "");
+  assert(imm8 <= 0x01, "imm8: %u", imm8);
   InstructionAttr attributes(AVX_512bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   int nds_enc = nds->is_valid() ? nds->encoding() : 0;
   int encode = vex_prefix_and_encode(dst->encoding(), nds_enc, src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
@@ -5746,39 +5849,44 @@
   emit_int8((unsigned char)(0xC0 | encode));
   // 0x00 - insert into lower 256 bits
   // 0x01 - insert into upper 256 bits
-  emit_int8(value & 0x01);
-}
-
-void Assembler::vinserti128h(XMMRegister dst, Address src) {
+  emit_int8(imm8 & 0x01);
+}
+
+void Assembler::vinserti128(XMMRegister dst, XMMRegister nds, Address src, uint8_t imm8) {
   assert(VM_Version::supports_avx2(), "");
   assert(dst != xnoreg, "sanity");
+  assert(imm8 <= 0x01, "imm8: %u", imm8);
   int vector_len = VM_Version::supports_evex() ? AVX_512bit : AVX_256bit;
+  int nds_enc = nds->is_valid() ? nds->encoding() : 0;
   InstructionMark im(this);
   InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   attributes.set_address_attributes(/* tuple_type */ EVEX_T4, /* input_size_in_bits */ EVEX_32bit);
   // swap src<->dst for encoding
-  vex_prefix(src, dst->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
+  vex_prefix(src, nds_enc, dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
   emit_int8(0x38);
   emit_operand(dst, src);
+  // 0x00 - insert into lower 128 bits
   // 0x01 - insert into upper 128 bits
-  emit_int8(0x01);
-}
-
-void Assembler::vextracti128h(XMMRegister dst, XMMRegister src) {
+  emit_int8(imm8 & 0x01);
+}
+
+void Assembler::vextracti128(XMMRegister dst, XMMRegister src, uint8_t imm8) {
   assert(VM_Version::supports_avx(), "");
+  assert(imm8 <= 0x01, "imm8: %u", imm8);
   int vector_len = VM_Version::supports_evex() ? AVX_512bit : AVX_256bit;
   InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   int encode = vex_prefix_and_encode(src->encoding(), 0, dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
   emit_int8(0x39);
   emit_int8((unsigned char)(0xC0 | encode));
-  // 0x00 - insert into lower 128 bits
-  // 0x01 - insert into upper 128 bits
-  emit_int8(0x01);
-}
-
-void Assembler::vextracti128h(Address dst, XMMRegister src) {
+  // 0x00 - extract from lower 128 bits
+  // 0x01 - extract from upper 128 bits
+  emit_int8(imm8 & 0x01);
+}
+
+void Assembler::vextracti128(Address dst, XMMRegister src, uint8_t imm8) {
   assert(VM_Version::supports_avx2(), "");
   assert(src != xnoreg, "sanity");
+  assert(imm8 <= 0x01, "imm8: %u", imm8);
   int vector_len = VM_Version::supports_evex() ? AVX_512bit : AVX_256bit;
   InstructionMark im(this);
   InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
@@ -5786,47 +5894,53 @@
   vex_prefix(dst, 0, src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
   emit_int8(0x39);
   emit_operand(src, dst);
+  // 0x00 - extract from lower 128 bits
   // 0x01 - extract from upper 128 bits
-  emit_int8(0x01);
-}
-
-void Assembler::vextracti64x4h(XMMRegister dst, XMMRegister src, int value) {
+  emit_int8(imm8 & 0x01);
+}
+
+void Assembler::vextracti64x4(XMMRegister dst, XMMRegister src, uint8_t imm8) {
   assert(VM_Version::supports_evex(), "");
+  assert(imm8 <= 0x01, "imm8: %u", imm8);
   InstructionAttr attributes(AVX_512bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   int encode = vex_prefix_and_encode(src->encoding(), 0, dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
   emit_int8(0x3B);
   emit_int8((unsigned char)(0xC0 | encode));
   // 0x00 - extract from lower 256 bits
   // 0x01 - extract from upper 256 bits
-  emit_int8(value & 0x01);
-}
-
-void Assembler::vextracti64x2h(XMMRegister dst, XMMRegister src, int value) {
+  emit_int8(imm8 & 0x01);
+}
+
+void Assembler::vextracti64x2(XMMRegister dst, XMMRegister src, uint8_t imm8) {
   assert(VM_Version::supports_evex(), "");
+  assert(imm8 <= 0x03, "imm8: %u", imm8);
   InstructionAttr attributes(AVX_512bit, /* vex_w */ !_legacy_mode_dq, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   int encode = vex_prefix_and_encode(src->encoding(), 0, dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
   emit_int8(0x39);
   emit_int8((unsigned char)(0xC0 | encode));
+  // 0x00 - extract from bits 127:0
   // 0x01 - extract from bits 255:128
   // 0x02 - extract from bits 383:256
   // 0x03 - extract from bits 511:384
-  emit_int8(value & 0x3);
-}
-
-void Assembler::vextractf64x4h(XMMRegister dst, XMMRegister src, int value) {
+  emit_int8(imm8 & 0x03);
+}
+
+void Assembler::vextractf64x4(XMMRegister dst, XMMRegister src, uint8_t imm8) {
   assert(VM_Version::supports_evex(), "");
+  assert(imm8 <= 0x01, "imm8: %u", imm8);
   InstructionAttr attributes(AVX_512bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   int encode = vex_prefix_and_encode(src->encoding(), 0, dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
   emit_int8(0x1B);
   emit_int8((unsigned char)(0xC0 | encode));
   // 0x00 - extract from lower 256 bits
   // 0x01 - extract from upper 256 bits
-  emit_int8(value & 0x1);
-}
-
-void Assembler::vextractf64x4h(Address dst, XMMRegister src, int value) {
+  emit_int8(imm8 & 0x01);
+}
+
+void Assembler::vextractf64x4(Address dst, XMMRegister src, uint8_t imm8) {
   assert(VM_Version::supports_evex(), "");
   assert(src != xnoreg, "sanity");
+  assert(imm8 <= 0x01, "imm8: %u", imm8);
   InstructionMark im(this);
   InstructionAttr attributes(AVX_512bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   attributes.set_address_attributes(/* tuple_type */ EVEX_T4,/* input_size_in_bits */  EVEX_64bit);
@@ -5835,11 +5949,12 @@
   emit_operand(src, dst);
   // 0x00 - extract from lower 256 bits
   // 0x01 - extract from upper 256 bits
-  emit_int8(value & 0x01);
-}
-
-void Assembler::vextractf32x4h(XMMRegister dst, XMMRegister src, int value) {
+  emit_int8(imm8 & 0x01);
+}
+
+void Assembler::vextractf32x4(XMMRegister dst, XMMRegister src, uint8_t imm8) {
   assert(VM_Version::supports_avx(), "");
+  assert(imm8 <= 0x03, "imm8: %u", imm8);
   int vector_len = VM_Version::supports_evex() ? AVX_512bit : AVX_256bit;
   InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   int encode = vex_prefix_and_encode(src->encoding(), 0, dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
@@ -5849,12 +5964,13 @@
   // 0x01 - extract from bits 255:128
   // 0x02 - extract from bits 383:256
   // 0x03 - extract from bits 511:384
-  emit_int8(value & 0x3);
-}
-
-void Assembler::vextractf32x4h(Address dst, XMMRegister src, int value) {
+  emit_int8(imm8 & 0x03);
+}
+
+void Assembler::vextractf32x4(Address dst, XMMRegister src, uint8_t imm8) {
   assert(VM_Version::supports_evex(), "");
   assert(src != xnoreg, "sanity");
+  assert(imm8 <= 0x03, "imm8: %u", imm8);
   InstructionMark im(this);
   InstructionAttr attributes(AVX_512bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   attributes.set_address_attributes(/* tuple_type */ EVEX_T4, /* input_size_in_bits */ EVEX_32bit);
@@ -5865,19 +5981,21 @@
   // 0x01 - extract from bits 255:128
   // 0x02 - extract from bits 383:256
   // 0x03 - extract from bits 511:384
-  emit_int8(value & 0x3);
-}
-
-void Assembler::vextractf64x2h(XMMRegister dst, XMMRegister src, int value) {
+  emit_int8(imm8 & 0x03);
+}
+
+void Assembler::vextractf64x2(XMMRegister dst, XMMRegister src, uint8_t imm8) {
   assert(VM_Version::supports_evex(), "");
+  assert(imm8 <= 0x03, "imm8: %u", imm8);
   InstructionAttr attributes(AVX_512bit, /* vex_w */ !_legacy_mode_dq, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false);
   int encode = vex_prefix_and_encode(src->encoding(), 0, dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
   emit_int8(0x19);
   emit_int8((unsigned char)(0xC0 | encode));
+  // 0x00 - extract from bits 127:0
   // 0x01 - extract from bits 255:128
   // 0x02 - extract from bits 383:256
   // 0x03 - extract from bits 511:384
-  emit_int8(value & 0x3);
+  emit_int8(imm8 & 0x03);
 }
 
 // duplicate 4-bytes integer data from src into 8 locations in dest
--- a/hotspot/src/cpu/x86/vm/assembler_x86.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/assembler_x86.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1672,6 +1672,18 @@
 
   void setb(Condition cc, Register dst);
 
+  void palignr(XMMRegister dst, XMMRegister src, int imm8);
+  void pblendw(XMMRegister dst, XMMRegister src, int imm8);
+
+  void sha1rnds4(XMMRegister dst, XMMRegister src, int imm8);
+  void sha1nexte(XMMRegister dst, XMMRegister src);
+  void sha1msg1(XMMRegister dst, XMMRegister src);
+  void sha1msg2(XMMRegister dst, XMMRegister src);
+  // xmm0 is implicit additional source to the following instruction.
+  void sha256rnds2(XMMRegister dst, XMMRegister src);
+  void sha256msg1(XMMRegister dst, XMMRegister src);
+  void sha256msg2(XMMRegister dst, XMMRegister src);
+
   void shldl(Register dst, Register src);
   void shldl(Register dst, Register src, int8_t imm8);
 
@@ -1868,6 +1880,7 @@
   void paddb(XMMRegister dst, XMMRegister src);
   void paddw(XMMRegister dst, XMMRegister src);
   void paddd(XMMRegister dst, XMMRegister src);
+  void paddd(XMMRegister dst, Address src);
   void paddq(XMMRegister dst, XMMRegister src);
   void vpaddb(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len);
   void vpaddw(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len);
@@ -1958,33 +1971,31 @@
   void vpxor(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len);
   void vpxor(XMMRegister dst, XMMRegister nds, Address src, int vector_len);
 
-  // Copy low 128bit into high 128bit of YMM registers.
-  void vinsertf128h(XMMRegister dst, XMMRegister nds, XMMRegister src);
-  void vinserti128h(XMMRegister dst, XMMRegister nds, XMMRegister src);
-  void vextractf128h(XMMRegister dst, XMMRegister src);
-  void vextracti128h(XMMRegister dst, XMMRegister src);
-
-  // Load/store high 128bit of YMM registers which does not destroy other half.
-  void vinsertf128h(XMMRegister dst, Address src);
-  void vinserti128h(XMMRegister dst, Address src);
-  void vextractf128h(Address dst, XMMRegister src);
-  void vextracti128h(Address dst, XMMRegister src);
-
-  // Copy low 256bit into high 256bit of ZMM registers.
-  void vinserti64x4h(XMMRegister dst, XMMRegister nds, XMMRegister src, int value);
-  void vinsertf64x4h(XMMRegister dst, XMMRegister nds, XMMRegister src, int value);
-  void vextracti64x4h(XMMRegister dst, XMMRegister src, int value);
-  void vextractf64x4h(XMMRegister dst, XMMRegister src, int value);
-  void vextractf64x4h(Address dst, XMMRegister src, int value);
-  void vinsertf64x4h(XMMRegister dst, Address src, int value);
-
-  // Copy targeted 128bit segments of the ZMM registers
-  void vextracti64x2h(XMMRegister dst, XMMRegister src, int value);
-  void vextractf64x2h(XMMRegister dst, XMMRegister src, int value);
-  void vextractf32x4h(XMMRegister dst, XMMRegister src, int value);
-  void vextractf32x4h(Address dst, XMMRegister src, int value);
-  void vinsertf32x4h(XMMRegister dst, XMMRegister nds, XMMRegister src, int value);
-  void vinsertf32x4h(XMMRegister dst, Address src, int value);
+  // 128bit copy from/to 256bit (YMM) vector registers
+  void vinsertf128(XMMRegister dst, XMMRegister nds, XMMRegister src, uint8_t imm8);
+  void vinserti128(XMMRegister dst, XMMRegister nds, XMMRegister src, uint8_t imm8);
+  void vextractf128(XMMRegister dst, XMMRegister src, uint8_t imm8);
+  void vextracti128(XMMRegister dst, XMMRegister src, uint8_t imm8);
+  void vinsertf128(XMMRegister dst, XMMRegister nds, Address src, uint8_t imm8);
+  void vinserti128(XMMRegister dst, XMMRegister nds, Address src, uint8_t imm8);
+  void vextractf128(Address dst, XMMRegister src, uint8_t imm8);
+  void vextracti128(Address dst, XMMRegister src, uint8_t imm8);
+
+  // 256bit copy from/to 512bit (ZMM) vector registers
+  void vinserti64x4(XMMRegister dst, XMMRegister nds, XMMRegister src, uint8_t imm8);
+  void vinsertf64x4(XMMRegister dst, XMMRegister nds, XMMRegister src, uint8_t imm8);
+  void vextracti64x4(XMMRegister dst, XMMRegister src, uint8_t imm8);
+  void vextractf64x4(XMMRegister dst, XMMRegister src, uint8_t imm8);
+  void vextractf64x4(Address dst, XMMRegister src, uint8_t imm8);
+  void vinsertf64x4(XMMRegister dst, XMMRegister nds, Address src, uint8_t imm8);
+
+  // 128bit copy from/to 256bit (YMM) or 512bit (ZMM) vector registers
+  void vextracti64x2(XMMRegister dst, XMMRegister src, uint8_t imm8);
+  void vextractf64x2(XMMRegister dst, XMMRegister src, uint8_t imm8);
+  void vextractf32x4(XMMRegister dst, XMMRegister src, uint8_t imm8);
+  void vextractf32x4(Address dst, XMMRegister src, uint8_t imm8);
+  void vinsertf32x4(XMMRegister dst, XMMRegister nds, XMMRegister src, uint8_t imm8);
+  void vinsertf32x4(XMMRegister dst, XMMRegister nds, Address src, uint8_t imm8);
 
   // duplicate 4-bytes integer data from src into 8 locations in dest
   void vpbroadcastd(XMMRegister dst, XMMRegister src);
--- a/hotspot/src/cpu/x86/vm/globals_x86.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/globals_x86.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -97,6 +97,8 @@
 
 define_pd_global(bool, PreserveFramePointer, false);
 
+define_pd_global(intx, InitArrayShortSize, 8*BytesPerLong);
+
 #define ARCH_FLAGS(develop, product, diagnostic, experimental, notproduct, range, constraint) \
                                                                             \
   develop(bool, IEEEPrecision, true,                                        \
--- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -3445,7 +3445,7 @@
 
 void MacroAssembler::movdqu(Address dst, XMMRegister src) {
   if (UseAVX > 2 && !VM_Version::supports_avx512vl() && (src->encoding() > 15)) {
-    Assembler::vextractf32x4h(dst, src, 0);
+    Assembler::vextractf32x4(dst, src, 0);
   } else {
     Assembler::movdqu(dst, src);
   }
@@ -3453,7 +3453,7 @@
 
 void MacroAssembler::movdqu(XMMRegister dst, Address src) {
   if (UseAVX > 2 && !VM_Version::supports_avx512vl() && (dst->encoding() > 15)) {
-    Assembler::vinsertf32x4h(dst, src, 0);
+    Assembler::vinsertf32x4(dst, dst, src, 0);
   } else {
     Assembler::movdqu(dst, src);
   }
@@ -3478,7 +3478,7 @@
 
 void MacroAssembler::vmovdqu(Address dst, XMMRegister src) {
   if (UseAVX > 2 && !VM_Version::supports_avx512vl() && (src->encoding() > 15)) {
-    Assembler::vextractf64x4h(dst, src, 0);
+    vextractf64x4_low(dst, src);
   } else {
     Assembler::vmovdqu(dst, src);
   }
@@ -3486,7 +3486,7 @@
 
 void MacroAssembler::vmovdqu(XMMRegister dst, Address src) {
   if (UseAVX > 2 && !VM_Version::supports_avx512vl() && (dst->encoding() > 15)) {
-    Assembler::vinsertf64x4h(dst, src, 0);
+    vinsertf64x4_low(dst, src);
   } else {
     Assembler::vmovdqu(dst, src);
   }
@@ -5649,14 +5649,14 @@
         // Save upper half of ZMM registers
         subptr(rsp, 32*num_xmm_regs);
         for (int n = 0; n < num_xmm_regs; n++) {
-          vextractf64x4h(Address(rsp, n*32), as_XMMRegister(n), 1);
+          vextractf64x4_high(Address(rsp, n*32), as_XMMRegister(n));
         }
       }
       assert(UseAVX > 0, "256 bit vectors are supported only with AVX");
       // Save upper half of YMM registers
       subptr(rsp, 16*num_xmm_regs);
       for (int n = 0; n < num_xmm_regs; n++) {
-        vextractf128h(Address(rsp, n*16), as_XMMRegister(n));
+        vextractf128_high(Address(rsp, n*16), as_XMMRegister(n));
       }
     }
 #endif
@@ -5665,7 +5665,7 @@
 #ifdef _LP64
     if (VM_Version::supports_evex()) {
       for (int n = 0; n < num_xmm_regs; n++) {
-        vextractf32x4h(Address(rsp, n*16), as_XMMRegister(n), 0);
+        vextractf32x4(Address(rsp, n*16), as_XMMRegister(n), 0);
       }
     } else {
       for (int n = 0; n < num_xmm_regs; n++) {
@@ -5753,7 +5753,7 @@
 #ifdef _LP64
   if (VM_Version::supports_evex()) {
     for (int n = 0; n < num_xmm_regs; n++) {
-      vinsertf32x4h(as_XMMRegister(n), Address(rsp, n*16), 0);
+      vinsertf32x4(as_XMMRegister(n), as_XMMRegister(n), Address(rsp, n*16), 0);
     }
   } else {
     for (int n = 0; n < num_xmm_regs; n++) {
@@ -5771,12 +5771,12 @@
     if (MaxVectorSize > 16) {
       // Restore upper half of YMM registers.
       for (int n = 0; n < num_xmm_regs; n++) {
-        vinsertf128h(as_XMMRegister(n), Address(rsp, n*16));
+        vinsertf128_high(as_XMMRegister(n), Address(rsp, n*16));
       }
       addptr(rsp, 16*num_xmm_regs);
       if(UseAVX > 2) {
         for (int n = 0; n < num_xmm_regs; n++) {
-          vinsertf64x4h(as_XMMRegister(n), Address(rsp, n*32), 1);
+          vinsertf64x4_high(as_XMMRegister(n), Address(rsp, n*32));
         }
         addptr(rsp, 32*num_xmm_regs);
       }
@@ -7198,21 +7198,50 @@
 
 }
 
-void MacroAssembler::clear_mem(Register base, Register cnt, Register tmp) {
+void MacroAssembler::clear_mem(Register base, Register cnt, Register tmp, bool is_large) {
   // cnt - number of qwords (8-byte words).
   // base - start address, qword aligned.
+  // is_large - if optimizers know cnt is larger than InitArrayShortSize
   assert(base==rdi, "base register must be edi for rep stos");
   assert(tmp==rax,   "tmp register must be eax for rep stos");
   assert(cnt==rcx,   "cnt register must be ecx for rep stos");
+  assert(InitArrayShortSize % BytesPerLong == 0,
+    "InitArrayShortSize should be the multiple of BytesPerLong");
+
+  Label DONE;
 
   xorptr(tmp, tmp);
+
+  if (!is_large) {
+    Label LOOP, LONG;
+    cmpptr(cnt, InitArrayShortSize/BytesPerLong);
+    jccb(Assembler::greater, LONG);
+
+    NOT_LP64(shlptr(cnt, 1);) // convert to number of 32-bit words for 32-bit VM
+
+    decrement(cnt);
+    jccb(Assembler::negative, DONE); // Zero length
+
+    // Use individual pointer-sized stores for small counts:
+    BIND(LOOP);
+    movptr(Address(base, cnt, Address::times_ptr), tmp);
+    decrement(cnt);
+    jccb(Assembler::greaterEqual, LOOP);
+    jmpb(DONE);
+
+    BIND(LONG);
+  }
+
+  // Use longer rep-prefixed ops for non-small counts:
   if (UseFastStosb) {
-    shlptr(cnt,3); // convert to number of bytes
+    shlptr(cnt, 3); // convert to number of bytes
     rep_stosb();
   } else {
-    NOT_LP64(shlptr(cnt,1);) // convert to number of dwords for 32-bit VM
+    NOT_LP64(shlptr(cnt, 1);) // convert to number of 32-bit words for 32-bit VM
     rep_stos();
   }
+
+  BIND(DONE);
 }
 
 #ifdef COMPILER2
--- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -48,7 +48,6 @@
   // This is the base routine called by the different versions of call_VM_leaf. The interpreter
   // may customize this version by overriding it for its purposes (e.g., to save/restore
   // additional registers when doing a VM call).
-#define COMMA ,
 
   virtual void call_VM_leaf_base(
     address entry_point,               // the entry point
@@ -903,35 +902,66 @@
   void ldmxcsr(Address src) { Assembler::ldmxcsr(src); }
   void ldmxcsr(AddressLiteral src);
 
+  void fast_sha1(XMMRegister abcd, XMMRegister e0, XMMRegister e1, XMMRegister msg0,
+                 XMMRegister msg1, XMMRegister msg2, XMMRegister msg3, XMMRegister shuf_mask,
+                 Register buf, Register state, Register ofs, Register limit, Register rsp,
+                 bool multi_block);
+
+#ifdef _LP64
+  void fast_sha256(XMMRegister msg, XMMRegister state0, XMMRegister state1, XMMRegister msgtmp0,
+                   XMMRegister msgtmp1, XMMRegister msgtmp2, XMMRegister msgtmp3, XMMRegister msgtmp4,
+                   Register buf, Register state, Register ofs, Register limit, Register rsp,
+                   bool multi_block, XMMRegister shuf_mask);
+#else
+  void fast_sha256(XMMRegister msg, XMMRegister state0, XMMRegister state1, XMMRegister msgtmp0,
+                   XMMRegister msgtmp1, XMMRegister msgtmp2, XMMRegister msgtmp3, XMMRegister msgtmp4,
+                   Register buf, Register state, Register ofs, Register limit, Register rsp,
+                   bool multi_block);
+#endif
+
   void fast_exp(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3,
                 XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7,
                 Register rax, Register rcx, Register rdx, Register tmp);
 
+#ifdef _LP64
   void fast_log(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3,
                 XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7,
-                Register rax, Register rcx, Register rdx, Register tmp1 LP64_ONLY(COMMA Register tmp2));
+                Register rax, Register rcx, Register rdx, Register tmp1, Register tmp2);
 
   void fast_pow(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4,
                 XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register rax, Register rcx,
-                Register rdx NOT_LP64(COMMA  Register tmp) LP64_ONLY(COMMA  Register tmp1)
-                LP64_ONLY(COMMA  Register tmp2) LP64_ONLY(COMMA  Register tmp3) LP64_ONLY(COMMA  Register tmp4));
+                Register rdx, Register tmp1, Register tmp2, Register tmp3, Register tmp4);
 
   void fast_sin(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3,
                 XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7,
-                Register rax, Register rbx LP64_ONLY(COMMA  Register rcx), Register rdx
-                LP64_ONLY(COMMA Register tmp1) LP64_ONLY(COMMA Register tmp2)
-                LP64_ONLY(COMMA Register tmp3) LP64_ONLY(COMMA Register tmp4));
+                Register rax, Register rbx, Register rcx, Register rdx, Register tmp1, Register tmp2,
+                Register tmp3, Register tmp4);
 
   void fast_cos(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3,
                 XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7,
-                Register rax, Register rcx, Register rdx NOT_LP64(COMMA Register tmp)
-                LP64_ONLY(COMMA Register r8) LP64_ONLY(COMMA Register r9)
-                LP64_ONLY(COMMA Register r10) LP64_ONLY(COMMA Register r11));
+                Register rax, Register rcx, Register rdx, Register tmp1,
+                Register tmp2, Register tmp3, Register tmp4);
+#else
+  void fast_log(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3,
+                XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7,
+                Register rax, Register rcx, Register rdx, Register tmp1);
 
-#ifndef _LP64
+  void fast_pow(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4,
+                XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register rax, Register rcx,
+                Register rdx, Register tmp);
+
+  void fast_sin(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3,
+                XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7,
+                Register rax, Register rbx, Register rdx);
+
+  void fast_cos(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3,
+                XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7,
+                Register rax, Register rcx, Register rdx, Register tmp);
+
   void libm_sincos_huge(XMMRegister xmm0, XMMRegister xmm1, Register eax, Register ecx,
                         Register edx, Register ebx, Register esi, Register edi,
                         Register ebp, Register esp);
+
   void libm_reduce_pi04l(Register eax, Register ecx, Register edx, Register ebx,
                          Register esi, Register edi, Register ebp, Register esp);
 #endif
@@ -1185,13 +1215,130 @@
   void vpxor(XMMRegister dst, XMMRegister src) { Assembler::vpxor(dst, dst, src, true); }
   void vpxor(XMMRegister dst, Address src) { Assembler::vpxor(dst, dst, src, true); }
 
-  // Move packed integer values from low 128 bit to hign 128 bit in 256 bit vector.
-  void vinserti128h(XMMRegister dst, XMMRegister nds, XMMRegister src) {
-    if (UseAVX > 1) // vinserti128h is available only in AVX2
-      Assembler::vinserti128h(dst, nds, src);
-    else
-      Assembler::vinsertf128h(dst, nds, src);
+  void vinserti128(XMMRegister dst, XMMRegister nds, XMMRegister src, uint8_t imm8) {
+    if (UseAVX > 1) { // vinserti128 is available only in AVX2
+      Assembler::vinserti128(dst, nds, src, imm8);
+    } else {
+      Assembler::vinsertf128(dst, nds, src, imm8);
+    }
+  }
+
+  void vinserti128(XMMRegister dst, XMMRegister nds, Address src, uint8_t imm8) {
+    if (UseAVX > 1) { // vinserti128 is available only in AVX2
+      Assembler::vinserti128(dst, nds, src, imm8);
+    } else {
+      Assembler::vinsertf128(dst, nds, src, imm8);
+    }
+  }
+
+  void vextracti128(XMMRegister dst, XMMRegister src, uint8_t imm8) {
+    if (UseAVX > 1) { // vextracti128 is available only in AVX2
+      Assembler::vextracti128(dst, src, imm8);
+    } else {
+      Assembler::vextractf128(dst, src, imm8);
+    }
+  }
+
+  void vextracti128(Address dst, XMMRegister src, uint8_t imm8) {
+    if (UseAVX > 1) { // vextracti128 is available only in AVX2
+      Assembler::vextracti128(dst, src, imm8);
+    } else {
+      Assembler::vextractf128(dst, src, imm8);
+    }
+  }
+
+  // 128bit copy to/from high 128 bits of 256bit (YMM) vector registers
+  void vinserti128_high(XMMRegister dst, XMMRegister src) {
+    vinserti128(dst, dst, src, 1);
+  }
+  void vinserti128_high(XMMRegister dst, Address src) {
+    vinserti128(dst, dst, src, 1);
+  }
+  void vextracti128_high(XMMRegister dst, XMMRegister src) {
+    vextracti128(dst, src, 1);
+  }
+  void vextracti128_high(Address dst, XMMRegister src) {
+    vextracti128(dst, src, 1);
+  }
+  void vinsertf128_high(XMMRegister dst, XMMRegister src) {
+    vinsertf128(dst, dst, src, 1);
+  }
+  void vinsertf128_high(XMMRegister dst, Address src) {
+    vinsertf128(dst, dst, src, 1);
+  }
+  void vextractf128_high(XMMRegister dst, XMMRegister src) {
+    vextractf128(dst, src, 1);
+  }
+  void vextractf128_high(Address dst, XMMRegister src) {
+    vextractf128(dst, src, 1);
+  }
+
+  // 256bit copy to/from high 256 bits of 512bit (ZMM) vector registers
+  void vinserti64x4_high(XMMRegister dst, XMMRegister src) {
+    vinserti64x4(dst, dst, src, 1);
   }
+  void vinsertf64x4_high(XMMRegister dst, XMMRegister src) {
+    vinsertf64x4(dst, dst, src, 1);
+  }
+  void vextracti64x4_high(XMMRegister dst, XMMRegister src) {
+    vextracti64x4(dst, src, 1);
+  }
+  void vextractf64x4_high(XMMRegister dst, XMMRegister src) {
+    vextractf64x4(dst, src, 1);
+  }
+  void vextractf64x4_high(Address dst, XMMRegister src) {
+    vextractf64x4(dst, src, 1);
+  }
+  void vinsertf64x4_high(XMMRegister dst, Address src) {
+    vinsertf64x4(dst, dst, src, 1);
+  }
+
+  // 128bit copy to/from low 128 bits of 256bit (YMM) vector registers
+  void vinserti128_low(XMMRegister dst, XMMRegister src) {
+    vinserti128(dst, dst, src, 0);
+  }
+  void vinserti128_low(XMMRegister dst, Address src) {
+    vinserti128(dst, dst, src, 0);
+  }
+  void vextracti128_low(XMMRegister dst, XMMRegister src) {
+    vextracti128(dst, src, 0);
+  }
+  void vextracti128_low(Address dst, XMMRegister src) {
+    vextracti128(dst, src, 0);
+  }
+  void vinsertf128_low(XMMRegister dst, XMMRegister src) {
+    vinsertf128(dst, dst, src, 0);
+  }
+  void vinsertf128_low(XMMRegister dst, Address src) {
+    vinsertf128(dst, dst, src, 0);
+  }
+  void vextractf128_low(XMMRegister dst, XMMRegister src) {
+    vextractf128(dst, src, 0);
+  }
+  void vextractf128_low(Address dst, XMMRegister src) {
+    vextractf128(dst, src, 0);
+  }
+
+  // 256bit copy to/from low 256 bits of 512bit (ZMM) vector registers
+  void vinserti64x4_low(XMMRegister dst, XMMRegister src) {
+    vinserti64x4(dst, dst, src, 0);
+  }
+  void vinsertf64x4_low(XMMRegister dst, XMMRegister src) {
+    vinsertf64x4(dst, dst, src, 0);
+  }
+  void vextracti64x4_low(XMMRegister dst, XMMRegister src) {
+    vextracti64x4(dst, src, 0);
+  }
+  void vextractf64x4_low(XMMRegister dst, XMMRegister src) {
+    vextractf64x4(dst, src, 0);
+  }
+  void vextractf64x4_low(Address dst, XMMRegister src) {
+    vextractf64x4(dst, src, 0);
+  }
+  void vinsertf64x4_low(XMMRegister dst, Address src) {
+    vinsertf64x4(dst, dst, src, 0);
+  }
+
 
   // Carry-Less Multiplication Quadword
   void vpclmulldq(XMMRegister dst, XMMRegister nds, XMMRegister src) {
@@ -1284,8 +1431,9 @@
   // C2 compiled method's prolog code.
   void verified_entry(int framesize, int stack_bang_size, bool fp_mode_24b);
 
-  // clear memory of size 'cnt' qwords, starting at 'base'.
-  void clear_mem(Register base, Register cnt, Register rtmp);
+  // clear memory of size 'cnt' qwords, starting at 'base';
+  // if 'is_large' is set, do not try to produce short loop
+  void clear_mem(Register base, Register cnt, Register rtmp, bool is_large);
 
 #ifdef COMPILER2
   void string_indexof_char(Register str1, Register cnt1, Register ch, Register result,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86_sha.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,495 @@
+/*
+* Copyright (c) 2016, Intel Corporation.
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* This code is free software; you can redistribute it and/or modify it
+* under the terms of the GNU General Public License version 2 only, as
+* published by the Free Software Foundation.
+*
+* This code is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+* version 2 for more details (a copy is included in the LICENSE file that
+* accompanied this code).
+*
+* You should have received a copy of the GNU General Public License version
+* 2 along with this work; if not, write to the Free Software Foundation,
+* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+*
+* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+* or visit www.oracle.com if you need additional information or have any
+* questions.
+*
+*/
+
+#include "precompiled.hpp"
+#include "asm/assembler.hpp"
+#include "asm/assembler.inline.hpp"
+#include "runtime/stubRoutines.hpp"
+#include "macroAssembler_x86.hpp"
+
+// ofs and limit are used for multi-block byte array.
+// int com.sun.security.provider.DigestBase.implCompressMultiBlock(byte[] b, int ofs, int limit)
+void MacroAssembler::fast_sha1(XMMRegister abcd, XMMRegister e0, XMMRegister e1, XMMRegister msg0,
+  XMMRegister msg1, XMMRegister msg2, XMMRegister msg3, XMMRegister shuf_mask,
+  Register buf, Register state, Register ofs, Register limit, Register rsp, bool multi_block) {
+
+  Label start, done_hash, loop0;
+
+  address upper_word_mask = StubRoutines::x86::upper_word_mask_addr();
+  address shuffle_byte_flip_mask = StubRoutines::x86::shuffle_byte_flip_mask_addr();
+
+  bind(start);
+  movdqu(abcd, Address(state, 0));
+  pinsrd(e0, Address(state, 16), 3);
+  movdqu(shuf_mask, ExternalAddress(upper_word_mask)); // 0xFFFFFFFF000000000000000000000000
+  pand(e0, shuf_mask);
+  pshufd(abcd, abcd, 0x1B);
+  movdqu(shuf_mask, ExternalAddress(shuffle_byte_flip_mask)); //0x000102030405060708090a0b0c0d0e0f
+
+  bind(loop0);
+  // Save hash values for addition after rounds
+  movdqu(Address(rsp, 0), e0);
+  movdqu(Address(rsp, 16), abcd);
+
+
+  // Rounds 0 - 3
+  movdqu(msg0, Address(buf, 0));
+  pshufb(msg0, shuf_mask);
+  paddd(e0, msg0);
+  movdqa(e1, abcd);
+  sha1rnds4(abcd, e0, 0);
+
+  // Rounds 4 - 7
+  movdqu(msg1, Address(buf, 16));
+  pshufb(msg1, shuf_mask);
+  sha1nexte(e1, msg1);
+  movdqa(e0, abcd);
+  sha1rnds4(abcd, e1, 0);
+  sha1msg1(msg0, msg1);
+
+  // Rounds 8 - 11
+  movdqu(msg2, Address(buf, 32));
+  pshufb(msg2, shuf_mask);
+  sha1nexte(e0, msg2);
+  movdqa(e1, abcd);
+  sha1rnds4(abcd, e0, 0);
+  sha1msg1(msg1, msg2);
+  pxor(msg0, msg2);
+
+  // Rounds 12 - 15
+  movdqu(msg3, Address(buf, 48));
+  pshufb(msg3, shuf_mask);
+  sha1nexte(e1, msg3);
+  movdqa(e0, abcd);
+  sha1msg2(msg0, msg3);
+  sha1rnds4(abcd, e1, 0);
+  sha1msg1(msg2, msg3);
+  pxor(msg1, msg3);
+
+  // Rounds 16 - 19
+  sha1nexte(e0, msg0);
+  movdqa(e1, abcd);
+  sha1msg2(msg1, msg0);
+  sha1rnds4(abcd, e0, 0);
+  sha1msg1(msg3, msg0);
+  pxor(msg2, msg0);
+
+  // Rounds 20 - 23
+  sha1nexte(e1, msg1);
+  movdqa(e0, abcd);
+  sha1msg2(msg2, msg1);
+  sha1rnds4(abcd, e1, 1);
+  sha1msg1(msg0, msg1);
+  pxor(msg3, msg1);
+
+  // Rounds 24 - 27
+  sha1nexte(e0, msg2);
+  movdqa(e1, abcd);
+  sha1msg2(msg3, msg2);
+  sha1rnds4(abcd, e0, 1);
+  sha1msg1(msg1, msg2);
+  pxor(msg0, msg2);
+
+  // Rounds 28 - 31
+  sha1nexte(e1, msg3);
+  movdqa(e0, abcd);
+  sha1msg2(msg0, msg3);
+  sha1rnds4(abcd, e1, 1);
+  sha1msg1(msg2, msg3);
+  pxor(msg1, msg3);
+
+  // Rounds 32 - 35
+  sha1nexte(e0, msg0);
+  movdqa(e1, abcd);
+  sha1msg2(msg1, msg0);
+  sha1rnds4(abcd, e0, 1);
+  sha1msg1(msg3, msg0);
+  pxor(msg2, msg0);
+
+  // Rounds 36 - 39
+  sha1nexte(e1, msg1);
+  movdqa(e0, abcd);
+  sha1msg2(msg2, msg1);
+  sha1rnds4(abcd, e1, 1);
+  sha1msg1(msg0, msg1);
+  pxor(msg3, msg1);
+
+  // Rounds 40 - 43
+  sha1nexte(e0, msg2);
+  movdqa(e1, abcd);
+  sha1msg2(msg3, msg2);
+  sha1rnds4(abcd, e0, 2);
+  sha1msg1(msg1, msg2);
+  pxor(msg0, msg2);
+
+  // Rounds 44 - 47
+  sha1nexte(e1, msg3);
+  movdqa(e0, abcd);
+  sha1msg2(msg0, msg3);
+  sha1rnds4(abcd, e1, 2);
+  sha1msg1(msg2, msg3);
+  pxor(msg1, msg3);
+
+  // Rounds 48 - 51
+  sha1nexte(e0, msg0);
+  movdqa(e1, abcd);
+  sha1msg2(msg1, msg0);
+  sha1rnds4(abcd, e0, 2);
+  sha1msg1(msg3, msg0);
+  pxor(msg2, msg0);
+
+  // Rounds 52 - 55
+  sha1nexte(e1, msg1);
+  movdqa(e0, abcd);
+  sha1msg2(msg2, msg1);
+  sha1rnds4(abcd, e1, 2);
+  sha1msg1(msg0, msg1);
+  pxor(msg3, msg1);
+
+  // Rounds 56 - 59
+  sha1nexte(e0, msg2);
+  movdqa(e1, abcd);
+  sha1msg2(msg3, msg2);
+  sha1rnds4(abcd, e0, 2);
+  sha1msg1(msg1, msg2);
+  pxor(msg0, msg2);
+
+  // Rounds 60 - 63
+  sha1nexte(e1, msg3);
+  movdqa(e0, abcd);
+  sha1msg2(msg0, msg3);
+  sha1rnds4(abcd, e1, 3);
+  sha1msg1(msg2, msg3);
+  pxor(msg1, msg3);
+
+  // Rounds 64 - 67
+  sha1nexte(e0, msg0);
+  movdqa(e1, abcd);
+  sha1msg2(msg1, msg0);
+  sha1rnds4(abcd, e0, 3);
+  sha1msg1(msg3, msg0);
+  pxor(msg2, msg0);
+
+  // Rounds 68 - 71
+  sha1nexte(e1, msg1);
+  movdqa(e0, abcd);
+  sha1msg2(msg2, msg1);
+  sha1rnds4(abcd, e1, 3);
+  pxor(msg3, msg1);
+
+  // Rounds 72 - 75
+  sha1nexte(e0, msg2);
+  movdqa(e1, abcd);
+  sha1msg2(msg3, msg2);
+  sha1rnds4(abcd, e0, 3);
+
+  // Rounds 76 - 79
+  sha1nexte(e1, msg3);
+  movdqa(e0, abcd);
+  sha1rnds4(abcd, e1, 3);
+
+  // add current hash values with previously saved
+  movdqu(msg0, Address(rsp, 0));
+  sha1nexte(e0, msg0);
+  movdqu(msg0, Address(rsp, 16));
+  paddd(abcd, msg0);
+
+  if (multi_block) {
+    // increment data pointer and loop if more to process
+    addptr(buf, 64);
+    addptr(ofs, 64);
+    cmpptr(ofs, limit);
+    jcc(Assembler::belowEqual, loop0);
+    movptr(rax, ofs); //return ofs
+  }
+  // write hash values back in the correct order
+  pshufd(abcd, abcd, 0x1b);
+  movdqu(Address(state, 0), abcd);
+  pextrd(Address(state, 16), e0, 3);
+
+  bind(done_hash);
+
+}
+
+// xmm0 (msg) is used as an implicit argument to sh256rnds2
+// and state0 and state1 can never use xmm0 register.
+// ofs and limit are used for multi-block byte array.
+// int com.sun.security.provider.DigestBase.implCompressMultiBlock(byte[] b, int ofs, int limit)
+#ifdef _LP64
+void MacroAssembler::fast_sha256(XMMRegister msg, XMMRegister state0, XMMRegister state1, XMMRegister msgtmp0,
+  XMMRegister msgtmp1, XMMRegister msgtmp2, XMMRegister msgtmp3, XMMRegister msgtmp4,
+  Register buf, Register state, Register ofs, Register limit, Register rsp,
+  bool multi_block, XMMRegister shuf_mask) {
+#else
+void MacroAssembler::fast_sha256(XMMRegister msg, XMMRegister state0, XMMRegister state1, XMMRegister msgtmp0,
+  XMMRegister msgtmp1, XMMRegister msgtmp2, XMMRegister msgtmp3, XMMRegister msgtmp4,
+  Register buf, Register state, Register ofs, Register limit, Register rsp,
+  bool multi_block) {
+#endif
+  Label start, done_hash, loop0;
+
+  address K256 = StubRoutines::x86::k256_addr();
+  address pshuffle_byte_flip_mask = StubRoutines::x86::pshuffle_byte_flip_mask_addr();
+
+  bind(start);
+  movdqu(state0, Address(state, 0));
+  movdqu(state1, Address(state, 16));
+
+  pshufd(state0, state0, 0xB1);
+  pshufd(state1, state1, 0x1B);
+  movdqa(msgtmp4, state0);
+  palignr(state0, state1, 8);
+  pblendw(state1, msgtmp4, 0xF0);
+
+#ifdef _LP64
+  movdqu(shuf_mask, ExternalAddress(pshuffle_byte_flip_mask));
+#endif
+  lea(rax, ExternalAddress(K256));
+
+  bind(loop0);
+  movdqu(Address(rsp, 0), state0);
+  movdqu(Address(rsp, 16), state1);
+
+  // Rounds 0-3
+  movdqu(msg, Address(buf, 0));
+#ifdef _LP64
+  pshufb(msg, shuf_mask);
+#else
+  pshufb(msg, ExternalAddress(pshuffle_byte_flip_mask));
+#endif
+  movdqa(msgtmp0, msg);
+  paddd(msg, Address(rax, 0));
+  sha256rnds2(state1, state0);
+  pshufd(msg, msg, 0x0E);
+  sha256rnds2(state0, state1);
+
+  // Rounds 4-7
+  movdqu(msg, Address(buf, 16));
+#ifdef _LP64
+  pshufb(msg, shuf_mask);
+#else
+  pshufb(msg, ExternalAddress(pshuffle_byte_flip_mask));
+#endif
+  movdqa(msgtmp1, msg);
+  paddd(msg, Address(rax, 16));
+  sha256rnds2(state1, state0);
+  pshufd(msg, msg, 0x0E);
+  sha256rnds2(state0, state1);
+  sha256msg1(msgtmp0, msgtmp1);
+
+  // Rounds 8-11
+  movdqu(msg, Address(buf, 32));
+#ifdef _LP64
+  pshufb(msg, shuf_mask);
+#else
+  pshufb(msg, ExternalAddress(pshuffle_byte_flip_mask));
+#endif
+  movdqa(msgtmp2, msg);
+  paddd(msg, Address(rax, 32));
+  sha256rnds2(state1, state0);
+  pshufd(msg, msg, 0x0E);
+  sha256rnds2(state0, state1);
+  sha256msg1(msgtmp1, msgtmp2);
+
+  // Rounds 12-15
+  movdqu(msg, Address(buf, 48));
+#ifdef _LP64
+  pshufb(msg, shuf_mask);
+#else
+  pshufb(msg, ExternalAddress(pshuffle_byte_flip_mask));
+#endif
+  movdqa(msgtmp3, msg);
+  paddd(msg, Address(rax, 48));
+  sha256rnds2(state1, state0);
+  movdqa(msgtmp4, msgtmp3);
+  palignr(msgtmp4, msgtmp2, 4);
+  paddd(msgtmp0, msgtmp4);
+  sha256msg2(msgtmp0, msgtmp3);
+  pshufd(msg, msg, 0x0E);
+  sha256rnds2(state0, state1);
+  sha256msg1(msgtmp2, msgtmp3);
+
+  // Rounds 16-19
+  movdqa(msg, msgtmp0);
+  paddd(msg, Address(rax, 64));
+  sha256rnds2(state1, state0);
+  movdqa(msgtmp4, msgtmp0);
+  palignr(msgtmp4, msgtmp3, 4);
+  paddd(msgtmp1, msgtmp4);
+  sha256msg2(msgtmp1, msgtmp0);
+  pshufd(msg, msg, 0x0E);
+  sha256rnds2(state0, state1);
+  sha256msg1(msgtmp3, msgtmp0);
+
+  // Rounds 20-23
+  movdqa(msg, msgtmp1);
+  paddd(msg, Address(rax, 80));
+  sha256rnds2(state1, state0);
+  movdqa(msgtmp4, msgtmp1);
+  palignr(msgtmp4, msgtmp0, 4);
+  paddd(msgtmp2, msgtmp4);
+  sha256msg2(msgtmp2, msgtmp1);
+  pshufd(msg, msg, 0x0E);
+  sha256rnds2(state0, state1);
+  sha256msg1(msgtmp0, msgtmp1);
+
+  // Rounds 24-27
+  movdqa(msg, msgtmp2);
+  paddd(msg, Address(rax, 96));
+  sha256rnds2(state1, state0);
+  movdqa(msgtmp4, msgtmp2);
+  palignr(msgtmp4, msgtmp1, 4);
+  paddd(msgtmp3, msgtmp4);
+  sha256msg2(msgtmp3, msgtmp2);
+  pshufd(msg, msg, 0x0E);
+  sha256rnds2(state0, state1);
+  sha256msg1(msgtmp1, msgtmp2);
+
+  // Rounds 28-31
+  movdqa(msg, msgtmp3);
+  paddd(msg, Address(rax, 112));
+  sha256rnds2(state1, state0);
+  movdqa(msgtmp4, msgtmp3);
+  palignr(msgtmp4, msgtmp2, 4);
+  paddd(msgtmp0, msgtmp4);
+  sha256msg2(msgtmp0, msgtmp3);
+  pshufd(msg, msg, 0x0E);
+  sha256rnds2(state0, state1);
+  sha256msg1(msgtmp2, msgtmp3);
+
+  // Rounds 32-35
+  movdqa(msg, msgtmp0);
+  paddd(msg, Address(rax, 128));
+  sha256rnds2(state1, state0);
+  movdqa(msgtmp4, msgtmp0);
+  palignr(msgtmp4, msgtmp3, 4);
+  paddd(msgtmp1, msgtmp4);
+  sha256msg2(msgtmp1, msgtmp0);
+  pshufd(msg, msg, 0x0E);
+  sha256rnds2(state0, state1);
+  sha256msg1(msgtmp3, msgtmp0);
+
+  // Rounds 36-39
+  movdqa(msg, msgtmp1);
+  paddd(msg, Address(rax, 144));
+  sha256rnds2(state1, state0);
+  movdqa(msgtmp4, msgtmp1);
+  palignr(msgtmp4, msgtmp0, 4);
+  paddd(msgtmp2, msgtmp4);
+  sha256msg2(msgtmp2, msgtmp1);
+  pshufd(msg, msg, 0x0E);
+  sha256rnds2(state0, state1);
+  sha256msg1(msgtmp0, msgtmp1);
+
+  // Rounds 40-43
+  movdqa(msg, msgtmp2);
+  paddd(msg, Address(rax, 160));
+  sha256rnds2(state1, state0);
+  movdqa(msgtmp4, msgtmp2);
+  palignr(msgtmp4, msgtmp1, 4);
+  paddd(msgtmp3, msgtmp4);
+  sha256msg2(msgtmp3, msgtmp2);
+  pshufd(msg, msg, 0x0E);
+  sha256rnds2(state0, state1);
+  sha256msg1(msgtmp1, msgtmp2);
+
+  // Rounds 44-47
+  movdqa(msg, msgtmp3);
+  paddd(msg, Address(rax, 176));
+  sha256rnds2(state1, state0);
+  movdqa(msgtmp4, msgtmp3);
+  palignr(msgtmp4, msgtmp2, 4);
+  paddd(msgtmp0, msgtmp4);
+  sha256msg2(msgtmp0, msgtmp3);
+  pshufd(msg, msg, 0x0E);
+  sha256rnds2(state0, state1);
+  sha256msg1(msgtmp2, msgtmp3);
+
+  // Rounds 48-51
+  movdqa(msg, msgtmp0);
+  paddd(msg, Address(rax, 192));
+  sha256rnds2(state1, state0);
+  movdqa(msgtmp4, msgtmp0);
+  palignr(msgtmp4, msgtmp3, 4);
+  paddd(msgtmp1, msgtmp4);
+  sha256msg2(msgtmp1, msgtmp0);
+  pshufd(msg, msg, 0x0E);
+  sha256rnds2(state0, state1);
+  sha256msg1(msgtmp3, msgtmp0);
+
+  // Rounds 52-55
+  movdqa(msg, msgtmp1);
+  paddd(msg, Address(rax, 208));
+  sha256rnds2(state1, state0);
+  movdqa(msgtmp4, msgtmp1);
+  palignr(msgtmp4, msgtmp0, 4);
+  paddd(msgtmp2, msgtmp4);
+  sha256msg2(msgtmp2, msgtmp1);
+  pshufd(msg, msg, 0x0E);
+  sha256rnds2(state0, state1);
+
+  // Rounds 56-59
+  movdqa(msg, msgtmp2);
+  paddd(msg, Address(rax, 224));
+  sha256rnds2(state1, state0);
+  movdqa(msgtmp4, msgtmp2);
+  palignr(msgtmp4, msgtmp1, 4);
+  paddd(msgtmp3, msgtmp4);
+  sha256msg2(msgtmp3, msgtmp2);
+  pshufd(msg, msg, 0x0E);
+  sha256rnds2(state0, state1);
+
+  // Rounds 60-63
+  movdqa(msg, msgtmp3);
+  paddd(msg, Address(rax, 240));
+  sha256rnds2(state1, state0);
+  pshufd(msg, msg, 0x0E);
+  sha256rnds2(state0, state1);
+  movdqu(msg, Address(rsp, 0));
+  paddd(state0, msg);
+  movdqu(msg, Address(rsp, 16));
+  paddd(state1, msg);
+
+  if (multi_block) {
+    // increment data pointer and loop if more to process
+    addptr(buf, 64);
+    addptr(ofs, 64);
+    cmpptr(ofs, limit);
+    jcc(Assembler::belowEqual, loop0);
+    movptr(rax, ofs); //return ofs
+  }
+
+  pshufd(state0, state0, 0x1B);
+  pshufd(state1, state1, 0xB1);
+  movdqa(msgtmp4, state0);
+  pblendw(state0, state1, 0xF0);
+  palignr(state1, msgtmp4, 8);
+
+  movdqu(Address(state, 0), state0);
+  movdqu(Address(state, 16), state1);
+
+  bind(done_hash);
+
+}
--- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -208,13 +208,13 @@
     __ subptr(rsp, ymm_bytes);
     // Save upper half of YMM registers
     for (int n = 0; n < num_xmm_regs; n++) {
-      __ vextractf128h(Address(rsp, n*16), as_XMMRegister(n));
+      __ vextractf128_high(Address(rsp, n*16), as_XMMRegister(n));
     }
     if (UseAVX > 2) {
       __ subptr(rsp, zmm_bytes);
       // Save upper half of ZMM registers
       for (int n = 0; n < num_xmm_regs; n++) {
-        __ vextractf64x4h(Address(rsp, n*32), as_XMMRegister(n), 1);
+        __ vextractf64x4_high(Address(rsp, n*32), as_XMMRegister(n));
       }
     }
   }
@@ -304,13 +304,13 @@
     if (UseAVX > 2) {
       // Restore upper half of ZMM registers.
       for (int n = 0; n < num_xmm_regs; n++) {
-        __ vinsertf64x4h(as_XMMRegister(n), Address(rsp, n*32), 1);
+        __ vinsertf64x4_high(as_XMMRegister(n), Address(rsp, n*32));
       }
       __ addptr(rsp, zmm_bytes);
     }
     // Restore upper half of YMM registers.
     for (int n = 0; n < num_xmm_regs; n++) {
-      __ vinsertf128h(as_XMMRegister(n), Address(rsp, n*16));
+      __ vinsertf128_high(as_XMMRegister(n), Address(rsp, n*16));
     }
     __ addptr(rsp, ymm_bytes);
   }
--- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -179,13 +179,13 @@
     // Save upper half of YMM registers(0..15)
     int base_addr = XSAVE_AREA_YMM_BEGIN;
     for (int n = 0; n < 16; n++) {
-      __ vextractf128h(Address(rsp, base_addr+n*16), as_XMMRegister(n));
+      __ vextractf128_high(Address(rsp, base_addr+n*16), as_XMMRegister(n));
     }
     if (VM_Version::supports_evex()) {
       // Save upper half of ZMM registers(0..15)
       base_addr = XSAVE_AREA_ZMM_BEGIN;
       for (int n = 0; n < 16; n++) {
-        __ vextractf64x4h(Address(rsp, base_addr+n*32), as_XMMRegister(n), 1);
+        __ vextractf64x4_high(Address(rsp, base_addr+n*32), as_XMMRegister(n));
       }
       // Save full ZMM registers(16..num_xmm_regs)
       base_addr = XSAVE_AREA_UPPERBANK;
@@ -333,13 +333,13 @@
     // Restore upper half of YMM registers (0..15)
     int base_addr = XSAVE_AREA_YMM_BEGIN;
     for (int n = 0; n < 16; n++) {
-      __ vinsertf128h(as_XMMRegister(n), Address(rsp,  base_addr+n*16));
+      __ vinsertf128_high(as_XMMRegister(n), Address(rsp, base_addr+n*16));
     }
     if (VM_Version::supports_evex()) {
       // Restore upper half of ZMM registers (0..15)
       base_addr = XSAVE_AREA_ZMM_BEGIN;
       for (int n = 0; n < 16; n++) {
-        __ vinsertf64x4h(as_XMMRegister(n), Address(rsp, base_addr+n*32), 1);
+        __ vinsertf64x4_high(as_XMMRegister(n), Address(rsp, base_addr+n*32));
       }
       // Restore full ZMM registers(16..num_xmm_regs)
       base_addr = XSAVE_AREA_UPPERBANK;
--- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -3068,6 +3068,136 @@
     return start;
   }
 
+  address generate_upper_word_mask() {
+    __ align(64);
+    StubCodeMark mark(this, "StubRoutines", "upper_word_mask");
+    address start = __ pc();
+    __ emit_data(0x00000000, relocInfo::none, 0);
+    __ emit_data(0x00000000, relocInfo::none, 0);
+    __ emit_data(0x00000000, relocInfo::none, 0);
+    __ emit_data(0xFFFFFFFF, relocInfo::none, 0);
+    return start;
+  }
+
+  address generate_shuffle_byte_flip_mask() {
+    __ align(64);
+    StubCodeMark mark(this, "StubRoutines", "shuffle_byte_flip_mask");
+    address start = __ pc();
+    __ emit_data(0x0c0d0e0f, relocInfo::none, 0);
+    __ emit_data(0x08090a0b, relocInfo::none, 0);
+    __ emit_data(0x04050607, relocInfo::none, 0);
+    __ emit_data(0x00010203, relocInfo::none, 0);
+    return start;
+  }
+
+  // ofs and limit are use for multi-block byte array.
+  // int com.sun.security.provider.DigestBase.implCompressMultiBlock(byte[] b, int ofs, int limit)
+  address generate_sha1_implCompress(bool multi_block, const char *name) {
+    __ align(CodeEntryAlignment);
+    StubCodeMark mark(this, "StubRoutines", name);
+    address start = __ pc();
+
+    Register buf   = rax;
+    Register state = rdx;
+    Register ofs   = rcx;
+    Register limit = rdi;
+
+    const Address  buf_param(rbp, 8 + 0);
+    const Address  state_param(rbp, 8 + 4);
+    const Address  ofs_param(rbp, 8 + 8);
+    const Address  limit_param(rbp, 8 + 12);
+
+    const XMMRegister abcd = xmm0;
+    const XMMRegister e0 = xmm1;
+    const XMMRegister e1 = xmm2;
+    const XMMRegister msg0 = xmm3;
+
+    const XMMRegister msg1 = xmm4;
+    const XMMRegister msg2 = xmm5;
+    const XMMRegister msg3 = xmm6;
+    const XMMRegister shuf_mask = xmm7;
+
+    __ enter();
+    __ subptr(rsp, 8 * wordSize);
+    if (multi_block) {
+      __ push(limit);
+    }
+    __ movptr(buf, buf_param);
+    __ movptr(state, state_param);
+    if (multi_block) {
+      __ movptr(ofs, ofs_param);
+      __ movptr(limit, limit_param);
+    }
+
+    __ fast_sha1(abcd, e0, e1, msg0, msg1, msg2, msg3, shuf_mask,
+      buf, state, ofs, limit, rsp, multi_block);
+
+    if (multi_block) {
+      __ pop(limit);
+    }
+    __ addptr(rsp, 8 * wordSize);
+    __ leave();
+    __ ret(0);
+    return start;
+  }
+
+  address generate_pshuffle_byte_flip_mask() {
+    __ align(64);
+    StubCodeMark mark(this, "StubRoutines", "pshuffle_byte_flip_mask");
+    address start = __ pc();
+    __ emit_data(0x00010203, relocInfo::none, 0);
+    __ emit_data(0x04050607, relocInfo::none, 0);
+    __ emit_data(0x08090a0b, relocInfo::none, 0);
+    __ emit_data(0x0c0d0e0f, relocInfo::none, 0);
+    return start;
+  }
+
+  // ofs and limit are use for multi-block byte array.
+  // int com.sun.security.provider.DigestBase.implCompressMultiBlock(byte[] b, int ofs, int limit)
+ address generate_sha256_implCompress(bool multi_block, const char *name) {
+    __ align(CodeEntryAlignment);
+    StubCodeMark mark(this, "StubRoutines", name);
+    address start = __ pc();
+
+    Register buf = rbx;
+    Register state = rsi;
+    Register ofs = rdx;
+    Register limit = rcx;
+
+    const Address  buf_param(rbp, 8 + 0);
+    const Address  state_param(rbp, 8 + 4);
+    const Address  ofs_param(rbp, 8 + 8);
+    const Address  limit_param(rbp, 8 + 12);
+
+    const XMMRegister msg = xmm0;
+    const XMMRegister state0 = xmm1;
+    const XMMRegister state1 = xmm2;
+    const XMMRegister msgtmp0 = xmm3;
+
+    const XMMRegister msgtmp1 = xmm4;
+    const XMMRegister msgtmp2 = xmm5;
+    const XMMRegister msgtmp3 = xmm6;
+    const XMMRegister msgtmp4 = xmm7;
+
+    __ enter();
+    __ subptr(rsp, 8 * wordSize);
+    handleSOERegisters(true /*saving*/);
+    __ movptr(buf, buf_param);
+    __ movptr(state, state_param);
+    if (multi_block) {
+     __ movptr(ofs, ofs_param);
+     __ movptr(limit, limit_param);
+    }
+
+    __ fast_sha256(msg, state0, state1, msgtmp0, msgtmp1, msgtmp2, msgtmp3, msgtmp4,
+      buf, state, ofs, limit, rsp, multi_block);
+
+    handleSOERegisters(false);
+    __ addptr(rsp, 8 * wordSize);
+    __ leave();
+    __ ret(0);
+    return start;
+  }
 
   // byte swap x86 long
   address generate_ghash_long_swap_mask() {
@@ -3772,6 +3902,19 @@
       StubRoutines::_counterMode_AESCrypt = generate_counterMode_AESCrypt_Parallel();
     }
 
+    if (UseSHA1Intrinsics) {
+      StubRoutines::x86::_upper_word_mask_addr = generate_upper_word_mask();
+      StubRoutines::x86::_shuffle_byte_flip_mask_addr = generate_shuffle_byte_flip_mask();
+      StubRoutines::_sha1_implCompress = generate_sha1_implCompress(false, "sha1_implCompress");
+      StubRoutines::_sha1_implCompressMB = generate_sha1_implCompress(true, "sha1_implCompressMB");
+    }
+    if (UseSHA256Intrinsics) {
+      StubRoutines::x86::_k256_adr = (address)StubRoutines::x86::_k256;
+      StubRoutines::x86::_pshuffle_byte_flip_mask_addr = generate_pshuffle_byte_flip_mask();
+      StubRoutines::_sha256_implCompress = generate_sha256_implCompress(false, "sha256_implCompress");
+      StubRoutines::_sha256_implCompressMB = generate_sha256_implCompress(true, "sha256_implCompressMB");
+    }
+
     // Generate GHASH intrinsics code
     if (UseGHASHIntrinsics) {
       StubRoutines::x86::_ghash_long_swap_mask_addr = generate_ghash_long_swap_mask();
--- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -275,7 +275,7 @@
     }
     if (VM_Version::supports_evex()) {
       for (int i = xmm_save_first; i <= last_reg; i++) {
-        __ vextractf32x4h(xmm_save(i), as_XMMRegister(i), 0);
+        __ vextractf32x4(xmm_save(i), as_XMMRegister(i), 0);
       }
     } else {
       for (int i = xmm_save_first; i <= last_reg; i++) {
@@ -393,7 +393,7 @@
     // emit the restores for xmm regs
     if (VM_Version::supports_evex()) {
       for (int i = xmm_save_first; i <= last_reg; i++) {
-        __ vinsertf32x4h(as_XMMRegister(i), xmm_save(i), 0);
+        __ vinsertf32x4(as_XMMRegister(i), as_XMMRegister(i), xmm_save(i), 0);
       }
     } else {
       for (int i = xmm_save_first; i <= last_reg; i++) {
@@ -3695,6 +3695,133 @@
     return start;
   }
 
+  address generate_upper_word_mask() {
+    __ align(64);
+    StubCodeMark mark(this, "StubRoutines", "upper_word_mask");
+    address start = __ pc();
+    __ emit_data64(0x0000000000000000, relocInfo::none);
+    __ emit_data64(0xFFFFFFFF00000000, relocInfo::none);
+    return start;
+  }
+
+  address generate_shuffle_byte_flip_mask() {
+    __ align(64);
+    StubCodeMark mark(this, "StubRoutines", "shuffle_byte_flip_mask");
+    address start = __ pc();
+    __ emit_data64(0x08090a0b0c0d0e0f, relocInfo::none);
+    __ emit_data64(0x0001020304050607, relocInfo::none);
+    return start;
+  }
+
+  // ofs and limit are use for multi-block byte array.
+  // int com.sun.security.provider.DigestBase.implCompressMultiBlock(byte[] b, int ofs, int limit)
+  address generate_sha1_implCompress(bool multi_block, const char *name) {
+    __ align(CodeEntryAlignment);
+    StubCodeMark mark(this, "StubRoutines", name);
+    address start = __ pc();
+
+    Register buf = c_rarg0;
+    Register state = c_rarg1;
+    Register ofs = c_rarg2;
+    Register limit = c_rarg3;
+
+    const XMMRegister abcd = xmm0;
+    const XMMRegister e0 = xmm1;
+    const XMMRegister e1 = xmm2;
+    const XMMRegister msg0 = xmm3;
+
+    const XMMRegister msg1 = xmm4;
+    const XMMRegister msg2 = xmm5;
+    const XMMRegister msg3 = xmm6;
+    const XMMRegister shuf_mask = xmm7;
+
+    __ enter();
+
+#ifdef _WIN64
+    // save the xmm registers which must be preserved 6-7
+    __ subptr(rsp, 4 * wordSize);
+    __ movdqu(Address(rsp, 0), xmm6);
+    __ movdqu(Address(rsp, 2 * wordSize), xmm7);
+#endif
+
+    __ subptr(rsp, 4 * wordSize);
+
+    __ fast_sha1(abcd, e0, e1, msg0, msg1, msg2, msg3, shuf_mask,
+      buf, state, ofs, limit, rsp, multi_block);
+
+    __ addptr(rsp, 4 * wordSize);
+#ifdef _WIN64
+    // restore xmm regs belonging to calling function
+    __ movdqu(xmm6, Address(rsp, 0));
+    __ movdqu(xmm7, Address(rsp, 2 * wordSize));
+    __ addptr(rsp, 4 * wordSize);
+#endif
+
+    __ leave();
+    __ ret(0);
+    return start;
+  }
+
+  address generate_pshuffle_byte_flip_mask() {
+    __ align(64);
+    StubCodeMark mark(this, "StubRoutines", "pshuffle_byte_flip_mask");
+    address start = __ pc();
+    __ emit_data64(0x0405060700010203, relocInfo::none);
+    __ emit_data64(0x0c0d0e0f08090a0b, relocInfo::none);
+    return start;
+  }
+
+// ofs and limit are use for multi-block byte array.
+// int com.sun.security.provider.DigestBase.implCompressMultiBlock(byte[] b, int ofs, int limit)
+  address generate_sha256_implCompress(bool multi_block, const char *name) {
+    __ align(CodeEntryAlignment);
+    StubCodeMark mark(this, "StubRoutines", name);
+    address start = __ pc();
+
+    Register buf = c_rarg0;
+    Register state = c_rarg1;
+    Register ofs = c_rarg2;
+    Register limit = c_rarg3;
+
+    const XMMRegister msg = xmm0;
+    const XMMRegister state0 = xmm1;
+    const XMMRegister state1 = xmm2;
+    const XMMRegister msgtmp0 = xmm3;
+
+    const XMMRegister msgtmp1 = xmm4;
+    const XMMRegister msgtmp2 = xmm5;
+    const XMMRegister msgtmp3 = xmm6;
+    const XMMRegister msgtmp4 = xmm7;
+
+    const XMMRegister shuf_mask = xmm8;
+
+    __ enter();
+#ifdef _WIN64
+    // save the xmm registers which must be preserved 6-7
+    __ subptr(rsp, 6 * wordSize);
+    __ movdqu(Address(rsp, 0), xmm6);
+    __ movdqu(Address(rsp, 2 * wordSize), xmm7);
+    __ movdqu(Address(rsp, 4 * wordSize), xmm8);
+#endif
+
+    __ subptr(rsp, 4 * wordSize);
+
+    __ fast_sha256(msg, state0, state1, msgtmp0, msgtmp1, msgtmp2, msgtmp3, msgtmp4,
+      buf, state, ofs, limit, rsp, multi_block, shuf_mask);
+
+    __ addptr(rsp, 4 * wordSize);
+#ifdef _WIN64
+    // restore xmm regs belonging to calling function
+    __ movdqu(xmm6, Address(rsp, 0));
+    __ movdqu(xmm7, Address(rsp, 2 * wordSize));
+    __ movdqu(xmm8, Address(rsp, 4 * wordSize));
+    __ addptr(rsp, 6 * wordSize);
+#endif
+    __ leave();
+    __ ret(0);
+    return start;
+  }
+
   // This is a version of CTR/AES crypt which does 6 blocks in a loop at a time
   // to hide instruction latency
   //
@@ -4974,6 +5101,19 @@
       StubRoutines::_counterMode_AESCrypt = generate_counterMode_AESCrypt_Parallel();
     }
 
+    if (UseSHA1Intrinsics) {
+      StubRoutines::x86::_upper_word_mask_addr = generate_upper_word_mask();
+      StubRoutines::x86::_shuffle_byte_flip_mask_addr = generate_shuffle_byte_flip_mask();
+      StubRoutines::_sha1_implCompress = generate_sha1_implCompress(false, "sha1_implCompress");
+      StubRoutines::_sha1_implCompressMB = generate_sha1_implCompress(true, "sha1_implCompressMB");
+    }
+    if (UseSHA256Intrinsics) {
+      StubRoutines::x86::_k256_adr = (address)StubRoutines::x86::_k256;
+      StubRoutines::x86::_pshuffle_byte_flip_mask_addr = generate_pshuffle_byte_flip_mask();
+      StubRoutines::_sha256_implCompress = generate_sha256_implCompress(false, "sha256_implCompress");
+      StubRoutines::_sha256_implCompressMB = generate_sha256_implCompress(true, "sha256_implCompressMB");
+    }
+
     // Generate GHASH intrinsics code
     if (UseGHASHIntrinsics) {
       StubRoutines::x86::_ghash_long_swap_mask_addr = generate_ghash_long_swap_mask();
--- a/hotspot/src/cpu/x86/vm/stubRoutines_x86.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/stubRoutines_x86.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -29,6 +29,12 @@
 #include "runtime/thread.inline.hpp"
 #include "crc32c.h"
 
+#ifdef _MSC_VER
+#define ALIGNED_(x) __declspec(align(x))
+#else
+#define ALIGNED_(x) __attribute__ ((aligned(x)))
+#endif
+
 // Implementation of the platform-specific part of StubRoutines - for
 // a description of how to extend it, see the stubRoutines.hpp file.
 
@@ -37,6 +43,10 @@
 address StubRoutines::x86::_counter_shuffle_mask_addr = NULL;
 address StubRoutines::x86::_ghash_long_swap_mask_addr = NULL;
 address StubRoutines::x86::_ghash_byte_swap_mask_addr = NULL;
+address StubRoutines::x86::_upper_word_mask_addr = NULL;
+address StubRoutines::x86::_shuffle_byte_flip_mask_addr = NULL;
+address StubRoutines::x86::_k256_adr = NULL;
+address StubRoutines::x86::_pshuffle_byte_flip_mask_addr = NULL;
 
 uint64_t StubRoutines::x86::_crc_by128_masks[] =
 {
@@ -236,3 +246,23 @@
     _crc32c_table = (juint*)pclmulqdq_table;
   }
 }
+
+ALIGNED_(64) juint StubRoutines::x86::_k256[] =
+{
+    0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL,
+    0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL,
+    0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL,
+    0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, 0xc19bf174UL,
+    0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL,
+    0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL,
+    0x983e5152UL, 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL,
+    0xc6e00bf3UL, 0xd5a79147UL, 0x06ca6351UL, 0x14292967UL,
+    0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, 0x53380d13UL,
+    0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL,
+    0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL,
+    0xd192e819UL, 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL,
+    0x19a4c116UL, 0x1e376c08UL, 0x2748774cUL, 0x34b0bcb5UL,
+    0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, 0x682e6ff3UL,
+    0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL,
+    0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL
+};
--- a/hotspot/src/cpu/x86/vm/stubRoutines_x86.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/stubRoutines_x86.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -46,6 +46,17 @@
   static address _ghash_long_swap_mask_addr;
   static address _ghash_byte_swap_mask_addr;
 
+  // upper word mask for sha1
+  static address _upper_word_mask_addr;
+  // byte flip mask for sha1
+  static address _shuffle_byte_flip_mask_addr;
+
+  //k256 table for sha256
+  static juint _k256[];
+  static address _k256_adr;
+  // byte flip mask for sha256
+  static address _pshuffle_byte_flip_mask_addr;
+
  public:
   static address verify_mxcsr_entry()    { return _verify_mxcsr_entry; }
   static address key_shuffle_mask_addr() { return _key_shuffle_mask_addr; }
@@ -53,5 +64,9 @@
   static address crc_by128_masks_addr()  { return (address)_crc_by128_masks; }
   static address ghash_long_swap_mask_addr() { return _ghash_long_swap_mask_addr; }
   static address ghash_byte_swap_mask_addr() { return _ghash_byte_swap_mask_addr; }
+  static address upper_word_mask_addr() { return _upper_word_mask_addr; }
+  static address shuffle_byte_flip_mask_addr() { return _shuffle_byte_flip_mask_addr; }
+  static address k256_addr()      { return _k256_adr; }
+  static address pshuffle_byte_flip_mask_addr() { return _pshuffle_byte_flip_mask_addr; }
   static void generate_CRC32C_table(bool is_pclmulqdq_supported);
 #endif // CPU_X86_VM_STUBROUTINES_X86_32_HPP
--- a/hotspot/src/cpu/x86/vm/vmStructs_x86.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/vmStructs_x86.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -68,10 +68,11 @@
   declare_constant(VM_Version::CPU_AVX512DQ)                        \
   declare_constant(VM_Version::CPU_AVX512PF)                        \
   declare_constant(VM_Version::CPU_AVX512ER)                        \
-  declare_constant(VM_Version::CPU_AVX512CD)                        \
-  declare_constant(VM_Version::CPU_AVX512BW)
+  declare_constant(VM_Version::CPU_AVX512CD)
 
 #define VM_LONG_CONSTANTS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) \
-  declare_preprocessor_constant("VM_Version::CPU_AVX512VL", CPU_AVX512VL)
+  declare_preprocessor_constant("VM_Version::CPU_AVX512BW", CPU_AVX512BW) \
+  declare_preprocessor_constant("VM_Version::CPU_AVX512VL", CPU_AVX512VL) \
+  declare_preprocessor_constant("VM_Version::CPU_SHA", CPU_SHA)
 
 #endif // CPU_X86_VM_VMSTRUCTS_X86_HPP
--- a/hotspot/src/cpu/x86/vm/vm_version_x86.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -385,7 +385,7 @@
 
     __ movdl(xmm0, rcx);
     __ pshufd(xmm0, xmm0, 0x00);
-    __ vinsertf128h(xmm0, xmm0, xmm0);
+    __ vinsertf128_high(xmm0, xmm0);
     __ vmovdqu(xmm7, xmm0);
 #ifdef _LP64
     __ vmovdqu(xmm8, xmm0);
@@ -577,7 +577,7 @@
   }
 
   char buf[256];
-  jio_snprintf(buf, sizeof(buf), "(%u cores per cpu, %u threads per core) family %d model %d stepping %d%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
+  jio_snprintf(buf, sizeof(buf), "(%u cores per cpu, %u threads per core) family %d model %d stepping %d%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
                cores_per_cpu(), threads_per_core(),
                cpu_family(), _model, _stepping,
                (supports_cmov() ? ", cmov" : ""),
@@ -608,7 +608,8 @@
                (supports_bmi1() ? ", bmi1" : ""),
                (supports_bmi2() ? ", bmi2" : ""),
                (supports_adx() ? ", adx" : ""),
-               (supports_evex() ? ", evex" : ""));
+               (supports_evex() ? ", evex" : ""),
+               (supports_sha() ? ", sha" : ""));
   _features_string = os::strdup(buf);
 
   // UseSSE is set to the smaller of what hardware supports and what
@@ -730,17 +731,29 @@
     FLAG_SET_DEFAULT(UseGHASHIntrinsics, false);
   }
 
-  if (UseSHA) {
+  if (supports_sha()) {
+    if (FLAG_IS_DEFAULT(UseSHA)) {
+      UseSHA = true;
+    }
+  } else if (UseSHA) {
     warning("SHA instructions are not available on this CPU");
     FLAG_SET_DEFAULT(UseSHA, false);
   }
 
-  if (UseSHA1Intrinsics) {
+  if (UseSHA) {
+    if (FLAG_IS_DEFAULT(UseSHA1Intrinsics)) {
+      FLAG_SET_DEFAULT(UseSHA1Intrinsics, true);
+    }
+  } else if (UseSHA1Intrinsics) {
     warning("Intrinsics for SHA-1 crypto hash functions not available on this CPU.");
     FLAG_SET_DEFAULT(UseSHA1Intrinsics, false);
   }
 
-  if (UseSHA256Intrinsics) {
+  if (UseSHA) {
+    if (FLAG_IS_DEFAULT(UseSHA256Intrinsics)) {
+      FLAG_SET_DEFAULT(UseSHA256Intrinsics, true);
+    }
+  } else if (UseSHA256Intrinsics) {
     warning("Intrinsics for SHA-224 and SHA-256 crypto hash functions not available on this CPU.");
     FLAG_SET_DEFAULT(UseSHA256Intrinsics, false);
   }
@@ -750,6 +763,10 @@
     FLAG_SET_DEFAULT(UseSHA512Intrinsics, false);
   }
 
+  if (!(UseSHA1Intrinsics || UseSHA256Intrinsics || UseSHA512Intrinsics)) {
+    FLAG_SET_DEFAULT(UseSHA, false);
+  }
+
   if (UseAdler32Intrinsics) {
     warning("Adler32Intrinsics not available on this CPU.");
     FLAG_SET_DEFAULT(UseAdler32Intrinsics, false);
--- a/hotspot/src/cpu/x86/vm/vm_version_x86.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/vm_version_x86.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -221,7 +221,7 @@
                avx512pf : 1,
                avx512er : 1,
                avx512cd : 1,
-                        : 1,
+                    sha : 1,
                avx512bw : 1,
                avx512vl : 1;
     } bits;
@@ -282,11 +282,13 @@
     CPU_AVX512DQ = (1 << 27),
     CPU_AVX512PF = (1 << 28),
     CPU_AVX512ER = (1 << 29),
-    CPU_AVX512CD = (1 << 30),
-    CPU_AVX512BW = (1 << 31)
+    CPU_AVX512CD = (1 << 30)
+    // Keeping sign bit 31 unassigned.
   };
 
-#define CPU_AVX512VL UCONST64(0x100000000) // EVEX instructions with smaller vector length : enums are limited to 32bit
+#define CPU_AVX512BW ((uint64_t)UCONST64(0x100000000)) // enums are limited to 31 bit
+#define CPU_AVX512VL ((uint64_t)UCONST64(0x200000000)) // EVEX instructions with smaller vector length
+#define CPU_SHA ((uint64_t)UCONST64(0x400000000))      // SHA instructions
 
   enum Extended_Family {
     // AMD
@@ -516,6 +518,8 @@
          result |= CPU_ADX;
       if(_cpuid_info.sef_cpuid7_ebx.bits.bmi2 != 0)
         result |= CPU_BMI2;
+      if (_cpuid_info.sef_cpuid7_ebx.bits.sha != 0)
+        result |= CPU_SHA;
       if(_cpuid_info.ext_cpuid1_ecx.bits.lzcnt_intel != 0)
         result |= CPU_LZCNT;
       // for Intel, ecx.bits.misalignsse bit (bit 8) indicates support for prefetchw
@@ -721,6 +725,7 @@
   static bool supports_avx512nobw() { return (supports_evex() && !supports_avx512bw()); }
   static bool supports_avx256only() { return (supports_avx2() && !supports_evex()); }
   static bool supports_avxonly()    { return ((supports_avx2() || supports_avx()) && !supports_evex()); }
+  static bool supports_sha()        { return (_features & CPU_SHA) != 0; }
   // Intel features
   static bool is_intel_family_core() { return is_intel() &&
                                        extended_cpu_family() == CPU_FAMILY_INTEL_CORE; }
--- a/hotspot/src/cpu/x86/vm/x86.ad	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/x86.ad	Mon Mar 28 08:41:54 2016 -0700
@@ -3179,13 +3179,13 @@
             "punpcklbw $dst,$dst\n\t"
             "pshuflw $dst,$dst,0x00\n\t"
             "punpcklqdq $dst,$dst\n\t"
-            "vinserti128h $dst,$dst,$dst\t! replicate32B" %}
+            "vinserti128_high $dst,$dst\t! replicate32B" %}
   ins_encode %{
     __ movdl($dst$$XMMRegister, $src$$Register);
     __ punpcklbw($dst$$XMMRegister, $dst$$XMMRegister);
     __ pshuflw($dst$$XMMRegister, $dst$$XMMRegister, 0x00);
     __ punpcklqdq($dst$$XMMRegister, $dst$$XMMRegister);
-    __ vinserti128h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister);
+    __ vinserti128_high($dst$$XMMRegister, $dst$$XMMRegister);
   %}
   ins_pipe( pipe_slow );
 %}
@@ -3196,12 +3196,12 @@
   format %{ "punpcklbw $dst,$mem\n\t"
             "pshuflw $dst,$dst,0x00\n\t"
             "punpcklqdq $dst,$dst\n\t"
-            "vinserti128h $dst,$dst,$dst\t! replicate32B" %}
+            "vinserti128_high $dst,$dst\t! replicate32B" %}
   ins_encode %{
     __ punpcklbw($dst$$XMMRegister, $mem$$Address);
     __ pshuflw($dst$$XMMRegister, $dst$$XMMRegister, 0x00);
     __ punpcklqdq($dst$$XMMRegister, $dst$$XMMRegister);
-    __ vinserti128h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister);
+    __ vinserti128_high($dst$$XMMRegister, $dst$$XMMRegister);
   %}
   ins_pipe( pipe_slow );
 %}
@@ -3223,11 +3223,11 @@
   match(Set dst (ReplicateB con));
   format %{ "movq    $dst,[$constantaddress]\n\t"
             "punpcklqdq $dst,$dst\n\t"
-            "vinserti128h $dst,$dst,$dst\t! lreplicate32B($con)" %}
+            "vinserti128_high $dst,$dst\t! lreplicate32B($con)" %}
   ins_encode %{
     __ movq($dst$$XMMRegister, $constantaddress(replicate8_imm($con$$constant, 1)));
     __ punpcklqdq($dst$$XMMRegister, $dst$$XMMRegister);
-    __ vinserti128h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister);
+    __ vinserti128_high($dst$$XMMRegister, $dst$$XMMRegister);
   %}
   ins_pipe( pipe_slow );
 %}
@@ -3298,12 +3298,12 @@
   format %{ "movd    $dst,$src\n\t"
             "pshuflw $dst,$dst,0x00\n\t"
             "punpcklqdq $dst,$dst\n\t"
-            "vinserti128h $dst,$dst,$dst\t! replicate16S" %}
+            "vinserti128_high $dst,$dst\t! replicate16S" %}
   ins_encode %{
     __ movdl($dst$$XMMRegister, $src$$Register);
     __ pshuflw($dst$$XMMRegister, $dst$$XMMRegister, 0x00);
     __ punpcklqdq($dst$$XMMRegister, $dst$$XMMRegister);
-    __ vinserti128h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister);
+    __ vinserti128_high($dst$$XMMRegister, $dst$$XMMRegister);
   %}
   ins_pipe( pipe_slow );
 %}
@@ -3313,11 +3313,11 @@
   match(Set dst (ReplicateS (LoadS mem)));
   format %{ "pshuflw $dst,$mem,0x00\n\t"
             "punpcklqdq $dst,$dst\n\t"
-            "vinserti128h $dst,$dst,$dst\t! replicate16S" %}
+            "vinserti128_high $dst,$dst\t! replicate16S" %}
   ins_encode %{
     __ pshuflw($dst$$XMMRegister, $mem$$Address, 0x00);
     __ punpcklqdq($dst$$XMMRegister, $dst$$XMMRegister);
-    __ vinserti128h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister);
+    __ vinserti128_high($dst$$XMMRegister, $dst$$XMMRegister);
   %}
   ins_pipe( pipe_slow );
 %}
@@ -3327,11 +3327,11 @@
   match(Set dst (ReplicateS con));
   format %{ "movq    $dst,[$constantaddress]\n\t"
             "punpcklqdq $dst,$dst\n\t"
-            "vinserti128h $dst,$dst,$dst\t! replicate16S($con)" %}
+            "vinserti128_high $dst,$dst\t! replicate16S($con)" %}
   ins_encode %{
     __ movq($dst$$XMMRegister, $constantaddress(replicate8_imm($con$$constant, 2)));
     __ punpcklqdq($dst$$XMMRegister, $dst$$XMMRegister);
-    __ vinserti128h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister);
+    __ vinserti128_high($dst$$XMMRegister, $dst$$XMMRegister);
   %}
   ins_pipe( pipe_slow );
 %}
@@ -3363,11 +3363,11 @@
   match(Set dst (ReplicateI src));
   format %{ "movd    $dst,$src\n\t"
             "pshufd  $dst,$dst,0x00\n\t"
-            "vinserti128h $dst,$dst,$dst\t! replicate8I" %}
+            "vinserti128_high $dst,$dst\t! replicate8I" %}
   ins_encode %{
     __ movdl($dst$$XMMRegister, $src$$Register);
     __ pshufd($dst$$XMMRegister, $dst$$XMMRegister, 0x00);
-    __ vinserti128h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister);
+    __ vinserti128_high($dst$$XMMRegister, $dst$$XMMRegister);
   %}
   ins_pipe( pipe_slow );
 %}
@@ -3376,10 +3376,10 @@
   predicate(n->as_Vector()->length() == 8 && !VM_Version::supports_avx512vl());
   match(Set dst (ReplicateI (LoadI mem)));
   format %{ "pshufd  $dst,$mem,0x00\n\t"
-            "vinserti128h $dst,$dst,$dst\t! replicate8I" %}
+            "vinserti128_high $dst,$dst\t! replicate8I" %}
   ins_encode %{
     __ pshufd($dst$$XMMRegister, $mem$$Address, 0x00);
-    __ vinserti128h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister);
+    __ vinserti128_high($dst$$XMMRegister, $dst$$XMMRegister);
   %}
   ins_pipe( pipe_slow );
 %}
@@ -3401,11 +3401,11 @@
   match(Set dst (ReplicateI con));
   format %{ "movq    $dst,[$constantaddress]\t! replicate8I($con)\n\t"
             "punpcklqdq $dst,$dst\n\t"
-            "vinserti128h $dst,$dst,$dst" %}
+            "vinserti128_high $dst,$dst" %}
   ins_encode %{
     __ movq($dst$$XMMRegister, $constantaddress(replicate8_imm($con$$constant, 4)));
     __ punpcklqdq($dst$$XMMRegister, $dst$$XMMRegister);
-    __ vinserti128h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister);
+    __ vinserti128_high($dst$$XMMRegister, $dst$$XMMRegister);
   %}
   ins_pipe( pipe_slow );
 %}
@@ -3430,11 +3430,11 @@
   match(Set dst (ReplicateL src));
   format %{ "movdq   $dst,$src\n\t"
             "punpcklqdq $dst,$dst\n\t"
-            "vinserti128h $dst,$dst,$dst\t! replicate4L" %}
+            "vinserti128_high $dst,$dst\t! replicate4L" %}
   ins_encode %{
     __ movdq($dst$$XMMRegister, $src$$Register);
     __ punpcklqdq($dst$$XMMRegister, $dst$$XMMRegister);
-    __ vinserti128h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister);
+    __ vinserti128_high($dst$$XMMRegister, $dst$$XMMRegister);
   %}
   ins_pipe( pipe_slow );
 %}
@@ -3447,13 +3447,13 @@
             "movdl   $tmp,$src.hi\n\t"
             "punpckldq $dst,$tmp\n\t"
             "punpcklqdq $dst,$dst\n\t"
-            "vinserti128h $dst,$dst,$dst\t! replicate4L" %}
+            "vinserti128_high $dst,$dst\t! replicate4L" %}
   ins_encode %{
     __ movdl($dst$$XMMRegister, $src$$Register);
     __ movdl($tmp$$XMMRegister, HIGH_FROM_LOW($src$$Register));
     __ punpckldq($dst$$XMMRegister, $tmp$$XMMRegister);
     __ punpcklqdq($dst$$XMMRegister, $dst$$XMMRegister);
-    __ vinserti128h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister);
+    __ vinserti128_high($dst$$XMMRegister, $dst$$XMMRegister);
   %}
   ins_pipe( pipe_slow );
 %}
@@ -3464,11 +3464,11 @@
   match(Set dst (ReplicateL con));
   format %{ "movq    $dst,[$constantaddress]\n\t"
             "punpcklqdq $dst,$dst\n\t"
-            "vinserti128h $dst,$dst,$dst\t! replicate4L($con)" %}
+            "vinserti128_high $dst,$dst\t! replicate4L($con)" %}
   ins_encode %{
     __ movq($dst$$XMMRegister, $constantaddress($con));
     __ punpcklqdq($dst$$XMMRegister, $dst$$XMMRegister);
-    __ vinserti128h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister);
+    __ vinserti128_high($dst$$XMMRegister, $dst$$XMMRegister);
   %}
   ins_pipe( pipe_slow );
 %}
@@ -3478,11 +3478,11 @@
   match(Set dst (ReplicateL (LoadL mem)));
   format %{ "movq    $dst,$mem\n\t"
             "punpcklqdq $dst,$dst\n\t"
-            "vinserti128h $dst,$dst,$dst\t! replicate4L" %}
+            "vinserti128_high $dst,$dst\t! replicate4L" %}
   ins_encode %{
     __ movq($dst$$XMMRegister, $mem$$Address);
     __ punpcklqdq($dst$$XMMRegister, $dst$$XMMRegister);
-    __ vinserti128h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister);
+    __ vinserti128_high($dst$$XMMRegister, $dst$$XMMRegister);
   %}
   ins_pipe( pipe_slow );
 %}
@@ -3511,10 +3511,10 @@
   predicate(n->as_Vector()->length() == 8 && !VM_Version::supports_avx512vl());
   match(Set dst (ReplicateF src));
   format %{ "pshufd  $dst,$src,0x00\n\t"
-            "vinsertf128h $dst,$dst,$dst\t! replicate8F" %}
+            "vinsertf128_high $dst,$dst\t! replicate8F" %}
   ins_encode %{
     __ pshufd($dst$$XMMRegister, $src$$XMMRegister, 0x00);
-    __ vinsertf128h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister);
+    __ vinsertf128_high($dst$$XMMRegister, $dst$$XMMRegister);
   %}
   ins_pipe( pipe_slow );
 %}
@@ -3523,10 +3523,10 @@
   predicate(n->as_Vector()->length() == 8 && !VM_Version::supports_avx512vl());
   match(Set dst (ReplicateF (LoadF mem)));
   format %{ "pshufd  $dst,$mem,0x00\n\t"
-            "vinsertf128h $dst,$dst,$dst\t! replicate8F" %}
+            "vinsertf128_high $dst,$dst\t! replicate8F" %}
   ins_encode %{
     __ pshufd($dst$$XMMRegister, $mem$$Address, 0x00);
-    __ vinsertf128h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister);
+    __ vinsertf128_high($dst$$XMMRegister, $dst$$XMMRegister);
   %}
   ins_pipe( pipe_slow );
 %}
@@ -3576,10 +3576,10 @@
   predicate(n->as_Vector()->length() == 4 && !VM_Version::supports_avx512vl());
   match(Set dst (ReplicateD src));
   format %{ "pshufd  $dst,$src,0x44\n\t"
-            "vinsertf128h $dst,$dst,$dst\t! replicate4D" %}
+            "vinsertf128_high $dst,$dst\t! replicate4D" %}
   ins_encode %{
     __ pshufd($dst$$XMMRegister, $src$$XMMRegister, 0x44);
-    __ vinsertf128h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister);
+    __ vinsertf128_high($dst$$XMMRegister, $dst$$XMMRegister);
   %}
   ins_pipe( pipe_slow );
 %}
@@ -3588,10 +3588,10 @@
   predicate(n->as_Vector()->length() == 4 && !VM_Version::supports_avx512vl());
   match(Set dst (ReplicateD (LoadD mem)));
   format %{ "pshufd  $dst,$mem,0x44\n\t"
-            "vinsertf128h $dst,$dst,$dst\t! replicate4D" %}
+            "vinsertf128_high $dst,$dst\t! replicate4D" %}
   ins_encode %{
     __ pshufd($dst$$XMMRegister, $mem$$Address, 0x44);
-    __ vinsertf128h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister);
+    __ vinsertf128_high($dst$$XMMRegister, $dst$$XMMRegister);
   %}
   ins_pipe( pipe_slow );
 %}
@@ -4791,7 +4791,7 @@
   effect(TEMP tmp, TEMP tmp2);
   format %{ "vphaddd  $tmp,$src2,$src2\n\t"
             "vphaddd  $tmp,$tmp,$tmp2\n\t"
-            "vextracti128  $tmp2,$tmp\n\t"
+            "vextracti128_high  $tmp2,$tmp\n\t"
             "vpaddd   $tmp,$tmp,$tmp2\n\t"
             "movd     $tmp2,$src1\n\t"
             "vpaddd   $tmp2,$tmp2,$tmp\n\t"
@@ -4800,7 +4800,7 @@
     int vector_len = 1;
     __ vphaddd($tmp$$XMMRegister, $src2$$XMMRegister, $src2$$XMMRegister, vector_len);
     __ vphaddd($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, vector_len);
-    __ vextracti128h($tmp2$$XMMRegister, $tmp$$XMMRegister);
+    __ vextracti128_high($tmp2$$XMMRegister, $tmp$$XMMRegister);
     __ vpaddd($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, 0);
     __ movdl($tmp2$$XMMRegister, $src1$$Register);
     __ vpaddd($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister, 0);
@@ -4813,7 +4813,7 @@
   predicate(UseAVX > 2);
   match(Set dst (AddReductionVI src1 src2));
   effect(TEMP tmp, TEMP tmp2);
-  format %{ "vextracti128  $tmp,$src2\n\t"
+  format %{ "vextracti128_high  $tmp,$src2\n\t"
             "vpaddd  $tmp,$tmp,$src2\n\t"
             "pshufd  $tmp2,$tmp,0xE\n\t"
             "vpaddd  $tmp,$tmp,$tmp2\n\t"
@@ -4824,7 +4824,7 @@
             "movd    $dst,$tmp2\t! add reduction8I" %}
   ins_encode %{
     int vector_len = 0;
-    __ vextracti128h($tmp$$XMMRegister, $src2$$XMMRegister);
+    __ vextracti128_high($tmp$$XMMRegister, $src2$$XMMRegister);
     __ vpaddd($tmp$$XMMRegister, $tmp$$XMMRegister, $src2$$XMMRegister, vector_len);
     __ pshufd($tmp2$$XMMRegister, $tmp$$XMMRegister, 0xE);
     __ vpaddd($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, vector_len);
@@ -4841,9 +4841,9 @@
   predicate(UseAVX > 2);
   match(Set dst (AddReductionVI src1 src2));
   effect(TEMP tmp, TEMP tmp2, TEMP tmp3);
-  format %{ "vextracti64x4  $tmp3,$src2,0x1\n\t"
+  format %{ "vextracti64x4_high  $tmp3,$src2\n\t"
             "vpaddd  $tmp3,$tmp3,$src2\n\t"
-            "vextracti128   $tmp,$tmp3\n\t"
+            "vextracti128_high  $tmp,$tmp3\n\t"
             "vpaddd  $tmp,$tmp,$tmp3\n\t"
             "pshufd  $tmp2,$tmp,0xE\n\t"
             "vpaddd  $tmp,$tmp,$tmp2\n\t"
@@ -4853,9 +4853,9 @@
             "vpaddd  $tmp2,$tmp,$tmp2\n\t"
             "movd    $dst,$tmp2\t! mul reduction16I" %}
   ins_encode %{
-    __ vextracti64x4h($tmp3$$XMMRegister, $src2$$XMMRegister, 1);
+    __ vextracti64x4_high($tmp3$$XMMRegister, $src2$$XMMRegister);
     __ vpaddd($tmp3$$XMMRegister, $tmp3$$XMMRegister, $src2$$XMMRegister, 1);
-    __ vextracti128h($tmp$$XMMRegister, $tmp3$$XMMRegister);
+    __ vextracti128_high($tmp$$XMMRegister, $tmp3$$XMMRegister);
     __ vpaddd($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp3$$XMMRegister, 0);
     __ pshufd($tmp2$$XMMRegister, $tmp$$XMMRegister, 0xE);
     __ vpaddd($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, 0);
@@ -4892,7 +4892,7 @@
   predicate(UseAVX > 2);
   match(Set dst (AddReductionVL src1 src2));
   effect(TEMP tmp, TEMP tmp2);
-  format %{ "vextracti128  $tmp,$src2\n\t"
+  format %{ "vextracti128_high  $tmp,$src2\n\t"
             "vpaddq  $tmp2,$tmp,$src2\n\t"
             "pshufd  $tmp,$tmp2,0xE\n\t"
             "vpaddq  $tmp2,$tmp2,$tmp\n\t"
@@ -4900,7 +4900,7 @@
             "vpaddq  $tmp2,$tmp2,$tmp\n\t"
             "movdq   $dst,$tmp2\t! add reduction4L" %}
   ins_encode %{
-    __ vextracti128h($tmp$$XMMRegister, $src2$$XMMRegister);
+    __ vextracti128_high($tmp$$XMMRegister, $src2$$XMMRegister);
     __ vpaddq($tmp2$$XMMRegister, $tmp$$XMMRegister, $src2$$XMMRegister, 0);
     __ pshufd($tmp$$XMMRegister, $tmp2$$XMMRegister, 0xE);
     __ vpaddq($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister, 0);
@@ -4915,9 +4915,9 @@
   predicate(UseAVX > 2);
   match(Set dst (AddReductionVL src1 src2));
   effect(TEMP tmp, TEMP tmp2);
-  format %{ "vextracti64x4  $tmp2,$src2,0x1\n\t"
+  format %{ "vextracti64x4_high  $tmp2,$src2\n\t"
             "vpaddq  $tmp2,$tmp2,$src2\n\t"
-            "vextracti128   $tmp,$tmp2\n\t"
+            "vextracti128_high  $tmp,$tmp2\n\t"
             "vpaddq  $tmp2,$tmp2,$tmp\n\t"
             "pshufd  $tmp,$tmp2,0xE\n\t"
             "vpaddq  $tmp2,$tmp2,$tmp\n\t"
@@ -4925,9 +4925,9 @@
             "vpaddq  $tmp2,$tmp2,$tmp\n\t"
             "movdq   $dst,$tmp2\t! add reduction8L" %}
   ins_encode %{
-    __ vextracti64x4h($tmp2$$XMMRegister, $src2$$XMMRegister, 1);
+    __ vextracti64x4_high($tmp2$$XMMRegister, $src2$$XMMRegister);
     __ vpaddq($tmp2$$XMMRegister, $tmp2$$XMMRegister, $src2$$XMMRegister, 1);
-    __ vextracti128h($tmp$$XMMRegister, $tmp2$$XMMRegister);
+    __ vextracti128_high($tmp$$XMMRegister, $tmp2$$XMMRegister);
     __ vpaddq($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister, 0);
     __ pshufd($tmp$$XMMRegister, $tmp2$$XMMRegister, 0xE);
     __ vpaddq($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister, 0);
@@ -5026,7 +5026,7 @@
             "vaddss  $dst,$dst,$tmp\n\t"
             "pshufd  $tmp,$src2,0x03\n\t"
             "vaddss  $dst,$dst,$tmp\n\t"
-            "vextractf128  $tmp2,$src2\n\t"
+            "vextractf128_high  $tmp2,$src2\n\t"
             "vaddss  $dst,$dst,$tmp2\n\t"
             "pshufd  $tmp,$tmp2,0x01\n\t"
             "vaddss  $dst,$dst,$tmp\n\t"
@@ -5042,7 +5042,7 @@
     __ vaddss($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
     __ pshufd($tmp$$XMMRegister, $src2$$XMMRegister, 0x03);
     __ vaddss($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
-    __ vextractf128h($tmp2$$XMMRegister, $src2$$XMMRegister);
+    __ vextractf128_high($tmp2$$XMMRegister, $src2$$XMMRegister);
     __ vaddss($dst$$XMMRegister, $dst$$XMMRegister, $tmp2$$XMMRegister);
     __ pshufd($tmp$$XMMRegister, $tmp2$$XMMRegister, 0x01);
     __ vaddss($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
@@ -5065,7 +5065,7 @@
             "vaddss  $dst,$dst,$tmp\n\t"
             "pshufd  $tmp,$src2,0x03\n\t"
             "vaddss  $dst,$dst,$tmp\n\t"
-            "vextractf32x4  $tmp2,$src2, 0x1\n\t"
+            "vextractf32x4  $tmp2,$src2,0x1\n\t"
             "vaddss  $dst,$dst,$tmp2\n\t"
             "pshufd  $tmp,$tmp2,0x01\n\t"
             "vaddss  $dst,$dst,$tmp\n\t"
@@ -5073,7 +5073,7 @@
             "vaddss  $dst,$dst,$tmp\n\t"
             "pshufd  $tmp,$tmp2,0x03\n\t"
             "vaddss  $dst,$dst,$tmp\n\t"
-            "vextractf32x4  $tmp2,$src2, 0x2\n\t"
+            "vextractf32x4  $tmp2,$src2,0x2\n\t"
             "vaddss  $dst,$dst,$tmp2\n\t"
             "pshufd  $tmp,$tmp2,0x01\n\t"
             "vaddss  $dst,$dst,$tmp\n\t"
@@ -5081,7 +5081,7 @@
             "vaddss  $dst,$dst,$tmp\n\t"
             "pshufd  $tmp,$tmp2,0x03\n\t"
             "vaddss  $dst,$dst,$tmp\n\t"
-            "vextractf32x4  $tmp2,$src2, 0x3\n\t"
+            "vextractf32x4  $tmp2,$src2,0x3\n\t"
             "vaddss  $dst,$dst,$tmp2\n\t"
             "pshufd  $tmp,$tmp2,0x01\n\t"
             "vaddss  $dst,$dst,$tmp\n\t"
@@ -5097,7 +5097,7 @@
     __ vaddss($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
     __ pshufd($tmp$$XMMRegister, $src2$$XMMRegister, 0x03);
     __ vaddss($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
-    __ vextractf32x4h($tmp2$$XMMRegister, $src2$$XMMRegister, 0x1);
+    __ vextractf32x4($tmp2$$XMMRegister, $src2$$XMMRegister, 0x1);
     __ vaddss($dst$$XMMRegister, $dst$$XMMRegister, $tmp2$$XMMRegister);
     __ pshufd($tmp$$XMMRegister, $tmp2$$XMMRegister, 0x01);
     __ vaddss($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
@@ -5105,7 +5105,7 @@
     __ vaddss($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
     __ pshufd($tmp$$XMMRegister, $tmp2$$XMMRegister, 0x03);
     __ vaddss($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
-    __ vextractf32x4h($tmp2$$XMMRegister, $src2$$XMMRegister, 0x2);
+    __ vextractf32x4($tmp2$$XMMRegister, $src2$$XMMRegister, 0x2);
     __ vaddss($dst$$XMMRegister, $dst$$XMMRegister, $tmp2$$XMMRegister);
     __ pshufd($tmp$$XMMRegister, $tmp2$$XMMRegister, 0x01);
     __ vaddss($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
@@ -5113,7 +5113,7 @@
     __ vaddss($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
     __ pshufd($tmp$$XMMRegister, $tmp2$$XMMRegister, 0x03);
     __ vaddss($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
-    __ vextractf32x4h($tmp2$$XMMRegister, $src2$$XMMRegister, 0x3);
+    __ vextractf32x4($tmp2$$XMMRegister, $src2$$XMMRegister, 0x3);
     __ vaddss($dst$$XMMRegister, $dst$$XMMRegister, $tmp2$$XMMRegister);
     __ pshufd($tmp$$XMMRegister, $tmp2$$XMMRegister, 0x01);
     __ vaddss($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
@@ -5162,7 +5162,7 @@
   format %{ "vaddsd  $dst,$dst,$src2\n\t"
             "pshufd  $tmp,$src2,0xE\n\t"
             "vaddsd  $dst,$dst,$tmp\n\t"
-            "vextractf32x4h  $tmp2,$src2, 0x1\n\t"
+            "vextractf32x4  $tmp2,$src2,0x1\n\t"
             "vaddsd  $dst,$dst,$tmp2\n\t"
             "pshufd  $tmp,$tmp2,0xE\n\t"
             "vaddsd  $dst,$dst,$tmp\t! add reduction4D" %}
@@ -5170,7 +5170,7 @@
     __ vaddsd($dst$$XMMRegister, $dst$$XMMRegister, $src2$$XMMRegister);
     __ pshufd($tmp$$XMMRegister, $src2$$XMMRegister, 0xE);
     __ vaddsd($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
-    __ vextractf32x4h($tmp2$$XMMRegister, $src2$$XMMRegister, 0x1);
+    __ vextractf32x4($tmp2$$XMMRegister, $src2$$XMMRegister, 0x1);
     __ vaddsd($dst$$XMMRegister, $dst$$XMMRegister, $tmp2$$XMMRegister);
     __ pshufd($tmp$$XMMRegister, $tmp2$$XMMRegister, 0xE);
     __ vaddsd($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
@@ -5185,15 +5185,15 @@
   format %{ "vaddsd  $dst,$dst,$src2\n\t"
             "pshufd  $tmp,$src2,0xE\n\t"
             "vaddsd  $dst,$dst,$tmp\n\t"
-            "vextractf32x4  $tmp2,$src2, 0x1\n\t"
+            "vextractf32x4  $tmp2,$src2,0x1\n\t"
             "vaddsd  $dst,$dst,$tmp2\n\t"
             "pshufd  $tmp,$tmp2,0xE\n\t"
             "vaddsd  $dst,$dst,$tmp\n\t"
-            "vextractf32x4  $tmp2,$src2, 0x2\n\t"
+            "vextractf32x4  $tmp2,$src2,0x2\n\t"
             "vaddsd  $dst,$dst,$tmp2\n\t"
             "pshufd  $tmp,$tmp2,0xE\n\t"
             "vaddsd  $dst,$dst,$tmp\n\t"
-            "vextractf32x4  $tmp2,$src2, 0x3\n\t"
+            "vextractf32x4  $tmp2,$src2,0x3\n\t"
             "vaddsd  $dst,$dst,$tmp2\n\t"
             "pshufd  $tmp,$tmp2,0xE\n\t"
             "vaddsd  $dst,$dst,$tmp\t! add reduction8D" %}
@@ -5201,15 +5201,15 @@
     __ vaddsd($dst$$XMMRegister, $dst$$XMMRegister, $src2$$XMMRegister);
     __ pshufd($tmp$$XMMRegister, $src2$$XMMRegister, 0xE);
     __ vaddsd($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
-    __ vextractf32x4h($tmp2$$XMMRegister, $src2$$XMMRegister, 0x1);
+    __ vextractf32x4($tmp2$$XMMRegister, $src2$$XMMRegister, 0x1);
     __ vaddsd($dst$$XMMRegister, $dst$$XMMRegister, $tmp2$$XMMRegister);
     __ pshufd($tmp$$XMMRegister, $tmp2$$XMMRegister, 0xE);
     __ vaddsd($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
-    __ vextractf32x4h($tmp2$$XMMRegister, $src2$$XMMRegister, 0x2);
+    __ vextractf32x4($tmp2$$XMMRegister, $src2$$XMMRegister, 0x2);
     __ vaddsd($dst$$XMMRegister, $dst$$XMMRegister, $tmp2$$XMMRegister);
     __ pshufd($tmp$$XMMRegister, $tmp2$$XMMRegister, 0xE);
     __ vaddsd($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
-    __ vextractf32x4h($tmp2$$XMMRegister, $src2$$XMMRegister, 0x3);
+    __ vextractf32x4($tmp2$$XMMRegister, $src2$$XMMRegister, 0x3);
     __ vaddsd($dst$$XMMRegister, $dst$$XMMRegister, $tmp2$$XMMRegister);
     __ pshufd($tmp$$XMMRegister, $tmp2$$XMMRegister, 0xE);
     __ vaddsd($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
@@ -5307,7 +5307,7 @@
   predicate(UseAVX > 0);
   match(Set dst (MulReductionVI src1 src2));
   effect(TEMP tmp, TEMP tmp2);
-  format %{ "vextracti128  $tmp,$src2\n\t"
+  format %{ "vextracti128_high  $tmp,$src2\n\t"
             "vpmulld  $tmp,$tmp,$src2\n\t"
             "pshufd   $tmp2,$tmp,0xE\n\t"
             "vpmulld  $tmp,$tmp,$tmp2\n\t"
@@ -5318,7 +5318,7 @@
             "movd     $dst,$tmp2\t! mul reduction8I" %}
   ins_encode %{
     int vector_len = 0;
-    __ vextracti128h($tmp$$XMMRegister, $src2$$XMMRegister);
+    __ vextracti128_high($tmp$$XMMRegister, $src2$$XMMRegister);
     __ vpmulld($tmp$$XMMRegister, $tmp$$XMMRegister, $src2$$XMMRegister, vector_len);
     __ pshufd($tmp2$$XMMRegister, $tmp$$XMMRegister, 0xE);
     __ vpmulld($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, vector_len);
@@ -5335,9 +5335,9 @@
   predicate(UseAVX > 2);
   match(Set dst (MulReductionVI src1 src2));
   effect(TEMP tmp, TEMP tmp2, TEMP tmp3);
-  format %{ "vextracti64x4  $tmp3,$src2,0x1\n\t"
+  format %{ "vextracti64x4_high  $tmp3,$src2\n\t"
             "vpmulld  $tmp3,$tmp3,$src2\n\t"
-            "vextracti128   $tmp,$tmp3\n\t"
+            "vextracti128_high  $tmp,$tmp3\n\t"
             "vpmulld  $tmp,$tmp,$src2\n\t"
             "pshufd   $tmp2,$tmp,0xE\n\t"
             "vpmulld  $tmp,$tmp,$tmp2\n\t"
@@ -5347,9 +5347,9 @@
             "vpmulld  $tmp2,$tmp,$tmp2\n\t"
             "movd     $dst,$tmp2\t! mul reduction16I" %}
   ins_encode %{
-    __ vextracti64x4h($tmp3$$XMMRegister, $src2$$XMMRegister, 1);
+    __ vextracti64x4_high($tmp3$$XMMRegister, $src2$$XMMRegister);
     __ vpmulld($tmp3$$XMMRegister, $tmp3$$XMMRegister, $src2$$XMMRegister, 1);
-    __ vextracti128h($tmp$$XMMRegister, $tmp3$$XMMRegister);
+    __ vextracti128_high($tmp$$XMMRegister, $tmp3$$XMMRegister);
     __ vpmulld($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp3$$XMMRegister, 0);
     __ pshufd($tmp2$$XMMRegister, $tmp$$XMMRegister, 0xE);
     __ vpmulld($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, 0);
@@ -5386,7 +5386,7 @@
   predicate(UseAVX > 2 && VM_Version::supports_avx512dq());
   match(Set dst (MulReductionVL src1 src2));
   effect(TEMP tmp, TEMP tmp2);
-  format %{ "vextracti128  $tmp,$src2\n\t"
+  format %{ "vextracti128_high  $tmp,$src2\n\t"
             "vpmullq  $tmp2,$tmp,$src2\n\t"
             "pshufd   $tmp,$tmp2,0xE\n\t"
             "vpmullq  $tmp2,$tmp2,$tmp\n\t"
@@ -5394,7 +5394,7 @@
             "vpmullq  $tmp2,$tmp2,$tmp\n\t"
             "movdq    $dst,$tmp2\t! mul reduction4L" %}
   ins_encode %{
-    __ vextracti128h($tmp$$XMMRegister, $src2$$XMMRegister);
+    __ vextracti128_high($tmp$$XMMRegister, $src2$$XMMRegister);
     __ vpmullq($tmp2$$XMMRegister, $tmp$$XMMRegister, $src2$$XMMRegister, 0);
     __ pshufd($tmp$$XMMRegister, $tmp2$$XMMRegister, 0xE);
     __ vpmullq($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister, 0);
@@ -5409,9 +5409,9 @@
   predicate(UseAVX > 2 && VM_Version::supports_avx512dq());
   match(Set dst (MulReductionVL src1 src2));
   effect(TEMP tmp, TEMP tmp2);
-  format %{ "vextracti64x4  $tmp2,$src2,0x1\n\t"
+  format %{ "vextracti64x4_high  $tmp2,$src2\n\t"
             "vpmullq  $tmp2,$tmp2,$src2\n\t"
-            "vextracti128   $tmp,$tmp2\n\t"
+            "vextracti128_high  $tmp,$tmp2\n\t"
             "vpmullq  $tmp2,$tmp2,$tmp\n\t"
             "pshufd   $tmp,$tmp2,0xE\n\t"
             "vpmullq  $tmp2,$tmp2,$tmp\n\t"
@@ -5419,9 +5419,9 @@
             "vpmullq  $tmp2,$tmp2,$tmp\n\t"
             "movdq    $dst,$tmp2\t! mul reduction8L" %}
   ins_encode %{
-    __ vextracti64x4h($tmp2$$XMMRegister, $src2$$XMMRegister, 1);
+    __ vextracti64x4_high($tmp2$$XMMRegister, $src2$$XMMRegister);
     __ vpmullq($tmp2$$XMMRegister, $tmp2$$XMMRegister, $src2$$XMMRegister, 1);
-    __ vextracti128h($tmp$$XMMRegister, $tmp2$$XMMRegister);
+    __ vextracti128_high($tmp$$XMMRegister, $tmp2$$XMMRegister);
     __ vpmullq($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister, 0);
     __ pshufd($tmp$$XMMRegister, $tmp2$$XMMRegister, 0xE);
     __ vpmullq($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister, 0);
@@ -5520,7 +5520,7 @@
             "vmulss  $dst,$dst,$tmp\n\t"
             "pshufd  $tmp,$src2,0x03\n\t"
             "vmulss  $dst,$dst,$tmp\n\t"
-            "vextractf128  $tmp2,$src2\n\t"
+            "vextractf128_high  $tmp2,$src2\n\t"
             "vmulss  $dst,$dst,$tmp2\n\t"
             "pshufd  $tmp,$tmp2,0x01\n\t"
             "vmulss  $dst,$dst,$tmp\n\t"
@@ -5536,7 +5536,7 @@
     __ vmulss($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
     __ pshufd($tmp$$XMMRegister, $src2$$XMMRegister, 0x03);
     __ vmulss($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
-    __ vextractf128h($tmp2$$XMMRegister, $src2$$XMMRegister);
+    __ vextractf128_high($tmp2$$XMMRegister, $src2$$XMMRegister);
     __ vmulss($dst$$XMMRegister, $dst$$XMMRegister, $tmp2$$XMMRegister);
     __ pshufd($tmp$$XMMRegister, $tmp2$$XMMRegister, 0x01);
     __ vmulss($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
@@ -5559,7 +5559,7 @@
             "vmulss  $dst,$dst,$tmp\n\t"
             "pshufd  $tmp,$src2,0x03\n\t"
             "vmulss  $dst,$dst,$tmp\n\t"
-            "vextractf32x4  $tmp2,$src2, 0x1\n\t"
+            "vextractf32x4  $tmp2,$src2,0x1\n\t"
             "vmulss  $dst,$dst,$tmp2\n\t"
             "pshufd  $tmp,$tmp2,0x01\n\t"
             "vmulss  $dst,$dst,$tmp\n\t"
@@ -5567,7 +5567,7 @@
             "vmulss  $dst,$dst,$tmp\n\t"
             "pshufd  $tmp,$tmp2,0x03\n\t"
             "vmulss  $dst,$dst,$tmp\n\t"
-            "vextractf32x4  $tmp2,$src2, 0x2\n\t"
+            "vextractf32x4  $tmp2,$src2,0x2\n\t"
             "vmulss  $dst,$dst,$tmp2\n\t"
             "pshufd  $tmp,$tmp2,0x01\n\t"
             "vmulss  $dst,$dst,$tmp\n\t"
@@ -5575,7 +5575,7 @@
             "vmulss  $dst,$dst,$tmp\n\t"
             "pshufd  $tmp,$tmp2,0x03\n\t"
             "vmulss  $dst,$dst,$tmp\n\t"
-            "vextractf32x4  $tmp2,$src2, 0x3\n\t"
+            "vextractf32x4  $tmp2,$src2,0x3\n\t"
             "vmulss  $dst,$dst,$tmp2\n\t"
             "pshufd  $tmp,$tmp2,0x01\n\t"
             "vmulss  $dst,$dst,$tmp\n\t"
@@ -5591,7 +5591,7 @@
     __ vmulss($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
     __ pshufd($tmp$$XMMRegister, $src2$$XMMRegister, 0x03);
     __ vmulss($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
-    __ vextractf32x4h($tmp2$$XMMRegister, $src2$$XMMRegister, 0x1);
+    __ vextractf32x4($tmp2$$XMMRegister, $src2$$XMMRegister, 0x1);
     __ vmulss($dst$$XMMRegister, $dst$$XMMRegister, $tmp2$$XMMRegister);
     __ pshufd($tmp$$XMMRegister, $tmp2$$XMMRegister, 0x01);
     __ vmulss($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
@@ -5599,7 +5599,7 @@
     __ vmulss($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
     __ pshufd($tmp$$XMMRegister, $tmp2$$XMMRegister, 0x03);
     __ vmulss($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
-    __ vextractf32x4h($tmp2$$XMMRegister, $src2$$XMMRegister, 0x2);
+    __ vextractf32x4($tmp2$$XMMRegister, $src2$$XMMRegister, 0x2);
     __ vmulss($dst$$XMMRegister, $dst$$XMMRegister, $tmp2$$XMMRegister);
     __ pshufd($tmp$$XMMRegister, $tmp2$$XMMRegister, 0x01);
     __ vmulss($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
@@ -5607,7 +5607,7 @@
     __ vmulss($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
     __ pshufd($tmp$$XMMRegister, $tmp2$$XMMRegister, 0x03);
     __ vmulss($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
-    __ vextractf32x4h($tmp2$$XMMRegister, $src2$$XMMRegister, 0x3);
+    __ vextractf32x4($tmp2$$XMMRegister, $src2$$XMMRegister, 0x3);
     __ vmulss($dst$$XMMRegister, $dst$$XMMRegister, $tmp2$$XMMRegister);
     __ pshufd($tmp$$XMMRegister, $tmp2$$XMMRegister, 0x01);
     __ vmulss($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
@@ -5656,7 +5656,7 @@
   format %{ "vmulsd  $dst,$dst,$src2\n\t"
             "pshufd  $tmp,$src2,0xE\n\t"
             "vmulsd  $dst,$dst,$tmp\n\t"
-            "vextractf128  $tmp2,$src2\n\t"
+            "vextractf128_high  $tmp2,$src2\n\t"
             "vmulsd  $dst,$dst,$tmp2\n\t"
             "pshufd  $tmp,$tmp2,0xE\n\t"
             "vmulsd  $dst,$dst,$tmp\t! mul reduction4D" %}
@@ -5664,7 +5664,7 @@
     __ vmulsd($dst$$XMMRegister, $dst$$XMMRegister, $src2$$XMMRegister);
     __ pshufd($tmp$$XMMRegister, $src2$$XMMRegister, 0xE);
     __ vmulsd($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
-    __ vextractf128h($tmp2$$XMMRegister, $src2$$XMMRegister);
+    __ vextractf128_high($tmp2$$XMMRegister, $src2$$XMMRegister);
     __ vmulsd($dst$$XMMRegister, $dst$$XMMRegister, $tmp2$$XMMRegister);
     __ pshufd($tmp$$XMMRegister, $tmp2$$XMMRegister, 0xE);
     __ vmulsd($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
@@ -5679,15 +5679,15 @@
   format %{ "vmulsd  $dst,$dst,$src2\n\t"
             "pshufd  $tmp,$src2,0xE\n\t"
             "vmulsd  $dst,$dst,$tmp\n\t"
-            "vextractf32x4  $tmp2,$src2, 0x1\n\t"
+            "vextractf32x4  $tmp2,$src2,0x1\n\t"
             "vmulsd  $dst,$dst,$tmp2\n\t"
             "pshufd  $tmp,$src2,0xE\n\t"
             "vmulsd  $dst,$dst,$tmp\n\t"
-            "vextractf32x4  $tmp2,$src2, 0x2\n\t"
+            "vextractf32x4  $tmp2,$src2,0x2\n\t"
             "vmulsd  $dst,$dst,$tmp2\n\t"
             "pshufd  $tmp,$tmp2,0xE\n\t"
             "vmulsd  $dst,$dst,$tmp\n\t"
-            "vextractf32x4  $tmp2,$src2, 0x3\n\t"
+            "vextractf32x4  $tmp2,$src2,0x3\n\t"
             "vmulsd  $dst,$dst,$tmp2\n\t"
             "pshufd  $tmp,$tmp2,0xE\n\t"
             "vmulsd  $dst,$dst,$tmp\t! mul reduction8D" %}
@@ -5695,15 +5695,15 @@
     __ vmulsd($dst$$XMMRegister, $dst$$XMMRegister, $src2$$XMMRegister);
     __ pshufd($tmp$$XMMRegister, $src2$$XMMRegister, 0xE);
     __ vmulsd($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
-    __ vextractf32x4h($tmp2$$XMMRegister, $src2$$XMMRegister, 0x1);
+    __ vextractf32x4($tmp2$$XMMRegister, $src2$$XMMRegister, 0x1);
     __ vmulsd($dst$$XMMRegister, $dst$$XMMRegister, $tmp2$$XMMRegister);
     __ pshufd($tmp$$XMMRegister, $tmp2$$XMMRegister, 0xE);
     __ vmulsd($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
-    __ vextractf32x4h($tmp2$$XMMRegister, $src2$$XMMRegister, 0x2);
+    __ vextractf32x4($tmp2$$XMMRegister, $src2$$XMMRegister, 0x2);
     __ vmulsd($dst$$XMMRegister, $dst$$XMMRegister, $tmp2$$XMMRegister);
     __ pshufd($tmp$$XMMRegister, $tmp2$$XMMRegister, 0xE);
     __ vmulsd($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
-    __ vextractf32x4h($tmp2$$XMMRegister, $src2$$XMMRegister, 0x3);
+    __ vextractf32x4($tmp2$$XMMRegister, $src2$$XMMRegister, 0x3);
     __ vmulsd($dst$$XMMRegister, $dst$$XMMRegister, $tmp2$$XMMRegister);
     __ pshufd($tmp$$XMMRegister, $tmp2$$XMMRegister, 0xE);
     __ vmulsd($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister);
--- a/hotspot/src/cpu/x86/vm/x86_32.ad	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/x86_32.ad	Mon Mar 28 08:41:54 2016 -0700
@@ -1420,9 +1420,6 @@
 // The ecx parameter to rep stos for the ClearArray node is in dwords.
 const bool Matcher::init_array_count_is_in_bytes = false;
 
-// Threshold size for cleararray.
-const int Matcher::init_array_short_size = 8 * BytesPerLong;
-
 // Needs 2 CMOV's for longs.
 const int Matcher::long_cmove_cost() { return 1; }
 
@@ -11369,27 +11366,54 @@
 // =======================================================================
 // fast clearing of an array
 instruct rep_stos(eCXRegI cnt, eDIRegP base, eAXRegI zero, Universe dummy, eFlagsReg cr) %{
-  predicate(!UseFastStosb);
+  predicate(!((ClearArrayNode*)n)->is_large());
   match(Set dummy (ClearArray cnt base));
   effect(USE_KILL cnt, USE_KILL base, KILL zero, KILL cr);
-  format %{ "XOR    EAX,EAX\t# ClearArray:\n\t"
-            "SHL    ECX,1\t# Convert doublewords to words\n\t"
-            "REP STOS\t# store EAX into [EDI++] while ECX--" %}
-  ins_encode %{
-    __ clear_mem($base$$Register, $cnt$$Register, $zero$$Register);
-  %}
-  ins_pipe( pipe_slow );
-%}
-
-instruct rep_fast_stosb(eCXRegI cnt, eDIRegP base, eAXRegI zero, Universe dummy, eFlagsReg cr) %{
-  predicate(UseFastStosb);
+
+  format %{ $$template
+    $$emit$$"XOR    EAX,EAX\t# ClearArray:\n\t"
+    $$emit$$"CMP    InitArrayShortSize,rcx\n\t"
+    $$emit$$"JG     LARGE\n\t"
+    $$emit$$"SHL    ECX, 1\n\t"
+    $$emit$$"DEC    ECX\n\t"
+    $$emit$$"JS     DONE\t# Zero length\n\t"
+    $$emit$$"MOV    EAX,(EDI,ECX,4)\t# LOOP\n\t"
+    $$emit$$"DEC    ECX\n\t"
+    $$emit$$"JGE    LOOP\n\t"
+    $$emit$$"JMP    DONE\n\t"
+    $$emit$$"# LARGE:\n\t"
+    if (UseFastStosb) {
+       $$emit$$"SHL    ECX,3\t# Convert doublewords to bytes\n\t"
+       $$emit$$"REP STOSB\t# store EAX into [EDI++] while ECX--\n\t"
+    } else {
+       $$emit$$"SHL    ECX,1\t# Convert doublewords to words\n\t"
+       $$emit$$"REP STOS\t# store EAX into [EDI++] while ECX--\n\t"
+    }
+    $$emit$$"# DONE"
+  %}
+  ins_encode %{
+    __ clear_mem($base$$Register, $cnt$$Register, $zero$$Register, false);
+  %}
+  ins_pipe( pipe_slow );
+%}
+
+instruct rep_stos_large(eCXRegI cnt, eDIRegP base, eAXRegI zero, Universe dummy, eFlagsReg cr) %{
+  predicate(((ClearArrayNode*)n)->is_large());
   match(Set dummy (ClearArray cnt base));
   effect(USE_KILL cnt, USE_KILL base, KILL zero, KILL cr);
-  format %{ "XOR    EAX,EAX\t# ClearArray:\n\t"
-            "SHL    ECX,3\t# Convert doublewords to bytes\n\t"
-            "REP STOSB\t# store EAX into [EDI++] while ECX--" %}
-  ins_encode %{
-    __ clear_mem($base$$Register, $cnt$$Register, $zero$$Register);
+  format %{ $$template
+    $$emit$$"XOR    EAX,EAX\t# ClearArray:\n\t"
+    if (UseFastStosb) {
+       $$emit$$"SHL    ECX,3\t# Convert doublewords to bytes\n\t"
+       $$emit$$"REP STOSB\t# store EAX into [EDI++] while ECX--\n\t"
+    } else {
+       $$emit$$"SHL    ECX,1\t# Convert doublewords to words\n\t"
+       $$emit$$"REP STOS\t# store EAX into [EDI++] while ECX--\n\t"
+    }
+    $$emit$$"# DONE"
+  %}
+  ins_encode %{
+    __ clear_mem($base$$Register, $cnt$$Register, $zero$$Register, true);
   %}
   ins_pipe( pipe_slow );
 %}
--- a/hotspot/src/cpu/x86/vm/x86_64.ad	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/x86_64.ad	Mon Mar 28 08:41:54 2016 -0700
@@ -1637,9 +1637,6 @@
 // The ecx parameter to rep stosq for the ClearArray node is in words.
 const bool Matcher::init_array_count_is_in_bytes = false;
 
-// Threshold size for cleararray.
-const int Matcher::init_array_short_size = 8 * BytesPerLong;
-
 // No additional cost for CMOVL.
 const int Matcher::long_cmove_cost() { return 0; }
 
@@ -10460,31 +10457,55 @@
 instruct rep_stos(rcx_RegL cnt, rdi_RegP base, rax_RegI zero, Universe dummy,
                   rFlagsReg cr)
 %{
-  predicate(!UseFastStosb);
+  predicate(!((ClearArrayNode*)n)->is_large());
   match(Set dummy (ClearArray cnt base));
   effect(USE_KILL cnt, USE_KILL base, KILL zero, KILL cr);
 
-  format %{ "xorq    rax, rax\t# ClearArray:\n\t"
-            "rep     stosq\t# Store rax to *rdi++ while rcx--" %}
-  ins_encode %{
-    __ clear_mem($base$$Register, $cnt$$Register, $zero$$Register);
+  format %{ $$template
+    $$emit$$"xorq    rax, rax\t# ClearArray:\n\t"
+    $$emit$$"cmp     InitArrayShortSize,rcx\n\t"
+    $$emit$$"jg      LARGE\n\t"
+    $$emit$$"dec     rcx\n\t"
+    $$emit$$"js      DONE\t# Zero length\n\t"
+    $$emit$$"mov     rax,(rdi,rcx,8)\t# LOOP\n\t"
+    $$emit$$"dec     rcx\n\t"
+    $$emit$$"jge     LOOP\n\t"
+    $$emit$$"jmp     DONE\n\t"
+    $$emit$$"# LARGE:\n\t"
+    if (UseFastStosb) {
+       $$emit$$"shlq    rcx,3\t# Convert doublewords to bytes\n\t"
+       $$emit$$"rep     stosb\t# Store rax to *rdi++ while rcx--\n\t"
+    } else {
+       $$emit$$"rep     stosq\t# Store rax to *rdi++ while rcx--\n\t"
+    }
+    $$emit$$"# DONE"
+  %}
+  ins_encode %{
+    __ clear_mem($base$$Register, $cnt$$Register, $zero$$Register, false);
   %}
   ins_pipe(pipe_slow);
 %}
 
-instruct rep_fast_stosb(rcx_RegL cnt, rdi_RegP base, rax_RegI zero, Universe dummy,
-                        rFlagsReg cr)
-%{
-  predicate(UseFastStosb);
+instruct rep_stos_large(rcx_RegL cnt, rdi_RegP base, rax_RegI zero, Universe dummy,
+                  rFlagsReg cr)
+%{
+  predicate(((ClearArrayNode*)n)->is_large());
   match(Set dummy (ClearArray cnt base));
   effect(USE_KILL cnt, USE_KILL base, KILL zero, KILL cr);
-  format %{ "xorq    rax, rax\t# ClearArray:\n\t"
-            "shlq    rcx,3\t# Convert doublewords to bytes\n\t"
-            "rep     stosb\t# Store rax to *rdi++ while rcx--" %}
-  ins_encode %{
-    __ clear_mem($base$$Register, $cnt$$Register, $zero$$Register);
-  %}
-  ins_pipe( pipe_slow );
+
+  format %{ $$template
+    $$emit$$"xorq    rax, rax\t# ClearArray:\n\t"
+    if (UseFastStosb) {
+       $$emit$$"shlq    rcx,3\t# Convert doublewords to bytes\n\t"
+       $$emit$$"rep     stosb\t# Store rax to *rdi++ while rcx--"
+    } else {
+       $$emit$$"rep     stosq\t# Store rax to *rdi++ while rcx--"
+    }
+  %}
+  ins_encode %{
+    __ clear_mem($base$$Register, $cnt$$Register, $zero$$Register, true);
+  %}
+  ins_pipe(pipe_slow);
 %}
 
 instruct string_compareL(rdi_RegP str1, rcx_RegI cnt1, rsi_RegP str2, rdx_RegI cnt2,
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.amd64/src/jdk/vm/ci/amd64/AMD64.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.amd64/src/jdk/vm/ci/amd64/AMD64.java	Mon Mar 28 08:41:54 2016 -0700
@@ -203,7 +203,8 @@
         AVX512ER,
         AVX512CD,
         AVX512BW,
-        AVX512VL
+        AVX512VL,
+        SHA
     }
 
     private final EnumSet<CPUFeature> features;
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.amd64/src/jdk/vm/ci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory.java	Mon Mar 28 08:41:54 2016 -0700
@@ -122,6 +122,9 @@
         if ((config.vmVersionFeatures & config.amd64AVX512VL) != 0) {
             features.add(AMD64.CPUFeature.AVX512VL);
         }
+        if ((config.vmVersionFeatures & config.amd64SHA) != 0) {
+            features.add(AMD64.CPUFeature.SHA);
+        }
         return features;
     }
 
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantReflectionProvider.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantReflectionProvider.java	Mon Mar 28 08:41:54 2016 -0700
@@ -339,7 +339,7 @@
 
     public JavaConstant readStableFieldValue(ResolvedJavaField field, JavaConstant receiver, boolean isDefaultStable) {
         JavaConstant fieldValue = readNonStableFieldValue(field, receiver);
-        if (fieldValue.isNonNull()) {
+        if (fieldValue != null && fieldValue.isNonNull()) {
             JavaType declaredType = field.getType();
             if (declaredType.getComponentType() != null) {
                 int stableDimension = getArrayDimension(declaredType);
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
 import jdk.vm.ci.code.CompilationRequest;
 import jdk.vm.ci.code.CompilationRequestResult;
 import jdk.vm.ci.common.JVMCIError;
+import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option;
 import jdk.vm.ci.runtime.JVMCICompiler;
 import jdk.vm.ci.runtime.JVMCICompilerFactory;
 import jdk.vm.ci.runtime.JVMCIRuntime;
@@ -47,29 +48,33 @@
         }
     }
 
+    /**
+     * Factory of the selected system compiler.
+     */
     private static JVMCICompilerFactory compilerFactory;
 
     /**
-     * Selects the system compiler.
+     * Gets the selected system compiler factory.
      *
-     * Called from VM. This method has an object return type to allow it to be called with a VM
-     * utility function used to call other static initialization methods.
+     * @return the selected system compiler factory
      */
-    static Boolean selectCompiler(String compilerName) {
-        assert compilerFactory == null;
-        for (JVMCICompilerFactory factory : Services.load(JVMCICompilerFactory.class)) {
-            if (factory.getCompilerName().equals(compilerName)) {
-                compilerFactory = factory;
-                return Boolean.TRUE;
-            }
-        }
-
-        throw new JVMCIError("JVMCI compiler '%s' not found", compilerName);
-    }
-
     static JVMCICompilerFactory getCompilerFactory() {
         if (compilerFactory == null) {
-            compilerFactory = new DummyCompilerFactory();
+            JVMCICompilerFactory factory = null;
+            String compilerName = Option.Compiler.getString();
+            if (compilerName != null) {
+                for (JVMCICompilerFactory f : Services.load(JVMCICompilerFactory.class)) {
+                    if (f.getCompilerName().equals(compilerName)) {
+                        factory = f;
+                    }
+                }
+                if (factory == null) {
+                    throw new JVMCIError("JVMCI compiler '%s' not found", compilerName);
+                }
+            } else {
+                factory = new DummyCompilerFactory();
+            }
+            compilerFactory = factory;
         }
         return compilerFactory;
     }
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java	Mon Mar 28 08:41:54 2016 -0700
@@ -91,6 +91,7 @@
      * A list of all supported JVMCI options.
      */
     public enum Option {
+        Compiler(String.class, null, "Selects the system compiler."),
         ImplicitStableValues(boolean.class, true, "Mark well-known stable fields as such."),
         // Note: The following one is not used (see InitTimer.ENABLED).
         InitTimer(boolean.class, false, "Specifies if initialization timing is enabled."),
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaAccessProvider.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaAccessProvider.java	Mon Mar 28 08:41:54 2016 -0700
@@ -41,7 +41,6 @@
 import jdk.vm.ci.meta.DeoptimizationReason;
 import jdk.vm.ci.meta.JavaConstant;
 import jdk.vm.ci.meta.JavaKind;
-import jdk.vm.ci.meta.JavaType;
 import jdk.vm.ci.meta.MetaAccessProvider;
 import jdk.vm.ci.meta.ResolvedJavaField;
 import jdk.vm.ci.meta.ResolvedJavaMethod;
@@ -111,23 +110,26 @@
     }
 
     public ResolvedJavaField lookupJavaField(Field reflectionField) {
-        String name = reflectionField.getName();
         Class<?> fieldHolder = reflectionField.getDeclaringClass();
-        Class<?> fieldType = reflectionField.getType();
-        // java.lang.reflect.Field's modifiers should be enough here since VM internal modifier bits
-        // are not used (yet).
-        final int modifiers = reflectionField.getModifiers();
-        final long offset = Modifier.isStatic(modifiers) ? UNSAFE.staticFieldOffset(reflectionField) : UNSAFE.objectFieldOffset(reflectionField);
 
         HotSpotResolvedObjectType holder = fromObjectClass(fieldHolder);
-        JavaType type = runtime.fromClass(fieldType);
+        if (Modifier.isStatic(reflectionField.getModifiers())) {
+            final long offset = UNSAFE.staticFieldOffset(reflectionField);
+            for (ResolvedJavaField field : holder.getStaticFields()) {
+                if (offset == ((HotSpotResolvedJavaField) field).offset()) {
+                    return field;
+                }
+            }
+        } else {
+            final long offset = UNSAFE.objectFieldOffset(reflectionField);
+            for (ResolvedJavaField field : holder.getInstanceFields(false)) {
+                if (offset == ((HotSpotResolvedJavaField) field).offset()) {
+                    return field;
+                }
+            }
+        }
 
-        if (offset != -1) {
-            HotSpotResolvedObjectType resolved = holder;
-            return resolved.createField(name, type, offset, modifiers);
-        } else {
-            throw new JVMCIError("unresolved field %s", reflectionField);
-        }
+        throw new JVMCIError("unresolved field %s", reflectionField);
     }
 
     private static int intMaskRight(int n) {
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java	Mon Mar 28 08:41:54 2016 -0700
@@ -945,6 +945,7 @@
     @HotSpotVMConstant(name = "VM_Version::CPU_AVX512CD", archs = {"amd64"}) @Stable public long amd64AVX512CD;
     @HotSpotVMConstant(name = "VM_Version::CPU_AVX512BW", archs = {"amd64"}) @Stable public long amd64AVX512BW;
     @HotSpotVMConstant(name = "VM_Version::CPU_AVX512VL", archs = {"amd64"}) @Stable public long amd64AVX512VL;
+    @HotSpotVMConstant(name = "VM_Version::CPU_SHA", archs = {"amd64"}) @Stable public long amd64SHA;
 
     // SPARC specific values
     @HotSpotVMConstant(name = "VM_Version::vis3_instructions_m", archs = {"sparc"}) @Stable public int sparcVis3Instructions;
--- a/hotspot/src/os/linux/vm/os_linux.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/os/linux/vm/os_linux.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -144,6 +144,7 @@
 int os::Linux::_page_size = -1;
 const int os::Linux::_vm_default_page_size = (8 * K);
 bool os::Linux::_supports_fast_thread_cpu_time = false;
+uint32_t os::Linux::_os_version = 0;
 const char * os::Linux::_glibc_version = NULL;
 const char * os::Linux::_libpthread_version = NULL;
 pthread_condattr_t os::Linux::_condattr[1];
@@ -4356,6 +4357,48 @@
   return (tp.tv_sec * NANOSECS_PER_SEC) + tp.tv_nsec;
 }
 
+void os::Linux::initialize_os_info() {
+  assert(_os_version == 0, "OS info already initialized");
+
+  struct utsname _uname;
+
+  uint32_t major;
+  uint32_t minor;
+  uint32_t fix;
+
+  int rc;
+
+  // Kernel version is unknown if
+  // verification below fails.
+  _os_version = 0x01000000;
+
+  rc = uname(&_uname);
+  if (rc != -1) {
+
+    rc = sscanf(_uname.release,"%d.%d.%d", &major, &minor, &fix);
+    if (rc == 3) {
+
+      if (major < 256 && minor < 256 && fix < 256) {
+        // Kernel version format is as expected,
+        // set it overriding unknown state.
+        _os_version = (major << 16) |
+                      (minor << 8 ) |
+                      (fix   << 0 ) ;
+      }
+    }
+  }
+}
+
+uint32_t os::Linux::os_version() {
+  assert(_os_version != 0, "not initialized");
+  return _os_version & 0x00FFFFFF;
+}
+
+bool os::Linux::os_version_is_known() {
+  assert(_os_version != 0, "not initialized");
+  return _os_version & 0x01000000 ? false : true;
+}
+
 /////
 // glibc on Linux platform uses non-documented flag
 // to indicate, that some special sort of signal
@@ -4578,6 +4621,8 @@
 
   Linux::initialize_system_info();
 
+  Linux::initialize_os_info();
+
   // main_thread points to the aboriginal thread
   Linux::_main_thread = pthread_self();
 
--- a/hotspot/src/os/linux/vm/os_linux.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/os/linux/vm/os_linux.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -56,6 +56,15 @@
 
   static GrowableArray<int>* _cpu_to_node;
 
+  // 0x00000000 = uninitialized,
+  // 0x01000000 = kernel version unknown,
+  // otherwise a 32-bit number:
+  // Ox00AABBCC
+  // AA, Major Version
+  // BB, Minor Version
+  // CC, Fix   Version
+  static uint32_t _os_version;
+
  protected:
 
   static julong _physical_memory;
@@ -198,6 +207,10 @@
 
   static jlong fast_thread_cpu_time(clockid_t clockid);
 
+  static void initialize_os_info();
+  static bool os_version_is_known();
+  static uint32_t os_version();
+
   // pthread_cond clock suppport
  private:
   static pthread_condattr_t _condattr[1];
--- a/hotspot/src/os/posix/vm/os_posix.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/os/posix/vm/os_posix.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -336,13 +336,13 @@
   const char *start;
 
   if (lib_name != NULL) {
-    len = name_len = strlen(lib_name);
+    name_len = strlen(lib_name);
     if (is_absolute_path) {
       // Need to strip path, prefix and suffix
       if ((start = strrchr(lib_name, *os::file_separator())) != NULL) {
         lib_name = ++start;
       }
-      if (len <= (prefix_len + suffix_len)) {
+      if (strlen(lib_name) <= (prefix_len + suffix_len)) {
         return NULL;
       }
       lib_name += prefix_len;
--- a/hotspot/src/os/windows/vm/os_windows.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/os/windows/vm/os_windows.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -951,11 +951,11 @@
     FILETIME wt;
     GetSystemTimeAsFileTime(&wt);
     jlong rtc_millis = windows_to_java_time(wt);
-    jlong user_millis = windows_to_java_time(user_time);
-    jlong system_millis = windows_to_java_time(kernel_time);
     *process_real_time = ((double) rtc_millis) / ((double) MILLIUNITS);
-    *process_user_time = ((double) user_millis) / ((double) MILLIUNITS);
-    *process_system_time = ((double) system_millis) / ((double) MILLIUNITS);
+    *process_user_time =
+      (double) jlong_from(user_time.dwHighDateTime, user_time.dwLowDateTime) / (10 * MICROUNITS);
+    *process_system_time =
+      (double) jlong_from(kernel_time.dwHighDateTime, kernel_time.dwLowDateTime) / (10 * MICROUNITS);
     return true;
   } else {
     return false;
--- a/hotspot/src/os_cpu/linux_aarch64/vm/copy_linux_aarch64.inline.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/os_cpu/linux_aarch64/vm/copy_linux_aarch64.inline.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -26,44 +26,108 @@
 #ifndef OS_CPU_LINUX_AARCH64_VM_COPY_LINUX_AARCH64_INLINE_HPP
 #define OS_CPU_LINUX_AARCH64_VM_COPY_LINUX_AARCH64_INLINE_HPP
 
+#define COPY_SMALL(from, to, count)                                     \
+{                                                                       \
+        long tmp0, tmp1, tmp2, tmp3;                                    \
+        long tmp4, tmp5, tmp6, tmp7;                                    \
+  __asm volatile(                                                       \
+"       adr     %[t0], 0f;"                                             \
+"       add     %[t0], %[t0], %[cnt], lsl #5;"                          \
+"       br      %[t0];"                                                 \
+"       .align  5;"                                                     \
+"0:"                                                                    \
+"       b       1f;"                                                    \
+"       .align  5;"                                                     \
+"       ldr     %[t0], [%[s], #0];"                                     \
+"       str     %[t0], [%[d], #0];"                                     \
+"       b       1f;"                                                    \
+"       .align  5;"                                                     \
+"       ldp     %[t0], %[t1], [%[s], #0];"                              \
+"       stp     %[t0], %[t1], [%[d], #0];"                              \
+"       b       1f;"                                                    \
+"       .align  5;"                                                     \
+"       ldp     %[t0], %[t1], [%[s], #0];"                              \
+"       ldr     %[t2], [%[s], #16];"                                    \
+"       stp     %[t0], %[t1], [%[d], #0];"                              \
+"       str     %[t2], [%[d], #16];"                                    \
+"       b       1f;"                                                    \
+"       .align  5;"                                                     \
+"       ldp     %[t0], %[t1], [%[s], #0];"                              \
+"       ldp     %[t2], %[t3], [%[s], #16];"                             \
+"       stp     %[t0], %[t1], [%[d], #0];"                              \
+"       stp     %[t2], %[t3], [%[d], #16];"                             \
+"       b       1f;"                                                    \
+"       .align  5;"                                                     \
+"       ldp     %[t0], %[t1], [%[s], #0];"                              \
+"       ldp     %[t2], %[t3], [%[s], #16];"                             \
+"       ldr     %[t4], [%[s], #32];"                                    \
+"       stp     %[t0], %[t1], [%[d], #0];"                              \
+"       stp     %[t2], %[t3], [%[d], #16];"                             \
+"       str     %[t4], [%[d], #32];"                                    \
+"       b       1f;"                                                    \
+"       .align  5;"                                                     \
+"       ldp     %[t0], %[t1], [%[s], #0];"                              \
+"       ldp     %[t2], %[t3], [%[s], #16];"                             \
+"       ldp     %[t4], %[t5], [%[s], #32];"                             \
+"2:"                                                                    \
+"       stp     %[t0], %[t1], [%[d], #0];"                              \
+"       stp     %[t2], %[t3], [%[d], #16];"                             \
+"       stp     %[t4], %[t5], [%[d], #32];"                             \
+"       b       1f;"                                                    \
+"       .align  5;"                                                     \
+"       ldr     %[t6], [%[s], #0];"                                     \
+"       ldp     %[t0], %[t1], [%[s], #8];"                              \
+"       ldp     %[t2], %[t3], [%[s], #24];"                             \
+"       ldp     %[t4], %[t5], [%[s], #40];"                             \
+"       str     %[t6], [%[d]], #8;"                                     \
+"       b       2b;"                                                    \
+"       .align  5;"                                                     \
+"       ldp     %[t0], %[t1], [%[s], #0];"                              \
+"       ldp     %[t2], %[t3], [%[s], #16];"                             \
+"       ldp     %[t4], %[t5], [%[s], #32];"                             \
+"       ldp     %[t6], %[t7], [%[s], #48];"                             \
+"       stp     %[t0], %[t1], [%[d], #0];"                              \
+"       stp     %[t2], %[t3], [%[d], #16];"                             \
+"       stp     %[t4], %[t5], [%[d], #32];"                             \
+"       stp     %[t6], %[t7], [%[d], #48];"                             \
+"1:"                                                                    \
+                                                                        \
+  : [s]"+r"(from), [d]"+r"(to), [cnt]"+r"(count),                       \
+    [t0]"=&r"(tmp0), [t1]"=&r"(tmp1), [t2]"=&r"(tmp2), [t3]"=&r"(tmp3), \
+    [t4]"=&r"(tmp4), [t5]"=&r"(tmp5), [t6]"=&r"(tmp6), [t7]"=&r"(tmp7)  \
+  :                                                                     \
+  : "memory", "cc");                                                    \
+}
+
 static void pd_conjoint_words(HeapWord* from, HeapWord* to, size_t count) {
-  (void)memmove(to, from, count * HeapWordSize);
+  __asm volatile( "prfm pldl1strm, [%[s], #0];" :: [s]"r"(from) : "memory");
+  if (__builtin_expect(count <= 8, 1)) {
+    COPY_SMALL(from, to, count);
+    return;
+  }
+  _Copy_conjoint_words(from, to, count);
 }
 
 static void pd_disjoint_words(HeapWord* from, HeapWord* to, size_t count) {
-  switch (count) {
-  case 8:  to[7] = from[7];
-  case 7:  to[6] = from[6];
-  case 6:  to[5] = from[5];
-  case 5:  to[4] = from[4];
-  case 4:  to[3] = from[3];
-  case 3:  to[2] = from[2];
-  case 2:  to[1] = from[1];
-  case 1:  to[0] = from[0];
-  case 0:  break;
-  default:
-    (void)memcpy(to, from, count * HeapWordSize);
-    break;
+  if (__builtin_constant_p(count)) {
+    memcpy(to, from, count * sizeof(HeapWord));
+    return;
   }
+  __asm volatile( "prfm pldl1strm, [%[s], #0];" :: [s]"r"(from) : "memory");
+  if (__builtin_expect(count <= 8, 1)) {
+    COPY_SMALL(from, to, count);
+    return;
+  }
+  _Copy_disjoint_words(from, to, count);
 }
 
 static void pd_disjoint_words_atomic(HeapWord* from, HeapWord* to, size_t count) {
-  switch (count) {
-  case 8:  to[7] = from[7];
-  case 7:  to[6] = from[6];
-  case 6:  to[5] = from[5];
-  case 5:  to[4] = from[4];
-  case 4:  to[3] = from[3];
-  case 3:  to[2] = from[2];
-  case 2:  to[1] = from[1];
-  case 1:  to[0] = from[0];
-  case 0:  break;
-  default:
-    while (count-- > 0) {
-      *to++ = *from++;
-    }
-    break;
+  __asm volatile( "prfm pldl1strm, [%[s], #0];" :: [s]"r"(from) : "memory");
+  if (__builtin_expect(count <= 8, 1)) {
+    COPY_SMALL(from, to, count);
+    return;
   }
+  _Copy_disjoint_words(from, to, count);
 }
 
 static void pd_aligned_conjoint_words(HeapWord* from, HeapWord* to, size_t count) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/linux_aarch64/vm/copy_linux_aarch64.s	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,236 @@
+/*
+ * Copyright (c) 2016, Linaro Ltd. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+        .global _Copy_conjoint_words
+        .global _Copy_disjoint_words
+
+s       .req    x0
+d       .req    x1
+count   .req    x2
+t0      .req    x3
+t1      .req    x4
+t2      .req    x5
+t3      .req    x6
+t4      .req    x7
+t5      .req    x8
+t6      .req    x9
+t7      .req    x10
+
+        .align  6
+_Copy_disjoint_words:
+        // Ensure 2 word aligned
+        tbz     s, #3, fwd_copy_aligned
+        ldr     t0, [s], #8
+        str     t0, [d], #8
+        sub     count, count, #1
+
+fwd_copy_aligned:
+        // Bias s & d so we only pre index on the last copy
+        sub     s, s, #16
+        sub     d, d, #16
+
+        ldp     t0, t1, [s, #16]
+        ldp     t2, t3, [s, #32]
+        ldp     t4, t5, [s, #48]
+        ldp     t6, t7, [s, #64]!
+
+        subs    count, count, #16
+        blo     fwd_copy_drain
+
+fwd_copy_again:
+        prfm    pldl1keep, [s, #256]
+        stp     t0, t1, [d, #16]
+        ldp     t0, t1, [s, #16]
+        stp     t2, t3, [d, #32]
+        ldp     t2, t3, [s, #32]
+        stp     t4, t5, [d, #48]
+        ldp     t4, t5, [s, #48]
+        stp     t6, t7, [d, #64]!
+        ldp     t6, t7, [s, #64]!
+        subs    count, count, #8
+        bhs     fwd_copy_again
+
+fwd_copy_drain:
+        stp     t0, t1, [d, #16]
+        stp     t2, t3, [d, #32]
+        stp     t4, t5, [d, #48]
+        stp     t6, t7, [d, #64]!
+
+        // count is now -8..-1 for 0..7 words to copy
+        adr     t0, 0f
+        add     t0, t0, count, lsl #5
+        br      t0
+
+        .align  5
+        ret                             // -8 == 0 words
+        .align  5
+        ldr     t0, [s, #16]            // -7 == 1 word
+        str     t0, [d, #16]
+        ret
+        .align  5
+        ldp     t0, t1, [s, #16]        // -6 = 2 words
+        stp     t0, t1, [d, #16]
+        ret
+        .align  5
+        ldp     t0, t1, [s, #16]        // -5 = 3 words
+        ldr     t2, [s, #32]
+        stp     t0, t1, [d, #16]
+        str     t2, [d, #32]
+        ret
+        .align  5
+        ldp     t0, t1, [s, #16]        // -4 = 4 words
+        ldp     t2, t3, [s, #32]
+        stp     t0, t1, [d, #16]
+        stp     t2, t3, [d, #32]
+        ret
+        .align  5
+        ldp     t0, t1, [s, #16]        // -3 = 5 words
+        ldp     t2, t3, [s, #32]
+        ldr     t4, [s, #48]
+        stp     t0, t1, [d, #16]
+        stp     t2, t3, [d, #32]
+        str     t4, [d, #48]
+        ret
+        .align  5
+        ldp     t0, t1, [s, #16]        // -2 = 6 words
+        ldp     t2, t3, [s, #32]
+        ldp     t4, t5, [s, #48]
+        stp     t0, t1, [d, #16]
+        stp     t2, t3, [d, #32]
+        stp     t4, t5, [d, #48]
+        ret
+        .align  5
+        ldp     t0, t1, [s, #16]        // -1 = 7 words
+        ldp     t2, t3, [s, #32]
+        ldp     t4, t5, [s, #48]
+        ldr     t6, [s, #64]
+        stp     t0, t1, [d, #16]
+        stp     t2, t3, [d, #32]
+        stp     t4, t5, [d, #48]
+        str     t6, [d, #64]
+        // Is always aligned here, code for 7 words is one instruction
+        // too large so it just falls through.
+        .align  5
+0:
+        ret
+
+        .align  6
+_Copy_conjoint_words:
+        sub     t0, d, s
+        cmp     t0, count, lsl #3
+        bhs     _Copy_disjoint_words
+
+        add     s, s, count, lsl #3
+        add     d, d, count, lsl #3
+
+        // Ensure 2 word aligned
+        tbz     s, #3, bwd_copy_aligned
+        ldr     t0, [s, #-8]!
+        str     t0, [d, #-8]!
+        sub     count, count, #1
+
+bwd_copy_aligned:
+        ldp     t0, t1, [s, #-16]
+        ldp     t2, t3, [s, #-32]
+        ldp     t4, t5, [s, #-48]
+        ldp     t6, t7, [s, #-64]!
+
+        subs    count, count, #16
+        blo     bwd_copy_drain
+
+bwd_copy_again:
+        prfm    pldl1keep, [s, #-256]
+        stp     t0, t1, [d, #-16]
+        ldp     t0, t1, [s, #-16]
+        stp     t2, t3, [d, #-32]
+        ldp     t2, t3, [s, #-32]
+        stp     t4, t5, [d, #-48]
+        ldp     t4, t5, [s, #-48]
+        stp     t6, t7, [d, #-64]!
+        ldp     t6, t7, [s, #-64]!
+        subs    count, count, #8
+        bhs     bwd_copy_again
+
+bwd_copy_drain:
+        stp     t0, t1, [d, #-16]
+        stp     t2, t3, [d, #-32]
+        stp     t4, t5, [d, #-48]
+        stp     t6, t7, [d, #-64]!
+
+        // count is now -8..-1 for 0..7 words to copy
+        adr     t0, 0f
+        add     t0, t0, count, lsl #5
+        br      t0
+
+        .align  5
+        ret                             // -8 == 0 words
+        .align  5
+        ldr     t0, [s, #-8]            // -7 == 1 word
+        str     t0, [d, #-8]
+        ret
+        .align  5
+        ldp     t0, t1, [s, #-16]       // -6 = 2 words
+        stp     t0, t1, [d, #-16]
+        ret
+        .align  5
+        ldp     t0, t1, [s, #-16]       // -5 = 3 words
+        ldr     t2, [s, #-24]
+        stp     t0, t1, [d, #-16]
+        str     t2, [d, #-24]
+        ret
+        .align  5
+        ldp     t0, t1, [s, #-16]       // -4 = 4 words
+        ldp     t2, t3, [s, #-32]
+        stp     t0, t1, [d, #-16]
+        stp     t2, t3, [d, #-32]
+        ret
+        .align  5
+        ldp     t0, t1, [s, #-16]       // -3 = 5 words
+        ldp     t2, t3, [s, #-32]
+        ldr     t4, [s, #-40]
+        stp     t0, t1, [d, #-16]
+        stp     t2, t3, [d, #-32]
+        str     t4, [d, #-40]
+        ret
+        .align  5
+        ldp     t0, t1, [s, #-16]       // -2 = 6 words
+        ldp     t2, t3, [s, #-32]
+        ldp     t4, t5, [s, #-48]
+        stp     t0, t1, [d, #-16]
+        stp     t2, t3, [d, #-32]
+        stp     t4, t5, [d, #-48]
+        ret
+        .align  5
+        ldp     t0, t1, [s, #-16]       // -1 = 7 words
+        ldp     t2, t3, [s, #-32]
+        ldp     t4, t5, [s, #-48]
+        ldr     t6, [s, #-56]
+        stp     t0, t1, [d, #-16]
+        stp     t2, t3, [d, #-32]
+        stp     t4, t5, [d, #-48]
+        str     t6, [d, #-56]
+        // Is always aligned here, code for 7 words is one instruction
+        // too large so it just falls through.
+        .align  5
+0:
+        ret
--- a/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -257,7 +257,38 @@
   }
 }
 
-void Canonicalizer::do_LoadIndexed    (LoadIndexed*     x) {}
+void Canonicalizer::do_LoadIndexed    (LoadIndexed*     x) {
+  StableArrayConstant* array = x->array()->type()->as_StableArrayConstant();
+  IntConstant* index = x->index()->type()->as_IntConstant();
+
+  assert(array == NULL || FoldStableValues, "not enabled");
+
+  // Constant fold loads from stable arrays.
+  if (array != NULL && index != NULL) {
+    jint idx = index->value();
+    if (idx < 0 || idx >= array->value()->length()) {
+      // Leave the load as is. The range check will handle it.
+      return;
+    }
+
+    ciConstant field_val = array->value()->element_value(idx);
+    if (!field_val.is_null_or_zero()) {
+      jint dimension = array->dimension();
+      assert(dimension <= array->value()->array_type()->dimension(), "inconsistent info");
+      ValueType* value = NULL;
+      if (dimension > 1) {
+        // Preserve information about the dimension for the element.
+        assert(field_val.as_object()->is_array(), "not an array");
+        value = new StableArrayConstant(field_val.as_object()->as_array(), dimension - 1);
+      } else {
+        assert(dimension == 1, "sanity");
+        value = as_ValueType(field_val);
+      }
+      set_canonical(new Constant(value));
+    }
+  }
+}
+
 void Canonicalizer::do_StoreIndexed   (StoreIndexed*    x) {
   // If a value is going to be stored into a field or array some of
   // the conversions emitted by javac are unneeded because the fields
@@ -471,7 +502,7 @@
     InstanceConstant* c = x->argument_at(0)->type()->as_InstanceConstant();
     if (c != NULL && !c->value()->is_null_object()) {
       // ciInstance::java_mirror_type() returns non-NULL only for Java mirrors
-      ciType* t = c->value()->as_instance()->java_mirror_type();
+      ciType* t = c->value()->java_mirror_type();
       if (t->is_klass()) {
         // substitute cls.isInstance(obj) of a constant Class into
         // an InstantOf instruction
@@ -487,6 +518,17 @@
     }
     break;
   }
+  case vmIntrinsics::_isPrimitive        : {
+    assert(x->number_of_arguments() == 1, "wrong type");
+
+    // Class.isPrimitive is known on constant classes:
+    InstanceConstant* c = x->argument_at(0)->type()->as_InstanceConstant();
+    if (c != NULL && !c->value()->is_null_object()) {
+      ciType* t = c->value()->java_mirror_type();
+      set_constant(t->is_primitive_type());
+    }
+    break;
+  }
   }
 }
 
--- a/hotspot/src/share/vm/c1/c1_Compiler.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_Compiler.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -148,6 +148,7 @@
   case vmIntrinsics::_longBitsToDouble:
   case vmIntrinsics::_getClass:
   case vmIntrinsics::_isInstance:
+  case vmIntrinsics::_isPrimitive:
   case vmIntrinsics::_currentThread:
   case vmIntrinsics::_dabs:
   case vmIntrinsics::_dsqrt:
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -1519,6 +1519,29 @@
   append(new Return(x));
 }
 
+Value GraphBuilder::make_constant(ciConstant field_value, ciField* field) {
+  BasicType field_type = field_value.basic_type();
+  ValueType* value = as_ValueType(field_value);
+
+  // Attach dimension info to stable arrays.
+  if (FoldStableValues &&
+      field->is_stable() && field_type == T_ARRAY && !field_value.is_null_or_zero()) {
+    ciArray* array = field_value.as_object()->as_array();
+    jint dimension = field->type()->as_array_klass()->dimension();
+    value = new StableArrayConstant(array, dimension);
+  }
+
+  switch (field_type) {
+    case T_ARRAY:
+    case T_OBJECT:
+      if (field_value.as_object()->should_be_constant()) {
+        return new Constant(value);
+      }
+      return NULL; // Not a constant.
+    default:
+      return new Constant(value);
+  }
+}
 
 void GraphBuilder::access_field(Bytecodes::Code code) {
   bool will_link;
@@ -1563,22 +1586,13 @@
   switch (code) {
     case Bytecodes::_getstatic: {
       // check for compile-time constants, i.e., initialized static final fields
-      Instruction* constant = NULL;
+      Value constant = NULL;
       if (field->is_constant() && !PatchALot) {
-        ciConstant field_val = field->constant_value();
-        BasicType field_type = field_val.basic_type();
-        switch (field_type) {
-        case T_ARRAY:
-        case T_OBJECT:
-          if (field_val.as_object()->should_be_constant()) {
-            constant = new Constant(as_ValueType(field_val));
-          }
-          break;
-
-        default:
-          constant = new Constant(as_ValueType(field_val));
-        }
+        ciConstant field_value = field->constant_value();
         // Stable static fields are checked for non-default values in ciField::initialize_from().
+        assert(!field->is_stable() || !field_value.is_null_or_zero(),
+               "stable static w/ default value shouldn't be a constant");
+        constant = make_constant(field_value, field);
       }
       if (constant != NULL) {
         push(type, append(constant));
@@ -1591,38 +1605,29 @@
       }
       break;
     }
-    case Bytecodes::_putstatic:
-      { Value val = pop(type);
-        if (state_before == NULL) {
-          state_before = copy_state_for_exception();
-        }
-        append(new StoreField(append(obj), offset, field, val, true, state_before, needs_patching));
+    case Bytecodes::_putstatic: {
+      Value val = pop(type);
+      if (state_before == NULL) {
+        state_before = copy_state_for_exception();
       }
+      append(new StoreField(append(obj), offset, field, val, true, state_before, needs_patching));
       break;
+    }
     case Bytecodes::_getfield: {
       // Check for compile-time constants, i.e., trusted final non-static fields.
-      Instruction* constant = NULL;
+      Value constant = NULL;
       obj = apop();
       ObjectType* obj_type = obj->type()->as_ObjectType();
       if (obj_type->is_constant() && !PatchALot) {
         ciObject* const_oop = obj_type->constant_value();
         if (!const_oop->is_null_object() && const_oop->is_loaded()) {
           if (field->is_constant()) {
-            ciConstant field_val = field->constant_value_of(const_oop);
-            BasicType field_type = field_val.basic_type();
-            switch (field_type) {
-            case T_ARRAY:
-            case T_OBJECT:
-              if (field_val.as_object()->should_be_constant()) {
-                constant = new Constant(as_ValueType(field_val));
-              }
-              break;
-            default:
-              constant = new Constant(as_ValueType(field_val));
-            }
-            if (FoldStableValues && field->is_stable() && field_val.is_null_or_zero()) {
+            ciConstant field_value = field->constant_value_of(const_oop);
+            if (FoldStableValues && field->is_stable() && field_value.is_null_or_zero()) {
               // Stable field with default value can't be constant.
               constant = NULL;
+            } else {
+              constant = make_constant(field_value, field);
             }
           } else {
             // For CallSite objects treat the target field as a compile time constant.
@@ -3942,7 +3947,7 @@
 
 
 bool GraphBuilder::try_method_handle_inline(ciMethod* callee) {
-  ValueStack* state_before = state()->copy_for_parsing();
+  ValueStack* state_before = copy_state_before();
   vmIntrinsics::ID iid = callee->intrinsic_id();
   switch (iid) {
   case vmIntrinsics::_invokeBasic:
@@ -4032,7 +4037,7 @@
     fatal("unexpected intrinsic %d: %s", iid, vmIntrinsics::name_at(iid));
     break;
   }
-  set_state(state_before);
+  set_state(state_before->copy_for_parsing());
   return false;
 }
 
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -276,6 +276,7 @@
   void iterate_all_blocks(bool start_in_current_block_for_inlining = false);
   Dependencies* dependency_recorder() const; // = compilation()->dependencies()
   bool direct_compare(ciKlass* k);
+  Value make_constant(ciConstant value, ciField* field);
 
   void kill_all();
 
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -1296,6 +1296,25 @@
   __ move_wide(new LIR_Address(temp, in_bytes(Klass::java_mirror_offset()), T_OBJECT), result);
 }
 
+// java.lang.Class::isPrimitive()
+void LIRGenerator::do_isPrimitive(Intrinsic* x) {
+  assert(x->number_of_arguments() == 1, "wrong type");
+
+  LIRItem rcvr(x->argument_at(0), this);
+  rcvr.load_item();
+  LIR_Opr temp = new_register(T_METADATA);
+  LIR_Opr result = rlock_result(x);
+
+  CodeEmitInfo* info = NULL;
+  if (x->needs_null_check()) {
+    info = state_for(x);
+  }
+
+  __ move(new LIR_Address(rcvr.result(), java_lang_Class::klass_offset_in_bytes(), T_ADDRESS), temp, info);
+  __ cmp(lir_cond_notEqual, temp, LIR_OprFact::intConst(0));
+  __ cmove(lir_cond_notEqual, LIR_OprFact::intConst(0), LIR_OprFact::intConst(1), result, T_BOOLEAN);
+}
+
 
 // Example: Thread.currentThread()
 void LIRGenerator::do_currentThread(Intrinsic* x) {
@@ -3098,6 +3117,7 @@
 
   case vmIntrinsics::_Object_init:    do_RegisterFinalizer(x); break;
   case vmIntrinsics::_isInstance:     do_isInstance(x);    break;
+  case vmIntrinsics::_isPrimitive:    do_isPrimitive(x);   break;
   case vmIntrinsics::_getClass:       do_getClass(x);      break;
   case vmIntrinsics::_currentThread:  do_currentThread(x); break;
 
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -246,6 +246,7 @@
 
   void do_RegisterFinalizer(Intrinsic* x);
   void do_isInstance(Intrinsic* x);
+  void do_isPrimitive(Intrinsic* x);
   void do_getClass(Intrinsic* x);
   void do_currentThread(Intrinsic* x);
   void do_MathIntrinsic(Intrinsic* x);
--- a/hotspot/src/share/vm/c1/c1_Runtime1.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_Runtime1.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -335,6 +335,7 @@
   NOT_PRODUCT(_new_instance_slowcase_cnt++;)
 
   assert(klass->is_klass(), "not a class");
+  Handle holder(THREAD, klass->klass_holder()); // keep the klass alive
   instanceKlassHandle h(thread, klass);
   h->check_valid_for_instantiation(true, CHECK);
   // make sure klass is initialized
@@ -370,6 +371,7 @@
   //       anymore after new_objArray() and no GC can happen before.
   //       (This may have to change if this code changes!)
   assert(array_klass->is_klass(), "not a class");
+  Handle holder(THREAD, array_klass->klass_holder()); // keep the klass alive
   Klass* elem_klass = ObjArrayKlass::cast(array_klass)->element_klass();
   objArrayOop obj = oopFactory::new_objArray(elem_klass, length, CHECK);
   thread->set_vm_result(obj);
@@ -386,6 +388,7 @@
 
   assert(klass->is_klass(), "not a class");
   assert(rank >= 1, "rank must be nonzero");
+  Handle holder(THREAD, klass->klass_holder()); // keep the klass alive
   oop obj = ArrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK);
   thread->set_vm_result(obj);
 JRT_END
--- a/hotspot/src/share/vm/c1/c1_ValueType.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_ValueType.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -45,6 +45,7 @@
 class     ObjectConstant;
 class     ArrayType;
 class       ArrayConstant;
+class         StableArrayConstant;
 class     InstanceType;
 class       InstanceConstant;
 class   MetadataType;
@@ -168,6 +169,7 @@
   virtual MethodConstant*   as_MethodConstant()  { return NULL; }
   virtual MethodDataConstant* as_MethodDataConstant() { return NULL; }
   virtual ArrayConstant*    as_ArrayConstant()   { return NULL; }
+  virtual StableArrayConstant* as_StableArrayConstant()   { return NULL; }
   virtual AddressConstant*  as_AddressConstant() { return NULL; }
 
   // type operations
@@ -355,6 +357,20 @@
   virtual ciType* exact_type() const;
 };
 
+class StableArrayConstant: public ArrayConstant {
+ private:
+  jint _dimension;
+
+ public:
+  StableArrayConstant(ciArray* value, jint dimension) : ArrayConstant(value) {
+    assert(dimension > 0, "not a stable array");
+    _dimension = dimension;
+  }
+
+  jint dimension() const                              { return _dimension; }
+
+  virtual StableArrayConstant* as_StableArrayConstant() { return this; }
+};
 
 class InstanceType: public ObjectType {
  public:
--- a/hotspot/src/share/vm/ci/ciMethodData.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/ci/ciMethodData.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -81,7 +81,7 @@
 void ciMethodData::load_extra_data() {
   MethodData* mdo = get_MethodData();
 
-  MutexLocker(mdo->extra_data_lock());
+  MutexLocker ml(mdo->extra_data_lock());
 
   // speculative trap entries also hold a pointer to a Method so need to be translated
   DataLayout* dp_src  = mdo->extra_data_base();
@@ -103,16 +103,13 @@
 
     switch(tag) {
     case DataLayout::speculative_trap_data_tag: {
-      ciSpeculativeTrapData* data_dst = new ciSpeculativeTrapData(dp_dst);
-      SpeculativeTrapData* data_src = new SpeculativeTrapData(dp_src);
-
-      data_dst->translate_from(data_src);
+      ciSpeculativeTrapData data_dst(dp_dst);
+      SpeculativeTrapData   data_src(dp_src);
 
-#ifdef ASSERT
-      SpeculativeTrapData* data_src2 = new SpeculativeTrapData(dp_src);
-      assert(data_src2->method() == data_src->method() && data_src2->bci() == data_src->bci(), "entries changed while translating");
-#endif
-
+      { // During translation a safepoint can happen or VM lock can be taken (e.g., Compile_lock).
+        MutexUnlocker ml(mdo->extra_data_lock());
+        data_dst.translate_from(&data_src);
+      }
       break;
     }
     case DataLayout::bit_data_tag:
@@ -120,9 +117,11 @@
     case DataLayout::no_tag:
     case DataLayout::arg_info_data_tag:
       // An empty slot or ArgInfoData entry marks the end of the trap data
-      return;
+      {
+        return; // Need a block to avoid SS compiler bug
+      }
     default:
-      fatal("bad tag = %d", dp_dst->tag());
+      fatal("bad tag = %d", tag);
     }
   }
 }
--- a/hotspot/src/share/vm/classfile/vmSymbols.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -1060,14 +1060,15 @@
    do_name(     updateByteBuffer_A_name,                          "updateByteBuffer")                                   \
                                                                                                                         \
   /* support for Unsafe */                                                                                              \
-  do_class(sun_misc_Unsafe,                        "sun/misc/Unsafe")                                                   \
   do_class(jdk_internal_misc_Unsafe,               "jdk/internal/misc/Unsafe")                                          \
                                                                                                                         \
   do_intrinsic(_allocateInstance,         jdk_internal_misc_Unsafe,     allocateInstance_name, allocateInstance_signature, F_RN) \
    do_name(     allocateInstance_name,                                  "allocateInstance")                                      \
    do_signature(allocateInstance_signature,                             "(Ljava/lang/Class;)Ljava/lang/Object;")                 \
+  do_intrinsic(_allocateUninitializedArray, jdk_internal_misc_Unsafe,   allocateUninitializedArray_name, newArray_signature,  F_R) \
+   do_name(     allocateUninitializedArray_name,                        "allocateUninitializedArray0")                           \
   do_intrinsic(_copyMemory,               jdk_internal_misc_Unsafe,     copyMemory_name, copyMemory_signature,         F_RN)     \
-   do_name(     copyMemory_name,                                        "copyMemory")                                            \
+   do_name(     copyMemory_name,                                        "copyMemory0")                                           \
    do_signature(copyMemory_signature,                                   "(Ljava/lang/Object;JLjava/lang/Object;JJ)V")            \
   do_intrinsic(_loadFence,                jdk_internal_misc_Unsafe,     loadFence_name, loadFence_signature,           F_RN)     \
    do_name(     loadFence_name,                                         "loadFence")                                             \
--- a/hotspot/src/share/vm/code/codeCache.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/code/codeCache.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -637,16 +637,19 @@
 }
 
 // Walk the list of methods which might contain non-perm oops.
-void CodeCache::scavenge_root_nmethods_do(CodeBlobClosure* f) {
+void CodeCache::scavenge_root_nmethods_do(CodeBlobToOopClosure* f) {
   assert_locked_or_safepoint(CodeCache_lock);
 
   if (UseG1GC) {
     return;
   }
 
+  const bool fix_relocations = f->fix_relocations();
   debug_only(mark_scavenge_root_nmethods());
 
-  for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) {
+  nmethod* prev = NULL;
+  nmethod* cur = scavenge_root_nmethods();
+  while (cur != NULL) {
     debug_only(cur->clear_scavenge_root_marked());
     assert(cur->scavenge_root_not_marked(), "");
     assert(cur->on_scavenge_root_list(), "else shouldn't be on this list");
@@ -659,6 +662,18 @@
       // Perform cur->oops_do(f), maybe just once per nmethod.
       f->do_code_blob(cur);
     }
+    nmethod* const next = cur->scavenge_root_link();
+    // The scavengable nmethod list must contain all methods with scavengable
+    // oops. It is safe to include more nmethod on the list, but we do not
+    // expect any live non-scavengable nmethods on the list.
+    if (fix_relocations) {
+      if (!is_live || !cur->detect_scavenge_root_oops()) {
+        unlink_scavenge_root_nmethod(cur, prev);
+      } else {
+        prev = cur;
+      }
+    }
+    cur = next;
   }
 
   // Check for stray marks.
@@ -678,6 +693,24 @@
   print_trace("add_scavenge_root", nm);
 }
 
+void CodeCache::unlink_scavenge_root_nmethod(nmethod* nm, nmethod* prev) {
+  assert_locked_or_safepoint(CodeCache_lock);
+
+  assert((prev == NULL && scavenge_root_nmethods() == nm) ||
+         (prev != NULL && prev->scavenge_root_link() == nm), "precondition");
+
+  assert(!UseG1GC, "G1 does not use the scavenge_root_nmethods list");
+
+  print_trace("unlink_scavenge_root", nm);
+  if (prev == NULL) {
+    set_scavenge_root_nmethods(nm->scavenge_root_link());
+  } else {
+    prev->set_scavenge_root_link(nm->scavenge_root_link());
+  }
+  nm->set_scavenge_root_link(NULL);
+  nm->clear_on_scavenge_root_list();
+}
+
 void CodeCache::drop_scavenge_root_nmethod(nmethod* nm) {
   assert_locked_or_safepoint(CodeCache_lock);
 
@@ -686,20 +719,13 @@
   }
 
   print_trace("drop_scavenge_root", nm);
-  nmethod* last = NULL;
-  nmethod* cur = scavenge_root_nmethods();
-  while (cur != NULL) {
-    nmethod* next = cur->scavenge_root_link();
+  nmethod* prev = NULL;
+  for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) {
     if (cur == nm) {
-      if (last != NULL)
-            last->set_scavenge_root_link(next);
-      else  set_scavenge_root_nmethods(next);
-      nm->set_scavenge_root_link(NULL);
-      nm->clear_on_scavenge_root_list();
+      unlink_scavenge_root_nmethod(cur, prev);
       return;
     }
-    last = cur;
-    cur = next;
+    prev = cur;
   }
   assert(false, "should have been on list");
 }
@@ -728,11 +754,7 @@
     } else {
       // Prune it from the list, so we don't have to look at it any more.
       print_trace("prune_scavenge_root", cur);
-      cur->set_scavenge_root_link(NULL);
-      cur->clear_on_scavenge_root_list();
-      if (last != NULL)
-            last->set_scavenge_root_link(next);
-      else  set_scavenge_root_nmethods(next);
+      unlink_scavenge_root_nmethod(cur, last);
     }
     cur = next;
   }
--- a/hotspot/src/share/vm/code/codeCache.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/code/codeCache.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -116,6 +116,10 @@
   static int    allocated_segments();
   static size_t freelists_length();
 
+  static void set_scavenge_root_nmethods(nmethod* nm) { _scavenge_root_nmethods = nm; }
+  static void prune_scavenge_root_nmethods();
+  static void unlink_scavenge_root_nmethod(nmethod* nm, nmethod* prev);
+
  public:
   // Initialization
   static void initialize();
@@ -153,13 +157,17 @@
   // to "true" iff some code got unloaded.
   static void do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred);
   static void asserted_non_scavengable_nmethods_do(CodeBlobClosure* f = NULL) PRODUCT_RETURN;
-  static void scavenge_root_nmethods_do(CodeBlobClosure* f);
+
+  // Apply f to every live code blob in scavengable nmethods. Prune nmethods
+  // from the list of scavengable nmethods if f->fix_relocations() and a nmethod
+  // no longer has scavengable oops.  If f->fix_relocations(), then f must copy
+  // objects to their new location immediately to avoid fixing nmethods on the
+  // basis of the old object locations.
+  static void scavenge_root_nmethods_do(CodeBlobToOopClosure* f);
 
   static nmethod* scavenge_root_nmethods()            { return _scavenge_root_nmethods; }
-  static void set_scavenge_root_nmethods(nmethod* nm) { _scavenge_root_nmethods = nm; }
   static void add_scavenge_root_nmethod(nmethod* nm);
   static void drop_scavenge_root_nmethod(nmethod* nm);
-  static void prune_scavenge_root_nmethods();
 
   // Printing/debugging
   static void print();                           // prints summary
--- a/hotspot/src/share/vm/code/debugInfoRec.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/code/debugInfoRec.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -369,7 +369,6 @@
   assert(method == NULL ||
          (method->is_native() && bci == 0) ||
          (!method->is_native() && 0 <= bci && bci < method->code_size()) ||
-         (method->is_compiled_lambda_form() && bci == -99) ||  // this might happen in C1
          bci == -1, "illegal bci");
 
   // serialize the locals/expressions/monitors
--- a/hotspot/src/share/vm/code/nmethod.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/code/nmethod.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -1381,7 +1381,6 @@
   assert(_method == NULL, "Tautology");
 
   set_osr_link(NULL);
-  //set_scavenge_root_link(NULL); // done by prune_scavenge_root_nmethods
   NMethodSweeper::report_state_change(this);
 }
 
--- a/hotspot/src/share/vm/compiler/compileBroker.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/compiler/compileBroker.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -838,12 +838,8 @@
                                         const methodHandle& hot_method,
                                         int hot_count,
                                         const char* comment,
+                                        bool blocking,
                                         Thread* thread) {
-  // do nothing if compiler thread(s) is not available
-  if (!_initialized) {
-    return;
-  }
-
   guarantee(!method->is_abstract(), "cannot compile abstract methods");
   assert(method->method_holder()->is_instance_klass(),
          "sanity check");
@@ -916,7 +912,6 @@
 
   // Outputs from the following MutexLocker block:
   CompileTask* task     = NULL;
-  bool         blocking = false;
   CompileQueue* queue  = compile_queue(comp_level);
 
   // Acquire our lock.
@@ -946,9 +941,6 @@
       return;
     }
 
-    // Should this thread wait for completion of the compile?
-    blocking = is_compile_blocking();
-
 #if INCLUDE_JVMCI
     if (UseJVMCICompiler) {
       if (blocking) {
@@ -1034,11 +1026,28 @@
   }
 }
 
-
 nmethod* CompileBroker::compile_method(const methodHandle& method, int osr_bci,
                                        int comp_level,
                                        const methodHandle& hot_method, int hot_count,
                                        const char* comment, Thread* THREAD) {
+  // do nothing if compilebroker is not available
+  if (!_initialized) {
+    return NULL;
+  }
+  AbstractCompiler *comp = CompileBroker::compiler(comp_level);
+  assert(comp != NULL, "Ensure we don't compile before compilebroker init");
+  DirectiveSet* directive = DirectivesStack::getMatchingDirective(method, comp);
+  nmethod* nm = CompileBroker::compile_method(method, osr_bci, comp_level, hot_method, hot_count, comment, directive, THREAD);
+  DirectivesStack::release(directive);
+  return nm;
+}
+
+nmethod* CompileBroker::compile_method(const methodHandle& method, int osr_bci,
+                                         int comp_level,
+                                         const methodHandle& hot_method, int hot_count,
+                                         const char* comment, DirectiveSet* directive,
+                                         Thread* THREAD) {
+
   // make sure arguments make sense
   assert(method->method_holder()->is_instance_klass(), "not an instance method");
   assert(osr_bci == InvocationEntryBci || (0 <= osr_bci && osr_bci < method->code_size()), "bci out of range");
@@ -1051,8 +1060,8 @@
   // lock, make sure that the compilation
   // isn't prohibited in a straightforward way.
   AbstractCompiler *comp = CompileBroker::compiler(comp_level);
-  if (comp == NULL || !comp->can_compile_method(method) ||
-      compilation_is_prohibited(method, osr_bci, comp_level)) {
+  if (!comp->can_compile_method(method) ||
+      compilation_is_prohibited(method, osr_bci, comp_level, directive->ExcludeOption)) {
     return NULL;
   }
 
@@ -1160,7 +1169,7 @@
       CompilationPolicy::policy()->delay_compilation(method());
       return NULL;
     }
-    compile_method_base(method, osr_bci, comp_level, hot_method, hot_count, comment, THREAD);
+    compile_method_base(method, osr_bci, comp_level, hot_method, hot_count, comment, !directive->BackgroundCompilationOption, THREAD);
   }
 
   // return requested nmethod
@@ -1217,7 +1226,7 @@
 // CompileBroker::compilation_is_prohibited
 //
 // See if this compilation is not allowed.
-bool CompileBroker::compilation_is_prohibited(const methodHandle& method, int osr_bci, int comp_level) {
+bool CompileBroker::compilation_is_prohibited(const methodHandle& method, int osr_bci, int comp_level, bool excluded) {
   bool is_native = method->is_native();
   // Some compilers may not support the compilation of natives.
   AbstractCompiler *comp = compiler(comp_level);
@@ -1235,11 +1244,6 @@
     return true;
   }
 
-  // Breaking the abstraction - directives are only used inside a compilation otherwise.
-  DirectiveSet* directive = DirectivesStack::getMatchingDirective(method, comp);
-  bool excluded = directive->ExcludeOption;
-  DirectivesStack::release(directive);
-
   // The method may be explicitly excluded by the user.
   double scale;
   if (excluded || (CompilerOracle::has_option_value(method, "CompileThresholdScaling", scale) && scale == 0)) {
@@ -1304,16 +1308,6 @@
   return assign_compile_id(method, osr_bci);
 }
 
-/**
- * Should the current thread block until this compilation request
- * has been fulfilled?
- */
-bool CompileBroker::is_compile_blocking() {
-  assert(!InstanceRefKlass::owns_pending_list_lock(JavaThread::current()), "possible deadlock");
-  return !BackgroundCompilation;
-}
-
-
 // ------------------------------------------------------------------
 // CompileBroker::preload_classes
 void CompileBroker::preload_classes(const methodHandle& method, TRAPS) {
--- a/hotspot/src/share/vm/compiler/compileBroker.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/compiler/compileBroker.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -222,8 +222,7 @@
   static JavaThread* make_thread(const char* name, CompileQueue* queue, CompilerCounters* counters, AbstractCompiler* comp, bool compiler_thread, TRAPS);
   static void init_compiler_sweeper_threads(int c1_compiler_count, int c2_compiler_count);
   static bool compilation_is_complete  (const methodHandle& method, int osr_bci, int comp_level);
-  static bool compilation_is_prohibited(const methodHandle& method, int osr_bci, int comp_level);
-  static bool is_compile_blocking();
+  static bool compilation_is_prohibited(const methodHandle& method, int osr_bci, int comp_level, bool excluded);
   static void preload_classes          (const methodHandle& method, TRAPS);
 
   static CompileTask* create_compile_task(CompileQueue*       queue,
@@ -253,6 +252,7 @@
                                   const methodHandle& hot_method,
                                   int hot_count,
                                   const char* comment,
+                                  bool blocking,
                                   Thread* thread);
 
   static CompileQueue* compile_queue(int comp_level);
@@ -291,6 +291,15 @@
                                  int hot_count,
                                  const char* comment, Thread* thread);
 
+  static nmethod* compile_method(const methodHandle& method,
+                                   int osr_bci,
+                                   int comp_level,
+                                   const methodHandle& hot_method,
+                                   int hot_count,
+                                   const char* comment,
+                                   DirectiveSet* directive,
+                                   Thread* thread);
+
   // Acquire any needed locks and assign a compile id
   static uint assign_compile_id_unlocked(Thread* thread, const methodHandle& method, int osr_bci);
 
--- a/hotspot/src/share/vm/compiler/compilerDirectives.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/compiler/compilerDirectives.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -472,9 +472,12 @@
   _depth++;
 }
 
-void DirectivesStack::pop() {
+void DirectivesStack::pop(int count) {
   MutexLockerEx locker(DirectivesStack_lock, Mutex::_no_safepoint_check_flag);
-  pop_inner();
+  assert(count > -1, "No negative values");
+  for (int i = 0; i < count; i++) {
+    pop_inner();
+  }
 }
 
 void DirectivesStack::pop_inner() {
--- a/hotspot/src/share/vm/compiler/compilerDirectives.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/compiler/compilerDirectives.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,6 +42,7 @@
     cflags(PrintAssembly,           bool, PrintAssembly, PrintAssembly) \
     cflags(PrintInlining,           bool, PrintInlining, PrintInlining) \
     cflags(PrintNMethods,           bool, PrintNMethods, PrintNMethods) \
+    cflags(BackgroundCompilation,   bool, BackgroundCompilation, BackgroundCompilation) \
     cflags(ReplayInline,            bool, false, ReplayInline) \
     cflags(DumpReplay,              bool, false, DumpReplay) \
     cflags(DumpInline,              bool, false, DumpInline) \
@@ -87,7 +88,7 @@
   static DirectiveSet* getMatchingDirective(methodHandle mh, AbstractCompiler* comp);
   static DirectiveSet* getDefaultDirective(AbstractCompiler* comp);
   static void push(CompilerDirectives* directive);
-  static void pop();
+  static void pop(int count);
   static bool check_capacity(int request_size, outputStream* st);
   static void clear();
   static void print(outputStream* st);
--- a/hotspot/src/share/vm/compiler/directivesParser.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/compiler/directivesParser.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -55,7 +55,7 @@
   assert(_tmp_depth == 0, "Consistency");
 }
 
-bool DirectivesParser::parse_string(const char* text, outputStream* st) {
+int DirectivesParser::parse_string(const char* text, outputStream* st) {
   DirectivesParser cd(text, st);
   if (cd.valid()) {
     return cd.install_directives();
@@ -63,7 +63,7 @@
     cd.clean_tmp();
     st->flush();
     st->print_cr("Parsing of compiler directives failed");
-    return false;
+    return -1;
   }
 }
 
@@ -97,17 +97,17 @@
       buffer[num_read] = '\0';
       // close file
       os::close(file_handle);
-      return parse_string(buffer, stream);
+      return parse_string(buffer, stream) > 0;
     }
   }
   return false;
 }
 
-bool DirectivesParser::install_directives() {
+int DirectivesParser::install_directives() {
   // Check limit
   if (!DirectivesStack::check_capacity(_tmp_depth, _st)) {
     clean_tmp();
-    return false;
+    return 0;
   }
 
   // Pop from internal temporary stack and push to compileBroker.
@@ -120,14 +120,14 @@
   }
   if (i == 0) {
     _st->print_cr("No directives in file");
-    return false;
+    return 0;
   } else {
     _st->print_cr("%i compiler directives added", i);
     if (CompilerDirectivesPrint) {
       // Print entire directives stack after new has been pushed.
       DirectivesStack::print(_st);
     }
-    return true;
+    return i;
   }
 }
 
--- a/hotspot/src/share/vm/compiler/directivesParser.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/compiler/directivesParser.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -51,8 +51,8 @@
   static bool has_file();
   static bool parse_from_flag();
   static bool parse_from_file(const char* filename, outputStream* st);
-  static bool parse_string(const char* string, outputStream* st);
-  bool install_directives();
+  static int  parse_string(const char* string, outputStream* st);
+  int install_directives();
 
 private:
   DirectivesParser(const char* text, outputStream* st);
--- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -2329,9 +2329,13 @@
     GCIdMarkAndRestore conc_gc_id_mark(_cmThread->gc_id());
     if (_cm->has_aborted()) {
       _gc_tracer_cm->report_concurrent_mode_failure();
+
+      // ConcurrentGCTimer will be ended as well.
+      _cm->register_concurrent_gc_end_and_stop_timer();
+    } else {
+      _gc_timer_cm->register_gc_end();
     }
 
-    _gc_timer_cm->register_gc_end();
     _gc_tracer_cm->report_gc_end(_gc_timer_cm->gc_end(), _gc_timer_cm->time_partitions());
 
     // Clear state variables to prepare for the next concurrent cycle.
--- a/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -269,6 +269,8 @@
   _reserve_regions = 0;
 
   _cset_chooser = new CollectionSetChooser();
+
+  _ihop_control = create_ihop_control();
 }
 
 G1CollectorPolicy::~G1CollectorPolicy() {
@@ -469,8 +471,6 @@
   if (max_young_size != MaxNewSize) {
     FLAG_SET_ERGO(size_t, MaxNewSize, max_young_size);
   }
-
-  _ihop_control = create_ihop_control();
 }
 
 void G1CollectorPolicy::initialize_flags() {
@@ -565,6 +565,8 @@
   _reserve_regions = (uint) ceil(reserve_regions_d);
 
   _young_gen_sizer->heap_size_changed(new_number_of_regions);
+
+  _ihop_control->update_target_occupancy(new_number_of_regions * HeapRegion::GrainBytes);
 }
 
 uint G1CollectorPolicy::calculate_young_list_desired_min_length(
@@ -1234,13 +1236,11 @@
 G1IHOPControl* G1CollectorPolicy::create_ihop_control() const {
   if (G1UseAdaptiveIHOP) {
     return new G1AdaptiveIHOPControl(InitiatingHeapOccupancyPercent,
-                                     G1CollectedHeap::heap()->max_capacity(),
                                      &_predictor,
                                      G1ReservePercent,
                                      G1HeapWastePercent);
   } else {
-    return new G1StaticIHOPControl(InitiatingHeapOccupancyPercent,
-                                   G1CollectedHeap::heap()->max_capacity());
+    return new G1StaticIHOPControl(InitiatingHeapOccupancyPercent);
   }
 }
 
--- a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -441,7 +441,7 @@
   _has_aborted(false),
   _restart_for_overflow(false),
   _concurrent_marking_in_progress(false),
-  _concurrent_phase_started(false),
+  _concurrent_phase_status(ConcPhaseNotStarted),
 
   // _verbose_level set below
 
@@ -1008,16 +1008,43 @@
 }
 
 void G1ConcurrentMark::register_concurrent_phase_start(const char* title) {
-  assert(!_concurrent_phase_started, "Sanity");
-  _concurrent_phase_started = true;
+  uint old_val = 0;
+  do {
+    old_val = Atomic::cmpxchg(ConcPhaseStarted, &_concurrent_phase_status, ConcPhaseNotStarted);
+  } while (old_val != ConcPhaseNotStarted);
   _g1h->gc_timer_cm()->register_gc_concurrent_start(title);
 }
 
+void G1ConcurrentMark::register_concurrent_phase_end_common(bool end_timer) {
+  if (_concurrent_phase_status == ConcPhaseNotStarted) {
+    return;
+  }
+
+  uint old_val = Atomic::cmpxchg(ConcPhaseStopping, &_concurrent_phase_status, ConcPhaseStarted);
+  if (old_val == ConcPhaseStarted) {
+    _g1h->gc_timer_cm()->register_gc_concurrent_end();
+    // If 'end_timer' is true, we came here to end timer which needs concurrent phase ended.
+    // We need to end it before changing the status to 'ConcPhaseNotStarted' to prevent
+    // starting a new concurrent phase by 'ConcurrentMarkThread'.
+    if (end_timer) {
+      _g1h->gc_timer_cm()->register_gc_end();
+    }
+    old_val = Atomic::cmpxchg(ConcPhaseNotStarted, &_concurrent_phase_status, ConcPhaseStopping);
+    assert(old_val == ConcPhaseStopping, "Should not have changed since we entered this scope.");
+  } else {
+    do {
+      // Let other thread finish changing '_concurrent_phase_status' to 'ConcPhaseNotStarted'.
+      os::naked_short_sleep(1);
+    } while (_concurrent_phase_status != ConcPhaseNotStarted);
+  }
+}
+
 void G1ConcurrentMark::register_concurrent_phase_end() {
-  if (_concurrent_phase_started) {
-    _concurrent_phase_started = false;
-    _g1h->gc_timer_cm()->register_gc_concurrent_end();
-  }
+  register_concurrent_phase_end_common(false);
+}
+
+void G1ConcurrentMark::register_concurrent_gc_end_and_stop_timer() {
+  register_concurrent_phase_end_common(true);
 }
 
 void G1ConcurrentMark::markFromRoots() {
@@ -2605,9 +2632,6 @@
 
   _g1h->trace_heap_after_concurrent_cycle();
 
-  // Close any open concurrent phase timing
-  register_concurrent_phase_end();
-
   _g1h->register_concurrent_cycle_end();
 }
 
--- a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -352,8 +352,17 @@
   // time of remark.
   volatile bool           _concurrent_marking_in_progress;
 
-  // Keep track of whether we have started concurrent phase or not.
-  bool                    _concurrent_phase_started;
+  // There would be a race between ConcurrentMarkThread and VMThread(ConcurrentMark::abort())
+  // to call ConcurrentGCTimer::register_gc_concurrent_end().
+  // And this variable is used to keep track of concurrent phase.
+  volatile uint           _concurrent_phase_status;
+  // Concurrent phase is not yet started.
+  static const uint       ConcPhaseNotStarted = 0;
+  // Concurrent phase is started.
+  static const uint       ConcPhaseStarted = 1;
+  // Caller thread of ConcurrentGCTimer::register_gc_concurrent_end() is ending concurrent phase.
+  // So other thread should wait until the status to be changed to ConcPhaseNotStarted.
+  static const uint       ConcPhaseStopping = 2;
 
   // All of these times are in ms
   NumberSeq _init_times;
@@ -485,6 +494,9 @@
   // Set to true when initialization is complete
   bool _completed_initialization;
 
+  // end_timer, true to end gc timer after ending concurrent phase.
+  void register_concurrent_phase_end_common(bool end_timer);
+
 public:
   // Manipulation of the global mark stack.
   // The push and pop operations are used by tasks for transfers
@@ -520,6 +532,8 @@
 
   void register_concurrent_phase_start(const char* title);
   void register_concurrent_phase_end();
+  // Ends both concurrent phase and timer.
+  void register_concurrent_gc_end_and_stop_timer();
 
   void update_accum_task_vtime(int i, double vtime) {
     _accum_task_vtime[i] += vtime;
--- a/hotspot/src/share/vm/gc/g1/g1IHOPControl.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/gc/g1/g1IHOPControl.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -29,15 +29,21 @@
 #include "gc/shared/gcTrace.hpp"
 #include "logging/log.hpp"
 
-G1IHOPControl::G1IHOPControl(double initial_ihop_percent, size_t target_occupancy) :
+G1IHOPControl::G1IHOPControl(double initial_ihop_percent) :
   _initial_ihop_percent(initial_ihop_percent),
-  _target_occupancy(target_occupancy),
+  _target_occupancy(0),
   _last_allocated_bytes(0),
   _last_allocation_time_s(0.0)
 {
   assert(_initial_ihop_percent >= 0.0 && _initial_ihop_percent <= 100.0, "Initial IHOP value must be between 0 and 100 but is %.3f", initial_ihop_percent);
 }
 
+void G1IHOPControl::update_target_occupancy(size_t new_target_occupancy) {
+  log_debug(gc, ihop)("Target occupancy update: old: " SIZE_FORMAT "B, new: " SIZE_FORMAT "B",
+                      _target_occupancy, new_target_occupancy);
+  _target_occupancy = new_target_occupancy;
+}
+
 void G1IHOPControl::update_allocation_info(double allocation_time_s, size_t allocated_bytes, size_t additional_buffer_size) {
   assert(allocation_time_s >= 0.0, "Allocation time must be positive but is %.3f", allocation_time_s);
 
@@ -46,6 +52,7 @@
 }
 
 void G1IHOPControl::print() {
+  assert(_target_occupancy > 0, "Target occupancy still not updated yet.");
   size_t cur_conc_mark_start_threshold = get_conc_mark_start_threshold();
   log_debug(gc, ihop)("Basic information (value update), threshold: " SIZE_FORMAT "B (%1.2f), target occupancy: " SIZE_FORMAT "B, current occupancy: " SIZE_FORMAT "B, "
                       "recent allocation size: " SIZE_FORMAT "B, recent allocation duration: %1.2fms, recent old gen allocation rate: %1.2fB/s, recent marking phase length: %1.2fms",
@@ -60,6 +67,7 @@
 }
 
 void G1IHOPControl::send_trace_event(G1NewTracer* tracer) {
+  assert(_target_occupancy > 0, "Target occupancy still not updated yet.");
   tracer->report_basic_ihop_statistics(get_conc_mark_start_threshold(),
                                        _target_occupancy,
                                        G1CollectedHeap::heap()->used(),
@@ -68,10 +76,9 @@
                                        last_marking_length_s());
 }
 
-G1StaticIHOPControl::G1StaticIHOPControl(double ihop_percent, size_t target_occupancy) :
-  G1IHOPControl(ihop_percent, target_occupancy),
+G1StaticIHOPControl::G1StaticIHOPControl(double ihop_percent) :
+  G1IHOPControl(ihop_percent),
   _last_marking_length_s(0.0) {
-  assert(_target_occupancy > 0, "Target occupancy must be larger than zero.");
 }
 
 #ifndef PRODUCT
@@ -85,7 +92,8 @@
 void G1StaticIHOPControl::test() {
   size_t const initial_ihop = 45;
 
-  G1StaticIHOPControl ctrl(initial_ihop, 100);
+  G1StaticIHOPControl ctrl(initial_ihop);
+  ctrl.update_target_occupancy(100);
 
   size_t threshold = ctrl.get_conc_mark_start_threshold();
   assert(threshold == initial_ihop,
@@ -115,11 +123,10 @@
 #endif
 
 G1AdaptiveIHOPControl::G1AdaptiveIHOPControl(double ihop_percent,
-                                             size_t initial_target_occupancy,
                                              G1Predictions const* predictor,
                                              size_t heap_reserve_percent,
                                              size_t heap_waste_percent) :
-  G1IHOPControl(ihop_percent, initial_target_occupancy),
+  G1IHOPControl(ihop_percent),
   _predictor(predictor),
   _marking_times_s(10, 0.95),
   _allocation_rate_s(10, 0.95),
@@ -130,6 +137,7 @@
 }
 
 size_t G1AdaptiveIHOPControl::actual_target_threshold() const {
+  guarantee(_target_occupancy > 0, "Target occupancy still not updated yet.");
   // The actual target threshold takes the heap reserve and the expected waste in
   // free space  into account.
   // _heap_reserve is that part of the total heap capacity that is reserved for
@@ -227,7 +235,8 @@
   // target_size - (young_size + alloc_amount/alloc_time * marking_time)
 
   G1Predictions pred(0.95);
-  G1AdaptiveIHOPControl ctrl(initial_threshold, target_size, &pred, 0, 0);
+  G1AdaptiveIHOPControl ctrl(initial_threshold, &pred, 0, 0);
+  ctrl.update_target_occupancy(target_size);
 
   // First "load".
   size_t const alloc_time1 = 2;
@@ -288,5 +297,6 @@
 
 void IHOP_test() {
   G1StaticIHOPControl::test();
+  G1AdaptiveIHOPControl::test();
 }
 #endif
--- a/hotspot/src/share/vm/gc/g1/g1IHOPControl.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/gc/g1/g1IHOPControl.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -38,7 +38,8 @@
  protected:
   // The initial IHOP value relative to the target occupancy.
   double _initial_ihop_percent;
-  // The target maximum occupancy of the heap.
+  // The target maximum occupancy of the heap. The target occupancy is the number
+  // of bytes when marking should be finished and reclaim started.
   size_t _target_occupancy;
 
   // Most recent complete mutator allocation period in seconds.
@@ -46,10 +47,9 @@
   // Amount of bytes allocated during _last_allocation_time_s.
   size_t _last_allocated_bytes;
 
-  // Initialize an instance with the initial IHOP value in percent and the target
-  // occupancy. The target occupancy is the number of bytes when marking should
-  // be finished and reclaim started.
-  G1IHOPControl(double initial_ihop_percent, size_t target_occupancy);
+  // Initialize an instance with the initial IHOP value in percent. The target
+  // occupancy will be updated at the first heap expansion.
+  G1IHOPControl(double initial_ihop_percent);
 
   // Most recent time from the end of the initial mark to the start of the first
   // mixed gc.
@@ -60,6 +60,8 @@
   // Get the current non-young occupancy at which concurrent marking should start.
   virtual size_t get_conc_mark_start_threshold() = 0;
 
+  // Adjust target occupancy.
+  virtual void update_target_occupancy(size_t new_target_occupancy);
   // Update information about time during which allocations in the Java heap occurred,
   // how large these allocations were in bytes, and an additional buffer.
   // The allocations should contain any amount of space made unusable for further
@@ -86,9 +88,12 @@
  protected:
   double last_marking_length_s() const { return _last_marking_length_s; }
  public:
-  G1StaticIHOPControl(double ihop_percent, size_t target_occupancy);
+  G1StaticIHOPControl(double ihop_percent);
 
-  size_t get_conc_mark_start_threshold() { return (size_t) (_initial_ihop_percent * _target_occupancy / 100.0); }
+  size_t get_conc_mark_start_threshold() {
+    guarantee(_target_occupancy > 0, "Target occupancy must have been initialized.");
+    return (size_t) (_initial_ihop_percent * _target_occupancy / 100.0);
+  }
 
   virtual void update_marking_length(double marking_length_s) {
    assert(marking_length_s > 0.0, "Marking length must be larger than zero but is %.3f", marking_length_s);
@@ -132,7 +137,6 @@
   virtual double last_marking_length_s() const { return _marking_times_s.last(); }
  public:
   G1AdaptiveIHOPControl(double ihop_percent,
-                        size_t initial_target_occupancy,
                         G1Predictions const* predictor,
                         size_t heap_reserve_percent, // The percentage of total heap capacity that should not be tapped into.
                         size_t heap_waste_percent);  // The percentage of the free space in the heap that we think is not usable for allocation.
--- a/hotspot/src/share/vm/gc/g1/g1OopClosures.inline.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/gc/g1/g1OopClosures.inline.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -171,14 +171,7 @@
 #ifdef ASSERT
   // can't do because of races
   // assert(obj == NULL || obj->is_oop(), "expected an oop");
-
-  // Do the safe subset of is_oop
-#ifdef CHECK_UNHANDLED_OOPS
-  oopDesc* o = obj.obj();
-#else
-  oopDesc* o = obj;
-#endif // CHECK_UNHANDLED_OOPS
-  assert((intptr_t)o % MinObjAlignmentInBytes == 0, "not oop aligned");
+  assert(check_obj_alignment(obj), "not oop aligned");
   assert(_g1->is_in_reserved(obj), "must be in heap");
 #endif // ASSERT
 
--- a/hotspot/src/share/vm/gc/g1/g1RemSet.inline.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/gc/g1/g1RemSet.inline.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -44,14 +44,7 @@
 #ifdef ASSERT
   // can't do because of races
   // assert(obj == NULL || obj->is_oop(), "expected an oop");
-
-  // Do the safe subset of is_oop
-#ifdef CHECK_UNHANDLED_OOPS
-  oopDesc* o = obj.obj();
-#else
-  oopDesc* o = obj;
-#endif // CHECK_UNHANDLED_OOPS
-  assert((intptr_t)o % MinObjAlignmentInBytes == 0, "not oop aligned");
+  assert(check_obj_alignment(obj), "not oop aligned");
   assert(_g1->is_in_reserved(obj), "must be in heap");
 #endif // ASSERT
 
--- a/hotspot/src/share/vm/gc/parallel/psCompactionManager.inline.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/gc/parallel/psCompactionManager.inline.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -125,14 +125,14 @@
   T* const beg = base + beg_index;
   T* const end = base + end_index;
 
+  if (end_index < len) {
+    cm->push_objarray(obj, end_index); // Push the continuation.
+  }
+
   // Push the non-NULL elements of the next stride on the marking stack.
   for (T* e = beg; e < end; e++) {
     cm->mark_and_push<T>(e);
   }
-
-  if (end_index < len) {
-    cm->push_objarray(obj, end_index); // Push the continuation.
-  }
 }
 
 inline void ParCompactionManager::follow_contents(objArrayOop obj, int index) {
--- a/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -1484,17 +1484,6 @@
 }
 
 void
-PSParallelCompact::clear_source_region(HeapWord* beg_addr, HeapWord* end_addr)
-{
-  RegionData* const beg_ptr = _summary_data.addr_to_region_ptr(beg_addr);
-  HeapWord* const end_aligned_up = _summary_data.region_align_up(end_addr);
-  RegionData* const end_ptr = _summary_data.addr_to_region_ptr(end_aligned_up);
-  for (RegionData* cur = beg_ptr; cur < end_ptr; ++cur) {
-    cur->set_source_region(0);
-  }
-}
-
-void
 PSParallelCompact::summarize_space(SpaceId id, bool maximum_compaction)
 {
   assert(id < last_space_id, "id out of range");
--- a/hotspot/src/share/vm/gc/parallel/psParallelCompact.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/gc/parallel/psParallelCompact.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -1065,9 +1065,6 @@
   // non-empty.
   static void fill_dense_prefix_end(SpaceId id);
 
-  // Clear the summary data source_region field for the specified addresses.
-  static void clear_source_region(HeapWord* beg_addr, HeapWord* end_addr);
-
   static void summarize_spaces_quick();
   static void summarize_space(SpaceId id, bool maximum_compaction);
   static void summary_phase(ParCompactionManager* cm, bool maximum_compaction);
--- a/hotspot/src/share/vm/gc/parallel/psScavenge.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/gc/parallel/psScavenge.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -600,12 +600,6 @@
 
     NOT_PRODUCT(reference_processor()->verify_no_references_recorded());
 
-    {
-      GCTraceTime(Debug, gc, phases) tm("Prune Scavenge Root Methods", &_gc_timer);
-
-      CodeCache::prune_scavenge_root_nmethods();
-    }
-
     // Re-verify object start arrays
     if (VerifyObjectStartArray &&
         VerifyAfterGC) {
--- a/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -561,7 +561,7 @@
                                      OopClosure* weak_roots,
                                      CLDClosure* strong_cld_closure,
                                      CLDClosure* weak_cld_closure,
-                                     CodeBlobClosure* code_roots) {
+                                     CodeBlobToOopClosure* code_roots) {
   // General roots.
   assert(Threads::thread_claim_parity() != 0, "must have called prologue code");
   assert(code_roots != NULL, "code root closure should always be set");
@@ -578,7 +578,7 @@
   // Don't process them if they will be processed during the ClassLoaderDataGraph phase.
   CLDClosure* roots_from_clds_p = (strong_cld_closure != weak_cld_closure) ? strong_cld_closure : NULL;
   // Only process code roots from thread stacks if we aren't visiting the entire CodeCache anyway
-  CodeBlobClosure* roots_from_code_p = (so & SO_AllCodeCache) ? NULL : code_roots;
+  CodeBlobToOopClosure* roots_from_code_p = (so & SO_AllCodeCache) ? NULL : code_roots;
 
   bool is_par = scope->n_threads() > 1;
   Threads::possibly_parallel_oops_do(is_par, strong_roots, roots_from_clds_p, roots_from_code_p);
--- a/hotspot/src/share/vm/gc/shared/genCollectedHeap.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/gc/shared/genCollectedHeap.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -399,7 +399,7 @@
                      OopClosure* weak_roots,
                      CLDClosure* strong_cld_closure,
                      CLDClosure* weak_cld_closure,
-                     CodeBlobClosure* code_roots);
+                     CodeBlobToOopClosure* code_roots);
 
  public:
   static const bool StrongAndWeakRoots = false;
--- a/hotspot/src/share/vm/jvmci/jvmciCompiler.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/jvmciCompiler.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -162,6 +162,9 @@
     CLEAR_PENDING_EXCEPTION;
 
     java_lang_Throwable::java_printStackTrace(exception, THREAD);
+    if (HAS_PENDING_EXCEPTION) {
+      CLEAR_PENDING_EXCEPTION;
+    }
 
     env->set_failure("exception throw", false);
   } else {
--- a/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -51,7 +51,6 @@
 jobject JVMCIRuntime::_HotSpotJVMCIRuntime_instance = NULL;
 bool JVMCIRuntime::_HotSpotJVMCIRuntime_initialized = false;
 bool JVMCIRuntime::_well_known_classes_initialized = false;
-const char* JVMCIRuntime::_compiler = NULL;
 int JVMCIRuntime::_trivial_prefixes_count = 0;
 char** JVMCIRuntime::_trivial_prefixes = NULL;
 bool JVMCIRuntime::_shutdown_called = false;
@@ -104,6 +103,7 @@
 JRT_BLOCK_ENTRY(void, JVMCIRuntime::new_instance(JavaThread* thread, Klass* klass))
   JRT_BLOCK;
   assert(klass->is_klass(), "not a class");
+  Handle holder(THREAD, klass->klass_holder()); // keep the klass alive
   instanceKlassHandle h(thread, klass);
   h->check_valid_for_instantiation(true, CHECK);
   // make sure klass is initialized
@@ -129,6 +129,7 @@
     BasicType elt_type = TypeArrayKlass::cast(array_klass)->element_type();
     obj = oopFactory::new_typeArray(elt_type, length, CHECK);
   } else {
+    Handle holder(THREAD, array_klass->klass_holder()); // keep the klass alive
     Klass* elem_klass = ObjArrayKlass::cast(array_klass)->element_klass();
     obj = oopFactory::new_objArray(elem_klass, length, CHECK);
   }
@@ -172,6 +173,7 @@
 JRT_ENTRY(void, JVMCIRuntime::new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims))
   assert(klass->is_klass(), "not a class");
   assert(rank >= 1, "rank must be nonzero");
+  Handle holder(THREAD, klass->klass_holder()); // keep the klass alive
   oop obj = ArrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK);
   thread->set_vm_result(obj);
 JRT_END
@@ -642,15 +644,6 @@
            "HotSpotJVMCIRuntime initialization should only be triggered through JVMCI initialization");
 #endif
 
-    if (_compiler != NULL) {
-      JavaCallArguments args;
-      oop compiler = java_lang_String::create_oop_from_str(_compiler, CHECK);
-      args.push_oop(compiler);
-      callStatic("jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig",
-                 "selectCompiler",
-                 "(Ljava/lang/String;)Ljava/lang/Boolean;", &args, CHECK);
-    }
-
     Handle result = callStatic("jdk/vm/ci/hotspot/HotSpotJVMCIRuntime",
                                "runtime",
                                "()Ljdk/vm/ci/hotspot/HotSpotJVMCIRuntime;", NULL, CHECK);
@@ -783,66 +776,6 @@
   }
 JVM_END
 
-/**
- * Closure for parsing a line from a *.properties file in jre/lib/jvmci/properties.
- * The line must match the regular expression "[^=]+=.*". That is one or more
- * characters other than '=' followed by '=' followed by zero or more characters.
- * Everything before the '=' is the property name and everything after '=' is the value.
- * Lines that start with '#' are treated as comments and ignored.
- * No special processing of whitespace or any escape characters is performed.
- * The last definition of a property "wins" (i.e., it overrides all earlier
- * definitions of the property).
- */
-class JVMCIPropertiesFileClosure : public ParseClosure {
-  SystemProperty** _plist;
-public:
-  JVMCIPropertiesFileClosure(SystemProperty** plist) : _plist(plist) {}
-  void do_line(char* line) {
-    if (line[0] == '#') {
-      // skip comment
-      return;
-    }
-    size_t len = strlen(line);
-    char* sep = strchr(line, '=');
-    if (sep == NULL) {
-      warn_and_abort("invalid format: could not find '=' character");
-      return;
-    }
-    if (sep == line) {
-      warn_and_abort("invalid format: name cannot be empty");
-      return;
-    }
-    *sep = '\0';
-    const char* name = line;
-    char* value = sep + 1;
-    Arguments::PropertyList_unique_add(_plist, name, value);
-  }
-};
-
-void JVMCIRuntime::init_system_properties(SystemProperty** plist) {
-  char jvmciDir[JVM_MAXPATHLEN];
-  const char* fileSep = os::file_separator();
-  jio_snprintf(jvmciDir, sizeof(jvmciDir), "%s%slib%sjvmci",
-               Arguments::get_java_home(), fileSep, fileSep, fileSep);
-  DIR* dir = os::opendir(jvmciDir);
-  if (dir != NULL) {
-    struct dirent *entry;
-    char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(jvmciDir), mtInternal);
-    JVMCIPropertiesFileClosure closure(plist);
-    const unsigned suffix_len = (unsigned)strlen(".properties");
-    while ((entry = os::readdir(dir, (dirent *) dbuf)) != NULL && !closure.is_aborted()) {
-      const char* name = entry->d_name;
-      if (strlen(name) > suffix_len && strcmp(name + strlen(name) - suffix_len, ".properties") == 0) {
-        char propertiesFilePath[JVM_MAXPATHLEN];
-        jio_snprintf(propertiesFilePath, sizeof(propertiesFilePath), "%s%s%s",jvmciDir, fileSep, name);
-        JVMCIRuntime::parse_lines(propertiesFilePath, &closure, false);
-      }
-    }
-    FREE_C_HEAP_ARRAY(char, dbuf);
-    os::closedir(dir);
-  }
-}
-
 #define CHECK_WARN_ABORT_(message) THREAD); \
   if (HAS_PENDING_EXCEPTION) { \
     warning(message); \
@@ -853,12 +786,6 @@
   } \
   (void)(0
 
-void JVMCIRuntime::save_compiler(const char* compiler) {
-  assert(compiler != NULL, "npe");
-  assert(_compiler == NULL, "cannot reassign JVMCI compiler");
-  _compiler = compiler;
-}
-
 void JVMCIRuntime::shutdown(TRAPS) {
   if (_HotSpotJVMCIRuntime_instance != NULL) {
     _shutdown_called = true;
@@ -884,69 +811,3 @@
   }
   return false;
 }
-
-void JVMCIRuntime::parse_lines(char* path, ParseClosure* closure, bool warnStatFailure) {
-  struct stat st;
-  if (::stat(path, &st) == 0 && (st.st_mode & S_IFREG) == S_IFREG) { // exists & is regular file
-    int file_handle = ::open(path, os::default_file_open_flags(), 0);
-    if (file_handle != -1) {
-      char* buffer = NEW_C_HEAP_ARRAY(char, st.st_size + 1, mtInternal);
-      int num_read;
-      num_read = (int) ::read(file_handle, (char*) buffer, st.st_size);
-      if (num_read == -1) {
-        warning("Error reading file %s due to %s", path, strerror(errno));
-      } else if (num_read != st.st_size) {
-        warning("Only read %d of " SIZE_FORMAT " bytes from %s", num_read, (size_t) st.st_size, path);
-      }
-      ::close(file_handle);
-      closure->set_filename(path);
-      if (num_read == st.st_size) {
-        buffer[num_read] = '\0';
-
-        char* line = buffer;
-        while (line - buffer < num_read && !closure->is_aborted()) {
-          // find line end (\r, \n or \r\n)
-          char* nextline = NULL;
-          char* cr = strchr(line, '\r');
-          char* lf = strchr(line, '\n');
-          if (cr != NULL && lf != NULL) {
-            char* min = MIN2(cr, lf);
-            *min = '\0';
-            if (lf == cr + 1) {
-              nextline = lf + 1;
-            } else {
-              nextline = min + 1;
-            }
-          } else if (cr != NULL) {
-            *cr = '\0';
-            nextline = cr + 1;
-          } else if (lf != NULL) {
-            *lf = '\0';
-            nextline = lf + 1;
-          }
-          // trim left
-          while (*line == ' ' || *line == '\t') line++;
-          char* end = line + strlen(line);
-          // trim right
-          while (end > line && (*(end -1) == ' ' || *(end -1) == '\t')) end--;
-          *end = '\0';
-          // skip comments and empty lines
-          if (*line != '#' && strlen(line) > 0) {
-            closure->parse_line(line);
-          }
-          if (nextline != NULL) {
-            line = nextline;
-          } else {
-            // File without newline at the end
-            break;
-          }
-        }
-      }
-      FREE_C_HEAP_ARRAY(char, buffer);
-    } else {
-      warning("Error opening file %s due to %s", path, strerror(errno));
-    }
-  } else if (warnStatFailure) {
-    warning("Could not stat file %s due to %s", path, strerror(errno));
-  }
-}
--- a/hotspot/src/share/vm/jvmci/jvmciRuntime.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/jvmciRuntime.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -70,7 +70,6 @@
   static jobject _HotSpotJVMCIRuntime_instance;
   static bool _HotSpotJVMCIRuntime_initialized;
   static bool _well_known_classes_initialized;
-  static const char* _compiler;
 
   static int _trivial_prefixes_count;
   static char** _trivial_prefixes;
@@ -85,19 +84,9 @@
   static Handle create_Service(const char* name, TRAPS);
 
  public:
-
-  /**
-   * Parses *.properties files in jre/lib/jvmci/ and adds the properties to plist.
-   */
-  static void init_system_properties(SystemProperty** plist);
-
-  /**
-   * Saves the value of the "jvmci.compiler" system property for processing
-   * when JVMCI is initialized.
-   */
-  static void save_compiler(const char* compiler);
-
-  static bool is_HotSpotJVMCIRuntime_initialized() { return _HotSpotJVMCIRuntime_initialized; }
+  static bool is_HotSpotJVMCIRuntime_initialized() {
+    return _HotSpotJVMCIRuntime_initialized;
+  }
 
   /**
    * Gets the singleton HotSpotJVMCIRuntime instance, initializing it if necessary
@@ -136,7 +125,6 @@
   }
 
   static bool treat_as_trivial(Method* method);
-  static void parse_lines(char* path, ParseClosure* closure, bool warnStatFailure);
 
   static BasicType kindToBasicType(Handle kind, TRAPS);
 
--- a/hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -639,11 +639,12 @@
   declare_constant(VM_Version::CPU_AVX512DQ)                        \
   declare_constant(VM_Version::CPU_AVX512PF)                        \
   declare_constant(VM_Version::CPU_AVX512ER)                        \
-  declare_constant(VM_Version::CPU_AVX512CD)                        \
-  declare_constant(VM_Version::CPU_AVX512BW)
+  declare_constant(VM_Version::CPU_AVX512CD)
 
 #define VM_LONG_CONSTANTS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) \
-  declare_preprocessor_constant("VM_Version::CPU_AVX512VL", CPU_AVX512VL)
+  declare_preprocessor_constant("VM_Version::CPU_AVX512BW", CPU_AVX512BW) \
+  declare_preprocessor_constant("VM_Version::CPU_AVX512VL", CPU_AVX512VL) \
+  declare_preprocessor_constant("VM_Version::CPU_SHA", CPU_SHA)
 
 #endif // TARGET_ARCH_x86
 
--- a/hotspot/src/share/vm/logging/log.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/logging/log.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -107,18 +107,25 @@
     return LogTagSetMapping<T0, T1, T2, T3, T4>::tagset().is_level(level);
   }
 
+  ATTRIBUTE_PRINTF(2, 3)
+  static void write(LogLevelType level, const char* fmt, ...) {
+    va_list args;
+    va_start(args, fmt);
+    vwrite(level, fmt, args);
+    va_end(args);
+  };
+
   template <LogLevelType Level>
   ATTRIBUTE_PRINTF(1, 2)
   static void write(const char* fmt, ...) {
     va_list args;
     va_start(args, fmt);
-    vwrite<Level>(fmt, args);
+    vwrite(Level, fmt, args);
     va_end(args);
   };
 
-  template <LogLevelType Level>
-  ATTRIBUTE_PRINTF(1, 0)
-  static void vwrite(const char* fmt, va_list args) {
+  ATTRIBUTE_PRINTF(2, 0)
+  static void vwrite(LogLevelType level, const char* fmt, va_list args) {
     char buf[LogBufferSize];
     va_list saved_args;         // For re-format on buf overflow.
     va_copy(saved_args, args);
@@ -132,27 +139,26 @@
       prefix_len = LogPrefix<T0, T1, T2, T3, T4>::prefix(newbuf, newbuf_len);
       ret = os::log_vsnprintf(newbuf + prefix_len, newbuf_len - prefix_len, fmt, saved_args);
       assert(ret >= 0, "Log message buffer issue");
-      puts<Level>(newbuf);
+      puts(level, newbuf);
       FREE_C_HEAP_ARRAY(char, newbuf);
     } else {
-      puts<Level>(buf);
+      puts(level, buf);
     }
   }
 
-  template <LogLevelType Level>
-  static void puts(const char* string) {
-    LogTagSetMapping<T0, T1, T2, T3, T4>::tagset().log(Level, string);
+  static void puts(LogLevelType level, const char* string) {
+    LogTagSetMapping<T0, T1, T2, T3, T4>::tagset().log(level, string);
   }
 
 #define LOG_LEVEL(level, name) ATTRIBUTE_PRINTF(2, 0) \
   Log& v##name(const char* fmt, va_list args) { \
-    vwrite<LogLevel::level>(fmt, args); \
+    vwrite(LogLevel::level, fmt, args); \
     return *this; \
   } \
   Log& name(const char* fmt, ...) ATTRIBUTE_PRINTF(2, 3) { \
     va_list args; \
     va_start(args, fmt); \
-    vwrite<LogLevel::level>(fmt, args); \
+    vwrite(LogLevel::level, fmt, args); \
     va_end(args); \
     return *this; \
   } \
--- a/hotspot/src/share/vm/memory/iterator.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/memory/iterator.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -285,9 +285,12 @@
  protected:
   void do_nmethod(nmethod* nm);
  public:
+  // If fix_relocations(), then cl must copy objects to their new location immediately to avoid
+  // patching nmethods with the old locations.
   CodeBlobToOopClosure(OopClosure* cl, bool fix_relocations) : _cl(cl), _fix_relocations(fix_relocations) {}
   virtual void do_code_blob(CodeBlob* cb);
 
+  bool fix_relocations() const { return _fix_relocations; }
   const static bool FixRelocations = true;
 };
 
--- a/hotspot/src/share/vm/oops/method.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/oops/method.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -1338,73 +1338,6 @@
   return vmSymbols::find_sid(klass_name);
 }
 
-static bool is_unsafe_alias(vmSymbols::SID name_id) {
-  // All 70 intrinsic candidate methods from sun.misc.Unsafe in 1.8.
-  // Some have the same method name but different signature, e.g.
-  // getByte(long), getByte(Object,long)
-  switch (name_id) {
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(allocateInstance_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(copyMemory_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(loadFence_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(storeFence_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(fullFence_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(getObject_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(getBoolean_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(getByte_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(getShort_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(getChar_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(getInt_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(getLong_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(getFloat_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(getDouble_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(putObject_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(putBoolean_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(putByte_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(putShort_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(putChar_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(putInt_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(putLong_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(putFloat_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(putDouble_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(getObjectVolatile_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(getBooleanVolatile_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(getByteVolatile_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(getShortVolatile_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(getCharVolatile_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(getIntVolatile_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(getLongVolatile_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(getFloatVolatile_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(getDoubleVolatile_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(putObjectVolatile_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(putBooleanVolatile_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(putByteVolatile_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(putShortVolatile_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(putCharVolatile_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(putIntVolatile_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(putLongVolatile_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(putFloatVolatile_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(putDoubleVolatile_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(getAddress_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(putAddress_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(compareAndSwapObject_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(compareAndSwapLong_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(compareAndSwapInt_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(putOrderedObject_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(putOrderedLong_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(putOrderedInt_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(getAndAddInt_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(getAndAddLong_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(getAndSetInt_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(getAndSetLong_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(getAndSetObject_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(park_name):
-    case vmSymbols::VM_SYMBOL_ENUM_NAME(unpark_name):
-      return true;
-  }
-
-  return false;
-}
-
 void Method::init_intrinsic_id() {
   assert(_intrinsic_id == vmIntrinsics::_none, "do this just once");
   const uintptr_t max_id_uint = right_n_bits((int)(sizeof(_intrinsic_id) * BitsPerByte));
@@ -1457,14 +1390,6 @@
     if (is_static() != MethodHandles::is_signature_polymorphic_static(id))
       id = vmIntrinsics::_none;
     break;
-
-  case vmSymbols::VM_SYMBOL_ENUM_NAME(sun_misc_Unsafe):
-    // Map sun.misc.Unsafe to jdk.internal.misc.Unsafe
-    if (!is_unsafe_alias(name_id))  break;
-    // pretend it is the corresponding method in the internal Unsafe class:
-    klass_id = vmSymbols::VM_SYMBOL_ENUM_NAME(jdk_internal_misc_Unsafe);
-    id = vmIntrinsics::find_id(klass_id, name_id, sig_id, flags);
-    break;
   }
 
   if (id != vmIntrinsics::_none) {
--- a/hotspot/src/share/vm/oops/oop.inline.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/oops/oop.inline.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -295,7 +295,7 @@
 // in inner GC loops so these are separated.
 
 inline bool check_obj_alignment(oop obj) {
-  return cast_from_oop<intptr_t>(obj) % MinObjAlignmentInBytes == 0;
+  return (cast_from_oop<intptr_t>(obj) & MinObjAlignmentInBytesMask) == 0;
 }
 
 oop oopDesc::decode_heap_oop_not_null(narrowOop v) {
--- a/hotspot/src/share/vm/oops/symbol.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/oops/symbol.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -158,9 +158,21 @@
 }
 
 void Symbol::print_symbol_on(outputStream* st) const {
-  ResourceMark rm;
+  char *s;
   st = st ? st : tty;
-  st->print("%s", as_quoted_ascii());
+  {
+    // ResourceMark may not affect st->print(). If st is a string
+    // stream it could resize, using the same resource arena.
+    ResourceMark rm;
+    s = as_quoted_ascii();
+    s = os::strdup(s);
+  }
+  if (s == NULL) {
+    st->print("(null)");
+  } else {
+    st->print("%s", s);
+    os::free(s);
+  }
 }
 
 char* Symbol::as_quoted_ascii() const {
--- a/hotspot/src/share/vm/opto/c2compiler.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/opto/c2compiler.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -498,6 +498,7 @@
   case vmIntrinsics::_currentTimeMillis:
   case vmIntrinsics::_nanoTime:
   case vmIntrinsics::_allocateInstance:
+  case vmIntrinsics::_allocateUninitializedArray:
   case vmIntrinsics::_newArray:
   case vmIntrinsics::_getLength:
   case vmIntrinsics::_copyOf:
--- a/hotspot/src/share/vm/opto/callnode.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/opto/callnode.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -1243,13 +1243,13 @@
 
 Node *SafePointNode::peek_monitor_box() const {
   int mon = jvms()->nof_monitors() - 1;
-  assert(mon >= 0, "most have a monitor");
+  assert(mon >= 0, "must have a monitor");
   return monitor_box(jvms(), mon);
 }
 
 Node *SafePointNode::peek_monitor_obj() const {
   int mon = jvms()->nof_monitors() - 1;
-  assert(mon >= 0, "most have a monitor");
+  assert(mon >= 0, "must have a monitor");
   return monitor_obj(jvms(), mon);
 }
 
--- a/hotspot/src/share/vm/opto/cfgnode.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/opto/cfgnode.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -1665,7 +1665,7 @@
 
   bool uncasted = false;
   Node* uin = unique_input(phase, false);
-  if (uin == NULL) {
+  if (uin == NULL && can_reshape) {
     uncasted = true;
     uin = unique_input(phase, true);
   }
@@ -1702,6 +1702,8 @@
     }
 
     if (uncasted) {
+      // Wait until after parsing for the type information to propagate from the casts
+      assert(can_reshape, "Invalid during parsing");
       const Type* phi_type = bottom_type();
       assert(phi_type->isa_int() || phi_type->isa_ptr(), "bad phi type");
       int opcode;
@@ -1720,8 +1722,9 @@
       Node* cast = ConstraintCastNode::make_cast(opcode, r, uin, phi_type, true);
       cast = phase->transform(cast);
       // set all inputs to the new cast so the Phi is removed by Identity
+      PhaseIterGVN* igvn = phase->is_IterGVN();
       for (uint i = 1; i < req(); i++) {
-        set_req(i, cast);
+        set_req_X(i, cast, igvn);
       }
       uin = cast;
     }
--- a/hotspot/src/share/vm/opto/compile.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/opto/compile.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -1118,7 +1118,11 @@
   bool           in_scratch_emit_size() const   { return _in_scratch_emit_size;     }
 
   enum ScratchBufferBlob {
+#if defined(PPC64)
+    MAX_inst_size       = 2048,
+#else
     MAX_inst_size       = 1024,
+#endif
     MAX_locs_size       = 128, // number of relocInfo elements
     MAX_const_size      = 128,
     MAX_stubs_size      = 128
--- a/hotspot/src/share/vm/opto/library_call.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/opto/library_call.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -48,6 +48,7 @@
 #include "opto/runtime.hpp"
 #include "opto/subnode.hpp"
 #include "prims/nativeLookup.hpp"
+#include "prims/unsafe.hpp"
 #include "runtime/sharedRuntime.hpp"
 #ifdef TRACE_HAVE_INTRINSICS
 #include "trace/traceMacros.hpp"
@@ -248,6 +249,7 @@
   bool inline_unsafe_access(bool is_native_ptr, bool is_store, BasicType type, AccessKind kind, bool is_unaligned);
   static bool klass_needs_init_guard(Node* kls);
   bool inline_unsafe_allocate();
+  bool inline_unsafe_newArray(bool uninitialized);
   bool inline_unsafe_copyMemory();
   bool inline_native_currentThread();
 
@@ -255,8 +257,6 @@
   bool inline_native_isInterrupted();
   bool inline_native_Class_query(vmIntrinsics::ID id);
   bool inline_native_subtype_check();
-
-  bool inline_native_newArray();
   bool inline_native_getLength();
   bool inline_array_copyOf(bool is_copyOfRange);
   bool inline_array_equals(StrIntrinsicNode::ArgEnc ae);
@@ -709,7 +709,6 @@
   case vmIntrinsics::_nanoTime:                 return inline_native_time_funcs(CAST_FROM_FN_PTR(address, os::javaTimeNanos), "nanoTime");
   case vmIntrinsics::_allocateInstance:         return inline_unsafe_allocate();
   case vmIntrinsics::_copyMemory:               return inline_unsafe_copyMemory();
-  case vmIntrinsics::_newArray:                 return inline_native_newArray();
   case vmIntrinsics::_getLength:                return inline_native_getLength();
   case vmIntrinsics::_copyOf:                   return inline_array_copyOf(false);
   case vmIntrinsics::_copyOfRange:              return inline_array_copyOf(true);
@@ -718,6 +717,9 @@
   case vmIntrinsics::_Objects_checkIndex:       return inline_objects_checkIndex();
   case vmIntrinsics::_clone:                    return inline_native_clone(intrinsic()->is_virtual());
 
+  case vmIntrinsics::_allocateUninitializedArray: return inline_unsafe_newArray(true);
+  case vmIntrinsics::_newArray:                   return inline_unsafe_newArray(false);
+
   case vmIntrinsics::_isAssignableFrom:         return inline_native_subtype_check();
 
   case vmIntrinsics::_isInstance:
@@ -2298,9 +2300,6 @@
 }
 
 
-// Interpret Unsafe.fieldOffset cookies correctly:
-extern jlong Unsafe_field_offset_to_byte_offset(jlong field_offset);
-
 const TypeOopPtr* LibraryCallKit::sharpen_unsafe_type(Compile::AliasType* alias_type, const TypePtr *adr_type, bool is_native_ptr) {
   // Attempt to infer a sharper value type from the offset and base type.
   ciKlass* sharpened_klass = NULL;
@@ -3777,9 +3776,17 @@
 
 //-----------------------inline_native_newArray--------------------------
 // private static native Object java.lang.reflect.newArray(Class<?> componentType, int length);
-bool LibraryCallKit::inline_native_newArray() {
-  Node* mirror    = argument(0);
-  Node* count_val = argument(1);
+// private        native Object Unsafe.allocateUninitializedArray0(Class<?> cls, int size);
+bool LibraryCallKit::inline_unsafe_newArray(bool uninitialized) {
+  Node* mirror;
+  Node* count_val;
+  if (uninitialized) {
+    mirror    = argument(1);
+    count_val = argument(2);
+  } else {
+    mirror    = argument(0);
+    count_val = argument(1);
+  }
 
   mirror = null_check(mirror);
   // If mirror or obj is dead, only null-path is taken.
@@ -3824,6 +3831,12 @@
     result_val->init_req(_normal_path, obj);
     result_io ->init_req(_normal_path, i_o());
     result_mem->init_req(_normal_path, reset_memory());
+
+    if (uninitialized) {
+      // Mark the allocation so that zeroing is skipped
+      AllocateArrayNode* alloc = AllocateArrayNode::Ideal_array_allocation(obj, &_gvn);
+      alloc->maybe_set_complete(&_gvn);
+    }
   }
 
   // Return the combined state.
@@ -4412,7 +4425,7 @@
 }
 
 //----------------------inline_unsafe_copyMemory-------------------------
-// public native void Unsafe.copyMemory(Object srcBase, long srcOffset, Object destBase, long destOffset, long bytes);
+// public native void Unsafe.copyMemory0(Object srcBase, long srcOffset, Object destBase, long destOffset, long bytes);
 bool LibraryCallKit::inline_unsafe_copyMemory() {
   if (callee()->is_static())  return false;  // caller must have the capability!
   null_check_receiver();  // null-check receiver
--- a/hotspot/src/share/vm/opto/matcher.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/opto/matcher.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -399,10 +399,6 @@
   // Optional scaling for the parameter to the ClearArray/CopyArray node.
   static const bool init_array_count_is_in_bytes;
 
-  // Threshold small size (in bytes) for a ClearArray/CopyArray node.
-  // Anything this size or smaller may get converted to discrete scalar stores.
-  static const int init_array_short_size;
-
   // Some hardware needs 2 CMOV's for longs.
   static const int long_cmove_cost();
 
--- a/hotspot/src/share/vm/opto/memnode.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/opto/memnode.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -2741,6 +2741,9 @@
 //------------------------------Idealize---------------------------------------
 // Clearing a short array is faster with stores
 Node *ClearArrayNode::Ideal(PhaseGVN *phase, bool can_reshape){
+  // Already know this is a large node, do not try to ideal it
+  if (_is_large) return NULL;
+
   const int unit = BytesPerLong;
   const TypeX* t = phase->type(in(2))->isa_intptr_t();
   if (!t)  return NULL;
@@ -2753,8 +2756,11 @@
   // (see jck test stmt114.stmt11402.val).
   if (size <= 0 || size % unit != 0)  return NULL;
   intptr_t count = size / unit;
-  // Length too long; use fast hardware clear
-  if (size > Matcher::init_array_short_size)  return NULL;
+  // Length too long; communicate this to matchers and assemblers.
+  // Assemblers are responsible to produce fast hardware clears for it.
+  if (size > InitArrayShortSize) {
+    return new ClearArrayNode(in(0), in(1), in(2), in(3), true);
+  }
   Node *mem = in(1);
   if( phase->type(mem)==Type::TOP ) return NULL;
   Node *adr = in(3);
@@ -2852,7 +2858,7 @@
   // Bulk clear double-words
   Node* zsize = phase->transform(new SubXNode(zend, zbase) );
   Node* adr = phase->transform(new AddPNode(dest, dest, start_offset) );
-  mem = new ClearArrayNode(ctl, mem, zsize, adr);
+  mem = new ClearArrayNode(ctl, mem, zsize, adr, false);
   return phase->transform(mem);
 }
 
@@ -3901,7 +3907,7 @@
                                               zeroes_done, zeroes_needed,
                                               phase);
         zeroes_done = zeroes_needed;
-        if (zsize > Matcher::init_array_short_size && ++big_init_gaps > 2)
+        if (zsize > InitArrayShortSize && ++big_init_gaps > 2)
           do_zeroing = false;   // leave the hole, next time
       }
     }
--- a/hotspot/src/share/vm/opto/memnode.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/opto/memnode.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -1013,9 +1013,11 @@
 
 //------------------------------ClearArray-------------------------------------
 class ClearArrayNode: public Node {
+private:
+  bool _is_large;
 public:
-  ClearArrayNode( Node *ctrl, Node *arymem, Node *word_cnt, Node *base )
-    : Node(ctrl,arymem,word_cnt,base) {
+  ClearArrayNode( Node *ctrl, Node *arymem, Node *word_cnt, Node *base, bool is_large)
+    : Node(ctrl,arymem,word_cnt,base), _is_large(is_large) {
     init_class_id(Class_ClearArray);
   }
   virtual int         Opcode() const;
@@ -1026,6 +1028,7 @@
   virtual Node* Identity(PhaseGVN* phase);
   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
   virtual uint match_edge(uint idx) const;
+  bool is_large() const { return _is_large; }
 
   // Clear the given area of an object or array.
   // The start offset must always be aligned mod BytesPerInt.
--- a/hotspot/src/share/vm/opto/runtime.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/opto/runtime.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -220,22 +220,17 @@
 
   // These checks are cheap to make and support reflective allocation.
   int lh = klass->layout_helper();
-  if (Klass::layout_helper_needs_slow_path(lh)
-      || !InstanceKlass::cast(klass)->is_initialized()) {
-    KlassHandle kh(THREAD, klass);
-    kh->check_valid_for_instantiation(false, THREAD);
+  if (Klass::layout_helper_needs_slow_path(lh) || !InstanceKlass::cast(klass)->is_initialized()) {
+    Handle holder(THREAD, klass->klass_holder()); // keep the klass alive
+    klass->check_valid_for_instantiation(false, THREAD);
     if (!HAS_PENDING_EXCEPTION) {
-      InstanceKlass::cast(kh())->initialize(THREAD);
-    }
-    if (!HAS_PENDING_EXCEPTION) {
-      klass = kh();
-    } else {
-      klass = NULL;
+      InstanceKlass::cast(klass)->initialize(THREAD);
     }
   }
 
-  if (klass != NULL) {
+  if (!HAS_PENDING_EXCEPTION) {
     // Scavenge and allocate an instance.
+    Handle holder(THREAD, klass->klass_holder()); // keep the klass alive
     oop result = InstanceKlass::cast(klass)->allocate_instance(THREAD);
     thread->set_vm_result(result);
 
@@ -275,6 +270,7 @@
     // Although the oopFactory likes to work with the elem_type,
     // the compiler prefers the array_type, since it must already have
     // that latter value in hand for the fast path.
+    Handle holder(THREAD, array_type->klass_holder()); // keep the array klass alive
     Klass* elem_type = ObjArrayKlass::cast(array_type)->element_klass();
     result = oopFactory::new_objArray(elem_type, len, THREAD);
   }
@@ -353,6 +349,7 @@
   jint dims[2];
   dims[0] = len1;
   dims[1] = len2;
+  Handle holder(THREAD, elem_type->klass_holder()); // keep the klass alive
   oop obj = ArrayKlass::cast(elem_type)->multi_allocate(2, dims, THREAD);
   deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
   thread->set_vm_result(obj);
@@ -369,6 +366,7 @@
   dims[0] = len1;
   dims[1] = len2;
   dims[2] = len3;
+  Handle holder(THREAD, elem_type->klass_holder()); // keep the klass alive
   oop obj = ArrayKlass::cast(elem_type)->multi_allocate(3, dims, THREAD);
   deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
   thread->set_vm_result(obj);
@@ -386,6 +384,7 @@
   dims[1] = len2;
   dims[2] = len3;
   dims[3] = len4;
+  Handle holder(THREAD, elem_type->klass_holder()); // keep the klass alive
   oop obj = ArrayKlass::cast(elem_type)->multi_allocate(4, dims, THREAD);
   deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
   thread->set_vm_result(obj);
@@ -404,6 +403,7 @@
   dims[2] = len3;
   dims[3] = len4;
   dims[4] = len5;
+  Handle holder(THREAD, elem_type->klass_holder()); // keep the klass alive
   oop obj = ArrayKlass::cast(elem_type)->multi_allocate(5, dims, THREAD);
   deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
   thread->set_vm_result(obj);
@@ -421,6 +421,7 @@
   jint *c_dims = NEW_RESOURCE_ARRAY(jint, len);
   Copy::conjoint_jints_atomic(j_dims, c_dims, len);
 
+  Handle holder(THREAD, elem_type->klass_holder()); // keep the klass alive
   oop obj = ArrayKlass::cast(elem_type)->multi_allocate(len, c_dims, THREAD);
   deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
   thread->set_vm_result(obj);
--- a/hotspot/src/share/vm/prims/nativeLookup.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/prims/nativeLookup.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -35,6 +35,7 @@
 #include "oops/symbol.hpp"
 #include "prims/jvm_misc.hpp"
 #include "prims/nativeLookup.hpp"
+#include "prims/unsafe.hpp"
 #include "runtime/arguments.hpp"
 #include "runtime/handles.inline.hpp"
 #include "runtime/javaCalls.hpp"
@@ -109,8 +110,6 @@
 }
 
 extern "C" {
-  void JNICALL JVM_RegisterJDKInternalMiscUnsafeMethods(JNIEnv *env, jclass unsafecls);
-  void JNICALL JVM_RegisterSunMiscUnsafeMethods(JNIEnv *env, jclass unsafecls);
   void JNICALL JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass unsafecls);
   void JNICALL JVM_RegisterPerfMethods(JNIEnv *env, jclass perfclass);
   void JNICALL JVM_RegisterWhiteBoxMethods(JNIEnv *env, jclass wbclass);
@@ -125,7 +124,6 @@
 
 static JNINativeMethod lookup_special_native_methods[] = {
   { CC"Java_jdk_internal_misc_Unsafe_registerNatives",             NULL, FN_PTR(JVM_RegisterJDKInternalMiscUnsafeMethods) },
-  { CC"Java_sun_misc_Unsafe_registerNatives",                      NULL, FN_PTR(JVM_RegisterSunMiscUnsafeMethods)         },
   { CC"Java_java_lang_invoke_MethodHandleNatives_registerNatives", NULL, FN_PTR(JVM_RegisterMethodHandleMethods) },
   { CC"Java_jdk_internal_perf_Perf_registerNatives",               NULL, FN_PTR(JVM_RegisterPerfMethods)         },
   { CC"Java_sun_hotspot_WhiteBox_registerNatives",                 NULL, FN_PTR(JVM_RegisterWhiteBoxMethods)     },
--- a/hotspot/src/share/vm/prims/unsafe.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/prims/unsafe.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -30,6 +30,7 @@
 #include "oops/oop.inline.hpp"
 #include "prims/jni.h"
 #include "prims/jvm.h"
+#include "prims/unsafe.hpp"
 #include "runtime/atomic.inline.hpp"
 #include "runtime/globals.hpp"
 #include "runtime/interfaceSupport.hpp"
@@ -45,8 +46,8 @@
 #include "gc/g1/g1SATBCardTableModRefBS.hpp"
 #endif // INCLUDE_ALL_GCS
 
-/*
- *      Implementation of class Unsafe
+/**
+ * Implementation of the jdk.internal.misc.Unsafe class
  */
 
 
@@ -56,25 +57,15 @@
 
 
 #define UNSAFE_ENTRY(result_type, header) \
-  JVM_ENTRY(result_type, header)
+  JVM_ENTRY(static result_type, header)
 
-// Can't use UNSAFE_LEAF because it has the signature of a straight
-// call into the runtime (just like JVM_LEAF, funny that) but it's
-// called like a Java Native and thus the wrapper built for it passes
-// arguments like a JNI call.  It expects those arguments to be popped
-// from the stack on Intel like all good JNI args are, and adjusts the
-// stack according.  Since the JVM_LEAF call expects no extra
-// arguments the stack isn't popped in the C code, is pushed by the
-// wrapper and we get sick.
-//#define UNSAFE_LEAF(result_type, header) \
-//  JVM_LEAF(result_type, header)
+#define UNSAFE_LEAF(result_type, header) \
+  JVM_LEAF(static result_type, header)
 
 #define UNSAFE_END JVM_END
 
-#define UnsafeWrapper(arg) /*nothing, for the present*/
 
-
-inline void* addr_from_java(jlong addr) {
+static inline void* addr_from_java(jlong addr) {
   // This assert fails in a variety of ways on 32-bit systems.
   // It is impossible to predict whether native code that converts
   // pointers to longs will sign-extend or zero-extend the addresses.
@@ -82,7 +73,7 @@
   return (void*)(uintptr_t)addr;
 }
 
-inline jlong addr_to_java(void* p) {
+static inline jlong addr_to_java(void* p) {
   assert(p == (void*)(uintptr_t)p, "must not be odd high bits");
   return (uintptr_t)p;
 }
@@ -98,24 +89,17 @@
 // through conversion functions when going between the VM and the Unsafe API.
 // The conversion functions just happen to be no-ops at present.
 
-inline jlong field_offset_to_byte_offset(jlong field_offset) {
+static inline jlong field_offset_to_byte_offset(jlong field_offset) {
   return field_offset;
 }
 
-inline jlong field_offset_from_byte_offset(jlong byte_offset) {
+static inline jlong field_offset_from_byte_offset(jlong byte_offset) {
   return byte_offset;
 }
 
-inline jint invocation_key_from_method_slot(jint slot) {
-  return slot;
-}
+static inline void* index_oop_from_field_offset_long(oop p, jlong field_offset) {
+  jlong byte_offset = field_offset_to_byte_offset(field_offset);
 
-inline jint invocation_key_to_method_slot(jint key) {
-  return key;
-}
-
-inline void* index_oop_from_field_offset_long(oop p, jlong field_offset) {
-  jlong byte_offset = field_offset_to_byte_offset(field_offset);
 #ifdef ASSERT
   if (p != NULL) {
     assert(byte_offset >= 0 && byte_offset <= (jlong)MAX_OBJECT_SIZE, "sane offset");
@@ -128,10 +112,12 @@
     assert(byte_offset < p_size, "Unsafe access: offset " INT64_FORMAT " > object's size " INT64_FORMAT, byte_offset, p_size);
   }
 #endif
-  if (sizeof(char*) == sizeof(jint))    // (this constant folds!)
+
+  if (sizeof(char*) == sizeof(jint)) {   // (this constant folds!)
     return (address)p + (jint) byte_offset;
-  else
+  } else {
     return (address)p +        byte_offset;
+  }
 }
 
 // Externally callable versions:
@@ -142,12 +128,6 @@
 jlong Unsafe_field_offset_from_byte_offset(jlong byte_offset) {
   return byte_offset;
 }
-jint Unsafe_invocation_key_from_method_slot(jint slot) {
-  return invocation_key_from_method_slot(slot);
-}
-jint Unsafe_invocation_key_to_method_slot(jint key) {
-  return invocation_key_to_method_slot(key);
-}
 
 
 ///// Data in the Java heap.
@@ -177,17 +157,19 @@
 // These functions allow a null base pointer with an arbitrary address.
 // But if the base pointer is non-null, the offset should make some sense.
 // That is, it should be in the range [0, MAX_OBJECT_SIZE].
-UNSAFE_ENTRY(jobject, Unsafe_GetObject(JNIEnv *env, jobject unsafe, jobject obj, jlong offset))
-  UnsafeWrapper("Unsafe_GetObject");
+UNSAFE_ENTRY(jobject, Unsafe_GetObject(JNIEnv *env, jobject unsafe, jobject obj, jlong offset)) {
   oop p = JNIHandles::resolve(obj);
   oop v;
+
   if (UseCompressedOops) {
     narrowOop n = *(narrowOop*)index_oop_from_field_offset_long(p, offset);
     v = oopDesc::decode_heap_oop(n);
   } else {
     v = *(oop*)index_oop_from_field_offset_long(p, offset);
   }
+
   jobject ret = JNIHandles::make_local(env, v);
+
 #if INCLUDE_ALL_GCS
   // We could be accessing the referent field in a reference
   // object. If G1 is enabled then we need to register non-null
@@ -212,67 +194,71 @@
     }
   }
 #endif // INCLUDE_ALL_GCS
-  return ret;
-UNSAFE_END
 
-UNSAFE_ENTRY(void, Unsafe_SetObject(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject x_h))
-  UnsafeWrapper("Unsafe_SetObject");
+  return ret;
+} UNSAFE_END
+
+UNSAFE_ENTRY(void, Unsafe_SetObject(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject x_h)) {
   oop x = JNIHandles::resolve(x_h);
   oop p = JNIHandles::resolve(obj);
+
   if (UseCompressedOops) {
     oop_store((narrowOop*)index_oop_from_field_offset_long(p, offset), x);
   } else {
     oop_store((oop*)index_oop_from_field_offset_long(p, offset), x);
   }
-UNSAFE_END
+} UNSAFE_END
 
-UNSAFE_ENTRY(jobject, Unsafe_GetObjectVolatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset))
-  UnsafeWrapper("Unsafe_GetObjectVolatile");
+UNSAFE_ENTRY(jobject, Unsafe_GetObjectVolatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset)) {
   oop p = JNIHandles::resolve(obj);
   void* addr = index_oop_from_field_offset_long(p, offset);
+
   volatile oop v;
+
   if (UseCompressedOops) {
     volatile narrowOop n = *(volatile narrowOop*) addr;
     (void)const_cast<oop&>(v = oopDesc::decode_heap_oop(n));
   } else {
     (void)const_cast<oop&>(v = *(volatile oop*) addr);
   }
+
   OrderAccess::acquire();
   return JNIHandles::make_local(env, v);
-UNSAFE_END
+} UNSAFE_END
 
-UNSAFE_ENTRY(void, Unsafe_SetObjectVolatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject x_h))
-  UnsafeWrapper("Unsafe_SetObjectVolatile");
+UNSAFE_ENTRY(void, Unsafe_SetObjectVolatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject x_h)) {
   oop x = JNIHandles::resolve(x_h);
   oop p = JNIHandles::resolve(obj);
   void* addr = index_oop_from_field_offset_long(p, offset);
   OrderAccess::release();
+
   if (UseCompressedOops) {
     oop_store((narrowOop*)addr, x);
   } else {
     oop_store((oop*)addr, x);
   }
-  OrderAccess::fence();
-UNSAFE_END
 
-UNSAFE_ENTRY(jobject, Unsafe_GetUncompressedObject(JNIEnv *env, jobject unsafe, jlong addr))
-  UnsafeWrapper("Unsafe_GetUncompressedObject");
+  OrderAccess::fence();
+} UNSAFE_END
+
+UNSAFE_ENTRY(jobject, Unsafe_GetUncompressedObject(JNIEnv *env, jobject unsafe, jlong addr)) {
   oop v = *(oop*) (address) addr;
-  return JNIHandles::make_local(env, v);
-UNSAFE_END
 
-UNSAFE_ENTRY(jclass, Unsafe_GetJavaMirror(JNIEnv *env, jobject unsafe, jlong metaspace_klass))
-  UnsafeWrapper("Unsafe_GetJavaMirror");
+  return JNIHandles::make_local(env, v);
+} UNSAFE_END
+
+UNSAFE_ENTRY(jclass, Unsafe_GetJavaMirror(JNIEnv *env, jobject unsafe, jlong metaspace_klass)) {
   Klass* klass = (Klass*) (address) metaspace_klass;
+
   return (jclass) JNIHandles::make_local(klass->java_mirror());
-UNSAFE_END
+} UNSAFE_END
 
-UNSAFE_ENTRY(jlong, Unsafe_GetKlassPointer(JNIEnv *env, jobject unsafe, jobject obj))
-  UnsafeWrapper("Unsafe_GetKlassPointer");
+UNSAFE_ENTRY(jlong, Unsafe_GetKlassPointer(JNIEnv *env, jobject unsafe, jobject obj)) {
   oop o = JNIHandles::resolve(obj);
   jlong klass = (jlong) (address) o->klass();
+
   return klass;
-UNSAFE_END
+} UNSAFE_END
 
 #ifndef SUPPORTS_NATIVE_CX8
 
@@ -303,83 +289,54 @@
 // the address of the field _after_ we have acquired the lock, else the object may have
 // been moved by the GC
 
-UNSAFE_ENTRY(jlong, Unsafe_GetLongVolatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset))
-  UnsafeWrapper("Unsafe_GetLongVolatile");
-  {
-    if (VM_Version::supports_cx8()) {
-      GET_FIELD_VOLATILE(obj, offset, jlong, v);
-      return v;
-    }
-    else {
-      Handle p (THREAD, JNIHandles::resolve(obj));
-      jlong* addr = (jlong*)(index_oop_from_field_offset_long(p(), offset));
-      MutexLockerEx mu(UnsafeJlong_lock, Mutex::_no_safepoint_check_flag);
-      jlong value = Atomic::load(addr);
-      return value;
-    }
+UNSAFE_ENTRY(jlong, Unsafe_GetLongVolatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset)) {
+  if (VM_Version::supports_cx8()) {
+    GET_FIELD_VOLATILE(obj, offset, jlong, v);
+    return v;
+  } else {
+    Handle p (THREAD, JNIHandles::resolve(obj));
+    jlong* addr = (jlong*)(index_oop_from_field_offset_long(p(), offset));
+    MutexLockerEx mu(UnsafeJlong_lock, Mutex::_no_safepoint_check_flag);
+    jlong value = Atomic::load(addr);
+    return value;
   }
-UNSAFE_END
+} UNSAFE_END
 
-UNSAFE_ENTRY(void, Unsafe_SetLongVolatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jlong x))
-  UnsafeWrapper("Unsafe_SetLongVolatile");
-  {
-    if (VM_Version::supports_cx8()) {
-      SET_FIELD_VOLATILE(obj, offset, jlong, x);
-    }
-    else {
-      Handle p (THREAD, JNIHandles::resolve(obj));
-      jlong* addr = (jlong*)(index_oop_from_field_offset_long(p(), offset));
-      MutexLockerEx mu(UnsafeJlong_lock, Mutex::_no_safepoint_check_flag);
-      Atomic::store(x, addr);
-    }
+UNSAFE_ENTRY(void, Unsafe_SetLongVolatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jlong x)) {
+  if (VM_Version::supports_cx8()) {
+    SET_FIELD_VOLATILE(obj, offset, jlong, x);
+  } else {
+    Handle p (THREAD, JNIHandles::resolve(obj));
+    jlong* addr = (jlong*)(index_oop_from_field_offset_long(p(), offset));
+    MutexLockerEx mu(UnsafeJlong_lock, Mutex::_no_safepoint_check_flag);
+    Atomic::store(x, addr);
   }
-UNSAFE_END
+} UNSAFE_END
 
 #endif // not SUPPORTS_NATIVE_CX8
 
-UNSAFE_ENTRY(jboolean, Unsafe_isBigEndian0(JNIEnv *env, jobject unsafe))
-  UnsafeWrapper("Unsafe_IsBigEndian0");
-  {
+UNSAFE_LEAF(jboolean, Unsafe_isBigEndian0(JNIEnv *env, jobject unsafe)) {
 #ifdef VM_LITTLE_ENDIAN
-    return false;
+  return false;
 #else
-    return true;
+  return true;
 #endif
-  }
-UNSAFE_END
+} UNSAFE_END
 
-UNSAFE_ENTRY(jint, Unsafe_unalignedAccess0(JNIEnv *env, jobject unsafe))
-  UnsafeWrapper("Unsafe_UnalignedAccess0");
-  {
-    return UseUnalignedAccesses;
-  }
-UNSAFE_END
+UNSAFE_LEAF(jint, Unsafe_unalignedAccess0(JNIEnv *env, jobject unsafe)) {
+  return UseUnalignedAccesses;
+} UNSAFE_END
 
-#define DEFINE_GETSETOOP(jboolean, Boolean) \
+#define DEFINE_GETSETOOP(java_type, Type)        \
  \
-UNSAFE_ENTRY(jboolean, Unsafe_Get##Boolean##140(JNIEnv *env, jobject unsafe, jobject obj, jint offset)) \
-  UnsafeWrapper("Unsafe_Get"#Boolean); \
-  if (obj == NULL)  THROW_0(vmSymbols::java_lang_NullPointerException()); \
-  GET_FIELD(obj, offset, jboolean, v); \
+UNSAFE_ENTRY(java_type, Unsafe_Get##Type(JNIEnv *env, jobject unsafe, jobject obj, jlong offset)) { \
+  GET_FIELD(obj, offset, java_type, v); \
   return v; \
-UNSAFE_END \
+} UNSAFE_END \
  \
-UNSAFE_ENTRY(void, Unsafe_Set##Boolean##140(JNIEnv *env, jobject unsafe, jobject obj, jint offset, jboolean x)) \
-  UnsafeWrapper("Unsafe_Set"#Boolean); \
-  if (obj == NULL)  THROW(vmSymbols::java_lang_NullPointerException()); \
-  SET_FIELD(obj, offset, jboolean, x); \
-UNSAFE_END \
- \
-UNSAFE_ENTRY(jboolean, Unsafe_Get##Boolean(JNIEnv *env, jobject unsafe, jobject obj, jlong offset)) \
-  UnsafeWrapper("Unsafe_Get"#Boolean); \
-  GET_FIELD(obj, offset, jboolean, v); \
-  return v; \
-UNSAFE_END \
- \
-UNSAFE_ENTRY(void, Unsafe_Set##Boolean(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jboolean x)) \
-  UnsafeWrapper("Unsafe_Set"#Boolean); \
-  SET_FIELD(obj, offset, jboolean, x); \
-UNSAFE_END \
+UNSAFE_ENTRY(void, Unsafe_Set##Type(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, java_type x)) { \
+  SET_FIELD(obj, offset, java_type, x); \
+} UNSAFE_END \
  \
 // END DEFINE_GETSETOOP.
 
@@ -394,18 +351,16 @@
 
 #undef DEFINE_GETSETOOP
 
-#define DEFINE_GETSETOOP_VOLATILE(jboolean, Boolean) \
+#define DEFINE_GETSETOOP_VOLATILE(java_type, Type) \
  \
-UNSAFE_ENTRY(jboolean, Unsafe_Get##Boolean##Volatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset)) \
-  UnsafeWrapper("Unsafe_Get"#Boolean); \
-  GET_FIELD_VOLATILE(obj, offset, jboolean, v); \
+UNSAFE_ENTRY(java_type, Unsafe_Get##Type##Volatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset)) { \
+  GET_FIELD_VOLATILE(obj, offset, java_type, v); \
   return v; \
-UNSAFE_END \
+} UNSAFE_END \
  \
-UNSAFE_ENTRY(void, Unsafe_Set##Boolean##Volatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jboolean x)) \
-  UnsafeWrapper("Unsafe_Set"#Boolean); \
-  SET_FIELD_VOLATILE(obj, offset, jboolean, x); \
-UNSAFE_END \
+UNSAFE_ENTRY(void, Unsafe_Set##Type##Volatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, java_type x)) { \
+  SET_FIELD_VOLATILE(obj, offset, java_type, x); \
+} UNSAFE_END \
  \
 // END DEFINE_GETSETOOP_VOLATILE.
 
@@ -425,59 +380,53 @@
 
 // The non-intrinsified versions of setOrdered just use setVolatile
 
-UNSAFE_ENTRY(void, Unsafe_SetOrderedInt(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jint x))
-  UnsafeWrapper("Unsafe_SetOrderedInt");
+UNSAFE_ENTRY(void, Unsafe_SetOrderedInt(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jint x)) {
   SET_FIELD_VOLATILE(obj, offset, jint, x);
-UNSAFE_END
+} UNSAFE_END
 
-UNSAFE_ENTRY(void, Unsafe_SetOrderedObject(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject x_h))
-  UnsafeWrapper("Unsafe_SetOrderedObject");
+UNSAFE_ENTRY(void, Unsafe_SetOrderedObject(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject x_h)) {
   oop x = JNIHandles::resolve(x_h);
   oop p = JNIHandles::resolve(obj);
   void* addr = index_oop_from_field_offset_long(p, offset);
   OrderAccess::release();
+
   if (UseCompressedOops) {
     oop_store((narrowOop*)addr, x);
   } else {
     oop_store((oop*)addr, x);
   }
-  OrderAccess::fence();
-UNSAFE_END
 
-UNSAFE_ENTRY(void, Unsafe_SetOrderedLong(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jlong x))
-  UnsafeWrapper("Unsafe_SetOrderedLong");
+  OrderAccess::fence();
+} UNSAFE_END
+
+UNSAFE_ENTRY(void, Unsafe_SetOrderedLong(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jlong x)) {
 #ifdef SUPPORTS_NATIVE_CX8
   SET_FIELD_VOLATILE(obj, offset, jlong, x);
 #else
+
   // Keep old code for platforms which may not have atomic long (8 bytes) instructions
-  {
-    if (VM_Version::supports_cx8()) {
-      SET_FIELD_VOLATILE(obj, offset, jlong, x);
-    }
-    else {
-      Handle p (THREAD, JNIHandles::resolve(obj));
-      jlong* addr = (jlong*)(index_oop_from_field_offset_long(p(), offset));
-      MutexLockerEx mu(UnsafeJlong_lock, Mutex::_no_safepoint_check_flag);
-      Atomic::store(x, addr);
-    }
+  if (VM_Version::supports_cx8()) {
+    SET_FIELD_VOLATILE(obj, offset, jlong, x);
+  } else {
+    Handle p(THREAD, JNIHandles::resolve(obj));
+    jlong* addr = (jlong*)(index_oop_from_field_offset_long(p(), offset));
+    MutexLockerEx mu(UnsafeJlong_lock, Mutex::_no_safepoint_check_flag);
+    Atomic::store(x, addr);
   }
 #endif
-UNSAFE_END
+} UNSAFE_END
 
-UNSAFE_ENTRY(void, Unsafe_LoadFence(JNIEnv *env, jobject unsafe))
-  UnsafeWrapper("Unsafe_LoadFence");
+UNSAFE_LEAF(void, Unsafe_LoadFence(JNIEnv *env, jobject unsafe)) {
   OrderAccess::acquire();
-UNSAFE_END
+} UNSAFE_END
 
-UNSAFE_ENTRY(void, Unsafe_StoreFence(JNIEnv *env, jobject unsafe))
-  UnsafeWrapper("Unsafe_StoreFence");
+UNSAFE_LEAF(void, Unsafe_StoreFence(JNIEnv *env, jobject unsafe)) {
   OrderAccess::release();
-UNSAFE_END
+} UNSAFE_END
 
-UNSAFE_ENTRY(void, Unsafe_FullFence(JNIEnv *env, jobject unsafe))
-  UnsafeWrapper("Unsafe_FullFence");
+UNSAFE_LEAF(void, Unsafe_FullFence(JNIEnv *env, jobject unsafe)) {
   OrderAccess::fence();
-UNSAFE_END
+} UNSAFE_END
 
 ////// Data in the C heap.
 
@@ -486,24 +435,22 @@
 //
 #define DEFINE_GETSETNATIVE(java_type, Type, native_type) \
  \
-UNSAFE_ENTRY(java_type, Unsafe_GetNative##Type(JNIEnv *env, jobject unsafe, jlong addr)) \
-  UnsafeWrapper("Unsafe_GetNative"#Type); \
+UNSAFE_ENTRY(java_type, Unsafe_GetNative##Type(JNIEnv *env, jobject unsafe, jlong addr)) { \
   void* p = addr_from_java(addr); \
   JavaThread* t = JavaThread::current(); \
   t->set_doing_unsafe_access(true); \
   java_type x = *(volatile native_type*)p; \
   t->set_doing_unsafe_access(false); \
   return x; \
-UNSAFE_END \
+} UNSAFE_END \
  \
-UNSAFE_ENTRY(void, Unsafe_SetNative##Type(JNIEnv *env, jobject unsafe, jlong addr, java_type x)) \
-  UnsafeWrapper("Unsafe_SetNative"#Type); \
+UNSAFE_ENTRY(void, Unsafe_SetNative##Type(JNIEnv *env, jobject unsafe, jlong addr, java_type x)) { \
   JavaThread* t = JavaThread::current(); \
   t->set_doing_unsafe_access(true); \
   void* p = addr_from_java(addr); \
   *(volatile native_type*)p = x; \
   t->set_doing_unsafe_access(false); \
-UNSAFE_END \
+} UNSAFE_END \
  \
 // END DEFINE_GETSETNATIVE.
 
@@ -517,8 +464,7 @@
 
 #undef DEFINE_GETSETNATIVE
 
-UNSAFE_ENTRY(jlong, Unsafe_GetNativeLong(JNIEnv *env, jobject unsafe, jlong addr))
-  UnsafeWrapper("Unsafe_GetNativeLong");
+UNSAFE_ENTRY(jlong, Unsafe_GetNativeLong(JNIEnv *env, jobject unsafe, jlong addr)) {
   JavaThread* t = JavaThread::current();
   // We do it this way to avoid problems with access to heap using 64
   // bit loads, as jlong in heap could be not 64-bit aligned, and on
@@ -526,7 +472,8 @@
   t->set_doing_unsafe_access(true);
   void* p = addr_from_java(addr);
   jlong x;
-  if (((intptr_t)p & 7) == 0) {
+
+  if (is_ptr_aligned(p, sizeof(jlong)) == 0) {
     // jlong is aligned, do a volatile access
     x = *(volatile jlong*)p;
   } else {
@@ -535,17 +482,19 @@
     acc.words[1] = ((volatile jint*)p)[1];
     x = acc.long_value;
   }
+
   t->set_doing_unsafe_access(false);
+
   return x;
-UNSAFE_END
+} UNSAFE_END
 
-UNSAFE_ENTRY(void, Unsafe_SetNativeLong(JNIEnv *env, jobject unsafe, jlong addr, jlong x))
-  UnsafeWrapper("Unsafe_SetNativeLong");
+UNSAFE_ENTRY(void, Unsafe_SetNativeLong(JNIEnv *env, jobject unsafe, jlong addr, jlong x)) {
   JavaThread* t = JavaThread::current();
   // see comment for Unsafe_GetNativeLong
   t->set_doing_unsafe_access(true);
   void* p = addr_from_java(addr);
-  if (((intptr_t)p & 7) == 0) {
+
+  if (is_ptr_aligned(p, sizeof(jlong))) {
     // jlong is aligned, do a volatile access
     *(volatile jlong*)p = x;
   } else {
@@ -554,119 +503,81 @@
     ((volatile jint*)p)[0] = acc.words[0];
     ((volatile jint*)p)[1] = acc.words[1];
   }
+
   t->set_doing_unsafe_access(false);
-UNSAFE_END
+} UNSAFE_END
 
 
-UNSAFE_ENTRY(jlong, Unsafe_GetNativeAddress(JNIEnv *env, jobject unsafe, jlong addr))
-  UnsafeWrapper("Unsafe_GetNativeAddress");
+UNSAFE_LEAF(jlong, Unsafe_GetNativeAddress(JNIEnv *env, jobject unsafe, jlong addr)) {
   void* p = addr_from_java(addr);
+
   return addr_to_java(*(void**)p);
-UNSAFE_END
+} UNSAFE_END
 
-UNSAFE_ENTRY(void, Unsafe_SetNativeAddress(JNIEnv *env, jobject unsafe, jlong addr, jlong x))
-  UnsafeWrapper("Unsafe_SetNativeAddress");
+UNSAFE_LEAF(void, Unsafe_SetNativeAddress(JNIEnv *env, jobject unsafe, jlong addr, jlong x)) {
   void* p = addr_from_java(addr);
   *(void**)p = addr_from_java(x);
-UNSAFE_END
+} UNSAFE_END
 
 
 ////// Allocation requests
 
-UNSAFE_ENTRY(jobject, Unsafe_AllocateInstance(JNIEnv *env, jobject unsafe, jclass cls))
-  UnsafeWrapper("Unsafe_AllocateInstance");
-  {
-    ThreadToNativeFromVM ttnfv(thread);
-    return env->AllocObject(cls);
-  }
-UNSAFE_END
+UNSAFE_ENTRY(jobject, Unsafe_AllocateInstance(JNIEnv *env, jobject unsafe, jclass cls)) {
+  ThreadToNativeFromVM ttnfv(thread);
+  return env->AllocObject(cls);
+} UNSAFE_END
 
-UNSAFE_ENTRY(jlong, Unsafe_AllocateMemory(JNIEnv *env, jobject unsafe, jlong size))
-  UnsafeWrapper("Unsafe_AllocateMemory");
+UNSAFE_ENTRY(jlong, Unsafe_AllocateMemory0(JNIEnv *env, jobject unsafe, jlong size)) {
   size_t sz = (size_t)size;
-  if (sz != (julong)size || size < 0) {
-    THROW_0(vmSymbols::java_lang_IllegalArgumentException());
-  }
-  if (sz == 0) {
-    return 0;
-  }
+
   sz = round_to(sz, HeapWordSize);
   void* x = os::malloc(sz, mtInternal);
-  if (x == NULL) {
-    THROW_0(vmSymbols::java_lang_OutOfMemoryError());
-  }
-  //Copy::fill_to_words((HeapWord*)x, sz / HeapWordSize);
+
   return addr_to_java(x);
-UNSAFE_END
+} UNSAFE_END
 
-UNSAFE_ENTRY(jlong, Unsafe_ReallocateMemory(JNIEnv *env, jobject unsafe, jlong addr, jlong size))
-  UnsafeWrapper("Unsafe_ReallocateMemory");
+UNSAFE_ENTRY(jlong, Unsafe_ReallocateMemory0(JNIEnv *env, jobject unsafe, jlong addr, jlong size)) {
   void* p = addr_from_java(addr);
   size_t sz = (size_t)size;
-  if (sz != (julong)size || size < 0) {
-    THROW_0(vmSymbols::java_lang_IllegalArgumentException());
-  }
-  if (sz == 0) {
-    os::free(p);
-    return 0;
-  }
   sz = round_to(sz, HeapWordSize);
-  void* x = (p == NULL) ? os::malloc(sz, mtInternal) : os::realloc(p, sz, mtInternal);
-  if (x == NULL) {
-    THROW_0(vmSymbols::java_lang_OutOfMemoryError());
-  }
+
+  void* x = os::realloc(p, sz, mtInternal);
+
   return addr_to_java(x);
-UNSAFE_END
+} UNSAFE_END
 
-UNSAFE_ENTRY(void, Unsafe_FreeMemory(JNIEnv *env, jobject unsafe, jlong addr))
-  UnsafeWrapper("Unsafe_FreeMemory");
+UNSAFE_ENTRY(void, Unsafe_FreeMemory0(JNIEnv *env, jobject unsafe, jlong addr)) {
   void* p = addr_from_java(addr);
-  if (p == NULL) {
-    return;
-  }
+
   os::free(p);
-UNSAFE_END
+} UNSAFE_END
 
-UNSAFE_ENTRY(void, Unsafe_SetMemory(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jlong size, jbyte value))
-  UnsafeWrapper("Unsafe_SetMemory");
+UNSAFE_ENTRY(void, Unsafe_SetMemory0(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jlong size, jbyte value)) {
   size_t sz = (size_t)size;
-  if (sz != (julong)size || size < 0) {
-    THROW(vmSymbols::java_lang_IllegalArgumentException());
-  }
+
   oop base = JNIHandles::resolve(obj);
   void* p = index_oop_from_field_offset_long(base, offset);
+
   Copy::fill_to_memory_atomic(p, sz, value);
-UNSAFE_END
+} UNSAFE_END
 
-UNSAFE_ENTRY(void, Unsafe_CopyMemory(JNIEnv *env, jobject unsafe, jobject srcObj, jlong srcOffset, jobject dstObj, jlong dstOffset, jlong size))
-  UnsafeWrapper("Unsafe_CopyMemory");
-  if (size == 0) {
-    return;
-  }
+UNSAFE_ENTRY(void, Unsafe_CopyMemory0(JNIEnv *env, jobject unsafe, jobject srcObj, jlong srcOffset, jobject dstObj, jlong dstOffset, jlong size)) {
   size_t sz = (size_t)size;
-  if (sz != (julong)size || size < 0) {
-    THROW(vmSymbols::java_lang_IllegalArgumentException());
-  }
+
   oop srcp = JNIHandles::resolve(srcObj);
   oop dstp = JNIHandles::resolve(dstObj);
-  if (dstp != NULL && !dstp->is_typeArray()) {
-    // NYI:  This works only for non-oop arrays at present.
-    // Generalizing it would be reasonable, but requires card marking.
-    // Also, autoboxing a Long from 0L in copyMemory(x,y, 0L,z, n) would be bad.
-    THROW(vmSymbols::java_lang_IllegalArgumentException());
-  }
+
   void* src = index_oop_from_field_offset_long(srcp, srcOffset);
   void* dst = index_oop_from_field_offset_long(dstp, dstOffset);
+
   Copy::conjoint_memory_atomic(src, dst, sz);
-UNSAFE_END
+} UNSAFE_END
 
 // This function is a leaf since if the source and destination are both in native memory
 // the copy may potentially be very large, and we don't want to disable GC if we can avoid it.
 // If either source or destination (or both) are on the heap, the function will enter VM using
 // JVM_ENTRY_FROM_LEAF
-JVM_LEAF(void, Unsafe_CopySwapMemory0(JNIEnv *env, jobject unsafe, jobject srcObj, jlong srcOffset, jobject dstObj, jlong dstOffset, jlong size, jlong elemSize)) {
-  UnsafeWrapper("Unsafe_CopySwapMemory0");
-
+UNSAFE_LEAF(void, Unsafe_CopySwapMemory0(JNIEnv *env, jobject unsafe, jobject srcObj, jlong srcOffset, jobject dstObj, jlong dstOffset, jlong size, jlong elemSize)) {
   size_t sz = (size_t)size;
   size_t esz = (size_t)elemSize;
 
@@ -689,32 +600,24 @@
       Copy::conjoint_swap(src, dst, sz, esz);
     } JVM_END
   }
-} JVM_END
+} UNSAFE_END
 
 ////// Random queries
 
-// See comment at file start about UNSAFE_LEAF
-//UNSAFE_LEAF(jint, Unsafe_AddressSize())
-UNSAFE_ENTRY(jint, Unsafe_AddressSize(JNIEnv *env, jobject unsafe))
-  UnsafeWrapper("Unsafe_AddressSize");
+UNSAFE_LEAF(jint, Unsafe_AddressSize0(JNIEnv *env, jobject unsafe)) {
   return sizeof(void*);
-UNSAFE_END
+} UNSAFE_END
 
-// See comment at file start about UNSAFE_LEAF
-//UNSAFE_LEAF(jint, Unsafe_PageSize())
-UNSAFE_ENTRY(jint, Unsafe_PageSize(JNIEnv *env, jobject unsafe))
-  UnsafeWrapper("Unsafe_PageSize");
+UNSAFE_LEAF(jint, Unsafe_PageSize()) {
   return os::vm_page_size();
-UNSAFE_END
+} UNSAFE_END
 
-jint find_field_offset(jobject field, int must_be_static, TRAPS) {
-  if (field == NULL) {
-    THROW_0(vmSymbols::java_lang_NullPointerException());
-  }
+static jint find_field_offset(jobject field, int must_be_static, TRAPS) {
+  assert(field != NULL, "field must not be NULL");
 
   oop reflected   = JNIHandles::resolve_non_null(field);
   oop mirror      = java_lang_reflect_Field::clazz(reflected);
-  Klass* k      = java_lang_Class::as_Klass(mirror);
+  Klass* k        = java_lang_Class::as_Klass(mirror);
   int slot        = java_lang_reflect_Field::slot(reflected);
   int modifiers   = java_lang_reflect_Field::modifiers(reflected);
 
@@ -729,18 +632,17 @@
   return field_offset_from_byte_offset(offset);
 }
 
-UNSAFE_ENTRY(jlong, Unsafe_ObjectFieldOffset(JNIEnv *env, jobject unsafe, jobject field))
-  UnsafeWrapper("Unsafe_ObjectFieldOffset");
+UNSAFE_ENTRY(jlong, Unsafe_ObjectFieldOffset0(JNIEnv *env, jobject unsafe, jobject field)) {
   return find_field_offset(field, 0, THREAD);
-UNSAFE_END
+} UNSAFE_END
 
-UNSAFE_ENTRY(jlong, Unsafe_StaticFieldOffset(JNIEnv *env, jobject unsafe, jobject field))
-  UnsafeWrapper("Unsafe_StaticFieldOffset");
+UNSAFE_ENTRY(jlong, Unsafe_StaticFieldOffset0(JNIEnv *env, jobject unsafe, jobject field)) {
   return find_field_offset(field, 1, THREAD);
-UNSAFE_END
+} UNSAFE_END
 
-UNSAFE_ENTRY(jobject, Unsafe_StaticFieldBaseFromField(JNIEnv *env, jobject unsafe, jobject field))
-  UnsafeWrapper("Unsafe_StaticFieldBase");
+UNSAFE_ENTRY(jobject, Unsafe_StaticFieldBase0(JNIEnv *env, jobject unsafe, jobject field)) {
+  assert(field != NULL, "field must not be NULL");
+
   // Note:  In this VM implementation, a field address is always a short
   // offset from the base of a a klass metaobject.  Thus, the full dynamic
   // range of the return type is never used.  However, some implementations
@@ -749,8 +651,6 @@
   // large.  In that last case, this function would return NULL, since
   // the address would operate alone, without any base pointer.
 
-  if (field == NULL)  THROW_0(vmSymbols::java_lang_NullPointerException());
-
   oop reflected   = JNIHandles::resolve_non_null(field);
   oop mirror      = java_lang_reflect_Field::clazz(reflected);
   int modifiers   = java_lang_reflect_Field::modifiers(reflected);
@@ -760,13 +660,11 @@
   }
 
   return JNIHandles::make_local(env, mirror);
-UNSAFE_END
+} UNSAFE_END
 
-UNSAFE_ENTRY(void, Unsafe_EnsureClassInitialized(JNIEnv *env, jobject unsafe, jobject clazz)) {
-  UnsafeWrapper("Unsafe_EnsureClassInitialized");
-  if (clazz == NULL) {
-    THROW(vmSymbols::java_lang_NullPointerException());
-  }
+UNSAFE_ENTRY(void, Unsafe_EnsureClassInitialized0(JNIEnv *env, jobject unsafe, jobject clazz)) {
+  assert(clazz != NULL, "clazz must not be NULL");
+
   oop mirror = JNIHandles::resolve_non_null(clazz);
 
   Klass* klass = java_lang_Class::as_Klass(mirror);
@@ -777,26 +675,26 @@
 }
 UNSAFE_END
 
-UNSAFE_ENTRY(jboolean, Unsafe_ShouldBeInitialized(JNIEnv *env, jobject unsafe, jobject clazz)) {
-  UnsafeWrapper("Unsafe_ShouldBeInitialized");
-  if (clazz == NULL) {
-    THROW_(vmSymbols::java_lang_NullPointerException(), false);
-  }
+UNSAFE_ENTRY(jboolean, Unsafe_ShouldBeInitialized0(JNIEnv *env, jobject unsafe, jobject clazz)) {
+  assert(clazz != NULL, "clazz must not be NULL");
+
   oop mirror = JNIHandles::resolve_non_null(clazz);
   Klass* klass = java_lang_Class::as_Klass(mirror);
+
   if (klass != NULL && klass->should_be_initialized()) {
     return true;
   }
+
   return false;
 }
 UNSAFE_END
 
-static void getBaseAndScale(int& base, int& scale, jclass acls, TRAPS) {
-  if (acls == NULL) {
-    THROW(vmSymbols::java_lang_NullPointerException());
-  }
-  oop      mirror = JNIHandles::resolve_non_null(acls);
-  Klass* k      = java_lang_Class::as_Klass(mirror);
+static void getBaseAndScale(int& base, int& scale, jclass clazz, TRAPS) {
+  assert(clazz != NULL, "clazz must not be NULL");
+
+  oop mirror = JNIHandles::resolve_non_null(clazz);
+  Klass* k = java_lang_Class::as_Klass(mirror);
+
   if (k == NULL || !k->is_array_klass()) {
     THROW(vmSymbols::java_lang_InvalidClassException());
   } else if (k->is_objArray_klass()) {
@@ -812,18 +710,18 @@
   }
 }
 
-UNSAFE_ENTRY(jint, Unsafe_ArrayBaseOffset(JNIEnv *env, jobject unsafe, jclass acls))
-  UnsafeWrapper("Unsafe_ArrayBaseOffset");
+UNSAFE_ENTRY(jint, Unsafe_ArrayBaseOffset0(JNIEnv *env, jobject unsafe, jclass clazz)) {
   int base = 0, scale = 0;
-  getBaseAndScale(base, scale, acls, CHECK_0);
+  getBaseAndScale(base, scale, clazz, CHECK_0);
+
   return field_offset_from_byte_offset(base);
-UNSAFE_END
+} UNSAFE_END
 
 
-UNSAFE_ENTRY(jint, Unsafe_ArrayIndexScale(JNIEnv *env, jobject unsafe, jclass acls))
-  UnsafeWrapper("Unsafe_ArrayIndexScale");
+UNSAFE_ENTRY(jint, Unsafe_ArrayIndexScale0(JNIEnv *env, jobject unsafe, jclass clazz)) {
   int base = 0, scale = 0;
-  getBaseAndScale(base, scale, acls, CHECK_0);
+  getBaseAndScale(base, scale, clazz, CHECK_0);
+
   // This VM packs both fields and array elements down to the byte.
   // But watch out:  If this changes, so that array references for
   // a given primitive type (say, T_BOOLEAN) use different memory units
@@ -839,100 +737,88 @@
   // The following allows for a pretty general fieldOffset cookie scheme,
   // but requires it to be linear in byte offset.
   return field_offset_from_byte_offset(scale) - field_offset_from_byte_offset(0);
-UNSAFE_END
+} UNSAFE_END
 
 
 static inline void throw_new(JNIEnv *env, const char *ename) {
   char buf[100];
+
   jio_snprintf(buf, 100, "%s%s", "java/lang/", ename);
+
   jclass cls = env->FindClass(buf);
   if (env->ExceptionCheck()) {
     env->ExceptionClear();
     tty->print_cr("Unsafe: cannot throw %s because FindClass has failed", buf);
     return;
   }
-  char* msg = NULL;
-  env->ThrowNew(cls, msg);
+
+  env->ThrowNew(cls, NULL);
 }
 
 static jclass Unsafe_DefineClass_impl(JNIEnv *env, jstring name, jbyteArray data, int offset, int length, jobject loader, jobject pd) {
-  {
-    // Code lifted from JDK 1.3 ClassLoader.c
+  // Code lifted from JDK 1.3 ClassLoader.c
+
+  jbyte *body;
+  char *utfName = NULL;
+  jclass result = 0;
+  char buf[128];
 
-    jbyte *body;
-    char *utfName;
-    jclass result = 0;
-    char buf[128];
+  assert(data != NULL, "Class bytes must not be NULL");
+  assert(length >= 0, "length must not be negative: %d", length);
 
-    if (UsePerfData) {
-      ClassLoader::unsafe_defineClassCallCounter()->inc();
-    }
+  if (UsePerfData) {
+    ClassLoader::unsafe_defineClassCallCounter()->inc();
+  }
 
-    if (data == NULL) {
-        throw_new(env, "NullPointerException");
-        return 0;
-    }
+  body = NEW_C_HEAP_ARRAY(jbyte, length, mtInternal);
+  if (body == NULL) {
+    throw_new(env, "OutOfMemoryError");
+    return 0;
+  }
+
+  env->GetByteArrayRegion(data, offset, length, body);
+  if (env->ExceptionOccurred()) {
+    goto free_body;
+  }
 
-    /* Work around 4153825. malloc crashes on Solaris when passed a
-     * negative size.
-     */
-    if (length < 0) {
-        throw_new(env, "ArrayIndexOutOfBoundsException");
-        return 0;
-    }
+  if (name != NULL) {
+    uint len = env->GetStringUTFLength(name);
+    int unicode_len = env->GetStringLength(name);
 
-    body = NEW_C_HEAP_ARRAY(jbyte, length, mtInternal);
-
-    if (body == 0) {
+    if (len >= sizeof(buf)) {
+      utfName = NEW_C_HEAP_ARRAY(char, len + 1, mtInternal);
+      if (utfName == NULL) {
         throw_new(env, "OutOfMemoryError");
-        return 0;
+        goto free_body;
+      }
+    } else {
+      utfName = buf;
     }
 
-    env->GetByteArrayRegion(data, offset, length, body);
-
-    if (env->ExceptionOccurred())
-        goto free_body;
+    env->GetStringUTFRegion(name, 0, unicode_len, utfName);
 
-    if (name != NULL) {
-        uint len = env->GetStringUTFLength(name);
-        int unicode_len = env->GetStringLength(name);
-        if (len >= sizeof(buf)) {
-            utfName = NEW_C_HEAP_ARRAY(char, len + 1, mtInternal);
-            if (utfName == NULL) {
-                throw_new(env, "OutOfMemoryError");
-                goto free_body;
-            }
-        } else {
-            utfName = buf;
-        }
-        env->GetStringUTFRegion(name, 0, unicode_len, utfName);
-        //VerifyFixClassname(utfName);
-        for (uint i = 0; i < len; i++) {
-          if (utfName[i] == '.')   utfName[i] = '/';
-        }
-    } else {
-        utfName = NULL;
+    for (uint i = 0; i < len; i++) {
+      if (utfName[i] == '.')   utfName[i] = '/';
     }
+  }
 
-    result = JVM_DefineClass(env, utfName, loader, body, length, pd);
+  result = JVM_DefineClass(env, utfName, loader, body, length, pd);
 
-    if (utfName && utfName != buf)
-        FREE_C_HEAP_ARRAY(char, utfName);
+  if (utfName && utfName != buf) {
+    FREE_C_HEAP_ARRAY(char, utfName);
+  }
 
  free_body:
-    FREE_C_HEAP_ARRAY(jbyte, body);
-    return result;
-  }
+  FREE_C_HEAP_ARRAY(jbyte, body);
+  return result;
 }
 
 
-UNSAFE_ENTRY(jclass, Unsafe_DefineClass(JNIEnv *env, jobject unsafe, jstring name, jbyteArray data, int offset, int length, jobject loader, jobject pd))
-  UnsafeWrapper("Unsafe_DefineClass");
-  {
-    ThreadToNativeFromVM ttnfv(thread);
-    return Unsafe_DefineClass_impl(env, name, data, offset, length, loader, pd);
-  }
-UNSAFE_END
+UNSAFE_ENTRY(jclass, Unsafe_DefineClass0(JNIEnv *env, jobject unsafe, jstring name, jbyteArray data, int offset, int length, jobject loader, jobject pd)) {
+  ThreadToNativeFromVM ttnfv(thread);
+
+  return Unsafe_DefineClass_impl(env, name, data, offset, length, loader, pd);
+} UNSAFE_END
 
 
 // define a class but do not make it known to the class loader or system dictionary
@@ -986,45 +872,35 @@
 static instanceKlassHandle
 Unsafe_DefineAnonymousClass_impl(JNIEnv *env,
                                  jclass host_class, jbyteArray data, jobjectArray cp_patches_jh,
-                                 HeapWord* *temp_alloc,
+                                 u1** temp_alloc,
                                  TRAPS) {
+  assert(host_class != NULL, "host_class must not be NULL");
+  assert(data != NULL, "data must not be NULL");
 
   if (UsePerfData) {
     ClassLoader::unsafe_defineClassCallCounter()->inc();
   }
 
-  if (data == NULL) {
-    THROW_0(vmSymbols::java_lang_NullPointerException());
-  }
+  jint length = typeArrayOop(JNIHandles::resolve_non_null(data))->length();
+  assert(length >= 0, "class_bytes_length must not be negative: %d", length);
 
-  jint length = typeArrayOop(JNIHandles::resolve_non_null(data))->length();
-  jint word_length = (length + sizeof(HeapWord)-1) / sizeof(HeapWord);
-  HeapWord* body = NEW_C_HEAP_ARRAY(HeapWord, word_length, mtInternal);
-  if (body == NULL) {
+  int class_bytes_length = (int) length;
+
+  u1* class_bytes = NEW_C_HEAP_ARRAY(u1, length, mtInternal);
+  if (class_bytes == NULL) {
     THROW_0(vmSymbols::java_lang_OutOfMemoryError());
   }
 
   // caller responsible to free it:
-  (*temp_alloc) = body;
-
-  {
-    jbyte* array_base = typeArrayOop(JNIHandles::resolve_non_null(data))->byte_at_addr(0);
-    Copy::conjoint_words((HeapWord*) array_base, body, word_length);
-  }
+  *temp_alloc = class_bytes;
 
-  u1* class_bytes = (u1*) body;
-  int class_bytes_length = (int) length;
-  if (class_bytes_length < 0)  class_bytes_length = 0;
-  if (class_bytes == NULL
-      || host_class == NULL
-      || length != class_bytes_length)
-    THROW_0(vmSymbols::java_lang_IllegalArgumentException());
+  jbyte* array_base = typeArrayOop(JNIHandles::resolve_non_null(data))->byte_at_addr(0);
+  Copy::conjoint_jbytes(array_base, class_bytes, length);
 
   objArrayHandle cp_patches_h;
   if (cp_patches_jh != NULL) {
     oop p = JNIHandles::resolve_non_null(cp_patches_jh);
-    if (!p->is_objArray())
-      THROW_0(vmSymbols::java_lang_IllegalArgumentException());
+    assert(p->is_objArray(), "cp_patches must be an object[]");
     cp_patches_h = objArrayHandle(THREAD, (objArrayOop)p);
   }
 
@@ -1036,60 +912,56 @@
   Handle      host_domain(THREAD, host_klass->protection_domain());
 
   GrowableArray<Handle>* cp_patches = NULL;
+
   if (cp_patches_h.not_null()) {
     int alen = cp_patches_h->length();
+
     for (int i = alen-1; i >= 0; i--) {
       oop p = cp_patches_h->obj_at(i);
       if (p != NULL) {
         Handle patch(THREAD, p);
-        if (cp_patches == NULL)
+
+        if (cp_patches == NULL) {
           cp_patches = new GrowableArray<Handle>(i+1, i+1, Handle());
+        }
+
         cp_patches->at_put(i, patch);
       }
     }
   }
 
-  ClassFileStream st(class_bytes,
-                     class_bytes_length,
-                     host_source,
-                     ClassFileStream::verify);
+  ClassFileStream st(class_bytes, class_bytes_length, host_source, ClassFileStream::verify);
 
-  instanceKlassHandle anon_klass;
-  {
-    Symbol* no_class_name = NULL;
-    Klass* anonk = SystemDictionary::parse_stream(no_class_name,
-                                                  host_loader,
-                                                  host_domain,
-                                                  &st,
-                                                  host_klass,
-                                                  cp_patches,
-                                                  CHECK_NULL);
-    if (anonk == NULL)  return NULL;
-    anon_klass = instanceKlassHandle(THREAD, anonk);
+  Symbol* no_class_name = NULL;
+  Klass* anonk = SystemDictionary::parse_stream(no_class_name,
+                                                host_loader,
+                                                host_domain,
+                                                &st,
+                                                host_klass,
+                                                cp_patches,
+                                                CHECK_NULL);
+  if (anonk == NULL) {
+    return NULL;
   }
 
-  return anon_klass;
+  return instanceKlassHandle(THREAD, anonk);
 }
 
-UNSAFE_ENTRY(jclass, Unsafe_DefineAnonymousClass(JNIEnv *env, jobject unsafe, jclass host_class, jbyteArray data, jobjectArray cp_patches_jh))
-{
+UNSAFE_ENTRY(jclass, Unsafe_DefineAnonymousClass0(JNIEnv *env, jobject unsafe, jclass host_class, jbyteArray data, jobjectArray cp_patches_jh)) {
+  ResourceMark rm(THREAD);
+
   instanceKlassHandle anon_klass;
   jobject res_jh = NULL;
-
-  UnsafeWrapper("Unsafe_DefineAnonymousClass");
-  ResourceMark rm(THREAD);
-
-  HeapWord* temp_alloc = NULL;
+  u1* temp_alloc = NULL;
 
-  anon_klass = Unsafe_DefineAnonymousClass_impl(env, host_class, data,
-                                                cp_patches_jh,
-                                                   &temp_alloc, THREAD);
-  if (anon_klass() != NULL)
+  anon_klass = Unsafe_DefineAnonymousClass_impl(env, host_class, data, cp_patches_jh, &temp_alloc, THREAD);
+  if (anon_klass() != NULL) {
     res_jh = JNIHandles::make_local(env, anon_klass->java_mirror());
+  }
 
   // try/finally clause:
   if (temp_alloc != NULL) {
-    FREE_C_HEAP_ARRAY(HeapWord, temp_alloc);
+    FREE_C_HEAP_ARRAY(u1, temp_alloc);
   }
 
   // The anonymous class loader data has been artificially been kept alive to
@@ -1102,100 +974,103 @@
   // let caller initialize it as needed...
 
   return (jclass) res_jh;
-}
-UNSAFE_END
+} UNSAFE_END
 
 
 
-UNSAFE_ENTRY(void, Unsafe_ThrowException(JNIEnv *env, jobject unsafe, jthrowable thr))
-  UnsafeWrapper("Unsafe_ThrowException");
-  {
-    ThreadToNativeFromVM ttnfv(thread);
-    env->Throw(thr);
-  }
-UNSAFE_END
+UNSAFE_ENTRY(void, Unsafe_ThrowException(JNIEnv *env, jobject unsafe, jthrowable thr)) {
+  ThreadToNativeFromVM ttnfv(thread);
+  env->Throw(thr);
+} UNSAFE_END
 
 // JSR166 ------------------------------------------------------------------
 
-UNSAFE_ENTRY(jobject, Unsafe_CompareAndExchangeObject(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject e_h, jobject x_h))
-  UnsafeWrapper("Unsafe_CompareAndExchangeObject");
+UNSAFE_ENTRY(jobject, Unsafe_CompareAndExchangeObject(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject e_h, jobject x_h)) {
   oop x = JNIHandles::resolve(x_h);
   oop e = JNIHandles::resolve(e_h);
   oop p = JNIHandles::resolve(obj);
   HeapWord* addr = (HeapWord *)index_oop_from_field_offset_long(p, offset);
   oop res = oopDesc::atomic_compare_exchange_oop(x, addr, e, true);
-  if (res == e)
+  if (res == e) {
     update_barrier_set((void*)addr, x);
+  }
   return JNIHandles::make_local(env, res);
-UNSAFE_END
+} UNSAFE_END
 
-UNSAFE_ENTRY(jint, Unsafe_CompareAndExchangeInt(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jint e, jint x))
-  UnsafeWrapper("Unsafe_CompareAndExchangeInt");
+UNSAFE_ENTRY(jint, Unsafe_CompareAndExchangeInt(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jint e, jint x)) {
   oop p = JNIHandles::resolve(obj);
   jint* addr = (jint *) index_oop_from_field_offset_long(p, offset);
-  return (jint)(Atomic::cmpxchg(x, addr, e));
-UNSAFE_END
 
-UNSAFE_ENTRY(jlong, Unsafe_CompareAndExchangeLong(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jlong e, jlong x))
-  UnsafeWrapper("Unsafe_CompareAndExchangeLong");
+  return (jint)(Atomic::cmpxchg(x, addr, e));
+} UNSAFE_END
+
+UNSAFE_ENTRY(jlong, Unsafe_CompareAndExchangeLong(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jlong e, jlong x)) {
   Handle p (THREAD, JNIHandles::resolve(obj));
   jlong* addr = (jlong*)(index_oop_from_field_offset_long(p(), offset));
+
 #ifdef SUPPORTS_NATIVE_CX8
   return (jlong)(Atomic::cmpxchg(x, addr, e));
 #else
-  if (VM_Version::supports_cx8())
+  if (VM_Version::supports_cx8()) {
     return (jlong)(Atomic::cmpxchg(x, addr, e));
-  else {
+  } else {
     MutexLockerEx mu(UnsafeJlong_lock, Mutex::_no_safepoint_check_flag);
+
     jlong val = Atomic::load(addr);
-    if (val == e)
+    if (val == e) {
       Atomic::store(x, addr);
+    }
     return val;
   }
 #endif
-UNSAFE_END
+} UNSAFE_END
 
-UNSAFE_ENTRY(jboolean, Unsafe_CompareAndSwapObject(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject e_h, jobject x_h))
-  UnsafeWrapper("Unsafe_CompareAndSwapObject");
+UNSAFE_ENTRY(jboolean, Unsafe_CompareAndSwapObject(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject e_h, jobject x_h)) {
   oop x = JNIHandles::resolve(x_h);
   oop e = JNIHandles::resolve(e_h);
   oop p = JNIHandles::resolve(obj);
   HeapWord* addr = (HeapWord *)index_oop_from_field_offset_long(p, offset);
   oop res = oopDesc::atomic_compare_exchange_oop(x, addr, e, true);
-  jboolean success  = (res == e);
-  if (success)
-    update_barrier_set((void*)addr, x);
-  return success;
-UNSAFE_END
+  if (res != e) {
+    return false;
+  }
 
-UNSAFE_ENTRY(jboolean, Unsafe_CompareAndSwapInt(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jint e, jint x))
-  UnsafeWrapper("Unsafe_CompareAndSwapInt");
+  update_barrier_set((void*)addr, x);
+
+  return true;
+} UNSAFE_END
+
+UNSAFE_ENTRY(jboolean, Unsafe_CompareAndSwapInt(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jint e, jint x)) {
   oop p = JNIHandles::resolve(obj);
   jint* addr = (jint *) index_oop_from_field_offset_long(p, offset);
+
   return (jint)(Atomic::cmpxchg(x, addr, e)) == e;
-UNSAFE_END
+} UNSAFE_END
 
-UNSAFE_ENTRY(jboolean, Unsafe_CompareAndSwapLong(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jlong e, jlong x))
-  UnsafeWrapper("Unsafe_CompareAndSwapLong");
-  Handle p (THREAD, JNIHandles::resolve(obj));
-  jlong* addr = (jlong*)(index_oop_from_field_offset_long(p(), offset));
+UNSAFE_ENTRY(jboolean, Unsafe_CompareAndSwapLong(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jlong e, jlong x)) {
+  Handle p(THREAD, JNIHandles::resolve(obj));
+  jlong* addr = (jlong*)index_oop_from_field_offset_long(p(), offset);
+
 #ifdef SUPPORTS_NATIVE_CX8
   return (jlong)(Atomic::cmpxchg(x, addr, e)) == e;
 #else
-  if (VM_Version::supports_cx8())
+  if (VM_Version::supports_cx8()) {
     return (jlong)(Atomic::cmpxchg(x, addr, e)) == e;
-  else {
-    jboolean success = false;
+  } else {
     MutexLockerEx mu(UnsafeJlong_lock, Mutex::_no_safepoint_check_flag);
+
     jlong val = Atomic::load(addr);
-    if (val == e) { Atomic::store(x, addr); success = true; }
-    return success;
+    if (val != e) {
+      return false;
+    }
+
+    Atomic::store(x, addr);
+    return true;
   }
 #endif
-UNSAFE_END
+} UNSAFE_END
 
-UNSAFE_ENTRY(void, Unsafe_Park(JNIEnv *env, jobject unsafe, jboolean isAbsolute, jlong time))
-  UnsafeWrapper("Unsafe_Park");
+UNSAFE_ENTRY(void, Unsafe_Park(JNIEnv *env, jobject unsafe, jboolean isAbsolute, jlong time)) {
   EventThreadPark event;
   HOTSPOT_THREAD_PARK_BEGIN((uintptr_t) thread->parker(), (int) isAbsolute, time);
 
@@ -1203,6 +1078,7 @@
   thread->parker()->park(isAbsolute != 0, time);
 
   HOTSPOT_THREAD_PARK_END((uintptr_t) thread->parker());
+
   if (event.should_commit()) {
     oop obj = thread->current_park_blocker();
     event.set_klass((obj != NULL) ? obj->klass() : NULL);
@@ -1210,11 +1086,11 @@
     event.set_address((obj != NULL) ? (TYPE_ADDRESS) cast_from_oop<uintptr_t>(obj) : 0);
     event.commit();
   }
-UNSAFE_END
+} UNSAFE_END
 
-UNSAFE_ENTRY(void, Unsafe_Unpark(JNIEnv *env, jobject unsafe, jobject jthread))
-  UnsafeWrapper("Unsafe_Unpark");
+UNSAFE_ENTRY(void, Unsafe_Unpark(JNIEnv *env, jobject unsafe, jobject jthread)) {
   Parker* p = NULL;
+
   if (jthread != NULL) {
     oop java_thread = JNIHandles::resolve_non_null(jthread);
     if (java_thread != NULL) {
@@ -1228,6 +1104,7 @@
         // Grab lock if apparently null or using older version of library
         MutexLocker mu(Threads_lock);
         java_thread = JNIHandles::resolve_non_null(jthread);
+
         if (java_thread != NULL) {
           JavaThread* thr = java_lang_Thread::thread(java_thread);
           if (thr != NULL) {
@@ -1240,14 +1117,14 @@
       }
     }
   }
+
   if (p != NULL) {
     HOTSPOT_THREAD_UNPARK((uintptr_t) p);
     p->unpark();
   }
-UNSAFE_END
+} UNSAFE_END
 
-UNSAFE_ENTRY(jint, Unsafe_Loadavg(JNIEnv *env, jobject unsafe, jdoubleArray loadavg, jint nelem))
-  UnsafeWrapper("Unsafe_Loadavg");
+UNSAFE_ENTRY(jint, Unsafe_GetLoadAverage0(JNIEnv *env, jobject unsafe, jdoubleArray loadavg, jint nelem)) {
   const int max_nelem = 3;
   double la[max_nelem];
   jint ret;
@@ -1255,15 +1132,11 @@
   typeArrayOop a = typeArrayOop(JNIHandles::resolve_non_null(loadavg));
   assert(a->is_typeArray(), "must be type array");
 
-  if (nelem < 0 || nelem > max_nelem || a->length() < nelem) {
-    ThreadToNativeFromVM ttnfv(thread);
-    throw_new(env, "ArrayIndexOutOfBoundsException");
+  ret = os::loadavg(la, nelem);
+  if (ret == -1) {
     return -1;
   }
 
-  ret = os::loadavg(la, nelem);
-  if (ret == -1) return -1;
-
   // if successful, ret is the number of samples actually retrieved.
   assert(ret >= 0 && ret <= max_nelem, "Unexpected loadavg return value");
   switch(ret) {
@@ -1271,8 +1144,9 @@
     case 2: a->double_at_put(1, (jdouble)la[1]); // fall through
     case 1: a->double_at_put(0, (jdouble)la[0]); break;
   }
+
   return ret;
-UNSAFE_END
+} UNSAFE_END
 
 
 /// JVM_RegisterUnsafeMethods
@@ -1292,87 +1166,17 @@
 #define CC (char*)  /*cast a literal from (const char*)*/
 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
 
-#define DECLARE_GETPUTOOP(Boolean, Z) \
-    {CC "get" #Boolean,      CC "(" OBJ "J)" #Z,       FN_PTR(Unsafe_Get##Boolean)}, \
-    {CC "put" #Boolean,      CC "(" OBJ "J" #Z ")V",   FN_PTR(Unsafe_Set##Boolean)}, \
-    {CC "get" #Boolean "Volatile",      CC "(" OBJ "J)" #Z,       FN_PTR(Unsafe_Get##Boolean##Volatile)}, \
-    {CC "put" #Boolean "Volatile",      CC "(" OBJ "J" #Z ")V",   FN_PTR(Unsafe_Set##Boolean##Volatile)}
+#define DECLARE_GETPUTOOP(Type, Desc) \
+    {CC "get" #Type,      CC "(" OBJ "J)" #Desc,       FN_PTR(Unsafe_Get##Type)}, \
+    {CC "put" #Type,      CC "(" OBJ "J" #Desc ")V",   FN_PTR(Unsafe_Set##Type)}, \
+    {CC "get" #Type "Volatile",      CC "(" OBJ "J)" #Desc,       FN_PTR(Unsafe_Get##Type##Volatile)}, \
+    {CC "put" #Type "Volatile",      CC "(" OBJ "J" #Desc ")V",   FN_PTR(Unsafe_Set##Type##Volatile)}
 
 
 #define DECLARE_GETPUTNATIVE(Byte, B) \
     {CC "get" #Byte,         CC "(" ADR ")" #B,       FN_PTR(Unsafe_GetNative##Byte)}, \
     {CC "put" #Byte,         CC "(" ADR#B ")V",       FN_PTR(Unsafe_SetNative##Byte)}
 
-
-static JNINativeMethod sun_misc_Unsafe_methods[] = {
-    {CC "getObject",        CC "(" OBJ "J)" OBJ "",   FN_PTR(Unsafe_GetObject)},
-    {CC "putObject",        CC "(" OBJ "J" OBJ ")V",  FN_PTR(Unsafe_SetObject)},
-    {CC "getObjectVolatile",CC "(" OBJ "J)" OBJ "",   FN_PTR(Unsafe_GetObjectVolatile)},
-    {CC "putObjectVolatile",CC "(" OBJ "J" OBJ ")V",  FN_PTR(Unsafe_SetObjectVolatile)},
-
-    {CC "getUncompressedObject", CC "(" ADR ")" OBJ,  FN_PTR(Unsafe_GetUncompressedObject)},
-    {CC "getJavaMirror",         CC "(" ADR ")" CLS,  FN_PTR(Unsafe_GetJavaMirror)},
-    {CC "getKlassPointer",       CC "(" OBJ ")" ADR,  FN_PTR(Unsafe_GetKlassPointer)},
-
-    DECLARE_GETPUTOOP(Boolean, Z),
-    DECLARE_GETPUTOOP(Byte, B),
-    DECLARE_GETPUTOOP(Short, S),
-    DECLARE_GETPUTOOP(Char, C),
-    DECLARE_GETPUTOOP(Int, I),
-    DECLARE_GETPUTOOP(Long, J),
-    DECLARE_GETPUTOOP(Float, F),
-    DECLARE_GETPUTOOP(Double, D),
-
-    DECLARE_GETPUTNATIVE(Byte, B),
-    DECLARE_GETPUTNATIVE(Short, S),
-    DECLARE_GETPUTNATIVE(Char, C),
-    DECLARE_GETPUTNATIVE(Int, I),
-    DECLARE_GETPUTNATIVE(Long, J),
-    DECLARE_GETPUTNATIVE(Float, F),
-    DECLARE_GETPUTNATIVE(Double, D),
-
-    {CC "getAddress",         CC "(" ADR ")" ADR,        FN_PTR(Unsafe_GetNativeAddress)},
-    {CC "putAddress",         CC "(" ADR "" ADR ")V",    FN_PTR(Unsafe_SetNativeAddress)},
-
-    {CC "allocateMemory",     CC "(J)" ADR,              FN_PTR(Unsafe_AllocateMemory)},
-    {CC "reallocateMemory",   CC "(" ADR "J)" ADR,       FN_PTR(Unsafe_ReallocateMemory)},
-    {CC "freeMemory",         CC "(" ADR ")V",           FN_PTR(Unsafe_FreeMemory)},
-
-    {CC "objectFieldOffset",  CC "(" FLD ")J",           FN_PTR(Unsafe_ObjectFieldOffset)},
-    {CC "staticFieldOffset",  CC "(" FLD ")J",           FN_PTR(Unsafe_StaticFieldOffset)},
-    {CC "staticFieldBase",    CC "(" FLD ")" OBJ,        FN_PTR(Unsafe_StaticFieldBaseFromField)},
-    {CC "ensureClassInitialized",CC "(" CLS ")V",        FN_PTR(Unsafe_EnsureClassInitialized)},
-    {CC "arrayBaseOffset",    CC "(" CLS ")I",           FN_PTR(Unsafe_ArrayBaseOffset)},
-    {CC "arrayIndexScale",    CC "(" CLS ")I",           FN_PTR(Unsafe_ArrayIndexScale)},
-    {CC "addressSize",        CC "()I",                  FN_PTR(Unsafe_AddressSize)},
-    {CC "pageSize",           CC "()I",                  FN_PTR(Unsafe_PageSize)},
-
-    {CC "defineClass",        CC "(" DC_Args ")" CLS,    FN_PTR(Unsafe_DefineClass)},
-    {CC "allocateInstance",   CC "(" CLS ")" OBJ,        FN_PTR(Unsafe_AllocateInstance)},
-    {CC "throwException",     CC "(" THR ")V",           FN_PTR(Unsafe_ThrowException)},
-    {CC "compareAndSwapObject", CC "(" OBJ "J" OBJ "" OBJ ")Z", FN_PTR(Unsafe_CompareAndSwapObject)},
-    {CC "compareAndSwapInt",  CC "(" OBJ "J""I""I"")Z",  FN_PTR(Unsafe_CompareAndSwapInt)},
-    {CC "compareAndSwapLong", CC "(" OBJ "J""J""J"")Z",  FN_PTR(Unsafe_CompareAndSwapLong)},
-    {CC "putOrderedObject",   CC "(" OBJ "J" OBJ ")V",   FN_PTR(Unsafe_SetOrderedObject)},
-    {CC "putOrderedInt",      CC "(" OBJ "JI)V",         FN_PTR(Unsafe_SetOrderedInt)},
-    {CC "putOrderedLong",     CC "(" OBJ "JJ)V",         FN_PTR(Unsafe_SetOrderedLong)},
-    {CC "park",               CC "(ZJ)V",                FN_PTR(Unsafe_Park)},
-    {CC "unpark",             CC "(" OBJ ")V",           FN_PTR(Unsafe_Unpark)},
-
-    {CC "getLoadAverage",     CC "([DI)I",               FN_PTR(Unsafe_Loadavg)},
-
-    {CC "copyMemory",         CC "(" OBJ "J" OBJ "JJ)V", FN_PTR(Unsafe_CopyMemory)},
-    {CC "setMemory",          CC "(" OBJ "JJB)V",        FN_PTR(Unsafe_SetMemory)},
-
-    {CC "defineAnonymousClass", CC "(" DAC_Args ")" CLS, FN_PTR(Unsafe_DefineAnonymousClass)},
-
-    {CC "shouldBeInitialized",CC "(" CLS ")Z",           FN_PTR(Unsafe_ShouldBeInitialized)},
-
-    {CC "loadFence",          CC "()V",                  FN_PTR(Unsafe_LoadFence)},
-    {CC "storeFence",         CC "()V",                  FN_PTR(Unsafe_StoreFence)},
-    {CC "fullFence",          CC "()V",                  FN_PTR(Unsafe_FullFence)},
-};
-
 static JNINativeMethod jdk_internal_misc_Unsafe_methods[] = {
     {CC "getObject",        CC "(" OBJ "J)" OBJ "",   FN_PTR(Unsafe_GetObject)},
     {CC "putObject",        CC "(" OBJ "J" OBJ ")V",  FN_PTR(Unsafe_SetObject)},
@@ -1403,20 +1207,20 @@
     {CC "getAddress",         CC "(" ADR ")" ADR,        FN_PTR(Unsafe_GetNativeAddress)},
     {CC "putAddress",         CC "(" ADR "" ADR ")V",    FN_PTR(Unsafe_SetNativeAddress)},
 
-    {CC "allocateMemory",     CC "(J)" ADR,              FN_PTR(Unsafe_AllocateMemory)},
-    {CC "reallocateMemory",   CC "(" ADR "J)" ADR,       FN_PTR(Unsafe_ReallocateMemory)},
-    {CC "freeMemory",         CC "(" ADR ")V",           FN_PTR(Unsafe_FreeMemory)},
+    {CC "allocateMemory0",    CC "(J)" ADR,              FN_PTR(Unsafe_AllocateMemory0)},
+    {CC "reallocateMemory0",  CC "(" ADR "J)" ADR,       FN_PTR(Unsafe_ReallocateMemory0)},
+    {CC "freeMemory0",        CC "(" ADR ")V",           FN_PTR(Unsafe_FreeMemory0)},
 
-    {CC "objectFieldOffset",  CC "(" FLD ")J",           FN_PTR(Unsafe_ObjectFieldOffset)},
-    {CC "staticFieldOffset",  CC "(" FLD ")J",           FN_PTR(Unsafe_StaticFieldOffset)},
-    {CC "staticFieldBase",    CC "(" FLD ")" OBJ,        FN_PTR(Unsafe_StaticFieldBaseFromField)},
-    {CC "ensureClassInitialized",CC "(" CLS ")V",        FN_PTR(Unsafe_EnsureClassInitialized)},
-    {CC "arrayBaseOffset",    CC "(" CLS ")I",           FN_PTR(Unsafe_ArrayBaseOffset)},
-    {CC "arrayIndexScale",    CC "(" CLS ")I",           FN_PTR(Unsafe_ArrayIndexScale)},
-    {CC "addressSize",        CC "()I",                  FN_PTR(Unsafe_AddressSize)},
+    {CC "objectFieldOffset0", CC "(" FLD ")J",           FN_PTR(Unsafe_ObjectFieldOffset0)},
+    {CC "staticFieldOffset0", CC "(" FLD ")J",           FN_PTR(Unsafe_StaticFieldOffset0)},
+    {CC "staticFieldBase0",   CC "(" FLD ")" OBJ,        FN_PTR(Unsafe_StaticFieldBase0)},
+    {CC "ensureClassInitialized0", CC "(" CLS ")V",      FN_PTR(Unsafe_EnsureClassInitialized0)},
+    {CC "arrayBaseOffset0",   CC "(" CLS ")I",           FN_PTR(Unsafe_ArrayBaseOffset0)},
+    {CC "arrayIndexScale0",   CC "(" CLS ")I",           FN_PTR(Unsafe_ArrayIndexScale0)},
+    {CC "addressSize0",       CC "()I",                  FN_PTR(Unsafe_AddressSize0)},
     {CC "pageSize",           CC "()I",                  FN_PTR(Unsafe_PageSize)},
 
-    {CC "defineClass",        CC "(" DC_Args ")" CLS,    FN_PTR(Unsafe_DefineClass)},
+    {CC "defineClass0",       CC "(" DC_Args ")" CLS,    FN_PTR(Unsafe_DefineClass0)},
     {CC "allocateInstance",   CC "(" CLS ")" OBJ,        FN_PTR(Unsafe_AllocateInstance)},
     {CC "throwException",     CC "(" THR ")V",           FN_PTR(Unsafe_ThrowException)},
     {CC "compareAndSwapObject", CC "(" OBJ "J" OBJ "" OBJ ")Z", FN_PTR(Unsafe_CompareAndSwapObject)},
@@ -1432,15 +1236,15 @@
     {CC "park",               CC "(ZJ)V",                FN_PTR(Unsafe_Park)},
     {CC "unpark",             CC "(" OBJ ")V",           FN_PTR(Unsafe_Unpark)},
 
-    {CC "getLoadAverage",     CC "([DI)I",               FN_PTR(Unsafe_Loadavg)},
+    {CC "getLoadAverage0",    CC "([DI)I",               FN_PTR(Unsafe_GetLoadAverage0)},
 
-    {CC "copyMemory",         CC "(" OBJ "J" OBJ "JJ)V", FN_PTR(Unsafe_CopyMemory)},
+    {CC "copyMemory0",        CC "(" OBJ "J" OBJ "JJ)V", FN_PTR(Unsafe_CopyMemory0)},
     {CC "copySwapMemory0",    CC "(" OBJ "J" OBJ "JJJ)V", FN_PTR(Unsafe_CopySwapMemory0)},
-    {CC "setMemory",          CC "(" OBJ "JJB)V",        FN_PTR(Unsafe_SetMemory)},
+    {CC "setMemory0",         CC "(" OBJ "JJB)V",        FN_PTR(Unsafe_SetMemory0)},
 
-    {CC "defineAnonymousClass", CC "(" DAC_Args ")" CLS, FN_PTR(Unsafe_DefineAnonymousClass)},
+    {CC "defineAnonymousClass0", CC "(" DAC_Args ")" CLS, FN_PTR(Unsafe_DefineAnonymousClass0)},
 
-    {CC "shouldBeInitialized",CC "(" CLS ")Z",           FN_PTR(Unsafe_ShouldBeInitialized)},
+    {CC "shouldBeInitialized0", CC "(" CLS ")Z",         FN_PTR(Unsafe_ShouldBeInitialized0)},
 
     {CC "loadFence",          CC "()V",                  FN_PTR(Unsafe_LoadFence)},
     {CC "storeFence",         CC "()V",                  FN_PTR(Unsafe_StoreFence)},
@@ -1466,27 +1270,14 @@
 #undef DECLARE_GETPUTNATIVE
 
 
-// These two functions are exported, used by NativeLookup.
+// This function is exported, used by NativeLookup.
 // The Unsafe_xxx functions above are called only from the interpreter.
 // The optimizer looks at names and signatures to recognize
 // individual functions.
 
-JVM_ENTRY(void, JVM_RegisterSunMiscUnsafeMethods(JNIEnv *env, jclass unsafeclass))
-  UnsafeWrapper("JVM_RegisterSunMiscUnsafeMethods");
-  {
-    ThreadToNativeFromVM ttnfv(thread);
-
-    int ok = env->RegisterNatives(unsafeclass, sun_misc_Unsafe_methods, sizeof(sun_misc_Unsafe_methods)/sizeof(JNINativeMethod));
-    guarantee(ok == 0, "register sun.misc.Unsafe natives");
-  }
-JVM_END
+JVM_ENTRY(void, JVM_RegisterJDKInternalMiscUnsafeMethods(JNIEnv *env, jclass unsafeclass)) {
+  ThreadToNativeFromVM ttnfv(thread);
 
-JVM_ENTRY(void, JVM_RegisterJDKInternalMiscUnsafeMethods(JNIEnv *env, jclass unsafeclass))
-  UnsafeWrapper("JVM_RegisterJDKInternalMiscUnsafeMethods");
-  {
-    ThreadToNativeFromVM ttnfv(thread);
-
-    int ok = env->RegisterNatives(unsafeclass, jdk_internal_misc_Unsafe_methods, sizeof(jdk_internal_misc_Unsafe_methods)/sizeof(JNINativeMethod));
-    guarantee(ok == 0, "register jdk.internal.misc.Unsafe natives");
-  }
-JVM_END
+  int ok = env->RegisterNatives(unsafeclass, jdk_internal_misc_Unsafe_methods, sizeof(jdk_internal_misc_Unsafe_methods)/sizeof(JNINativeMethod));
+  guarantee(ok == 0, "register jdk.internal.misc.Unsafe natives");
+} JVM_END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/vm/prims/unsafe.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+
+#ifndef SHARE_VM_PRIMS_UNSAFE_HPP
+#define SHARE_VM_PRIMS_UNSAFE_HPP
+
+#include "jni.h"
+
+extern "C" {
+  void JNICALL JVM_RegisterJDKInternalMiscUnsafeMethods(JNIEnv *env, jclass unsafecls);
+}
+
+jlong Unsafe_field_offset_to_byte_offset(jlong field_offset);
+
+jlong Unsafe_field_offset_from_byte_offset(jlong byte_offset);
+
+#endif // SHARE_VM_PRIMS_UNSAFE_HPP
--- a/hotspot/src/share/vm/prims/whitebox.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/prims/whitebox.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -31,6 +31,7 @@
 #include "classfile/stringTable.hpp"
 #include "code/codeCache.hpp"
 #include "compiler/methodMatcher.hpp"
+#include "compiler/directivesParser.hpp"
 #include "jvmtifiles/jvmtiEnv.hpp"
 #include "memory/metadataFactory.hpp"
 #include "memory/metaspaceShared.hpp"
@@ -637,6 +638,10 @@
 WB_END
 
 WB_ENTRY(jboolean, WB_EnqueueMethodForCompilation(JNIEnv* env, jobject o, jobject method, jint comp_level, jint bci))
+  // Screen for unavailable/bad comp level
+  if (CompileBroker::compiler(comp_level) == NULL) {
+    return false;
+  }
   jmethodID jmid = reflected_method_to_jmid(thread, env, method);
   CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
   methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
@@ -1539,6 +1544,27 @@
   }
 }
 
+WB_ENTRY(jint, WB_AddCompilerDirective(JNIEnv* env, jobject o, jstring compDirect))
+  // can't be in VM when we call JNI
+  ThreadToNativeFromVM ttnfv(thread);
+  const char* dir = env->GetStringUTFChars(compDirect, NULL);
+  int ret;
+  {
+    ThreadInVMfromNative ttvfn(thread); // back to VM
+    ret = DirectivesParser::parse_string(dir, tty);
+  }
+  env->ReleaseStringUTFChars(compDirect, dir);
+  // -1 for error parsing directive. Return 0 as number of directives added.
+  if (ret == -1) {
+    ret = 0;
+  }
+  return (jint) ret;
+WB_END
+
+WB_ENTRY(void, WB_RemoveCompilerDirective(JNIEnv* env, jobject o, jint count))
+  DirectivesStack::pop(count);
+WB_END
+
 #define CC (char*)
 
 static JNINativeMethod methods[] = {
@@ -1732,6 +1758,9 @@
   {CC"isSharedClass",      CC"(Ljava/lang/Class;)Z",  (void*)&WB_IsSharedClass },
   {CC"areSharedStringsIgnored",           CC"()Z",    (void*)&WB_AreSharedStringsIgnored },
   {CC"clearInlineCaches",  CC"()V",                   (void*)&WB_ClearInlineCaches },
+  {CC"addCompilerDirective",    CC"(Ljava/lang/String;)I",
+                                                      (void*)&WB_AddCompilerDirective },
+  {CC"removeCompilerDirective", CC"(I)V",             (void*)&WB_RemoveCompilerDirective },
 };
 
 #undef CC
--- a/hotspot/src/share/vm/runtime/advancedThresholdPolicy.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/runtime/advancedThresholdPolicy.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,17 +42,30 @@
 }
 
 void AdvancedThresholdPolicy::initialize() {
+  int count = CICompilerCount;
+#ifdef _LP64
   // Turn on ergonomic compiler count selection
   if (FLAG_IS_DEFAULT(CICompilerCountPerCPU) && FLAG_IS_DEFAULT(CICompilerCount)) {
     FLAG_SET_DEFAULT(CICompilerCountPerCPU, true);
   }
-  int count = CICompilerCount;
   if (CICompilerCountPerCPU) {
     // Simple log n seems to grow too slowly for tiered, try something faster: log n * log log n
     int log_cpu = log2_intptr(os::active_processor_count());
     int loglog_cpu = log2_intptr(MAX2(log_cpu, 1));
     count = MAX2(log_cpu * loglog_cpu, 1) * 3 / 2;
   }
+#else
+  // On 32-bit systems, the number of compiler threads is limited to 3.
+  // On these systems, the virtual address space available to the JVM
+  // is usually limited to 2-4 GB (the exact value depends on the platform).
+  // As the compilers (especially C2) can consume a large amount of
+  // memory, scaling the number of compiler threads with the number of
+  // available cores can result in the exhaustion of the address space
+  /// available to the VM and thus cause the VM to crash.
+  if (FLAG_IS_DEFAULT(CICompilerCount)) {
+    count = 3;
+  }
+#endif
 
   set_c1_count(MAX2(count / 3, 1));
   set_c2_count(MAX2(count - c1_count(), 1));
@@ -164,9 +177,7 @@
 
 // Called with the queue locked and with at least one element
 CompileTask* AdvancedThresholdPolicy::select_task(CompileQueue* compile_queue) {
-#if INCLUDE_JVMCI
   CompileTask *max_blocking_task = NULL;
-#endif
   CompileTask *max_task = NULL;
   Method* max_method = NULL;
   jlong t = os::javaTimeMillis();
@@ -180,7 +191,8 @@
       max_method = method;
     } else {
       // If a method has been stale for some time, remove it from the queue.
-      if (is_stale(t, TieredCompileTaskTimeout, method) && !is_old(method)) {
+      // Blocking tasks don't become stale
+      if (!task->is_blocking() && is_stale(t, TieredCompileTaskTimeout, method) && !is_old(method)) {
         if (PrintTieredEvents) {
           print_event(REMOVE_FROM_QUEUE, method, method, task->osr_bci(), (CompLevel)task->comp_level());
         }
@@ -197,29 +209,25 @@
         max_method = method;
       }
     }
-#if INCLUDE_JVMCI
-    if (UseJVMCICompiler && task->is_blocking()) {
+
+    if (task->is_blocking()) {
       if (max_blocking_task == NULL || compare_methods(method, max_blocking_task->method())) {
         max_blocking_task = task;
       }
     }
-#endif
+
     task = next_task;
   }
 
-#if INCLUDE_JVMCI
-  if (UseJVMCICompiler) {
-    if (max_blocking_task != NULL) {
-      // In blocking compilation mode, the CompileBroker will make
-      // compilations submitted by a JVMCI compiler thread non-blocking. These
-      // compilations should be scheduled after all blocking compilations
-      // to service non-compiler related compilations sooner and reduce the
-      // chance of such compilations timing out.
-      max_task = max_blocking_task;
-      max_method = max_task->method();
-    }
+  if (max_blocking_task != NULL) {
+    // In blocking compilation mode, the CompileBroker will make
+    // compilations submitted by a JVMCI compiler thread non-blocking. These
+    // compilations should be scheduled after all blocking compilations
+    // to service non-compiler related compilations sooner and reduce the
+    // chance of such compilations timing out.
+    max_task = max_blocking_task;
+    max_method = max_task->method();
   }
-#endif
 
   if (max_task->comp_level() == CompLevel_full_profile && TieredStopAtLevel > CompLevel_full_profile
       && is_method_profiled(max_method)) {
--- a/hotspot/src/share/vm/runtime/arguments.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/runtime/arguments.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -235,8 +235,6 @@
 
   // Set OS specific system properties values
   os::init_system_properties_values();
-
-  JVMCI_ONLY(JVMCIRuntime::init_system_properties(&_system_properties);)
 }
 
 // Update/Initialize System properties after JDK version number is known
@@ -2540,9 +2538,11 @@
     status = false;
   }
 
+#ifdef _LP64
   if (!FLAG_IS_DEFAULT(CICompilerCount) && !FLAG_IS_DEFAULT(CICompilerCountPerCPU) && CICompilerCountPerCPU) {
     warning("The VM option CICompilerCountPerCPU overrides CICompilerCount.");
   }
+#endif
 
 #ifndef SUPPORT_RESERVED_STACK_AREA
   if (StackReservedPages != 0) {
--- a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsCompiler.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsCompiler.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -354,6 +354,14 @@
   return Flag::SUCCESS;
 }
 
+Flag::Error InitArrayShortSizeConstraintFunc(intx value, bool verbose) {
+  if (value % BytesPerLong != 0) {
+    return Flag::VIOLATES_CONSTRAINT;
+  } else {
+    return Flag::SUCCESS;
+  }
+}
+
 #ifdef COMPILER2
 Flag::Error InteriorEntryAlignmentConstraintFunc(intx value, bool verbose) {
   if (InteriorEntryAlignment > CodeEntryAlignment) {
--- a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsCompiler.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsCompiler.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -62,6 +62,8 @@
 
 Flag::Error TypeProfileLevelConstraintFunc(uintx value, bool verbose);
 
+Flag::Error InitArrayShortSizeConstraintFunc(intx value, bool verbose);
+
 #ifdef COMPILER2
 Flag::Error InteriorEntryAlignmentConstraintFunc(intx value, bool verbose);
 
--- a/hotspot/src/share/vm/runtime/commandLineFlagRangeList.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/runtime/commandLineFlagRangeList.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -247,6 +247,9 @@
 void emit_range_double(const char* /*name*/)    { /* NOP */ }
 
 // CommandLineFlagRange emitting code functions if range arguments are provided
+void emit_range_int(const char* name, int min, int max)       {
+  CommandLineFlagRangeList::add(new CommandLineFlagRange_int(name, min, max));
+}
 void emit_range_intx(const char* name, intx min, intx max) {
   CommandLineFlagRangeList::add(new CommandLineFlagRange_intx(name, min, max));
 }
--- a/hotspot/src/share/vm/runtime/globals.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/runtime/globals.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -725,7 +725,7 @@
                                                                             \
   product(bool, UseSHA, false,                                              \
           "Control whether SHA instructions can be used "                   \
-          "on SPARC and on ARM")                                            \
+          "on SPARC, on ARM and on x86")                                    \
                                                                             \
   product(bool, UseGHASHIntrinsics, false,                                  \
           "Use intrinsics for GHASH versions of crypto")                    \
@@ -891,9 +891,6 @@
   notproduct(bool, VerifyLastFrame, false,                                  \
           "Verify oops on last frame on entry to VM")                       \
                                                                             \
-  develop(bool, TraceHandleAllocation, false,                               \
-          "Print out warnings when suspiciously many handles are allocated")\
-                                                                            \
   product(bool, FailOverToOldVerifier, true,                                \
           "Fail over to old verifier when split verifier fails")            \
                                                                             \
@@ -1603,10 +1600,10 @@
   product(bool, ResizePLAB, true,                                           \
           "Dynamically resize (survivor space) promotion LAB's")            \
                                                                             \
-  product(intx, ParGCArrayScanChunk, 50,                                    \
+  product(int, ParGCArrayScanChunk, 50,                                     \
           "Scan a subset of object array and push remainder, if array is "  \
           "bigger than this")                                               \
-          range(1, max_intx)                                                \
+          range(1, max_jint/3)                                              \
                                                                             \
   product(bool, ParGCUseLocalOverflow, false,                               \
           "Instead of a global overflow list, use local overflow stacks")   \
@@ -3024,14 +3021,6 @@
   notproduct(ccstrlist, SuppressErrorAt, "",                                \
           "List of assertions (file:line) to muzzle")                       \
                                                                             \
-  notproduct(size_t, HandleAllocationLimit, 1024,                           \
-          "Threshold for HandleMark allocation when +TraceHandleAllocation "\
-          "is used")                                                        \
-                                                                            \
-  develop(size_t, TotalHandleAllocationLimit, 1024,                         \
-          "Threshold for total handle allocation when "                     \
-          "+TraceHandleAllocation is used")                                 \
-                                                                            \
   develop(intx, StackPrintLimit, 100,                                       \
           "number of stack frames to print in VM-level stack dump")         \
                                                                             \
@@ -3079,16 +3068,16 @@
   develop(intx, MethodHistogramCutoff, 100,                                 \
           "The cutoff value for method invocation histogram (+CountCalls)") \
                                                                             \
-  develop(intx, ProfilerNumberOfInterpretedMethods, 25,                     \
+  diagnostic(intx, ProfilerNumberOfInterpretedMethods, 25,                  \
           "Number of interpreted methods to show in profile")               \
                                                                             \
-  develop(intx, ProfilerNumberOfCompiledMethods, 25,                        \
+  diagnostic(intx, ProfilerNumberOfCompiledMethods, 25,                     \
           "Number of compiled methods to show in profile")                  \
                                                                             \
-  develop(intx, ProfilerNumberOfStubMethods, 25,                            \
+  diagnostic(intx, ProfilerNumberOfStubMethods, 25,                         \
           "Number of stub methods to show in profile")                      \
                                                                             \
-  develop(intx, ProfilerNumberOfRuntimeStubNodes, 25,                       \
+  diagnostic(intx, ProfilerNumberOfRuntimeStubNodes, 25,                    \
           "Number of runtime stub nodes to show in profile")                \
                                                                             \
   product(intx, ProfileIntervalsTicks, 100,                                 \
@@ -4149,6 +4138,13 @@
              "in the loaded class C. "                                      \
              "Check (3) is available only in debug builds.")                \
                                                                             \
+  develop_pd(intx, InitArrayShortSize,                                      \
+          "Threshold small size (in bytes) for clearing arrays. "           \
+          "Anything this size or smaller may get converted to discrete "    \
+          "scalar stores.")                                                 \
+          range(0, max_intx)                                                \
+          constraint(InitArrayShortSizeConstraintFunc, AfterErgo)           \
+                                                                            \
   diagnostic(bool, CompilerDirectivesIgnoreCompileCommands, false,          \
              "Disable backwards compatibility for compile commands.")       \
                                                                             \
--- a/hotspot/src/share/vm/runtime/handles.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/runtime/handles.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -129,14 +129,6 @@
     k = k->next();
   }
 
-  // The thread local handle areas should not get very large
-  if (TraceHandleAllocation && (size_t)handles_visited > TotalHandleAllocationLimit) {
-#ifdef ASSERT
-    warning("%d: Visited in HandleMark : " SIZE_FORMAT, _nof_handlemarks, handles_visited);
-#else
-    warning("Visited in HandleMark : " SIZE_FORMAT, handles_visited);
-#endif
-  }
   if (_prev != NULL) _prev->oops_do(f);
 }
 
@@ -165,31 +157,6 @@
   assert(area->_handle_mark_nesting > 0, "must stack allocate HandleMarks" );
   debug_only(area->_handle_mark_nesting--);
 
-  // Debug code to trace the number of handles allocated per mark/
-#ifdef ASSERT
-  if (TraceHandleAllocation) {
-    size_t handles = 0;
-    Chunk *c = _chunk->next();
-    if (c == NULL) {
-      handles = area->_hwm - _hwm; // no new chunk allocated
-    } else {
-      handles = _max - _hwm;      // add rest in first chunk
-      while(c != NULL) {
-        handles += c->length();
-        c = c->next();
-      }
-      handles -= area->_max - area->_hwm; // adjust for last trunk not full
-    }
-    handles /= sizeof(void *); // Adjust for size of a handle
-    if (handles > HandleAllocationLimit) {
-      // Note: _nof_handlemarks is only set in debug mode
-      warning("%d: Allocated in HandleMark : " SIZE_FORMAT, _nof_handlemarks, handles);
-    }
-
-    tty->print_cr("Handles " SIZE_FORMAT, handles);
-  }
-#endif
-
   // Delete later chunks
   if( _chunk->next() ) {
     // reset arena size before delete chunks. Otherwise, the total
--- a/hotspot/src/share/vm/runtime/interfaceSupport.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/runtime/interfaceSupport.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -521,9 +521,9 @@
     JNI_ENTRY_NO_PRESERVE(result_type, header)                       \
     WeakPreserveExceptionMark __wem(thread);
 
-#define JNI_ENTRY_NO_PRESERVE(result_type, header)             \
+#define JNI_ENTRY_NO_PRESERVE(result_type, header)                   \
 extern "C" {                                                         \
-  result_type JNICALL header {                                \
+  result_type JNICALL header {                                       \
     JavaThread* thread=JavaThread::thread_from_jni_environment(env); \
     assert( !VerifyJNIEnvThread || (thread == Thread::current()), "JNIEnv is only valid in same thread"); \
     ThreadInVMfromNative __tiv(thread);                              \
@@ -535,7 +535,7 @@
 // a GC, is called outside the NoHandleMark (set via VM_QUICK_ENTRY_BASE).
 #define JNI_QUICK_ENTRY(result_type, header)                         \
 extern "C" {                                                         \
-  result_type JNICALL header {                                \
+  result_type JNICALL header {                                       \
     JavaThread* thread=JavaThread::thread_from_jni_environment(env); \
     assert( !VerifyJNIEnvThread || (thread == Thread::current()), "JNIEnv is only valid in same thread"); \
     ThreadInVMfromNative __tiv(thread);                              \
@@ -545,7 +545,7 @@
 
 #define JNI_LEAF(result_type, header)                                \
 extern "C" {                                                         \
-  result_type JNICALL header {                                \
+  result_type JNICALL header {                                       \
     JavaThread* thread=JavaThread::thread_from_jni_environment(env); \
     assert( !VerifyJNIEnvThread || (thread == Thread::current()), "JNIEnv is only valid in same thread"); \
     VM_LEAF_BASE(result_type, header)
--- a/hotspot/src/share/vm/runtime/simpleThresholdPolicy.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/runtime/simpleThresholdPolicy.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -138,9 +138,15 @@
     FLAG_SET_DEFAULT(CICompilerCount, 3);
   }
   int count = CICompilerCount;
+#ifdef _LP64
+  // On 64-bit systems, scale the number of compiler threads with
+  // the number of cores available on the system. Scaling is not
+  // performed on 32-bit systems because it can lead to exhaustion
+  // of the virtual memory address space available to the JVM.
   if (CICompilerCountPerCPU) {
     count = MAX2(log2_intptr(os::active_processor_count()), 1) * 3 / 2;
   }
+#endif
   set_c1_count(MAX2(count / 3, 1));
   set_c2_count(MAX2(count - c1_count(), 1));
   FLAG_SET_ERGO(intx, CICompilerCount, c1_count() + c2_count());
--- a/hotspot/src/share/vm/runtime/thread.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/runtime/thread.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -3738,15 +3738,6 @@
     Chunk::start_chunk_pool_cleaner_task();
   }
 
-#if INCLUDE_JVMCI
-  if (EnableJVMCI) {
-    const char* jvmciCompiler = Arguments::PropertyList_get_value(Arguments::system_properties(), "jvmci.compiler");
-    if (jvmciCompiler != NULL) {
-      JVMCIRuntime::save_compiler(jvmciCompiler);
-    }
-  }
-#endif // INCLUDE_JVMCI
-
   // initialize compiler(s)
 #if defined(COMPILER1) || defined(COMPILER2) || defined(SHARK) || INCLUDE_JVMCI
   CompileBroker::compilation_init(CHECK_JNI_ERR);
--- a/hotspot/src/share/vm/services/diagnosticCommand.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/services/diagnosticCommand.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -931,7 +931,7 @@
 }
 
 void CompilerDirectivesRemoveDCmd::execute(DCmdSource source, TRAPS) {
-  DirectivesStack::pop();
+  DirectivesStack::pop(1);
 }
 
 void CompilerDirectivesClearDCmd::execute(DCmdSource source, TRAPS) {
--- a/hotspot/src/share/vm/shark/sharkBuilder.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/shark/sharkBuilder.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -29,6 +29,7 @@
 #include "gc/shared/cardTableModRefBS.hpp"
 #include "memory/resourceArea.hpp"
 #include "oops/method.hpp"
+#include "prims/unsafe.hpp"
 #include "runtime/os.hpp"
 #include "runtime/synchronizer.hpp"
 #include "runtime/thread.hpp"
@@ -326,7 +327,6 @@
 }
 
 Value* SharkBuilder::unsafe_field_offset_to_byte_offset() {
-  extern jlong Unsafe_field_offset_to_byte_offset(jlong field_offset);
   return make_function((address) Unsafe_field_offset_to_byte_offset, "l", "l");
 }
 
--- a/hotspot/src/share/vm/utilities/globalDefinitions.hpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/utilities/globalDefinitions.hpp	Mon Mar 28 08:41:54 2016 -0700
@@ -313,7 +313,7 @@
 // ANSI C++ does not allow casting from one pointer type to a function pointer
 // directly without at best a warning. This macro accomplishes it silently
 // In every case that is present at this point the value be cast is a pointer
-// to a C linkage function. In somecase the type used for the cast reflects
+// to a C linkage function. In some case the type used for the cast reflects
 // that linkage and a picky compiler would not complain. In other cases because
 // there is no convenient place to place a typedef with extern C linkage (i.e
 // a platform dependent header file) it doesn't. At this point no compiler seems
@@ -678,7 +678,7 @@
 inline const char* type2name(BasicType t) { return (uint)t < T_CONFLICT+1 ? type2name_tab[t] : NULL; }
 extern BasicType name2type(const char* name);
 
-// Auxilary math routines
+// Auxiliary math routines
 // least common multiple
 extern size_t lcm(size_t a, size_t b);
 
@@ -801,7 +801,7 @@
 
 // TosState describes the top-of-stack state before and after the execution of
 // a bytecode or method. The top-of-stack value may be cached in one or more CPU
-// registers. The TosState corresponds to the 'machine represention' of this cached
+// registers. The TosState corresponds to the 'machine representation' of this cached
 // value. There's 4 states corresponding to the JAVA types int, long, float & double
 // as well as a 5th state in case the top-of-stack value is actually on the top
 // of stack (in memory) and thus not cached. The atos state corresponds to the itos
@@ -876,7 +876,7 @@
 // a transition from one state to another. These extra states makes it possible for the safepoint code to
 // handle certain thread_states without having to suspend the thread - making the safepoint code faster.
 //
-// Given a state, the xxx_trans state can always be found by adding 1.
+// Given a state, the xxxx_trans state can always be found by adding 1.
 //
 enum JavaThreadState {
   _thread_uninitialized     =  0, // should never happen (missing initialization)
@@ -1425,7 +1425,7 @@
 // operations.
 
 // The goal of this code to avoid undefined or implementation-defined
-// behaviour.  The use of an lvalue to reference cast is explicitly
+// behavior.  The use of an lvalue to reference cast is explicitly
 // permitted by Lvalues and rvalues [basic.lval].  [Section 3.10 Para
 // 15 in C++03]
 #define JAVA_INTEGER_OP(OP, NAME, TYPE, UNSIGNED_TYPE)  \
--- a/hotspot/src/share/vm/utilities/ostream.cpp	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/src/share/vm/utilities/ostream.cpp	Mon Mar 28 08:41:54 2016 -0700
@@ -338,7 +338,9 @@
       }
       char* oldbuf = buffer;
       assert(rm == NULL || Thread::current()->current_resource_mark() == rm,
-             "stringStream is re-allocated with a different ResourceMark");
+             "StringStream is re-allocated with a different ResourceMark. Current: "
+             PTR_FORMAT " original: " PTR_FORMAT,
+             p2i(Thread::current()->current_resource_mark()), p2i(rm));
       buffer = NEW_RESOURCE_ARRAY(char, end);
       if (buffer_pos > 0) {
         memcpy(buffer, oldbuf, buffer_pos);
--- a/hotspot/test/TEST.groups	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/TEST.groups	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -230,8 +230,10 @@
 #
 needs_g1gc = \
   compiler/regalloc/C1ObjectSpillInLogicOp.java \
+  gc/TestSmallHeap.java \
   gc/TestSystemGC.java \
   gc/arguments/TestAlignmentToUseLargePages.java \
+  gc/arguments/TestG1ConcRefinementThreads.java \
   gc/arguments/TestG1HeapRegionSize.java \
   gc/arguments/TestG1HeapSizeFlags.java \
   gc/arguments/TestG1PercentageOptions.java \
@@ -242,11 +244,11 @@
   gc/class_unloading/TestG1ClassUnloadingHWM.java \
   gc/ergonomics/TestDynamicNumberOfGCThreads.java \
   gc/g1/ \
+  gc/logging/TestGCId.java \
   gc/metaspace/G1AddMetaspaceDependency.java \
   gc/metaspace/TestMetaspacePerfCounters.java \
   gc/startup_warnings/TestG1.java \
-  gc/whitebox/TestConcMarkCycleWB.java \
-  gc/arguments/TestG1ConcRefinementThreads.java
+  gc/whitebox/TestConcMarkCycleWB.java 
 
 hotspot_native_sanity = \
   native_sanity
--- a/hotspot/test/compiler/compilercontrol/jcmd/StressAddJcmdBase.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/compiler/compilercontrol/jcmd/StressAddJcmdBase.java	Mon Mar 28 08:41:54 2016 -0700
@@ -32,74 +32,99 @@
 import jdk.test.lib.Utils;
 import pool.PoolHelper;
 
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Random;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
-import java.util.stream.Stream;
 
 public abstract class StressAddJcmdBase {
     private static final int DIRECTIVES_AMOUNT = Integer.getInteger(
             "compiler.compilercontrol.jcmd.StressAddJcmdBase.directivesAmount",
-            1000);
-    private static final int DIRECTIVE_FILES = Integer.getInteger(
-            "compiler.compilercontrol.jcmd.StressAddJcmdBase.directiveFiles",
-            5);
+            200);
+    private static final int TIMEOUT = Integer.getInteger(
+            "compiler.compilercontrol.jcmd.StressAddJcmdBase.timeout",
+            30);
     private static final List<MethodDescriptor> DESCRIPTORS = new PoolHelper()
             .getAllMethods().stream()
                     .map(pair -> AbstractTestBase
                             .getValidMethodDescriptor(pair.first))
                     .collect(Collectors.toList());
+    private static final String DIRECTIVE_FILE = "directives.json";
+    private static final List<String> VM_OPTIONS = new ArrayList<>();
+    private static final Random RANDOM = Utils.getRandomInstance();
+
+    static {
+        VM_OPTIONS.add("-Xmixed");
+        VM_OPTIONS.add("-XX:+UnlockDiagnosticVMOptions");
+        VM_OPTIONS.add("-XX:+LogCompilation");
+        VM_OPTIONS.add("-XX:CompilerDirectivesLimit=1001");
+    }
 
     /**
      * Performs test
      */
     public void test() {
-        List<String> commands = prepareCommands();
-        Executor executor = new TimeLimitedExecutor(commands);
+        HugeDirectiveUtil.createHugeFile(DESCRIPTORS, DIRECTIVE_FILE,
+                DIRECTIVES_AMOUNT);
+        Executor executor = new TimeLimitedExecutor();
         List<OutputAnalyzer> outputAnalyzers = executor.execute();
         outputAnalyzers.get(0).shouldHaveExitValue(0);
     }
 
     /**
-     * Makes connection to the test VM
+     * Makes connection to the test VM and performs a diagnostic command
      *
-     * @param pid      a pid of the VM under test
-     * @param commands a list of jcmd commands to be executed
+     * @param pid a pid of the VM under test
      * @return true if the test should continue invocation of this method
      */
-    protected abstract boolean makeConnection(int pid, List<String> commands);
+    protected abstract boolean makeConnection(int pid);
 
     /**
      * Finish test executions
      */
     protected void finish() { }
 
-    private List<String> prepareCommands() {
-        String[] files = new String[DIRECTIVE_FILES];
-        for (int i = 0; i < DIRECTIVE_FILES; i++) {
-            files[i] = "directives" + i + ".json";
-            HugeDirectiveUtil.createHugeFile(DESCRIPTORS, files[i],
-                    DIRECTIVES_AMOUNT);
+    protected String nextCommand() {
+        int i = RANDOM.nextInt(JcmdCommand.values().length);
+        JcmdCommand jcmdCommand = JcmdCommand.values()[i];
+        switch (jcmdCommand) {
+            case ADD:
+                return jcmdCommand.command + " " + DIRECTIVE_FILE;
+            case PRINT:
+            case CLEAR:
+            case REMOVE:
+                return jcmdCommand.command;
+            default:
+                throw new Error("TESTBUG: incorrect command: " + jcmdCommand);
         }
-        return Stream.of(files)
-                .map(file -> "Compiler.directives_add " + file)
-                .collect(Collectors.toList());
+    }
+
+    private enum JcmdCommand {
+        ADD("Compiler.directives_add"),
+        PRINT("Compiler.directives_print"),
+        CLEAR("Compiler.directives_clear"),
+        REMOVE("Compiler.directives_remove");
+
+        public final String command;
+
+        JcmdCommand(String command) {
+            this.command = command;
+        }
     }
 
     private class TimeLimitedExecutor extends Executor {
-        private final List<String> jcmdCommands;
-
-        public TimeLimitedExecutor(List<String> jcmdCommands) {
+        public TimeLimitedExecutor() {
             /* There are no need to check the state */
-            super(true, null, null, jcmdCommands);
-            this.jcmdCommands = jcmdCommands;
+            super(true, VM_OPTIONS, null, null);
         }
 
         @Override
         protected OutputAnalyzer[] executeJCMD(int pid) {
             TimeLimitedRunner runner = new TimeLimitedRunner(
-                    Utils.DEFAULT_TEST_TIMEOUT,
+                    TimeUnit.SECONDS.toMillis(TIMEOUT),
                     Utils.TIMEOUT_FACTOR,
-                    () -> makeConnection(pid, jcmdCommands));
+                    () -> makeConnection(pid));
             try {
                 runner.call();
             } catch (Exception e) {
--- a/hotspot/test/compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java	Mon Mar 28 08:41:54 2016 -0700
@@ -27,21 +27,19 @@
  * @summary Tests jcmd to be able to add a lot of huge directive files with
  *          parallel executed jcmds until timeout has reached
  * @library /testlibrary /test/lib /compiler/testlibrary ../share /
- * @ignore 8148563
  * @build compiler.compilercontrol.jcmd.StressAddMultiThreadedTest
  *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
  *        compiler.testlibrary.CompilerUtils
  *        compiler.compilercontrol.share.actions.*
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm/timeout=360 compiler.compilercontrol.jcmd.StressAddMultiThreadedTest
+ * @run driver compiler.compilercontrol.jcmd.StressAddMultiThreadedTest
  */
 
 package compiler.compilercontrol.jcmd;
 
 import jdk.test.lib.dcmd.PidJcmdExecutor;
 
-import java.util.List;
 import java.util.concurrent.ArrayBlockingQueue;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.ExecutorService;
@@ -49,16 +47,15 @@
 import java.util.concurrent.TimeUnit;
 
 public class StressAddMultiThreadedTest extends StressAddJcmdBase {
-    private static final int THREADS;
+    private static final int THREADS = Integer.getInteger(
+            "compiler.compilercontrol.jcmd.StressAddMultiThreadedTest.threads",
+            5);
+    private volatile int commands = Integer.getInteger(
+            "compiler.compilercontrol.jcmd.StressAddMultiThreadedTest.commands",
+            20);
     private final BlockingQueue<Runnable> queue;
     private final ExecutorService executor;
 
-    static {
-        THREADS = Runtime.getRuntime().availableProcessors()
-                * Integer.getInteger("compiler.compilercontrol.jcmd" +
-                        ".StressAddMultiThreadedTest.threadFactor", 10);
-    }
-
     public StressAddMultiThreadedTest() {
         queue = new ArrayBlockingQueue<>(THREADS);
         executor = new ThreadPoolExecutor(THREADS, THREADS, 100,
@@ -71,14 +68,10 @@
     }
 
     @Override
-    protected boolean makeConnection(int pid, List<String> commands) {
-        commands.forEach(command -> {
-            if (!executor.isShutdown()) {
-                executor.submit(() -> new PidJcmdExecutor(String.valueOf(pid))
-                        .execute(command));
-            }
-        });
-        return !executor.isShutdown();
+    protected boolean makeConnection(int pid) {
+        executor.submit(() -> new PidJcmdExecutor(String.valueOf(pid))
+                .execute(nextCommand()));
+        return (--commands != 0);
     }
 
     @Override
--- a/hotspot/test/compiler/compilercontrol/jcmd/StressAddSequentiallyTest.java	Thu Mar 24 02:04:14 2016 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 8137167
- * @summary Tests jcmd to be able to add a lot of huge directives
- * @library /testlibrary /test/lib /compiler/testlibrary ../share /
- * @build compiler.compilercontrol.jcmd.StressAddSequentiallyTest
- *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
- *        compiler.testlibrary.CompilerUtils
- *        compiler.compilercontrol.share.actions.*
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm/timeout=300 compiler.compilercontrol.jcmd.StressAddSequentiallyTest
- */
-
-package compiler.compilercontrol.jcmd;
-
-import jdk.test.lib.dcmd.PidJcmdExecutor;
-
-import java.util.List;
-
-public class StressAddSequentiallyTest extends StressAddJcmdBase {
-    public static void main(String[] args) {
-        new StressAddSequentiallyTest().test();
-    }
-
-    @Override
-    protected boolean makeConnection(int pid, List<String> commands) {
-        commands.forEach(command -> new PidJcmdExecutor(String.valueOf(pid))
-                .execute(command));
-        return true;
-    }
-}
--- a/hotspot/test/compiler/compilercontrol/share/MultiCommand.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/compiler/compilercontrol/share/MultiCommand.java	Mon Mar 28 08:41:54 2016 -0700
@@ -53,8 +53,8 @@
         List<CompileCommand> testCases = new ArrayList<>();
         for (Command cmd : commands) {
             if (validOnly && cmd == Command.NONEXISTENT) {
-                // skip invalid command
-                continue;
+                // replace with a valid command
+                cmd = Command.EXCLUDE;
             }
             Executable exec = Utils.getRandomElement(METHODS).first;
             MethodDescriptor md;
--- a/hotspot/test/compiler/intrinsics/IntrinsicDisabledTest.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/compiler/intrinsics/IntrinsicDisabledTest.java	Mon Mar 28 08:41:54 2016 -0700
@@ -33,8 +33,8 @@
  *                   -XX:+WhiteBoxAPI
  *                   -XX:DisableIntrinsic=_putCharVolatile,_putInt
  *                   -XX:DisableIntrinsic=_putIntVolatile
- *                   -XX:CompileCommand=option,sun.misc.Unsafe::putChar,ccstrlist,DisableIntrinsic,_getCharVolatile,_getInt
- *                   -XX:CompileCommand=option,sun.misc.Unsafe::putCharVolatile,ccstrlist,DisableIntrinsic,_getIntVolatile
+ *                   -XX:CompileCommand=option,jdk.internal.misc.Unsafe::putChar,ccstrlist,DisableIntrinsic,_getCharVolatile,_getInt
+ *                   -XX:CompileCommand=option,jdk.internal.misc.Unsafe::putCharVolatile,ccstrlist,DisableIntrinsic,_getIntVolatile
  *                   IntrinsicDisabledTest
  */
 
@@ -60,7 +60,7 @@
         return Boolean.valueOf(Objects.toString(wb.getVMFlag("TieredCompilation")));
     }
 
-    /* This test uses several methods from sun.misc.Unsafe. The method
+    /* This test uses several methods from jdk.internal.misc.Unsafe. The method
      * getMethod() returns a different Executable for each different
      * combination of its input parameters. There are eight possible
      * combinations, getMethod can return an Executable representing
@@ -74,7 +74,7 @@
         String methodTypeName = isChar ? "Char" : "Int";
 
         try {
-            Class aClass = Class.forName("sun.misc.Unsafe");
+            Class aClass = Class.forName("jdk.internal.misc.Unsafe");
             if (isPut) {
                 aMethod = aClass.getDeclaredMethod("put" + methodTypeName + (isVolatile ? "Volatile" : ""),
                                                    Object.class,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/intrinsics/class/TestClassIsPrimitive.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+/*
+ * @test
+ * @bug 8150669
+ * @summary C1 intrinsic for Class.isPrimitive
+ * @modules java.base/jdk.internal.misc
+ * @run main/othervm -ea -Diters=200   -Xint                   TestClassIsPrimitive
+ * @run main/othervm -ea -Diters=30000 -XX:TieredStopAtLevel=1 TestClassIsPrimitive
+ * @run main/othervm -ea -Diters=30000 -XX:TieredStopAtLevel=4 TestClassIsPrimitive
+ */
+import java.lang.reflect.Field;
+import java.lang.reflect.Array;
+import java.util.concurrent.Callable;
+
+public class TestClassIsPrimitive {
+    static final int ITERS = Integer.getInteger("iters", 1);
+
+    public static void main(String... args) throws Exception {
+        testOK(true,  InlineConstants::testBoolean);
+        testOK(true,  InlineConstants::testByte);
+        testOK(true,  InlineConstants::testShort);
+        testOK(true,  InlineConstants::testChar);
+        testOK(true,  InlineConstants::testInt);
+        testOK(true,  InlineConstants::testFloat);
+        testOK(true,  InlineConstants::testLong);
+        testOK(true,  InlineConstants::testDouble);
+        testOK(false, InlineConstants::testObject);
+        testOK(false, InlineConstants::testArray);
+
+        testOK(true,  StaticConstants::testBoolean);
+        testOK(true,  StaticConstants::testByte);
+        testOK(true,  StaticConstants::testShort);
+        testOK(true,  StaticConstants::testChar);
+        testOK(true,  StaticConstants::testInt);
+        testOK(true,  StaticConstants::testFloat);
+        testOK(true,  StaticConstants::testLong);
+        testOK(true,  StaticConstants::testDouble);
+        testOK(false, StaticConstants::testObject);
+        testOK(false, StaticConstants::testArray);
+        testNPE(      StaticConstants::testNull);
+
+        testOK(true,  NoConstants::testBoolean);
+        testOK(true,  NoConstants::testByte);
+        testOK(true,  NoConstants::testShort);
+        testOK(true,  NoConstants::testChar);
+        testOK(true,  NoConstants::testInt);
+        testOK(true,  NoConstants::testFloat);
+        testOK(true,  NoConstants::testLong);
+        testOK(true,  NoConstants::testDouble);
+        testOK(false, NoConstants::testObject);
+        testOK(false, NoConstants::testArray);
+        testNPE(      NoConstants::testNull);
+    }
+
+    public static void testOK(boolean expected, Callable<Object> test) throws Exception {
+        for (int c = 0; c < ITERS; c++) {
+            Object res = test.call();
+            if (!res.equals(expected)) {
+                throw new IllegalStateException("Wrong result: expected = " + expected + ", but got " + res);
+            }
+        }
+    }
+
+    static volatile Object sink;
+
+    public static void testNPE(Callable<Object> test) throws Exception {
+        for (int c = 0; c < ITERS; c++) {
+            try {
+               sink = test.call();
+               throw new IllegalStateException("Expected NPE");
+            } catch (NullPointerException iae) {
+               // expected
+            }
+        }
+    }
+
+    static volatile Class<?> classBoolean = boolean.class;
+    static volatile Class<?> classByte    = byte.class;
+    static volatile Class<?> classShort   = short.class;
+    static volatile Class<?> classChar    = char.class;
+    static volatile Class<?> classInt     = int.class;
+    static volatile Class<?> classFloat   = float.class;
+    static volatile Class<?> classLong    = long.class;
+    static volatile Class<?> classDouble  = double.class;
+    static volatile Class<?> classObject  = Object.class;
+    static volatile Class<?> classArray   = Object[].class;
+    static volatile Class<?> classNull    = null;
+
+    static final Class<?> staticClassBoolean = boolean.class;
+    static final Class<?> staticClassByte    = byte.class;
+    static final Class<?> staticClassShort   = short.class;
+    static final Class<?> staticClassChar    = char.class;
+    static final Class<?> staticClassInt     = int.class;
+    static final Class<?> staticClassFloat   = float.class;
+    static final Class<?> staticClassLong    = long.class;
+    static final Class<?> staticClassDouble  = double.class;
+    static final Class<?> staticClassObject  = Object.class;
+    static final Class<?> staticClassArray   = Object[].class;
+    static final Class<?> staticClassNull    = null;
+
+    static class InlineConstants {
+        static boolean testBoolean() { return boolean.class.isPrimitive();  }
+        static boolean testByte()    { return byte.class.isPrimitive();     }
+        static boolean testShort()   { return short.class.isPrimitive();    }
+        static boolean testChar()    { return char.class.isPrimitive();     }
+        static boolean testInt()     { return int.class.isPrimitive();      }
+        static boolean testFloat()   { return float.class.isPrimitive();    }
+        static boolean testLong()    { return long.class.isPrimitive();     }
+        static boolean testDouble()  { return double.class.isPrimitive();   }
+        static boolean testObject()  { return Object.class.isPrimitive();   }
+        static boolean testArray()   { return Object[].class.isPrimitive(); }
+    }
+
+    static class StaticConstants {
+        static boolean testBoolean() { return staticClassBoolean.isPrimitive(); }
+        static boolean testByte()    { return staticClassByte.isPrimitive();    }
+        static boolean testShort()   { return staticClassShort.isPrimitive();   }
+        static boolean testChar()    { return staticClassChar.isPrimitive();    }
+        static boolean testInt()     { return staticClassInt.isPrimitive();     }
+        static boolean testFloat()   { return staticClassFloat.isPrimitive();   }
+        static boolean testLong()    { return staticClassLong.isPrimitive();    }
+        static boolean testDouble()  { return staticClassDouble.isPrimitive();  }
+        static boolean testObject()  { return staticClassObject.isPrimitive();  }
+        static boolean testArray()   { return staticClassArray.isPrimitive();   }
+        static boolean testNull()    { return staticClassNull.isPrimitive();    }
+    }
+
+    static class NoConstants {
+        static boolean testBoolean() { return classBoolean.isPrimitive(); }
+        static boolean testByte()    { return classByte.isPrimitive();    }
+        static boolean testShort()   { return classShort.isPrimitive();   }
+        static boolean testChar()    { return classChar.isPrimitive();    }
+        static boolean testInt()     { return classInt.isPrimitive();     }
+        static boolean testFloat()   { return classFloat.isPrimitive();   }
+        static boolean testLong()    { return classLong.isPrimitive();    }
+        static boolean testDouble()  { return classDouble.isPrimitive();  }
+        static boolean testObject()  { return classObject.isPrimitive();  }
+        static boolean testArray()   { return classArray.isPrimitive();   }
+        static boolean testNull()    { return classNull.isPrimitive();    }
+    }
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/intrinsics/unsafe/AllocateUninitializedArray.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,213 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+/*
+ * @test
+ * @bug 8150465
+ * @summary Unsafe methods to produce uninitialized arrays
+ * @modules java.base/jdk.internal.misc
+ * @run main/othervm -ea -Diters=200   -Xint                   AllocateUninitializedArray
+ * @run main/othervm -ea -Diters=30000 -XX:TieredStopAtLevel=1 AllocateUninitializedArray
+ * @run main/othervm -ea -Diters=30000 -XX:TieredStopAtLevel=4 AllocateUninitializedArray
+ */
+import java.lang.reflect.Field;
+import java.lang.reflect.Array;
+import java.util.concurrent.Callable;
+
+public class AllocateUninitializedArray {
+    static final int ITERS = Integer.getInteger("iters", 1);
+    static final jdk.internal.misc.Unsafe UNSAFE;
+
+    static {
+        try {
+            Field f = jdk.internal.misc.Unsafe.class.getDeclaredField("theUnsafe");
+            f.setAccessible(true);
+            UNSAFE = (jdk.internal.misc.Unsafe) f.get(null);
+        } catch (Exception e) {
+            throw new RuntimeException("Unable to get Unsafe instance.", e);
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+        testIAE(AllConstants::testObject);
+        testIAE(LengthIsConstant::testObject);
+        testIAE(ClassIsConstant::testObject);
+        testIAE(NothingIsConstant::testObject);
+
+        testIAE(AllConstants::testArray);
+        testIAE(LengthIsConstant::testArray);
+        testIAE(ClassIsConstant::testArray);
+        testIAE(NothingIsConstant::testArray);
+
+        testIAE(AllConstants::testNull);
+        testIAE(LengthIsConstant::testNull);
+        testIAE(ClassIsConstant::testNull);
+        testIAE(NothingIsConstant::testNull);
+
+        testOK(boolean[].class, 10, AllConstants::testBoolean);
+        testOK(byte[].class,    10, AllConstants::testByte);
+        testOK(short[].class,   10, AllConstants::testShort);
+        testOK(char[].class,    10, AllConstants::testChar);
+        testOK(int[].class,     10, AllConstants::testInt);
+        testOK(float[].class,   10, AllConstants::testFloat);
+        testOK(long[].class,    10, AllConstants::testLong);
+        testOK(double[].class,  10, AllConstants::testDouble);
+
+        testOK(boolean[].class, 10, LengthIsConstant::testBoolean);
+        testOK(byte[].class,    10, LengthIsConstant::testByte);
+        testOK(short[].class,   10, LengthIsConstant::testShort);
+        testOK(char[].class,    10, LengthIsConstant::testChar);
+        testOK(int[].class,     10, LengthIsConstant::testInt);
+        testOK(float[].class,   10, LengthIsConstant::testFloat);
+        testOK(long[].class,    10, LengthIsConstant::testLong);
+        testOK(double[].class,  10, LengthIsConstant::testDouble);
+
+        testOK(boolean[].class, 10, ClassIsConstant::testBoolean);
+        testOK(byte[].class,    10, ClassIsConstant::testByte);
+        testOK(short[].class,   10, ClassIsConstant::testShort);
+        testOK(char[].class,    10, ClassIsConstant::testChar);
+        testOK(int[].class,     10, ClassIsConstant::testInt);
+        testOK(float[].class,   10, ClassIsConstant::testFloat);
+        testOK(long[].class,    10, ClassIsConstant::testLong);
+        testOK(double[].class,  10, ClassIsConstant::testDouble);
+
+        testOK(boolean[].class, 10, NothingIsConstant::testBoolean);
+        testOK(byte[].class,    10, NothingIsConstant::testByte);
+        testOK(short[].class,   10, NothingIsConstant::testShort);
+        testOK(char[].class,    10, NothingIsConstant::testChar);
+        testOK(int[].class,     10, NothingIsConstant::testInt);
+        testOK(float[].class,   10, NothingIsConstant::testFloat);
+        testOK(long[].class,    10, NothingIsConstant::testLong);
+        testOK(double[].class,  10, NothingIsConstant::testDouble);
+    }
+
+    public static void testOK(Class<?> expectClass, int expectLen, Callable<Object> test) throws Exception {
+        for (int c = 0; c < ITERS; c++) {
+            Object res = test.call();
+            Class<?> actualClass = res.getClass();
+            if (!actualClass.equals(expectClass)) {
+                throw new IllegalStateException("Wrong class: expected = " + expectClass + ", but got " + actualClass);
+            }
+            int actualLen = Array.getLength(res);
+            if (actualLen != expectLen) {
+                throw new IllegalStateException("Wrong length: expected = " + expectLen + ", but got " + actualLen);
+            }
+        }
+    }
+
+    static volatile Object sink;
+
+    public static void testIAE(Callable<Object> test) throws Exception {
+        for (int c = 0; c < ITERS; c++) {
+            try {
+               sink = test.call();
+               throw new IllegalStateException("Expected IAE");
+            } catch (IllegalArgumentException iae) {
+               // expected
+            }
+        }
+    }
+
+    static volatile int sampleLenNeg  = -1;
+    static volatile int sampleLenZero = 0;
+    static volatile int sampleLen     = 10;
+
+
+    static volatile Class<?> classBoolean = boolean.class;
+    static volatile Class<?> classByte    = byte.class;
+    static volatile Class<?> classShort   = short.class;
+    static volatile Class<?> classChar    = char.class;
+    static volatile Class<?> classInt     = int.class;
+    static volatile Class<?> classFloat   = float.class;
+    static volatile Class<?> classLong    = long.class;
+    static volatile Class<?> classDouble  = double.class;
+    static volatile Class<?> classObject  = Object.class;
+    static volatile Class<?> classArray   = Object[].class;
+    static volatile Class<?> classNull    = null;
+
+    static class AllConstants {
+        static Object testBoolean() { return UNSAFE.allocateUninitializedArray(boolean.class,  10); }
+        static Object testByte()    { return UNSAFE.allocateUninitializedArray(byte.class,     10); }
+        static Object testShort()   { return UNSAFE.allocateUninitializedArray(short.class,    10); }
+        static Object testChar()    { return UNSAFE.allocateUninitializedArray(char.class,     10); }
+        static Object testInt()     { return UNSAFE.allocateUninitializedArray(int.class,      10); }
+        static Object testFloat()   { return UNSAFE.allocateUninitializedArray(float.class,    10); }
+        static Object testLong()    { return UNSAFE.allocateUninitializedArray(long.class,     10); }
+        static Object testDouble()  { return UNSAFE.allocateUninitializedArray(double.class,   10); }
+        static Object testObject()  { return UNSAFE.allocateUninitializedArray(Object.class,   10); }
+        static Object testArray()   { return UNSAFE.allocateUninitializedArray(Object[].class, 10); }
+        static Object testNull()    { return UNSAFE.allocateUninitializedArray(null,           10); }
+        static Object testZero()    { return UNSAFE.allocateUninitializedArray(int.class,      0);  }
+        static Object testNeg()     { return UNSAFE.allocateUninitializedArray(int.class,      -1); }
+    }
+
+    static class ClassIsConstant {
+        static Object testBoolean() { return UNSAFE.allocateUninitializedArray(boolean.class,  sampleLen); }
+        static Object testByte()    { return UNSAFE.allocateUninitializedArray(byte.class,     sampleLen); }
+        static Object testShort()   { return UNSAFE.allocateUninitializedArray(short.class,    sampleLen); }
+        static Object testChar()    { return UNSAFE.allocateUninitializedArray(char.class,     sampleLen); }
+        static Object testInt()     { return UNSAFE.allocateUninitializedArray(int.class,      sampleLen); }
+        static Object testFloat()   { return UNSAFE.allocateUninitializedArray(float.class,    sampleLen); }
+        static Object testLong()    { return UNSAFE.allocateUninitializedArray(long.class,     sampleLen); }
+        static Object testDouble()  { return UNSAFE.allocateUninitializedArray(double.class,   sampleLen); }
+        static Object testObject()  { return UNSAFE.allocateUninitializedArray(Object.class,   sampleLen); }
+        static Object testArray()   { return UNSAFE.allocateUninitializedArray(Object[].class, sampleLen); }
+        static Object testNull()    { return UNSAFE.allocateUninitializedArray(null,           sampleLen); }
+        static Object testZero()    { return UNSAFE.allocateUninitializedArray(int.class,      sampleLenZero); }
+        static Object testNeg()     { return UNSAFE.allocateUninitializedArray(int.class,      sampleLenNeg); }
+    }
+
+    static class LengthIsConstant {
+        static Object testBoolean() { return UNSAFE.allocateUninitializedArray(classBoolean, 10); }
+        static Object testByte()    { return UNSAFE.allocateUninitializedArray(classByte,    10); }
+        static Object testShort()   { return UNSAFE.allocateUninitializedArray(classShort,   10); }
+        static Object testChar()    { return UNSAFE.allocateUninitializedArray(classChar,    10); }
+        static Object testInt()     { return UNSAFE.allocateUninitializedArray(classInt,     10); }
+        static Object testFloat()   { return UNSAFE.allocateUninitializedArray(classFloat,   10); }
+        static Object testLong()    { return UNSAFE.allocateUninitializedArray(classLong,    10); }
+        static Object testDouble()  { return UNSAFE.allocateUninitializedArray(classDouble,  10); }
+        static Object testObject()  { return UNSAFE.allocateUninitializedArray(classObject,  10); }
+        static Object testArray()   { return UNSAFE.allocateUninitializedArray(classArray,   10); }
+        static Object testNull()    { return UNSAFE.allocateUninitializedArray(classNull,    10); }
+        static Object testZero()    { return UNSAFE.allocateUninitializedArray(classInt,     0);  }
+        static Object testNeg()     { return UNSAFE.allocateUninitializedArray(classInt,     -1); }
+    }
+
+    static class NothingIsConstant {
+        static Object testBoolean() { return UNSAFE.allocateUninitializedArray(classBoolean, sampleLen); }
+        static Object testByte()    { return UNSAFE.allocateUninitializedArray(classByte,    sampleLen); }
+        static Object testShort()   { return UNSAFE.allocateUninitializedArray(classShort,   sampleLen); }
+        static Object testChar()    { return UNSAFE.allocateUninitializedArray(classChar,    sampleLen); }
+        static Object testInt()     { return UNSAFE.allocateUninitializedArray(classInt,     sampleLen); }
+        static Object testFloat()   { return UNSAFE.allocateUninitializedArray(classFloat,   sampleLen); }
+        static Object testLong()    { return UNSAFE.allocateUninitializedArray(classLong,    sampleLen); }
+        static Object testDouble()  { return UNSAFE.allocateUninitializedArray(classDouble,  sampleLen); }
+        static Object testObject()  { return UNSAFE.allocateUninitializedArray(classObject,  sampleLen); }
+        static Object testArray()   { return UNSAFE.allocateUninitializedArray(classArray,   sampleLen); }
+        static Object testNull()    { return UNSAFE.allocateUninitializedArray(classNull,    sampleLen); }
+        static Object testZero()    { return UNSAFE.allocateUninitializedArray(classInt,     sampleLenZero); }
+        static Object testNeg()     { return UNSAFE.allocateUninitializedArray(classInt,     sampleLenNeg); }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/jvmci/meta/StableFieldTest.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8151664
+ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64")
+ * @library /testlibrary /test/lib /
+ * @modules java.base/jdk.internal.vm.annotation
+ *          jdk.vm.ci/jdk.vm.ci.hotspot
+ *          jdk.vm.ci/jdk.vm.ci.meta
+ *          jdk.vm.ci/jdk.vm.ci.runtime
+ * @compile StableFieldTest.java
+ * @run main ClassFileInstaller compiler.jvmci.meta.StableFieldTest
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -Xbootclasspath/a:. compiler.jvmci.meta.StableFieldTest
+ */
+
+package compiler.jvmci.meta;
+
+import java.lang.reflect.Field;
+import jdk.internal.vm.annotation.Stable;
+import jdk.vm.ci.hotspot.HotSpotResolvedJavaField;
+import jdk.vm.ci.meta.MetaAccessProvider;
+import jdk.vm.ci.meta.ResolvedJavaField;
+import jdk.vm.ci.runtime.JVMCI;
+
+public class StableFieldTest {
+
+    @Stable static int myStaticField = 5;
+    @Stable int myInstanceField = 10;
+
+    public static void main(String[] args) throws Throwable {
+        MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess();
+        for (String name : new String[] {"myStaticField", "myInstanceField"}) {
+            java.lang.reflect.Field javaField = StableFieldTest.class.getDeclaredField(name);
+            HotSpotResolvedJavaField field = (HotSpotResolvedJavaField) metaAccess.lookupJavaField(javaField);
+            if (!field.isStable()) {
+                throw new AssertionError("Expected HotSpotResolvedJavaField.isStable() to return true for " + javaField);
+            }
+        }
+    }
+}
--- a/hotspot/test/compiler/stable/StableConfiguration.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/compiler/stable/StableConfiguration.java	Mon Mar 28 08:41:54 2016 -0700
@@ -32,51 +32,10 @@
 public class StableConfiguration {
     static final WhiteBox WB = WhiteBox.getWhiteBox();
     public static final boolean isStableEnabled;
-    public static final boolean isServerWithStable;
 
     static {
         Boolean value = WB.getBooleanVMFlag("FoldStableValues");
         isStableEnabled = (value == null ? false : value);
-        isServerWithStable = isStableEnabled && get();
         System.out.println("@Stable:         " + (isStableEnabled ? "enabled" : "disabled"));
-        System.out.println("Server Compiler: " + get());
-    }
-
-    // The method 'get' below returns true if the method is server compiled
-    // and is used by the Stable tests to determine whether methods in
-    // general are being server compiled or not as the -XX:+FoldStableValues
-    // option is only applicable to -server.
-    //
-    // On aarch64 we DeOptimize when patching. This means that when the
-    // method is compiled as a result of -Xcomp it DeOptimizes immediately.
-    // The result is that getMethodCompilationLevel returns 0. This means
-    // the method returns true based on java.vm.name.
-    //
-    // However when the tests are run with -XX:+TieredCompilation and
-    // -XX:TieredStopAtLevel=1 this fails because methods will always
-    // be client compiled.
-    //
-    // Solution is to add a simple method 'get1' which should never be
-    // DeOpted and use that to determine the compilation level instead.
-    static void get1() {
-    }
-
-    // ::get() is among immediately compiled methods.
-    static boolean get() {
-        try {
-            get1();
-            Method m = StableConfiguration.class.getDeclaredMethod("get1");
-            int level = WB.getMethodCompilationLevel(m);
-            if (level > 0) {
-              return (level == 4);
-            } else {
-              String javaVM = System.getProperty("java.vm.name", "");
-              if (javaVM.contains("Server")) return true;
-              if (javaVM.contains("Client")) return false;
-              throw new Error("Unknown VM type: "+javaVM);
-            }
-        } catch (NoSuchMethodException e) {
-            throw new Error(e);
-        }
     }
 }
--- a/hotspot/test/compiler/stable/TestStableBoolean.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/compiler/stable/TestStableBoolean.java	Mon Mar 28 08:41:54 2016 -0700
@@ -60,8 +60,7 @@
 import java.lang.reflect.InvocationTargetException;
 
 public class TestStableBoolean {
-    static final boolean isStableEnabled    = StableConfiguration.isStableEnabled;
-    static final boolean isServerWithStable = StableConfiguration.isServerWithStable;
+    static final boolean isStableEnabled = StableConfiguration.isStableEnabled;
 
     public static void main(String[] args) throws Exception {
         run(DefaultValue.class);
@@ -183,14 +182,14 @@
                 c.v = new boolean[1]; c.v[0] = true;  boolean val1 = get();
                 c.v[0] = false; boolean val2 = get();
                 assertEquals(val1, true);
-                assertEquals(val2, (isServerWithStable ? true : false));
+                assertEquals(val2, (isStableEnabled ? true : false));
             }
 
             {
                 c.v = new boolean[20]; c.v[10] = true;  boolean val1 = get1();
                 c.v[10] = false; boolean val2 = get1();
                 assertEquals(val1, true);
-                assertEquals(val2, (isServerWithStable ? true : false));
+                assertEquals(val2, (isStableEnabled ? true : false));
             }
 
             {
@@ -215,19 +214,19 @@
                 c.v = new boolean[1][1]; c.v[0][0] = true;  boolean val1 = get();
                 c.v[0][0] = false; boolean val2 = get();
                 assertEquals(val1, true);
-                assertEquals(val2, (isServerWithStable ? true : false));
+                assertEquals(val2, (isStableEnabled ? true : false));
 
                 c.v = new boolean[1][1]; c.v[0][0] = false; boolean val3 = get();
-                assertEquals(val3, (isServerWithStable ? true : false));
+                assertEquals(val3, (isStableEnabled ? true : false));
 
                 c.v[0] = new boolean[1]; c.v[0][0] = false; boolean val4 = get();
-                assertEquals(val4, (isServerWithStable ? true : false));
+                assertEquals(val4, (isStableEnabled ? true : false));
             }
 
             {
                 c.v = new boolean[1][1]; boolean[] val1 = get1();
                 c.v[0] = new boolean[1]; boolean[] val2 = get1();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -253,28 +252,28 @@
                 c.v = new boolean[1][1][1]; c.v[0][0][0] = true;  boolean val1 = get();
                 c.v[0][0][0] = false; boolean val2 = get();
                 assertEquals(val1, true);
-                assertEquals(val2, (isServerWithStable ? true : false));
+                assertEquals(val2, (isStableEnabled ? true : false));
 
                 c.v = new boolean[1][1][1]; c.v[0][0][0] = false; boolean val3 = get();
-                assertEquals(val3, (isServerWithStable ? true : false));
+                assertEquals(val3, (isStableEnabled ? true : false));
 
                 c.v[0] = new boolean[1][1]; c.v[0][0][0] = false; boolean val4 = get();
-                assertEquals(val4, (isServerWithStable ? true : false));
+                assertEquals(val4, (isStableEnabled ? true : false));
 
                 c.v[0][0] = new boolean[1]; c.v[0][0][0] = false; boolean val5 = get();
-                assertEquals(val5, (isServerWithStable ? true : false));
+                assertEquals(val5, (isStableEnabled ? true : false));
             }
 
             {
                 c.v = new boolean[1][1][1]; boolean[] val1 = get1();
                 c.v[0][0] = new boolean[1]; boolean[] val2 = get1();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new boolean[1][1][1]; boolean[][] val1 = get2();
                 c.v[0] = new boolean[1][1]; boolean[][] val2 = get2();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -301,37 +300,37 @@
                 c.v = new boolean[1][1][1][1]; c.v[0][0][0][0] = true;  boolean val1 = get();
                 c.v[0][0][0][0] = false; boolean val2 = get();
                 assertEquals(val1, true);
-                assertEquals(val2, (isServerWithStable ? true : false));
+                assertEquals(val2, (isStableEnabled ? true : false));
 
                 c.v = new boolean[1][1][1][1]; c.v[0][0][0][0] = false; boolean val3 = get();
-                assertEquals(val3, (isServerWithStable ? true : false));
+                assertEquals(val3, (isStableEnabled ? true : false));
 
                 c.v[0] = new boolean[1][1][1]; c.v[0][0][0][0] = false; boolean val4 = get();
-                assertEquals(val4, (isServerWithStable ? true : false));
+                assertEquals(val4, (isStableEnabled ? true : false));
 
                 c.v[0][0] = new boolean[1][1]; c.v[0][0][0][0] = false; boolean val5 = get();
-                assertEquals(val5, (isServerWithStable ? true : false));
+                assertEquals(val5, (isStableEnabled ? true : false));
 
                 c.v[0][0][0] = new boolean[1]; c.v[0][0][0][0] = false; boolean val6 = get();
-                assertEquals(val6, (isServerWithStable ? true : false));
+                assertEquals(val6, (isStableEnabled ? true : false));
             }
 
             {
                 c.v = new boolean[1][1][1][1]; boolean[] val1 = get1();
                 c.v[0][0][0] = new boolean[1]; boolean[] val2 = get1();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new boolean[1][1][1][1]; boolean[][] val1 = get2();
                 c.v[0][0] = new boolean[1][1]; boolean[][] val2 = get2();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new boolean[1][1][1][1]; boolean[][][] val1 = get3();
                 c.v[0] = new boolean[1][1][1]; boolean[][][] val2 = get3();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -394,7 +393,7 @@
                 c.v = new boolean[1][1]; c.v[0] = new boolean[0]; boolean[] val1 = get1();
                 c.v[0] = new boolean[0]; boolean[] val2 = get1();
 
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -430,14 +429,14 @@
                 c.v = new boolean[1][1][1]; c.v[0][0] = new boolean[0]; boolean[] val1 = get1();
                 c.v[0][0] = new boolean[0]; boolean[] val2 = get1();
 
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new boolean[1][1][1]; c.v[0] = new boolean[0][0]; boolean[][] val1 = get2();
                 c.v[0] = new boolean[0][0]; boolean[][] val2 = get2();
 
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -572,7 +571,7 @@
                 elem.a = false; boolean val3 = get(); boolean val4 = get1();
 
                 assertEquals(val1, true);
-                assertEquals(val3, (isServerWithStable ? true : false));
+                assertEquals(val3, (isStableEnabled ? true : false));
 
                 assertEquals(val2, true);
                 assertEquals(val4, false);
--- a/hotspot/test/compiler/stable/TestStableByte.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/compiler/stable/TestStableByte.java	Mon Mar 28 08:41:54 2016 -0700
@@ -61,7 +61,6 @@
 
 public class TestStableByte {
     static final boolean isStableEnabled    = StableConfiguration.isStableEnabled;
-    static final boolean isServerWithStable = StableConfiguration.isServerWithStable;
 
     public static void main(String[] args) throws Exception {
         run(DefaultValue.class);
@@ -182,10 +181,10 @@
                 c.v = new byte[1]; c.v[0] = 1; byte val1 = get();
                 c.v[0] = 2; byte val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isServerWithStable ? 1 : 2));
+                assertEquals(val2, (isStableEnabled ? 1 : 2));
 
                 c.v = new byte[1]; c.v[0] = 3; byte val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 3));
             }
 
@@ -193,10 +192,10 @@
                 c.v = new byte[20]; c.v[10] = 1; byte val1 = get1();
                 c.v[10] = 2; byte val2 = get1();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isServerWithStable ? 1 : 2));
+                assertEquals(val2, (isStableEnabled ? 1 : 2));
 
                 c.v = new byte[20]; c.v[10] = 3; byte val3 = get1();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 3));
             }
 
@@ -222,21 +221,21 @@
                 c.v = new byte[1][1]; c.v[0][0] = 1; byte val1 = get();
                 c.v[0][0] = 2; byte val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isServerWithStable ? 1 : 2));
+                assertEquals(val2, (isStableEnabled ? 1 : 2));
 
                 c.v = new byte[1][1]; c.v[0][0] = 3; byte val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 3));
 
                 c.v[0] = new byte[1]; c.v[0][0] = 4; byte val4 = get();
-                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val4, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 4));
             }
 
             {
                 c.v = new byte[1][1]; byte[] val1 = get1();
                 c.v[0] = new byte[1]; byte[] val2 = get1();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -262,31 +261,31 @@
                 c.v = new byte[1][1][1]; c.v[0][0][0] = 1; byte val1 = get();
                 c.v[0][0][0] = 2; byte val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isServerWithStable ? 1 : 2));
+                assertEquals(val2, (isStableEnabled ? 1 : 2));
 
                 c.v = new byte[1][1][1]; c.v[0][0][0] = 3; byte val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 3));
 
                 c.v[0] = new byte[1][1]; c.v[0][0][0] = 4; byte val4 = get();
-                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val4, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 4));
 
                 c.v[0][0] = new byte[1]; c.v[0][0][0] = 5; byte val5 = get();
-                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val5, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 5));
             }
 
             {
                 c.v = new byte[1][1][1]; byte[] val1 = get1();
                 c.v[0][0] = new byte[1]; byte[] val2 = get1();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new byte[1][1][1]; byte[][] val1 = get2();
                 c.v[0] = new byte[1][1]; byte[][] val2 = get2();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -313,41 +312,41 @@
                 c.v = new byte[1][1][1][1]; c.v[0][0][0][0] = 1; byte val1 = get();
                 c.v[0][0][0][0] = 2; byte val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isServerWithStable ? 1 : 2));
+                assertEquals(val2, (isStableEnabled ? 1 : 2));
 
                 c.v = new byte[1][1][1][1]; c.v[0][0][0][0] = 3; byte val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 3));
 
                 c.v[0] = new byte[1][1][1]; c.v[0][0][0][0] = 4; byte val4 = get();
-                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val4, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 4));
 
                 c.v[0][0] = new byte[1][1]; c.v[0][0][0][0] = 5; byte val5 = get();
-                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val5, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 5));
 
                 c.v[0][0][0] = new byte[1]; c.v[0][0][0][0] = 6; byte val6 = get();
-                assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val6, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 6));
             }
 
             {
                 c.v = new byte[1][1][1][1]; byte[] val1 = get1();
                 c.v[0][0][0] = new byte[1]; byte[] val2 = get1();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new byte[1][1][1][1]; byte[][] val1 = get2();
                 c.v[0][0] = new byte[1][1]; byte[][] val2 = get2();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new byte[1][1][1][1]; byte[][][] val1 = get3();
                 c.v[0] = new byte[1][1][1]; byte[][][] val2 = get3();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -409,7 +408,7 @@
                 c.v = new byte[1][1]; c.v[0] = new byte[0]; byte[] val1 = get1();
                 c.v[0] = new byte[0]; byte[] val2 = get1();
 
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -445,14 +444,14 @@
                 c.v = new byte[1][1][1]; c.v[0][0] = new byte[0]; byte[] val1 = get1();
                 c.v[0][0] = new byte[0]; byte[] val2 = get1();
 
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new byte[1][1][1]; c.v[0] = new byte[0][0]; byte[][] val1 = get2();
                 c.v[0] = new byte[0][0]; byte[][] val2 = get2();
 
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -587,7 +586,7 @@
                 elem.a = 2; byte val3 = get(); byte val4 = get1();
 
                 assertEquals(val1, 1);
-                assertEquals(val3, (isServerWithStable ? 1 : 2));
+                assertEquals(val3, (isStableEnabled ? 1 : 2));
 
                 assertEquals(val2, 1);
                 assertEquals(val4, 2);
--- a/hotspot/test/compiler/stable/TestStableChar.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/compiler/stable/TestStableChar.java	Mon Mar 28 08:41:54 2016 -0700
@@ -61,7 +61,6 @@
 
 public class TestStableChar {
     static final boolean isStableEnabled    = StableConfiguration.isStableEnabled;
-    static final boolean isServerWithStable = StableConfiguration.isServerWithStable;
 
     public static void main(String[] args) throws Exception {
         run(DefaultValue.class);
@@ -182,10 +181,10 @@
                 c.v = new char[1]; c.v[0] = 'a'; char val1 = get();
                 c.v[0] = 'b'; char val2 = get();
                 assertEquals(val1, 'a');
-                assertEquals(val2, (isServerWithStable ? 'a' : 'b'));
+                assertEquals(val2, (isStableEnabled ? 'a' : 'b'));
 
                 c.v = new char[1]; c.v[0] = 'c'; char val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 'a' : 'b')
                         : 'c'));
             }
 
@@ -193,10 +192,10 @@
                 c.v = new char[20]; c.v[10] = 'a'; char val1 = get1();
                 c.v[10] = 'b'; char val2 = get1();
                 assertEquals(val1, 'a');
-                assertEquals(val2, (isServerWithStable ? 'a' : 'b'));
+                assertEquals(val2, (isStableEnabled ? 'a' : 'b'));
 
                 c.v = new char[20]; c.v[10] = 'c'; char val3 = get1();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 'a' : 'b')
                         : 'c'));
             }
 
@@ -222,21 +221,21 @@
                 c.v = new char[1][1]; c.v[0][0] = 'a'; char val1 = get();
                 c.v[0][0] = 'b'; char val2 = get();
                 assertEquals(val1, 'a');
-                assertEquals(val2, (isServerWithStable ? 'a' : 'b'));
+                assertEquals(val2, (isStableEnabled ? 'a' : 'b'));
 
                 c.v = new char[1][1]; c.v[0][0] = 'c'; char val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 'a' : 'b')
                         : 'c'));
 
                 c.v[0] = new char[1]; c.v[0][0] = 'd'; char val4 = get();
-                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+                assertEquals(val4, (isStableEnabled ? (isStableEnabled ? 'a' : 'b')
                         : 'd'));
             }
 
             {
                 c.v = new char[1][1]; char[] val1 = get1();
                 c.v[0] = new char[1]; char[] val2 = get1();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -262,31 +261,31 @@
                 c.v = new char[1][1][1]; c.v[0][0][0] = 'a'; char val1 = get();
                 c.v[0][0][0] = 'b'; char val2 = get();
                 assertEquals(val1, 'a');
-                assertEquals(val2, (isServerWithStable ? 'a' : 'b'));
+                assertEquals(val2, (isStableEnabled ? 'a' : 'b'));
 
                 c.v = new char[1][1][1]; c.v[0][0][0] = 'c'; char val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 'a' : 'b')
                         : 'c'));
 
                 c.v[0] = new char[1][1]; c.v[0][0][0] = 'd'; char val4 = get();
-                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+                assertEquals(val4, (isStableEnabled ? (isStableEnabled ? 'a' : 'b')
                         : 'd'));
 
                 c.v[0][0] = new char[1]; c.v[0][0][0] = 'e'; char val5 = get();
-                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+                assertEquals(val5, (isStableEnabled ? (isStableEnabled ? 'a' : 'b')
                         : 'e'));
             }
 
             {
                 c.v = new char[1][1][1]; char[] val1 = get1();
                 c.v[0][0] = new char[1]; char[] val2 = get1();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new char[1][1][1]; char[][] val1 = get2();
                 c.v[0] = new char[1][1]; char[][] val2 = get2();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -313,41 +312,41 @@
                 c.v = new char[1][1][1][1]; c.v[0][0][0][0] = 'a'; char val1 = get();
                 c.v[0][0][0][0] = 'b'; char val2 = get();
                 assertEquals(val1, 'a');
-                assertEquals(val2, (isServerWithStable ? 'a' : 'b'));
+                assertEquals(val2, (isStableEnabled ? 'a' : 'b'));
 
                 c.v = new char[1][1][1][1]; c.v[0][0][0][0] = 'c'; char val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 'a' : 'b')
                         : 'c'));
 
                 c.v[0] = new char[1][1][1]; c.v[0][0][0][0] = 'd'; char val4 = get();
-                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+                assertEquals(val4, (isStableEnabled ? (isStableEnabled ? 'a' : 'b')
                         : 'd'));
 
                 c.v[0][0] = new char[1][1]; c.v[0][0][0][0] = 'e'; char val5 = get();
-                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+                assertEquals(val5, (isStableEnabled ? (isStableEnabled ? 'a' : 'b')
                         : 'e'));
 
                 c.v[0][0][0] = new char[1]; c.v[0][0][0][0] = 'f'; char val6 = get();
-                assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 'a' : 'b')
+                assertEquals(val6, (isStableEnabled ? (isStableEnabled ? 'a' : 'b')
                         : 'f'));
             }
 
             {
                 c.v = new char[1][1][1][1]; char[] val1 = get1();
                 c.v[0][0][0] = new char[1]; char[] val2 = get1();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new char[1][1][1][1]; char[][] val1 = get2();
                 c.v[0][0] = new char[1][1]; char[][] val2 = get2();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new char[1][1][1][1]; char[][][] val1 = get3();
                 c.v[0] = new char[1][1][1]; char[][][] val2 = get3();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -407,7 +406,7 @@
                 c.v = new char[1][1]; c.v[0] = new char[0]; char[] val1 = get1();
                 c.v[0] = new char[0]; char[] val2 = get1();
 
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -443,14 +442,14 @@
                 c.v = new char[1][1][1]; c.v[0][0] = new char[0]; char[] val1 = get1();
                 c.v[0][0] = new char[0]; char[] val2 = get1();
 
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new char[1][1][1]; c.v[0] = new char[0][0]; char[][] val1 = get2();
                 c.v[0] = new char[0][0]; char[][] val2 = get2();
 
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -585,7 +584,7 @@
                 elem.a = 'b'; char val3 = get(); char val4 = get1();
 
                 assertEquals(val1, 'a');
-                assertEquals(val3, (isServerWithStable ? 'a' : 'b'));
+                assertEquals(val3, (isStableEnabled ? 'a' : 'b'));
 
                 assertEquals(val2, 'a');
                 assertEquals(val4, 'b');
--- a/hotspot/test/compiler/stable/TestStableDouble.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/compiler/stable/TestStableDouble.java	Mon Mar 28 08:41:54 2016 -0700
@@ -61,7 +61,6 @@
 
 public class TestStableDouble {
     static final boolean isStableEnabled    = StableConfiguration.isStableEnabled;
-    static final boolean isServerWithStable = StableConfiguration.isServerWithStable;
 
     public static void main(String[] args) throws Exception {
         run(DefaultValue.class);
@@ -182,10 +181,10 @@
                 c.v = new double[1]; c.v[0] = 1.0; double val1 = get();
                 c.v[0] = 2.0; double val2 = get();
                 assertEquals(val1, 1.0);
-                assertEquals(val2, (isServerWithStable ? 1.0 : 2.0));
+                assertEquals(val2, (isStableEnabled ? 1.0 : 2.0));
 
                 c.v = new double[1]; c.v[0] = 3.0; double val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0)
                         : 3.0));
             }
 
@@ -193,10 +192,10 @@
                 c.v = new double[20]; c.v[10] = 1.0; double val1 = get1();
                 c.v[10] = 2.0; double val2 = get1();
                 assertEquals(val1, 1.0);
-                assertEquals(val2, (isServerWithStable ? 1.0 : 2.0));
+                assertEquals(val2, (isStableEnabled ? 1.0 : 2.0));
 
                 c.v = new double[20]; c.v[10] = 3.0; double val3 = get1();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0)
                         : 3.0));
             }
 
@@ -222,21 +221,21 @@
                 c.v = new double[1][1]; c.v[0][0] = 1.0; double val1 = get();
                 c.v[0][0] = 2.0; double val2 = get();
                 assertEquals(val1, 1.0);
-                assertEquals(val2, (isServerWithStable ? 1.0 : 2.0));
+                assertEquals(val2, (isStableEnabled ? 1.0 : 2.0));
 
                 c.v = new double[1][1]; c.v[0][0] = 3.0; double val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0)
                         : 3.0));
 
                 c.v[0] = new double[1]; c.v[0][0] = 4.0; double val4 = get();
-                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+                assertEquals(val4, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0)
                         : 4.0));
             }
 
             {
                 c.v = new double[1][1]; double[] val1 = get1();
                 c.v[0] = new double[1]; double[] val2 = get1();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -262,31 +261,31 @@
                 c.v = new double[1][1][1]; c.v[0][0][0] = 1.0; double val1 = get();
                 c.v[0][0][0] = 2.0; double val2 = get();
                 assertEquals(val1, 1.0);
-                assertEquals(val2, (isServerWithStable ? 1.0 : 2.0));
+                assertEquals(val2, (isStableEnabled ? 1.0 : 2.0));
 
                 c.v = new double[1][1][1]; c.v[0][0][0] = 3.0; double val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0)
                         : 3.0));
 
                 c.v[0] = new double[1][1]; c.v[0][0][0] = 4.0; double val4 = get();
-                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+                assertEquals(val4, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0)
                         : 4.0));
 
                 c.v[0][0] = new double[1]; c.v[0][0][0] = 5.0; double val5 = get();
-                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+                assertEquals(val5, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0)
                         : 5.0));
             }
 
             {
                 c.v = new double[1][1][1]; double[] val1 = get1();
                 c.v[0][0] = new double[1]; double[] val2 = get1();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new double[1][1][1]; double[][] val1 = get2();
                 c.v[0] = new double[1][1]; double[][] val2 = get2();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -313,41 +312,41 @@
                 c.v = new double[1][1][1][1]; c.v[0][0][0][0] = 1.0; double val1 = get();
                 c.v[0][0][0][0] = 2.0; double val2 = get();
                 assertEquals(val1, 1.0);
-                assertEquals(val2, (isServerWithStable ? 1.0 : 2.0));
+                assertEquals(val2, (isStableEnabled ? 1.0 : 2.0));
 
                 c.v = new double[1][1][1][1]; c.v[0][0][0][0] = 3.0; double val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0)
                         : 3.0));
 
                 c.v[0] = new double[1][1][1]; c.v[0][0][0][0] = 4.0; double val4 = get();
-                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+                assertEquals(val4, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0)
                         : 4.0));
 
                 c.v[0][0] = new double[1][1]; c.v[0][0][0][0] = 5.0; double val5 = get();
-                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+                assertEquals(val5, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0)
                         : 5.0));
 
                 c.v[0][0][0] = new double[1]; c.v[0][0][0][0] = 6.0; double val6 = get();
-                assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
+                assertEquals(val6, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0)
                         : 6.0));
             }
 
             {
                 c.v = new double[1][1][1][1]; double[] val1 = get1();
                 c.v[0][0][0] = new double[1]; double[] val2 = get1();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new double[1][1][1][1]; double[][] val1 = get2();
                 c.v[0][0] = new double[1][1]; double[][] val2 = get2();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new double[1][1][1][1]; double[][][] val1 = get3();
                 c.v[0] = new double[1][1][1]; double[][][] val2 = get3();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -407,7 +406,7 @@
                 c.v = new double[1][1]; c.v[0] = new double[0]; double[] val1 = get1();
                 c.v[0] = new double[0]; double[] val2 = get1();
 
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -443,14 +442,14 @@
                 c.v = new double[1][1][1]; c.v[0][0] = new double[0]; double[] val1 = get1();
                 c.v[0][0] = new double[0]; double[] val2 = get1();
 
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new double[1][1][1]; c.v[0] = new double[0][0]; double[][] val1 = get2();
                 c.v[0] = new double[0][0]; double[][] val2 = get2();
 
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -585,7 +584,7 @@
                 elem.a = 2.0; double val3 = get(); double val4 = get1();
 
                 assertEquals(val1, 1.0);
-                assertEquals(val3, (isServerWithStable ? 1.0 : 2.0));
+                assertEquals(val3, (isStableEnabled ? 1.0 : 2.0));
 
                 assertEquals(val2, 1.0);
                 assertEquals(val4, 2.0);
--- a/hotspot/test/compiler/stable/TestStableFloat.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/compiler/stable/TestStableFloat.java	Mon Mar 28 08:41:54 2016 -0700
@@ -61,7 +61,6 @@
 
 public class TestStableFloat {
     static final boolean isStableEnabled    = StableConfiguration.isStableEnabled;
-    static final boolean isServerWithStable = StableConfiguration.isServerWithStable;
 
     public static void main(String[] args) throws Exception {
         run(DefaultValue.class);
@@ -182,10 +181,10 @@
                 c.v = new float[1]; c.v[0] = 1.0F; float val1 = get();
                 c.v[0] = 2.0F; float val2 = get();
                 assertEquals(val1, 1.0F);
-                assertEquals(val2, (isServerWithStable ? 1.0F : 2.0F));
+                assertEquals(val2, (isStableEnabled ? 1.0F : 2.0F));
 
                 c.v = new float[1]; c.v[0] = 3.0F; float val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1.0F : 2.0F)
                         : 3.0F));
             }
 
@@ -193,10 +192,10 @@
                 c.v = new float[20]; c.v[10] = 1.0F; float val1 = get1();
                 c.v[10] = 2.0F; float val2 = get1();
                 assertEquals(val1, 1.0F);
-                assertEquals(val2, (isServerWithStable ? 1.0F : 2.0F));
+                assertEquals(val2, (isStableEnabled ? 1.0F : 2.0F));
 
                 c.v = new float[20]; c.v[10] = 3.0F; float val3 = get1();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1.0F : 2.0F)
                         : 3.0F));
             }
 
@@ -222,21 +221,21 @@
                 c.v = new float[1][1]; c.v[0][0] = 1.0F; float val1 = get();
                 c.v[0][0] = 2.0F; float val2 = get();
                 assertEquals(val1, 1.0F);
-                assertEquals(val2, (isServerWithStable ? 1.0F : 2.0F));
+                assertEquals(val2, (isStableEnabled ? 1.0F : 2.0F));
 
                 c.v = new float[1][1]; c.v[0][0] = 3.0F; float val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1.0F : 2.0F)
                         : 3.0F));
 
                 c.v[0] = new float[1]; c.v[0][0] = 4.0F; float val4 = get();
-                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+                assertEquals(val4, (isStableEnabled ? (isStableEnabled ? 1.0F : 2.0F)
                         : 4.0F));
             }
 
             {
                 c.v = new float[1][1]; float[] val1 = get1();
                 c.v[0] = new float[1]; float[] val2 = get1();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -262,31 +261,31 @@
                 c.v = new float[1][1][1]; c.v[0][0][0] = 1.0F; float val1 = get();
                 c.v[0][0][0] = 2.0F; float val2 = get();
                 assertEquals(val1, 1.0F);
-                assertEquals(val2, (isServerWithStable ? 1.0F : 2.0F));
+                assertEquals(val2, (isStableEnabled ? 1.0F : 2.0F));
 
                 c.v = new float[1][1][1]; c.v[0][0][0] = 3.0F; float val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1.0F : 2.0F)
                         : 3.0F));
 
                 c.v[0] = new float[1][1]; c.v[0][0][0] = 4.0F; float val4 = get();
-                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+                assertEquals(val4, (isStableEnabled ? (isStableEnabled ? 1.0F : 2.0F)
                         : 4.0F));
 
                 c.v[0][0] = new float[1]; c.v[0][0][0] = 5.0F; float val5 = get();
-                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+                assertEquals(val5, (isStableEnabled ? (isStableEnabled ? 1.0F : 2.0F)
                         : 5.0F));
             }
 
             {
                 c.v = new float[1][1][1]; float[] val1 = get1();
                 c.v[0][0] = new float[1]; float[] val2 = get1();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new float[1][1][1]; float[][] val1 = get2();
                 c.v[0] = new float[1][1]; float[][] val2 = get2();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -313,41 +312,41 @@
                 c.v = new float[1][1][1][1]; c.v[0][0][0][0] = 1.0F; float val1 = get();
                 c.v[0][0][0][0] = 2.0F; float val2 = get();
                 assertEquals(val1, 1.0F);
-                assertEquals(val2, (isServerWithStable ? 1.0F : 2.0F));
+                assertEquals(val2, (isStableEnabled ? 1.0F : 2.0F));
 
                 c.v = new float[1][1][1][1]; c.v[0][0][0][0] = 3.0F; float val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1.0F : 2.0F)
                         : 3.0F));
 
                 c.v[0] = new float[1][1][1]; c.v[0][0][0][0] = 4.0F; float val4 = get();
-                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+                assertEquals(val4, (isStableEnabled ? (isStableEnabled ? 1.0F : 2.0F)
                         : 4.0F));
 
                 c.v[0][0] = new float[1][1]; c.v[0][0][0][0] = 5.0F; float val5 = get();
-                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+                assertEquals(val5, (isStableEnabled ? (isStableEnabled ? 1.0F : 2.0F)
                         : 5.0F));
 
                 c.v[0][0][0] = new float[1]; c.v[0][0][0][0] = 6.0F; float val6 = get();
-                assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1.0F : 2.0F)
+                assertEquals(val6, (isStableEnabled ? (isStableEnabled ? 1.0F : 2.0F)
                         : 6.0F));
             }
 
             {
                 c.v = new float[1][1][1][1]; float[] val1 = get1();
                 c.v[0][0][0] = new float[1]; float[] val2 = get1();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new float[1][1][1][1]; float[][] val1 = get2();
                 c.v[0][0] = new float[1][1]; float[][] val2 = get2();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new float[1][1][1][1]; float[][][] val1 = get3();
                 c.v[0] = new float[1][1][1]; float[][][] val2 = get3();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -407,7 +406,7 @@
                 c.v = new float[1][1]; c.v[0] = new float[0]; float[] val1 = get1();
                 c.v[0] = new float[0]; float[] val2 = get1();
 
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -443,14 +442,14 @@
                 c.v = new float[1][1][1]; c.v[0][0] = new float[0]; float[] val1 = get1();
                 c.v[0][0] = new float[0]; float[] val2 = get1();
 
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new float[1][1][1]; c.v[0] = new float[0][0]; float[][] val1 = get2();
                 c.v[0] = new float[0][0]; float[][] val2 = get2();
 
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -585,7 +584,7 @@
                 elem.a = 2.0F; float val3 = get(); float val4 = get1();
 
                 assertEquals(val1, 1.0F);
-                assertEquals(val3, (isServerWithStable ? 1.0F : 2.0F));
+                assertEquals(val3, (isStableEnabled ? 1.0F : 2.0F));
 
                 assertEquals(val2, 1.0F);
                 assertEquals(val4, 2.0F);
--- a/hotspot/test/compiler/stable/TestStableInt.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/compiler/stable/TestStableInt.java	Mon Mar 28 08:41:54 2016 -0700
@@ -61,7 +61,6 @@
 
 public class TestStableInt {
     static final boolean isStableEnabled    = StableConfiguration.isStableEnabled;
-    static final boolean isServerWithStable = StableConfiguration.isServerWithStable;
 
     public static void main(String[] args) throws Exception {
         run(DefaultValue.class);
@@ -182,10 +181,10 @@
                 c.v = new int[1]; c.v[0] = 1; int val1 = get();
                 c.v[0] = 2; int val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isServerWithStable ? 1 : 2));
+                assertEquals(val2, (isStableEnabled ? 1 : 2));
 
                 c.v = new int[1]; c.v[0] = 3; int val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 3));
             }
 
@@ -193,10 +192,10 @@
                 c.v = new int[20]; c.v[10] = 1; int val1 = get1();
                 c.v[10] = 2; int val2 = get1();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isServerWithStable ? 1 : 2));
+                assertEquals(val2, (isStableEnabled ? 1 : 2));
 
                 c.v = new int[20]; c.v[10] = 3; int val3 = get1();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 3));
             }
 
@@ -222,21 +221,21 @@
                 c.v = new int[1][1]; c.v[0][0] = 1; int val1 = get();
                 c.v[0][0] = 2; int val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isServerWithStable ? 1 : 2));
+                assertEquals(val2, (isStableEnabled ? 1 : 2));
 
                 c.v = new int[1][1]; c.v[0][0] = 3; int val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 3));
 
                 c.v[0] = new int[1]; c.v[0][0] = 4; int val4 = get();
-                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val4, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 4));
             }
 
             {
                 c.v = new int[1][1]; int[] val1 = get1();
                 c.v[0] = new int[1]; int[] val2 = get1();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -262,31 +261,31 @@
                 c.v = new int[1][1][1]; c.v[0][0][0] = 1; int val1 = get();
                 c.v[0][0][0] = 2; int val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isServerWithStable ? 1 : 2));
+                assertEquals(val2, (isStableEnabled ? 1 : 2));
 
                 c.v = new int[1][1][1]; c.v[0][0][0] = 3; int val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 3));
 
                 c.v[0] = new int[1][1]; c.v[0][0][0] = 4; int val4 = get();
-                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val4, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 4));
 
                 c.v[0][0] = new int[1]; c.v[0][0][0] = 5; int val5 = get();
-                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val5, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 5));
             }
 
             {
                 c.v = new int[1][1][1]; int[] val1 = get1();
                 c.v[0][0] = new int[1]; int[] val2 = get1();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new int[1][1][1]; int[][] val1 = get2();
                 c.v[0] = new int[1][1]; int[][] val2 = get2();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -313,41 +312,41 @@
                 c.v = new int[1][1][1][1]; c.v[0][0][0][0] = 1; int val1 = get();
                 c.v[0][0][0][0] = 2; int val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isServerWithStable ? 1 : 2));
+                assertEquals(val2, (isStableEnabled ? 1 : 2));
 
                 c.v = new int[1][1][1][1]; c.v[0][0][0][0] = 3; int val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 3));
 
                 c.v[0] = new int[1][1][1]; c.v[0][0][0][0] = 4; int val4 = get();
-                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val4, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 4));
 
                 c.v[0][0] = new int[1][1]; c.v[0][0][0][0] = 5; int val5 = get();
-                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val5, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 5));
 
                 c.v[0][0][0] = new int[1]; c.v[0][0][0][0] = 6; int val6 = get();
-                assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val6, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 6));
             }
 
             {
                 c.v = new int[1][1][1][1]; int[] val1 = get1();
                 c.v[0][0][0] = new int[1]; int[] val2 = get1();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new int[1][1][1][1]; int[][] val1 = get2();
                 c.v[0][0] = new int[1][1]; int[][] val2 = get2();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new int[1][1][1][1]; int[][][] val1 = get3();
                 c.v[0] = new int[1][1][1]; int[][][] val2 = get3();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -407,7 +406,7 @@
                 c.v = new int[1][1]; c.v[0] = new int[0]; int[] val1 = get1();
                 c.v[0] = new int[0]; int[] val2 = get1();
 
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -443,14 +442,14 @@
                 c.v = new int[1][1][1]; c.v[0][0] = new int[0]; int[] val1 = get1();
                 c.v[0][0] = new int[0]; int[] val2 = get1();
 
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new int[1][1][1]; c.v[0] = new int[0][0]; int[][] val1 = get2();
                 c.v[0] = new int[0][0]; int[][] val2 = get2();
 
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -585,7 +584,7 @@
                 elem.a = 2; int val3 = get(); int val4 = get1();
 
                 assertEquals(val1, 1);
-                assertEquals(val3, (isServerWithStable ? 1 : 2));
+                assertEquals(val3, (isStableEnabled ? 1 : 2));
 
                 assertEquals(val2, 1);
                 assertEquals(val4, 2);
--- a/hotspot/test/compiler/stable/TestStableLong.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/compiler/stable/TestStableLong.java	Mon Mar 28 08:41:54 2016 -0700
@@ -61,7 +61,6 @@
 
 public class TestStableLong {
     static final boolean isStableEnabled    = StableConfiguration.isStableEnabled;
-    static final boolean isServerWithStable = StableConfiguration.isServerWithStable;
 
     public static void main(String[] args) throws Exception {
         run(DefaultValue.class);
@@ -182,10 +181,10 @@
                 c.v = new long[1]; c.v[0] = 1; long val1 = get();
                 c.v[0] = 2; long val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isServerWithStable ? 1 : 2));
+                assertEquals(val2, (isStableEnabled ? 1 : 2));
 
                 c.v = new long[1]; c.v[0] = 3; long val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 3));
             }
 
@@ -193,10 +192,10 @@
                 c.v = new long[20]; c.v[10] = 1; long val1 = get1();
                 c.v[10] = 2; long val2 = get1();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isServerWithStable ? 1 : 2));
+                assertEquals(val2, (isStableEnabled ? 1 : 2));
 
                 c.v = new long[20]; c.v[10] = 3; long val3 = get1();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 3));
             }
 
@@ -222,21 +221,21 @@
                 c.v = new long[1][1]; c.v[0][0] = 1; long val1 = get();
                 c.v[0][0] = 2; long val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isServerWithStable ? 1 : 2));
+                assertEquals(val2, (isStableEnabled ? 1 : 2));
 
                 c.v = new long[1][1]; c.v[0][0] = 3; long val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 3));
 
                 c.v[0] = new long[1]; c.v[0][0] = 4; long val4 = get();
-                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val4, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 4));
             }
 
             {
                 c.v = new long[1][1]; long[] val1 = get1();
                 c.v[0] = new long[1]; long[] val2 = get1();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -262,31 +261,31 @@
                 c.v = new long[1][1][1]; c.v[0][0][0] = 1; long val1 = get();
                 c.v[0][0][0] = 2; long val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isServerWithStable ? 1 : 2));
+                assertEquals(val2, (isStableEnabled ? 1 : 2));
 
                 c.v = new long[1][1][1]; c.v[0][0][0] = 3; long val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 3));
 
                 c.v[0] = new long[1][1]; c.v[0][0][0] = 4; long val4 = get();
-                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val4, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 4));
 
                 c.v[0][0] = new long[1]; c.v[0][0][0] = 5; long val5 = get();
-                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val5, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 5));
             }
 
             {
                 c.v = new long[1][1][1]; long[] val1 = get1();
                 c.v[0][0] = new long[1]; long[] val2 = get1();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new long[1][1][1]; long[][] val1 = get2();
                 c.v[0] = new long[1][1]; long[][] val2 = get2();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -313,41 +312,41 @@
                 c.v = new long[1][1][1][1]; c.v[0][0][0][0] = 1; long val1 = get();
                 c.v[0][0][0][0] = 2; long val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isServerWithStable ? 1 : 2));
+                assertEquals(val2, (isStableEnabled ? 1 : 2));
 
                 c.v = new long[1][1][1][1]; c.v[0][0][0][0] = 3; long val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 3));
 
                 c.v[0] = new long[1][1][1]; c.v[0][0][0][0] = 4; long val4 = get();
-                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val4, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 4));
 
                 c.v[0][0] = new long[1][1]; c.v[0][0][0][0] = 5; long val5 = get();
-                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val5, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 5));
 
                 c.v[0][0][0] = new long[1]; c.v[0][0][0][0] = 6; long val6 = get();
-                assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val6, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 6));
             }
 
             {
                 c.v = new long[1][1][1][1]; long[] val1 = get1();
                 c.v[0][0][0] = new long[1]; long[] val2 = get1();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new long[1][1][1][1]; long[][] val1 = get2();
                 c.v[0][0] = new long[1][1]; long[][] val2 = get2();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new long[1][1][1][1]; long[][][] val1 = get3();
                 c.v[0] = new long[1][1][1]; long[][][] val2 = get3();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -407,7 +406,7 @@
                 c.v = new long[1][1]; c.v[0] = new long[0]; long[] val1 = get1();
                 c.v[0] = new long[0]; long[] val2 = get1();
 
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -443,14 +442,14 @@
                 c.v = new long[1][1][1]; c.v[0][0] = new long[0]; long[] val1 = get1();
                 c.v[0][0] = new long[0]; long[] val2 = get1();
 
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new long[1][1][1]; c.v[0] = new long[0][0]; long[][] val1 = get2();
                 c.v[0] = new long[0][0]; long[][] val2 = get2();
 
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -585,7 +584,7 @@
                 elem.a = 2; long val3 = get(); long val4 = get1();
 
                 assertEquals(val1, 1);
-                assertEquals(val3, (isServerWithStable ? 1 : 2));
+                assertEquals(val3, (isStableEnabled ? 1 : 2));
 
                 assertEquals(val2, 1);
                 assertEquals(val4, 2);
--- a/hotspot/test/compiler/stable/TestStableObject.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/compiler/stable/TestStableObject.java	Mon Mar 28 08:41:54 2016 -0700
@@ -61,7 +61,6 @@
 
 public class TestStableObject {
     static final boolean isStableEnabled    = StableConfiguration.isStableEnabled;
-    static final boolean isServerWithStable = StableConfiguration.isServerWithStable;
 
     public static void main(String[] args) throws Exception {
         run(DefaultValue.class);
@@ -184,10 +183,10 @@
                 c.v = new Object[1]; c.v[0] = Values.A; Object val1 = get();
                 c.v[0] = Values.B; Object val2 = get();
                 assertEquals(val1, Values.A);
-                assertEquals(val2, (isServerWithStable ? Values.A : Values.B));
+                assertEquals(val2, (isStableEnabled ? Values.A : Values.B));
 
                 c.v = new Object[1]; c.v[0] = Values.C; Object val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? Values.A : Values.B)
                         : Values.C));
             }
 
@@ -195,10 +194,10 @@
                 c.v = new Object[20]; c.v[10] = Values.A; Object val1 = get1();
                 c.v[10] = Values.B; Object val2 = get1();
                 assertEquals(val1, Values.A);
-                assertEquals(val2, (isServerWithStable ? Values.A : Values.B));
+                assertEquals(val2, (isStableEnabled ? Values.A : Values.B));
 
                 c.v = new Object[20]; c.v[10] = Values.C; Object val3 = get1();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? Values.A : Values.B)
                         : Values.C));
             }
 
@@ -224,21 +223,21 @@
                 c.v = new Object[1][1]; c.v[0][0] = Values.A; Object val1 = get();
                 c.v[0][0] = Values.B; Object val2 = get();
                 assertEquals(val1, Values.A);
-                assertEquals(val2, (isServerWithStable ? Values.A : Values.B));
+                assertEquals(val2, (isStableEnabled ? Values.A : Values.B));
 
                 c.v = new Object[1][1]; c.v[0][0] = Values.C; Object val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? Values.A : Values.B)
                         : Values.C));
 
                 c.v[0] = new Object[1]; c.v[0][0] = Values.D; Object val4 = get();
-                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+                assertEquals(val4, (isStableEnabled ? (isStableEnabled ? Values.A : Values.B)
                         : Values.D));
             }
 
             {
                 c.v = new Object[1][1]; Object[] val1 = get1();
                 c.v[0] = new Object[1]; Object[] val2 = get1();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -264,31 +263,31 @@
                 c.v = new Object[1][1][1]; c.v[0][0][0] = Values.A; Object val1 = get();
                 c.v[0][0][0] = Values.B; Object val2 = get();
                 assertEquals(val1, Values.A);
-                assertEquals(val2, (isServerWithStable ? Values.A : Values.B));
+                assertEquals(val2, (isStableEnabled ? Values.A : Values.B));
 
                 c.v = new Object[1][1][1]; c.v[0][0][0] = Values.C; Object val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? Values.A : Values.B)
                         : Values.C));
 
                 c.v[0] = new Object[1][1]; c.v[0][0][0] = Values.D; Object val4 = get();
-                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+                assertEquals(val4, (isStableEnabled ? (isStableEnabled ? Values.A : Values.B)
                         : Values.D));
 
                 c.v[0][0] = new Object[1]; c.v[0][0][0] = Values.E; Object val5 = get();
-                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+                assertEquals(val5, (isStableEnabled ? (isStableEnabled ? Values.A : Values.B)
                         : Values.E));
             }
 
             {
                 c.v = new Object[1][1][1]; Object[] val1 = get1();
                 c.v[0][0] = new Object[1]; Object[] val2 = get1();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new Object[1][1][1]; Object[][] val1 = get2();
                 c.v[0] = new Object[1][1]; Object[][] val2 = get2();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -315,41 +314,41 @@
                 c.v = new Object[1][1][1][1]; c.v[0][0][0][0] = Values.A; Object val1 = get();
                 c.v[0][0][0][0] = Values.B; Object val2 = get();
                 assertEquals(val1, Values.A);
-                assertEquals(val2, (isServerWithStable ? Values.A : Values.B));
+                assertEquals(val2, (isStableEnabled ? Values.A : Values.B));
 
                 c.v = new Object[1][1][1][1]; c.v[0][0][0][0] = Values.C; Object val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? Values.A : Values.B)
                         : Values.C));
 
                 c.v[0] = new Object[1][1][1]; c.v[0][0][0][0] = Values.D; Object val4 = get();
-                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+                assertEquals(val4, (isStableEnabled ? (isStableEnabled ? Values.A : Values.B)
                         : Values.D));
 
                 c.v[0][0] = new Object[1][1]; c.v[0][0][0][0] = Values.E; Object val5 = get();
-                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+                assertEquals(val5, (isStableEnabled ? (isStableEnabled ? Values.A : Values.B)
                         : Values.E));
 
                 c.v[0][0][0] = new Object[1]; c.v[0][0][0][0] = Values.F; Object val6 = get();
-                assertEquals(val6, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B)
+                assertEquals(val6, (isStableEnabled ? (isStableEnabled ? Values.A : Values.B)
                         : Values.F));
             }
 
             {
                 c.v = new Object[1][1][1][1]; Object[] val1 = get1();
                 c.v[0][0][0] = new Object[1]; Object[] val2 = get1();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new Object[1][1][1][1]; Object[][] val1 = get2();
                 c.v[0][0] = new Object[1][1]; Object[][] val2 = get2();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new Object[1][1][1][1]; Object[][][] val1 = get3();
                 c.v[0] = new Object[1][1][1]; Object[][][] val2 = get3();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -409,7 +408,7 @@
                 c.v = new Object[1][1]; c.v[0] = new Object[0]; Object[] val1 = get1();
                 c.v[0] = new Object[0]; Object[] val2 = get1();
 
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -445,14 +444,14 @@
                 c.v = new Object[1][1][1]; c.v[0][0] = new Object[0]; Object[] val1 = get1();
                 c.v[0][0] = new Object[0]; Object[] val2 = get1();
 
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new Object[1][1][1]; c.v[0] = new Object[0][0]; Object[][] val1 = get2();
                 c.v[0] = new Object[0][0]; Object[][] val2 = get2();
 
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -587,7 +586,7 @@
                 elem.a = Values.B; Object val3 = get(); Object val4 = get1();
 
                 assertEquals(val1, Values.A);
-                assertEquals(val3, (isServerWithStable ? Values.A : Values.B));
+                assertEquals(val3, (isStableEnabled ? Values.A : Values.B));
 
                 assertEquals(val2, Values.A);
                 assertEquals(val4, Values.B);
--- a/hotspot/test/compiler/stable/TestStableShort.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/compiler/stable/TestStableShort.java	Mon Mar 28 08:41:54 2016 -0700
@@ -61,7 +61,6 @@
 
 public class TestStableShort {
     static final boolean isStableEnabled    = StableConfiguration.isStableEnabled;
-    static final boolean isServerWithStable = StableConfiguration.isServerWithStable;
 
     public static void main(String[] args) throws Exception {
         run(DefaultValue.class);
@@ -182,10 +181,10 @@
                 c.v = new short[1]; c.v[0] = 1; short val1 = get();
                 c.v[0] = 2; short val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isServerWithStable ? 1 : 2));
+                assertEquals(val2, (isStableEnabled ? 1 : 2));
 
                 c.v = new short[1]; c.v[0] = 3; short val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 3));
             }
 
@@ -193,10 +192,10 @@
                 c.v = new short[20]; c.v[10] = 1; short val1 = get1();
                 c.v[10] = 2; short val2 = get1();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isServerWithStable ? 1 : 2));
+                assertEquals(val2, (isStableEnabled ? 1 : 2));
 
                 c.v = new short[20]; c.v[10] = 3; short val3 = get1();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 3));
             }
 
@@ -222,21 +221,21 @@
                 c.v = new short[1][1]; c.v[0][0] = 1; short val1 = get();
                 c.v[0][0] = 2; short val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isServerWithStable ? 1 : 2));
+                assertEquals(val2, (isStableEnabled ? 1 : 2));
 
                 c.v = new short[1][1]; c.v[0][0] = 3; short val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 3));
 
                 c.v[0] = new short[1]; c.v[0][0] = 4; short val4 = get();
-                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val4, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 4));
             }
 
             {
                 c.v = new short[1][1]; short[] val1 = get1();
                 c.v[0] = new short[1]; short[] val2 = get1();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -262,31 +261,31 @@
                 c.v = new short[1][1][1]; c.v[0][0][0] = 1; short val1 = get();
                 c.v[0][0][0] = 2; short val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isServerWithStable ? 1 : 2));
+                assertEquals(val2, (isStableEnabled ? 1 : 2));
 
                 c.v = new short[1][1][1]; c.v[0][0][0] = 3; short val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 3));
 
                 c.v[0] = new short[1][1]; c.v[0][0][0] = 4; short val4 = get();
-                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val4, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 4));
 
                 c.v[0][0] = new short[1]; c.v[0][0][0] = 5; short val5 = get();
-                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val5, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 5));
             }
 
             {
                 c.v = new short[1][1][1]; short[] val1 = get1();
                 c.v[0][0] = new short[1]; short[] val2 = get1();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new short[1][1][1]; short[][] val1 = get2();
                 c.v[0] = new short[1][1]; short[][] val2 = get2();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -313,41 +312,41 @@
                 c.v = new short[1][1][1][1]; c.v[0][0][0][0] = 1; short val1 = get();
                 c.v[0][0][0][0] = 2; short val2 = get();
                 assertEquals(val1, 1);
-                assertEquals(val2, (isServerWithStable ? 1 : 2));
+                assertEquals(val2, (isStableEnabled ? 1 : 2));
 
                 c.v = new short[1][1][1][1]; c.v[0][0][0][0] = 3; short val3 = get();
-                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 3));
 
                 c.v[0] = new short[1][1][1]; c.v[0][0][0][0] = 4; short val4 = get();
-                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val4, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 4));
 
                 c.v[0][0] = new short[1][1]; c.v[0][0][0][0] = 5; short val5 = get();
-                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val5, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 5));
 
                 c.v[0][0][0] = new short[1]; c.v[0][0][0][0] = 6; short val6 = get();
-                assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1 : 2)
+                assertEquals(val6, (isStableEnabled ? (isStableEnabled ? 1 : 2)
                         : 6));
             }
 
             {
                 c.v = new short[1][1][1][1]; short[] val1 = get1();
                 c.v[0][0][0] = new short[1]; short[] val2 = get1();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new short[1][1][1][1]; short[][] val1 = get2();
                 c.v[0][0] = new short[1][1]; short[][] val2 = get2();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new short[1][1][1][1]; short[][][] val1 = get3();
                 c.v[0] = new short[1][1][1]; short[][][] val2 = get3();
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -407,7 +406,7 @@
                 c.v = new short[1][1]; c.v[0] = new short[0]; short[] val1 = get1();
                 c.v[0] = new short[0]; short[] val2 = get1();
 
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -443,14 +442,14 @@
                 c.v = new short[1][1][1]; c.v[0][0] = new short[0]; short[] val1 = get1();
                 c.v[0][0] = new short[0]; short[] val2 = get1();
 
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
                 c.v = new short[1][1][1]; c.v[0] = new short[0][0]; short[][] val1 = get2();
                 c.v[0] = new short[0][0]; short[][] val2 = get2();
 
-                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
+                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
             }
 
             {
@@ -585,7 +584,7 @@
                 elem.a = 2; short val3 = get(); short val4 = get1();
 
                 assertEquals(val1, 1);
-                assertEquals(val3, (isServerWithStable ? 1 : 2));
+                assertEquals(val3, (isStableEnabled ? 1 : 2));
 
                 assertEquals(val2, 1);
                 assertEquals(val4, 2);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/types/TestPhiElimination.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+/**
+ * @test
+ * @bug 8150804
+ * @summary Tests elimination of Phi nodes without losing type information.
+ * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement TestPhiElimination
+ */
+public class TestPhiElimination {
+    /*
+       A::get() is inlined into test(obj) producing the following graph:
+
+               Parm (obj)
+            TestPhiElimination
+                   |
+                 CastPP
+        TestPhiElimination:NotNull
+                   |
+              CheckCastPP
+               A:NotNull
+               /       \
+       CheckCastPP     |
+        A:NotNull      |
+                \     /
+                  Phi
+                   A
+                   |
+               Safepoint
+
+       PhiNode::ideal() then replaces the Phi by a CheckCastPP:
+
+               Parm (obj)
+            TestPhiElimination
+                   |
+              CheckCastPP
+                   A
+                   |
+               Safepoint
+
+       losing the :NotNull information. Therefore, we cannot prove that obj != null
+       when accessing a field and add an uncommon trap. Since obj is used as monitor, we
+       set it to TOP in the uncommon trap branch and later fail in Process_OopMap_Node
+       because the monitor object is TOP.
+    */
+    public Object test(TestPhiElimination obj) {
+        if (obj instanceof A) {
+            return ((A) obj).get();
+        }
+        return null;
+    }
+
+    static public void main(String[] args) {
+        TestPhiElimination t = new TestPhiElimination();
+
+        // Warmup
+        B b = new B();
+        for (int i = 0; i < 1_000; ++i) {
+            t.test(b);
+        }
+
+        // Compile
+        A a = new A();
+        for (int i = 0; i < 20_000; ++i) {
+            if (i % 2 == 0) {
+                a.f = null;
+            }
+            t.test(a);
+        }
+    }
+
+}
+
+class A extends TestPhiElimination {
+    public Object f;
+
+    public A create() {
+        return new A();
+    }
+
+    public synchronized Object get() {
+        if (f == null) {
+            f = create();
+        }
+        return f;
+    }
+}
+
+class B extends A {
+
+}
--- a/hotspot/test/compiler/unsafe/UnsafeGetConstantField.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/compiler/unsafe/UnsafeGetConstantField.java	Mon Mar 28 08:41:54 2016 -0700
@@ -58,6 +58,7 @@
 import jdk.internal.org.objectweb.asm.Type;
 import jdk.internal.vm.annotation.Stable;
 import jdk.test.lib.Asserts;
+import jdk.test.lib.Platform;
 import jdk.internal.misc.Unsafe;
 
 import java.io.IOException;
@@ -73,9 +74,11 @@
     static final Unsafe U = Unsafe.getUnsafe();
 
     public static void main(String[] args) {
-        testUnsafeGetAddress();
-        testUnsafeGetField();
-        testUnsafeGetFieldUnaligned();
+        if (Platform.isServer()) {
+            testUnsafeGetAddress();
+            testUnsafeGetField();
+            testUnsafeGetFieldUnaligned();
+        }
         System.out.println("TEST PASSED");
     }
 
--- a/hotspot/test/compiler/unsafe/UnsafeGetStableArrayElement.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/compiler/unsafe/UnsafeGetStableArrayElement.java	Mon Mar 28 08:41:54 2016 -0700
@@ -43,6 +43,7 @@
 
 import static jdk.internal.misc.Unsafe.*;
 import static jdk.test.lib.Asserts.*;
+import static jdk.test.lib.Platform;
 
 public class UnsafeGetStableArrayElement {
     @Stable static final boolean[] STABLE_BOOLEAN_ARRAY = new boolean[16];
@@ -219,6 +220,12 @@
     }
 
     public static void main(String[] args) throws Exception {
+        if (Platform.isServer()) {
+            test();
+        }
+    }
+
+    static void test() throws Exception {
         // boolean[], aligned accesses
         testMatched(   Test::testZ_Z, Test::changeZ);
         testMismatched(Test::testZ_B, Test::changeZ);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/whitebox/BlockingCompilation.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2016 SAP SE. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8150646
+ * @summary Add support for blocking compiles through whitebox API
+ * @library /testlibrary /test/lib /
+ * @build sun.hotspot.WhiteBox
+ *        compiler.testlibrary.CompilerUtils
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ *                              sun.hotspot.WhiteBox$WhiteBoxPermission
+ *
+ * @run main/othervm/timeout=60
+ *        -Xbootclasspath/a:.
+ *        -Xmixed
+ *        -XX:+UnlockDiagnosticVMOptions
+ *        -XX:+WhiteBoxAPI
+ *        -XX:+PrintCompilation
+ *        BlockingCompilation
+ */
+
+import java.lang.reflect.Method;
+import java.util.Random;
+
+import sun.hotspot.WhiteBox;
+import compiler.testlibrary.CompilerUtils;
+
+public class BlockingCompilation {
+    private static final WhiteBox WB = WhiteBox.getWhiteBox();
+    private static final Random RANDOM = new Random();
+
+    public static int foo() {
+        return RANDOM.nextInt();
+    }
+
+    public static void main(String[] args) throws Exception {
+        Method m = BlockingCompilation.class.getMethod("foo");
+        int[] levels = CompilerUtils.getAvailableCompilationLevels();
+        int highest_level = levels[levels.length-1];
+
+        // If there are no compilers available these tests don't make any sense.
+        if (levels.length == 0) return;
+
+        // Make sure no compilations can progress, blocking compiles will hang
+        WB.lockCompilation();
+
+        // Verify method state before test
+        if (WB.isMethodCompiled(m)) {
+            throw new Exception("Should not be compiled after deoptimization");
+        }
+        if (WB.isMethodQueuedForCompilation(m)) {
+            throw new Exception("Should not be enqueued on any level");
+        }
+
+        // Try compiling on highest available comp level.
+        // If the compiles are blocking, this call will block until the test time out,
+        // Progress == success
+        // (Don't run with -Xcomp since that can cause long timeouts due to many compiles)
+        WB.enqueueMethodForCompilation(m, highest_level);
+
+        // restore state
+        WB.unlockCompilation();
+        while (!WB.isMethodCompiled(m)) {
+          Thread.sleep(100);
+        }
+        WB.deoptimizeMethod(m);
+        WB.clearMethodState(m);
+
+        // Blocking compilations on all levels, using the default versions of
+        // WB.enqueueMethodForCompilation() and manually setting compiler directives.
+        String directive = "[{ match: \"BlockingCompilation.foo\", BackgroundCompilation: false }]";
+        if (WB.addCompilerDirective(directive) != 1) {
+            throw new Exception("Failed to add compiler directive");
+        }
+
+        try {
+            for (int l : levels) {
+                // Make uncompiled
+                WB.deoptimizeMethod(m);
+
+                // Verify that it's not compiled
+                if (WB.isMethodCompiled(m)) {
+                    throw new Exception("Should not be compiled after deoptimization");
+                }
+                if (WB.isMethodQueuedForCompilation(m)) {
+                    throw new Exception("Should not be enqueued on any level");
+                }
+
+                // Add to queue and verify that it went well
+                if (!WB.enqueueMethodForCompilation(m, l)) {
+                    throw new Exception("Could not be enqueued for compilation");
+                }
+
+                // Verify that it is compiled
+                if (!WB.isMethodCompiled(m)) {
+                    throw new Exception("Must be compiled here");
+                }
+                // And verify the level
+                if (WB.getMethodCompilationLevel(m) != l) {
+                    String msg = m + " should be compiled at level " + l +
+                                 "(but is actually compiled at level " +
+                                 WB.getMethodCompilationLevel(m) + ")";
+                    System.out.println("==> " + msg);
+                    throw new Exception(msg);
+                }
+            }
+        } finally {
+            WB.removeCompilerDirective(1);
+        }
+
+        // Clean up
+        WB.deoptimizeMethod(m);
+        WB.clearMethodState(m);
+
+        // Make sure no compilations can progress, blocking compiles will hang
+        WB.lockCompilation();
+
+        // Verify method state before test
+        if (WB.isMethodCompiled(m)) {
+            throw new Exception("Should not be compiled after deoptimization");
+        }
+        if (WB.isMethodQueuedForCompilation(m)) {
+            throw new Exception("Should not be enqueued on any level");
+        }
+
+        // Try compiling on highest available comp level.
+        // If the compiles are blocking, this call will block until the test time out,
+        // Progress == success
+        // (Don't run with -Xcomp since that can cause long timeouts due to many compiles)
+        WB.enqueueMethodForCompilation(m, highest_level);
+
+        // restore state
+        WB.unlockCompilation();
+    }
+}
--- a/hotspot/test/compiler/whitebox/ClearMethodStateTest.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/compiler/whitebox/ClearMethodStateTest.java	Mon Mar 28 08:41:54 2016 -0700
@@ -22,6 +22,7 @@
  */
 
 import java.util.function.Function;
+
 import compiler.whitebox.CompilerWhiteBoxTest;
 
 /*
@@ -32,14 +33,24 @@
  * @build ClearMethodStateTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCase$Helper::* ClearMethodStateTest
+ * @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI ClearMethodStateTest
  * @summary testing of WB::clearMethodState()
  * @author igor.ignatyev@oracle.com
  */
 public class ClearMethodStateTest extends CompilerWhiteBoxTest {
 
     public static void main(String[] args) throws Exception {
-        CompilerWhiteBoxTest.main(ClearMethodStateTest::new, args);
+        String directive =
+                "[{ match:\"*SimpleTestCase$Helper.*\", BackgroundCompilation: false }, " +
+                " { match:\"*.*\", inline:\"-*SimpleTestCase$Helper.*\"}]";
+        if (WHITE_BOX.addCompilerDirective(directive) != 2) {
+            throw new RuntimeException("Could not add directive");
+        }
+        try {
+            CompilerWhiteBoxTest.main(ClearMethodStateTest::new, args);
+        } finally {
+            WHITE_BOX.removeCompilerDirective(2);
+        }
     }
 
     private ClearMethodStateTest(TestCase testCase) {
@@ -58,6 +69,7 @@
      */
     @Override
     protected void test() throws Exception {
+
         checkNotCompiled();
         compile();
         WHITE_BOX.clearMethodState(method);
--- a/hotspot/test/compiler/whitebox/CompilerWhiteBoxTest.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/compiler/whitebox/CompilerWhiteBoxTest.java	Mon Mar 28 08:41:54 2016 -0700
@@ -213,6 +213,7 @@
      *                          compilation level.
      */
     protected final void checkNotCompiled() {
+        waitBackgroundCompilation();
         checkNotCompiled(true);
         checkNotCompiled(false);
     }
@@ -226,7 +227,6 @@
      *                          compilation level.
      */
     protected final void checkNotCompiled(boolean isOsr) {
-        waitBackgroundCompilation();
         if (WHITE_BOX.isMethodQueuedForCompilation(method)) {
             throw new RuntimeException(method + " must not be in queue");
         }
@@ -315,11 +315,11 @@
             return;
         }
         final Object obj = new Object();
-        for (int i = 0; i < 10
+        for (int i = 0; i < 100
                 && WHITE_BOX.isMethodQueuedForCompilation(executable); ++i) {
             synchronized (obj) {
                 try {
-                    obj.wait(1000);
+                    obj.wait(100);
                 } catch (InterruptedException e) {
                     Thread.currentThread().interrupt();
                 }
--- a/hotspot/test/compiler/whitebox/EnqueueMethodForCompilationTest.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/compiler/whitebox/EnqueueMethodForCompilationTest.java	Mon Mar 28 08:41:54 2016 -0700
@@ -31,14 +31,24 @@
  * @build EnqueueMethodForCompilationTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm/timeout=600 -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCase$Helper::* EnqueueMethodForCompilationTest
+ * @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI EnqueueMethodForCompilationTest
  * @summary testing of WB::enqueueMethodForCompilation()
  * @author igor.ignatyev@oracle.com
  */
 public class EnqueueMethodForCompilationTest extends CompilerWhiteBoxTest {
 
     public static void main(String[] args) throws Exception {
-        CompilerWhiteBoxTest.main(EnqueueMethodForCompilationTest::new, args);
+        String directive =
+                "[{ match:\"*SimpleTestCase$Helper.*\", BackgroundCompilation: false }, " +
+                " { match:\"*.*\", inline:\"-*SimpleTestCase$Helper.*\"}]";
+        if (WHITE_BOX.addCompilerDirective(directive) != 2) {
+            throw new RuntimeException("Could not add directive");
+        }
+        try {
+            CompilerWhiteBoxTest.main(EnqueueMethodForCompilationTest::new, args);
+        } finally {
+            WHITE_BOX.removeCompilerDirective(2);
+        }
     }
 
     private EnqueueMethodForCompilationTest(TestCase testCase) {
--- a/hotspot/test/compiler/whitebox/LockCompilationTest.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/compiler/whitebox/LockCompilationTest.java	Mon Mar 28 08:41:54 2016 -0700
@@ -29,7 +29,7 @@
  * @build LockCompilationTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm/timeout=600 -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCase$Helper::* LockCompilationTest
+ * @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI LockCompilationTest
  * @summary testing of WB::lock/unlockCompilation()
  */
 
@@ -37,12 +37,15 @@
 import java.io.PrintWriter;
 import java.util.concurrent.BrokenBarrierException;
 import java.util.concurrent.CyclicBarrier;
+
 import compiler.whitebox.CompilerWhiteBoxTest;
 import jdk.test.lib.Asserts;
 
 public class LockCompilationTest extends CompilerWhiteBoxTest {
     public static void main(String[] args) throws Exception {
-        CompilerWhiteBoxTest.main(LockCompilationTest::new, args);
+        // This case waits for 10 seconds and verifies that the method hasn't been
+        // compiled during that time. Only do that for one of the test cases.
+        CompilerWhiteBoxTest.main(LockCompilationTest::new, new String[] {"METHOD_TEST"});
     }
 
     private LockCompilationTest(TestCase testCase) {
--- a/hotspot/test/compiler/whitebox/MakeMethodNotCompilableTest.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/compiler/whitebox/MakeMethodNotCompilableTest.java	Mon Mar 28 08:41:54 2016 -0700
@@ -31,14 +31,24 @@
  * @build MakeMethodNotCompilableTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm/timeout=2400 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCase$Helper::* MakeMethodNotCompilableTest
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI  -Xmixed MakeMethodNotCompilableTest
  * @summary testing of WB::makeMethodNotCompilable()
  * @author igor.ignatyev@oracle.com
  */
 public class MakeMethodNotCompilableTest extends CompilerWhiteBoxTest {
     private int bci;
     public static void main(String[] args) throws Exception {
-        CompilerWhiteBoxTest.main(MakeMethodNotCompilableTest::new, args);
+        String directive =
+                "[{ match:\"*SimpleTestCase$Helper.*\", BackgroundCompilation: false }, " +
+                " { match:\"*.*\", inline:\"-*SimpleTestCase$Helper.*\"}]";
+        if (WHITE_BOX.addCompilerDirective(directive) != 2) {
+            throw new RuntimeException("Could not add directive");
+        }
+        try {
+            CompilerWhiteBoxTest.main(MakeMethodNotCompilableTest::new, args);
+        } finally {
+            WHITE_BOX.removeCompilerDirective(2);
+        }
     }
 
     private MakeMethodNotCompilableTest(TestCase testCase) {
--- a/hotspot/test/gc/TestCardTablePageCommits.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/gc/TestCardTablePageCommits.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
  * @key gc
  * @bug 8059066
  * @summary Tests that the card table does not commit the same page twice
+ * @requires vm.gc=="Parallel" | vm.gc=="null"
  * @library /testlibrary
  * @modules java.base/sun.misc
  *          java.management
--- a/hotspot/test/gc/arguments/TestCMSHeapSizeFlags.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/gc/arguments/TestCMSHeapSizeFlags.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
  * @test TestCMSHeapSizeFlags
  * @key gc
  * @bug 8006088
+ * @requires vm.gc=="ConcMarkSweep" | vm.gc=="null"
  * @summary Tests argument processing for initial and maximum heap size for the CMS collector
  * @library /testlibrary /test/lib
  * @modules java.base/sun.misc
--- a/hotspot/test/gc/arguments/TestG1ConcRefinementThreads.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/gc/arguments/TestG1ConcRefinementThreads.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
  * @test TestG1ConcRefinementThreads
  * @key gc
  * @bug 8047976
+ * @requires vm.gc=="G1" | vm.gc=="null"
  * @summary Tests argument processing for G1ConcRefinementThreads
  * @library /testlibrary
  * @modules java.base/sun.misc
--- a/hotspot/test/gc/arguments/TestG1HeapSizeFlags.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/gc/arguments/TestG1HeapSizeFlags.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
  * @test TestG1HeapSizeFlags
  * @key gc
  * @bug 8006088
+ * @requires vm.gc=="G1" | vm.gc=="null"
  * @summary Tests argument processing for initial and maximum heap size for the G1 collector
  * @library /testlibrary /test/lib
  * @modules java.base/sun.misc
--- a/hotspot/test/gc/arguments/TestG1PercentageOptions.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/gc/arguments/TestG1PercentageOptions.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
  * @test TestG1PercentageOptions
  * @key gc
  * @bug 8068942
+ * @requires vm.gc=="G1" | vm.gc=="null"
  * @summary Test argument processing of various percentage options
  * @library /testlibrary
  * @modules java.base/sun.misc
--- a/hotspot/test/gc/arguments/TestParallelHeapSizeFlags.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/gc/arguments/TestParallelHeapSizeFlags.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
  * @bug 8006088
  * @summary Tests argument processing for initial and maximum heap size for the
  * parallel collectors.
+ * @requires vm.gc=="null"
  * @library /testlibrary /test/lib
  * @modules java.base/sun.misc
  *          java.management
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData00.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData00.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
  * @summary Checks that decommitment occurs for JVM with different
  * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
  * @requires vm.gc=="G1" | vm.gc=="null"
+ * @requires vm.opt.AggressiveOpts=="false" | vm.opt.AggressiveOpts=="null"
  * @library /testlibrary /test/lib
  * @modules java.base/sun.misc
  *          java.management
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData05.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData05.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
  * @summary Checks that decommitment occurs for JVM with different
  * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
  * @requires vm.gc=="G1" | vm.gc=="null"
+ * @requires vm.opt.AggressiveOpts=="false" | vm.opt.AggressiveOpts=="null"
  * @library /testlibrary /test/lib
  * @modules java.base/sun.misc
  *          java.management
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData10.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData10.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
  * @summary Checks that decommitment occurs for JVM with different
  * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
  * @requires vm.gc=="G1" | vm.gc=="null"
+ * @requires vm.opt.AggressiveOpts=="false" | vm.opt.AggressiveOpts=="null"
  * @library /testlibrary /test/lib
  * @modules java.base/sun.misc
  *          java.management
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData15.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData15.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
  * @summary Checks that decommitment occurs for JVM with different
  * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
  * @requires vm.gc=="G1" | vm.gc=="null"
+ * @requires vm.opt.AggressiveOpts=="false" | vm.opt.AggressiveOpts=="null"
  * @library /testlibrary /test/lib
  * @modules java.base/sun.misc
  *          java.management
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData20.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData20.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
  * @summary Checks that decommitment occurs for JVM with different
  * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
  * @requires vm.gc=="G1" | vm.gc=="null"
+ * @requires vm.opt.AggressiveOpts=="false" | vm.opt.AggressiveOpts=="null"
  * @library /testlibrary /test/lib
  * @modules java.base/sun.misc
   *          java.management
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData25.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData25.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
  * @summary Checks that decommitment occurs for JVM with different
  * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
  * @requires vm.gc=="G1" | vm.gc=="null"
+ * @requires vm.opt.AggressiveOpts=="false" | vm.opt.AggressiveOpts=="null"
  * @library /testlibrary /test/lib
  * @modules java.base/sun.misc
  *          java.management
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData30.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData30.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
  * @summary Checks that decommitment occurs for JVM with different
  * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
  * @requires vm.gc=="G1" | vm.gc=="null"
+ * @requires vm.opt.AggressiveOpts=="false" | vm.opt.AggressiveOpts=="null"
  * @library /testlibrary /test/lib
  * @modules java.base/sun.misc
  *          java.management
--- a/hotspot/test/gc/g1/plab/TestPLABPromotion.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/gc/g1/plab/TestPLABPromotion.java	Mon Mar 28 08:41:54 2016 -0700
@@ -27,7 +27,7 @@
  * @summary Test PLAB promotion
  * @requires vm.gc=="G1" | vm.gc=="null"
  * @requires vm.opt.FlightRecorder != true
- * @library /testlibrary /../../test/lib /
+ * @library /testlibrary /test/lib /
  * @modules java.management
  * @build ClassFileInstaller
  *        sun.hotspot.WhiteBox
--- a/hotspot/test/gc/g1/plab/TestPLABResize.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/gc/g1/plab/TestPLABResize.java	Mon Mar 28 08:41:54 2016 -0700
@@ -27,7 +27,7 @@
  * @summary Test for PLAB resizing
  * @requires vm.gc=="G1" | vm.gc=="null"
  * @requires vm.opt.FlightRecorder != true
- * @library /testlibrary /../../test/lib /
+ * @library /testlibrary /test/lib /
  * @modules java.management
  * @build ClassFileInstaller
  *        sun.hotspot.WhiteBox
--- a/hotspot/test/gc/logging/TestGCId.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/gc/logging/TestGCId.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
  * @test TestGCId
  * @bug 8043607
  * @summary Ensure that the GCId is logged
+ * @requires vm.gc=="null"
  * @key gc
  * @library /testlibrary
  * @modules java.base/sun.misc
--- a/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java	Mon Mar 28 08:41:54 2016 -0700
@@ -85,13 +85,6 @@
         setAllowedExitCodes("SharedMiscCodeSize", 2);
 
         /*
-         * JDK-8145204
-         * Temporarily remove testing of max range for ParGCArrayScanChunk because
-         * JVM can hang when ParGCArrayScanChunk=4294967296 and ParallelGC is used
-         */
-        excludeTestMaxRange("ParGCArrayScanChunk");
-
-        /*
          * Remove CICompilerCount from testing because currently it can hang system
          */
         excludeTestMaxRange("CICompilerCount");
--- a/hotspot/test/serviceability/dcmd/compiler/CodelistTest.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/hotspot/test/serviceability/dcmd/compiler/CodelistTest.java	Mon Mar 28 08:41:54 2016 -0700
@@ -24,26 +24,39 @@
 /*
  * @test CodelistTest
  * @bug 8054889
- * @library /testlibrary
+ * @library /testlibrary /test/lib /
  * @modules java.base/sun.misc
  *          java.compiler
  *          java.management
  *          jdk.jvmstat/sun.jvmstat.monitor
  * @build jdk.test.lib.*
- * @build jdk.test.lib.dcmd.*
- * @build MethodIdentifierParser
- * @run testng CodelistTest
+ *        jdk.test.lib.dcmd.*
+ *        sun.hotspot.WhiteBox
+ *        compiler.testlibrary.CompilerUtils
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                                sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-UseCodeCacheFlushing -Xmixed CodelistTest
+ * @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-UseCodeCacheFlushing -Xint CodelistTest
  * @summary Test of diagnostic command Compiler.codelist
+ *
+ * Flag comment:
+ * -XX:-UseCodeCacheFlushing - to prevent methods from being removed from the code cache before we have checked the results
+ *
+ * This test should never run in the same VM as other tests - the code cache may get huge which will
+ * create an enormous amount of output to parse. Same for -Xcomp.
  */
 
-import org.testng.annotations.Test;
-import org.testng.Assert;
-
+import compiler.testlibrary.CompilerUtils;
+import compiler.whitebox.CompilerWhiteBoxTest;
 import jdk.test.lib.OutputAnalyzer;
 import jdk.test.lib.dcmd.CommandExecutor;
 import jdk.test.lib.dcmd.JMXExecutor;
+import org.testng.annotations.Test;
+import org.testng.Assert;
+import sun.hotspot.WhiteBox;
 
 import java.lang.reflect.Method;
+import java.util.Iterator;
 
 public class CodelistTest {
 
@@ -62,58 +75,68 @@
      *
      */
 
+    protected static final WhiteBox WB = WhiteBox.getWhiteBox();
+
     public void run(CommandExecutor executor) {
-        int ok   = 0;
-        int fail = 0;
+
+        TestCase[] testcases = {
+                new TestCase(CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE, "testcaseMethod1"),
+                new TestCase(CompilerWhiteBoxTest.COMP_LEVEL_LIMITED_PROFILE, "testcaseMethod2"),
+                new TestCase(CompilerWhiteBoxTest.COMP_LEVEL_FULL_PROFILE, "testcaseMethod3"),
+                new TestCase(CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION, "testcaseMethod4"),
+        };
+
+        String directive = "{ match: \"CodelistTest.testcaseMethod*\", " +
+                "BackgroundCompilation: false }";
+        Assert.assertTrue(
+                WB.addCompilerDirective(directive) == 1,
+                "Must succeed");
+
+        try {
+            // Enqueue one test method for each available level
+            int[] complevels = CompilerUtils.getAvailableCompilationLevels();
+            for (int level : complevels) {
+                // Only test comp level 1 and 4 - level 1, 2 and 3 may interfere with each other
+                if (level == 1 || level == 4) {
+                    TestCase testcase = testcases[level - 1];
+                    WB.enqueueMethodForCompilation(testcase.method, testcase.level);
+                    // Set results to false for those methods we must to find
+                    // We will also assert if we find any test method we don't expect
+                    testcase.check = false;
+                }
+            }
+        } finally {
+            WB.removeCompilerDirective(1);
+        }
 
         // Get output from dcmd (diagnostic command)
         OutputAnalyzer output = executor.execute("Compiler.codelist");
+        Iterator<String> lines = output.asLines().iterator();
 
-        // Grab a method name from the output
-        int count = 0;
-
-        for (String line : output.asLines()) {
-            count++;
+        // Loop over output set result for all found methods
+        while (lines.hasNext()) {
+            String line = lines.next();
 
-            String[] parts = line.split(" ");
-            // int compileID = Integer.parseInt(parts[0]);
-            // int compileLevel = Integer.parseInt(parts[1]);
-            String methodPrintedInLogFormat = parts[2];
+            // Fast check for common part of method name
+            if (line.contains("CodelistTest.testcaseMethod")) {
+                String[] parts = line.split(" ");
+                int compileID = Integer.parseInt(parts[0]);
+                int compileLevel = Integer.parseInt(parts[1]);
+                String str = parts[2];
 
-            // skip inits, clinits, methodHandles and getUnsafe -
-            // they can not be reflected
-            if (methodPrintedInLogFormat.contains("<init>")) {
-                continue;
-            }
-            if (methodPrintedInLogFormat.contains("<clinit>")) {
-                continue;
-            }
-            if (methodPrintedInLogFormat.contains("MethodHandle")) {
-                continue;
+                for (TestCase testcase : testcases) {
+                    if (str.contains(testcase.methodName)) {
+                        Assert.assertFalse(testcase.check, "Must not be found or already found.");
+                        Assert.assertTrue(testcase.level == compileLevel, "Must have correct level");
+                        testcase.check = true;
+                    }
+                }
             }
-            if (methodPrintedInLogFormat.contains("sun.misc.Unsafe.getUnsafe")) {
-                continue;
-            }
-            if (methodPrintedInLogFormat.contains("jdk.internal.misc.Unsafe.getUnsafe")) {
-                continue;
-            }
+        }
 
-            MethodIdentifierParser mf = new MethodIdentifierParser(methodPrintedInLogFormat);
-            Method m = null;
-            try {
-                m = mf.getMethod();
-            } catch (NoSuchMethodException e) {
-                m = null;
-            } catch (ClassNotFoundException e) {
-                Assert.fail("Test error: Caught unexpected exception", e);
-            }
-            if (m == null) {
-                Assert.fail("Test failed on: " + methodPrintedInLogFormat);
-            }
-            if (count > 10) {
-                // Testing 10 entries is enough. Lets not waste time.
-                break;
-            }
+        // Check all testcases that was run
+        for (TestCase testcase : testcases) {
+            Assert.assertTrue(testcase.check, "Missing testcase " + testcase.methodName);
         }
     }
 
@@ -121,4 +144,38 @@
     public void jmx() {
         run(new JMXExecutor());
     }
+
+    public void testcaseMethod1() {
+    }
+
+    public void testcaseMethod2() {
+    }
+
+    public void testcaseMethod3() {
+    }
+
+    public void testcaseMethod4() {
+    }
+
+    public static Method getMethod(Class klass, String name, Class<?>... parameterTypes) {
+        try {
+            return klass.getDeclaredMethod(name, parameterTypes);
+        } catch (NoSuchMethodException | SecurityException e) {
+            throw new RuntimeException("exception on getting method Helper." + name, e);
+        }
+    }
+
+    class TestCase {
+        Method method;
+        int level;
+        String methodName;
+        Boolean check;
+
+        public TestCase(int level, String methodName) {
+            this.method = getMethod(CodelistTest.class, methodName);
+            this.level = level;
+            this.methodName = methodName;
+            this.check = true;
+        }
+    }
 }
--- a/jaxp/.hgtags	Thu Mar 24 02:04:14 2016 +0300
+++ b/jaxp/.hgtags	Mon Mar 28 08:41:54 2016 -0700
@@ -353,3 +353,4 @@
 3b9fa8b1491479f7ae18131a34036b58b647493e jdk-9+108
 24e247ee1fffaa625d480b2a4eef2d3a8a59f5cb jdk-9+109
 1c1bb661d35b846dc04931bd5f687a0348f80345 jdk-9+110
+27a3d65e1580386d060e0aa3a68ab52c1a9ab568 jdk-9+111
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/BaseEntry.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/BaseEntry.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,13 +24,9 @@
  */
 package javax.xml.catalog;
 
-import java.io.File;
 import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.Objects;
-import jdk.xml.internal.SecuritySupport;
 
 /**
  * Represents a general Catalog entry.
@@ -238,18 +234,6 @@
     }
 
     /**
-     * Replace backslashes with forward slashes. (URLs always use forward
-     * slashes.)
-     *
-     * @param sysid The input system identifier.
-     * @return The same system identifier with backslashes turned into forward
-     * slashes.
-     */
-    protected String fixSlashes(String sysid) {
-        return sysid.replace('\\', '/');
-    }
-
-    /**
      * Construct an absolute URI from a relative one, using the current base
      * URI.
      *
@@ -260,7 +244,7 @@
     protected String makeAbsolute(String sysid) {
         URL local = null;
 
-        sysid = fixSlashes(sysid);
+        sysid = Util.fixSlashes(sysid);
         /**
          * try { local = new URL(base, sysid); } catch (MalformedURLException e)
          * { catalogManager.debug.message(1, "Malformed URL on system
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogFeatures.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogFeatures.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,10 @@
  */
 package javax.xml.catalog;
 
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Map;
 import jdk.xml.internal.SecuritySupport;
 
 /**
@@ -380,10 +384,7 @@
      */
     CatalogFeatures(Builder builder) {
         init();
-        setProperty(Feature.FILES.ordinal(), State.APIPROPERTY, builder.files);
-        setProperty(Feature.PREFER.ordinal(), State.APIPROPERTY, builder.prefer);
-        setProperty(Feature.DEFER.ordinal(), State.APIPROPERTY, builder.defer);
-        setProperty(Feature.RESOLVE.ordinal(), State.APIPROPERTY, builder.resolve);
+        setProperties(builder);
     }
 
     /**
@@ -410,6 +411,15 @@
     }
 
     /**
+     * Sets properties by the Builder.
+     * @param builder the CatalogFeatures builder
+     */
+    private void setProperties(Builder builder) {
+        builder.values.entrySet().stream().forEach((entry) -> {
+            setProperty(entry.getKey().ordinal(), State.APIPROPERTY, entry.getValue());
+        });
+    }
+    /**
      * Sets the value of a property by its index, updates only if it shall override.
      *
      * @param index the index of the property
@@ -432,11 +442,24 @@
                          && !value.equals(RESOLVE_IGNORE)) {
                     CatalogMessages.reportIAE(new Object[]{value, Feature.RESOLVE.name()}, null);
                 }
+            } else if (index == Feature.FILES.ordinal()) {
+                try {
+                    if (Util.verifyAndGetURI(value, null) == null) {
+                        CatalogMessages.reportIAE(new Object[]{value, Feature.FILES.name()}, null);
+                    }
+                }catch (MalformedURLException | URISyntaxException | IllegalArgumentException ex) {
+                    CatalogMessages.reportIAE(new Object[]{value, Feature.FILES.name()}, ex);
+                }
+
             }
             if (states[index] == null || state.compareTo(states[index]) >= 0) {
                 values[index] = value;
                 states[index] = state;
             }
+        } else {
+            if (state == State.SYSTEMPROPERTY || state == State.JAXPDOTPROPERTIES) {
+                CatalogMessages.reportIAE(new Object[]{value, Feature.values()[index].name()}, null);
+            }
         }
     }
 
@@ -486,9 +509,9 @@
      */
     public static class Builder {
         /**
-         * Variables for the features supported by CatalogFeatures.
+         * Values of the features supported by CatalogFeatures.
          */
-        String files, prefer, defer, resolve;
+        Map<Feature, String> values = new HashMap<>();
 
         /**
          * Instantiation of Builder is not allowed.
@@ -505,20 +528,10 @@
          * property
          */
         public Builder with(Feature feature, String value) {
-            switch (feature) {
-                case FILES :
-                    files = value;
-                    break;
-                case PREFER :
-                    prefer = value;
-                    break;
-                case DEFER :
-                    defer = value;
-                    break;
-                case RESOLVE :
-                    resolve = value;
-                    break;
+            if (value == null || value.length() == 0) {
+                CatalogMessages.reportIAE(new Object[]{value, feature.name()}, null);
             }
+            values.put(feature, value);
             return this;
         }
 
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogImpl.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogImpl.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,6 @@
 package javax.xml.catalog;
 
 import com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl;
-import java.io.File;
 import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URI;
@@ -141,6 +140,12 @@
                 start++;
                 if (verifyCatalogFile(uri)) {
                     systemId = uri.toASCIIString();
+                    try {
+                        baseURI = new URL(systemId);
+                    } catch (MalformedURLException e) {
+                        CatalogMessages.reportRunTimeError(CatalogMessages.ERR_INVALID_PATH,
+                                new Object[]{temp}, e);
+                    }
                     break;
                 }
             }
@@ -291,59 +296,15 @@
      * to a system id
      */
     private URI getSystemId(String file) {
-        URL filepath;
-        if (file != null && file.length() > 0) {
-            try {
-                File f = new File(file);
-                if (baseURI != null && !f.isAbsolute()) {
-                    filepath = new URL(baseURI, fixSlashes(file));
-                    return filepath.toURI();
-                } else {
-                    return resolveURI(file);
-                }
-            } catch (MalformedURLException | URISyntaxException e) {
-                CatalogMessages.reportRunTimeError(CatalogMessages.ERR_INVALID_PATH,
-                        new Object[]{file}, e);
-            }
-        }
-        return null;
-    }
+        URI temp = null;
 
-    /**
-     * Resolves the specified uri. If the uri is relative, makes it absolute by
-     * the user.dir directory.
-     *
-     * @param uri The specified URI.
-     * @return The resolved URI
-     */
-    private URI resolveURI(String uri) throws MalformedURLException {
-        if (uri == null) {
-            uri = "";
+        try {
+            temp = Util.verifyAndGetURI(file, baseURI);
+        } catch (MalformedURLException | URISyntaxException | IllegalArgumentException e) {
+            CatalogMessages.reportRunTimeError(CatalogMessages.ERR_INVALID_PATH,
+                    new Object[]{file}, e);
         }
 
-        URI temp = toURI(uri);
-        String str = temp.toASCIIString();
-        String base = str.substring(0, str.lastIndexOf('/') + 1);
-        baseURI = new URL(str);
-
-        return temp;
-    }
-
-    /**
-     * Converts an URI string or file path to URI.
-     *
-     * @param uri an URI string or file path
-     * @return an URI
-     */
-    private URI toURI(String uri) {
-        URI temp = null;
-        try {
-            URL url = new URL(uri);
-            temp = url.toURI();
-        } catch (MalformedURLException | URISyntaxException mue) {
-            File file = new File(uri);
-            temp = file.toURI();
-        }
         return temp;
     }
 
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/Util.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/Util.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,13 @@
  */
 package javax.xml.catalog;
 
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import jdk.xml.internal.SecuritySupport;
 
 /**
@@ -31,6 +38,76 @@
  * @since 9
  */
 class Util {
+
+    /**
+     * Resolves the specified file path to an absolute systemId. If it is
+     * relative, it shall be resolved using the base or user.dir property if
+     * base is not specified.
+     *
+     * @param file The specified file path
+     * @param baseURI the base URI
+     * @return The URI
+     * @throws CatalogException if the specified file path can not be converted
+     * to a system id
+     */
+    static URI verifyAndGetURI(String file, URL baseURI)
+            throws MalformedURLException, URISyntaxException, IllegalArgumentException {
+        URL filepath;
+        URI temp;
+        if (file != null && file.length() > 0) {
+            File f = new File(file);
+
+            if (baseURI != null && !f.isAbsolute()) {
+                filepath = new URL(baseURI, fixSlashes(file));
+                temp = filepath.toURI();
+            } else {
+                temp = resolveURI(file);
+            }
+            //Paths.get may throw IllegalArgumentException
+            Path path = Paths.get(temp);
+            if (path.toFile().isFile()) {
+                return temp;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Resolves the specified uri. If the uri is relative, makes it absolute by
+     * the user.dir directory.
+     *
+     * @param uri The specified URI.
+     * @return The resolved URI
+     */
+    static URI resolveURI(String uri) throws MalformedURLException {
+        if (uri == null) {
+            uri = "";
+        }
+
+        URI temp = null;
+        try {
+            URL url = new URL(uri);
+            temp = url.toURI();
+        } catch (MalformedURLException | URISyntaxException mue) {
+            File file = new File(uri);
+            temp = file.toURI();
+        }
+
+        return temp;
+    }
+
+    /**
+     * Replace backslashes with forward slashes. (URLs always use forward
+     * slashes.)
+     *
+     * @param sysid The input system identifier.
+     * @return The same system identifier with backslashes turned into forward
+     * slashes.
+     */
+    static String fixSlashes(String sysid) {
+        return sysid.replace('\\', '/');
+    }
+
     /**
      * Find catalog file paths by reading the system property, and then
      * jaxp.properties if the system property is not specified.
@@ -38,7 +115,7 @@
      * @param sysPropertyName the name of system property
      * @return the catalog file paths, or null if not found.
      */
-    static public String[] getCatalogFiles(String sysPropertyName) {
+    static String[] getCatalogFiles(String sysPropertyName) {
         String value = SecuritySupport.getJAXPSystemProperty(sysPropertyName);
         if (value != null && !value.equals("")) {
             return value.split(";");
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java	Mon Mar 28 08:41:54 2016 -0700
@@ -42,11 +42,23 @@
 import org.xml.sax.ext.DefaultHandler2;
 
 /*
- * @bug 8081248, 8144966, 8146606, 8146237
+ * @bug 8081248, 8144966, 8146606, 8146237, 8151154
  * @summary Tests basic Catalog functions.
  */
+public class CatalogTest {
+    /**
+     * @bug 8151154
+     * Verifies that the CatalogFeatures' builder throws IllegalArgumentException
+     * on invalid file inputs.
+     * @param file the file path
+     */
+    @Test(dataProvider = "invalidPaths", expectedExceptions = IllegalArgumentException.class)
+    public void testFileInput(String file) {
+            CatalogFeatures features = CatalogFeatures.builder()
+                .with(CatalogFeatures.Feature.FILES, file)
+                .build();
+    }
 
-public class CatalogTest {
     /**
      * @bug 8146237
      * PREFER from Features API taking precedence over catalog file
@@ -201,6 +213,24 @@
         }
     }
 
+    /*
+       DataProvider: for testing the verification of file paths by
+                     the CatalogFeatures builder
+     */
+    @DataProvider(name = "invalidPaths")
+    Object[][] getFiles() {
+        return new Object[][]{
+            {null},
+            {""},
+            {"file:a/b\\c"},
+            {"file:/../../.."},
+            {"c:/te:t"},
+            {"c:/te?t"},
+            {"c/te*t"},
+            {"in|valid.txt"},
+            {"shema:invalid.txt"},
+        };
+    }
 
     /*
        DataProvider: provides test name, expected string, the catalog, and XML
--- a/jaxws/.hgtags	Thu Mar 24 02:04:14 2016 +0300
+++ b/jaxws/.hgtags	Mon Mar 28 08:41:54 2016 -0700
@@ -356,3 +356,4 @@
 513eb2e432f64f85992442da9acdfcfbb36555d9 jdk-9+108
 4b0697e4ce8940b1599af274ff02296d7f59aded jdk-9+109
 0db939c930f332dfa275cedfc7cf223ff1221ea4 jdk-9+110
+4d5296e0920afe7ef8d4db1939b76f0d407a3812 jdk-9+111
--- a/jdk/.hgtags	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/.hgtags	Mon Mar 28 08:41:54 2016 -0700
@@ -353,3 +353,4 @@
 42794e648cfe9fd67461dcbe8b7594241a84bcff jdk-9+108
 1c7bad0798900fe58f4db01ae7ffdc84f5baee8c jdk-9+109
 9417e1bcded6af5532c3b26235437ab227758877 jdk-9+110
+b2a69d66dc65ad1d3aeb3bd362cf5bb0deba040e jdk-9+111
--- a/jdk/make/gensrc/GensrcMisc.gmk	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/make/gensrc/GensrcMisc.gmk	Mon Mar 28 08:41:54 2016 -0700
@@ -23,7 +23,7 @@
 # questions.
 #
 
-##########################################################################################
+################################################################################
 # Install the launcher name, release version string, full version
 # string and the runtime name into the VersionProps.java file.
 
@@ -39,110 +39,68 @@
 
 GENSRC_JAVA_BASE += $(BUILD_VERSION_JAVA)
 
-##########################################################################################
-
-GENSRC_JAVA_BASE += $(SUPPORT_OUTPUTDIR)/gensrc/java.base/sun/nio/ch/SocketOptionRegistry.java
-
-GENSRC_SOR_SRC := $(JDK_TOPDIR)/make/src/native/genconstants/ch
-GENSRC_SOR_SRC_FILE := genSocketOptionRegistry.c
-GENSRC_SOR_BIN := $(BUILDTOOLS_OUTPUTDIR)/native/genSocketOptionRegistry
-
-SOR_COPYRIGHT_YEARS = $(shell $(CAT) $(GENSRC_SOR_SRC)/$(GENSRC_SOR_SRC_FILE) | \
-    $(NAWK) '/^.*Copyright.*Oracle/ { printf "%s %s",$$4,$$5 }')
+################################################################################
 
-$(eval $(call SetupNativeCompilation, BUILD_GENSRC_SOR_EXE, \
-    SRC := $(GENSRC_SOR_SRC), \
-    INCLUDE_FILES := $(GENSRC_SOR_SRC_FILE), \
-    CFLAGS_windows := -nologo, \
-    LDFLAGS_windows := -nologo, \
-    TOOLCHAIN := TOOLCHAIN_BUILD, \
-    OBJECT_DIR := $(GENSRC_SOR_BIN), \
-    OUTPUT_DIR := $(GENSRC_SOR_BIN), \
-    PROGRAM := genSocketOptionRegistry))
-
-SOR_PREGEN_FILE := $(JDK_TOPDIR)/src/closed/java.base/$(OPENJDK_TARGET_OS)/classes/sun/nio/ch/SocketOptionRegistry-$(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH).java.template
-
-ifeq ($(wildcard $(SOR_PREGEN_FILE)), )
-  $(SUPPORT_OUTPUTDIR)/gensrc/java.base/sun/nio/ch/SocketOptionRegistry.java: $(BUILD_GENSRC_SOR_EXE_TARGET)
-	$(MKDIR) -p $(@D)
-	$(RM) $@ $@.tmp
-	NAWK="$(NAWK)" SH="$(SH)" $(SH) -e \
-	    $(JDK_TOPDIR)/make/scripts/addNotices.sh "$(SOR_COPYRIGHT_YEARS)" > $@.tmp
-	$(BUILD_GENSRC_SOR_EXE_TARGET) >> $@.tmp
-	$(MV) $@.tmp $@
-else
-  $(SUPPORT_OUTPUTDIR)/gensrc/java.base/sun/nio/ch/SocketOptionRegistry.java: $(SOR_PREGEN_FILE)
-	$(call install-file)
+ifneq ($(filter $(TOOLCHAIN_TYPE), gcc clang), )
+  # Need to specify language since the template file has a non standard
+  # extension.
+  CPP_FLAGS += -x c
+else ifeq ($(TOOLCHAIN_TYPE), microsoft)
+  CPP_FLAGS += -nologo
 endif
 
-##########################################################################################
+# Generate a java source file from a template through the C preprocessor for the
+# target system. First extract the copyright notice at the start of the file.
+# Run the preprocessor. Filter out the default compiler stderr output on
+# Windows. Filter out all the header files output. Remove all "PREFIX_" strings
+# that were added to variable references in the template files to avoid being
+# matched by the preprocessor. Remove any #line directives left by the
+# preprocessor.
+define generate-preproc-src
+	$(call MakeDir, $(@D))
+	( $(NAWK) '/@@END_COPYRIGHT@@/{exit}1' $< && \
+	  $(CPP) $(CPP_FLAGS) $(SYSROOT_CFLAGS) $< \
+	      2> >($(GREP) -v '^$(<F)$$' >&2) \
+	      | $(NAWK) '/@@START_HERE@@/,0' \
+	      |  $(SED) -e 's/@@START_HERE@@/\/\/ AUTOMATICALLY GENERATED FILE - DO NOT EDIT/' \
+	      -e 's/PREFIX_//' -e 's/^#.*//' \
+	) > $@
+endef
+
+GENSRC_SOR_FILE += $(SUPPORT_OUTPUTDIR)/gensrc/java.base/sun/nio/ch/SocketOptionRegistry.java
+
+$(GENSRC_SOR_FILE): \
+    $(JDK_TOPDIR)/src/java.base/share/classes/sun/nio/ch/SocketOptionRegistry.java.template
+	$(generate-preproc-src)
+
+GENSRC_JAVA_BASE += $(GENSRC_SOR_FILE)
+
+################################################################################
 
 ifneq ($(OPENJDK_TARGET_OS), windows)
 
-  GENSRC_JAVA_BASE += $(SUPPORT_OUTPUTDIR)/gensrc/java.base/sun/nio/fs/UnixConstants.java
-
-  GENSRC_UC_SRC := $(JDK_TOPDIR)/make/src/native/genconstants/fs
-  GENSRC_UC_SRC_FILE := genUnixConstants.c
-  GENSRC_UC_BIN := $(BUILDTOOLS_OUTPUTDIR)/native/genUnixConstants
-
-  UC_COPYRIGHT_YEARS = $(shell $(CAT) $(GENSRC_UC_SRC)/$(GENSRC_UC_SRC_FILE) | \
-      $(NAWK) '/^.*Copyright.*Oracle/ { printf "%s %s",$$4,$$5 }')
+  GENSRC_UC_FILE := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/sun/nio/fs/UnixConstants.java
 
-  $(eval $(call SetupNativeCompilation, BUILD_GENSRC_UC_EXE, \
-      SRC := $(GENSRC_UC_SRC), \
-      INCLUDE_FILES := $(GENSRC_UC_SRC_FILE), \
-      TOOLCHAIN := TOOLCHAIN_BUILD, \
-      OBJECT_DIR := $(GENSRC_UC_BIN), \
-      OUTPUT_DIR := $(GENSRC_UC_BIN), \
-      PROGRAM := genUnixConstants))
-
-  UC_PREGEN_FILE := $(JDK_TOPDIR)/src/closed/java.base/$(OPENJDK_TARGET_OS)/classes/sun/nio/fs/UnixConstants-$(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH).java.template
+  $(GENSRC_UC_FILE): \
+      $(JDK_TOPDIR)/src/java.base/unix/classes/sun/nio/fs/UnixConstants.java.template
+	$(generate-preproc-src)
 
-  ifeq ($(wildcard $(UC_PREGEN_FILE)), )
-    $(SUPPORT_OUTPUTDIR)/gensrc/java.base/sun/nio/fs/UnixConstants.java: $(BUILD_GENSRC_UC_EXE_TARGET)
-	$(MKDIR) -p $(@D)
-	$(RM) $@ $@.tmp
-	NAWK="$(NAWK)" SH="$(SH)" $(SH) -e \
-	    $(JDK_TOPDIR)/make/scripts/addNotices.sh "$(UC_COPYRIGHT_YEARS)" > $@.tmp
-	$(BUILD_GENSRC_UC_EXE_TARGET) >> $@.tmp
-	$(MV) $@.tmp $@
-  else
-    $(SUPPORT_OUTPUTDIR)/gensrc/java.base/sun/nio/fs/UnixConstants.java: $(UC_PREGEN_FILE)
-	$(call install-file)
-  endif
+  GENSRC_JAVA_BASE += $(GENSRC_UC_FILE)
 
 endif
 
-##########################################################################################
+################################################################################
 
 ifeq ($(OPENJDK_TARGET_OS), solaris)
 
-  GENSRC_JAVA_BASE += $(SUPPORT_OUTPUTDIR)/gensrc/java.base/sun/nio/fs/SolarisConstants.java
-
-  GENSRC_SOL_SRC := $(JDK_TOPDIR)/make/src/native/genconstants/fs
-  GENSRC_SOL_SRC_FILE := genSolarisConstants.c
-  GENSRC_SOL_BIN := $(BUILDTOOLS_OUTPUTDIR)/native/genSolarisConstants
-
-  SOL_COPYRIGHT_YEARS = $(shell $(CAT) $(GENSRC_SOL_SRC)/$(GENSRC_SOL_SRC_FILE) | \
-      $(NAWK) '/^.*Copyright.*Oracle/ { printf "%s %s",$$4,$$5 }')
+  GENSRC_SC_FILE := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/sun/nio/fs/SolarisConstants.java
 
-  $(eval $(call SetupNativeCompilation, BUILD_GENSRC_SOL_EXE, \
-      SRC := $(GENSRC_SOL_SRC), \
-      INCLUDE_FILES := $(GENSRC_SOL_SRC_FILE), \
-      TOOLCHAIN := TOOLCHAIN_BUILD, \
-      OBJECT_DIR := $(GENSRC_SOL_BIN), \
-      OUTPUT_DIR := $(GENSRC_SOL_BIN), \
-      PROGRAM := genSolarisConstants))
+  $(GENSRC_SC_FILE): \
+      $(JDK_TOPDIR)/src/java.base/solaris/classes/sun/nio/fs/SolarisConstants.java.template
+	$(generate-preproc-src)
 
-  $(SUPPORT_OUTPUTDIR)/gensrc/java.base/sun/nio/fs/SolarisConstants.java: $(BUILD_GENSRC_SOL_EXE_TARGET)
-	$(MKDIR) -p $(@D)
-	$(RM) $@ $@.tmp
-	NAWK="$(NAWK)" SH="$(SH)" $(SH) -e \
-	    $(JDK_TOPDIR)/make/scripts/addNotices.sh "$(SOL_COPYRIGHT_YEARS)" > $@.tmp
-	$(BUILD_GENSRC_SOL_EXE_TARGET) >> $@.tmp
-	$(MV) $@.tmp $@
-
+  GENSRC_JAVA_BASE += $(GENSRC_SC_FILE)
 
 endif
 
-##########################################################################################
+################################################################################
--- a/jdk/make/gensrc/GensrcModuleLoaderMap.gmk	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/make/gensrc/GensrcModuleLoaderMap.gmk	Mon Mar 28 08:41:54 2016 -0700
@@ -25,103 +25,7 @@
 
 include Modules.gmk
 
-BOOT_MODULES :=
-UPGRADEABLE_MDOULES :=
-AGGREGATOR_MDOULES :=
-OTHER_PLATFORM_MODULES :=
-
-# Hook to include the corresponding custom file, if present.
-$(eval $(call IncludeCustomExtension, jdk, gensrc/GensrcModuleLoaderMap.gmk))
-
-BOOT_MODULES += \
-    java.base \
-    java.datatransfer \
-    java.desktop \
-    java.httpclient \
-    java.instrument \
-    java.logging \
-    java.management \
-    java.naming \
-    java.prefs \
-    java.rmi \
-    java.security.jgss \
-    java.security.sasl \
-    java.sql \
-    java.xml \
-    java.xml.crypto \
-    jdk.httpserver \
-    jdk.management \
-    jdk.sctp \
-    jdk.security.auth \
-    jdk.security.jgss \
-    #
-
-# to be deprivileged
-BOOT_MODULES += \
-    java.compiler \
-    java.scripting \
-    java.sql.rowset \
-    java.smartcardio \
-    jdk.charsets \
-    jdk.naming.rmi \
-    #
-
-UPGRADEABLE_MODULES += \
-    java.activation \
-    java.annotations.common \
-    java.corba \
-    java.transaction \
-    java.xml.bind \
-    java.xml.ws \
-    #
-
-AGGREGATOR_MODULES += \
-    java.compact1 \
-    java.compact2 \
-    java.compact3 \
-    java.se \
-    java.se.ee \
-    #
-
-OTHER_PLATFORM_MODULES += \
-    jdk.accessibility \
-    jdk.crypto.ec \
-    jdk.crypto.pkcs11 \
-    jdk.dynalink \
-    jdk.jsobject \
-    jdk.xml.dom \
-    jdk.localedata \
-    jdk.naming.dns \
-    jdk.scripting.nashorn \
-    jdk.zipfs \
-    #
-
-ifeq ($(OPENJDK_TARGET_OS), macsox)
-  BOOT_MODULES += jdk.deploy.osx
-endif
-ifeq ($(OPENJDK_TARGET_OS), windows)
-  OTHER_PLATFORM_MODULES += jdk.crypto.mscapi
-endif
-ifeq ($(OPENJDK_TARGET_OS), solaris)
-  OTHER_PLATFORM_MODULES += jdk.crypto.ucrypto
-endif
-
-# Param 1 - Name of module
-define ReadImportMetaData
-  ifneq ($$(wildcard $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties), )
-    classloader :=
-    include $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties
-    ifeq ($$(classloader), boot)
-      BOOT_MODULES += $1
-    else ifeq ($$(classloader), ext)
-      OTHER_PLATFORM_MODULES += $1
-    endif
-  endif
-endef
-
-IMPORTED_MODULES := $(call FindImportedModules)
-$(foreach m, $(IMPORTED_MODULES), $(eval $(call ReadImportMetaData, $m)))
-
+$(eval $(call ReadImportMetaData))
 
 # Replacing double-comma with a single comma is to workaround the issue
 # with some version of make on windows that doesn't substitute spaces
@@ -132,7 +36,7 @@
 )
 endef
 BOOT_MODULES_LIST := $(call SubstComma, $(BOOT_MODULES))
-PLATFORM_MODULES_LIST := $(call SubstComma, $(UPGRADEABLE_MODULES) $(AGGREGATOR_MODULES) $(OTHER_PLATFORM_MODULES))
+PLATFORM_MODULES_LIST := $(call SubstComma, $(PLATFORM_MODULES))
 
 VARDEPS_VALUE := $(BOOT_MODULES_LIST) $(PLATFORM_MODULES_LIST)
 VARDEPS_FILE := $(call DependOnVariable, VARDEPS_VALUE)
--- a/jdk/make/launcher/Launcher-jdk.scripting.nashorn.shell.gmk	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/make/launcher/Launcher-jdk.scripting.nashorn.shell.gmk	Mon Mar 28 08:41:54 2016 -0700
@@ -27,5 +27,6 @@
 
 $(eval $(call SetupBuildLauncher, jjs, \
     MAIN_CLASS := jdk.nashorn.tools.jjs.Main, \
+    JAVA_ARGS := -addmods ALL-SYSTEM, \
     CFLAGS := -DENABLE_ARG_FILES, \
 ))
--- a/jdk/make/src/native/genconstants/ch/genSocketOptionRegistry.c	Thu Mar 24 02:04:14 2016 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,147 +0,0 @@
-/*
- * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include <stdio.h>
-#ifdef _WIN32
-#include <winsock2.h>
-#include <ws2tcpip.h>
-#else
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#endif
-
-/* Defines SO_REUSEPORT */
-#if !defined(SO_REUSEPORT)
-#ifdef _WIN32
-#define SO_REUSEPORT 0
-#elif __linux__
-#define SO_REUSEPORT 15
-#elif __solaris__
-#define SO_REUSEPORT 0x100e
-#elif defined(AIX) || defined(MACOSX)
-#define SO_REUSEPORT 0x0200
-#else
-#define SO_REUSEPORT 0
-#endif
-#endif
-
-/**
- * Generates sun.nio.ch.SocketOptionRegistry, a class that maps Java-level
- * socket options to the platform specific level and option.
- */
-
-static void out(char* s) {
-    printf("%s\n", s);
-}
-
-static void emit(const char *name, char * family, int level, int optname) {
-    printf("            map.put(new RegistryKey(%s, %s),", name, family);
-    printf(" new OptionKey(%d, %d));\n", level, optname);
-}
-
-static void emit_unspec(const char *name, int level, int optname) {
-    emit(name, "Net.UNSPEC", level, optname);
-}
-
-static  void emit_inet(const char *name, int level, int optname) {
-    emit(name, "StandardProtocolFamily.INET", level, optname);
-}
-
-static void emit_inet6(const char *name, int level, int optname) {
-    emit(name, "StandardProtocolFamily.INET6", level, optname);
-}
-
-int main(int argc, const char* argv[]) {
-    out("// AUTOMATICALLY GENERATED FILE - DO NOT EDIT                                  ");
-    out("package sun.nio.ch;                                                            ");
-    out("import java.net.SocketOption;                                                  ");
-    out("import java.net.StandardSocketOptions;                                         ");
-    out("import java.net.ProtocolFamily;                                                ");
-    out("import java.net.StandardProtocolFamily;                                        ");
-    out("import java.util.Map;                                                          ");
-    out("import java.util.HashMap;                                                      ");
-    out("class SocketOptionRegistry {                                                   ");
-    out("    private SocketOptionRegistry() { }                                         ");
-    out("    private static class RegistryKey {                                         ");
-    out("        private final SocketOption<?> name;                                    ");
-    out("        private final ProtocolFamily family;                                   ");
-    out("        RegistryKey(SocketOption<?> name, ProtocolFamily family) {             ");
-    out("            this.name = name;                                                  ");
-    out("            this.family = family;                                              ");
-    out("        }                                                                      ");
-    out("        public int hashCode() {                                                ");
-    out("            return name.hashCode() + family.hashCode();                        ");
-    out("        }                                                                      ");
-    out("        public boolean equals(Object ob) {                                     ");
-    out("            if (ob == null) return false;                                      ");
-    out("            if (!(ob instanceof RegistryKey)) return false;                    ");
-    out("            RegistryKey other = (RegistryKey)ob;                               ");
-    out("            if (this.name != other.name) return false;                         ");
-    out("            if (this.family != other.family) return false;                     ");
-    out("            return true;                                                       ");
-    out("        }                                                                      ");
-    out("    }                                                                          ");
-    out("    private static class LazyInitialization {                                  ");
-    out("        static final Map<RegistryKey,OptionKey> options = options();           ");
-    out("        private static Map<RegistryKey,OptionKey> options() {                  ");
-    out("            Map<RegistryKey,OptionKey> map =                                   ");
-    out("                new HashMap<RegistryKey,OptionKey>();                          ");
-
-    emit_unspec("StandardSocketOptions.SO_BROADCAST", SOL_SOCKET, SO_BROADCAST);
-    emit_unspec("StandardSocketOptions.SO_KEEPALIVE", SOL_SOCKET, SO_KEEPALIVE);
-    emit_unspec("StandardSocketOptions.SO_LINGER",    SOL_SOCKET, SO_LINGER);
-    emit_unspec("StandardSocketOptions.SO_SNDBUF",    SOL_SOCKET, SO_SNDBUF);
-    emit_unspec("StandardSocketOptions.SO_RCVBUF",    SOL_SOCKET, SO_RCVBUF);
-    emit_unspec("StandardSocketOptions.SO_REUSEADDR", SOL_SOCKET, SO_REUSEADDR);
-    emit_unspec("StandardSocketOptions.SO_REUSEPORT", SOL_SOCKET, SO_REUSEPORT);
-    emit_unspec("StandardSocketOptions.TCP_NODELAY",  IPPROTO_TCP, TCP_NODELAY);
-
-    emit_inet("StandardSocketOptions.IP_TOS",            IPPROTO_IP,     IP_TOS);
-    emit_inet("StandardSocketOptions.IP_MULTICAST_IF",   IPPROTO_IP,     IP_MULTICAST_IF);
-    emit_inet("StandardSocketOptions.IP_MULTICAST_TTL",  IPPROTO_IP,     IP_MULTICAST_TTL);
-    emit_inet("StandardSocketOptions.IP_MULTICAST_LOOP", IPPROTO_IP,     IP_MULTICAST_LOOP);
-
-#ifdef AF_INET6
-    emit_inet6("StandardSocketOptions.IP_TOS",            IPPROTO_IPV6,  IPV6_TCLASS);
-    emit_inet6("StandardSocketOptions.IP_MULTICAST_IF",   IPPROTO_IPV6,  IPV6_MULTICAST_IF);
-    emit_inet6("StandardSocketOptions.IP_MULTICAST_TTL",  IPPROTO_IPV6,  IPV6_MULTICAST_HOPS);
-    emit_inet6("StandardSocketOptions.IP_MULTICAST_LOOP", IPPROTO_IPV6,  IPV6_MULTICAST_LOOP);
-#endif
-
-    emit_unspec("ExtendedSocketOption.SO_OOBINLINE", SOL_SOCKET, SO_OOBINLINE);
-
-    out("            return map;                                                        ");
-    out("        }                                                                      ");
-    out("    }                                                                          ");
-    out("    public static OptionKey findOption(SocketOption<?> name, ProtocolFamily family) { ");
-    out("        RegistryKey key = new RegistryKey(name, family);                       ");
-    out("        return LazyInitialization.options.get(key);                            ");
-    out("    }                                                                          ");
-    out("}                                                                              ");
-
-    return 0;
-}
--- a/jdk/make/src/native/genconstants/fs/genSolarisConstants.c	Thu Mar 24 02:04:14 2016 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/acl.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-
-/**
- * Generates sun.nio.fs.SolarisConstants
- */
-
-static void out(char* s) {
-    printf("%s\n", s);
-}
-
-static void emit(char* name, int value) {
-    printf("    static final int %s = %d;\n", name, value);
-}
-
-static void emitX(char* name, int value) {
-    printf("    static final int %s = 0x%x;\n", name, value);
-}
-
-#define DEF(X) emit(#X, X);
-#define DEFX(X) emitX(#X, X);
-
-int main(int argc, const char* argv[]) {
-    out("// AUTOMATICALLY GENERATED FILE - DO NOT EDIT                                  ");
-    out("package sun.nio.fs;                                                            ");
-    out("class SolarisConstants {                                                       ");
-    out("    private SolarisConstants() { }                                             ");
-
-    // extended attributes
-    DEFX(O_XATTR);
-    DEF(_PC_XATTR_ENABLED);
-
-    // ACL configuration
-    DEF(_PC_ACL_ENABLED);
-    DEFX(_ACL_ACE_ENABLED);
-
-    // ACL commands
-    DEFX(ACE_GETACL);
-    DEFX(ACE_SETACL);
-
-    // ACL mask/flags/types
-    emitX("ACE_ACCESS_ALLOWED_ACE_TYPE",        0x0000);
-    emitX("ACE_ACCESS_DENIED_ACE_TYPE",         0x0001);
-    emitX("ACE_SYSTEM_AUDIT_ACE_TYPE",          0x0002);
-    emitX("ACE_SYSTEM_ALARM_ACE_TYPE",          0x0003);
-    emitX("ACE_READ_DATA",                      0x00000001);
-    emitX("ACE_LIST_DIRECTORY",                 0x00000001);
-    emitX("ACE_WRITE_DATA",                     0x00000002);
-    emitX("ACE_ADD_FILE",                       0x00000002);
-    emitX("ACE_APPEND_DATA",                    0x00000004);
-    emitX("ACE_ADD_SUBDIRECTORY",               0x00000004);
-    emitX("ACE_READ_NAMED_ATTRS",               0x00000008);
-    emitX("ACE_WRITE_NAMED_ATTRS",              0x00000010);
-    emitX("ACE_EXECUTE",                        0x00000020);
-    emitX("ACE_DELETE_CHILD",                   0x00000040);
-    emitX("ACE_READ_ATTRIBUTES",                0x00000080);
-    emitX("ACE_WRITE_ATTRIBUTES",               0x00000100);
-    emitX("ACE_DELETE",                         0x00010000);
-    emitX("ACE_READ_ACL",                       0x00020000);
-    emitX("ACE_WRITE_ACL",                      0x00040000);
-    emitX("ACE_WRITE_OWNER",                    0x00080000);
-    emitX("ACE_SYNCHRONIZE",                    0x00100000);
-    emitX("ACE_FILE_INHERIT_ACE",               0x0001);
-    emitX("ACE_DIRECTORY_INHERIT_ACE",          0x0002);
-    emitX("ACE_NO_PROPAGATE_INHERIT_ACE",       0x0004);
-    emitX("ACE_INHERIT_ONLY_ACE",               0x0008);
-    emitX("ACE_SUCCESSFUL_ACCESS_ACE_FLAG",     0x0010);
-    emitX("ACE_FAILED_ACCESS_ACE_FLAG",         0x0020);
-    emitX("ACE_IDENTIFIER_GROUP",               0x0040);
-    emitX("ACE_OWNER",                          0x1000);
-    emitX("ACE_GROUP",                          0x2000);
-    emitX("ACE_EVERYONE",                       0x4000);
-
-    out("}                                                                              ");
-    return 0;
-}
--- a/jdk/make/src/native/genconstants/fs/genUnixConstants.c	Thu Mar 24 02:04:14 2016 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,142 +0,0 @@
-/*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-
-/**
- * Generates sun.nio.fs.UnixConstants
- */
-
-static void out(char* s) {
-    printf("%s\n", s);
-}
-
-static void emit(char* name, int value) {
-    printf("    static final int %s = %d;\n", name, value);
-}
-
-static void emitX(char* name, int value) {
-    printf("    static final int %s = 0x%x;\n", name, value);
-}
-
-#define DEF(X) emit(#X, X);
-#define DEFX(X) emitX(#X, X);
-
-int main(int argc, const char* argv[]) {
-    out("// AUTOMATICALLY GENERATED FILE - DO NOT EDIT                                  ");
-    out("package sun.nio.fs;                                                            ");
-    out("class UnixConstants {                                                          ");
-    out("    private UnixConstants() { }                                                ");
-
-    // open flags
-    DEF(O_RDONLY);
-    DEF(O_WRONLY);
-    DEF(O_RDWR);
-    DEFX(O_APPEND);
-    DEFX(O_CREAT);
-    DEFX(O_EXCL);
-    DEFX(O_TRUNC);
-    DEFX(O_SYNC);
-#ifndef O_DSYNC
-    // At least FreeBSD doesn't define O_DSYNC
-    emit("O_DSYNC", O_SYNC);
-#else
-    DEFX(O_DSYNC);
-#endif
-#ifdef O_NOFOLLOW
-    DEFX(O_NOFOLLOW);
-#else
-    // not supported (dummy values will not be used at runtime).
-    emitX("O_NOFOLLOW", 0x0);
-#endif
-
-    // mode masks
-    emitX("S_IAMB",
-         (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH));
-    DEF(S_IRUSR);
-    DEF(S_IWUSR);
-    DEF(S_IXUSR);
-    DEF(S_IRGRP);
-    DEF(S_IWGRP);
-    DEF(S_IXGRP);
-    DEF(S_IROTH);
-    DEF(S_IWOTH);
-    DEF(S_IXOTH);
-    DEFX(S_IFMT);
-    DEFX(S_IFREG);
-    DEFX(S_IFDIR);
-    DEFX(S_IFLNK);
-    DEFX(S_IFCHR);
-    DEFX(S_IFBLK);
-    DEFX(S_IFIFO);
-
-    // access modes
-    DEF(R_OK);
-    DEF(W_OK);
-    DEF(X_OK);
-    DEF(F_OK);
-
-    // errors
-    DEF(ENOENT);
-    DEF(ENXIO);
-    DEF(EACCES);
-    DEF(EEXIST);
-    DEF(ENOTDIR);
-    DEF(EINVAL);
-    DEF(EXDEV);
-    DEF(EISDIR);
-    DEF(ENOTEMPTY);
-    DEF(ENOSPC);
-    DEF(EAGAIN);
-    DEF(ENOSYS);
-    DEF(ELOOP);
-    DEF(EROFS);
-#ifndef ENODATA
-    // Only used in Linux java source, provide any value so it compiles
-    emit("ENODATA", ELAST);
-#else
-    DEF(ENODATA);
-#endif
-    DEF(ERANGE);
-    DEF(EMFILE);
-
-    // flags used with openat/unlinkat/etc.
-#if defined(AT_SYMLINK_NOFOLLOW) && defined(AT_REMOVEDIR)
-    DEFX(AT_SYMLINK_NOFOLLOW)
-    DEFX(AT_REMOVEDIR);
-#else
-    // not supported (dummy values will not be used at runtime).
-    emitX("AT_SYMLINK_NOFOLLOW", 0x0);
-    emitX("AT_REMOVEDIR", 0x0);
-#endif
-
-    out("}                                                                              ");
-
-    return 0;
-}
--- a/jdk/src/java.base/share/classes/java/io/ObjectInputStream.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/io/ObjectInputStream.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,7 @@
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
 import java.util.Arrays;
-import java.util.HashMap;
+import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import static java.io.ObjectStreamClass.processQueue;
@@ -212,20 +212,20 @@
     /** marker for unshared objects in internal handle table */
     private static final Object unsharedMarker = new Object();
 
-    /** table mapping primitive type names to corresponding class objects */
-    private static final HashMap<String, Class<?>> primClasses
-        = new HashMap<>(8, 1.0F);
-    static {
-        primClasses.put("boolean", boolean.class);
-        primClasses.put("byte", byte.class);
-        primClasses.put("char", char.class);
-        primClasses.put("short", short.class);
-        primClasses.put("int", int.class);
-        primClasses.put("long", long.class);
-        primClasses.put("float", float.class);
-        primClasses.put("double", double.class);
-        primClasses.put("void", void.class);
-    }
+    /**
+     * immutable table mapping primitive type names to corresponding
+     * class objects
+     */
+    private static final Map<String, Class<?>> primClasses =
+        Map.of("boolean", boolean.class,
+               "byte", byte.class,
+               "char", char.class,
+               "short", short.class,
+               "int", int.class,
+               "long", long.class,
+               "float", float.class,
+               "double", double.class,
+               "void", void.class);
 
     private static class Caches {
         /** cache of subclass security audit results */
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Mon Mar 28 08:41:54 2016 -0700
@@ -108,11 +108,14 @@
      * <p>
      * For now, the {@linkplain Lookup#lookupClass lookup class} of this lookup
      * object is in an unnamed module.
+     * Consequently, the lookup context of this lookup object will be the bootstrap
+     * class loader, which means it cannot find user classes.
      *
      * <p style="font-size:smaller;">
      * <em>Discussion:</em>
      * The lookup class can be changed to any other class {@code C} using an expression of the form
      * {@link Lookup#in publicLookup().in(C.class)}.
+     * but may change the lookup context by virtue of changing the class loader.
      * A public lookup object is always subject to
      * <a href="MethodHandles.Lookup.html#secmgr">security manager checks</a>.
      * Also, it cannot access
@@ -677,6 +680,11 @@
          * then no members, not even public members, will be accessible.
          * (In all other cases, public members will continue to be accessible.)
          * </ul>
+         * <p>
+         * The resulting lookup's capabilities for loading classes
+         * (used during {@link #findClass} invocations)
+         * are determined by the lookup class' loader,
+         * which may change due to this operation.
          *
          * @param requestedLookupClass the desired lookup class for the new lookup object
          * @return a lookup object which reports the desired lookup class
@@ -983,13 +991,17 @@
         /**
          * Looks up a class by name from the lookup context defined by this {@code Lookup} object. The static
          * initializer of the class is not run.
+         * <p>
+         * The lookup context here is determined by the {@linkplain #lookupClass() lookup class}, its class
+         * loader, and the {@linkplain #lookupModes() lookup modes}. In particular, the method first attempts to
+         * load the requested class, and then determines whether the class is accessible to this lookup object.
          *
          * @param targetName the fully qualified name of the class to be looked up.
          * @return the requested class.
          * @exception SecurityException if a security manager is present and it
          *            <a href="MethodHandles.Lookup.html#secmgr">refuses access</a>
          * @throws LinkageError if the linkage fails
-         * @throws ClassNotFoundException if the class does not exist.
+         * @throws ClassNotFoundException if the class cannot be loaded by the lookup class' loader.
          * @throws IllegalAccessException if the class is not accessible, using the allowed access
          * modes.
          * @exception SecurityException if a security manager is present and it
@@ -1004,6 +1016,9 @@
         /**
          * Determines if a class can be accessed from the lookup context defined by this {@code Lookup} object. The
          * static initializer of the class is not run.
+         * <p>
+         * The lookup context here is determined by the {@linkplain #lookupClass() lookup class} and the
+         * {@linkplain #lookupModes() lookup modes}.
          *
          * @param targetClass the class to be access-checked
          *
--- a/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1478,6 +1478,7 @@
      * that requires porting if there are private JDK changes occur.
      */
     private static final class MethodHandleInlineCopyStrategy {
+        static final Unsafe UNSAFE = Unsafe.getUnsafe();
 
         private MethodHandleInlineCopyStrategy() {
             // no instantiation
@@ -1512,10 +1513,9 @@
             mh = MethodHandles.dropArguments(NEW_STRING, 2, ptypes);
             mh = MethodHandles.dropArguments(mh, 0, int.class);
 
-            // In debug mode, check that remaining index is zero.
-            if (DEBUG) {
-                mh = MethodHandles.filterArgument(mh, 0, CHECK_INDEX);
-            }
+            // Safety: check that remaining index is zero -- that would mean the storage is completely
+            // overwritten, and no leakage of uninitialized data occurred.
+            mh = MethodHandles.filterArgument(mh, 0, CHECK_INDEX);
 
             // Mix in prependers. This happens when (int, byte[], byte) = (index, storage, coder) is already
             // known from the combinators below. We are assembling the string backwards, so "index" is the
@@ -1650,13 +1650,13 @@
 
         @ForceInline
         private static byte[] newArray(int length, byte coder) {
-            return new byte[length << coder];
+            return (byte[]) UNSAFE.allocateUninitializedArray(byte.class, length << coder);
         }
 
         @ForceInline
         private static int checkIndex(int index) {
             if (index != 0) {
-                throw new AssertionError("Exactness check failed: " + index + " characters left in the buffer.");
+                throw new IllegalStateException("Storage is not completely initialized, " + index + " bytes left");
             }
             return index;
         }
@@ -1721,12 +1721,7 @@
 
             NEW_STRING = lookupStatic(Lookup.IMPL_LOOKUP, STRING_HELPER, "newString", String.class, byte[].class, byte.class);
             NEW_ARRAY  = lookupStatic(Lookup.IMPL_LOOKUP, MethodHandleInlineCopyStrategy.class, "newArray", byte[].class, int.class, byte.class);
-
-            if (DEBUG) {
-                CHECK_INDEX = lookupStatic(Lookup.IMPL_LOOKUP, MethodHandleInlineCopyStrategy.class, "checkIndex", int.class, int.class);
-            } else {
-                CHECK_INDEX = null;
-            }
+            CHECK_INDEX = lookupStatic(Lookup.IMPL_LOOKUP, MethodHandleInlineCopyStrategy.class, "checkIndex", int.class, int.class);
         }
     }
 
--- a/jdk/src/java.base/share/classes/java/lang/reflect/Proxy.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Proxy.java	Mon Mar 28 08:41:54 2016 -0700
@@ -48,8 +48,8 @@
 
 import jdk.internal.loader.BootLoader;
 import jdk.internal.module.Modules;
+import jdk.internal.misc.Unsafe;
 import jdk.internal.misc.VM;
-import sun.misc.Unsafe;
 import sun.reflect.CallerSensitive;
 import sun.reflect.Reflection;
 import sun.reflect.misc.ReflectUtil;
--- a/jdk/src/java.base/share/classes/java/math/BigDecimal.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/math/BigDecimal.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -286,7 +286,7 @@
     private static final BigDecimal ZERO_THROUGH_TEN[] = {
         new BigDecimal(BigInteger.ZERO,       0,  0, 1),
         new BigDecimal(BigInteger.ONE,        1,  0, 1),
-        new BigDecimal(BigInteger.valueOf(2), 2,  0, 1),
+        new BigDecimal(BigInteger.TWO,        2,  0, 1),
         new BigDecimal(BigInteger.valueOf(3), 3,  0, 1),
         new BigDecimal(BigInteger.valueOf(4), 4,  0, 1),
         new BigDecimal(BigInteger.valueOf(5), 5,  0, 1),
@@ -936,7 +936,7 @@
                 rb = BigInteger.valueOf(5).pow(-exponent).multiply(compactVal);
                 scl = -exponent;
             } else { //  (exponent > 0)
-                rb = BigInteger.valueOf(2).pow(exponent).multiply(compactVal);
+                rb = BigInteger.TWO.pow(exponent).multiply(compactVal);
             }
             compactVal = compactValFor(rb);
         }
--- a/jdk/src/java.base/share/classes/java/math/BigInteger.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/math/BigInteger.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1266,9 +1266,11 @@
     public static final BigInteger ONE = valueOf(1);
 
     /**
-     * The BigInteger constant two.  (Not exported.)
+     * The BigInteger constant two.
+     *
+     * @since   9
      */
-    private static final BigInteger TWO = valueOf(2);
+    public static final BigInteger TWO = valueOf(2);
 
     /**
      * The BigInteger constant -1.  (Not exported.)
--- a/jdk/src/java.base/share/classes/java/net/URLClassLoader.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/net/URLClassLoader.java	Mon Mar 28 08:41:54 2016 -0700
@@ -49,11 +49,11 @@
 import java.util.jar.JarFile;
 import java.util.jar.Manifest;
 
+import jdk.internal.loader.Resource;
+import jdk.internal.loader.URLClassPath;
 import jdk.internal.misc.JavaNetAccess;
 import jdk.internal.misc.SharedSecrets;
 import jdk.internal.perf.PerfCounter;
-import sun.misc.Resource;
-import sun.misc.URLClassPath;
 import sun.net.www.ParseUtil;
 import sun.security.util.SecurityConstants;
 
--- a/jdk/src/java.base/share/classes/java/time/Instant.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/time/Instant.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1106,7 +1106,7 @@
      * complete units between the two instants.
      * The {@code Temporal} passed to this method is converted to a
      * {@code Instant} using {@link #from(TemporalAccessor)}.
-     * For example, the amount in days between two dates can be calculated
+     * For example, the amount in seconds between two dates can be calculated
      * using {@code startInstant.until(endInstant, SECONDS)}.
      * <p>
      * There are two equivalent ways of using this method.
--- a/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatter.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatter.java	Mon Mar 28 08:41:54 2016 -0700
@@ -619,6 +619,9 @@
      * The returned formatter has a chronology of ISO set to ensure dates in
      * other calendar systems are correctly converted.
      * It has no override zone and uses the {@link ResolverStyle#SMART SMART} resolver style.
+     * The {@code FULL} and {@code LONG} styles typically require a time-zone.
+     * When formatting using these styles, a {@code ZoneId} must be available,
+     * either by using {@code ZonedDateTime} or {@link DateTimeFormatter#withZone}.
      *
      * @param timeStyle  the formatter style to obtain, not null
      * @return the time formatter, not null
@@ -647,6 +650,9 @@
      * The returned formatter has a chronology of ISO set to ensure dates in
      * other calendar systems are correctly converted.
      * It has no override zone and uses the {@link ResolverStyle#SMART SMART} resolver style.
+     * The {@code FULL} and {@code LONG} styles typically require a time-zone.
+     * When formatting using these styles, a {@code ZoneId} must be available,
+     * either by using {@code ZonedDateTime} or {@link DateTimeFormatter#withZone}.
      *
      * @param dateTimeStyle  the formatter style to obtain, not null
      * @return the date-time formatter, not null
@@ -675,6 +681,9 @@
      * The returned formatter has a chronology of ISO set to ensure dates in
      * other calendar systems are correctly converted.
      * It has no override zone and uses the {@link ResolverStyle#SMART SMART} resolver style.
+     * The {@code FULL} and {@code LONG} styles typically require a time-zone.
+     * When formatting using these styles, a {@code ZoneId} must be available,
+     * either by using {@code ZonedDateTime} or {@link DateTimeFormatter#withZone}.
      *
      * @param dateStyle  the date formatter style to obtain, not null
      * @param timeStyle  the time formatter style to obtain, not null
@@ -923,6 +932,7 @@
      * <li>The {@link #ISO_LOCAL_DATE_TIME}
      * <li>The {@link ZoneOffset#getId() offset ID}. If the offset has seconds then
      *  they will be handled even though this is not part of the ISO-8601 standard.
+     *  The offset parsing is lenient, which allows the minutes and seconds to be optional.
      *  Parsing is case insensitive.
      * </ul>
      * <p>
@@ -935,7 +945,9 @@
         ISO_OFFSET_DATE_TIME = new DateTimeFormatterBuilder()
                 .parseCaseInsensitive()
                 .append(ISO_LOCAL_DATE_TIME)
+                .parseLenient()
                 .appendOffsetId()
+                .parseStrict()
                 .toFormatter(ResolverStyle.STRICT, IsoChronology.INSTANCE);
     }
 
@@ -1160,6 +1172,7 @@
      * <li>If the offset is not available to format or parse then the format is complete.
      * <li>The {@link ZoneOffset#getId() offset ID} without colons. If the offset has
      *  seconds then they will be handled even though this is not part of the ISO-8601 standard.
+     *  The offset parsing is lenient, which allows the minutes and seconds to be optional.
      *  Parsing is case insensitive.
      * </ul>
      * <p>
@@ -1178,7 +1191,9 @@
                 .appendValue(MONTH_OF_YEAR, 2)
                 .appendValue(DAY_OF_MONTH, 2)
                 .optionalStart()
+                .parseLenient()
                 .appendOffset("+HHMMss", "Z")
+                .parseStrict()
                 .toFormatter(ResolverStyle.STRICT, IsoChronology.INSTANCE);
     }
 
--- a/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java	Mon Mar 28 08:41:54 2016 -0700
@@ -866,7 +866,9 @@
      * Appends the zone offset, such as '+01:00', to the formatter.
      * <p>
      * This appends an instruction to format/parse the offset ID to the builder.
-     * This is equivalent to calling {@code appendOffset("+HH:MM:ss", "Z")}.
+     * This is equivalent to calling {@code appendOffset("+HH:mm:ss", "Z")}.
+     * See {@link #appendOffset(String, String)} for details on formatting
+     * and parsing.
      *
      * @return this, for chaining, not null
      */
@@ -886,9 +888,18 @@
      * If the offset cannot be obtained then an exception is thrown unless the
      * section of the formatter is optional.
      * <p>
-     * During parsing, the offset is parsed using the format defined below.
-     * If the offset cannot be parsed then an exception is thrown unless the
-     * section of the formatter is optional.
+     * When parsing in strict mode, the input must contain the mandatory
+     * and optional elements are defined by the specified pattern.
+     * If the offset cannot be parsed then an exception is thrown unless
+     * the section of the formatter is optional.
+     * <p>
+     * When parsing in lenient mode, only the hours are mandatory - minutes
+     * and seconds are optional. The colons are required if the specified
+     * pattern contains a colon. If the specified pattern is "+HH", the
+     * presence of colons is determined by whether the character after the
+     * hour digits is a colon or not.
+     * If the offset cannot be parsed then an exception is thrown unless
+     * the section of the formatter is optional.
      * <p>
      * The format of the offset is controlled by a pattern which must be one
      * of the following:
@@ -902,6 +913,10 @@
      * <li>{@code +HH:MM:ss} - hour and minute, with second if non-zero, with colon
      * <li>{@code +HHMMSS} - hour, minute and second, no colon
      * <li>{@code +HH:MM:SS} - hour, minute and second, with colon
+     * <li>{@code +HHmmss} - hour, with minute if non-zero or with minute and
+     * second if non-zero, no colon
+     * <li>{@code +HH:mm:ss} - hour, with minute if non-zero or with minute and
+     * second if non-zero, with colon
      * </ul>
      * The "no offset" text controls what text is printed when the total amount of
      * the offset fields to be output is zero.
@@ -1256,6 +1271,9 @@
      * During formatting, the chronology is obtained from the temporal object
      * being formatted, which may have been overridden by
      * {@link DateTimeFormatter#withChronology(Chronology)}.
+     * The {@code FULL} and {@code LONG} styles typically require a time-zone.
+     * When formatting using these styles, a {@code ZoneId} must be available,
+     * either by using {@code ZonedDateTime} or {@link DateTimeFormatter#withZone}.
      * <p>
      * During parsing, if a chronology has already been parsed, then it is used.
      * Otherwise the default from {@code DateTimeFormatter.withChronology(Chronology)}
@@ -3315,7 +3333,7 @@
      */
     static final class OffsetIdPrinterParser implements DateTimePrinterParser {
         static final String[] PATTERNS = new String[] {
-            "+HH", "+HHmm", "+HH:mm", "+HHMM", "+HH:MM", "+HHMMss", "+HH:MM:ss", "+HHMMSS", "+HH:MM:SS",
+            "+HH", "+HHmm", "+HH:mm", "+HHMM", "+HH:MM", "+HHMMss", "+HH:MM:ss", "+HHMMSS", "+HH:MM:SS", "+HHmmss", "+HH:mm:ss",
         };  // order used in pattern builder
         static final OffsetIdPrinterParser INSTANCE_ID_Z = new OffsetIdPrinterParser("+HH:MM:ss", "Z");
         static final OffsetIdPrinterParser INSTANCE_ID_ZERO = new OffsetIdPrinterParser("+HH:MM:ss", "0");
@@ -3362,11 +3380,11 @@
                 int output = absHours;
                 buf.append(totalSecs < 0 ? "-" : "+")
                     .append((char) (absHours / 10 + '0')).append((char) (absHours % 10 + '0'));
-                if (type >= 3 || (type >= 1 && absMinutes > 0)) {
+                if ((type >= 3 && type < 9) || (type >= 9 && absSeconds > 0) || (type >= 1 && absMinutes > 0)) {
                     buf.append((type % 2) == 0 ? ":" : "")
                         .append((char) (absMinutes / 10 + '0')).append((char) (absMinutes % 10 + '0'));
                     output += absMinutes;
-                    if (type >= 7 || (type >= 5 && absSeconds > 0)) {
+                    if (type == 7  || type == 8 || (type >= 5 && absSeconds > 0)) {
                         buf.append((type % 2) == 0 ? ":" : "")
                             .append((char) (absSeconds / 10 + '0')).append((char) (absSeconds % 10 + '0'));
                         output += absSeconds;
@@ -3384,6 +3402,15 @@
         public int parse(DateTimeParseContext context, CharSequence text, int position) {
             int length = text.length();
             int noOffsetLen = noOffsetText.length();
+            int parseType = type;
+            if (context.isStrict() == false) {
+                if ((parseType > 0 && (parseType % 2) == 0) ||
+                    (parseType == 0 && length > position + 3 && text.charAt(position + 3) == ':')) {
+                    parseType = 10;
+                } else {
+                    parseType = 9;
+                }
+            }
             if (noOffsetLen == 0) {
                 if (position == length) {
                     return context.setParsedField(OFFSET_SECONDS, 0, position, position);
@@ -3404,9 +3431,9 @@
                 int negative = (sign == '-' ? -1 : 1);
                 int[] array = new int[4];
                 array[0] = position + 1;
-                if ((parseNumber(array, 1, text, true) ||
-                        parseNumber(array, 2, text, type >=3) ||
-                        parseNumber(array, 3, text, false)) == false) {
+                if ((parseNumber(array, 1, text, true, parseType) ||
+                        parseNumber(array, 2, text, parseType >= 3 && parseType < 9, parseType) ||
+                        parseNumber(array, 3, text, parseType == 7 || parseType == 8, parseType)) == false) {
                     // success
                     long offsetSecs = negative * (array[1] * 3600L + array[2] * 60L + array[3]);
                     return context.setParsedField(OFFSET_SECONDS, offsetSecs, position, array[0]);
@@ -3414,7 +3441,7 @@
             }
             // handle special case of empty no offset text
             if (noOffsetLen == 0) {
-                return context.setParsedField(OFFSET_SECONDS, 0, position, position + noOffsetLen);
+                return context.setParsedField(OFFSET_SECONDS, 0, position, position);
             }
             return ~position;
         }
@@ -3426,14 +3453,15 @@
          * @param arrayIndex  the index to parse the value into
          * @param parseText  the offset ID, not null
          * @param required  whether this number is required
+         * @param parseType the offset pattern type
          * @return true if an error occurred
          */
-        private boolean parseNumber(int[] array, int arrayIndex, CharSequence parseText, boolean required) {
-            if ((type + 3) / 2 < arrayIndex) {
+        private boolean parseNumber(int[] array, int arrayIndex, CharSequence parseText, boolean required, int parseType) {
+            if ((parseType + 3) / 2 < arrayIndex) {
                 return false;  // ignore seconds/minutes
             }
             int pos = array[0];
-            if ((type % 2) == 0 && arrayIndex > 1) {
+            if ((parseType % 2) == 0 && arrayIndex > 1) {
                 if (pos + 1 > parseText.length() || parseText.charAt(pos) != ':') {
                     return required;
                 }
--- a/jdk/src/java.base/share/classes/java/time/format/DateTimePrintContext.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/time/format/DateTimePrintContext.java	Mon Mar 28 08:41:54 2016 -0700
@@ -218,6 +218,13 @@
                 }
                 return query.queryFrom(this);
             }
+
+            @Override
+            public String toString() {
+                return temporal +
+                        (effectiveChrono != null ? " with chronology " + effectiveChrono : "") +
+                        (effectiveZone != null ? " with zone " + effectiveZone : "");
+            }
         };
     }
 
@@ -279,7 +286,8 @@
     <R> R getValue(TemporalQuery<R> query) {
         R result = temporal.query(query);
         if (result == null && optional == 0) {
-            throw new DateTimeException("Unable to extract value: " + temporal.getClass());
+            throw new DateTimeException("Unable to extract " +
+                    query + " from temporal " + temporal);
         }
         return result;
     }
--- a/jdk/src/java.base/share/classes/java/time/temporal/TemporalQueries.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/time/temporal/TemporalQueries.java	Mon Mar 28 08:41:54 2016 -0700
@@ -341,58 +341,118 @@
     /**
      * A strict query for the {@code ZoneId}.
      */
-    static final TemporalQuery<ZoneId> ZONE_ID = (temporal) ->
-        temporal.query(TemporalQueries.ZONE_ID);
+    static final TemporalQuery<ZoneId> ZONE_ID = new TemporalQuery<>() {
+        @Override
+        public ZoneId queryFrom(TemporalAccessor temporal) {
+            return temporal.query(TemporalQueries.ZONE_ID);
+        }
+
+        @Override
+        public String toString() {
+            return "ZoneId";
+        }
+    };
 
     /**
      * A query for the {@code Chronology}.
      */
-    static final TemporalQuery<Chronology> CHRONO = (temporal) ->
-        temporal.query(TemporalQueries.CHRONO);
+    static final TemporalQuery<Chronology> CHRONO = new TemporalQuery<>() {
+        @Override
+        public Chronology queryFrom(TemporalAccessor temporal) {
+            return temporal.query(TemporalQueries.CHRONO);
+        }
+
+        @Override
+        public String toString() {
+            return "Chronology";
+        }
+    };
+
 
     /**
      * A query for the smallest supported unit.
      */
-    static final TemporalQuery<TemporalUnit> PRECISION = (temporal) ->
-        temporal.query(TemporalQueries.PRECISION);
+    static final TemporalQuery<TemporalUnit> PRECISION = new TemporalQuery<>() {
+        @Override
+        public TemporalUnit queryFrom(TemporalAccessor temporal) {
+            return temporal.query(TemporalQueries.PRECISION);
+        }
+
+        @Override
+        public String toString() {
+            return "Precision";
+        }
+    };
 
     //-----------------------------------------------------------------------
     /**
      * A query for {@code ZoneOffset} returning null if not found.
      */
-    static final TemporalQuery<ZoneOffset> OFFSET = (temporal) -> {
-        if (temporal.isSupported(OFFSET_SECONDS)) {
-            return ZoneOffset.ofTotalSeconds(temporal.get(OFFSET_SECONDS));
+    static final TemporalQuery<ZoneOffset> OFFSET = new TemporalQuery<>() {
+        @Override
+        public ZoneOffset queryFrom(TemporalAccessor temporal) {
+            if (temporal.isSupported(OFFSET_SECONDS)) {
+                return ZoneOffset.ofTotalSeconds(temporal.get(OFFSET_SECONDS));
+            }
+            return null;
         }
-        return null;
+
+        @Override
+        public String toString() {
+            return "ZoneOffset";
+        }
     };
 
     /**
      * A lenient query for the {@code ZoneId}, falling back to the {@code ZoneOffset}.
      */
-    static final TemporalQuery<ZoneId> ZONE = (temporal) -> {
-        ZoneId zone = temporal.query(ZONE_ID);
-        return (zone != null ? zone : temporal.query(OFFSET));
+    static final TemporalQuery<ZoneId> ZONE = new TemporalQuery<>() {
+        @Override
+        public ZoneId queryFrom(TemporalAccessor temporal) {
+            ZoneId zone = temporal.query(ZONE_ID);
+            return (zone != null ? zone : temporal.query(OFFSET));
+        }
+
+        @Override
+        public String toString() {
+            return "Zone";
+        }
     };
 
     /**
      * A query for {@code LocalDate} returning null if not found.
      */
-    static final TemporalQuery<LocalDate> LOCAL_DATE = (temporal) -> {
-        if (temporal.isSupported(EPOCH_DAY)) {
-            return LocalDate.ofEpochDay(temporal.getLong(EPOCH_DAY));
+    static final TemporalQuery<LocalDate> LOCAL_DATE = new TemporalQuery<>() {
+        @Override
+        public LocalDate queryFrom(TemporalAccessor temporal) {
+            if (temporal.isSupported(EPOCH_DAY)) {
+                return LocalDate.ofEpochDay(temporal.getLong(EPOCH_DAY));
+            }
+            return null;
         }
-        return null;
+
+        @Override
+        public String toString() {
+            return "LocalDate";
+        }
     };
 
     /**
      * A query for {@code LocalTime} returning null if not found.
      */
-    static final TemporalQuery<LocalTime> LOCAL_TIME = (temporal) -> {
-        if (temporal.isSupported(NANO_OF_DAY)) {
-            return LocalTime.ofNanoOfDay(temporal.getLong(NANO_OF_DAY));
+    static final TemporalQuery<LocalTime> LOCAL_TIME = new TemporalQuery<>() {
+        @Override
+        public LocalTime queryFrom(TemporalAccessor temporal) {
+            if (temporal.isSupported(NANO_OF_DAY)) {
+                return LocalTime.ofNanoOfDay(temporal.getLong(NANO_OF_DAY));
+            }
+            return null;
         }
-        return null;
+
+        @Override
+        public String toString() {
+            return "LocalTime";
+        }
     };
 
 }
--- a/jdk/src/java.base/share/classes/java/util/ArrayList.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/util/ArrayList.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1281,8 +1281,74 @@
 
         public Spliterator<E> spliterator() {
             checkForComodification();
-            return new ArrayListSpliterator<>(ArrayList.this, offset,
-                                              offset + this.size, this.modCount);
+
+            return new Spliterator<>() {
+                private int index = offset; // current index, modified on advance/split
+                private int fence = -1; // -1 until used; then one past last index
+                private int expectedModCount; // initialized when fence set
+
+                private int getFence() { // initialize fence to size on first use
+                    int hi; // (a specialized variant appears in method forEach)
+                    if ((hi = fence) < 0) {
+                        expectedModCount = modCount;
+                        hi = fence = offset + size;
+                    }
+                    return hi;
+                }
+
+                public ArrayListSpliterator<E> trySplit() {
+                    int hi = getFence(), lo = index, mid = (lo + hi) >>> 1;
+                    return (lo >= mid) ? null : // divide range in half unless too small
+                        new ArrayListSpliterator<>(ArrayList.this, lo, index = mid,
+                                                   expectedModCount);
+                }
+
+                public boolean tryAdvance(Consumer<? super E> action) {
+                    Objects.requireNonNull(action);
+                    int hi = getFence(), i = index;
+                    if (i < hi) {
+                        index = i + 1;
+                        @SuppressWarnings("unchecked") E e = (E)elementData[i];
+                        action.accept(e);
+                        if (ArrayList.this.modCount != expectedModCount)
+                            throw new ConcurrentModificationException();
+                        return true;
+                    }
+                    return false;
+                }
+
+                public void forEachRemaining(Consumer<? super E> action) {
+                    Objects.requireNonNull(action);
+                    int i, hi, mc; // hoist accesses and checks from loop
+                    ArrayList<E> lst = ArrayList.this;
+                    Object[] a;
+                    if ((a = lst.elementData) != null) {
+                        if ((hi = fence) < 0) {
+                            mc = modCount;
+                            hi = offset + size;
+                        }
+                        else
+                            mc = expectedModCount;
+                        if ((i = index) >= 0 && (index = hi) <= a.length) {
+                            for (; i < hi; ++i) {
+                                @SuppressWarnings("unchecked") E e = (E) a[i];
+                                action.accept(e);
+                            }
+                            if (lst.modCount == mc)
+                                return;
+                        }
+                    }
+                    throw new ConcurrentModificationException();
+                }
+
+                public long estimateSize() {
+                    return (long) (getFence() - index);
+                }
+
+                public int characteristics() {
+                    return Spliterator.ORDERED | Spliterator.SIZED | Spliterator.SUBSIZED;
+                }
+            };
         }
     }
 
--- a/jdk/src/java.base/share/classes/java/util/EnumMap.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/util/EnumMap.java	Mon Mar 28 08:41:54 2016 -0700
@@ -718,7 +718,7 @@
     }
 
     /**
-     * Returns a shallow copy of this enum map.  (The values themselves
+     * Returns a shallow copy of this enum map. The values themselves
      * are not cloned.
      *
      * @return a shallow copy of this enum map
--- a/jdk/src/java.base/share/classes/java/util/stream/Collectors.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/util/stream/Collectors.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -656,8 +656,9 @@
          */
         return new CollectorImpl<>(
                 () -> new double[3],
-                (a, t) -> { sumWithCompensation(a, mapper.applyAsDouble(t));
-                            a[2] += mapper.applyAsDouble(t);},
+                (a, t) -> { double val = mapper.applyAsDouble(t);
+                            sumWithCompensation(a, val);
+                            a[2] += val;},
                 (a, b) -> { sumWithCompensation(a, b[0]);
                             a[2] += b[2];
                             return sumWithCompensation(a, b[1]); },
@@ -768,7 +769,7 @@
          */
         return new CollectorImpl<>(
                 () -> new double[4],
-                (a, t) -> { sumWithCompensation(a, mapper.applyAsDouble(t)); a[2]++; a[3]+= mapper.applyAsDouble(t);},
+                (a, t) -> { double val = mapper.applyAsDouble(t); sumWithCompensation(a, val); a[2]++; a[3]+= val;},
                 (a, b) -> { sumWithCompensation(a, b[0]); sumWithCompensation(a, b[1]); a[2] += b[2]; a[3] += b[3]; return a; },
                 a -> (a[2] == 0) ? 0.0d : (computeFinalSum(a) / a[2]),
                 CH_NOID);
--- a/jdk/src/java.base/share/classes/java/util/stream/PipelineHelper.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/java/util/stream/PipelineHelper.java	Mon Mar 28 08:41:54 2016 -0700
@@ -98,7 +98,7 @@
      * @implSpec
      * The implementation behaves as if:
      * <pre>{@code
-     *     intoWrapped(wrapSink(sink), spliterator);
+     *     copyInto(wrapSink(sink), spliterator);
      * }</pre>
      *
      * @param sink the {@code Sink} to receive the results
--- a/jdk/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java	Mon Mar 28 08:41:54 2016 -0700
@@ -56,8 +56,6 @@
 
 import jdk.internal.module.ModulePatcher.PatchedModuleReader;
 import jdk.internal.misc.VM;
-import sun.misc.URLClassPath;
-import sun.misc.Resource;
 
 
 /**
--- a/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java	Mon Mar 28 08:41:54 2016 -0700
@@ -38,7 +38,6 @@
 import jdk.internal.misc.JavaLangAccess;
 import jdk.internal.misc.SharedSecrets;
 import jdk.internal.misc.VM;
-import sun.misc.URLClassPath;
 
 
 /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/loader/Resource.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,188 @@
+/*
+ * Copyright (c) 1998, 2009, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.internal.loader;
+
+import java.io.EOFException;
+import java.net.URL;
+import java.io.IOException;
+import java.io.InterruptedIOException;
+import java.io.InputStream;
+import java.security.CodeSigner;
+import java.util.jar.Manifest;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import sun.nio.ByteBuffered;
+
+/**
+ * This class is used to represent a Resource that has been loaded
+ * from the class path.
+ *
+ * @author  David Connelly
+ * @since   1.2
+ */
+public abstract class Resource {
+    /**
+     * Returns the name of the Resource.
+     */
+    public abstract String getName();
+
+    /**
+     * Returns the URL of the Resource.
+     */
+    public abstract URL getURL();
+
+    /**
+     * Returns the CodeSource URL for the Resource.
+     */
+    public abstract URL getCodeSourceURL();
+
+    /**
+     * Returns an InputStream for reading the Resource data.
+     */
+    public abstract InputStream getInputStream() throws IOException;
+
+    /**
+     * Returns the length of the Resource data, or -1 if unknown.
+     */
+    public abstract int getContentLength() throws IOException;
+
+    private InputStream cis;
+
+    /* Cache result in case getBytes is called after getByteBuffer. */
+    private synchronized InputStream cachedInputStream() throws IOException {
+        if (cis == null) {
+            cis = getInputStream();
+        }
+        return cis;
+    }
+
+    /**
+     * Returns the Resource data as an array of bytes.
+     */
+    public byte[] getBytes() throws IOException {
+        byte[] b;
+        // Get stream before content length so that a FileNotFoundException
+        // can propagate upwards without being caught too early
+        InputStream in = cachedInputStream();
+
+        // This code has been uglified to protect against interrupts.
+        // Even if a thread has been interrupted when loading resources,
+        // the IO should not abort, so must carefully retry, failing only
+        // if the retry leads to some other IO exception.
+
+        boolean isInterrupted = Thread.interrupted();
+        int len;
+        for (;;) {
+            try {
+                len = getContentLength();
+                break;
+            } catch (InterruptedIOException iioe) {
+                Thread.interrupted();
+                isInterrupted = true;
+            }
+        }
+
+        try {
+            b = new byte[0];
+            if (len == -1) len = Integer.MAX_VALUE;
+            int pos = 0;
+            while (pos < len) {
+                int bytesToRead;
+                if (pos >= b.length) { // Only expand when there's no room
+                    bytesToRead = Math.min(len - pos, b.length + 1024);
+                    if (b.length < pos + bytesToRead) {
+                        b = Arrays.copyOf(b, pos + bytesToRead);
+                    }
+                } else {
+                    bytesToRead = b.length - pos;
+                }
+                int cc = 0;
+                try {
+                    cc = in.read(b, pos, bytesToRead);
+                } catch (InterruptedIOException iioe) {
+                    Thread.interrupted();
+                    isInterrupted = true;
+                }
+                if (cc < 0) {
+                    if (len != Integer.MAX_VALUE) {
+                        throw new EOFException("Detect premature EOF");
+                    } else {
+                        if (b.length != pos) {
+                            b = Arrays.copyOf(b, pos);
+                        }
+                        break;
+                    }
+                }
+                pos += cc;
+            }
+        } finally {
+            try {
+                in.close();
+            } catch (InterruptedIOException iioe) {
+                isInterrupted = true;
+            } catch (IOException ignore) {}
+
+            if (isInterrupted) {
+                Thread.currentThread().interrupt();
+            }
+        }
+        return b;
+    }
+
+    /**
+     * Returns the Resource data as a ByteBuffer, but only if the input stream
+     * was implemented on top of a ByteBuffer. Return {@code null} otherwise.
+     * @return Resource data or null.
+     */
+    public ByteBuffer getByteBuffer() throws IOException {
+        InputStream in = cachedInputStream();
+        if (in instanceof ByteBuffered) {
+            return ((ByteBuffered)in).getByteBuffer();
+        }
+        return null;
+    }
+
+    /**
+     * Returns the Manifest for the Resource, or null if none.
+     */
+    public Manifest getManifest() throws IOException {
+        return null;
+    }
+
+    /**
+     * Returns theCertificates for the Resource, or null if none.
+     */
+    public java.security.cert.Certificate[] getCertificates() {
+        return null;
+    }
+
+    /**
+     * Returns the code signers for the Resource, or null if none.
+     */
+    public CodeSigner[] getCodeSigners() {
+        return null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/loader/URLClassPath.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,1052 @@
+/*
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.internal.loader;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.JarURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+import java.net.URLStreamHandlerFactory;
+import java.security.AccessControlException;
+import java.security.AccessController;
+import java.security.CodeSigner;
+import java.security.Permission;
+import java.security.PrivilegedExceptionAction;
+import java.security.cert.Certificate;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import java.util.Stack;
+import java.util.StringTokenizer;
+import java.util.jar.JarFile;
+import java.util.zip.ZipEntry;
+import java.util.jar.JarEntry;
+import java.util.jar.Manifest;
+import java.util.jar.Attributes;
+import java.util.jar.Attributes.Name;
+import java.util.zip.ZipFile;
+
+import jdk.internal.misc.JavaUtilZipFileAccess;
+import jdk.internal.misc.SharedSecrets;
+import sun.misc.InvalidJarIndexException;
+import sun.misc.JarIndex;
+import sun.net.util.URLUtil;
+import sun.net.www.ParseUtil;
+
+/**
+ * This class is used to maintain a search path of URLs for loading classes
+ * and resources from both JAR files and directories.
+ *
+ * @author  David Connelly
+ */
+public class URLClassPath {
+    private static final String USER_AGENT_JAVA_VERSION = "UA-Java-Version";
+    private static final String JAVA_HOME;
+    private static final String JAVA_VERSION;
+    private static final boolean DEBUG;
+    private static final boolean DISABLE_JAR_CHECKING;
+
+    static {
+        JAVA_HOME = java.security.AccessController.doPrivileged(
+            new sun.security.action.GetPropertyAction("java.home"));
+        JAVA_VERSION = java.security.AccessController.doPrivileged(
+            new sun.security.action.GetPropertyAction("java.version"));
+        DEBUG        = (java.security.AccessController.doPrivileged(
+            new sun.security.action.GetPropertyAction("sun.misc.URLClassPath.debug")) != null);
+        String p = java.security.AccessController.doPrivileged(
+            new sun.security.action.GetPropertyAction("sun.misc.URLClassPath.disableJarChecking"));
+        DISABLE_JAR_CHECKING = p != null ? p.equals("true") || p.equals("") : false;
+    }
+
+    /* The original search path of URLs. */
+    private ArrayList<URL> path = new ArrayList<>();
+
+    /* The stack of unopened URLs */
+    Stack<URL> urls = new Stack<>();
+
+    /* The resulting search path of Loaders */
+    ArrayList<Loader> loaders = new ArrayList<>();
+
+    /* Map of each URL opened to its corresponding Loader */
+    HashMap<String, Loader> lmap = new HashMap<>();
+
+    /* The jar protocol handler to use when creating new URLs */
+    private URLStreamHandler jarHandler;
+
+    /* Whether this URLClassLoader has been closed yet */
+    private boolean closed = false;
+
+    /**
+     * Creates a new URLClassPath for the given URLs. The URLs will be
+     * searched in the order specified for classes and resources. A URL
+     * ending with a '/' is assumed to refer to a directory. Otherwise,
+     * the URL is assumed to refer to a JAR file.
+     *
+     * @param urls the directory and JAR file URLs to search for classes
+     *        and resources
+     * @param factory the URLStreamHandlerFactory to use when creating new URLs
+     */
+    public URLClassPath(URL[] urls, URLStreamHandlerFactory factory) {
+        for (int i = 0; i < urls.length; i++) {
+            path.add(urls[i]);
+        }
+        push(urls);
+        if (factory != null) {
+            jarHandler = factory.createURLStreamHandler("jar");
+        }
+    }
+
+    public URLClassPath(URL[] urls) {
+        this(urls, null);
+    }
+
+    public synchronized List<IOException> closeLoaders() {
+        if (closed) {
+            return Collections.emptyList();
+        }
+        List<IOException> result = new LinkedList<>();
+        for (Loader loader : loaders) {
+            try {
+                loader.close();
+            } catch (IOException e) {
+                result.add (e);
+            }
+        }
+        closed = true;
+        return result;
+    }
+
+    /**
+     * Appends the specified URL to the search path of directory and JAR
+     * file URLs from which to load classes and resources.
+     * <p>
+     * If the URL specified is null or is already in the list of
+     * URLs, then invoking this method has no effect.
+     */
+    public synchronized void addURL(URL url) {
+        if (closed)
+            return;
+        synchronized (urls) {
+            if (url == null || path.contains(url))
+                return;
+
+            urls.add(0, url);
+            path.add(url);
+        }
+    }
+
+    /**
+     * Returns the original search path of URLs.
+     */
+    public URL[] getURLs() {
+        synchronized (urls) {
+            return path.toArray(new URL[path.size()]);
+        }
+    }
+
+    /**
+     * Finds the resource with the specified name on the URL search path
+     * or null if not found or security check fails.
+     *
+     * @param name      the name of the resource
+     * @param check     whether to perform a security check
+     * @return a <code>URL</code> for the resource, or <code>null</code>
+     * if the resource could not be found.
+     */
+    public URL findResource(String name, boolean check) {
+        Loader loader;
+        for (int i = 0; (loader = getLoader(i)) != null; i++) {
+            URL url = loader.findResource(name, check);
+            if (url != null) {
+                return url;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Finds the first Resource on the URL search path which has the specified
+     * name. Returns null if no Resource could be found.
+     *
+     * @param name the name of the Resource
+     * @param check     whether to perform a security check
+     * @return the Resource, or null if not found
+     */
+    public Resource getResource(String name, boolean check) {
+        if (DEBUG) {
+            System.err.println("URLClassPath.getResource(\"" + name + "\")");
+        }
+
+        Loader loader;
+        for (int i = 0; (loader = getLoader(i)) != null; i++) {
+            Resource res = loader.getResource(name, check);
+            if (res != null) {
+                return res;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Finds all resources on the URL search path with the given name.
+     * Returns an enumeration of the URL objects.
+     *
+     * @param name the resource name
+     * @return an Enumeration of all the urls having the specified name
+     */
+    public Enumeration<URL> findResources(final String name,
+                                     final boolean check) {
+        return new Enumeration<>() {
+            private int index = 0;
+            private URL url = null;
+
+            private boolean next() {
+                if (url != null) {
+                    return true;
+                } else {
+                    Loader loader;
+                    while ((loader = getLoader(index++)) != null) {
+                        url = loader.findResource(name, check);
+                        if (url != null) {
+                            return true;
+                        }
+                    }
+                    return false;
+                }
+            }
+
+            public boolean hasMoreElements() {
+                return next();
+            }
+
+            public URL nextElement() {
+                if (!next()) {
+                    throw new NoSuchElementException();
+                }
+                URL u = url;
+                url = null;
+                return u;
+            }
+        };
+    }
+
+    public Resource getResource(String name) {
+        return getResource(name, true);
+    }
+
+    /**
+     * Finds all resources on the URL search path with the given name.
+     * Returns an enumeration of the Resource objects.
+     *
+     * @param name the resource name
+     * @return an Enumeration of all the resources having the specified name
+     */
+    public Enumeration<Resource> getResources(final String name,
+                                    final boolean check) {
+        return new Enumeration<>() {
+            private int index = 0;
+            private Resource res = null;
+
+            private boolean next() {
+                if (res != null) {
+                    return true;
+                } else {
+                    Loader loader;
+                    while ((loader = getLoader(index++)) != null) {
+                        res = loader.getResource(name, check);
+                        if (res != null) {
+                            return true;
+                        }
+                    }
+                    return false;
+                }
+            }
+
+            public boolean hasMoreElements() {
+                return next();
+            }
+
+            public Resource nextElement() {
+                if (!next()) {
+                    throw new NoSuchElementException();
+                }
+                Resource r = res;
+                res = null;
+                return r;
+            }
+        };
+    }
+
+    public Enumeration<Resource> getResources(final String name) {
+        return getResources(name, true);
+    }
+
+    /*
+     * Returns the Loader at the specified position in the URL search
+     * path. The URLs are opened and expanded as needed. Returns null
+     * if the specified index is out of range.
+     */
+     private synchronized Loader getLoader(int index) {
+        if (closed) {
+            return null;
+        }
+         // Expand URL search path until the request can be satisfied
+         // or the URL stack is empty.
+        while (loaders.size() < index + 1) {
+            // Pop the next URL from the URL stack
+            URL url;
+            synchronized (urls) {
+                if (urls.empty()) {
+                    return null;
+                } else {
+                    url = urls.pop();
+                }
+            }
+            // Skip this URL if it already has a Loader. (Loader
+            // may be null in the case where URL has not been opened
+            // but is referenced by a JAR index.)
+            String urlNoFragString = URLUtil.urlNoFragString(url);
+            if (lmap.containsKey(urlNoFragString)) {
+                continue;
+            }
+            // Otherwise, create a new Loader for the URL.
+            Loader loader;
+            try {
+                loader = getLoader(url);
+                // If the loader defines a local class path then add the
+                // URLs to the list of URLs to be opened.
+                URL[] urls = loader.getClassPath();
+                if (urls != null) {
+                    push(urls);
+                }
+            } catch (IOException e) {
+                // Silently ignore for now...
+                continue;
+            }
+            // Finally, add the Loader to the search path.
+            loaders.add(loader);
+            lmap.put(urlNoFragString, loader);
+        }
+        return loaders.get(index);
+    }
+
+    /*
+     * Returns the Loader for the specified base URL.
+     */
+    private Loader getLoader(final URL url) throws IOException {
+        try {
+            return java.security.AccessController.doPrivileged(
+                new java.security.PrivilegedExceptionAction<>() {
+                public Loader run() throws IOException {
+                    String file = url.getFile();
+                    if (file != null && file.endsWith("/")) {
+                        if ("file".equals(url.getProtocol())) {
+                            return new FileLoader(url);
+                        } else {
+                            return new Loader(url);
+                        }
+                    } else {
+                        return new JarLoader(url, jarHandler, lmap);
+                    }
+                }
+            });
+        } catch (java.security.PrivilegedActionException pae) {
+            throw (IOException)pae.getException();
+        }
+    }
+
+    /*
+     * Pushes the specified URLs onto the list of unopened URLs.
+     */
+    private void push(URL[] us) {
+        synchronized (urls) {
+            for (int i = us.length - 1; i >= 0; --i) {
+                urls.push(us[i]);
+            }
+        }
+    }
+
+    /*
+     * Check whether the resource URL should be returned.
+     * Return null on security check failure.
+     * Called by java.net.URLClassLoader.
+     */
+    public static URL checkURL(URL url) {
+        if (url != null) {
+            try {
+                check(url);
+            } catch (Exception e) {
+                return null;
+            }
+        }
+        return url;
+    }
+
+    /*
+     * Check whether the resource URL should be returned.
+     * Throw exception on failure.
+     * Called internally within this file.
+     */
+    public static void check(URL url) throws IOException {
+        SecurityManager security = System.getSecurityManager();
+        if (security != null) {
+            URLConnection urlConnection = url.openConnection();
+            Permission perm = urlConnection.getPermission();
+            if (perm != null) {
+                try {
+                    security.checkPermission(perm);
+                } catch (SecurityException se) {
+                    // fallback to checkRead/checkConnect for pre 1.2
+                    // security managers
+                    if ((perm instanceof java.io.FilePermission) &&
+                        perm.getActions().indexOf("read") != -1) {
+                        security.checkRead(perm.getName());
+                    } else if ((perm instanceof
+                        java.net.SocketPermission) &&
+                        perm.getActions().indexOf("connect") != -1) {
+                        URL locUrl = url;
+                        if (urlConnection instanceof JarURLConnection) {
+                            locUrl = ((JarURLConnection)urlConnection).getJarFileURL();
+                        }
+                        security.checkConnect(locUrl.getHost(),
+                                              locUrl.getPort());
+                    } else {
+                        throw se;
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Inner class used to represent a loader of resources and classes
+     * from a base URL.
+     */
+    private static class Loader implements Closeable {
+        private final URL base;
+        private JarFile jarfile; // if this points to a jar file
+
+        /*
+         * Creates a new Loader for the specified URL.
+         */
+        Loader(URL url) {
+            base = url;
+        }
+
+        /*
+         * Returns the base URL for this Loader.
+         */
+        URL getBaseURL() {
+            return base;
+        }
+
+        URL findResource(final String name, boolean check) {
+            URL url;
+            try {
+                url = new URL(base, ParseUtil.encodePath(name, false));
+            } catch (MalformedURLException e) {
+                throw new IllegalArgumentException("name");
+            }
+
+            try {
+                if (check) {
+                    URLClassPath.check(url);
+                }
+
+                /*
+                 * For a HTTP connection we use the HEAD method to
+                 * check if the resource exists.
+                 */
+                URLConnection uc = url.openConnection();
+                if (uc instanceof HttpURLConnection) {
+                    HttpURLConnection hconn = (HttpURLConnection)uc;
+                    hconn.setRequestMethod("HEAD");
+                    if (hconn.getResponseCode() >= HttpURLConnection.HTTP_BAD_REQUEST) {
+                        return null;
+                    }
+                } else {
+                    // our best guess for the other cases
+                    uc.setUseCaches(false);
+                    InputStream is = uc.getInputStream();
+                    is.close();
+                }
+                return url;
+            } catch (Exception e) {
+                return null;
+            }
+        }
+
+        Resource getResource(final String name, boolean check) {
+            final URL url;
+            try {
+                url = new URL(base, ParseUtil.encodePath(name, false));
+            } catch (MalformedURLException e) {
+                throw new IllegalArgumentException("name");
+            }
+            final URLConnection uc;
+            try {
+                if (check) {
+                    URLClassPath.check(url);
+                }
+                uc = url.openConnection();
+                InputStream in = uc.getInputStream();
+                if (uc instanceof JarURLConnection) {
+                    /* Need to remember the jar file so it can be closed
+                     * in a hurry.
+                     */
+                    JarURLConnection juc = (JarURLConnection)uc;
+                    jarfile = JarLoader.checkJar(juc.getJarFile());
+                }
+            } catch (Exception e) {
+                return null;
+            }
+            return new Resource() {
+                public String getName() { return name; }
+                public URL getURL() { return url; }
+                public URL getCodeSourceURL() { return base; }
+                public InputStream getInputStream() throws IOException {
+                    return uc.getInputStream();
+                }
+                public int getContentLength() throws IOException {
+                    return uc.getContentLength();
+                }
+            };
+        }
+
+        /*
+         * Returns the Resource for the specified name, or null if not
+         * found or the caller does not have the permission to get the
+         * resource.
+         */
+        Resource getResource(final String name) {
+            return getResource(name, true);
+        }
+
+        /*
+         * close this loader and release all resources
+         * method overridden in sub-classes
+         */
+        public void close () throws IOException {
+            if (jarfile != null) {
+                jarfile.close();
+            }
+        }
+
+        /*
+         * Returns the local class path for this loader, or null if none.
+         */
+        URL[] getClassPath() throws IOException {
+            return null;
+        }
+    }
+
+    /*
+     * Inner class used to represent a Loader of resources from a JAR URL.
+     */
+    static class JarLoader extends Loader {
+        private JarFile jar;
+        private URL csu;
+        private JarIndex index;
+        private URLStreamHandler handler;
+        private HashMap<String, Loader> lmap;
+        private boolean closed = false;
+        private static final JavaUtilZipFileAccess zipAccess =
+                SharedSecrets.getJavaUtilZipFileAccess();
+
+        /*
+         * Creates a new JarLoader for the specified URL referring to
+         * a JAR file.
+         */
+        JarLoader(URL url, URLStreamHandler jarHandler,
+                  HashMap<String, Loader> loaderMap)
+            throws IOException
+        {
+            super(new URL("jar", "", -1, url + "!/", jarHandler));
+            csu = url;
+            handler = jarHandler;
+            lmap = loaderMap;
+
+            ensureOpen();
+        }
+
+        @Override
+        public void close () throws IOException {
+            // closing is synchronized at higher level
+            if (!closed) {
+                closed = true;
+                // in case not already open.
+                ensureOpen();
+                jar.close();
+            }
+        }
+
+        JarFile getJarFile () {
+            return jar;
+        }
+
+        private boolean isOptimizable(URL url) {
+            return "file".equals(url.getProtocol());
+        }
+
+        private void ensureOpen() throws IOException {
+            if (jar == null) {
+                try {
+                    java.security.AccessController.doPrivileged(
+                        new java.security.PrivilegedExceptionAction<>() {
+                            public Void run() throws IOException {
+                                if (DEBUG) {
+                                    System.err.println("Opening " + csu);
+                                    Thread.dumpStack();
+                                }
+
+                                jar = getJarFile(csu);
+                                index = JarIndex.getJarIndex(jar);
+                                if (index != null) {
+                                    String[] jarfiles = index.getJarFiles();
+                                // Add all the dependent URLs to the lmap so that loaders
+                                // will not be created for them by URLClassPath.getLoader(int)
+                                // if the same URL occurs later on the main class path.  We set
+                                // Loader to null here to avoid creating a Loader for each
+                                // URL until we actually need to try to load something from them.
+                                    for(int i = 0; i < jarfiles.length; i++) {
+                                        try {
+                                            URL jarURL = new URL(csu, jarfiles[i]);
+                                            // If a non-null loader already exists, leave it alone.
+                                            String urlNoFragString = URLUtil.urlNoFragString(jarURL);
+                                            if (!lmap.containsKey(urlNoFragString)) {
+                                                lmap.put(urlNoFragString, null);
+                                            }
+                                        } catch (MalformedURLException e) {
+                                            continue;
+                                        }
+                                    }
+                                }
+                                return null;
+                            }
+                        }
+                    );
+                } catch (java.security.PrivilegedActionException pae) {
+                    throw (IOException)pae.getException();
+                }
+            }
+        }
+
+        /* Throws if the given jar file is does not start with the correct LOC */
+        static JarFile checkJar(JarFile jar) throws IOException {
+            if (System.getSecurityManager() != null && !DISABLE_JAR_CHECKING
+                && !zipAccess.startsWithLocHeader(jar)) {
+                IOException x = new IOException("Invalid Jar file");
+                try {
+                    jar.close();
+                } catch (IOException ex) {
+                    x.addSuppressed(ex);
+                }
+                throw x;
+            }
+
+            return jar;
+        }
+
+        private JarFile getJarFile(URL url) throws IOException {
+            // Optimize case where url refers to a local jar file
+            if (isOptimizable(url)) {
+                FileURLMapper p = new FileURLMapper (url);
+                if (!p.exists()) {
+                    throw new FileNotFoundException(p.getPath());
+                }
+                return checkJar(new JarFile(new File(p.getPath()), true, ZipFile.OPEN_READ,
+                        JarFile.Release.RUNTIME));
+            }
+            URLConnection uc = (new URL(getBaseURL(), "#runtime")).openConnection();
+            uc.setRequestProperty(USER_AGENT_JAVA_VERSION, JAVA_VERSION);
+            JarFile jarFile = ((JarURLConnection)uc).getJarFile();
+            return checkJar(jarFile);
+        }
+
+        /*
+         * Returns the index of this JarLoader if it exists.
+         */
+        JarIndex getIndex() {
+            try {
+                ensureOpen();
+            } catch (IOException e) {
+                throw new InternalError(e);
+            }
+            return index;
+        }
+
+        /*
+         * Creates the resource and if the check flag is set to true, checks if
+         * is its okay to return the resource.
+         */
+        Resource checkResource(final String name, boolean check,
+            final JarEntry entry) {
+
+            final URL url;
+            try {
+                if (jar.isMultiRelease()) {
+                    // add #runtime fragment to tell JarURLConnection to use
+                    // runtime versioning if the underlying jar file is multi-release
+                    url = new URL(getBaseURL(), ParseUtil.encodePath(name, false) + "#runtime");
+                } else {
+                    url = new URL(getBaseURL(), ParseUtil.encodePath(name, false));
+                }
+                if (check) {
+                    URLClassPath.check(url);
+                }
+            } catch (MalformedURLException e) {
+                return null;
+                // throw new IllegalArgumentException("name");
+            } catch (IOException e) {
+                return null;
+            } catch (AccessControlException e) {
+                return null;
+            }
+
+            return new Resource() {
+                public String getName() { return name; }
+                public URL getURL() { return url; }
+                public URL getCodeSourceURL() { return csu; }
+                public InputStream getInputStream() throws IOException
+                    { return jar.getInputStream(entry); }
+                public int getContentLength()
+                    { return (int)entry.getSize(); }
+                public Manifest getManifest() throws IOException
+                    { return jar.getManifest(); };
+                public Certificate[] getCertificates()
+                    { return entry.getCertificates(); };
+                public CodeSigner[] getCodeSigners()
+                    { return entry.getCodeSigners(); };
+            };
+        }
+
+
+        /*
+         * Returns true iff atleast one resource in the jar file has the same
+         * package name as that of the specified resource name.
+         */
+        boolean validIndex(final String name) {
+            String packageName = name;
+            int pos;
+            if((pos = name.lastIndexOf('/')) != -1) {
+                packageName = name.substring(0, pos);
+            }
+
+            String entryName;
+            ZipEntry entry;
+            Enumeration<JarEntry> enum_ = jar.entries();
+            while (enum_.hasMoreElements()) {
+                entry = enum_.nextElement();
+                entryName = entry.getName();
+                if((pos = entryName.lastIndexOf('/')) != -1)
+                    entryName = entryName.substring(0, pos);
+                if (entryName.equals(packageName)) {
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        /*
+         * Returns the URL for a resource with the specified name
+         */
+        URL findResource(final String name, boolean check) {
+            Resource rsc = getResource(name, check);
+            if (rsc != null) {
+                return rsc.getURL();
+            }
+            return null;
+        }
+
+        /*
+         * Returns the JAR Resource for the specified name.
+         */
+        Resource getResource(final String name, boolean check) {
+            try {
+                ensureOpen();
+            } catch (IOException e) {
+                throw new InternalError(e);
+            }
+            final JarEntry entry = jar.getJarEntry(name);
+            if (entry != null)
+                return checkResource(name, check, entry);
+
+            if (index == null)
+                return null;
+
+            HashSet<String> visited = new HashSet<>();
+            return getResource(name, check, visited);
+        }
+
+        /*
+         * Version of getResource() that tracks the jar files that have been
+         * visited by linking through the index files. This helper method uses
+         * a HashSet to store the URLs of jar files that have been searched and
+         * uses it to avoid going into an infinite loop, looking for a
+         * non-existent resource
+         */
+        Resource getResource(final String name, boolean check,
+                             Set<String> visited) {
+
+            Resource res;
+            String[] jarFiles;
+            int count = 0;
+            LinkedList<String> jarFilesList = null;
+
+            /* If there no jar files in the index that can potential contain
+             * this resource then return immediately.
+             */
+            if((jarFilesList = index.get(name)) == null)
+                return null;
+
+            do {
+                int size = jarFilesList.size();
+                jarFiles = jarFilesList.toArray(new String[size]);
+                /* loop through the mapped jar file list */
+                while(count < size) {
+                    String jarName = jarFiles[count++];
+                    JarLoader newLoader;
+                    final URL url;
+
+                    try{
+                        url = new URL(csu, jarName);
+                        String urlNoFragString = URLUtil.urlNoFragString(url);
+                        if ((newLoader = (JarLoader)lmap.get(urlNoFragString)) == null) {
+                            /* no loader has been set up for this jar file
+                             * before
+                             */
+                            newLoader = AccessController.doPrivileged(
+                                new PrivilegedExceptionAction<>() {
+                                    public JarLoader run() throws IOException {
+                                        return new JarLoader(url, handler,
+                                            lmap);
+                                    }
+                                });
+
+                            /* this newly opened jar file has its own index,
+                             * merge it into the parent's index, taking into
+                             * account the relative path.
+                             */
+                            JarIndex newIndex = newLoader.getIndex();
+                            if(newIndex != null) {
+                                int pos = jarName.lastIndexOf('/');
+                                newIndex.merge(this.index, (pos == -1 ?
+                                    null : jarName.substring(0, pos + 1)));
+                            }
+
+                            /* put it in the global hashtable */
+                            lmap.put(urlNoFragString, newLoader);
+                        }
+                    } catch (java.security.PrivilegedActionException pae) {
+                        continue;
+                    } catch (MalformedURLException e) {
+                        continue;
+                    }
+
+
+                    /* Note that the addition of the url to the list of visited
+                     * jars incorporates a check for presence in the hashmap
+                     */
+                    boolean visitedURL = !visited.add(URLUtil.urlNoFragString(url));
+                    if (!visitedURL) {
+                        try {
+                            newLoader.ensureOpen();
+                        } catch (IOException e) {
+                            throw new InternalError(e);
+                        }
+                        final JarEntry entry = newLoader.jar.getJarEntry(name);
+                        if (entry != null) {
+                            return newLoader.checkResource(name, check, entry);
+                        }
+
+                        /* Verify that at least one other resource with the
+                         * same package name as the lookedup resource is
+                         * present in the new jar
+                         */
+                        if (!newLoader.validIndex(name)) {
+                            /* the mapping is wrong */
+                            throw new InvalidJarIndexException("Invalid index");
+                        }
+                    }
+
+                    /* If newLoader is the current loader or if it is a
+                     * loader that has already been searched or if the new
+                     * loader does not have an index then skip it
+                     * and move on to the next loader.
+                     */
+                    if (visitedURL || newLoader == this ||
+                            newLoader.getIndex() == null) {
+                        continue;
+                    }
+
+                    /* Process the index of the new loader
+                     */
+                    if((res = newLoader.getResource(name, check, visited))
+                            != null) {
+                        return res;
+                    }
+                }
+                // Get the list of jar files again as the list could have grown
+                // due to merging of index files.
+                jarFilesList = index.get(name);
+
+            // If the count is unchanged, we are done.
+            } while(count < jarFilesList.size());
+            return null;
+        }
+
+
+        /*
+         * Returns the JAR file local class path, or null if none.
+         */
+        URL[] getClassPath() throws IOException {
+            if (index != null) {
+                return null;
+            }
+
+            ensureOpen();
+
+            if (SharedSecrets.javaUtilJarAccess().jarFileHasClassPathAttribute(jar)) { // Only get manifest when necessary
+                Manifest man = jar.getManifest();
+                if (man != null) {
+                    Attributes attr = man.getMainAttributes();
+                    if (attr != null) {
+                        String value = attr.getValue(Name.CLASS_PATH);
+                        if (value != null) {
+                            return parseClassPath(csu, value);
+                        }
+                    }
+                }
+            }
+            return null;
+        }
+
+        /*
+         * Parses value of the Class-Path manifest attribute and returns
+         * an array of URLs relative to the specified base URL.
+         */
+        private URL[] parseClassPath(URL base, String value)
+            throws MalformedURLException
+        {
+            StringTokenizer st = new StringTokenizer(value);
+            URL[] urls = new URL[st.countTokens()];
+            int i = 0;
+            while (st.hasMoreTokens()) {
+                String path = st.nextToken();
+                urls[i] = new URL(base, path);
+                i++;
+            }
+            return urls;
+        }
+    }
+
+    /*
+     * Inner class used to represent a loader of classes and resources
+     * from a file URL that refers to a directory.
+     */
+    private static class FileLoader extends Loader {
+        /* Canonicalized File */
+        private File dir;
+
+        FileLoader(URL url) throws IOException {
+            super(url);
+            if (!"file".equals(url.getProtocol())) {
+                throw new IllegalArgumentException("url");
+            }
+            String path = url.getFile().replace('/', File.separatorChar);
+            path = ParseUtil.decode(path);
+            dir = (new File(path)).getCanonicalFile();
+        }
+
+        /*
+         * Returns the URL for a resource with the specified name
+         */
+        URL findResource(final String name, boolean check) {
+            Resource rsc = getResource(name, check);
+            if (rsc != null) {
+                return rsc.getURL();
+            }
+            return null;
+        }
+
+        Resource getResource(final String name, boolean check) {
+            final URL url;
+            try {
+                URL normalizedBase = new URL(getBaseURL(), ".");
+                url = new URL(getBaseURL(), ParseUtil.encodePath(name, false));
+
+                if (url.getFile().startsWith(normalizedBase.getFile()) == false) {
+                    // requested resource had ../..'s in path
+                    return null;
+                }
+
+                if (check)
+                    URLClassPath.check(url);
+
+                final File file;
+                if (name.indexOf("..") != -1) {
+                    file = (new File(dir, name.replace('/', File.separatorChar)))
+                          .getCanonicalFile();
+                    if ( !((file.getPath()).startsWith(dir.getPath())) ) {
+                        /* outside of base dir */
+                        return null;
+                    }
+                } else {
+                    file = new File(dir, name.replace('/', File.separatorChar));
+                }
+
+                if (file.exists()) {
+                    return new Resource() {
+                        public String getName() { return name; };
+                        public URL getURL() { return url; };
+                        public URL getCodeSourceURL() { return getBaseURL(); };
+                        public InputStream getInputStream() throws IOException
+                            { return new FileInputStream(file); };
+                        public int getContentLength() throws IOException
+                            { return (int)file.length(); };
+                    };
+                }
+            } catch (Exception e) {
+                return null;
+            }
+            return null;
+        }
+    }
+}
--- a/jdk/src/java.base/share/classes/jdk/internal/logger/BootstrapLogger.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/logger/BootstrapLogger.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -135,7 +135,7 @@
             Thread thread = AccessController.doPrivileged(new PrivilegedAction<Thread>() {
                 @Override
                 public Thread run() {
-                    Thread t = new InnocuousThread(new BootstrapMessageLoggerTask(owner, r));
+                    Thread t = InnocuousThread.newThread(new BootstrapMessageLoggerTask(owner, r));
                     t.setName("BootstrapMessageLoggerTask-"+t.getName());
                     return t;
                 }
@@ -904,7 +904,7 @@
                                 ? LoggingBackend.JUL_WITH_CONFIG
                                 : LoggingBackend.JUL_DEFAULT;
                         } else {
-                            // SimpleLogger is used
+                            // SimpleConsoleLogger is used
                             return LoggingBackend.NONE;
                         }
                     }
@@ -913,10 +913,10 @@
         }
     }
 
-    // We will use temporary SimpleConsoleLoggers if
+    // We will use a temporary SurrogateLogger if
     // the logging backend is JUL, there is no custom config,
     // and the LogManager has not been initialized yet.
-    private static  boolean useTemporaryLoggers() {
+    private static  boolean useSurrogateLoggers() {
         // being paranoid: this should already have been checked
         if (!isBooted()) return true;
         return DetectBackend.detectedBackend == LoggingBackend.JUL_DEFAULT
@@ -931,25 +931,24 @@
     public static synchronized boolean useLazyLoggers() {
         return !BootstrapLogger.isBooted()
                 || DetectBackend.detectedBackend == LoggingBackend.CUSTOM
-                || useTemporaryLoggers();
+                || useSurrogateLoggers();
     }
 
     // Called by LazyLoggerAccessor. This method will determine whether
     // to create a BootstrapLogger (if the VM is not yet booted),
-    // a SimpleConsoleLogger (if JUL is the default backend and there
+    // a SurrogateLogger (if JUL is the default backend and there
     // is no custom JUL configuration and LogManager is not yet initialized),
     // or a logger returned by the loaded LoggerFinder (all other cases).
     static Logger getLogger(LazyLoggerAccessor accessor) {
         if (!BootstrapLogger.isBooted()) {
             return new BootstrapLogger(accessor);
         } else {
-            boolean temporary = useTemporaryLoggers();
-            if (temporary) {
+            if (useSurrogateLoggers()) {
                 // JUL is the default backend, there is no custom configuration,
                 // LogManager has not been used.
                 synchronized(BootstrapLogger.class) {
-                    if (useTemporaryLoggers()) {
-                        return makeTemporaryLogger(accessor);
+                    if (useSurrogateLoggers()) {
+                        return createSurrogateLogger(accessor);
                     }
                 }
             }
@@ -961,46 +960,46 @@
 
     // If the backend is JUL, and there is no custom configuration, and
     // nobody has attempted to call LogManager.getLogManager() yet, then
-    // we can temporarily substitute JUL Logger with SimpleConsoleLoggers,
+    // we can temporarily substitute JUL Logger with SurrogateLoggers,
     // which avoids the cost of actually loading up the LogManager...
-    // The TemporaryLoggers class has the logic to create such temporary
+    // The RedirectedLoggers class has the logic to create such surrogate
     // loggers, and to possibly replace them with real JUL loggers if
     // someone calls LogManager.getLogManager().
-    static final class TemporaryLoggers implements
-            Function<LazyLoggerAccessor, SimpleConsoleLogger> {
+    static final class RedirectedLoggers implements
+            Function<LazyLoggerAccessor, SurrogateLogger> {
 
         // all accesses must be synchronized on the outer BootstrapLogger.class
-        final Map<LazyLoggerAccessor, SimpleConsoleLogger> temporaryLoggers =
+        final Map<LazyLoggerAccessor, SurrogateLogger> redirectedLoggers =
                 new HashMap<>();
 
         // all accesses must be synchronized on the outer BootstrapLogger.class
-        // The temporaryLoggers map will be cleared when LogManager is initialized.
+        // The redirectLoggers map will be cleared when LogManager is initialized.
         boolean cleared;
 
         @Override
         // all accesses must be synchronized on the outer BootstrapLogger.class
-        public SimpleConsoleLogger apply(LazyLoggerAccessor t) {
+        public SurrogateLogger apply(LazyLoggerAccessor t) {
             if (cleared) throw new IllegalStateException("LoggerFinder already initialized");
-            return SimpleConsoleLogger.makeSimpleLogger(t.getLoggerName(), true);
+            return SurrogateLogger.makeSurrogateLogger(t.getLoggerName());
         }
 
         // all accesses must be synchronized on the outer BootstrapLogger.class
-        SimpleConsoleLogger get(LazyLoggerAccessor a) {
+        SurrogateLogger get(LazyLoggerAccessor a) {
             if (cleared) throw new IllegalStateException("LoggerFinder already initialized");
-            return temporaryLoggers.computeIfAbsent(a, this);
+            return redirectedLoggers.computeIfAbsent(a, this);
         }
 
         // all accesses must be synchronized on the outer BootstrapLogger.class
-        Map<LazyLoggerAccessor, SimpleConsoleLogger> drainTemporaryLoggers() {
-            if (temporaryLoggers.isEmpty()) return null;
+        Map<LazyLoggerAccessor, SurrogateLogger> drainLoggersMap() {
+            if (redirectedLoggers.isEmpty()) return null;
             if (cleared) throw new IllegalStateException("LoggerFinder already initialized");
-            final Map<LazyLoggerAccessor, SimpleConsoleLogger> accessors = new HashMap<>(temporaryLoggers);
-            temporaryLoggers.clear();
+            final Map<LazyLoggerAccessor, SurrogateLogger> accessors = new HashMap<>(redirectedLoggers);
+            redirectedLoggers.clear();
             cleared = true;
             return accessors;
         }
 
-        static void resetTemporaryLoggers(Map<LazyLoggerAccessor, SimpleConsoleLogger> accessors) {
+        static void replaceSurrogateLoggers(Map<LazyLoggerAccessor, SurrogateLogger> accessors) {
             // When the backend is JUL we want to force the creation of
             // JUL loggers here: some tests are expecting that the
             // PlatformLogger will create JUL loggers as soon as the
@@ -1012,36 +1011,38 @@
             final LoggingBackend detectedBackend = DetectBackend.detectedBackend;
             final boolean lazy = detectedBackend != LoggingBackend.JUL_DEFAULT
                     && detectedBackend != LoggingBackend.JUL_WITH_CONFIG;
-            for (Map.Entry<LazyLoggerAccessor, SimpleConsoleLogger> a : accessors.entrySet()) {
+            for (Map.Entry<LazyLoggerAccessor, SurrogateLogger> a : accessors.entrySet()) {
                 a.getKey().release(a.getValue(), !lazy);
             }
         }
 
         // all accesses must be synchronized on the outer BootstrapLogger.class
-        static final TemporaryLoggers INSTANCE = new TemporaryLoggers();
+        static final RedirectedLoggers INSTANCE = new RedirectedLoggers();
     }
 
-    static synchronized Logger makeTemporaryLogger(LazyLoggerAccessor a) {
-        // accesses to TemporaryLoggers is synchronized on BootstrapLogger.class
-        return TemporaryLoggers.INSTANCE.get(a);
+    static synchronized Logger createSurrogateLogger(LazyLoggerAccessor a) {
+        // accesses to RedirectedLoggers is synchronized on BootstrapLogger.class
+        return RedirectedLoggers.INSTANCE.get(a);
     }
 
     private static volatile boolean logManagerConfigured;
 
-    private static synchronized Map<LazyLoggerAccessor, SimpleConsoleLogger>
-         releaseTemporaryLoggers() {
+    private static synchronized Map<LazyLoggerAccessor, SurrogateLogger>
+         releaseSurrogateLoggers() {
         // first check whether there's a chance that we have used
-        // temporary loggers; Will be false if logManagerConfigured is already
+        // surrogate loggers; Will be false if logManagerConfigured is already
         // true.
-        final boolean clearTemporaryLoggers = useTemporaryLoggers();
+        final boolean releaseSurrogateLoggers = useSurrogateLoggers();
 
         // then sets the flag that tells that the log manager is configured
         logManagerConfigured = true;
 
-        // finally replace all temporary loggers by real JUL loggers
-        if (clearTemporaryLoggers) {
-            // accesses to TemporaryLoggers is synchronized on BootstrapLogger.class
-            return TemporaryLoggers.INSTANCE.drainTemporaryLoggers();
+        // finally retrieves all surrogate loggers that should be replaced
+        // by real JUL loggers, and return them in the form of a redirected
+        // loggers map.
+        if (releaseSurrogateLoggers) {
+            // accesses to RedirectedLoggers is synchronized on BootstrapLogger.class
+            return RedirectedLoggers.INSTANCE.drainLoggersMap();
         } else {
             return null;
         }
@@ -1049,14 +1050,14 @@
 
     public static void redirectTemporaryLoggers() {
         // This call is synchronized on BootstrapLogger.class.
-        final Map<LazyLoggerAccessor, SimpleConsoleLogger> accessors =
-                releaseTemporaryLoggers();
+        final Map<LazyLoggerAccessor, SurrogateLogger> accessors =
+                releaseSurrogateLoggers();
 
         // We will now reset the logger accessors, triggering the
-        // (possibly lazy) replacement of any temporary logger by the
+        // (possibly lazy) replacement of any temporary surrogate logger by the
         // real logger returned from the loaded LoggerFinder.
         if (accessors != null) {
-            TemporaryLoggers.resetTemporaryLoggers(accessors);
+            RedirectedLoggers.replaceSurrogateLoggers(accessors);
         }
 
         BootstrapExecutors.flush();
--- a/jdk/src/java.base/share/classes/jdk/internal/logger/SimpleConsoleLogger.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/logger/SimpleConsoleLogger.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -38,6 +38,7 @@
 import java.lang.System.Logger;
 import java.util.function.Predicate;
 import java.util.function.Supplier;
+import sun.security.action.GetPropertyAction;
 import sun.util.logging.PlatformLogger;
 import sun.util.logging.PlatformLogger.ConfigurableBridge.LoggerConfiguration;
 
@@ -49,7 +50,19 @@
 public class SimpleConsoleLogger extends LoggerConfiguration
     implements Logger, PlatformLogger.Bridge, PlatformLogger.ConfigurableBridge {
 
-    static final PlatformLogger.Level DEFAULT_LEVEL = PlatformLogger.Level.INFO;
+    static final Level DEFAULT_LEVEL = getDefaultLevel();
+    static final PlatformLogger.Level DEFAULT_PLATFORM_LEVEL =
+            PlatformLogger.toPlatformLevel(DEFAULT_LEVEL);
+
+    static Level getDefaultLevel() {
+        String levelName = AccessController.doPrivileged(
+                new GetPropertyAction("jdk.system.logger.level", "INFO"));
+        try {
+            return Level.valueOf(levelName);
+        } catch (IllegalArgumentException iae) {
+            return Level.INFO;
+        }
+    }
 
     final String name;
     volatile PlatformLogger.Level  level;
@@ -59,8 +72,16 @@
         this.usePlatformLevel = usePlatformLevel;
     }
 
+    String getSimpleFormatString() {
+        return Formatting.SIMPLE_CONSOLE_LOGGER_FORMAT;
+    }
+
+    PlatformLogger.Level defaultPlatformLevel() {
+        return DEFAULT_PLATFORM_LEVEL;
+    }
+
     @Override
-    public String getName() {
+    public final String getName() {
         return name;
     }
 
@@ -77,12 +98,12 @@
     // ---------------------------------------------------
 
     @Override
-    public boolean isLoggable(Level level) {
+    public final boolean isLoggable(Level level) {
         return isLoggable(PlatformLogger.toPlatformLevel(level));
     }
 
     @Override
-    public void log(Level level, ResourceBundle bundle, String key, Throwable thrown) {
+    public final void log(Level level, ResourceBundle bundle, String key, Throwable thrown) {
         if (isLoggable(level)) {
             if (bundle != null) {
                 key = bundle.getString(key);
@@ -92,7 +113,7 @@
     }
 
     @Override
-    public void log(Level level, ResourceBundle bundle, String format, Object... params) {
+    public final void log(Level level, ResourceBundle bundle, String format, Object... params) {
         if (isLoggable(level)) {
             if (bundle != null) {
                 format = bundle.getString(format);
@@ -106,55 +127,55 @@
     // ---------------------------------------------------
 
     @Override
-    public boolean isLoggable(PlatformLogger.Level level) {
+    public final boolean isLoggable(PlatformLogger.Level level) {
         final PlatformLogger.Level effectiveLevel =  effectiveLevel();
         return level != PlatformLogger.Level.OFF
                 && level.ordinal() >= effectiveLevel.ordinal();
     }
 
     @Override
-    public boolean isEnabled() {
+    public final boolean isEnabled() {
         return level != PlatformLogger.Level.OFF;
     }
 
     @Override
-    public void log(PlatformLogger.Level level, String msg) {
+    public final void log(PlatformLogger.Level level, String msg) {
         if (isLoggable(level)) {
             publish(getCallerInfo(), logLevel(level), msg);
         }
     }
 
     @Override
-    public void log(PlatformLogger.Level level, String msg, Throwable thrown) {
+    public final void log(PlatformLogger.Level level, String msg, Throwable thrown) {
         if (isLoggable(level)) {
             publish(getCallerInfo(), logLevel(level), msg, thrown);
         }
     }
 
     @Override
-    public void log(PlatformLogger.Level level, String msg, Object... params) {
+    public final void log(PlatformLogger.Level level, String msg, Object... params) {
         if (isLoggable(level)) {
             publish(getCallerInfo(), logLevel(level), msg, params);
         }
     }
 
     private PlatformLogger.Level effectiveLevel() {
-        if (level == null) return DEFAULT_LEVEL;
+        if (level == null) return defaultPlatformLevel();
         return level;
     }
 
     @Override
-    public PlatformLogger.Level getPlatformLevel() {
+    public final PlatformLogger.Level getPlatformLevel() {
         return level;
     }
 
     @Override
-    public void setPlatformLevel(PlatformLogger.Level newLevel) {
+    public final void setPlatformLevel(PlatformLogger.Level newLevel) {
         level = newLevel;
     }
 
     @Override
-    public LoggerConfiguration getLoggerConfiguration() {
+    public final LoggerConfiguration getLoggerConfiguration() {
         return this;
     }
 
@@ -222,7 +243,7 @@
             }
             // Continue walking until we've found the relevant calling frame.
             // Skips logging/logger infrastructure.
-            return !isFilteredFrame(t);
+            return !Formatting.isFilteredFrame(t);
         }
 
         private boolean isLoggerImplFrame(String cname) {
@@ -256,7 +277,7 @@
         ZonedDateTime zdt = ZonedDateTime.now();
         String throwable = toString(thrown);
 
-        return String.format(Formatting.formatString,
+        return String.format(getSimpleFormatString(),
                          zdt,
                          callerInfo,
                          name,
@@ -280,31 +301,19 @@
         outputStream().print(format(level, msg, null, callerInfo));
     }
 
-    public static SimpleConsoleLogger makeSimpleLogger(String name, boolean usePlatformLevel) {
-        return new SimpleConsoleLogger(name, usePlatformLevel);
-    }
-
     public static SimpleConsoleLogger makeSimpleLogger(String name) {
         return new SimpleConsoleLogger(name, false);
     }
 
-    public static String getSimpleFormat(Function<String, String> defaultPropertyGetter) {
-        return Formatting.getSimpleFormat(defaultPropertyGetter);
-    }
-
-    public static boolean isFilteredFrame(StackFrame st) {
-        return Formatting.isFilteredFrame(st);
-    }
-
     @Override
-    public void log(PlatformLogger.Level level, Supplier<String> msgSupplier) {
+    public final void log(PlatformLogger.Level level, Supplier<String> msgSupplier) {
         if (isLoggable(level)) {
             publish(getCallerInfo(), logLevel(level), msgSupplier.get());
         }
     }
 
     @Override
-    public void log(PlatformLogger.Level level, Throwable thrown,
+    public final void log(PlatformLogger.Level level, Throwable thrown,
             Supplier<String> msgSupplier) {
         if (isLoggable(level)) {
             publish(getCallerInfo(), logLevel(level), msgSupplier.get(), thrown);
@@ -312,7 +321,7 @@
     }
 
     @Override
-    public void logp(PlatformLogger.Level level, String sourceClass,
+    public final void logp(PlatformLogger.Level level, String sourceClass,
             String sourceMethod, String msg) {
         if (isLoggable(level)) {
             publish(getCallerInfo(sourceClass, sourceMethod), logLevel(level), msg);
@@ -320,7 +329,7 @@
     }
 
     @Override
-    public void logp(PlatformLogger.Level level, String sourceClass,
+    public final void logp(PlatformLogger.Level level, String sourceClass,
             String sourceMethod, Supplier<String> msgSupplier) {
         if (isLoggable(level)) {
             publish(getCallerInfo(sourceClass, sourceMethod), logLevel(level), msgSupplier.get());
@@ -328,7 +337,7 @@
     }
 
     @Override
-    public void logp(PlatformLogger.Level level, String sourceClass, String sourceMethod,
+    public final void logp(PlatformLogger.Level level, String sourceClass, String sourceMethod,
             String msg, Object... params) {
         if (isLoggable(level)) {
             publish(getCallerInfo(sourceClass, sourceMethod), logLevel(level), msg, params);
@@ -336,7 +345,7 @@
     }
 
     @Override
-    public void logp(PlatformLogger.Level level, String sourceClass,
+    public final void logp(PlatformLogger.Level level, String sourceClass,
             String sourceMethod, String msg, Throwable thrown) {
         if (isLoggable(level)) {
             publish(getCallerInfo(sourceClass, sourceMethod), logLevel(level), msg, thrown);
@@ -344,7 +353,7 @@
     }
 
     @Override
-    public void logp(PlatformLogger.Level level, String sourceClass,
+    public final void logp(PlatformLogger.Level level, String sourceClass,
             String sourceMethod, Throwable thrown, Supplier<String> msgSupplier) {
         if (isLoggable(level)) {
             publish(getCallerInfo(sourceClass, sourceMethod), logLevel(level), msgSupplier.get(), thrown);
@@ -352,7 +361,7 @@
     }
 
     @Override
-    public void logrb(PlatformLogger.Level level, String sourceClass,
+    public final void logrb(PlatformLogger.Level level, String sourceClass,
             String sourceMethod, ResourceBundle bundle, String key, Object... params) {
         if (isLoggable(level)) {
             String msg = bundle == null ? key : bundle.getString(key);
@@ -361,7 +370,7 @@
     }
 
     @Override
-    public void logrb(PlatformLogger.Level level, String sourceClass,
+    public final void logrb(PlatformLogger.Level level, String sourceClass,
             String sourceMethod, ResourceBundle bundle, String key, Throwable thrown) {
         if (isLoggable(level)) {
             String msg = bundle == null ? key : bundle.getString(key);
@@ -370,7 +379,7 @@
     }
 
     @Override
-    public void logrb(PlatformLogger.Level level, ResourceBundle bundle,
+    public final void logrb(PlatformLogger.Level level, ResourceBundle bundle,
             String key, Object... params) {
         if (isLoggable(level)) {
             String msg = bundle == null ? key : bundle.getString(key);
@@ -379,7 +388,7 @@
     }
 
     @Override
-    public void logrb(PlatformLogger.Level level, ResourceBundle bundle,
+    public final void logrb(PlatformLogger.Level level, ResourceBundle bundle,
             String key, Throwable thrown) {
         if (isLoggable(level)) {
             String msg = bundle == null ? key : bundle.getString(key);
@@ -387,21 +396,38 @@
         }
     }
 
-    private static final class Formatting {
+    static final class Formatting {
+        // The default simple log format string.
+        // Used both by SimpleConsoleLogger when java.logging is not present,
+        // and by SurrogateLogger and java.util.logging.SimpleFormatter when
+        // java.logging is present.
         static final String DEFAULT_FORMAT =
             "%1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS %1$Tp %2$s%n%4$s: %5$s%6$s%n";
-        static final String FORMAT_PROP_KEY =
+
+        // The system property key that allows to change the default log format
+        // when java.logging is not present. This is used to control the formatting
+        // of the SimpleConsoleLogger.
+        static final String DEFAULT_FORMAT_PROP_KEY =
+            "jdk.system.logger.format";
+
+        // The system property key that allows to change the default log format
+        // when java.logging is present. This is used to control the formatting
+        // of the SurrogateLogger (used before java.util.logging.LogManager is
+        // initialized) and the java.util.logging.SimpleFormatter (used after
+        // java.util.logging.LogManager is  initialized).
+        static final String JUL_FORMAT_PROP_KEY =
             "java.util.logging.SimpleFormatter.format";
-        static final String formatString = getSimpleFormat(null);
+
+        // The simple console logger format string
+        static final String SIMPLE_CONSOLE_LOGGER_FORMAT =
+                getSimpleFormat(DEFAULT_FORMAT_PROP_KEY, null);
 
         // Make it easier to wrap Logger...
         static private final String[] skips;
         static {
             String additionalPkgs = AccessController.doPrivileged(
-                (PrivilegedAction<String>)
-                () -> System.getProperty("jdk.logger.packages"));
+                new GetPropertyAction("jdk.logger.packages"));
             skips = additionalPkgs == null ? new String[0] : additionalPkgs.split(",");
-
         }
 
         static boolean isFilteredFrame(StackFrame st) {
@@ -440,21 +466,29 @@
             return false;
         }
 
-        static String getSimpleFormat(Function<String, String> defaultPropertyGetter) {
-            // Using a lambda here causes
+        static String getSimpleFormat(String key, Function<String, String> defaultPropertyGetter) {
+            // Double check that 'key' is one of the expected property names:
+            // - DEFAULT_FORMAT_PROP_KEY is used to control the
+            //   SimpleConsoleLogger format when java.logging is
+            //   not present.
+            // - JUL_FORMAT_PROP_KEY is used when this method is called
+            //   from the SurrogateLogger subclass. It is used to control the
+            //   SurrogateLogger format and java.util.logging.SimpleFormatter
+            //   format when java.logging is present.
+            // This method should not be called with any other key.
+            if (!DEFAULT_FORMAT_PROP_KEY.equals(key)
+                    && !JUL_FORMAT_PROP_KEY.equals(key)) {
+                throw new IllegalArgumentException("Invalid property name: " + key);
+            }
+
+            // Do not use any lambda in this method. Using a lambda here causes
             //    jdk/test/java/lang/invoke/lambda/LogGeneratedClassesTest.java
             // to fail - because that test has a testcase which somehow references
-            // PlatformLogger and counts the number of generated lambda classes
-            // So we explicitely use new PrivilegedAction<String> here.
-            String format =
-                AccessController.doPrivileged(new PrivilegedAction<String>() {
-                @Override
-                public String run() {
-                    return System.getProperty(FORMAT_PROP_KEY);
-                }
-            });
+            // PlatformLogger and counts the number of generated lambda classes.
+            String format = AccessController.doPrivileged(new GetPropertyAction(key));
+
             if (format == null && defaultPropertyGetter != null) {
-                format = defaultPropertyGetter.apply(FORMAT_PROP_KEY);
+                format = defaultPropertyGetter.apply(key);
             }
             if (format != null) {
                 try {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/logger/SurrogateLogger.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.internal.logger;
+
+import java.util.function.Function;
+import sun.util.logging.PlatformLogger;
+
+/**
+ * A simple console logger used to emulate the behavior of JUL loggers when
+ * java.util.logging has no custom configuration.
+ * Surrogate loggers are usually only used temporarily, until the LogManager
+ * is initialized. At this point, the surrogates are replaced by an actual
+ * logger obtained from LogManager.
+ */
+public final class SurrogateLogger extends SimpleConsoleLogger {
+
+    private static final PlatformLogger.Level JUL_DEFAULT_LEVEL =
+            PlatformLogger.Level.INFO;
+    private static volatile String simpleFormatString;
+
+    SurrogateLogger(String name) {
+        super(name, true);
+    }
+
+    @Override
+    PlatformLogger.Level defaultPlatformLevel() {
+        return JUL_DEFAULT_LEVEL;
+    }
+
+    @Override
+    String getSimpleFormatString() {
+        if (simpleFormatString == null) {
+            simpleFormatString = getSimpleFormat(null);
+        }
+        return simpleFormatString;
+    }
+
+    public static String getSimpleFormat(Function<String, String> defaultPropertyGetter) {
+        return Formatting.getSimpleFormat(Formatting.JUL_FORMAT_PROP_KEY, defaultPropertyGetter);
+    }
+
+    public static SurrogateLogger makeSurrogateLogger(String name) {
+        return new SurrogateLogger(name);
+    }
+
+    public static boolean isFilteredFrame(StackWalker.StackFrame st) {
+        return Formatting.isFilteredFrame(st);
+    }
+}
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/InnocuousThread.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/InnocuousThread.java	Mon Mar 28 08:41:54 2016 -0700
@@ -45,20 +45,49 @@
     private static final long CONTEXTCLASSLOADER;
 
     private static final AtomicInteger threadNumber = new AtomicInteger(1);
+    private static String newName() {
+        return "InnocuousThread-" + threadNumber.getAndIncrement();
+    }
 
-    public InnocuousThread(Runnable target) {
-        this(INNOCUOUSTHREADGROUP, target,
-             "InnocuousThread-" + threadNumber.getAndIncrement());
+    /**
+     * Returns a new InnocuousThread with an auto-generated thread name
+     * and its context class loader is set to the system class loader.
+     */
+    public static Thread newThread(Runnable target) {
+        return newThread(newName(), target);
     }
 
-    public InnocuousThread(Runnable target, String name) {
-        this(INNOCUOUSTHREADGROUP, target, name);
+    /**
+     * Returns a new InnocuousThread with its context class loader
+     * set to the system class loader.
+     */
+    public static Thread newThread(String name, Runnable target) {
+        return new InnocuousThread(INNOCUOUSTHREADGROUP,
+                                   target,
+                                   name,
+                                   ClassLoader.getSystemClassLoader());
     }
 
-    public InnocuousThread(ThreadGroup group, Runnable target, String name) {
+    /**
+     * Returns a new InnocuousThread with an auto-generated thread name.
+     * Its context class loader is set to null.
+     */
+    public static Thread newSystemThread(Runnable target) {
+        return newSystemThread(newName(), target);
+    }
+
+    /**
+     * Returns a new InnocuousThread with null context class loader.
+     */
+    public static Thread newSystemThread(String name, Runnable target) {
+        return new InnocuousThread(INNOCUOUSTHREADGROUP,
+                                   target, name, null);
+    }
+
+    private InnocuousThread(ThreadGroup group, Runnable target, String name, ClassLoader tccl) {
         super(group, target, name, 0L, false);
         UNSAFE.putOrderedObject(this, INHERITEDACCESSCONTROLCONTEXT, ACC);
-        UNSAFE.putOrderedObject(this, CONTEXTCLASSLOADER, ClassLoader.getSystemClassLoader());
+        UNSAFE.putOrderedObject(this, CONTEXTCLASSLOADER, tccl);
     }
 
     @Override
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaNetAccess.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaNetAccess.java	Mon Mar 28 08:41:54 2016 -0700
@@ -26,7 +26,7 @@
 package jdk.internal.misc;
 
 import java.net.URLClassLoader;
-import sun.misc.URLClassPath;
+import jdk.internal.loader.URLClassPath;
 
 public interface JavaNetAccess {
     /**
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java	Mon Mar 28 08:41:54 2016 -0700
@@ -40,6 +40,15 @@
  * Although the class and all methods are public, use of this class is
  * limited because only trusted code can obtain instances of it.
  *
+ * <em>Note:</em> It is the resposibility of the caller to make sure
+ * arguments are checked before methods of this class are
+ * called. While some rudimentary checks are performed on the input,
+ * the checks are best effort and when performance is an overriding
+ * priority, as when methods of this class are optimized by the
+ * runtime compiler, some or all checks (if any) may be elided. Hence,
+ * the caller must not rely on the checks and corresponding
+ * exceptions!
+ *
  * @author John R. Rose
  * @see #getUnsafe
  */
@@ -358,6 +367,169 @@
     @HotSpotIntrinsicCandidate
     public native void putAddress(long address, long x);
 
+
+
+    /// helper methods for validating various types of objects/values
+
+    /**
+     * Create an exception reflecting that some of the input was invalid
+     *
+     * <em>Note:</em> It is the resposibility of the caller to make
+     * sure arguments are checked before the methods are called. While
+     * some rudimentary checks are performed on the input, the checks
+     * are best effort and when performance is an overriding priority,
+     * as when methods of this class are optimized by the runtime
+     * compiler, some or all checks (if any) may be elided. Hence, the
+     * caller must not rely on the checks and corresponding
+     * exceptions!
+     *
+     * @return an exception object
+     */
+    private RuntimeException invalidInput() {
+        return new IllegalArgumentException();
+    }
+
+    /**
+     * Check if a value is 32-bit clean (32 MSB are all zero)
+     *
+     * @param value the 64-bit value to check
+     *
+     * @return true if the value is 32-bit clean
+     */
+    private boolean is32BitClean(long value) {
+        return value >>> 32 == 0;
+    }
+
+    /**
+     * Check the validity of a size (the equivalent of a size_t)
+     *
+     * @throws RuntimeException if the size is invalid
+     *         (<em>Note:</em> after optimization, invalid inputs may
+     *         go undetected, which will lead to unpredictable
+     *         behavior)
+     */
+    private void checkSize(long size) {
+        if (ADDRESS_SIZE == 4) {
+            // Note: this will also check for negative sizes
+            if (!is32BitClean(size)) {
+                throw invalidInput();
+            }
+        } else if (size < 0) {
+            throw invalidInput();
+        }
+    }
+
+    /**
+     * Check the validity of a native address (the equivalent of void*)
+     *
+     * @throws RuntimeException if the address is invalid
+     *         (<em>Note:</em> after optimization, invalid inputs may
+     *         go undetected, which will lead to unpredictable
+     *         behavior)
+     */
+    private void checkNativeAddress(long address) {
+        if (ADDRESS_SIZE == 4) {
+            // Accept both zero and sign extended pointers. A valid
+            // pointer will, after the +1 below, either have produced
+            // the value 0x0 or 0x1. Masking off the low bit allows
+            // for testing against 0.
+            if ((((address >> 32) + 1) & ~1) != 0) {
+                throw invalidInput();
+            }
+        }
+    }
+
+    /**
+     * Check the validity of an offset, relative to a base object
+     *
+     * @param o the base object
+     * @param offset the offset to check
+     *
+     * @throws RuntimeException if the size is invalid
+     *         (<em>Note:</em> after optimization, invalid inputs may
+     *         go undetected, which will lead to unpredictable
+     *         behavior)
+     */
+    private void checkOffset(Object o, long offset) {
+        if (ADDRESS_SIZE == 4) {
+            // Note: this will also check for negative offsets
+            if (!is32BitClean(offset)) {
+                throw invalidInput();
+            }
+        } else if (offset < 0) {
+            throw invalidInput();
+        }
+    }
+
+    /**
+     * Check the validity of a double-register pointer
+     *
+     * Note: This code deliberately does *not* check for NPE for (at
+     * least) three reasons:
+     *
+     * 1) NPE is not just NULL/0 - there is a range of values all
+     * resulting in an NPE, which is not trivial to check for
+     *
+     * 2) It is the responsibility of the callers of Unsafe methods
+     * to verify the input, so throwing an exception here is not really
+     * useful - passing in a NULL pointer is a critical error and the
+     * must not expect an exception to be thrown anyway.
+     *
+     * 3) the actual operations will detect NULL pointers anyway by
+     * means of traps and signals (like SIGSEGV).
+     *
+     * @param o Java heap object, or null
+     * @param offset indication of where the variable resides in a Java heap
+     *        object, if any, else a memory address locating the variable
+     *        statically
+     *
+     * @throws RuntimeException if the pointer is invalid
+     *         (<em>Note:</em> after optimization, invalid inputs may
+     *         go undetected, which will lead to unpredictable
+     *         behavior)
+     */
+    private void checkPointer(Object o, long offset) {
+        if (o == null) {
+            checkNativeAddress(offset);
+        } else {
+            checkOffset(o, offset);
+        }
+    }
+
+    /**
+     * Check if a type is a primitive array type
+     *
+     * @param c the type to check
+     *
+     * @return true if the type is a primitive array type
+     */
+    private void checkPrimitiveArray(Class<?> c) {
+        Class<?> componentType = c.getComponentType();
+        if (componentType == null || !componentType.isPrimitive()) {
+            throw invalidInput();
+        }
+    }
+
+    /**
+     * Check that a pointer is a valid primitive array type pointer
+     *
+     * Note: pointers off-heap are considered to be primitive arrays
+     *
+     * @throws RuntimeException if the pointer is invalid
+     *         (<em>Note:</em> after optimization, invalid inputs may
+     *         go undetected, which will lead to unpredictable
+     *         behavior)
+     */
+    private void checkPrimitivePointer(Object o, long offset) {
+        checkPointer(o, offset);
+
+        if (o != null) {
+            // If on heap, it it must be a primitive array
+            checkPrimitiveArray(o.getClass());
+        }
+    }
+
+
     /// wrappers for malloc, realloc, free:
 
     /**
@@ -367,7 +539,16 @@
      * aligned for all value types.  Dispose of this memory by calling {@link
      * #freeMemory}, or resize it with {@link #reallocateMemory}.
      *
-     * @throws IllegalArgumentException if the size is negative or too large
+     * <em>Note:</em> It is the resposibility of the caller to make
+     * sure arguments are checked before the methods are called. While
+     * some rudimentary checks are performed on the input, the checks
+     * are best effort and when performance is an overriding priority,
+     * as when methods of this class are optimized by the runtime
+     * compiler, some or all checks (if any) may be elided. Hence, the
+     * caller must not rely on the checks and corresponding
+     * exceptions!
+     *
+     * @throws RuntimeException if the size is negative or too large
      *         for the native size_t type
      *
      * @throws OutOfMemoryError if the allocation is refused by the system
@@ -375,7 +556,32 @@
      * @see #getByte(long)
      * @see #putByte(long, byte)
      */
-    public native long allocateMemory(long bytes);
+    public long allocateMemory(long bytes) {
+        allocateMemoryChecks(bytes);
+
+        if (bytes == 0) {
+            return 0;
+        }
+
+        long p = allocateMemory0(bytes);
+        if (p == 0) {
+            throw new OutOfMemoryError();
+        }
+
+        return p;
+    }
+
+    /**
+     * Validate the arguments to allocateMemory
+     *
+     * @throws RuntimeException if the arguments are invalid
+     *         (<em>Note:</em> after optimization, invalid inputs may
+     *         go undetected, which will lead to unpredictable
+     *         behavior)
+     */
+    private void allocateMemoryChecks(long bytes) {
+        checkSize(bytes);
+    }
 
     /**
      * Resizes a new block of native memory, to the given size in bytes.  The
@@ -387,14 +593,50 @@
      * #reallocateMemory}.  The address passed to this method may be null, in
      * which case an allocation will be performed.
      *
-     * @throws IllegalArgumentException if the size is negative or too large
+     * <em>Note:</em> It is the resposibility of the caller to make
+     * sure arguments are checked before the methods are called. While
+     * some rudimentary checks are performed on the input, the checks
+     * are best effort and when performance is an overriding priority,
+     * as when methods of this class are optimized by the runtime
+     * compiler, some or all checks (if any) may be elided. Hence, the
+     * caller must not rely on the checks and corresponding
+     * exceptions!
+     *
+     * @throws RuntimeException if the size is negative or too large
      *         for the native size_t type
      *
      * @throws OutOfMemoryError if the allocation is refused by the system
      *
      * @see #allocateMemory
      */
-    public native long reallocateMemory(long address, long bytes);
+    public long reallocateMemory(long address, long bytes) {
+        reallocateMemoryChecks(address, bytes);
+
+        if (bytes == 0) {
+            freeMemory(address);
+            return 0;
+        }
+
+        long p = (address == 0) ? allocateMemory0(bytes) : reallocateMemory0(address, bytes);
+        if (p == 0) {
+            throw new OutOfMemoryError();
+        }
+
+        return p;
+    }
+
+    /**
+     * Validate the arguments to reallocateMemory
+     *
+     * @throws RuntimeException if the arguments are invalid
+     *         (<em>Note:</em> after optimization, invalid inputs may
+     *         go undetected, which will lead to unpredictable
+     *         behavior)
+     */
+    private void reallocateMemoryChecks(long address, long bytes) {
+        checkPointer(null, address);
+        checkSize(bytes);
+    }
 
     /**
      * Sets all bytes in a given block of memory to a fixed value
@@ -411,9 +653,28 @@
      * If the effective address and length are (resp.) even modulo 4 or 2,
      * the stores take place in units of 'int' or 'short'.
      *
+     * <em>Note:</em> It is the resposibility of the caller to make
+     * sure arguments are checked before the methods are called. While
+     * some rudimentary checks are performed on the input, the checks
+     * are best effort and when performance is an overriding priority,
+     * as when methods of this class are optimized by the runtime
+     * compiler, some or all checks (if any) may be elided. Hence, the
+     * caller must not rely on the checks and corresponding
+     * exceptions!
+     *
+     * @throws RuntimeException if any of the arguments is invalid
+     *
      * @since 1.7
      */
-    public native void setMemory(Object o, long offset, long bytes, byte value);
+    public void setMemory(Object o, long offset, long bytes, byte value) {
+        setMemoryChecks(o, offset, bytes, value);
+
+        if (bytes == 0) {
+            return;
+        }
+
+        setMemory0(o, offset, bytes, value);
+    }
 
     /**
      * Sets all bytes in a given block of memory to a fixed value
@@ -427,6 +688,19 @@
     }
 
     /**
+     * Validate the arguments to setMemory
+     *
+     * @throws RuntimeException if the arguments are invalid
+     *         (<em>Note:</em> after optimization, invalid inputs may
+     *         go undetected, which will lead to unpredictable
+     *         behavior)
+     */
+    private void setMemoryChecks(Object o, long offset, long bytes, byte value) {
+        checkPrimitivePointer(o, offset);
+        checkSize(bytes);
+    }
+
+    /**
      * Sets all bytes in a given block of memory to a copy of another
      * block.
      *
@@ -441,12 +715,31 @@
      * If the effective addresses and length are (resp.) even modulo 4 or 2,
      * the transfer takes place in units of 'int' or 'short'.
      *
+     * <em>Note:</em> It is the resposibility of the caller to make
+     * sure arguments are checked before the methods are called. While
+     * some rudimentary checks are performed on the input, the checks
+     * are best effort and when performance is an overriding priority,
+     * as when methods of this class are optimized by the runtime
+     * compiler, some or all checks (if any) may be elided. Hence, the
+     * caller must not rely on the checks and corresponding
+     * exceptions!
+     *
+     * @throws RuntimeException if any of the arguments is invalid
+     *
      * @since 1.7
      */
-    @HotSpotIntrinsicCandidate
-    public native void copyMemory(Object srcBase, long srcOffset,
-                                  Object destBase, long destOffset,
-                                  long bytes);
+    public void copyMemory(Object srcBase, long srcOffset,
+                           Object destBase, long destOffset,
+                           long bytes) {
+        copyMemoryChecks(srcBase, srcOffset, destBase, destOffset, bytes);
+
+        if (bytes == 0) {
+            return;
+        }
+
+        copyMemory0(srcBase, srcOffset, destBase, destOffset, bytes);
+    }
+
     /**
      * Sets all bytes in a given block of memory to a copy of another
      * block.  This provides a <em>single-register</em> addressing mode,
@@ -458,15 +751,22 @@
         copyMemory(null, srcAddress, null, destAddress, bytes);
     }
 
-    private boolean isPrimitiveArray(Class<?> c) {
-        Class<?> componentType = c.getComponentType();
-        return componentType != null && componentType.isPrimitive();
+    /**
+     * Validate the arguments to copyMemory
+     *
+     * @throws RuntimeException if any of the arguments is invalid
+     *         (<em>Note:</em> after optimization, invalid inputs may
+     *         go undetected, which will lead to unpredictable
+     *         behavior)
+     */
+    private void copyMemoryChecks(Object srcBase, long srcOffset,
+                                  Object destBase, long destOffset,
+                                  long bytes) {
+        checkSize(bytes);
+        checkPrimitivePointer(srcBase, srcOffset);
+        checkPrimitivePointer(destBase, destOffset);
     }
 
-    private native void copySwapMemory0(Object srcBase, long srcOffset,
-                                        Object destBase, long destOffset,
-                                        long bytes, long elemSize);
-
     /**
      * Copies all elements from one block of memory to another block,
      * *unconditionally* byte swapping the elements on the fly.
@@ -476,39 +776,23 @@
      * as discussed in {@link #getInt(Object,long)}.  When the object reference is null,
      * the offset supplies an absolute base address.
      *
+     * <em>Note:</em> It is the resposibility of the caller to make
+     * sure arguments are checked before the methods are called. While
+     * some rudimentary checks are performed on the input, the checks
+     * are best effort and when performance is an overriding priority,
+     * as when methods of this class are optimized by the runtime
+     * compiler, some or all checks (if any) may be elided. Hence, the
+     * caller must not rely on the checks and corresponding
+     * exceptions!
+     *
+     * @throws RuntimeException if any of the arguments is invalid
+     *
      * @since 9
      */
     public void copySwapMemory(Object srcBase, long srcOffset,
                                Object destBase, long destOffset,
                                long bytes, long elemSize) {
-        if (bytes < 0) {
-            throw new IllegalArgumentException();
-        }
-        if (elemSize != 2 && elemSize != 4 && elemSize != 8) {
-            throw new IllegalArgumentException();
-        }
-        if (bytes % elemSize != 0) {
-            throw new IllegalArgumentException();
-        }
-        if ((srcBase == null && srcOffset == 0) ||
-            (destBase == null && destOffset == 0)) {
-            throw new NullPointerException();
-        }
-
-        // Must be off-heap, or primitive heap arrays
-        if (srcBase != null && (srcOffset < 0 || !isPrimitiveArray(srcBase.getClass()))) {
-            throw new IllegalArgumentException();
-        }
-        if (destBase != null && (destOffset < 0 || !isPrimitiveArray(destBase.getClass()))) {
-            throw new IllegalArgumentException();
-        }
-
-        // Sanity check size and offsets on 32-bit platforms. Most
-        // significant 32 bits must be zero.
-        if (ADDRESS_SIZE == 4 &&
-            (bytes >>> 32 != 0 || srcOffset >>> 32 != 0 || destOffset >>> 32 != 0)) {
-            throw new IllegalArgumentException();
-        }
+        copySwapMemoryChecks(srcBase, srcOffset, destBase, destOffset, bytes, elemSize);
 
         if (bytes == 0) {
             return;
@@ -517,6 +801,22 @@
         copySwapMemory0(srcBase, srcOffset, destBase, destOffset, bytes, elemSize);
     }
 
+    private void copySwapMemoryChecks(Object srcBase, long srcOffset,
+                                      Object destBase, long destOffset,
+                                      long bytes, long elemSize) {
+        checkSize(bytes);
+
+        if (elemSize != 2 && elemSize != 4 && elemSize != 8) {
+            throw invalidInput();
+        }
+        if (bytes % elemSize != 0) {
+            throw invalidInput();
+        }
+
+        checkPrimitivePointer(srcBase, srcOffset);
+        checkPrimitivePointer(destBase, destOffset);
+    }
+
    /**
      * Copies all elements from one block of memory to another block, byte swapping the
      * elements on the fly.
@@ -535,9 +835,40 @@
      * #allocateMemory} or {@link #reallocateMemory}.  The address passed to
      * this method may be null, in which case no action is taken.
      *
+     * <em>Note:</em> It is the resposibility of the caller to make
+     * sure arguments are checked before the methods are called. While
+     * some rudimentary checks are performed on the input, the checks
+     * are best effort and when performance is an overriding priority,
+     * as when methods of this class are optimized by the runtime
+     * compiler, some or all checks (if any) may be elided. Hence, the
+     * caller must not rely on the checks and corresponding
+     * exceptions!
+     *
+     * @throws RuntimeException if any of the arguments is invalid
+     *
      * @see #allocateMemory
      */
-    public native void freeMemory(long address);
+    public void freeMemory(long address) {
+        freeMemoryChecks(address);
+
+        if (address == 0) {
+            return;
+        }
+
+        freeMemory0(address);
+    }
+
+    /**
+     * Validate the arguments to freeMemory
+     *
+     * @throws RuntimeException if the arguments are invalid
+     *         (<em>Note:</em> after optimization, invalid inputs may
+     *         go undetected, which will lead to unpredictable
+     *         behavior)
+     */
+    private void freeMemoryChecks(long address) {
+        checkPointer(null, address);
+    }
 
     /// random queries
 
@@ -546,7 +877,7 @@
      * {@link #staticFieldOffset}, {@link #objectFieldOffset},
      * or {@link #arrayBaseOffset}.
      */
-    public static final int INVALID_FIELD_OFFSET   = -1;
+    public static final int INVALID_FIELD_OFFSET = -1;
 
     /**
      * Reports the location of a given field in the storage allocation of its
@@ -566,7 +897,13 @@
      * must preserve all bits of static field offsets.
      * @see #getInt(Object, long)
      */
-    public native long objectFieldOffset(Field f);
+    public long objectFieldOffset(Field f) {
+        if (f == null) {
+            throw new NullPointerException();
+        }
+
+        return objectFieldOffset0(f);
+    }
 
     /**
      * Reports the location of a given static field, in conjunction with {@link
@@ -585,7 +922,13 @@
      * this method reports its result as a long value.
      * @see #getInt(Object, long)
      */
-    public native long staticFieldOffset(Field f);
+    public long staticFieldOffset(Field f) {
+        if (f == null) {
+            throw new NullPointerException();
+        }
+
+        return staticFieldOffset0(f);
+    }
 
     /**
      * Reports the location of a given static field, in conjunction with {@link
@@ -597,7 +940,13 @@
      * not be used in any way except as argument to the get and put routines in
      * this class.
      */
-    public native Object staticFieldBase(Field f);
+    public Object staticFieldBase(Field f) {
+        if (f == null) {
+            throw new NullPointerException();
+        }
+
+        return staticFieldBase0(f);
+    }
 
     /**
      * Detects if the given class may need to be initialized. This is often
@@ -605,14 +954,26 @@
      * class.
      * @return false only if a call to {@code ensureClassInitialized} would have no effect
      */
-    public native boolean shouldBeInitialized(Class<?> c);
+    public boolean shouldBeInitialized(Class<?> c) {
+        if (c == null) {
+            throw new NullPointerException();
+        }
+
+        return shouldBeInitialized0(c);
+    }
 
     /**
      * Ensures the given class has been initialized. This is often
      * needed in conjunction with obtaining the static field base of a
      * class.
      */
-    public native void ensureClassInitialized(Class<?> c);
+    public void ensureClassInitialized(Class<?> c) {
+        if (c == null) {
+            throw new NullPointerException();
+        }
+
+        ensureClassInitialized0(c);
+    }
 
     /**
      * Reports the offset of the first element in the storage allocation of a
@@ -624,7 +985,14 @@
      * @see #getInt(Object, long)
      * @see #putInt(Object, long, int)
      */
-    public native int arrayBaseOffset(Class<?> arrayClass);
+    public int arrayBaseOffset(Class<?> arrayClass) {
+        if (arrayClass == null) {
+            throw new NullPointerException();
+        }
+
+        return arrayBaseOffset0(arrayClass);
+    }
+
 
     /** The value of {@code arrayBaseOffset(boolean[].class)} */
     public static final int ARRAY_BOOLEAN_BASE_OFFSET
@@ -673,7 +1041,14 @@
      * @see #getInt(Object, long)
      * @see #putInt(Object, long, int)
      */
-    public native int arrayIndexScale(Class<?> arrayClass);
+    public int arrayIndexScale(Class<?> arrayClass) {
+        if (arrayClass == null) {
+            throw new NullPointerException();
+        }
+
+        return arrayIndexScale0(arrayClass);
+    }
+
 
     /** The value of {@code arrayIndexScale(boolean[].class)} */
     public static final int ARRAY_BOOLEAN_INDEX_SCALE
@@ -717,10 +1092,12 @@
      * other primitive types (as stored in native memory blocks) is determined
      * fully by their information content.
      */
-    public native int addressSize();
+    public int addressSize() {
+        return ADDRESS_SIZE;
+    }
 
     /** The value of {@code addressSize()} */
-    public static final int ADDRESS_SIZE = theUnsafe.addressSize();
+    public static final int ADDRESS_SIZE = theUnsafe.addressSize0();
 
     /**
      * Reports the size in bytes of a native memory page (whatever that is).
@@ -735,9 +1112,22 @@
      * Tells the VM to define a class, without security checks.  By default, the
      * class loader and protection domain come from the caller's class.
      */
-    public native Class<?> defineClass(String name, byte[] b, int off, int len,
-                                       ClassLoader loader,
-                                       ProtectionDomain protectionDomain);
+    public Class<?> defineClass(String name, byte[] b, int off, int len,
+                                ClassLoader loader,
+                                ProtectionDomain protectionDomain) {
+        if (b == null) {
+            throw new NullPointerException();
+        }
+        if (len < 0) {
+            throw new ArrayIndexOutOfBoundsException();
+        }
+
+        return defineClass0(name, b, off, len, loader, protectionDomain);
+    }
+
+    public native Class<?> defineClass0(String name, byte[] b, int off, int len,
+                                        ClassLoader loader,
+                                        ProtectionDomain protectionDomain);
 
     /**
      * Defines a class but does not make it known to the class loader or system dictionary.
@@ -755,7 +1145,13 @@
      * @param data      bytes of a class file
      * @param cpPatches where non-null entries exist, they replace corresponding CP entries in data
      */
-    public native Class<?> defineAnonymousClass(Class<?> hostClass, byte[] data, Object[] cpPatches);
+    public Class<?> defineAnonymousClass(Class<?> hostClass, byte[] data, Object[] cpPatches) {
+        if (hostClass == null || data == null) {
+            throw new NullPointerException();
+        }
+
+        return defineAnonymousClass0(hostClass, data, cpPatches);
+    }
 
     /**
      * Allocates an instance but does not run any constructor.
@@ -765,6 +1161,59 @@
     public native Object allocateInstance(Class<?> cls)
         throws InstantiationException;
 
+    /**
+     * Allocates an array of a given type, but does not do zeroing.
+     * <p>
+     * This method should only be used in the very rare cases where a high-performance code
+     * overwrites the destination array completely, and compilers cannot assist in zeroing elimination.
+     * In an overwhelming majority of cases, a normal Java allocation should be used instead.
+     * <p>
+     * Users of this method are <b>required</b> to overwrite the initial (garbage) array contents
+     * before allowing untrusted code, or code in other threads, to observe the reference
+     * to the newly allocated array. In addition, the publication of the array reference must be
+     * safe according to the Java Memory Model requirements.
+     * <p>
+     * The safest approach to deal with an uninitialized array is to keep the reference to it in local
+     * variable at least until the initialization is complete, and then publish it <b>once</b>, either
+     * by writing it to a <em>volatile</em> field, or storing it into a <em>final</em> field in constructor,
+     * or issuing a {@link #storeFence} before publishing the reference.
+     * <p>
+     * @implnote This method can only allocate primitive arrays, to avoid garbage reference
+     * elements that could break heap integrity.
+     *
+     * @param componentType array component type to allocate
+     * @param length array size to allocate
+     * @throws IllegalArgumentException if component type is null, or not a primitive class;
+     *                                  or the length is negative
+     */
+    public Object allocateUninitializedArray(Class<?> componentType, int length) {
+       if (componentType == null) {
+           throw new IllegalArgumentException("Component type is null");
+       }
+       if (!componentType.isPrimitive()) {
+           throw new IllegalArgumentException("Component type is not primitive");
+       }
+       if (length < 0) {
+           throw new IllegalArgumentException("Negative length");
+       }
+       return allocateUninitializedArray0(componentType, length);
+    }
+
+    @HotSpotIntrinsicCandidate
+    private Object allocateUninitializedArray0(Class<?> componentType, int length) {
+       // These fallbacks provide zeroed arrays, but intrinsic is not required to
+       // return the zeroed arrays.
+       if (componentType == byte.class)    return new byte[length];
+       if (componentType == boolean.class) return new boolean[length];
+       if (componentType == short.class)   return new short[length];
+       if (componentType == char.class)    return new char[length];
+       if (componentType == int.class)     return new int[length];
+       if (componentType == float.class)   return new float[length];
+       if (componentType == long.class)    return new long[length];
+       if (componentType == double.class)  return new double[length];
+       return null;
+    }
+
     /** Throws the exception without telling the verifier. */
     public native void throwException(Throwable ee);
 
@@ -1290,7 +1739,13 @@
      * @return the number of samples actually retrieved; or -1
      *         if the load average is unobtainable.
      */
-    public native int getLoadAverage(double[] loadavg, int nelems);
+    public int getLoadAverage(double[] loadavg, int nelems) {
+        if (nelems < 0 || nelems > 3 || nelems > loadavg.length) {
+            throw new ArrayIndexOutOfBoundsException();
+        }
+
+        return getLoadAverage0(loadavg, nelems);
+    }
 
     // The following contain CAS-based Java implementations used on
     // platforms not supporting native instructions
@@ -1718,9 +2173,6 @@
     }
 
     // JVM interface methods
-    private native boolean unalignedAccess0();
-    private native boolean isBigEndian0();
-
     // BE is true iff the native endianness of this platform is big.
     private static final boolean BE = theUnsafe.isBigEndian0();
 
@@ -1820,4 +2272,26 @@
     private static short convEndian(boolean big, short n) { return big == BE ? n : Short.reverseBytes(n)    ; }
     private static int convEndian(boolean big, int n)     { return big == BE ? n : Integer.reverseBytes(n)  ; }
     private static long convEndian(boolean big, long n)   { return big == BE ? n : Long.reverseBytes(n)     ; }
+
+
+
+    private native long allocateMemory0(long bytes);
+    private native long reallocateMemory0(long address, long bytes);
+    private native void freeMemory0(long address);
+    private native void setMemory0(Object o, long offset, long bytes, byte value);
+    @HotSpotIntrinsicCandidate
+    private native void copyMemory0(Object srcBase, long srcOffset, Object destBase, long destOffset, long bytes);
+    private native void copySwapMemory0(Object srcBase, long srcOffset, Object destBase, long destOffset, long bytes, long elemSize);
+    private native long objectFieldOffset0(Field f);
+    private native long staticFieldOffset0(Field f);
+    private native Object staticFieldBase0(Field f);
+    private native boolean shouldBeInitialized0(Class<?> c);
+    private native void ensureClassInitialized0(Class<?> c);
+    private native int arrayBaseOffset0(Class<?> arrayClass);
+    private native int arrayIndexScale0(Class<?> arrayClass);
+    private native int addressSize0();
+    private native Class<?> defineAnonymousClass0(Class<?> hostClass, byte[] data, Object[] cpPatches);
+    private native int getLoadAverage0(double[] loadavg, int nelems);
+    private native boolean unalignedAccess0();
+    private native boolean isBigEndian0();
 }
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java	Mon Mar 28 08:41:54 2016 -0700
@@ -51,9 +51,9 @@
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 
+import jdk.internal.loader.Resource;
 import jdk.internal.misc.JavaLangModuleAccess;
 import jdk.internal.misc.SharedSecrets;
-import sun.misc.Resource;
 import sun.net.www.ParseUtil;
 
 
@@ -583,4 +583,4 @@
         throw new IllegalArgumentException(msg);
     }
 
-}
\ No newline at end of file
+}
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java	Mon Mar 28 08:41:54 2016 -0700
@@ -195,7 +195,7 @@
     public ClassReader(final byte[] b, final int off, final int len) {
         this.b = b;
         // checks the class version
-        if (readShort(off + 6) > Opcodes.V1_8) {
+        if (readShort(off + 6) > Opcodes.V1_9) {
             throw new IllegalArgumentException();
         }
         // parses the constant pool
@@ -1199,7 +1199,14 @@
                         if (labels[label] == null) {
                             readLabel(label, labels).status |= Label.DEBUG;
                         }
-                        labels[label].line = readUnsignedShort(v + 12);
+                        Label l = labels[label];
+                        while (l.line > 0) {
+                            if (l.next == null) {
+                                l.next = new Label();
+                            }
+                            l = l.next;
+                        }
+                        l.line = readUnsignedShort(v + 12);
                         v += 4;
                     }
                 }
@@ -1314,9 +1321,15 @@
             // visits the label and line number for this offset, if any
             Label l = labels[offset];
             if (l != null) {
+                Label next = l.next;
+                l.next = null;
                 mv.visitLabel(l);
                 if ((context.flags & SKIP_DEBUG) == 0 && l.line > 0) {
                     mv.visitLineNumber(l.line, l);
+                    while (next != null) {
+                        mv.visitLineNumber(next.line, l);
+                        next = next.next;
+                    }
                 }
             }
 
@@ -1857,8 +1870,7 @@
             v += 2;
             break;
         case 'B': // pointer to CONSTANT_Byte
-            av.visit(name,
-                    (byte) readInt(items[readUnsignedShort(v)]));
+            av.visit(name, (byte) readInt(items[readUnsignedShort(v)]));
             v += 2;
             break;
         case 'Z': // pointer to CONSTANT_Boolean
@@ -1868,13 +1880,11 @@
             v += 2;
             break;
         case 'S': // pointer to CONSTANT_Short
-            av.visit(name,
-                    (short) readInt(items[readUnsignedShort(v)]));
+            av.visit(name, (short) readInt(items[readUnsignedShort(v)]));
             v += 2;
             break;
         case 'C': // pointer to CONSTANT_Char
-            av.visit(name,
-                    (char) readInt(items[readUnsignedShort(v)]));
+            av.visit(name, (char) readInt(items[readUnsignedShort(v)]));
             v += 2;
             break;
         case 's': // pointer to CONSTANT_Utf8
@@ -2515,11 +2525,12 @@
             int tag = readByte(index);
             int[] items = this.items;
             int cpIndex = items[readUnsignedShort(index + 1)];
+            boolean itf = b[cpIndex - 1] == ClassWriter.IMETH;
             String owner = readClass(cpIndex, buf);
             cpIndex = items[readUnsignedShort(cpIndex + 2)];
             String name = readUTF8(cpIndex, buf);
             String desc = readUTF8(cpIndex + 2, buf);
-            return new Handle(tag, owner, name, desc);
+            return new Handle(tag, owner, name, desc, itf);
         }
     }
 }
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassWriter.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassWriter.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1081,7 +1081,7 @@
             }
         } else if (cst instanceof Handle) {
             Handle h = (Handle) cst;
-            return newHandleItem(h.tag, h.owner, h.name, h.desc);
+            return newHandleItem(h.tag, h.owner, h.name, h.desc, h.itf);
         } else {
             throw new IllegalArgumentException("value " + cst);
         }
@@ -1216,10 +1216,12 @@
      *            the name of the field or method.
      * @param desc
      *            the descriptor of the field or method.
+     * @param itf
+     *            true if the owner is an interface.
      * @return a new or an already existing method type reference item.
      */
     Item newHandleItem(final int tag, final String owner, final String name,
-            final String desc) {
+            final String desc, final boolean itf) {
         key4.set(HANDLE_BASE + tag, owner, name, desc);
         Item result = get(key4);
         if (result == null) {
@@ -1228,8 +1230,7 @@
             } else {
                 put112(HANDLE,
                         tag,
-                        newMethod(owner, name, desc,
-                                tag == Opcodes.H_INVOKEINTERFACE));
+                        newMethod(owner, name, desc, itf));
             }
             result = new Item(index++, key4);
             put(result);
@@ -1259,10 +1260,44 @@
      *            the descriptor of the field or method.
      * @return the index of a new or already existing method type reference
      *         item.
+     *
+     * @deprecated this method is superseded by
+     *             {@link #newHandle(int, String, String, String, boolean)}.
+     */
+    @Deprecated
+    public int newHandle(final int tag, final String owner, final String name,
+            final String desc) {
+        return newHandle(tag, owner, name, desc, tag == Opcodes.H_INVOKEINTERFACE);
+    }
+
+    /**
+     * Adds a handle to the constant pool of the class being build. Does nothing
+     * if the constant pool already contains a similar item. <i>This method is
+     * intended for {@link Attribute} sub classes, and is normally not needed by
+     * class generators or adapters.</i>
+     *
+     * @param tag
+     *            the kind of this handle. Must be {@link Opcodes#H_GETFIELD},
+     *            {@link Opcodes#H_GETSTATIC}, {@link Opcodes#H_PUTFIELD},
+     *            {@link Opcodes#H_PUTSTATIC}, {@link Opcodes#H_INVOKEVIRTUAL},
+     *            {@link Opcodes#H_INVOKESTATIC},
+     *            {@link Opcodes#H_INVOKESPECIAL},
+     *            {@link Opcodes#H_NEWINVOKESPECIAL} or
+     *            {@link Opcodes#H_INVOKEINTERFACE}.
+     * @param owner
+     *            the internal name of the field or method owner class.
+     * @param name
+     *            the name of the field or method.
+     * @param desc
+     *            the descriptor of the field or method.
+     * @param itf
+     *            true if the owner is an interface.
+     * @return the index of a new or already existing method type reference
+     *         item.
      */
     public int newHandle(final int tag, final String owner, final String name,
-            final String desc) {
-        return newHandleItem(tag, owner, name, desc).index;
+            final String desc, final boolean itf) {
+        return newHandleItem(tag, owner, name, desc, itf).index;
     }
 
     /**
@@ -1294,7 +1329,7 @@
 
         int hashCode = bsm.hashCode();
         bootstrapMethods.putShort(newHandle(bsm.tag, bsm.owner, bsm.name,
-                bsm.desc));
+                bsm.desc, bsm.isInterface()));
 
         int argsLength = bsmArgs.length;
         bootstrapMethods.putShort(argsLength);
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Frame.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Frame.java	Mon Mar 28 08:41:54 2016 -0700
@@ -192,7 +192,7 @@
     private static final int LOCAL = 0x2000000;
 
     /**
-     * Kind of the types that are relative to the stack of an input stack
+     * Kind of the the types that are relative to the stack of an input stack
      * map frame. The value of such types is a position relatively to the top of
      * this stack.
      */
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Handle.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Handle.java	Mon Mar 28 08:41:54 2016 -0700
@@ -93,6 +93,12 @@
      */
     final String desc;
 
+
+    /**
+     * Indicate if the owner is an interface or not.
+     */
+    final boolean itf;
+
     /**
      * Constructs a new field or method handle.
      *
@@ -113,12 +119,44 @@
      * @param desc
      *            the descriptor of the field or method designated by this
      *            handle.
+     *
+     * @deprecated this constructor has been superseded
+     *             by {@link #Handle(int, String, String, String, boolean)}.
      */
+    @Deprecated
     public Handle(int tag, String owner, String name, String desc) {
+        this(tag, owner, name, desc, tag == Opcodes.H_INVOKEINTERFACE);
+    }
+
+    /**
+     * Constructs a new field or method handle.
+     *
+     * @param tag
+     *            the kind of field or method designated by this Handle. Must be
+     *            {@link Opcodes#H_GETFIELD}, {@link Opcodes#H_GETSTATIC},
+     *            {@link Opcodes#H_PUTFIELD}, {@link Opcodes#H_PUTSTATIC},
+     *            {@link Opcodes#H_INVOKEVIRTUAL},
+     *            {@link Opcodes#H_INVOKESTATIC},
+     *            {@link Opcodes#H_INVOKESPECIAL},
+     *            {@link Opcodes#H_NEWINVOKESPECIAL} or
+     *            {@link Opcodes#H_INVOKEINTERFACE}.
+     * @param owner
+     *            the internal name of the class that owns the field or method
+     *            designated by this handle.
+     * @param name
+     *            the name of the field or method designated by this handle.
+     * @param desc
+     *            the descriptor of the field or method designated by this
+     *            handle.
+     * @param itf
+     *            true if the owner is an interface.
+     */
+    public Handle(int tag, String owner, String name, String desc, boolean itf) {
         this.tag = tag;
         this.owner = owner;
         this.name = name;
         this.desc = desc;
+        this.itf = itf;
     }
 
     /**
@@ -164,6 +202,17 @@
         return desc;
     }
 
+    /**
+     * Returns true if the owner of the field or method designated
+     * by this handle is an interface.
+     *
+     * @return true if the owner of the field or method designated
+     *         by this handle is an interface.
+     */
+    public boolean isInterface() {
+        return itf;
+    }
+
     @Override
     public boolean equals(Object obj) {
         if (obj == this) {
@@ -173,13 +222,13 @@
             return false;
         }
         Handle h = (Handle) obj;
-        return tag == h.tag && owner.equals(h.owner) && name.equals(h.name)
-                && desc.equals(h.desc);
+        return tag == h.tag && itf == h.itf && owner.equals(h.owner)
+                && name.equals(h.name) && desc.equals(h.desc);
     }
 
     @Override
     public int hashCode() {
-        return tag + owner.hashCode() * name.hashCode() * desc.hashCode();
+        return tag + (itf? 64: 0) + owner.hashCode() * name.hashCode() * desc.hashCode();
     }
 
     /**
@@ -187,13 +236,16 @@
      * representation is:
      *
      * <pre>
+     * for a reference to a class:
      * owner '.' name desc ' ' '(' tag ')'
+     * for a reference to an interface:
+     * owner '.' name desc ' ' '(' tag ' ' itf ')'
      * </pre>
      *
      * . As this format is unambiguous, it can be parsed if necessary.
      */
     @Override
     public String toString() {
-        return owner + '.' + name + desc + " (" + tag + ')';
+        return owner + '.' + name + desc + " (" + tag + (itf? " itf": "") + ')';
     }
 }
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Label.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Label.java	Mon Mar 28 08:41:54 2016 -0700
@@ -160,7 +160,11 @@
     int status;
 
     /**
-     * The line number corresponding to this label, if known.
+     * The line number corresponding to this label, if known. If there are
+     * several lines, each line is stored in a separate label, all linked via
+     * their next field (these links are created in ClassReader and removed just
+     * before visitLabel is called, so that this does not impact the rest of the
+     * code).
      */
     int line;
 
@@ -268,7 +272,8 @@
      * The next basic block in the basic block stack. This stack is used in the
      * main loop of the fix point algorithm used in the second step of the
      * control flow analysis algorithms. It is also used in
-     * {@link #visitSubroutine} to avoid using a recursive method.
+     * {@link #visitSubroutine} to avoid using a recursive method, and in
+     * ClassReader to temporarily store multiple source lines for a label.
      *
      * @see MethodWriter#visitMaxs
      */
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/MethodVisitor.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/MethodVisitor.java	Mon Mar 28 08:41:54 2016 -0700
@@ -62,15 +62,16 @@
  * A visitor to visit a Java method. The methods of this class must be called in
  * the following order: ( <tt>visitParameter</tt> )* [
  * <tt>visitAnnotationDefault</tt> ] ( <tt>visitAnnotation</tt> |
- * <tt>visitTypeAnnotation</tt> | <tt>visitAttribute</tt> )* [
- * <tt>visitCode</tt> ( <tt>visitFrame</tt> | <tt>visit<i>X</i>Insn</tt> |
- * <tt>visitLabel</tt> | <tt>visitInsnAnnotation</tt> |
- * <tt>visitTryCatchBlock</tt> | <tt>visitTryCatchBlockAnnotation</tt> |
- * <tt>visitLocalVariable</tt> | <tt>visitLocalVariableAnnotation</tt> |
- * <tt>visitLineNumber</tt> )* <tt>visitMaxs</tt> ] <tt>visitEnd</tt>. In
- * addition, the <tt>visit<i>X</i>Insn</tt> and <tt>visitLabel</tt> methods must
- * be called in the sequential order of the bytecode instructions of the visited
- * code, <tt>visitInsnAnnotation</tt> must be called <i>after</i> the annotated
+ * <tt>visitParameterAnnotation</tt> <tt>visitTypeAnnotation</tt> |
+ * <tt>visitAttribute</tt> )* [ <tt>visitCode</tt> ( <tt>visitFrame</tt> |
+ * <tt>visit<i>X</i>Insn</tt> | <tt>visitLabel</tt> |
+ * <tt>visitInsnAnnotation</tt> | <tt>visitTryCatchBlock</tt> |
+ * <tt>visitTryCatchAnnotation</tt> | <tt>visitLocalVariable</tt> |
+ * <tt>visitLocalVariableAnnotation</tt> | <tt>visitLineNumber</tt> )*
+ * <tt>visitMaxs</tt> ] <tt>visitEnd</tt>. In addition, the
+ * <tt>visit<i>X</i>Insn</tt> and <tt>visitLabel</tt> methods must be called in
+ * the sequential order of the bytecode instructions of the visited code,
+ * <tt>visitInsnAnnotation</tt> must be called <i>after</i> the annotated
  * instruction, <tt>visitTryCatchBlock</tt> must be called <i>before</i> the
  * labels passed as arguments have been visited,
  * <tt>visitTryCatchBlockAnnotation</tt> must be called <i>after</i> the
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/MethodWriter.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/MethodWriter.java	Mon Mar 28 08:41:54 2016 -0700
@@ -2061,7 +2061,7 @@
         }
         int size = 8;
         if (code.length > 0) {
-            if (code.length > 65536) {
+            if (code.length > 65535) {
                 throw new RuntimeException("Method code too large!");
             }
             cw.newUTF8("Code");
@@ -2735,11 +2735,13 @@
                 l = l.successor;
             }
             // Update the offsets in the uninitialized types
-            for (i = 0; i < cw.typeTable.length; ++i) {
-                Item item = cw.typeTable[i];
-                if (item != null && item.type == ClassWriter.TYPE_UNINIT) {
-                    item.intVal = getNewOffset(allIndexes, allSizes, 0,
-                            item.intVal);
+            if (cw.typeTable != null) {
+                for (i = 0; i < cw.typeTable.length; ++i) {
+                    Item item = cw.typeTable[i];
+                    if (item != null && item.type == ClassWriter.TYPE_UNINIT) {
+                        item.intVal = getNewOffset(allIndexes, allSizes, 0,
+                                item.intVal);
+                    }
                 }
             }
             // The stack map frames are not serialized yet, so we don't need
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java	Mon Mar 28 08:41:54 2016 -0700
@@ -87,6 +87,7 @@
     int V1_6 = 0 << 16 | 50;
     int V1_7 = 0 << 16 | 51;
     int V1_8 = 0 << 16 | 52;
+    int V1_9 = 0 << 16 | 53;
 
     // access flags
 
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Type.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Type.java	Mon Mar 28 08:41:54 2016 -0700
@@ -654,7 +654,7 @@
      * @return the descriptor corresponding to this Java type.
      */
     public String getDescriptor() {
-        StringBuffer buf = new StringBuffer();
+        StringBuilder buf = new StringBuilder();
         getDescriptor(buf);
         return buf.toString();
     }
@@ -672,7 +672,7 @@
      */
     public static String getMethodDescriptor(final Type returnType,
             final Type... argumentTypes) {
-        StringBuffer buf = new StringBuffer();
+        StringBuilder buf = new StringBuilder();
         buf.append('(');
         for (int i = 0; i < argumentTypes.length; ++i) {
             argumentTypes[i].getDescriptor(buf);
@@ -689,7 +689,7 @@
      * @param buf
      *            the string buffer to which the descriptor must be appended.
      */
-    private void getDescriptor(final StringBuffer buf) {
+    private void getDescriptor(final StringBuilder buf) {
         if (this.buf == null) {
             // descriptor is in byte 3 of 'off' for primitive types (buf ==
             // null)
@@ -729,7 +729,7 @@
      * @return the descriptor corresponding to the given class.
      */
     public static String getDescriptor(final Class<?> c) {
-        StringBuffer buf = new StringBuffer();
+        StringBuilder buf = new StringBuilder();
         getDescriptor(buf, c);
         return buf.toString();
     }
@@ -743,7 +743,7 @@
      */
     public static String getConstructorDescriptor(final Constructor<?> c) {
         Class<?>[] parameters = c.getParameterTypes();
-        StringBuffer buf = new StringBuffer();
+        StringBuilder buf = new StringBuilder();
         buf.append('(');
         for (int i = 0; i < parameters.length; ++i) {
             getDescriptor(buf, parameters[i]);
@@ -760,7 +760,7 @@
      */
     public static String getMethodDescriptor(final Method m) {
         Class<?>[] parameters = m.getParameterTypes();
-        StringBuffer buf = new StringBuffer();
+        StringBuilder buf = new StringBuilder();
         buf.append('(');
         for (int i = 0; i < parameters.length; ++i) {
             getDescriptor(buf, parameters[i]);
@@ -778,7 +778,7 @@
      * @param c
      *            the class whose descriptor must be computed.
      */
-    private static void getDescriptor(final StringBuffer buf, final Class<?> c) {
+    private static void getDescriptor(final StringBuilder buf, final Class<?> c) {
         Class<?> d = c;
         while (true) {
             if (d.isPrimitive()) {
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/TypePath.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/TypePath.java	Mon Mar 28 08:41:54 2016 -0700
@@ -71,25 +71,25 @@
      * A type path step that steps into the element type of an array type. See
      * {@link #getStep getStep}.
      */
-    public static final int ARRAY_ELEMENT = 0;
+    public final static int ARRAY_ELEMENT = 0;
 
     /**
      * A type path step that steps into the nested type of a class type. See
      * {@link #getStep getStep}.
      */
-    public static final int INNER_TYPE = 1;
+    public final static int INNER_TYPE = 1;
 
     /**
      * A type path step that steps into the bound of a wildcard type. See
      * {@link #getStep getStep}.
      */
-    public static final int WILDCARD_BOUND = 2;
+    public final static int WILDCARD_BOUND = 2;
 
     /**
      * A type path step that steps into a type argument of a generic type. See
      * {@link #getStep getStep}.
      */
-    public static final int TYPE_ARGUMENT = 3;
+    public final static int TYPE_ARGUMENT = 3;
 
     /**
      * The byte array where the path is stored, in Java class file format.
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/TypeReference.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/TypeReference.java	Mon Mar 28 08:41:54 2016 -0700
@@ -74,133 +74,133 @@
      * The sort of type references that target a type parameter of a generic
      * class. See {@link #getSort getSort}.
      */
-    public static final int CLASS_TYPE_PARAMETER = 0x00;
+    public final static int CLASS_TYPE_PARAMETER = 0x00;
 
     /**
      * The sort of type references that target a type parameter of a generic
      * method. See {@link #getSort getSort}.
      */
-    public static final int METHOD_TYPE_PARAMETER = 0x01;
+    public final static int METHOD_TYPE_PARAMETER = 0x01;
 
     /**
      * The sort of type references that target the super class of a class or one
      * of the interfaces it implements. See {@link #getSort getSort}.
      */
-    public static final int CLASS_EXTENDS = 0x10;
+    public final static int CLASS_EXTENDS = 0x10;
 
     /**
      * The sort of type references that target a bound of a type parameter of a
      * generic class. See {@link #getSort getSort}.
      */
-    public static final int CLASS_TYPE_PARAMETER_BOUND = 0x11;
+    public final static int CLASS_TYPE_PARAMETER_BOUND = 0x11;
 
     /**
      * The sort of type references that target a bound of a type parameter of a
      * generic method. See {@link #getSort getSort}.
      */
-    public static final int METHOD_TYPE_PARAMETER_BOUND = 0x12;
+    public final static int METHOD_TYPE_PARAMETER_BOUND = 0x12;
 
     /**
      * The sort of type references that target the type of a field. See
      * {@link #getSort getSort}.
      */
-    public static final int FIELD = 0x13;
+    public final static int FIELD = 0x13;
 
     /**
      * The sort of type references that target the return type of a method. See
      * {@link #getSort getSort}.
      */
-    public static final int METHOD_RETURN = 0x14;
+    public final static int METHOD_RETURN = 0x14;
 
     /**
      * The sort of type references that target the receiver type of a method.
      * See {@link #getSort getSort}.
      */
-    public static final int METHOD_RECEIVER = 0x15;
+    public final static int METHOD_RECEIVER = 0x15;
 
     /**
      * The sort of type references that target the type of a formal parameter of
      * a method. See {@link #getSort getSort}.
      */
-    public static final int METHOD_FORMAL_PARAMETER = 0x16;
+    public final static int METHOD_FORMAL_PARAMETER = 0x16;
 
     /**
      * The sort of type references that target the type of an exception declared
      * in the throws clause of a method. See {@link #getSort getSort}.
      */
-    public static final int THROWS = 0x17;
+    public final static int THROWS = 0x17;
 
     /**
      * The sort of type references that target the type of a local variable in a
      * method. See {@link #getSort getSort}.
      */
-    public static final int LOCAL_VARIABLE = 0x40;
+    public final static int LOCAL_VARIABLE = 0x40;
 
     /**
      * The sort of type references that target the type of a resource variable
      * in a method. See {@link #getSort getSort}.
      */
-    public static final int RESOURCE_VARIABLE = 0x41;
+    public final static int RESOURCE_VARIABLE = 0x41;
 
     /**
      * The sort of type references that target the type of the exception of a
      * 'catch' clause in a method. See {@link #getSort getSort}.
      */
-    public static final int EXCEPTION_PARAMETER = 0x42;
+    public final static int EXCEPTION_PARAMETER = 0x42;
 
     /**
      * The sort of type references that target the type declared in an
      * 'instanceof' instruction. See {@link #getSort getSort}.
      */
-    public static final int INSTANCEOF = 0x43;
+    public final static int INSTANCEOF = 0x43;
 
     /**
      * The sort of type references that target the type of the object created by
      * a 'new' instruction. See {@link #getSort getSort}.
      */
-    public static final int NEW = 0x44;
+    public final static int NEW = 0x44;
 
     /**
      * The sort of type references that target the receiver type of a
      * constructor reference. See {@link #getSort getSort}.
      */
-    public static final int CONSTRUCTOR_REFERENCE = 0x45;
+    public final static int CONSTRUCTOR_REFERENCE = 0x45;
 
     /**
      * The sort of type references that target the receiver type of a method
      * reference. See {@link #getSort getSort}.
      */
-    public static final int METHOD_REFERENCE = 0x46;
+    public final static int METHOD_REFERENCE = 0x46;
 
     /**
      * The sort of type references that target the type declared in an explicit
      * or implicit cast instruction. See {@link #getSort getSort}.
      */
-    public static final int CAST = 0x47;
+    public final static int CAST = 0x47;
 
     /**
      * The sort of type references that target a type parameter of a generic
      * constructor in a constructor call. See {@link #getSort getSort}.
      */
-    public static final int CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT = 0x48;
+    public final static int CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT = 0x48;
 
     /**
      * The sort of type references that target a type parameter of a generic
      * method in a method call. See {@link #getSort getSort}.
      */
-    public static final int METHOD_INVOCATION_TYPE_ARGUMENT = 0x49;
+    public final static int METHOD_INVOCATION_TYPE_ARGUMENT = 0x49;
 
     /**
      * The sort of type references that target a type parameter of a generic
      * constructor in a constructor reference. See {@link #getSort getSort}.
      */
-    public static final int CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT = 0x4A;
+    public final static int CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT = 0x4A;
 
     /**
      * The sort of type references that target a type parameter of a generic
      * method in a method reference. See {@link #getSort getSort}.
      */
-    public static final int METHOD_REFERENCE_TYPE_ARGUMENT = 0x4B;
+    public final static int METHOD_REFERENCE_TYPE_ARGUMENT = 0x4B;
 
     /**
      * The type reference value in Java class file format.
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/AdviceAdapter.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/AdviceAdapter.java	Mon Mar 28 08:41:54 2016 -0700
@@ -389,9 +389,9 @@
                 break;
             case PUTFIELD:
                 popValue();
+                popValue();
                 if (longOrDouble) {
                     popValue();
-                    popValue();
                 }
                 break;
             // case GETFIELD:
@@ -619,7 +619,7 @@
     }
 
     /**
-     * Called at the beginning of the method or after super class class call in
+     * Called at the beginning of the method or after super class call in
      * the constructor. <br>
      * <br>
      *
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/AnnotationRemapper.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,108 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2011 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. Neither the name of the copyright holders nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package jdk.internal.org.objectweb.asm.commons;
+
+import jdk.internal.org.objectweb.asm.AnnotationVisitor;
+import jdk.internal.org.objectweb.asm.Opcodes;
+
+/**
+ * An {@link AnnotationVisitor} adapter for type remapping.
+ *
+ * @author Eugene Kuleshov
+ */
+public class AnnotationRemapper extends AnnotationVisitor {
+
+    protected final Remapper remapper;
+
+    public AnnotationRemapper(final AnnotationVisitor av,
+            final Remapper remapper) {
+        this(Opcodes.ASM5, av, remapper);
+    }
+
+    protected AnnotationRemapper(final int api, final AnnotationVisitor av,
+            final Remapper remapper) {
+        super(api, av);
+        this.remapper = remapper;
+    }
+
+    @Override
+    public void visit(String name, Object value) {
+        av.visit(name, remapper.mapValue(value));
+    }
+
+    @Override
+    public void visitEnum(String name, String desc, String value) {
+        av.visitEnum(name, remapper.mapDesc(desc), value);
+    }
+
+    @Override
+    public AnnotationVisitor visitAnnotation(String name, String desc) {
+        AnnotationVisitor v = av.visitAnnotation(name, remapper.mapDesc(desc));
+        return v == null ? null : (v == av ? this : new AnnotationRemapper(v,
+                remapper));
+    }
+
+    @Override
+    public AnnotationVisitor visitArray(String name) {
+        AnnotationVisitor v = av.visitArray(name);
+        return v == null ? null : (v == av ? this : new AnnotationRemapper(v,
+                remapper));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/ClassRemapper.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,161 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2011 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. Neither the name of the copyright holders nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package jdk.internal.org.objectweb.asm.commons;
+
+import jdk.internal.org.objectweb.asm.AnnotationVisitor;
+import jdk.internal.org.objectweb.asm.ClassVisitor;
+import jdk.internal.org.objectweb.asm.FieldVisitor;
+import jdk.internal.org.objectweb.asm.MethodVisitor;
+import jdk.internal.org.objectweb.asm.Opcodes;
+import jdk.internal.org.objectweb.asm.TypePath;
+
+/**
+ * A {@link ClassVisitor} for type remapping.
+ *
+ * @author Eugene Kuleshov
+ */
+public class ClassRemapper extends ClassVisitor {
+
+    protected final Remapper remapper;
+
+    protected String className;
+
+    public ClassRemapper(final ClassVisitor cv, final Remapper remapper) {
+        this(Opcodes.ASM5, cv, remapper);
+    }
+
+    protected ClassRemapper(final int api, final ClassVisitor cv,
+            final Remapper remapper) {
+        super(api, cv);
+        this.remapper = remapper;
+    }
+
+    @Override
+    public void visit(int version, int access, String name, String signature,
+            String superName, String[] interfaces) {
+        this.className = name;
+        super.visit(version, access, remapper.mapType(name), remapper
+                .mapSignature(signature, false), remapper.mapType(superName),
+                interfaces == null ? null : remapper.mapTypes(interfaces));
+    }
+
+    @Override
+    public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
+        AnnotationVisitor av = super.visitAnnotation(remapper.mapDesc(desc),
+                visible);
+        return av == null ? null : createAnnotationRemapper(av);
+    }
+
+    @Override
+    public AnnotationVisitor visitTypeAnnotation(int typeRef,
+            TypePath typePath, String desc, boolean visible) {
+        AnnotationVisitor av = super.visitTypeAnnotation(typeRef, typePath,
+                remapper.mapDesc(desc), visible);
+        return av == null ? null : createAnnotationRemapper(av);
+    }
+
+    @Override
+    public FieldVisitor visitField(int access, String name, String desc,
+            String signature, Object value) {
+        FieldVisitor fv = super.visitField(access,
+                remapper.mapFieldName(className, name, desc),
+                remapper.mapDesc(desc), remapper.mapSignature(signature, true),
+                remapper.mapValue(value));
+        return fv == null ? null : createFieldRemapper(fv);
+    }
+
+    @Override
+    public MethodVisitor visitMethod(int access, String name, String desc,
+            String signature, String[] exceptions) {
+        String newDesc = remapper.mapMethodDesc(desc);
+        MethodVisitor mv = super.visitMethod(access, remapper.mapMethodName(
+                className, name, desc), newDesc, remapper.mapSignature(
+                signature, false),
+                exceptions == null ? null : remapper.mapTypes(exceptions));
+        return mv == null ? null : createMethodRemapper(mv);
+    }
+
+    @Override
+    public void visitInnerClass(String name, String outerName,
+            String innerName, int access) {
+        // TODO should innerName be changed?
+        super.visitInnerClass(remapper.mapType(name), outerName == null ? null
+                : remapper.mapType(outerName), innerName, access);
+    }
+
+    @Override
+    public void visitOuterClass(String owner, String name, String desc) {
+        super.visitOuterClass(remapper.mapType(owner), name == null ? null
+                : remapper.mapMethodName(owner, name, desc),
+                desc == null ? null : remapper.mapMethodDesc(desc));
+    }
+
+    protected FieldVisitor createFieldRemapper(FieldVisitor fv) {
+        return new FieldRemapper(fv, remapper);
+    }
+
+    protected MethodVisitor createMethodRemapper(MethodVisitor mv) {
+        return new MethodRemapper(mv, remapper);
+    }
+
+    protected AnnotationVisitor createAnnotationRemapper(AnnotationVisitor av) {
+        return new AnnotationRemapper(av, remapper);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/FieldRemapper.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,100 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2011 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. Neither the name of the copyright holders nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package jdk.internal.org.objectweb.asm.commons;
+
+import jdk.internal.org.objectweb.asm.AnnotationVisitor;
+import jdk.internal.org.objectweb.asm.FieldVisitor;
+import jdk.internal.org.objectweb.asm.Opcodes;
+import jdk.internal.org.objectweb.asm.TypePath;
+
+/**
+ * A {@link FieldVisitor} adapter for type remapping.
+ *
+ * @author Eugene Kuleshov
+ */
+public class FieldRemapper extends FieldVisitor {
+
+    private final Remapper remapper;
+
+    public FieldRemapper(final FieldVisitor fv, final Remapper remapper) {
+        this(Opcodes.ASM5, fv, remapper);
+    }
+
+    protected FieldRemapper(final int api, final FieldVisitor fv,
+            final Remapper remapper) {
+        super(api, fv);
+        this.remapper = remapper;
+    }
+
+    @Override
+    public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
+        AnnotationVisitor av = fv.visitAnnotation(remapper.mapDesc(desc),
+                visible);
+        return av == null ? null : new AnnotationRemapper(av, remapper);
+    }
+
+    @Override
+    public AnnotationVisitor visitTypeAnnotation(int typeRef,
+            TypePath typePath, String desc, boolean visible) {
+        AnnotationVisitor av = super.visitTypeAnnotation(typeRef, typePath,
+                remapper.mapDesc(desc), visible);
+        return av == null ? null : new AnnotationRemapper(av, remapper);
+    }
+}
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/InstructionAdapter.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/InstructionAdapter.java	Mon Mar 28 08:41:54 2016 -0700
@@ -73,7 +73,7 @@
  */
 public class InstructionAdapter extends MethodVisitor {
 
-    public static final Type OBJECT_TYPE = Type.getType("Ljava/lang/Object;");
+    public final static Type OBJECT_TYPE = Type.getType("Ljava/lang/Object;");
 
     /**
      * Creates a new {@link InstructionAdapter}. <i>Subclasses must not use this
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/LocalVariablesSorter.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/LocalVariablesSorter.java	Mon Mar 28 08:41:54 2016 -0700
@@ -105,11 +105,6 @@
     protected int nextLocal;
 
     /**
-     * Indicates if at least one local variable has moved due to remapping.
-     */
-    private boolean changed;
-
-    /**
      * Creates a new {@link LocalVariablesSorter}. <i>Subclasses must not use
      * this constructor</i>. Instead, they must use the
      * {@link #LocalVariablesSorter(int, int, String, MethodVisitor)} version.
@@ -228,11 +223,6 @@
                     "ClassReader.accept() should be called with EXPAND_FRAMES flag");
         }
 
-        if (!changed) { // optimization for the case where mapping = identity
-            mv.visitFrame(type, nLocal, local, nStack, stack);
-            return;
-        }
-
         // creates a copy of newLocals
         Object[] oldLocals = new Object[newLocals.length];
         System.arraycopy(newLocals, 0, oldLocals, 0, oldLocals.length);
@@ -328,7 +318,6 @@
         int local = newLocalMapping(type);
         setLocalType(local, type);
         setFrameLocal(local, t);
-        changed = true;
         return local;
     }
 
@@ -396,9 +385,6 @@
         } else {
             value--;
         }
-        if (value != var) {
-            changed = true;
-        }
         return value;
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/MethodRemapper.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,252 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2011 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. Neither the name of the copyright holders nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package jdk.internal.org.objectweb.asm.commons;
+
+import jdk.internal.org.objectweb.asm.AnnotationVisitor;
+import jdk.internal.org.objectweb.asm.Handle;
+import jdk.internal.org.objectweb.asm.Label;
+import jdk.internal.org.objectweb.asm.MethodVisitor;
+import jdk.internal.org.objectweb.asm.Opcodes;
+import jdk.internal.org.objectweb.asm.TypePath;
+
+/**
+ * A {@link LocalVariablesSorter} for type mapping.
+ *
+ * @author Eugene Kuleshov
+ */
+public class MethodRemapper extends MethodVisitor {
+
+    protected final Remapper remapper;
+
+    public MethodRemapper(final MethodVisitor mv, final Remapper remapper) {
+        this(Opcodes.ASM5, mv, remapper);
+    }
+
+    protected MethodRemapper(final int api, final MethodVisitor mv,
+            final Remapper remapper) {
+        super(api, mv);
+        this.remapper = remapper;
+    }
+
+    @Override
+    public AnnotationVisitor visitAnnotationDefault() {
+        AnnotationVisitor av = super.visitAnnotationDefault();
+        return av == null ? av : new AnnotationRemapper(av, remapper);
+    }
+
+    @Override
+    public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
+        AnnotationVisitor av = super.visitAnnotation(remapper.mapDesc(desc),
+                visible);
+        return av == null ? av : new AnnotationRemapper(av, remapper);
+    }
+
+    @Override
+    public AnnotationVisitor visitTypeAnnotation(int typeRef,
+            TypePath typePath, String desc, boolean visible) {
+        AnnotationVisitor av = super.visitTypeAnnotation(typeRef, typePath,
+                remapper.mapDesc(desc), visible);
+        return av == null ? av : new AnnotationRemapper(av, remapper);
+    }
+
+    @Override
+    public AnnotationVisitor visitParameterAnnotation(int parameter,
+            String desc, boolean visible) {
+        AnnotationVisitor av = super.visitParameterAnnotation(parameter,
+                remapper.mapDesc(desc), visible);
+        return av == null ? av : new AnnotationRemapper(av, remapper);
+    }
+
+    @Override
+    public void visitFrame(int type, int nLocal, Object[] local, int nStack,
+            Object[] stack) {
+        super.visitFrame(type, nLocal, remapEntries(nLocal, local), nStack,
+                remapEntries(nStack, stack));
+    }
+
+    private Object[] remapEntries(int n, Object[] entries) {
+        for (int i = 0; i < n; i++) {
+            if (entries[i] instanceof String) {
+                Object[] newEntries = new Object[n];
+                if (i > 0) {
+                    System.arraycopy(entries, 0, newEntries, 0, i);
+                }
+                do {
+                    Object t = entries[i];
+                    newEntries[i++] = t instanceof String ? remapper
+                            .mapType((String) t) : t;
+                } while (i < n);
+                return newEntries;
+            }
+        }
+        return entries;
+    }
+
+    @Override
+    public void visitFieldInsn(int opcode, String owner, String name,
+            String desc) {
+        super.visitFieldInsn(opcode, remapper.mapType(owner),
+                remapper.mapFieldName(owner, name, desc),
+                remapper.mapDesc(desc));
+    }
+
+    @Deprecated
+    @Override
+    public void visitMethodInsn(final int opcode, final String owner,
+            final String name, final String desc) {
+        if (api >= Opcodes.ASM5) {
+            super.visitMethodInsn(opcode, owner, name, desc);
+            return;
+        }
+        doVisitMethodInsn(opcode, owner, name, desc,
+                opcode == Opcodes.INVOKEINTERFACE);
+    }
+
+    @Override
+    public void visitMethodInsn(final int opcode, final String owner,
+            final String name, final String desc, final boolean itf) {
+        if (api < Opcodes.ASM5) {
+            super.visitMethodInsn(opcode, owner, name, desc, itf);
+            return;
+        }
+        doVisitMethodInsn(opcode, owner, name, desc, itf);
+    }
+
+    private void doVisitMethodInsn(int opcode, String owner, String name,
+            String desc, boolean itf) {
+        // Calling super.visitMethodInsn requires to call the correct version
+        // depending on this.api (otherwise infinite loops can occur). To
+        // simplify and to make it easier to automatically remove the backward
+        // compatibility code, we inline the code of the overridden method here.
+        // IMPORTANT: THIS ASSUMES THAT visitMethodInsn IS NOT OVERRIDDEN IN
+        // LocalVariableSorter.
+        if (mv != null) {
+            mv.visitMethodInsn(opcode, remapper.mapType(owner),
+                    remapper.mapMethodName(owner, name, desc),
+                    remapper.mapMethodDesc(desc), itf);
+        }
+    }
+
+    @Override
+    public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,
+            Object... bsmArgs) {
+        for (int i = 0; i < bsmArgs.length; i++) {
+            bsmArgs[i] = remapper.mapValue(bsmArgs[i]);
+        }
+        super.visitInvokeDynamicInsn(
+                remapper.mapInvokeDynamicMethodName(name, desc),
+                remapper.mapMethodDesc(desc), (Handle) remapper.mapValue(bsm),
+                bsmArgs);
+    }
+
+    @Override
+    public void visitTypeInsn(int opcode, String type) {
+        super.visitTypeInsn(opcode, remapper.mapType(type));
+    }
+
+    @Override
+    public void visitLdcInsn(Object cst) {
+        super.visitLdcInsn(remapper.mapValue(cst));
+    }
+
+    @Override
+    public void visitMultiANewArrayInsn(String desc, int dims) {
+        super.visitMultiANewArrayInsn(remapper.mapDesc(desc), dims);
+    }
+
+    @Override
+    public AnnotationVisitor visitInsnAnnotation(int typeRef,
+            TypePath typePath, String desc, boolean visible) {
+        AnnotationVisitor av = super.visitInsnAnnotation(typeRef, typePath,
+                remapper.mapDesc(desc), visible);
+        return av == null ? av : new AnnotationRemapper(av, remapper);
+    }
+
+    @Override
+    public void visitTryCatchBlock(Label start, Label end, Label handler,
+            String type) {
+        super.visitTryCatchBlock(start, end, handler, type == null ? null
+                : remapper.mapType(type));
+    }
+
+    @Override
+    public AnnotationVisitor visitTryCatchAnnotation(int typeRef,
+            TypePath typePath, String desc, boolean visible) {
+        AnnotationVisitor av = super.visitTryCatchAnnotation(typeRef, typePath,
+                remapper.mapDesc(desc), visible);
+        return av == null ? av : new AnnotationRemapper(av, remapper);
+    }
+
+    @Override
+    public void visitLocalVariable(String name, String desc, String signature,
+            Label start, Label end, int index) {
+        super.visitLocalVariable(name, remapper.mapDesc(desc),
+                remapper.mapSignature(signature, true), start, end, index);
+    }
+
+    @Override
+    public AnnotationVisitor visitLocalVariableAnnotation(int typeRef,
+            TypePath typePath, Label[] start, Label[] end, int[] index,
+            String desc, boolean visible) {
+        AnnotationVisitor av = super.visitLocalVariableAnnotation(typeRef,
+                typePath, start, end, index, remapper.mapDesc(desc), visible);
+        return av == null ? av : new AnnotationRemapper(av, remapper);
+    }
+}
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/Remapper.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/Remapper.java	Mon Mar 28 08:41:54 2016 -0700
@@ -168,17 +168,19 @@
             Handle h = (Handle) value;
             return new Handle(h.getTag(), mapType(h.getOwner()), mapMethodName(
                     h.getOwner(), h.getName(), h.getDesc()),
-                    mapMethodDesc(h.getDesc()));
+                    mapMethodDesc(h.getDesc()), h.isInterface());
         }
         return value;
     }
 
     /**
-     *
+     * @param signature
+     *            signature for mapper
      * @param typeSignature
      *            true if signature is a FieldTypeSignature, such as the
      *            signature parameter of the ClassVisitor.visitField or
      *            MethodVisitor.visitLocalVariable methods
+     * @return signature rewritten as a string
      */
     public String mapSignature(String signature, boolean typeSignature) {
         if (signature == null) {
@@ -186,7 +188,7 @@
         }
         SignatureReader r = new SignatureReader(signature);
         SignatureWriter w = new SignatureWriter();
-        SignatureVisitor a = createRemappingSignatureAdapter(w);
+        SignatureVisitor a = createSignatureRemapper(w);
         if (typeSignature) {
             r.acceptType(a);
         } else {
@@ -195,9 +197,18 @@
         return w.toString();
     }
 
+    /**
+     * @deprecated use {@link #createSignatureRemapper} instead.
+     */
+    @Deprecated
     protected SignatureVisitor createRemappingSignatureAdapter(
             SignatureVisitor v) {
-        return new RemappingSignatureAdapter(v, this);
+        return new SignatureRemapper(v, this);
+    }
+
+    protected SignatureVisitor createSignatureRemapper(
+            SignatureVisitor v) {
+        return createRemappingSignatureAdapter(v);
     }
 
     /**
@@ -245,6 +256,10 @@
 
     /**
      * Map type name to the new name. Subclasses can override.
+     *
+     * @param typeName
+     *            the type name
+     * @return new name, default implementation is the identity.
      */
     public String map(String typeName) {
         return typeName;
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/RemappingAnnotationAdapter.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/RemappingAnnotationAdapter.java	Mon Mar 28 08:41:54 2016 -0700
@@ -65,8 +65,10 @@
 /**
  * An {@link AnnotationVisitor} adapter for type remapping.
  *
+ * //@deprecated use {@link AnnotationRemapper} instead.
  * @author Eugene Kuleshov
  */
+//@Deprecated
 public class RemappingAnnotationAdapter extends AnnotationVisitor {
 
     protected final Remapper remapper;
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/RemappingClassAdapter.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/RemappingClassAdapter.java	Mon Mar 28 08:41:54 2016 -0700
@@ -69,8 +69,10 @@
 /**
  * A {@link ClassVisitor} for type remapping.
  *
+ * @deprecated use {@link ClassRemapper} instead.
  * @author Eugene Kuleshov
  */
+@Deprecated
 public class RemappingClassAdapter extends ClassVisitor {
 
     protected final Remapper remapper;
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/RemappingFieldAdapter.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/RemappingFieldAdapter.java	Mon Mar 28 08:41:54 2016 -0700
@@ -67,8 +67,10 @@
 /**
  * A {@link FieldVisitor} adapter for type remapping.
  *
+ * @deprecated use {@link FieldRemapper} instead.
  * @author Eugene Kuleshov
  */
+@Deprecated
 public class RemappingFieldAdapter extends FieldVisitor {
 
     private final Remapper remapper;
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/RemappingMethodAdapter.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/RemappingMethodAdapter.java	Mon Mar 28 08:41:54 2016 -0700
@@ -69,8 +69,10 @@
 /**
  * A {@link LocalVariablesSorter} for type mapping.
  *
+ * //@deprecated use {@link MethodRemapper} instead.
  * @author Eugene Kuleshov
  */
+//@Deprecated
 public class RemappingMethodAdapter extends LocalVariablesSorter {
 
     protected final Remapper remapper;
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/RemappingSignatureAdapter.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/RemappingSignatureAdapter.java	Mon Mar 28 08:41:54 2016 -0700
@@ -65,8 +65,10 @@
 /**
  * A {@link SignatureVisitor} adapter for type mapping.
  *
+ * @deprecated use {@link SignatureRemapper} instead.
  * @author Eugene Kuleshov
  */
+@Deprecated
 public class RemappingSignatureAdapter extends SignatureVisitor {
 
     private final SignatureVisitor v;
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/SerialVersionUIDAdder.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/SerialVersionUIDAdder.java	Mon Mar 28 08:41:54 2016 -0700
@@ -234,7 +234,7 @@
     public void visit(final int version, final int access, final String name,
             final String signature, final String superName,
             final String[] interfaces) {
-        computeSVUID = (access & Opcodes.ACC_INTERFACE) == 0;
+        computeSVUID = (access & Opcodes.ACC_ENUM) == 0;
 
         if (computeSVUID) {
             this.name = name;
@@ -396,6 +396,11 @@
             /*
              * 2. The class modifiers written as a 32-bit integer.
              */
+            int access = this.access;
+            if ((access & Opcodes.ACC_INTERFACE) != 0) {
+                access = (svuidMethods.size() > 0) ? (access | Opcodes.ACC_ABSTRACT)
+                        : (access & ~Opcodes.ACC_ABSTRACT);
+            }
             dos.writeInt(access
                     & (Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL
                             | Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/SignatureRemapper.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,188 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * ASM: a very small and fast Java bytecode manipulation framework
+ * Copyright (c) 2000-2011 INRIA, France Telecom
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. Neither the name of the copyright holders nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package jdk.internal.org.objectweb.asm.commons;
+
+import java.util.Stack;
+
+import jdk.internal.org.objectweb.asm.Opcodes;
+import jdk.internal.org.objectweb.asm.signature.SignatureVisitor;
+
+/**
+ * A {@link SignatureVisitor} adapter for type mapping.
+ *
+ * @author Eugene Kuleshov
+ */
+public class SignatureRemapper extends SignatureVisitor {
+
+    private final SignatureVisitor v;
+
+    private final Remapper remapper;
+
+    private Stack<String> classNames = new Stack<String>();
+
+    public SignatureRemapper(final SignatureVisitor v, final Remapper remapper) {
+        this(Opcodes.ASM5, v, remapper);
+    }
+
+    protected SignatureRemapper(final int api, final SignatureVisitor v,
+            final Remapper remapper) {
+        super(api);
+        this.v = v;
+        this.remapper = remapper;
+    }
+
+    @Override
+    public void visitClassType(String name) {
+        classNames.push(name);
+        v.visitClassType(remapper.mapType(name));
+    }
+
+    @Override
+    public void visitInnerClassType(String name) {
+        String outerClassName = classNames.pop();
+        String className = outerClassName + '$' + name;
+        classNames.push(className);
+        String remappedOuter = remapper.mapType(outerClassName) + '$';
+        String remappedName = remapper.mapType(className);
+        int index = remappedName.startsWith(remappedOuter) ? remappedOuter
+                .length() : remappedName.lastIndexOf('$') + 1;
+        v.visitInnerClassType(remappedName.substring(index));
+    }
+
+    @Override
+    public void visitFormalTypeParameter(String name) {
+        v.visitFormalTypeParameter(name);
+    }
+
+    @Override
+    public void visitTypeVariable(String name) {
+        v.visitTypeVariable(name);
+    }
+
+    @Override
+    public SignatureVisitor visitArrayType() {
+        v.visitArrayType();
+        return this;
+    }
+
+    @Override
+    public void visitBaseType(char descriptor) {
+        v.visitBaseType(descriptor);
+    }
+
+    @Override
+    public SignatureVisitor visitClassBound() {
+        v.visitClassBound();
+        return this;
+    }
+
+    @Override
+    public SignatureVisitor visitExceptionType() {
+        v.visitExceptionType();
+        return this;
+    }
+
+    @Override
+    public SignatureVisitor visitInterface() {
+        v.visitInterface();
+        return this;
+    }
+
+    @Override
+    public SignatureVisitor visitInterfaceBound() {
+        v.visitInterfaceBound();
+        return this;
+    }
+
+    @Override
+    public SignatureVisitor visitParameterType() {
+        v.visitParameterType();
+        return this;
+    }
+
+    @Override
+    public SignatureVisitor visitReturnType() {
+        v.visitReturnType();
+        return this;
+    }
+
+    @Override
+    public SignatureVisitor visitSuperclass() {
+        v.visitSuperclass();
+        return this;
+    }
+
+    @Override
+    public void visitTypeArgument() {
+        v.visitTypeArgument();
+    }
+
+    @Override
+    public SignatureVisitor visitTypeArgument(char wildcard) {
+        v.visitTypeArgument(wildcard);
+        return this;
+    }
+
+    @Override
+    public void visitEnd() {
+        v.visitEnd();
+        classNames.pop();
+    }
+}
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/SimpleRemapper.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/SimpleRemapper.java	Mon Mar 28 08:41:54 2016 -0700
@@ -86,6 +86,12 @@
     }
 
     @Override
+    public String mapInvokeDynamicMethodName(String name, String desc) {
+        String s = map('.' + name + desc);
+        return s == null ? name : s;
+    }
+
+    @Override
     public String mapFieldName(String owner, String name, String desc) {
         String s = map(owner + '.' + name);
         return s == null ? name : s;
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/signature/SignatureVisitor.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/signature/SignatureVisitor.java	Mon Mar 28 08:41:54 2016 -0700
@@ -68,7 +68,7 @@
  * <ul>
  * <li><i>ClassSignature</i> = ( <tt>visitFormalTypeParameter</tt>
  * <tt>visitClassBound</tt>? <tt>visitInterfaceBound</tt>* )* (
- * <tt>visitSuperClass</tt> <tt>visitInterface</tt>* )</li>
+ * <tt>visitSuperclass</tt> <tt>visitInterface</tt>* )</li>
  * <li><i>MethodSignature</i> = ( <tt>visitFormalTypeParameter</tt>
  * <tt>visitClassBound</tt>? <tt>visitInterfaceBound</tt>* )* (
  * <tt>visitParameterType</tt>* <tt>visitReturnType</tt>
@@ -88,17 +88,17 @@
     /**
      * Wildcard for an "extends" type argument.
      */
-    public static final char EXTENDS = '+';
+    public final static char EXTENDS = '+';
 
     /**
      * Wildcard for a "super" type argument.
      */
-    public static final char SUPER = '-';
+    public final static char SUPER = '-';
 
     /**
      * Wildcard for a normal type argument.
      */
-    public static final char INSTANCEOF = '=';
+    public final static char INSTANCEOF = '=';
 
     /**
      * The ASM API version implemented by this visitor. The value of this field
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/signature/SignatureWriter.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/signature/SignatureWriter.java	Mon Mar 28 08:41:54 2016 -0700
@@ -69,9 +69,9 @@
 public class SignatureWriter extends SignatureVisitor {
 
     /**
-     * Buffer used to construct the signature.
+     * Builder used to construct the signature.
      */
-    private final StringBuffer buf = new StringBuffer();
+    private final StringBuilder buf = new StringBuilder();
 
     /**
      * Indicates if the signature contains formal type parameters.
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/InsnList.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/tree/InsnList.java	Mon Mar 28 08:41:54 2016 -0700
@@ -205,6 +205,9 @@
     /**
      * Returns an iterator over the instructions in this list.
      *
+     * @param index
+     *            index of instruction for the iterator to start at
+     *
      * @return an iterator over the instructions in this list.
      */
     @SuppressWarnings("unchecked")
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/ASMifier.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/ASMifier.java	Mon Mar 28 08:41:54 2016 -0700
@@ -856,7 +856,11 @@
         buf.append("{\n").append("av0 = ").append(name)
                 .append(".visitLocalVariableAnnotation(");
         buf.append(typeRef);
-        buf.append(", TypePath.fromString(\"").append(typePath).append("\"), ");
+        if (typePath == null) {
+            buf.append(", null, ");
+        } else {
+            buf.append(", TypePath.fromString(\"").append(typePath).append("\"), ");
+        }
         buf.append("new Label[] {");
         for (int i = 0; i < start.length; ++i) {
             buf.append(i == 0 ? " " : ", ");
@@ -934,7 +938,11 @@
         buf.append("{\n").append("av0 = ").append(name).append(".")
                 .append(method).append("(");
         buf.append(typeRef);
-        buf.append(", TypePath.fromString(\"").append(typePath).append("\"), ");
+        if (typePath == null) {
+            buf.append(", null, ");
+        } else {
+            buf.append(", TypePath.fromString(\"").append(typePath).append("\"), ");
+        }
         appendConstant(desc);
         buf.append(", ").append(visible).append(");\n");
         text.add(buf.toString());
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckMethodAdapter.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckMethodAdapter.java	Mon Mar 28 08:41:54 2016 -0700
@@ -437,6 +437,9 @@
      * will not perform any data flow check (see
      * {@link #CheckMethodAdapter(int,String,String,MethodVisitor,Map)}).
      *
+     * @param api
+     *            the ASM API version implemented by this CheckMethodAdapter.
+     *            Must be one of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
      * @param mv
      *            the method visitor to which this adapter must delegate calls.
      * @param labels
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/Printer.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/Printer.java	Mon Mar 28 08:41:54 2016 -0700
@@ -171,6 +171,10 @@
 
     /**
      * Constructs a new {@link Printer}.
+     *
+     * @param api
+     *            the ASM API version implemented by this printer. Must be one
+     *            of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
      */
     protected Printer(final int api) {
         this.api = api;
@@ -179,34 +183,103 @@
     }
 
     /**
-     * Class header. See {@link jdk.internal.org.objectweb.asm.ClassVisitor#visit}.
+     * Class header.
+     * See {@link jdk.internal.org.objectweb.asm.ClassVisitor#visit}.
+     *
+     * @param version
+     *            the class version.
+     * @param access
+     *            the class's access flags (see {@link Opcodes}). This parameter
+     *            also indicates if the class is deprecated.
+     * @param name
+     *            the internal name of the class (see
+     *            {@link jdk.internal.org.objectweb.asm.Type#getInternalName() getInternalName}).
+     * @param signature
+     *            the signature of this class. May be <tt>null</tt> if the class
+     *            is not a generic one, and does not extend or implement generic
+     *            classes or interfaces.
+     * @param superName
+     *            the internal of name of the super class (see
+     *            {@link jdk.internal.org.objectweb.asm.Type#getInternalName() getInternalName}).
+     *            For interfaces, the super class is {@link Object}. May be
+     *            <tt>null</tt>, but only for the {@link Object} class.
+     * @param interfaces
+     *            the internal names of the class's interfaces (see
+     *            {@link jdk.internal.org.objectweb.asm.Type#getInternalName() getInternalName}).
+     *            May be <tt>null</tt>.
      */
     public abstract void visit(final int version, final int access,
             final String name, final String signature, final String superName,
             final String[] interfaces);
 
     /**
-     * Class source. See {@link jdk.internal.org.objectweb.asm.ClassVisitor#visitSource}.
+     * Class source.
+     * See {@link jdk.internal.org.objectweb.asm.ClassVisitor#visitSource}.
+     *
+     * @param source
+     *            the name of the source file from which the class was compiled.
+     *            May be <tt>null</tt>.
+     * @param debug
+     *            additional debug information to compute the correspondance
+     *            between source and compiled elements of the class. May be
+     *            <tt>null</tt>.
      */
-    public abstract void visitSource(final String file, final String debug);
+    public abstract void visitSource(final String source, final String debug);
 
     /**
-     * Class outer class. See
-     * {@link jdk.internal.org.objectweb.asm.ClassVisitor#visitOuterClass}.
+     * Class outer class.
+     * See {@link jdk.internal.org.objectweb.asm.ClassVisitor#visitOuterClass}.
+     *
+     * Visits the enclosing class of the class. This method must be called only
+     * if the class has an enclosing class.
+     *
+     * @param owner
+     *            internal name of the enclosing class of the class.
+     * @param name
+     *            the name of the method that contains the class, or
+     *            <tt>null</tt> if the class is not enclosed in a method of its
+     *            enclosing class.
+     * @param desc
+     *            the descriptor of the method that contains the class, or
+     *            <tt>null</tt> if the class is not enclosed in a method of its
+     *            enclosing class.
      */
     public abstract void visitOuterClass(final String owner, final String name,
             final String desc);
 
     /**
-     * Class annotation. See
-     * {@link jdk.internal.org.objectweb.asm.ClassVisitor#visitAnnotation}.
+     * Class annotation.
+     * See {@link jdk.internal.org.objectweb.asm.ClassVisitor#visitAnnotation}.
+     *
+     * @param desc
+     *            the class descriptor of the annotation class.
+     * @param visible
+     *            <tt>true</tt> if the annotation is visible at runtime.
+     * @return the printer
      */
     public abstract Printer visitClassAnnotation(final String desc,
             final boolean visible);
 
     /**
-     * Class type annotation. See
-     * {@link jdk.internal.org.objectweb.asm.ClassVisitor#visitTypeAnnotation}.
+     * Class type annotation.
+     * See {@link jdk.internal.org.objectweb.asm.ClassVisitor#visitTypeAnnotation}.
+     *
+     * @param typeRef
+     *            a reference to the annotated type. The sort of this type
+     *            reference must be
+     *            {@link jdk.internal.org.objectweb.asm.TypeReference#CLASS_TYPE_PARAMETER CLASS_TYPE_PARAMETER},
+     *            {@link jdk.internal.org.objectweb.asm.TypeReference#CLASS_TYPE_PARAMETER_BOUND CLASS_TYPE_PARAMETER_BOUND}
+     *            or {@link jdk.internal.org.objectweb.asm.TypeReference#CLASS_EXTENDS CLASS_EXTENDS}.
+     *            See {@link jdk.internal.org.objectweb.asm.TypeReference}.
+     * @param typePath
+     *            the path to the annotated type argument, wildcard bound, array
+     *            element type, or static inner type within 'typeRef'. May be
+     *            <tt>null</tt> if the annotation targets 'typeRef' as a whole.
+     * @param desc
+     *            the class descriptor of the annotation class.
+     * @param visible
+     *            <tt>true</tt> if the annotation is visible at runtime.
+     * @return the printer
      */
     public Printer visitClassTypeAnnotation(final int typeRef,
             final TypePath typePath, final String desc, final boolean visible) {
@@ -214,26 +287,85 @@
     }
 
     /**
-     * Class attribute. See
-     * {@link jdk.internal.org.objectweb.asm.ClassVisitor#visitAttribute}.
+     * Class attribute.
+     * See {@link jdk.internal.org.objectweb.asm.ClassVisitor#visitAttribute}.
+     *
+     * @param attr
+     *            an attribute.
      */
     public abstract void visitClassAttribute(final Attribute attr);
 
     /**
-     * Class inner name. See
-     * {@link jdk.internal.org.objectweb.asm.ClassVisitor#visitInnerClass}.
+     * Class inner name.
+     * See {@link jdk.internal.org.objectweb.asm.ClassVisitor#visitInnerClass}.
+     *
+     * @param name
+     *            the internal name of an inner class (see
+     *            {@link jdk.internal.org.objectweb.asm.Type#getInternalName() getInternalName}).
+     * @param outerName
+     *            the internal name of the class to which the inner class
+     *            belongs (see {@link jdk.internal.org.objectweb.asm.Type#getInternalName() getInternalName}).
+     *            May be <tt>null</tt> for not member classes.
+     * @param innerName
+     *            the (simple) name of the inner class inside its enclosing
+     *            class. May be <tt>null</tt> for anonymous inner classes.
+     * @param access
+     *            the access flags of the inner class as originally declared in
+     *            the enclosing class.
      */
     public abstract void visitInnerClass(final String name,
             final String outerName, final String innerName, final int access);
 
     /**
-     * Class field. See {@link jdk.internal.org.objectweb.asm.ClassVisitor#visitField}.
+     * Class field.
+     * See {@link jdk.internal.org.objectweb.asm.ClassVisitor#visitField}.
+     *
+     * @param access
+     *            the field's access flags (see {@link Opcodes}). This parameter
+     *            also indicates if the field is synthetic and/or deprecated.
+     * @param name
+     *            the field's name.
+     * @param desc
+     *            the field's descriptor (see {@link jdk.internal.org.objectweb.asm.Type Type}).
+     * @param signature
+     *            the field's signature. May be <tt>null</tt> if the field's
+     *            type does not use generic types.
+     * @param value
+     *            the field's initial value. This parameter, which may be
+     *            <tt>null</tt> if the field does not have an initial value,
+     *            must be an {@link Integer}, a {@link Float}, a {@link Long}, a
+     *            {@link Double} or a {@link String} (for <tt>int</tt>,
+     *            <tt>float</tt>, <tt>long</tt> or <tt>String</tt> fields
+     *            respectively). <i>This parameter is only used for static
+     *            fields</i>. Its value is ignored for non static fields, which
+     *            must be initialized through bytecode instructions in
+     *            constructors or methods.
+     * @return the printer
      */
     public abstract Printer visitField(final int access, final String name,
             final String desc, final String signature, final Object value);
 
     /**
-     * Class method. See {@link jdk.internal.org.objectweb.asm.ClassVisitor#visitMethod}.
+     * Class method.
+     * See {@link jdk.internal.org.objectweb.asm.ClassVisitor#visitMethod}.
+     *
+     * @param access
+     *            the method's access flags (see {@link Opcodes}). This
+     *            parameter also indicates if the method is synthetic and/or
+     *            deprecated.
+     * @param name
+     *            the method's name.
+     * @param desc
+     *            the method's descriptor (see {@link jdk.internal.org.objectweb.asm.Type Type}).
+     * @param signature
+     *            the method's signature. May be <tt>null</tt> if the method
+     *            parameters, return type and exceptions do not use generic
+     *            types.
+     * @param exceptions
+     *            the internal names of the method's exception classes (see
+     *            {@link jdk.internal.org.objectweb.asm.Type#getInternalName() getInternalName}). May be
+     *            <tt>null</tt>.
+     * @return the printer
      */
     public abstract Printer visitMethod(final int access, final String name,
             final String desc, final String signature, final String[] exceptions);
@@ -248,26 +380,64 @@
     // ------------------------------------------------------------------------
 
     /**
-     * Annotation value. See {@link jdk.internal.org.objectweb.asm.AnnotationVisitor#visit}.
+     * Annotation value.
+     * See {@link jdk.internal.org.objectweb.asm.AnnotationVisitor#visit}.
+     *
+     * @param name
+     *            the value name.
+     * @param value
+     *            the actual value, whose type must be {@link Byte},
+     *            {@link Boolean}, {@link Character}, {@link Short},
+     *            {@link Integer} , {@link Long}, {@link Float}, {@link Double},
+     *            {@link String} or {@link jdk.internal.org.objectweb.asm.Type}
+     *            or OBJECT or ARRAY sort.
+     *            This value can also be an array of byte, boolean, short, char, int,
+     *            long, float or double values (this is equivalent to using
+     *            {@link #visitArray visitArray} and visiting each array element
+     *            in turn, but is more convenient).
      */
     public abstract void visit(final String name, final Object value);
 
     /**
-     * Annotation enum value. See
-     * {@link jdk.internal.org.objectweb.asm.AnnotationVisitor#visitEnum}.
+     * Annotation enum value.
+     * See {@link jdk.internal.org.objectweb.asm.AnnotationVisitor#visitEnum}.
+     *
+     * Visits an enumeration value of the annotation.
+     *
+     * @param name
+     *            the value name.
+     * @param desc
+     *            the class descriptor of the enumeration class.
+     * @param value
+     *            the actual enumeration value.
      */
     public abstract void visitEnum(final String name, final String desc,
             final String value);
 
     /**
-     * Nested annotation value. See
-     * {@link jdk.internal.org.objectweb.asm.AnnotationVisitor#visitAnnotation}.
+     * Nested annotation value.
+     * See {@link jdk.internal.org.objectweb.asm.AnnotationVisitor#visitAnnotation}.
+     *
+     * @param name
+     *            the value name.
+     * @param desc
+     *            the class descriptor of the nested annotation class.
+     * @return the printer
      */
     public abstract Printer visitAnnotation(final String name, final String desc);
 
     /**
-     * Annotation array value. See
-     * {@link jdk.internal.org.objectweb.asm.AnnotationVisitor#visitArray}.
+     * Annotation array value.
+     * See {@link jdk.internal.org.objectweb.asm.AnnotationVisitor#visitArray}.
+     *
+     * Visits an array value of the annotation. Note that arrays of primitive
+     * types (such as byte, boolean, short, char, int, long, float or double)
+     * can be passed as value to {@link #visit visit}. This is what
+     * {@link jdk.internal.org.objectweb.asm.ClassReader} does.
+     *
+     * @param name
+     *            the value name.
+     * @return the printer
      */
     public abstract Printer visitArray(final String name);
 
@@ -281,15 +451,35 @@
     // ------------------------------------------------------------------------
 
     /**
-     * Field annotation. See
-     * {@link jdk.internal.org.objectweb.asm.FieldVisitor#visitAnnotation}.
+     * Field annotation.
+     * See {@link jdk.internal.org.objectweb.asm.FieldVisitor#visitAnnotation}.
+     *
+     * @param desc
+     *            the class descriptor of the annotation class.
+     * @param visible
+     *            <tt>true</tt> if the annotation is visible at runtime.
+     * @return the printer
      */
     public abstract Printer visitFieldAnnotation(final String desc,
             final boolean visible);
 
     /**
-     * Field type annotation. See
-     * {@link jdk.internal.org.objectweb.asm.FieldVisitor#visitTypeAnnotation}.
+     * Field type annotation.
+     * See {@link jdk.internal.org.objectweb.asm.FieldVisitor#visitTypeAnnotation}.
+     *
+     * @param typeRef
+     *            a reference to the annotated type. The sort of this type
+     *            reference must be {@link jdk.internal.org.objectweb.asm.TypeReference#FIELD FIELD}.
+     *            See {@link jdk.internal.org.objectweb.asm.TypeReference}.
+     * @param typePath
+     *            the path to the annotated type argument, wildcard bound, array
+     *            element type, or static inner type within 'typeRef'. May be
+     *            <tt>null</tt> if the annotation targets 'typeRef' as a whole.
+     * @param desc
+     *            the class descriptor of the annotation class.
+     * @param visible
+     *            <tt>true</tt> if the annotation is visible at runtime.
+     * @return the printer
      */
     public Printer visitFieldTypeAnnotation(final int typeRef,
             final TypePath typePath, final String desc, final boolean visible) {
@@ -297,13 +487,17 @@
     }
 
     /**
-     * Field attribute. See
-     * {@link jdk.internal.org.objectweb.asm.FieldVisitor#visitAttribute}.
+     * Field attribute.
+     * See {@link jdk.internal.org.objectweb.asm.FieldVisitor#visitAttribute}.
+     *
+     * @param attr
+     *            an attribute.
      */
     public abstract void visitFieldAttribute(final Attribute attr);
 
     /**
-     * Field end. See {@link jdk.internal.org.objectweb.asm.FieldVisitor#visitEnd}.
+     * Field end.
+     * See {@link jdk.internal.org.objectweb.asm.FieldVisitor#visitEnd}.
      */
     public abstract void visitFieldEnd();
 
@@ -312,29 +506,58 @@
     // ------------------------------------------------------------------------
 
     /**
-     * Method parameter. See
-     * {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitParameter(String, int)}.
+     * Method parameter.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitParameter(String, int)}.
+     *
+     * @param name
+     *            parameter name or null if none is provided.
+     * @param access
+     *            the parameter's access flags, only <tt>ACC_FINAL</tt>,
+     *            <tt>ACC_SYNTHETIC</tt> or/and <tt>ACC_MANDATED</tt> are
+     *            allowed (see {@link Opcodes}).
      */
     public void visitParameter(String name, int access) {
         throw new RuntimeException("Must be overriden");
     }
 
     /**
-     * Method default annotation. See
-     * {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitAnnotationDefault}.
+     * Method default annotation.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitAnnotationDefault}.
+     *
+     * @return the printer
      */
     public abstract Printer visitAnnotationDefault();
 
     /**
-     * Method annotation. See
-     * {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitAnnotation}.
+     * Method annotation.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitAnnotation}.
+     *
+     * @param desc
+     *            the class descriptor of the annotation class.
+     * @param visible
+     *            <tt>true</tt> if the annotation is visible at runtime.
+     * @return the printer
      */
     public abstract Printer visitMethodAnnotation(final String desc,
             final boolean visible);
 
     /**
-     * Method type annotation. See
-     * {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitTypeAnnotation}.
+     * Method type annotation.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitTypeAnnotation}.
+     *
+     * @param typeRef
+     *            a reference to the annotated type. The sort of this type
+     *            reference must be {@link jdk.internal.org.objectweb.asm.TypeReference#FIELD FIELD}.
+     *            See {@link jdk.internal.org.objectweb.asm.TypeReference}.
+     * @param typePath
+     *            the path to the annotated type argument, wildcard bound, array
+     *            element type, or static inner type within 'typeRef'. May be
+     *            <tt>null</tt> if the annotation targets 'typeRef' as a whole.
+     * @param desc
+     *            the class descriptor of the annotation class.
+     * @param visible
+     *            <tt>true</tt> if the annotation is visible at runtime.
+     * @return the printer
      */
     public Printer visitMethodTypeAnnotation(final int typeRef,
             final TypePath typePath, final String desc, final boolean visible) {
@@ -342,64 +565,225 @@
     }
 
     /**
-     * Method parameter annotation. See
-     * {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitParameterAnnotation}.
+     * Method parameter annotation.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitParameterAnnotation}.
+     *
+     * @param parameter
+     *            the parameter index.
+     * @param desc
+     *            the class descriptor of the annotation class.
+     * @param visible
+     *            <tt>true</tt> if the annotation is visible at runtime.
+     * @return the printer
      */
     public abstract Printer visitParameterAnnotation(final int parameter,
             final String desc, final boolean visible);
 
     /**
-     * Method attribute. See
-     * {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitAttribute}.
+     * Method attribute.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitAttribute}.
+     *
+     * @param attr
+     *            an attribute.
      */
     public abstract void visitMethodAttribute(final Attribute attr);
 
     /**
-     * Method start. See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitCode}.
+     * Method start.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitCode}.
      */
     public abstract void visitCode();
 
     /**
-     * Method stack frame. See
-     * {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitFrame}.
+     * Method stack frame.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitFrame}.
+     *
+     * Visits the current state of the local variables and operand stack
+     * elements. This method must(*) be called <i>just before</i> any
+     * instruction <b>i</b> that follows an unconditional branch instruction
+     * such as GOTO or THROW, that is the target of a jump instruction, or that
+     * starts an exception handler block. The visited types must describe the
+     * values of the local variables and of the operand stack elements <i>just
+     * before</i> <b>i</b> is executed.<br>
+     * <br>
+     * (*) this is mandatory only for classes whose version is greater than or
+     * equal to {@link Opcodes#V1_6 V1_6}. <br>
+     * <br>
+     * The frames of a method must be given either in expanded form, or in
+     * compressed form (all frames must use the same format, i.e. you must not
+     * mix expanded and compressed frames within a single method):
+     * <ul>
+     * <li>In expanded form, all frames must have the F_NEW type.</li>
+     * <li>In compressed form, frames are basically "deltas" from the state of
+     * the previous frame:
+     * <ul>
+     * <li>{@link Opcodes#F_SAME} representing frame with exactly the same
+     * locals as the previous frame and with the empty stack.</li>
+     * <li>{@link Opcodes#F_SAME1} representing frame with exactly the same
+     * locals as the previous frame and with single value on the stack (
+     * <code>nStack</code> is 1 and <code>stack[0]</code> contains value for the
+     * type of the stack item).</li>
+     * <li>{@link Opcodes#F_APPEND} representing frame with current locals are
+     * the same as the locals in the previous frame, except that additional
+     * locals are defined (<code>nLocal</code> is 1, 2 or 3 and
+     * <code>local</code> elements contains values representing added types).</li>
+     * <li>{@link Opcodes#F_CHOP} representing frame with current locals are the
+     * same as the locals in the previous frame, except that the last 1-3 locals
+     * are absent and with the empty stack (<code>nLocals</code> is 1, 2 or 3).</li>
+     * <li>{@link Opcodes#F_FULL} representing complete frame data.</li>
+     * </ul>
+     * </li>
+     * </ul>
+     * <br>
+     * In both cases the first frame, corresponding to the method's parameters
+     * and access flags, is implicit and must not be visited. Also, it is
+     * illegal to visit two or more frames for the same code location (i.e., at
+     * least one instruction must be visited between two calls to visitFrame).
+     *
+     * @param type
+     *            the type of this stack map frame. Must be
+     *            {@link Opcodes#F_NEW} for expanded frames, or
+     *            {@link Opcodes#F_FULL}, {@link Opcodes#F_APPEND},
+     *            {@link Opcodes#F_CHOP}, {@link Opcodes#F_SAME} or
+     *            {@link Opcodes#F_APPEND}, {@link Opcodes#F_SAME1} for
+     *            compressed frames.
+     * @param nLocal
+     *            the number of local variables in the visited frame.
+     * @param local
+     *            the local variable types in this frame. This array must not be
+     *            modified. Primitive types are represented by
+     *            {@link Opcodes#TOP}, {@link Opcodes#INTEGER},
+     *            {@link Opcodes#FLOAT}, {@link Opcodes#LONG},
+     *            {@link Opcodes#DOUBLE},{@link Opcodes#NULL} or
+     *            {@link Opcodes#UNINITIALIZED_THIS} (long and double are
+     *            represented by a single element). Reference types are
+     *            represented by String objects (representing internal names),
+     *            and uninitialized types by Label objects (this label
+     *            designates the NEW instruction that created this uninitialized
+     *            value).
+     * @param nStack
+     *            the number of operand stack elements in the visited frame.
+     * @param stack
+     *            the operand stack types in this frame. This array must not be
+     *            modified. Its content has the same format as the "local"
+     *            array.
+     * @throws IllegalStateException
+     *             if a frame is visited just after another one, without any
+     *             instruction between the two (unless this frame is a
+     *             Opcodes#F_SAME frame, in which case it is silently ignored).
      */
     public abstract void visitFrame(final int type, final int nLocal,
             final Object[] local, final int nStack, final Object[] stack);
 
     /**
-     * Method instruction. See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitInsn}
-     * .
+     * Method instruction.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitInsn}
+     *
+     * @param opcode
+     *            the opcode of the instruction to be visited. This opcode is
+     *            either NOP, ACONST_NULL, ICONST_M1, ICONST_0, ICONST_1,
+     *            ICONST_2, ICONST_3, ICONST_4, ICONST_5, LCONST_0, LCONST_1,
+     *            FCONST_0, FCONST_1, FCONST_2, DCONST_0, DCONST_1, IALOAD,
+     *            LALOAD, FALOAD, DALOAD, AALOAD, BALOAD, CALOAD, SALOAD,
+     *            IASTORE, LASTORE, FASTORE, DASTORE, AASTORE, BASTORE, CASTORE,
+     *            SASTORE, POP, POP2, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1,
+     *            DUP2_X2, SWAP, IADD, LADD, FADD, DADD, ISUB, LSUB, FSUB, DSUB,
+     *            IMUL, LMUL, FMUL, DMUL, IDIV, LDIV, FDIV, DDIV, IREM, LREM,
+     *            FREM, DREM, INEG, LNEG, FNEG, DNEG, ISHL, LSHL, ISHR, LSHR,
+     *            IUSHR, LUSHR, IAND, LAND, IOR, LOR, IXOR, LXOR, I2L, I2F, I2D,
+     *            L2I, L2F, L2D, F2I, F2L, F2D, D2I, D2L, D2F, I2B, I2C, I2S,
+     *            LCMP, FCMPL, FCMPG, DCMPL, DCMPG, IRETURN, LRETURN, FRETURN,
+     *            DRETURN, ARETURN, RETURN, ARRAYLENGTH, ATHROW, MONITORENTER,
+     *            or MONITOREXIT.
      */
     public abstract void visitInsn(final int opcode);
 
     /**
-     * Method instruction. See
-     * {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitIntInsn}.
+     * Method instruction.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitIntInsn}.
+     *
+     * @param opcode
+     *            the opcode of the instruction to be visited. This opcode is
+     *            either BIPUSH, SIPUSH or NEWARRAY.
+     * @param operand
+     *            the operand of the instruction to be visited.<br>
+     *            When opcode is BIPUSH, operand value should be between
+     *            Byte.MIN_VALUE and Byte.MAX_VALUE.<br>
+     *            When opcode is SIPUSH, operand value should be between
+     *            Short.MIN_VALUE and Short.MAX_VALUE.<br>
+     *            When opcode is NEWARRAY, operand value should be one of
+     *            {@link Opcodes#T_BOOLEAN}, {@link Opcodes#T_CHAR},
+     *            {@link Opcodes#T_FLOAT}, {@link Opcodes#T_DOUBLE},
+     *            {@link Opcodes#T_BYTE}, {@link Opcodes#T_SHORT},
+     *            {@link Opcodes#T_INT} or {@link Opcodes#T_LONG}.
      */
     public abstract void visitIntInsn(final int opcode, final int operand);
 
     /**
-     * Method instruction. See
-     * {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitVarInsn}.
+     * Method instruction.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitVarInsn}.
+     *
+     * @param opcode
+     *            the opcode of the local variable instruction to be visited.
+     *            This opcode is either ILOAD, LLOAD, FLOAD, DLOAD, ALOAD,
+     *            ISTORE, LSTORE, FSTORE, DSTORE, ASTORE or RET.
+     * @param var
+     *            the operand of the instruction to be visited. This operand is
+     *            the index of a local variable.
      */
     public abstract void visitVarInsn(final int opcode, final int var);
 
     /**
-     * Method instruction. See
-     * {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitTypeInsn}.
+     * Method instruction.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitTypeInsn}.
+     *
+    /**
+     * Visits a type instruction. A type instruction is an instruction that
+     * takes the internal name of a class as parameter.
+     *
+     * @param opcode
+     *            the opcode of the type instruction to be visited. This opcode
+     *            is either NEW, ANEWARRAY, CHECKCAST or INSTANCEOF.
+     * @param type
+     *            the operand of the instruction to be visited. This operand
+     *            must be the internal name of an object or array class (see
+     *            {@link jdk.internal.org.objectweb.asm.Type#getInternalName() getInternalName}).
      */
     public abstract void visitTypeInsn(final int opcode, final String type);
 
     /**
-     * Method instruction. See
-     * {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitFieldInsn}.
+     * Method instruction.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitFieldInsn}.
+     *
+     * @param opcode
+     *            the opcode of the type instruction to be visited. This opcode
+     *            is either GETSTATIC, PUTSTATIC, GETFIELD or PUTFIELD.
+     * @param owner
+     *            the internal name of the field's owner class (see
+     *            {@link jdk.internal.org.objectweb.asm.Type#getInternalName() getInternalName}).
+     * @param name
+     *            the field's name.
+     * @param desc
+     *            the field's descriptor (see {@link jdk.internal.org.objectweb.asm.Type Type}).
      */
     public abstract void visitFieldInsn(final int opcode, final String owner,
             final String name, final String desc);
 
     /**
-     * Method instruction. See
-     * {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitMethodInsn}.
+     * Method instruction.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitMethodInsn}.
+     *
+     * @param opcode
+     *            the opcode of the type instruction to be visited. This opcode
+     *            is either INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or
+     *            INVOKEINTERFACE.
+     * @param owner
+     *            the internal name of the method's owner class (see
+     *            {@link jdk.internal.org.objectweb.asm.Type#getInternalName() getInternalName}).
+     * @param name
+     *            the method's name.
+     * @param desc
+     *            the method's descriptor (see {@link jdk.internal.org.objectweb.asm.Type Type}).
      */
     @Deprecated
     public void visitMethodInsn(final int opcode, final String owner,
@@ -413,8 +797,22 @@
     }
 
     /**
-     * Method instruction. See
-     * {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitMethodInsn}.
+     * Method instruction.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitMethodInsn}.
+     *
+     * @param opcode
+     *            the opcode of the type instruction to be visited. This opcode
+     *            is either INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or
+     *            INVOKEINTERFACE.
+     * @param owner
+     *            the internal name of the method's owner class (see
+     *            {@link jdk.internal.org.objectweb.asm.Type#getInternalName() getInternalName}).
+     * @param name
+     *            the method's name.
+     * @param desc
+     *            the method's descriptor (see {@link jdk.internal.org.objectweb.asm.Type Type}).
+     * @param itf
+     *            if the method's owner class is an interface.
      */
     public void visitMethodInsn(final int opcode, final String owner,
             final String name, final String desc, final boolean itf) {
@@ -430,59 +828,181 @@
     }
 
     /**
-     * Method instruction. See
-     * {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitInvokeDynamicInsn}.
+     * Method instruction.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitInvokeDynamicInsn}.
+     *
+     * Visits an invokedynamic instruction.
+     *
+     * @param name
+     *            the method's name.
+     * @param desc
+     *            the method's descriptor (see {@link jdk.internal.org.objectweb.asm.Type Type}).
+     * @param bsm
+     *            the bootstrap method.
+     * @param bsmArgs
+     *            the bootstrap method constant arguments. Each argument must be
+     *            an {@link Integer}, {@link Float}, {@link Long},
+     *            {@link Double}, {@link String}, {@link jdk.internal.org.objectweb.asm.Type} or {@link Handle}
+     *            value. This method is allowed to modify the content of the
+     *            array so a caller should expect that this array may change.
      */
     public abstract void visitInvokeDynamicInsn(String name, String desc,
             Handle bsm, Object... bsmArgs);
 
     /**
-     * Method instruction. See
-     * {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitJumpInsn}.
+     * Method jump instruction.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitJumpInsn}.
+     *
+     * @param opcode
+     *            the opcode of the type instruction to be visited. This opcode
+     *            is either IFEQ, IFNE, IFLT, IFGE, IFGT, IFLE, IF_ICMPEQ,
+     *            IF_ICMPNE, IF_ICMPLT, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE,
+     *            IF_ACMPEQ, IF_ACMPNE, GOTO, JSR, IFNULL or IFNONNULL.
+     * @param label
+     *            the operand of the instruction to be visited. This operand is
+     *            a label that designates the instruction to which the jump
+     *            instruction may jump.
      */
     public abstract void visitJumpInsn(final int opcode, final Label label);
 
     /**
-     * Method label. See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitLabel}.
+     * Method label.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitLabel}.
+     *
+     * @param label
+     *            a {@link Label Label} object.
      */
     public abstract void visitLabel(final Label label);
 
     /**
-     * Method instruction. See
-     * {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitLdcInsn}.
+     * Method instruction.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitLdcInsn}.
+     *
+     * Visits a LDC instruction. Note that new constant types may be added in
+     * future versions of the Java Virtual Machine. To easily detect new
+     * constant types, implementations of this method should check for
+     * unexpected constant types, like this:
+     *
+     * <pre>
+     * if (cst instanceof Integer) {
+     *     // ...
+     * } else if (cst instanceof Float) {
+     *     // ...
+     * } else if (cst instanceof Long) {
+     *     // ...
+     * } else if (cst instanceof Double) {
+     *     // ...
+     * } else if (cst instanceof String) {
+     *     // ...
+     * } else if (cst instanceof Type) {
+     *     int sort = ((Type) cst).getSort();
+     *     if (sort == Type.OBJECT) {
+     *         // ...
+     *     } else if (sort == Type.ARRAY) {
+     *         // ...
+     *     } else if (sort == Type.METHOD) {
+     *         // ...
+     *     } else {
+     *         // throw an exception
+     *     }
+     * } else if (cst instanceof Handle) {
+     *     // ...
+     * } else {
+     *     // throw an exception
+     * }
+     * </pre>
+     *
+     * @param cst
+     *            the constant to be loaded on the stack. This parameter must be
+     *            a non null {@link Integer}, a {@link Float}, a {@link Long}, a
+     *            {@link Double}, a {@link String}, a {@link jdk.internal.org.objectweb.asm.Type}
+     *            of OBJECT or ARRAY sort for <tt>.class</tt> constants, for classes whose
+     *            version is 49.0, a {@link jdk.internal.org.objectweb.asm.Type} of METHOD sort or a
+     *            {@link Handle} for MethodType and MethodHandle constants, for
+     *            classes whose version is 51.0.
      */
     public abstract void visitLdcInsn(final Object cst);
 
     /**
-     * Method instruction. See
-     * {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitIincInsn}.
+     * Method instruction.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitIincInsn}.
+     *
+     * @param var
+     *            index of the local variable to be incremented.
+     * @param increment
+     *            amount to increment the local variable by.
      */
     public abstract void visitIincInsn(final int var, final int increment);
 
     /**
-     * Method instruction. See
-     * {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitTableSwitchInsn}.
+     * Method instruction.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitTableSwitchInsn}.
+     *
+     * @param min
+     *            the minimum key value.
+     * @param max
+     *            the maximum key value.
+     * @param dflt
+     *            beginning of the default handler block.
+     * @param labels
+     *            beginnings of the handler blocks. <tt>labels[i]</tt> is the
+     *            beginning of the handler block for the <tt>min + i</tt> key.
      */
     public abstract void visitTableSwitchInsn(final int min, final int max,
             final Label dflt, final Label... labels);
 
     /**
-     * Method instruction. See
-     * {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitLookupSwitchInsn}.
+     * Method instruction.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitLookupSwitchInsn}.
+     *
+     * @param dflt
+     *            beginning of the default handler block.
+     * @param keys
+     *            the values of the keys.
+     * @param labels
+     *            beginnings of the handler blocks. <tt>labels[i]</tt> is the
+     *            beginning of the handler block for the <tt>keys[i]</tt> key.
      */
     public abstract void visitLookupSwitchInsn(final Label dflt,
             final int[] keys, final Label[] labels);
 
     /**
-     * Method instruction. See
-     * {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitMultiANewArrayInsn}.
+     * Method instruction.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitMultiANewArrayInsn}.
+     *
+     * @param desc
+     *            an array type descriptor (see {@link jdk.internal.org.objectweb.asm.Type Type}).
+     * @param dims
+     *            number of dimensions of the array to allocate.
      */
     public abstract void visitMultiANewArrayInsn(final String desc,
             final int dims);
 
     /**
-     * Instruction type annotation. See
-     * {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitInsnAnnotation}.
+     * Instruction type annotation.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitInsnAnnotation}.
+     *
+     * @param typeRef
+     *            a reference to the annotated type. The sort of this type
+     *            reference must be {@link jdk.internal.org.objectweb.asm.TypeReference#INSTANCEOF INSTANCEOF},
+     *            {@link jdk.internal.org.objectweb.asm.TypeReference#NEW NEW},
+     *            {@link jdk.internal.org.objectweb.asm.TypeReference#CONSTRUCTOR_REFERENCE CONSTRUCTOR_REFERENCE},
+     *            {@link jdk.internal.org.objectweb.asm.TypeReference#METHOD_REFERENCE METHOD_REFERENCE},
+     *            {@link jdk.internal.org.objectweb.asm.TypeReference#CAST CAST},
+     *            {@link jdk.internal.org.objectweb.asm.TypeReference#CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT},
+     *            {@link jdk.internal.org.objectweb.asm.TypeReference#METHOD_INVOCATION_TYPE_ARGUMENT METHOD_INVOCATION_TYPE_ARGUMENT},
+     *            {@link jdk.internal.org.objectweb.asm.TypeReference#CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT},
+     *            or {@link jdk.internal.org.objectweb.asm.TypeReference#METHOD_REFERENCE_TYPE_ARGUMENT METHOD_REFERENCE_TYPE_ARGUMENT}.
+     *            See {@link jdk.internal.org.objectweb.asm.TypeReference}.
+     * @param typePath
+     *            the path to the annotated type argument, wildcard bound, array
+     *            element type, or static inner type within 'typeRef'. May be
+     *            <tt>null</tt> if the annotation targets 'typeRef' as a whole.
+     * @param desc
+     *            the class descriptor of the annotation class.
+     * @param visible
+     *            <tt>true</tt> if the annotation is visible at runtime.
+     * @return the printer
      */
     public Printer visitInsnAnnotation(final int typeRef,
             final TypePath typePath, final String desc, final boolean visible) {
@@ -490,15 +1010,44 @@
     }
 
     /**
-     * Method exception handler. See
-     * {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitTryCatchBlock}.
+     * Method exception handler.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitTryCatchBlock}.
+     *
+     * @param start
+     *            beginning of the exception handler's scope (inclusive).
+     * @param end
+     *            end of the exception handler's scope (exclusive).
+     * @param handler
+     *            beginning of the exception handler's code.
+     * @param type
+     *            internal name of the type of exceptions handled by the
+     *            handler, or <tt>null</tt> to catch any exceptions (for
+     *            "finally" blocks).
+     * @throws IllegalArgumentException
+     *             if one of the labels has already been visited by this visitor
+     *             (by the {@link #visitLabel visitLabel} method).
      */
     public abstract void visitTryCatchBlock(final Label start, final Label end,
             final Label handler, final String type);
 
     /**
-     * Try catch block type annotation. See
-     * {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitTryCatchAnnotation}.
+     * Try catch block type annotation.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitTryCatchAnnotation}.
+     *
+     * @param typeRef
+     *            a reference to the annotated type. The sort of this type
+     *            reference must be {@link jdk.internal.org.objectweb.asm.TypeReference#EXCEPTION_PARAMETER
+     *            EXCEPTION_PARAMETER}.
+     *            See {@link jdk.internal.org.objectweb.asm.TypeReference}.
+     * @param typePath
+     *            the path to the annotated type argument, wildcard bound, array
+     *            element type, or static inner type within 'typeRef'. May be
+     *            <tt>null</tt> if the annotation targets 'typeRef' as a whole.
+     * @param desc
+     *            the class descriptor of the annotation class.
+     * @param visible
+     *            <tt>true</tt> if the annotation is visible at runtime.
+     * @return the printer
      */
     public Printer visitTryCatchAnnotation(final int typeRef,
             final TypePath typePath, final String desc, final boolean visible) {
@@ -506,16 +1055,62 @@
     }
 
     /**
-     * Method debug info. See
-     * {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitLocalVariable}.
+     * Method debug info.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitLocalVariable}.
+     *
+     * @param name
+     *            the name of a local variable.
+     * @param desc
+     *            the type descriptor of this local variable.
+     * @param signature
+     *            the type signature of this local variable. May be
+     *            <tt>null</tt> if the local variable type does not use generic
+     *            types.
+     * @param start
+     *            the first instruction corresponding to the scope of this local
+     *            variable (inclusive).
+     * @param end
+     *            the last instruction corresponding to the scope of this local
+     *            variable (exclusive).
+     * @param index
+     *            the local variable's index.
+     * @throws IllegalArgumentException
+     *             if one of the labels has not already been visited by this
+     *             visitor (by the {@link #visitLabel visitLabel} method).
      */
     public abstract void visitLocalVariable(final String name,
             final String desc, final String signature, final Label start,
             final Label end, final int index);
 
     /**
-     * Local variable type annotation. See
-     * {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitTryCatchAnnotation}.
+     * Local variable type annotation.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitTryCatchAnnotation}.
+     *
+     * @param typeRef
+     *            a reference to the annotated type. The sort of this type
+     *            reference must be {@link jdk.internal.org.objectweb.asm.TypeReference#LOCAL_VARIABLE
+     *            LOCAL_VARIABLE} or {@link jdk.internal.org.objectweb.asm.TypeReference#RESOURCE_VARIABLE
+     *            RESOURCE_VARIABLE}.
+     *            See {@link jdk.internal.org.objectweb.asm.TypeReference}.
+     * @param typePath
+     *            the path to the annotated type argument, wildcard bound, array
+     *            element type, or static inner type within 'typeRef'. May be
+     *            <tt>null</tt> if the annotation targets 'typeRef' as a whole.
+     * @param start
+     *            the fist instructions corresponding to the continuous ranges
+     *            that make the scope of this local variable (inclusive).
+     * @param end
+     *            the last instructions corresponding to the continuous ranges
+     *            that make the scope of this local variable (exclusive). This
+     *            array must have the same size as the 'start' array.
+     * @param index
+     *            the local variable's index in each range. This array must have
+     *            the same size as the 'start' array.
+     * @param desc
+     *            the class descriptor of the annotation class.
+     * @param visible
+     *            <tt>true</tt> if the annotation is visible at runtime.
+     * @return the printer
      */
     public Printer visitLocalVariableAnnotation(final int typeRef,
             final TypePath typePath, final Label[] start, final Label[] end,
@@ -524,19 +1119,34 @@
     }
 
     /**
-     * Method debug info. See
-     * {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitLineNumber}.
+     * Method debug info.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitLineNumber}.
+     *
+     * @param line
+     *            a line number. This number refers to the source file from
+     *            which the class was compiled.
+     * @param start
+     *            the first instruction corresponding to this line number.
+     * @throws IllegalArgumentException
+     *             if <tt>start</tt> has not already been visited by this
+     *             visitor (by the {@link #visitLabel visitLabel} method).
      */
     public abstract void visitLineNumber(final int line, final Label start);
 
     /**
-     * Method max stack and max locals. See
-     * {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitMaxs}.
+     * Method max stack and max locals.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitMaxs}.
+     *
+     * @param maxStack
+     *            maximum stack size of the method.
+     * @param maxLocals
+     *            maximum number of local variables for the method.
      */
     public abstract void visitMaxs(final int maxStack, final int maxLocals);
 
     /**
-     * Method end. See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitEnd}.
+     * Method end.
+     * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitEnd}.
      */
     public abstract void visitMethodEnd();
 
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TraceClassVisitor.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TraceClassVisitor.java	Mon Mar 28 08:41:54 2016 -0700
@@ -74,34 +74,36 @@
  * visitor chain to trace the class that is visited at a given point in this
  * chain. This may be useful for debugging purposes.
  * <p>
- * The trace printed when visiting the {@code Hello} class is the following:
+ * The trace printed when visiting the <tt>Hello</tt> class is the following:
+ * <p>
  * <blockquote>
  *
- * <pre>{@code
+ * <pre>
  * // class version 49.0 (49) // access flags 0x21 public class Hello {
  *
  * // compiled from: Hello.java
  *
- * // access flags 0x1 public <init> ()V ALOAD 0 INVOKESPECIAL
- * java/lang/Object <init> ()V RETURN MAXSTACK = 1 MAXLOCALS = 1
+ * // access flags 0x1 public &lt;init&gt; ()V ALOAD 0 INVOKESPECIAL
+ * java/lang/Object &lt;init&gt; ()V RETURN MAXSTACK = 1 MAXLOCALS = 1
  *
  * // access flags 0x9 public static main ([Ljava/lang/String;)V GETSTATIC
- * java/lang/System out Ljava/io/PrintStream; LDC "hello"
+ * java/lang/System out Ljava/io/PrintStream; LDC &quot;hello&quot;
  * INVOKEVIRTUAL java/io/PrintStream println (Ljava/lang/String;)V RETURN
  * MAXSTACK = 2 MAXLOCALS = 1 }
- * }</pre>
+ * </pre>
  *
- * </blockquote> where {@code Hello} is defined by:
+ * </blockquote> where <tt>Hello</tt> is defined by:
+ * <p>
  * <blockquote>
  *
- * <pre>{@code
+ * <pre>
  * public class Hello {
  *
  *     public static void main(String[] args) {
- *         System.out.println("hello");
+ *         System.out.println(&quot;hello&quot;);
  *     }
  * }
- * }</pre>
+ * </pre>
  *
  * </blockquote>
  *
@@ -135,7 +137,7 @@
      *
      * @param cv
      *            the {@link ClassVisitor} to which this visitor delegates
-     *            calls. May be {@code null}.
+     *            calls. May be <tt>null</tt>.
      * @param pw
      *            the print writer to be used to print the class.
      */
@@ -148,7 +150,7 @@
      *
      * @param cv
      *            the {@link ClassVisitor} to which this visitor delegates
-     *            calls. May be {@code null}.
+     *            calls. May be <tt>null</tt>.
      * @param p
      *            the object that actually converts visit events into text.
      * @param pw
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TraceSignatureVisitor.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/TraceSignatureVisitor.java	Mon Mar 28 08:41:54 2016 -0700
@@ -70,7 +70,7 @@
  */
 public final class TraceSignatureVisitor extends SignatureVisitor {
 
-    private final StringBuffer declaration;
+    private final StringBuilder declaration;
 
     private boolean isInterface;
 
@@ -82,9 +82,9 @@
 
     private boolean seenInterface;
 
-    private StringBuffer returnType;
+    private StringBuilder returnType;
 
-    private StringBuffer exceptions;
+    private StringBuilder exceptions;
 
     /**
      * Stack used to keep track of class types that have arguments. Each element
@@ -106,10 +106,10 @@
     public TraceSignatureVisitor(final int access) {
         super(Opcodes.ASM5);
         isInterface = (access & Opcodes.ACC_INTERFACE) != 0;
-        this.declaration = new StringBuffer();
+        this.declaration = new StringBuilder();
     }
 
-    private TraceSignatureVisitor(final StringBuffer buf) {
+    private TraceSignatureVisitor(final StringBuilder buf) {
         super(Opcodes.ASM5);
         this.declaration = buf;
     }
@@ -175,14 +175,14 @@
             declaration.append('(');
         }
         declaration.append(')');
-        returnType = new StringBuffer();
+        returnType = new StringBuilder();
         return new TraceSignatureVisitor(returnType);
     }
 
     @Override
     public SignatureVisitor visitExceptionType() {
         if (exceptions == null) {
-            exceptions = new StringBuffer();
+            exceptions = new StringBuilder();
         } else {
             exceptions.append(", ");
         }
--- a/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/version.txt	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/org/objectweb/asm/version.txt	Mon Mar 28 08:41:54 2016 -0700
@@ -1,12 +1,12 @@
 Path: .
-Working Copy Root Path: /hudson/jobs/objectweb-init/workspace/asm-svn-2014-10-15
+Working Copy Root Path: /hudson/jobs/objectweb-init/workspace/asm-svn-2016-01-25
 URL: file:///svnroot/asm/trunk/asm
 Repository Root: file:///svnroot/asm
 Repository UUID: 271bd773-ee82-43a6-9b2b-1890ed8ce7f9
-Revision: 1772
+Revision: 1795
 Node Kind: directory
 Schedule: normal
 Last Changed Author: ebruneton
-Last Changed Rev: 1772
-Last Changed Date: 2014-09-06 09:13:07 +0200 (Sat, 06 Sep 2014)
+Last Changed Rev: 1795
+Last Changed Date: 2016-01-24 14:17:10 +0100 (Sun, 24 Jan 2016)
 
--- a/jdk/src/java.base/share/classes/jdk/internal/ref/CleanerFactory.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/ref/CleanerFactory.java	Mon Mar 28 08:41:54 2016 -0700
@@ -25,24 +25,44 @@
 
 package jdk.internal.ref;
 
+import jdk.internal.misc.InnocuousThread;
+
 import java.lang.ref.Cleaner;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.concurrent.ThreadFactory;
 
 /**
- * CleanerFactory provides a Cleaner for use within OpenJDK modules.
+ * CleanerFactory provides a Cleaner for use within system modules.
  * The cleaner is created on the first reference to the CleanerFactory.
  */
 public final class CleanerFactory {
 
     /* The common Cleaner. */
-    private final static Cleaner commonCleaner = Cleaner.create();
+    private final static Cleaner commonCleaner = Cleaner.create(new ThreadFactory() {
+        @Override
+        public Thread newThread(Runnable r) {
+            return AccessController.doPrivileged(new PrivilegedAction<>() {
+                @Override
+                public Thread run() {
+                    Thread t = InnocuousThread.newSystemThread("Common-Cleaner", r);
+                    t.setPriority(Thread.MAX_PRIORITY - 2);
+                    return t;
+                }
+            });
+        }
+    });
 
     /**
-     * Cleaner for use within OpenJDK modules.
+     * Cleaner for use within system modules.
      *
-     * @return a Cleaner for use within OpenJDK modules
+     * This Cleaner will run on a thread whose context class loader
+     * is {@code null}. The system cleaning action to perform in
+     * this Cleaner should handle a {@code null} context class loader.
+     *
+     * @return a Cleaner for use within system modules
      */
     public static Cleaner cleaner() {
         return commonCleaner;
     }
-
 }
--- a/jdk/src/java.base/share/classes/jdk/internal/ref/CleanerImpl.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/jdk/internal/ref/CleanerImpl.java	Mon Mar 28 08:41:54 2016 -0700
@@ -324,10 +324,10 @@
         final AtomicInteger cleanerThreadNumber = new AtomicInteger();
 
         public Thread newThread(Runnable r) {
-            return AccessController.doPrivileged(new PrivilegedAction<Thread>() {
+            return AccessController.doPrivileged(new PrivilegedAction<>() {
                 @Override
                 public Thread run() {
-                    Thread t = new InnocuousThread(r);
+                    Thread t = InnocuousThread.newThread(r);
                     t.setPriority(Thread.MAX_PRIORITY - 2);
                     t.setName("Cleaner-" + cleanerThreadNumber.getAndIncrement());
                     return t;
--- a/jdk/src/java.base/share/classes/module-info.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/module-info.java	Mon Mar 28 08:41:54 2016 -0700
@@ -274,7 +274,6 @@
         jdk.localedata;
     exports sun.util.logging to
         java.desktop,
-        java.httpclient,
         java.logging,
         java.prefs;
 
--- a/jdk/src/java.base/share/classes/sun/misc/Resource.java	Thu Mar 24 02:04:14 2016 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,188 +0,0 @@
-/*
- * Copyright (c) 1998, 2009, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.misc;
-
-import java.io.EOFException;
-import java.net.URL;
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.io.InputStream;
-import java.security.CodeSigner;
-import java.util.jar.Manifest;
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-import sun.nio.ByteBuffered;
-
-/**
- * This class is used to represent a Resource that has been loaded
- * from the class path.
- *
- * @author  David Connelly
- * @since   1.2
- */
-public abstract class Resource {
-    /**
-     * Returns the name of the Resource.
-     */
-    public abstract String getName();
-
-    /**
-     * Returns the URL of the Resource.
-     */
-    public abstract URL getURL();
-
-    /**
-     * Returns the CodeSource URL for the Resource.
-     */
-    public abstract URL getCodeSourceURL();
-
-    /**
-     * Returns an InputStream for reading the Resource data.
-     */
-    public abstract InputStream getInputStream() throws IOException;
-
-    /**
-     * Returns the length of the Resource data, or -1 if unknown.
-     */
-    public abstract int getContentLength() throws IOException;
-
-    private InputStream cis;
-
-    /* Cache result in case getBytes is called after getByteBuffer. */
-    private synchronized InputStream cachedInputStream() throws IOException {
-        if (cis == null) {
-            cis = getInputStream();
-        }
-        return cis;
-    }
-
-    /**
-     * Returns the Resource data as an array of bytes.
-     */
-    public byte[] getBytes() throws IOException {
-        byte[] b;
-        // Get stream before content length so that a FileNotFoundException
-        // can propagate upwards without being caught too early
-        InputStream in = cachedInputStream();
-
-        // This code has been uglified to protect against interrupts.
-        // Even if a thread has been interrupted when loading resources,
-        // the IO should not abort, so must carefully retry, failing only
-        // if the retry leads to some other IO exception.
-
-        boolean isInterrupted = Thread.interrupted();
-        int len;
-        for (;;) {
-            try {
-                len = getContentLength();
-                break;
-            } catch (InterruptedIOException iioe) {
-                Thread.interrupted();
-                isInterrupted = true;
-            }
-        }
-
-        try {
-            b = new byte[0];
-            if (len == -1) len = Integer.MAX_VALUE;
-            int pos = 0;
-            while (pos < len) {
-                int bytesToRead;
-                if (pos >= b.length) { // Only expand when there's no room
-                    bytesToRead = Math.min(len - pos, b.length + 1024);
-                    if (b.length < pos + bytesToRead) {
-                        b = Arrays.copyOf(b, pos + bytesToRead);
-                    }
-                } else {
-                    bytesToRead = b.length - pos;
-                }
-                int cc = 0;
-                try {
-                    cc = in.read(b, pos, bytesToRead);
-                } catch (InterruptedIOException iioe) {
-                    Thread.interrupted();
-                    isInterrupted = true;
-                }
-                if (cc < 0) {
-                    if (len != Integer.MAX_VALUE) {
-                        throw new EOFException("Detect premature EOF");
-                    } else {
-                        if (b.length != pos) {
-                            b = Arrays.copyOf(b, pos);
-                        }
-                        break;
-                    }
-                }
-                pos += cc;
-            }
-        } finally {
-            try {
-                in.close();
-            } catch (InterruptedIOException iioe) {
-                isInterrupted = true;
-            } catch (IOException ignore) {}
-
-            if (isInterrupted) {
-                Thread.currentThread().interrupt();
-            }
-        }
-        return b;
-    }
-
-    /**
-     * Returns the Resource data as a ByteBuffer, but only if the input stream
-     * was implemented on top of a ByteBuffer. Return {@code null} otherwise.
-     * @return Resource data or null.
-     */
-    public ByteBuffer getByteBuffer() throws IOException {
-        InputStream in = cachedInputStream();
-        if (in instanceof ByteBuffered) {
-            return ((ByteBuffered)in).getByteBuffer();
-        }
-        return null;
-    }
-
-    /**
-     * Returns the Manifest for the Resource, or null if none.
-     */
-    public Manifest getManifest() throws IOException {
-        return null;
-    }
-
-    /**
-     * Returns theCertificates for the Resource, or null if none.
-     */
-    public java.security.cert.Certificate[] getCertificates() {
-        return null;
-    }
-
-    /**
-     * Returns the code signers for the Resource, or null if none.
-     */
-    public CodeSigner[] getCodeSigners() {
-        return null;
-    }
-}
--- a/jdk/src/java.base/share/classes/sun/misc/URLClassPath.java	Thu Mar 24 02:04:14 2016 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1080 +0,0 @@
-/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.misc;
-
-import java.io.Closeable;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.JarURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.net.URLStreamHandler;
-import java.net.URLStreamHandlerFactory;
-import java.security.AccessControlException;
-import java.security.AccessController;
-import java.security.CodeSigner;
-import java.security.Permission;
-import java.security.PrivilegedExceptionAction;
-import java.security.cert.Certificate;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Set;
-import java.util.Stack;
-import java.util.StringTokenizer;
-import java.util.jar.JarFile;
-import java.util.zip.ZipEntry;
-import java.util.jar.JarEntry;
-import java.util.jar.Manifest;
-import java.util.jar.Attributes;
-import java.util.jar.Attributes.Name;
-import java.util.zip.ZipFile;
-
-import jdk.internal.misc.JavaUtilZipFileAccess;
-import jdk.internal.misc.SharedSecrets;
-import sun.net.util.URLUtil;
-import sun.net.www.ParseUtil;
-
-/**
- * This class is used to maintain a search path of URLs for loading classes
- * and resources from both JAR files and directories.
- *
- * @author  David Connelly
- */
-public class URLClassPath {
-    private static final String USER_AGENT_JAVA_VERSION = "UA-Java-Version";
-    private static final String JAVA_HOME;
-    private static final String JAVA_VERSION;
-    private static final boolean DEBUG;
-    private static final boolean DISABLE_JAR_CHECKING;
-
-    static {
-        JAVA_HOME = java.security.AccessController.doPrivileged(
-            new sun.security.action.GetPropertyAction("java.home"));
-        JAVA_VERSION = java.security.AccessController.doPrivileged(
-            new sun.security.action.GetPropertyAction("java.version"));
-        DEBUG        = (java.security.AccessController.doPrivileged(
-            new sun.security.action.GetPropertyAction("sun.misc.URLClassPath.debug")) != null);
-        String p = java.security.AccessController.doPrivileged(
-            new sun.security.action.GetPropertyAction("sun.misc.URLClassPath.disableJarChecking"));
-        DISABLE_JAR_CHECKING = p != null ? p.equals("true") || p.equals("") : false;
-    }
-
-    /* The original search path of URLs. */
-    private ArrayList<URL> path = new ArrayList<>();
-
-    /* The stack of unopened URLs */
-    Stack<URL> urls = new Stack<>();
-
-    /* The resulting search path of Loaders */
-    ArrayList<Loader> loaders = new ArrayList<>();
-
-    /* Map of each URL opened to its corresponding Loader */
-    HashMap<String, Loader> lmap = new HashMap<>();
-
-    /* The jar protocol handler to use when creating new URLs */
-    private URLStreamHandler jarHandler;
-
-    /* Whether this URLClassLoader has been closed yet */
-    private boolean closed = false;
-
-    /**
-     * Creates a new URLClassPath for the given URLs. The URLs will be
-     * searched in the order specified for classes and resources. A URL
-     * ending with a '/' is assumed to refer to a directory. Otherwise,
-     * the URL is assumed to refer to a JAR file.
-     *
-     * @param urls the directory and JAR file URLs to search for classes
-     *        and resources
-     * @param factory the URLStreamHandlerFactory to use when creating new URLs
-     */
-    public URLClassPath(URL[] urls, URLStreamHandlerFactory factory) {
-        for (int i = 0; i < urls.length; i++) {
-            path.add(urls[i]);
-        }
-        push(urls);
-        if (factory != null) {
-            jarHandler = factory.createURLStreamHandler("jar");
-        }
-    }
-
-    public URLClassPath(URL[] urls) {
-        this(urls, null);
-    }
-
-    public synchronized List<IOException> closeLoaders() {
-        if (closed) {
-            return Collections.emptyList();
-        }
-        List<IOException> result = new LinkedList<>();
-        for (Loader loader : loaders) {
-            try {
-                loader.close();
-            } catch (IOException e) {
-                result.add (e);
-            }
-        }
-        closed = true;
-        return result;
-    }
-
-    /**
-     * Appends the specified URL to the search path of directory and JAR
-     * file URLs from which to load classes and resources.
-     * <p>
-     * If the URL specified is null or is already in the list of
-     * URLs, then invoking this method has no effect.
-     */
-    public synchronized void addURL(URL url) {
-        if (closed)
-            return;
-        synchronized (urls) {
-            if (url == null || path.contains(url))
-                return;
-
-            urls.add(0, url);
-            path.add(url);
-        }
-    }
-
-    /**
-     * Returns the original search path of URLs.
-     */
-    public URL[] getURLs() {
-        synchronized (urls) {
-            return path.toArray(new URL[path.size()]);
-        }
-    }
-
-    /**
-     * Finds the resource with the specified name on the URL search path
-     * or null if not found or security check fails.
-     *
-     * @param name      the name of the resource
-     * @param check     whether to perform a security check
-     * @return a <code>URL</code> for the resource, or <code>null</code>
-     * if the resource could not be found.
-     */
-    public URL findResource(String name, boolean check) {
-        Loader loader;
-        for (int i = 0; (loader = getLoader(i)) != null; i++) {
-            URL url = loader.findResource(name, check);
-            if (url != null) {
-                return url;
-            }
-        }
-        return null;
-    }
-
-    /**
-     * Finds the first Resource on the URL search path which has the specified
-     * name. Returns null if no Resource could be found.
-     *
-     * @param name the name of the Resource
-     * @param check     whether to perform a security check
-     * @return the Resource, or null if not found
-     */
-    public Resource getResource(String name, boolean check) {
-        if (DEBUG) {
-            System.err.println("URLClassPath.getResource(\"" + name + "\")");
-        }
-
-        Loader loader;
-        for (int i = 0; (loader = getLoader(i)) != null; i++) {
-            Resource res = loader.getResource(name, check);
-            if (res != null) {
-                return res;
-            }
-        }
-        return null;
-    }
-
-    /**
-     * Finds all resources on the URL search path with the given name.
-     * Returns an enumeration of the URL objects.
-     *
-     * @param name the resource name
-     * @return an Enumeration of all the urls having the specified name
-     */
-    public Enumeration<URL> findResources(final String name,
-                                     final boolean check) {
-        return new Enumeration<>() {
-            private int index = 0;
-            private URL url = null;
-
-            private boolean next() {
-                if (url != null) {
-                    return true;
-                } else {
-                    Loader loader;
-                    while ((loader = getLoader(index++)) != null) {
-                        url = loader.findResource(name, check);
-                        if (url != null) {
-                            return true;
-                        }
-                    }
-                    return false;
-                }
-            }
-
-            public boolean hasMoreElements() {
-                return next();
-            }
-
-            public URL nextElement() {
-                if (!next()) {
-                    throw new NoSuchElementException();
-                }
-                URL u = url;
-                url = null;
-                return u;
-            }
-        };
-    }
-
-    public Resource getResource(String name) {
-        return getResource(name, true);
-    }
-
-    /**
-     * Finds all resources on the URL search path with the given name.
-     * Returns an enumeration of the Resource objects.
-     *
-     * @param name the resource name
-     * @return an Enumeration of all the resources having the specified name
-     */
-    public Enumeration<Resource> getResources(final String name,
-                                    final boolean check) {
-        return new Enumeration<>() {
-            private int index = 0;
-            private Resource res = null;
-
-            private boolean next() {
-                if (res != null) {
-                    return true;
-                } else {
-                    Loader loader;
-                    while ((loader = getLoader(index++)) != null) {
-                        res = loader.getResource(name, check);
-                        if (res != null) {
-                            return true;
-                        }
-                    }
-                    return false;
-                }
-            }
-
-            public boolean hasMoreElements() {
-                return next();
-            }
-
-            public Resource nextElement() {
-                if (!next()) {
-                    throw new NoSuchElementException();
-                }
-                Resource r = res;
-                res = null;
-                return r;
-            }
-        };
-    }
-
-    public Enumeration<Resource> getResources(final String name) {
-        return getResources(name, true);
-    }
-
-    /*
-     * Returns the Loader at the specified position in the URL search
-     * path. The URLs are opened and expanded as needed. Returns null
-     * if the specified index is out of range.
-     */
-     private synchronized Loader getLoader(int index) {
-        if (closed) {
-            return null;
-        }
-         // Expand URL search path until the request can be satisfied
-         // or the URL stack is empty.
-        while (loaders.size() < index + 1) {
-            // Pop the next URL from the URL stack
-            URL url;
-            synchronized (urls) {
-                if (urls.empty()) {
-                    return null;
-                } else {
-                    url = urls.pop();
-                }
-            }
-            // Skip this URL if it already has a Loader. (Loader
-            // may be null in the case where URL has not been opened
-            // but is referenced by a JAR index.)
-            String urlNoFragString = URLUtil.urlNoFragString(url);
-            if (lmap.containsKey(urlNoFragString)) {
-                continue;
-            }
-            // Otherwise, create a new Loader for the URL.
-            Loader loader;
-            try {
-                loader = getLoader(url);
-                // If the loader defines a local class path then add the
-                // URLs to the list of URLs to be opened.
-                URL[] urls = loader.getClassPath();
-                if (urls != null) {
-                    push(urls);
-                }
-            } catch (IOException e) {
-                // Silently ignore for now...
-                continue;
-            }
-            // Finally, add the Loader to the search path.
-            loaders.add(loader);
-            lmap.put(urlNoFragString, loader);
-        }
-        return loaders.get(index);
-    }
-
-    /*
-     * Returns the Loader for the specified base URL.
-     */
-    private Loader getLoader(final URL url) throws IOException {
-        try {
-            return java.security.AccessController.doPrivileged(
-                new java.security.PrivilegedExceptionAction<>() {
-                public Loader run() throws IOException {
-                    String file = url.getFile();
-                    if (file != null && file.endsWith("/")) {
-                        if ("file".equals(url.getProtocol())) {
-                            return new FileLoader(url);
-                        } else {
-                            return new Loader(url);
-                        }
-                    } else {
-                        return new JarLoader(url, jarHandler, lmap);
-                    }
-                }
-            });
-        } catch (java.security.PrivilegedActionException pae) {
-            throw (IOException)pae.getException();
-        }
-    }
-
-    /*
-     * Pushes the specified URLs onto the list of unopened URLs.
-     */
-    private void push(URL[] us) {
-        synchronized (urls) {
-            for (int i = us.length - 1; i >= 0; --i) {
-                urls.push(us[i]);
-            }
-        }
-    }
-
-    /**
-     * Convert class path specification into an array of file URLs.
-     *
-     * The path of the file is encoded before conversion into URL
-     * form so that reserved characters can safely appear in the path.
-     */
-    public static URL[] pathToURLs(String path) {
-        StringTokenizer st = new StringTokenizer(path, File.pathSeparator);
-        URL[] urls = new URL[st.countTokens()];
-        int count = 0;
-        while (st.hasMoreTokens()) {
-            File f = new File(st.nextToken());
-            try {
-                f = new File(f.getCanonicalPath());
-            } catch (IOException x) {
-                // use the non-canonicalized filename
-            }
-            try {
-                urls[count++] = ParseUtil.fileToEncodedURL(f);
-            } catch (IOException x) { }
-        }
-
-        if (urls.length != count) {
-            URL[] tmp = new URL[count];
-            System.arraycopy(urls, 0, tmp, 0, count);
-            urls = tmp;
-        }
-        return urls;
-    }
-
-    /*
-     * Check whether the resource URL should be returned.
-     * Return null on security check failure.
-     * Called by java.net.URLClassLoader.
-     */
-    public static URL checkURL(URL url) {
-        if (url != null) {
-            try {
-                check(url);
-            } catch (Exception e) {
-                return null;
-            }
-        }
-        return url;
-    }
-
-    /*
-     * Check whether the resource URL should be returned.
-     * Throw exception on failure.
-     * Called internally within this file.
-     */
-    public static void check(URL url) throws IOException {
-        SecurityManager security = System.getSecurityManager();
-        if (security != null) {
-            URLConnection urlConnection = url.openConnection();
-            Permission perm = urlConnection.getPermission();
-            if (perm != null) {
-                try {
-                    security.checkPermission(perm);
-                } catch (SecurityException se) {
-                    // fallback to checkRead/checkConnect for pre 1.2
-                    // security managers
-                    if ((perm instanceof java.io.FilePermission) &&
-                        perm.getActions().indexOf("read") != -1) {
-                        security.checkRead(perm.getName());
-                    } else if ((perm instanceof
-                        java.net.SocketPermission) &&
-                        perm.getActions().indexOf("connect") != -1) {
-                        URL locUrl = url;
-                        if (urlConnection instanceof JarURLConnection) {
-                            locUrl = ((JarURLConnection)urlConnection).getJarFileURL();
-                        }
-                        security.checkConnect(locUrl.getHost(),
-                                              locUrl.getPort());
-                    } else {
-                        throw se;
-                    }
-                }
-            }
-        }
-    }
-
-    /**
-     * Inner class used to represent a loader of resources and classes
-     * from a base URL.
-     */
-    private static class Loader implements Closeable {
-        private final URL base;
-        private JarFile jarfile; // if this points to a jar file
-
-        /*
-         * Creates a new Loader for the specified URL.
-         */
-        Loader(URL url) {
-            base = url;
-        }
-
-        /*
-         * Returns the base URL for this Loader.
-         */
-        URL getBaseURL() {
-            return base;
-        }
-
-        URL findResource(final String name, boolean check) {
-            URL url;
-            try {
-                url = new URL(base, ParseUtil.encodePath(name, false));
-            } catch (MalformedURLException e) {
-                throw new IllegalArgumentException("name");
-            }
-
-            try {
-                if (check) {
-                    URLClassPath.check(url);
-                }
-
-                /*
-                 * For a HTTP connection we use the HEAD method to
-                 * check if the resource exists.
-                 */
-                URLConnection uc = url.openConnection();
-                if (uc instanceof HttpURLConnection) {
-                    HttpURLConnection hconn = (HttpURLConnection)uc;
-                    hconn.setRequestMethod("HEAD");
-                    if (hconn.getResponseCode() >= HttpURLConnection.HTTP_BAD_REQUEST) {
-                        return null;
-                    }
-                } else {
-                    // our best guess for the other cases
-                    uc.setUseCaches(false);
-                    InputStream is = uc.getInputStream();
-                    is.close();
-                }
-                return url;
-            } catch (Exception e) {
-                return null;
-            }
-        }
-
-        Resource getResource(final String name, boolean check) {
-            final URL url;
-            try {
-                url = new URL(base, ParseUtil.encodePath(name, false));
-            } catch (MalformedURLException e) {
-                throw new IllegalArgumentException("name");
-            }
-            final URLConnection uc;
-            try {
-                if (check) {
-                    URLClassPath.check(url);
-                }
-                uc = url.openConnection();
-                InputStream in = uc.getInputStream();
-                if (uc instanceof JarURLConnection) {
-                    /* Need to remember the jar file so it can be closed
-                     * in a hurry.
-                     */
-                    JarURLConnection juc = (JarURLConnection)uc;
-                    jarfile = JarLoader.checkJar(juc.getJarFile());
-                }
-            } catch (Exception e) {
-                return null;
-            }
-            return new Resource() {
-                public String getName() { return name; }
-                public URL getURL() { return url; }
-                public URL getCodeSourceURL() { return base; }
-                public InputStream getInputStream() throws IOException {
-                    return uc.getInputStream();
-                }
-                public int getContentLength() throws IOException {
-                    return uc.getContentLength();
-                }
-            };
-        }
-
-        /*
-         * Returns the Resource for the specified name, or null if not
-         * found or the caller does not have the permission to get the
-         * resource.
-         */
-        Resource getResource(final String name) {
-            return getResource(name, true);
-        }
-
-        /*
-         * close this loader and release all resources
-         * method overridden in sub-classes
-         */
-        public void close () throws IOException {
-            if (jarfile != null) {
-                jarfile.close();
-            }
-        }
-
-        /*
-         * Returns the local class path for this loader, or null if none.
-         */
-        URL[] getClassPath() throws IOException {
-            return null;
-        }
-    }
-
-    /*
-     * Inner class used to represent a Loader of resources from a JAR URL.
-     */
-    static class JarLoader extends Loader {
-        private JarFile jar;
-        private URL csu;
-        private JarIndex index;
-        private URLStreamHandler handler;
-        private HashMap<String, Loader> lmap;
-        private boolean closed = false;
-        private static final JavaUtilZipFileAccess zipAccess =
-                SharedSecrets.getJavaUtilZipFileAccess();
-
-        /*
-         * Creates a new JarLoader for the specified URL referring to
-         * a JAR file.
-         */
-        JarLoader(URL url, URLStreamHandler jarHandler,
-                  HashMap<String, Loader> loaderMap)
-            throws IOException
-        {
-            super(new URL("jar", "", -1, url + "!/", jarHandler));
-            csu = url;
-            handler = jarHandler;
-            lmap = loaderMap;
-
-            ensureOpen();
-        }
-
-        @Override
-        public void close () throws IOException {
-            // closing is synchronized at higher level
-            if (!closed) {
-                closed = true;
-                // in case not already open.
-                ensureOpen();
-                jar.close();
-            }
-        }
-
-        JarFile getJarFile () {
-            return jar;
-        }
-
-        private boolean isOptimizable(URL url) {
-            return "file".equals(url.getProtocol());
-        }
-
-        private void ensureOpen() throws IOException {
-            if (jar == null) {
-                try {
-                    java.security.AccessController.doPrivileged(
-                        new java.security.PrivilegedExceptionAction<>() {
-                            public Void run() throws IOException {
-                                if (DEBUG) {
-                                    System.err.println("Opening " + csu);
-                                    Thread.dumpStack();
-                                }
-
-                                jar = getJarFile(csu);
-                                index = JarIndex.getJarIndex(jar);
-                                if (index != null) {
-                                    String[] jarfiles = index.getJarFiles();
-                                // Add all the dependent URLs to the lmap so that loaders
-                                // will not be created for them by URLClassPath.getLoader(int)
-                                // if the same URL occurs later on the main class path.  We set
-                                // Loader to null here to avoid creating a Loader for each
-                                // URL until we actually need to try to load something from them.
-                                    for(int i = 0; i < jarfiles.length; i++) {
-                                        try {
-                                            URL jarURL = new URL(csu, jarfiles[i]);
-                                            // If a non-null loader already exists, leave it alone.
-                                            String urlNoFragString = URLUtil.urlNoFragString(jarURL);
-                                            if (!lmap.containsKey(urlNoFragString)) {
-                                                lmap.put(urlNoFragString, null);
-                                            }
-                                        } catch (MalformedURLException e) {
-                                            continue;
-                                        }
-                                    }
-                                }
-                                return null;
-                            }
-                        }
-                    );
-                } catch (java.security.PrivilegedActionException pae) {
-                    throw (IOException)pae.getException();
-                }
-            }
-        }
-
-        /* Throws if the given jar file is does not start with the correct LOC */
-        static JarFile checkJar(JarFile jar) throws IOException {
-            if (System.getSecurityManager() != null && !DISABLE_JAR_CHECKING
-                && !zipAccess.startsWithLocHeader(jar)) {
-                IOException x = new IOException("Invalid Jar file");
-                try {
-                    jar.close();
-                } catch (IOException ex) {
-                    x.addSuppressed(ex);
-                }
-                throw x;
-            }
-
-            return jar;
-        }
-
-        private JarFile getJarFile(URL url) throws IOException {
-            // Optimize case where url refers to a local jar file
-            if (isOptimizable(url)) {
-                FileURLMapper p = new FileURLMapper (url);
-                if (!p.exists()) {
-                    throw new FileNotFoundException(p.getPath());
-                }
-                return checkJar(new JarFile(new File(p.getPath()), true, ZipFile.OPEN_READ,
-                        JarFile.Release.RUNTIME));
-            }
-            URLConnection uc = (new URL(getBaseURL(), "#runtime")).openConnection();
-            uc.setRequestProperty(USER_AGENT_JAVA_VERSION, JAVA_VERSION);
-            JarFile jarFile = ((JarURLConnection)uc).getJarFile();
-            return checkJar(jarFile);
-        }
-
-        /*
-         * Returns the index of this JarLoader if it exists.
-         */
-        JarIndex getIndex() {
-            try {
-                ensureOpen();
-            } catch (IOException e) {
-                throw new InternalError(e);
-            }
-            return index;
-        }
-
-        /*
-         * Creates the resource and if the check flag is set to true, checks if
-         * is its okay to return the resource.
-         */
-        Resource checkResource(final String name, boolean check,
-            final JarEntry entry) {
-
-            final URL url;
-            try {
-                if (jar.isMultiRelease()) {
-                    // add #runtime fragment to tell JarURLConnection to use
-                    // runtime versioning if the underlying jar file is multi-release
-                    url = new URL(getBaseURL(), ParseUtil.encodePath(name, false) + "#runtime");
-                } else {
-                    url = new URL(getBaseURL(), ParseUtil.encodePath(name, false));
-                }
-                if (check) {
-                    URLClassPath.check(url);
-                }
-            } catch (MalformedURLException e) {
-                return null;
-                // throw new IllegalArgumentException("name");
-            } catch (IOException e) {
-                return null;
-            } catch (AccessControlException e) {
-                return null;
-            }
-
-            return new Resource() {
-                public String getName() { return name; }
-                public URL getURL() { return url; }
-                public URL getCodeSourceURL() { return csu; }
-                public InputStream getInputStream() throws IOException
-                    { return jar.getInputStream(entry); }
-                public int getContentLength()
-                    { return (int)entry.getSize(); }
-                public Manifest getManifest() throws IOException
-                    { return jar.getManifest(); };
-                public Certificate[] getCertificates()
-                    { return entry.getCertificates(); };
-                public CodeSigner[] getCodeSigners()
-                    { return entry.getCodeSigners(); };
-            };
-        }
-
-
-        /*
-         * Returns true iff atleast one resource in the jar file has the same
-         * package name as that of the specified resource name.
-         */
-        boolean validIndex(final String name) {
-            String packageName = name;
-            int pos;
-            if((pos = name.lastIndexOf('/')) != -1) {
-                packageName = name.substring(0, pos);
-            }
-
-            String entryName;
-            ZipEntry entry;
-            Enumeration<JarEntry> enum_ = jar.entries();
-            while (enum_.hasMoreElements()) {
-                entry = enum_.nextElement();
-                entryName = entry.getName();
-                if((pos = entryName.lastIndexOf('/')) != -1)
-                    entryName = entryName.substring(0, pos);
-                if (entryName.equals(packageName)) {
-                    return true;
-                }
-            }
-            return false;
-        }
-
-        /*
-         * Returns the URL for a resource with the specified name
-         */
-        URL findResource(final String name, boolean check) {
-            Resource rsc = getResource(name, check);
-            if (rsc != null) {
-                return rsc.getURL();
-            }
-            return null;
-        }
-
-        /*
-         * Returns the JAR Resource for the specified name.
-         */
-        Resource getResource(final String name, boolean check) {
-            try {
-                ensureOpen();
-            } catch (IOException e) {
-                throw new InternalError(e);
-            }
-            final JarEntry entry = jar.getJarEntry(name);
-            if (entry != null)
-                return checkResource(name, check, entry);
-
-            if (index == null)
-                return null;
-
-            HashSet<String> visited = new HashSet<>();
-            return getResource(name, check, visited);
-        }
-
-        /*
-         * Version of getResource() that tracks the jar files that have been
-         * visited by linking through the index files. This helper method uses
-         * a HashSet to store the URLs of jar files that have been searched and
-         * uses it to avoid going into an infinite loop, looking for a
-         * non-existent resource
-         */
-        Resource getResource(final String name, boolean check,
-                             Set<String> visited) {
-
-            Resource res;
-            String[] jarFiles;
-            int count = 0;
-            LinkedList<String> jarFilesList = null;
-
-            /* If there no jar files in the index that can potential contain
-             * this resource then return immediately.
-             */
-            if((jarFilesList = index.get(name)) == null)
-                return null;
-
-            do {
-                int size = jarFilesList.size();
-                jarFiles = jarFilesList.toArray(new String[size]);
-                /* loop through the mapped jar file list */
-                while(count < size) {
-                    String jarName = jarFiles[count++];
-                    JarLoader newLoader;
-                    final URL url;
-
-                    try{
-                        url = new URL(csu, jarName);
-                        String urlNoFragString = URLUtil.urlNoFragString(url);
-                        if ((newLoader = (JarLoader)lmap.get(urlNoFragString)) == null) {
-                            /* no loader has been set up for this jar file
-                             * before
-                             */
-                            newLoader = AccessController.doPrivileged(
-                                new PrivilegedExceptionAction<>() {
-                                    public JarLoader run() throws IOException {
-                                        return new JarLoader(url, handler,
-                                            lmap);
-                                    }
-                                });
-
-                            /* this newly opened jar file has its own index,
-                             * merge it into the parent's index, taking into
-                             * account the relative path.
-                             */
-                            JarIndex newIndex = newLoader.getIndex();
-                            if(newIndex != null) {
-                                int pos = jarName.lastIndexOf('/');
-                                newIndex.merge(this.index, (pos == -1 ?
-                                    null : jarName.substring(0, pos + 1)));
-                            }
-
-                            /* put it in the global hashtable */
-                            lmap.put(urlNoFragString, newLoader);
-                        }
-                    } catch (java.security.PrivilegedActionException pae) {
-                        continue;
-                    } catch (MalformedURLException e) {
-                        continue;
-                    }
-
-
-                    /* Note that the addition of the url to the list of visited
-                     * jars incorporates a check for presence in the hashmap
-                     */
-                    boolean visitedURL = !visited.add(URLUtil.urlNoFragString(url));
-                    if (!visitedURL) {
-                        try {
-                            newLoader.ensureOpen();
-                        } catch (IOException e) {
-                            throw new InternalError(e);
-                        }
-                        final JarEntry entry = newLoader.jar.getJarEntry(name);
-                        if (entry != null) {
-                            return newLoader.checkResource(name, check, entry);
-                        }
-
-                        /* Verify that at least one other resource with the
-                         * same package name as the lookedup resource is
-                         * present in the new jar
-                         */
-                        if (!newLoader.validIndex(name)) {
-                            /* the mapping is wrong */
-                            throw new InvalidJarIndexException("Invalid index");
-                        }
-                    }
-
-                    /* If newLoader is the current loader or if it is a
-                     * loader that has already been searched or if the new
-                     * loader does not have an index then skip it
-                     * and move on to the next loader.
-                     */
-                    if (visitedURL || newLoader == this ||
-                            newLoader.getIndex() == null) {
-                        continue;
-                    }
-
-                    /* Process the index of the new loader
-                     */
-                    if((res = newLoader.getResource(name, check, visited))
-                            != null) {
-                        return res;
-                    }
-                }
-                // Get the list of jar files again as the list could have grown
-                // due to merging of index files.
-                jarFilesList = index.get(name);
-
-            // If the count is unchanged, we are done.
-            } while(count < jarFilesList.size());
-            return null;
-        }
-
-
-        /*
-         * Returns the JAR file local class path, or null if none.
-         */
-        URL[] getClassPath() throws IOException {
-            if (index != null) {
-                return null;
-            }
-
-            ensureOpen();
-
-            if (SharedSecrets.javaUtilJarAccess().jarFileHasClassPathAttribute(jar)) { // Only get manifest when necessary
-                Manifest man = jar.getManifest();
-                if (man != null) {
-                    Attributes attr = man.getMainAttributes();
-                    if (attr != null) {
-                        String value = attr.getValue(Name.CLASS_PATH);
-                        if (value != null) {
-                            return parseClassPath(csu, value);
-                        }
-                    }
-                }
-            }
-            return null;
-        }
-
-        /*
-         * Parses value of the Class-Path manifest attribute and returns
-         * an array of URLs relative to the specified base URL.
-         */
-        private URL[] parseClassPath(URL base, String value)
-            throws MalformedURLException
-        {
-            StringTokenizer st = new StringTokenizer(value);
-            URL[] urls = new URL[st.countTokens()];
-            int i = 0;
-            while (st.hasMoreTokens()) {
-                String path = st.nextToken();
-                urls[i] = new URL(base, path);
-                i++;
-            }
-            return urls;
-        }
-    }
-
-    /*
-     * Inner class used to represent a loader of classes and resources
-     * from a file URL that refers to a directory.
-     */
-    private static class FileLoader extends Loader {
-        /* Canonicalized File */
-        private File dir;
-
-        FileLoader(URL url) throws IOException {
-            super(url);
-            if (!"file".equals(url.getProtocol())) {
-                throw new IllegalArgumentException("url");
-            }
-            String path = url.getFile().replace('/', File.separatorChar);
-            path = ParseUtil.decode(path);
-            dir = (new File(path)).getCanonicalFile();
-        }
-
-        /*
-         * Returns the URL for a resource with the specified name
-         */
-        URL findResource(final String name, boolean check) {
-            Resource rsc = getResource(name, check);
-            if (rsc != null) {
-                return rsc.getURL();
-            }
-            return null;
-        }
-
-        Resource getResource(final String name, boolean check) {
-            final URL url;
-            try {
-                URL normalizedBase = new URL(getBaseURL(), ".");
-                url = new URL(getBaseURL(), ParseUtil.encodePath(name, false));
-
-                if (url.getFile().startsWith(normalizedBase.getFile()) == false) {
-                    // requested resource had ../..'s in path
-                    return null;
-                }
-
-                if (check)
-                    URLClassPath.check(url);
-
-                final File file;
-                if (name.indexOf("..") != -1) {
-                    file = (new File(dir, name.replace('/', File.separatorChar)))
-                          .getCanonicalFile();
-                    if ( !((file.getPath()).startsWith(dir.getPath())) ) {
-                        /* outside of base dir */
-                        return null;
-                    }
-                } else {
-                    file = new File(dir, name.replace('/', File.separatorChar));
-                }
-
-                if (file.exists()) {
-                    return new Resource() {
-                        public String getName() { return name; };
-                        public URL getURL() { return url; };
-                        public URL getCodeSourceURL() { return getBaseURL(); };
-                        public InputStream getInputStream() throws IOException
-                            { return new FileInputStream(file); };
-                        public int getContentLength() throws IOException
-                            { return (int)file.length(); };
-                    };
-                }
-            } catch (Exception e) {
-                return null;
-            }
-            return null;
-        }
-    }
-}
--- a/jdk/src/java.base/share/classes/sun/misc/Unsafe.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/sun/misc/Unsafe.java	Mon Mar 28 08:41:54 2016 -0700
@@ -25,7 +25,7 @@
 
 package sun.misc;
 
-import jdk.internal.HotSpotIntrinsicCandidate;
+import jdk.internal.vm.annotation.ForceInline;
 import jdk.internal.misc.VM;
 import sun.reflect.CallerSensitive;
 import sun.reflect.Reflection;
@@ -39,21 +39,29 @@
  * Although the class and all methods are public, use of this class is
  * limited because only trusted code can obtain instances of it.
  *
+ * <em>Note:</em> It is the resposibility of the caller to make sure
+ * arguments are checked before methods of this class are
+ * called. While some rudimentary checks are performed on the input,
+ * the checks are best effort and when performance is an overriding
+ * priority, as when methods of this class are optimized by the
+ * runtime compiler, some or all checks (if any) may be elided. Hence,
+ * the caller must not rely on the checks and corresponding
+ * exceptions!
+ *
  * @author John R. Rose
  * @see #getUnsafe
  */
 
 public final class Unsafe {
 
-    private static native void registerNatives();
     static {
-        registerNatives();
         sun.reflect.Reflection.registerMethodsToFilter(Unsafe.class, "getUnsafe");
     }
 
     private Unsafe() {}
 
     private static final Unsafe theUnsafe = new Unsafe();
+    private static final jdk.internal.misc.Unsafe theInternalUnsafe = jdk.internal.misc.Unsafe.getUnsafe();
 
     /**
      * Provides the caller with the capability of performing unsafe
@@ -150,8 +158,10 @@
      * @throws RuntimeException No defined exceptions are thrown, not even
      *         {@link NullPointerException}
      */
-    @HotSpotIntrinsicCandidate
-    public native int getInt(Object o, long offset);
+    @ForceInline
+    public int getInt(Object o, long offset) {
+        return theInternalUnsafe.getInt(o, offset);
+    }
 
     /**
      * Stores a value into a given Java variable.
@@ -173,15 +183,19 @@
      * @throws RuntimeException No defined exceptions are thrown, not even
      *         {@link NullPointerException}
      */
-    @HotSpotIntrinsicCandidate
-    public native void putInt(Object o, long offset, int x);
+    @ForceInline
+    public void putInt(Object o, long offset, int x) {
+        theInternalUnsafe.putInt(o, offset, x);
+    }
 
     /**
      * Fetches a reference value from a given Java variable.
      * @see #getInt(Object, long)
      */
-    @HotSpotIntrinsicCandidate
-    public native Object getObject(Object o, long offset);
+    @ForceInline
+    public Object getObject(Object o, long offset) {
+        return theInternalUnsafe.getObject(o, offset);
+    }
 
     /**
      * Stores a reference value into a given Java variable.
@@ -193,51 +207,95 @@
      * are updated.
      * @see #putInt(Object, long, int)
      */
-    @HotSpotIntrinsicCandidate
-    public native void putObject(Object o, long offset, Object x);
+    @ForceInline
+    public void putObject(Object o, long offset, Object x) {
+        theInternalUnsafe.putObject(o, offset, x);
+    }
+
+    /** @see #getInt(Object, long) */
+    @ForceInline
+    public boolean getBoolean(Object o, long offset) {
+        return theInternalUnsafe.getBoolean(o, offset);
+    }
+
+    /** @see #putInt(Object, long, int) */
+    @ForceInline
+    public void putBoolean(Object o, long offset, boolean x) {
+        theInternalUnsafe.putBoolean(o, offset, x);
+    }
+
+    /** @see #getInt(Object, long) */
+    @ForceInline
+    public byte getByte(Object o, long offset) {
+        return theInternalUnsafe.getByte(o, offset);
+    }
+
+    /** @see #putInt(Object, long, int) */
+    @ForceInline
+    public void putByte(Object o, long offset, byte x) {
+        theInternalUnsafe.putByte(o, offset, x);
+    }
+
+    /** @see #getInt(Object, long) */
+    @ForceInline
+    public short getShort(Object o, long offset) {
+        return theInternalUnsafe.getShort(o, offset);
+    }
+
+    /** @see #putInt(Object, long, int) */
+    @ForceInline
+    public void putShort(Object o, long offset, short x) {
+        theInternalUnsafe.putShort(o, offset, x);
+    }
 
     /** @see #getInt(Object, long) */
-    @HotSpotIntrinsicCandidate
-    public native boolean getBoolean(Object o, long offset);
-    /** @see #putInt(Object, long, int) */
-    @HotSpotIntrinsicCandidate
-    public native void    putBoolean(Object o, long offset, boolean x);
-    /** @see #getInt(Object, long) */
-    @HotSpotIntrinsicCandidate
-    public native byte    getByte(Object o, long offset);
+    @ForceInline
+    public char getChar(Object o, long offset) {
+        return theInternalUnsafe.getChar(o, offset);
+    }
+
     /** @see #putInt(Object, long, int) */
-    @HotSpotIntrinsicCandidate
-    public native void    putByte(Object o, long offset, byte x);
+    @ForceInline
+    public void putChar(Object o, long offset, char x) {
+        theInternalUnsafe.putChar(o, offset, x);
+    }
+
     /** @see #getInt(Object, long) */
-    @HotSpotIntrinsicCandidate
-    public native short   getShort(Object o, long offset);
-    /** @see #putInt(Object, long, int) */
-    @HotSpotIntrinsicCandidate
-    public native void    putShort(Object o, long offset, short x);
-    /** @see #getInt(Object, long) */
-    @HotSpotIntrinsicCandidate
-    public native char    getChar(Object o, long offset);
+    @ForceInline
+    public long getLong(Object o, long offset) {
+        return theInternalUnsafe.getLong(o, offset);
+    }
+
     /** @see #putInt(Object, long, int) */
-    @HotSpotIntrinsicCandidate
-    public native void    putChar(Object o, long offset, char x);
-    /** @see #getInt(Object, long) */
-    @HotSpotIntrinsicCandidate
-    public native long    getLong(Object o, long offset);
-    /** @see #putInt(Object, long, int) */
-    @HotSpotIntrinsicCandidate
-    public native void    putLong(Object o, long offset, long x);
+    @ForceInline
+    public void putLong(Object o, long offset, long x) {
+        theInternalUnsafe.putLong(o, offset, x);
+    }
+
     /** @see #getInt(Object, long) */
-    @HotSpotIntrinsicCandidate
-    public native float   getFloat(Object o, long offset);
+    @ForceInline
+    public float getFloat(Object o, long offset) {
+        return theInternalUnsafe.getFloat(o, offset);
+    }
+
     /** @see #putInt(Object, long, int) */
-    @HotSpotIntrinsicCandidate
-    public native void    putFloat(Object o, long offset, float x);
+    @ForceInline
+    public void putFloat(Object o, long offset, float x) {
+        theInternalUnsafe.putFloat(o, offset, x);
+    }
+
     /** @see #getInt(Object, long) */
-    @HotSpotIntrinsicCandidate
-    public native double  getDouble(Object o, long offset);
+    @ForceInline
+    public double getDouble(Object o, long offset) {
+        return theInternalUnsafe.getDouble(o, offset);
+    }
+
     /** @see #putInt(Object, long, int) */
-    @HotSpotIntrinsicCandidate
-    public native void    putDouble(Object o, long offset, double x);
+    @ForceInline
+    public void putDouble(Object o, long offset, double x) {
+        theInternalUnsafe.putDouble(o, offset, x);
+    }
+
 
     // These read VM internal data.
 
@@ -248,7 +306,10 @@
      * @param address a memory address locating the variable
      * @return the value fetched from the indicated native variable
      */
-    public native Object getUncompressedObject(long address);
+    @ForceInline
+    public Object getUncompressedObject(long address) {
+        return theInternalUnsafe.getUncompressedObject(address);
+    }
 
     /**
      * Fetches the {@link java.lang.Class} Java mirror for the given native
@@ -257,7 +318,10 @@
      * @param metaspaceKlass a native metaspace {@code Klass} pointer
      * @return the {@link java.lang.Class} Java mirror
      */
-    public native Class<?> getJavaMirror(long metaspaceKlass);
+    @ForceInline
+    public Class<?> getJavaMirror(long metaspaceKlass) {
+        return theInternalUnsafe.getJavaMirror(metaspaceKlass);
+    }
 
     /**
      * Fetches a native metaspace {@code Klass} pointer for the given Java
@@ -266,7 +330,10 @@
      * @param o Java heap object for which to fetch the class pointer
      * @return a native metaspace {@code Klass} pointer
      */
-    public native long getKlassPointer(Object o);
+    @ForceInline
+    public long getKlassPointer(Object o) {
+        return theInternalUnsafe.getKlassPointer(o);
+    }
 
     // These work on values in the C heap.
 
@@ -277,8 +344,10 @@
      *
      * @see #allocateMemory
      */
-    @HotSpotIntrinsicCandidate
-    public native byte    getByte(long address);
+    @ForceInline
+    public byte getByte(long address) {
+        return theInternalUnsafe.getByte(address);
+    }
 
     /**
      * Stores a value into a given memory address.  If the address is zero, or
@@ -287,45 +356,83 @@
      *
      * @see #getByte(long)
      */
-    @HotSpotIntrinsicCandidate
-    public native void    putByte(long address, byte x);
+    @ForceInline
+    public void putByte(long address, byte x) {
+        theInternalUnsafe.putByte(address, x);
+    }
+
+    /** @see #getByte(long) */
+    @ForceInline
+    public short getShort(long address) {
+        return theInternalUnsafe.getShort(address);
+    }
+
+    /** @see #putByte(long, byte) */
+    @ForceInline
+    public void putShort(long address, short x) {
+        theInternalUnsafe.putShort(address, x);
+    }
+
+    /** @see #getByte(long) */
+    @ForceInline
+    public char getChar(long address) {
+        return theInternalUnsafe.getChar(address);
+    }
+
+    /** @see #putByte(long, byte) */
+    @ForceInline
+    public void putChar(long address, char x) {
+        theInternalUnsafe.putChar(address, x);
+    }
 
     /** @see #getByte(long) */
-    @HotSpotIntrinsicCandidate
-    public native short   getShort(long address);
-    /** @see #putByte(long, byte) */
-    @HotSpotIntrinsicCandidate
-    public native void    putShort(long address, short x);
-    /** @see #getByte(long) */
-    @HotSpotIntrinsicCandidate
-    public native char    getChar(long address);
+    @ForceInline
+    public int getInt(long address) {
+        return theInternalUnsafe.getInt(address);
+    }
+
     /** @see #putByte(long, byte) */
-    @HotSpotIntrinsicCandidate
-    public native void    putChar(long address, char x);
+    @ForceInline
+    public void putInt(long address, int x) {
+        theInternalUnsafe.putInt(address, x);
+    }
+
     /** @see #getByte(long) */
-    @HotSpotIntrinsicCandidate
-    public native int     getInt(long address);
+    @ForceInline
+    public long getLong(long address) {
+        return theInternalUnsafe.getLong(address);
+    }
+
     /** @see #putByte(long, byte) */
-    @HotSpotIntrinsicCandidate
-    public native void    putInt(long address, int x);
+    @ForceInline
+    public void putLong(long address, long x) {
+        theInternalUnsafe.putLong(address, x);
+    }
+
     /** @see #getByte(long) */
-    @HotSpotIntrinsicCandidate
-    public native long    getLong(long address);
-    /** @see #putByte(long, byte) */
-    @HotSpotIntrinsicCandidate
-    public native void    putLong(long address, long x);
-    /** @see #getByte(long) */
-    @HotSpotIntrinsicCandidate
-    public native float   getFloat(long address);
+    @ForceInline
+    public float getFloat(long address) {
+        return theInternalUnsafe.getFloat(address);
+    }
+
     /** @see #putByte(long, byte) */
-    @HotSpotIntrinsicCandidate
-    public native void    putFloat(long address, float x);
+    @ForceInline
+    public void putFloat(long address, float x) {
+        theInternalUnsafe.putFloat(address, x);
+    }
+
     /** @see #getByte(long) */
-    @HotSpotIntrinsicCandidate
-    public native double  getDouble(long address);
+    @ForceInline
+    public double getDouble(long address) {
+        return theInternalUnsafe.getDouble(address);
+    }
+
     /** @see #putByte(long, byte) */
-    @HotSpotIntrinsicCandidate
-    public native void    putDouble(long address, double x);
+    @ForceInline
+    public void putDouble(long address, double x) {
+        theInternalUnsafe.putDouble(address, x);
+    }
+
 
     /**
      * Fetches a native pointer from a given memory address.  If the address is
@@ -341,8 +448,10 @@
      *
      * @see #allocateMemory
      */
-    @HotSpotIntrinsicCandidate
-    public native long getAddress(long address);
+    @ForceInline
+    public long getAddress(long address) {
+        return theInternalUnsafe.getAddress(address);
+    }
 
     /**
      * Stores a native pointer into a given memory address.  If the address is
@@ -354,8 +463,11 @@
      *
      * @see #getAddress(long)
      */
-    @HotSpotIntrinsicCandidate
-    public native void putAddress(long address, long x);
+    @ForceInline
+    public void putAddress(long address, long x) {
+        theInternalUnsafe.putAddress(address, x);
+    }
+
 
     /// wrappers for malloc, realloc, free:
 
@@ -366,7 +478,16 @@
      * aligned for all value types.  Dispose of this memory by calling {@link
      * #freeMemory}, or resize it with {@link #reallocateMemory}.
      *
-     * @throws IllegalArgumentException if the size is negative or too large
+     * <em>Note:</em> It is the resposibility of the caller to make
+     * sure arguments are checked before the methods are called. While
+     * some rudimentary checks are performed on the input, the checks
+     * are best effort and when performance is an overriding priority,
+     * as when methods of this class are optimized by the runtime
+     * compiler, some or all checks (if any) may be elided. Hence, the
+     * caller must not rely on the checks and corresponding
+     * exceptions!
+     *
+     * @throws RuntimeException if the size is negative or too large
      *         for the native size_t type
      *
      * @throws OutOfMemoryError if the allocation is refused by the system
@@ -374,7 +495,10 @@
      * @see #getByte(long)
      * @see #putByte(long, byte)
      */
-    public native long allocateMemory(long bytes);
+    @ForceInline
+    public long allocateMemory(long bytes) {
+        return theInternalUnsafe.allocateMemory(bytes);
+    }
 
     /**
      * Resizes a new block of native memory, to the given size in bytes.  The
@@ -386,14 +510,26 @@
      * #reallocateMemory}.  The address passed to this method may be null, in
      * which case an allocation will be performed.
      *
-     * @throws IllegalArgumentException if the size is negative or too large
+     * <em>Note:</em> It is the resposibility of the caller to make
+     * sure arguments are checked before the methods are called. While
+     * some rudimentary checks are performed on the input, the checks
+     * are best effort and when performance is an overriding priority,
+     * as when methods of this class are optimized by the runtime
+     * compiler, some or all checks (if any) may be elided. Hence, the
+     * caller must not rely on the checks and corresponding
+     * exceptions!
+     *
+     * @throws RuntimeException if the size is negative or too large
      *         for the native size_t type
      *
      * @throws OutOfMemoryError if the allocation is refused by the system
      *
      * @see #allocateMemory
      */
-    public native long reallocateMemory(long address, long bytes);
+    @ForceInline
+    public long reallocateMemory(long address, long bytes) {
+        return theInternalUnsafe.reallocateMemory(address, bytes);
+    }
 
     /**
      * Sets all bytes in a given block of memory to a fixed value
@@ -410,9 +546,23 @@
      * If the effective address and length are (resp.) even modulo 4 or 2,
      * the stores take place in units of 'int' or 'short'.
      *
+     * <em>Note:</em> It is the resposibility of the caller to make
+     * sure arguments are checked before the methods are called. While
+     * some rudimentary checks are performed on the input, the checks
+     * are best effort and when performance is an overriding priority,
+     * as when methods of this class are optimized by the runtime
+     * compiler, some or all checks (if any) may be elided. Hence, the
+     * caller must not rely on the checks and corresponding
+     * exceptions!
+     *
+     * @throws RuntimeException if any of the arguments is invalid
+     *
      * @since 1.7
      */
-    public native void setMemory(Object o, long offset, long bytes, byte value);
+    @ForceInline
+    public void setMemory(Object o, long offset, long bytes, byte value) {
+        theInternalUnsafe.setMemory(o, offset, bytes, value);
+    }
 
     /**
      * Sets all bytes in a given block of memory to a fixed value
@@ -421,8 +571,9 @@
      *
      * <p>Equivalent to {@code setMemory(null, address, bytes, value)}.
      */
+    @ForceInline
     public void setMemory(long address, long bytes, byte value) {
-        setMemory(null, address, bytes, value);
+        theInternalUnsafe.setMemory(address, bytes, value);
     }
 
     /**
@@ -440,12 +591,26 @@
      * If the effective addresses and length are (resp.) even modulo 4 or 2,
      * the transfer takes place in units of 'int' or 'short'.
      *
+     * <em>Note:</em> It is the resposibility of the caller to make
+     * sure arguments are checked before the methods are called. While
+     * some rudimentary checks are performed on the input, the checks
+     * are best effort and when performance is an overriding priority,
+     * as when methods of this class are optimized by the runtime
+     * compiler, some or all checks (if any) may be elided. Hence, the
+     * caller must not rely on the checks and corresponding
+     * exceptions!
+     *
+     * @throws RuntimeException if any of the arguments is invalid
+     *
      * @since 1.7
      */
-    @HotSpotIntrinsicCandidate
-    public native void copyMemory(Object srcBase, long srcOffset,
-                                  Object destBase, long destOffset,
-                                  long bytes);
+    @ForceInline
+    public void copyMemory(Object srcBase, long srcOffset,
+                           Object destBase, long destOffset,
+                           long bytes) {
+        theInternalUnsafe.copyMemory(srcBase, srcOffset, destBase, destOffset, bytes);
+    }
+
     /**
      * Sets all bytes in a given block of memory to a copy of another
      * block.  This provides a <em>single-register</em> addressing mode,
@@ -453,8 +618,9 @@
      *
      * Equivalent to {@code copyMemory(null, srcAddress, null, destAddress, bytes)}.
      */
+    @ForceInline
     public void copyMemory(long srcAddress, long destAddress, long bytes) {
-        copyMemory(null, srcAddress, null, destAddress, bytes);
+        theInternalUnsafe.copyMemory(srcAddress, destAddress, bytes);
     }
 
     /**
@@ -462,9 +628,23 @@
      * #allocateMemory} or {@link #reallocateMemory}.  The address passed to
      * this method may be null, in which case no action is taken.
      *
+     * <em>Note:</em> It is the resposibility of the caller to make
+     * sure arguments are checked before the methods are called. While
+     * some rudimentary checks are performed on the input, the checks
+     * are best effort and when performance is an overriding priority,
+     * as when methods of this class are optimized by the runtime
+     * compiler, some or all checks (if any) may be elided. Hence, the
+     * caller must not rely on the checks and corresponding
+     * exceptions!
+     *
+     * @throws RuntimeException if any of the arguments is invalid
+     *
      * @see #allocateMemory
      */
-    public native void freeMemory(long address);
+    @ForceInline
+    public void freeMemory(long address) {
+        theInternalUnsafe.freeMemory(address);
+    }
 
     /// random queries
 
@@ -473,7 +653,7 @@
      * {@link #staticFieldOffset}, {@link #objectFieldOffset},
      * or {@link #arrayBaseOffset}.
      */
-    public static final int INVALID_FIELD_OFFSET   = -1;
+    public static final int INVALID_FIELD_OFFSET = jdk.internal.misc.Unsafe.INVALID_FIELD_OFFSET;
 
     /**
      * Reports the location of a given field in the storage allocation of its
@@ -493,7 +673,10 @@
      * must preserve all bits of static field offsets.
      * @see #getInt(Object, long)
      */
-    public native long objectFieldOffset(Field f);
+    @ForceInline
+    public long objectFieldOffset(Field f) {
+        return theInternalUnsafe.objectFieldOffset(f);
+    }
 
     /**
      * Reports the location of a given static field, in conjunction with {@link
@@ -512,7 +695,10 @@
      * this method reports its result as a long value.
      * @see #getInt(Object, long)
      */
-    public native long staticFieldOffset(Field f);
+    @ForceInline
+    public long staticFieldOffset(Field f) {
+        return theInternalUnsafe.staticFieldOffset(f);
+    }
 
     /**
      * Reports the location of a given static field, in conjunction with {@link
@@ -524,7 +710,10 @@
      * not be used in any way except as argument to the get and put routines in
      * this class.
      */
-    public native Object staticFieldBase(Field f);
+    @ForceInline
+    public Object staticFieldBase(Field f) {
+        return theInternalUnsafe.staticFieldBase(f);
+    }
 
     /**
      * Detects if the given class may need to be initialized. This is often
@@ -532,14 +721,20 @@
      * class.
      * @return false only if a call to {@code ensureClassInitialized} would have no effect
      */
-    public native boolean shouldBeInitialized(Class<?> c);
+    @ForceInline
+    public boolean shouldBeInitialized(Class<?> c) {
+        return theInternalUnsafe.shouldBeInitialized(c);
+    }
 
     /**
      * Ensures the given class has been initialized. This is often
      * needed in conjunction with obtaining the static field base of a
      * class.
      */
-    public native void ensureClassInitialized(Class<?> c);
+    @ForceInline
+    public void ensureClassInitialized(Class<?> c) {
+        theInternalUnsafe.ensureClassInitialized(c);
+    }
 
     /**
      * Reports the offset of the first element in the storage allocation of a
@@ -551,43 +746,37 @@
      * @see #getInt(Object, long)
      * @see #putInt(Object, long, int)
      */
-    public native int arrayBaseOffset(Class<?> arrayClass);
+    @ForceInline
+    public int arrayBaseOffset(Class<?> arrayClass) {
+        return theInternalUnsafe.arrayBaseOffset(arrayClass);
+    }
 
     /** The value of {@code arrayBaseOffset(boolean[].class)} */
-    public static final int ARRAY_BOOLEAN_BASE_OFFSET
-            = theUnsafe.arrayBaseOffset(boolean[].class);
+    public static final int ARRAY_BOOLEAN_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_BOOLEAN_BASE_OFFSET;
 
     /** The value of {@code arrayBaseOffset(byte[].class)} */
-    public static final int ARRAY_BYTE_BASE_OFFSET
-            = theUnsafe.arrayBaseOffset(byte[].class);
+    public static final int ARRAY_BYTE_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_BYTE_BASE_OFFSET;
 
     /** The value of {@code arrayBaseOffset(short[].class)} */
-    public static final int ARRAY_SHORT_BASE_OFFSET
-            = theUnsafe.arrayBaseOffset(short[].class);
+    public static final int ARRAY_SHORT_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_SHORT_BASE_OFFSET;
 
     /** The value of {@code arrayBaseOffset(char[].class)} */
-    public static final int ARRAY_CHAR_BASE_OFFSET
-            = theUnsafe.arrayBaseOffset(char[].class);
+    public static final int ARRAY_CHAR_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_CHAR_BASE_OFFSET;
 
     /** The value of {@code arrayBaseOffset(int[].class)} */
-    public static final int ARRAY_INT_BASE_OFFSET
-            = theUnsafe.arrayBaseOffset(int[].class);
+    public static final int ARRAY_INT_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_INT_BASE_OFFSET;
 
     /** The value of {@code arrayBaseOffset(long[].class)} */
-    public static final int ARRAY_LONG_BASE_OFFSET
-            = theUnsafe.arrayBaseOffset(long[].class);
+    public static final int ARRAY_LONG_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_LONG_BASE_OFFSET;
 
     /** The value of {@code arrayBaseOffset(float[].class)} */
-    public static final int ARRAY_FLOAT_BASE_OFFSET
-            = theUnsafe.arrayBaseOffset(float[].class);
+    public static final int ARRAY_FLOAT_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_FLOAT_BASE_OFFSET;
 
     /** The value of {@code arrayBaseOffset(double[].class)} */
-    public static final int ARRAY_DOUBLE_BASE_OFFSET
-            = theUnsafe.arrayBaseOffset(double[].class);
+    public static final int ARRAY_DOUBLE_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_DOUBLE_BASE_OFFSET;
 
     /** The value of {@code arrayBaseOffset(Object[].class)} */
-    public static final int ARRAY_OBJECT_BASE_OFFSET
-            = theUnsafe.arrayBaseOffset(Object[].class);
+    public static final int ARRAY_OBJECT_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_OBJECT_BASE_OFFSET;
 
     /**
      * Reports the scale factor for addressing elements in the storage
@@ -600,43 +789,37 @@
      * @see #getInt(Object, long)
      * @see #putInt(Object, long, int)
      */
-    public native int arrayIndexScale(Class<?> arrayClass);
+    @ForceInline
+    public int arrayIndexScale(Class<?> arrayClass) {
+        return theInternalUnsafe.arrayIndexScale(arrayClass);
+    }
 
     /** The value of {@code arrayIndexScale(boolean[].class)} */
-    public static final int ARRAY_BOOLEAN_INDEX_SCALE
-            = theUnsafe.arrayIndexScale(boolean[].class);
+    public static final int ARRAY_BOOLEAN_INDEX_SCALE = jdk.internal.misc.Unsafe.ARRAY_BOOLEAN_INDEX_SCALE;
 
     /** The value of {@code arrayIndexScale(byte[].class)} */
-    public static final int ARRAY_BYTE_INDEX_SCALE
-            = theUnsafe.arrayIndexScale(byte[].class);
+    public static final int ARRAY_BYTE_INDEX_SCALE = jdk.internal.misc.Unsafe.ARRAY_BYTE_INDEX_SCALE;
 
     /** The value of {@code arrayIndexScale(short[].class)} */
-    public static final int ARRAY_SHORT_INDEX_SCALE
-            = theUnsafe.arrayIndexScale(short[].class);
+    public static final int ARRAY_SHORT_INDEX_SCALE = jdk.internal.misc.Unsafe.ARRAY_SHORT_INDEX_SCALE;
 
     /** The value of {@code arrayIndexScale(char[].class)} */
-    public static final int ARRAY_CHAR_INDEX_SCALE
-            = theUnsafe.arrayIndexScale(char[].class);
+    public static final int ARRAY_CHAR_INDEX_SCALE = jdk.internal.misc.Unsafe.ARRAY_CHAR_INDEX_SCALE;
 
     /** The value of {@code arrayIndexScale(int[].class)} */
-    public static final int ARRAY_INT_INDEX_SCALE
-            = theUnsafe.arrayIndexScale(int[].class);
+    public static final int ARRAY_INT_INDEX_SCALE = jdk.internal.misc.Unsafe.ARRAY_INT_INDEX_SCALE;
 
     /** The value of {@code arrayIndexScale(long[].class)} */
-    public static final int ARRAY_LONG_INDEX_SCALE
-            = theUnsafe.arrayIndexScale(long[].class);
+    public static final int ARRAY_LONG_INDEX_SCALE = jdk.internal.misc.Unsafe.ARRAY_LONG_INDEX_SCALE;
 
     /** The value of {@code arrayIndexScale(float[].class)} */
-    public static final int ARRAY_FLOAT_INDEX_SCALE
-            = theUnsafe.arrayIndexScale(float[].class);
+    public static final int ARRAY_FLOAT_INDEX_SCALE = jdk.internal.misc.Unsafe.ARRAY_FLOAT_INDEX_SCALE;
 
     /** The value of {@code arrayIndexScale(double[].class)} */
-    public static final int ARRAY_DOUBLE_INDEX_SCALE
-            = theUnsafe.arrayIndexScale(double[].class);
+    public static final int ARRAY_DOUBLE_INDEX_SCALE = jdk.internal.misc.Unsafe.ARRAY_DOUBLE_INDEX_SCALE;
 
     /** The value of {@code arrayIndexScale(Object[].class)} */
-    public static final int ARRAY_OBJECT_INDEX_SCALE
-            = theUnsafe.arrayIndexScale(Object[].class);
+    public static final int ARRAY_OBJECT_INDEX_SCALE = jdk.internal.misc.Unsafe.ARRAY_OBJECT_INDEX_SCALE;
 
     /**
      * Reports the size in bytes of a native pointer, as stored via {@link
@@ -644,16 +827,22 @@
      * other primitive types (as stored in native memory blocks) is determined
      * fully by their information content.
      */
-    public native int addressSize();
+    @ForceInline
+    public int addressSize() {
+        return theInternalUnsafe.addressSize();
+    }
 
     /** The value of {@code addressSize()} */
-    public static final int ADDRESS_SIZE = theUnsafe.addressSize();
+    public static final int ADDRESS_SIZE = theInternalUnsafe.addressSize();
 
     /**
      * Reports the size in bytes of a native memory page (whatever that is).
      * This value will always be a power of two.
      */
-    public native int pageSize();
+    @ForceInline
+    public int pageSize() {
+        return theInternalUnsafe.pageSize();
+    }
 
 
     /// random trusted operations from JNI:
@@ -662,9 +851,12 @@
      * Tells the VM to define a class, without security checks.  By default, the
      * class loader and protection domain come from the caller's class.
      */
-    public native Class<?> defineClass(String name, byte[] b, int off, int len,
-                                       ClassLoader loader,
-                                       ProtectionDomain protectionDomain);
+    @ForceInline
+    public Class<?> defineClass(String name, byte[] b, int off, int len,
+                                ClassLoader loader,
+                                ProtectionDomain protectionDomain) {
+        return theInternalUnsafe.defineClass(name, b, off, len, loader, protectionDomain);
+    }
 
     /**
      * Defines a class but does not make it known to the class loader or system dictionary.
@@ -682,18 +874,26 @@
      * @param data      bytes of a class file
      * @param cpPatches where non-null entries exist, they replace corresponding CP entries in data
      */
-    public native Class<?> defineAnonymousClass(Class<?> hostClass, byte[] data, Object[] cpPatches);
+    @ForceInline
+    public Class<?> defineAnonymousClass(Class<?> hostClass, byte[] data, Object[] cpPatches) {
+        return theInternalUnsafe.defineAnonymousClass(hostClass, data, cpPatches);
+    }
 
     /**
      * Allocates an instance but does not run any constructor.
      * Initializes the class if it has not yet been.
      */
-    @HotSpotIntrinsicCandidate
-    public native Object allocateInstance(Class<?> cls)
-        throws InstantiationException;
+    @ForceInline
+    public Object allocateInstance(Class<?> cls)
+        throws InstantiationException {
+        return theInternalUnsafe.allocateInstance(cls);
+    }
 
     /** Throws the exception without telling the verifier. */
-    public native void throwException(Throwable ee);
+    @ForceInline
+    public void throwException(Throwable ee) {
+        theInternalUnsafe.throwException(ee);
+    }
 
     /**
      * Atomically updates Java variable to {@code x} if it is currently
@@ -704,10 +904,12 @@
      *
      * @return {@code true} if successful
      */
-    @HotSpotIntrinsicCandidate
-    public final native boolean compareAndSwapObject(Object o, long offset,
-                                                     Object expected,
-                                                     Object x);
+    @ForceInline
+    public final boolean compareAndSwapObject(Object o, long offset,
+                                              Object expected,
+                                              Object x) {
+        return theInternalUnsafe.compareAndSwapObject(o, offset, expected, x);
+    }
 
     /**
      * Atomically updates Java variable to {@code x} if it is currently
@@ -718,10 +920,12 @@
      *
      * @return {@code true} if successful
      */
-    @HotSpotIntrinsicCandidate
-    public final native boolean compareAndSwapInt(Object o, long offset,
-                                                  int expected,
-                                                  int x);
+    @ForceInline
+    public final boolean compareAndSwapInt(Object o, long offset,
+                                           int expected,
+                                           int x) {
+        return theInternalUnsafe.compareAndSwapInt(o, offset, expected, x);
+    }
 
     /**
      * Atomically updates Java variable to {@code x} if it is currently
@@ -732,88 +936,126 @@
      *
      * @return {@code true} if successful
      */
-    @HotSpotIntrinsicCandidate
-    public final native boolean compareAndSwapLong(Object o, long offset,
-                                                   long expected,
-                                                   long x);
+    @ForceInline
+    public final boolean compareAndSwapLong(Object o, long offset,
+                                            long expected,
+                                            long x) {
+        return theInternalUnsafe.compareAndSwapLong(o, offset, expected, x);
+    }
 
     /**
      * Fetches a reference value from a given Java variable, with volatile
      * load semantics. Otherwise identical to {@link #getObject(Object, long)}
      */
-    @HotSpotIntrinsicCandidate
-    public native Object getObjectVolatile(Object o, long offset);
+    @ForceInline
+    public Object getObjectVolatile(Object o, long offset) {
+        return theInternalUnsafe.getObjectVolatile(o, offset);
+    }
 
     /**
      * Stores a reference value into a given Java variable, with
      * volatile store semantics. Otherwise identical to {@link #putObject(Object, long, Object)}
      */
-    @HotSpotIntrinsicCandidate
-    public native void    putObjectVolatile(Object o, long offset, Object x);
+    @ForceInline
+    public void putObjectVolatile(Object o, long offset, Object x) {
+        theInternalUnsafe.putObjectVolatile(o, offset, x);
+    }
 
     /** Volatile version of {@link #getInt(Object, long)}  */
-    @HotSpotIntrinsicCandidate
-    public native int     getIntVolatile(Object o, long offset);
+    @ForceInline
+    public int getIntVolatile(Object o, long offset) {
+        return theInternalUnsafe.getIntVolatile(o, offset);
+    }
 
     /** Volatile version of {@link #putInt(Object, long, int)}  */
-    @HotSpotIntrinsicCandidate
-    public native void    putIntVolatile(Object o, long offset, int x);
+    @ForceInline
+    public void putIntVolatile(Object o, long offset, int x) {
+        theInternalUnsafe.putIntVolatile(o, offset, x);
+    }
 
     /** Volatile version of {@link #getBoolean(Object, long)}  */
-    @HotSpotIntrinsicCandidate
-    public native boolean getBooleanVolatile(Object o, long offset);
+    @ForceInline
+    public boolean getBooleanVolatile(Object o, long offset) {
+        return theInternalUnsafe.getBooleanVolatile(o, offset);
+    }
 
     /** Volatile version of {@link #putBoolean(Object, long, boolean)}  */
-    @HotSpotIntrinsicCandidate
-    public native void    putBooleanVolatile(Object o, long offset, boolean x);
+    @ForceInline
+    public void putBooleanVolatile(Object o, long offset, boolean x) {
+        theInternalUnsafe.putBooleanVolatile(o, offset, x);
+    }
 
     /** Volatile version of {@link #getByte(Object, long)}  */
-    @HotSpotIntrinsicCandidate
-    public native byte    getByteVolatile(Object o, long offset);
+    @ForceInline
+    public byte getByteVolatile(Object o, long offset) {
+        return theInternalUnsafe.getByteVolatile(o, offset);
+    }
 
     /** Volatile version of {@link #putByte(Object, long, byte)}  */
-    @HotSpotIntrinsicCandidate
-    public native void    putByteVolatile(Object o, long offset, byte x);
+    @ForceInline
+    public void putByteVolatile(Object o, long offset, byte x) {
+        theInternalUnsafe.putByteVolatile(o, offset, x);
+    }
 
     /** Volatile version of {@link #getShort(Object, long)}  */
-    @HotSpotIntrinsicCandidate
-    public native short   getShortVolatile(Object o, long offset);
+    @ForceInline
+    public short getShortVolatile(Object o, long offset) {
+        return theInternalUnsafe.getShortVolatile(o, offset);
+    }
 
     /** Volatile version of {@link #putShort(Object, long, short)}  */
-    @HotSpotIntrinsicCandidate
-    public native void    putShortVolatile(Object o, long offset, short x);
+    @ForceInline
+    public void putShortVolatile(Object o, long offset, short x) {
+        theInternalUnsafe.putShortVolatile(o, offset, x);
+    }
 
     /** Volatile version of {@link #getChar(Object, long)}  */
-    @HotSpotIntrinsicCandidate
-    public native char    getCharVolatile(Object o, long offset);
+    @ForceInline
+    public char getCharVolatile(Object o, long offset) {
+        return theInternalUnsafe.getCharVolatile(o, offset);
+    }
 
     /** Volatile version of {@link #putChar(Object, long, char)}  */
-    @HotSpotIntrinsicCandidate
-    public native void    putCharVolatile(Object o, long offset, char x);
+    @ForceInline
+    public void putCharVolatile(Object o, long offset, char x) {
+        theInternalUnsafe.putCharVolatile(o, offset, x);
+    }
 
     /** Volatile version of {@link #getLong(Object, long)}  */
-    @HotSpotIntrinsicCandidate
-    public native long    getLongVolatile(Object o, long offset);
+    @ForceInline
+    public long getLongVolatile(Object o, long offset) {
+        return theInternalUnsafe.getLongVolatile(o, offset);
+    }
 
     /** Volatile version of {@link #putLong(Object, long, long)}  */
-    @HotSpotIntrinsicCandidate
-    public native void    putLongVolatile(Object o, long offset, long x);
+    @ForceInline
+    public void putLongVolatile(Object o, long offset, long x) {
+        theInternalUnsafe.putLongVolatile(o, offset, x);
+    }
 
     /** Volatile version of {@link #getFloat(Object, long)}  */
-    @HotSpotIntrinsicCandidate
-    public native float   getFloatVolatile(Object o, long offset);
+    @ForceInline
+    public float getFloatVolatile(Object o, long offset) {
+        return theInternalUnsafe.getFloatVolatile(o, offset);
+    }
 
     /** Volatile version of {@link #putFloat(Object, long, float)}  */
-    @HotSpotIntrinsicCandidate
-    public native void    putFloatVolatile(Object o, long offset, float x);
+    @ForceInline
+    public void putFloatVolatile(Object o, long offset, float x) {
+        theInternalUnsafe.putFloatVolatile(o, offset, x);
+    }
 
     /** Volatile version of {@link #getDouble(Object, long)}  */
-    @HotSpotIntrinsicCandidate
-    public native double  getDoubleVolatile(Object o, long offset);
+    @ForceInline
+    public double getDoubleVolatile(Object o, long offset) {
+        return theInternalUnsafe.getDoubleVolatile(o, offset);
+    }
 
     /** Volatile version of {@link #putDouble(Object, long, double)}  */
-    @HotSpotIntrinsicCandidate
-    public native void    putDoubleVolatile(Object o, long offset, double x);
+    @ForceInline
+    public void putDoubleVolatile(Object o, long offset, double x) {
+        theInternalUnsafe.putDoubleVolatile(o, offset, x);
+    }
 
     /**
      * Version of {@link #putObjectVolatile(Object, long, Object)}
@@ -824,16 +1066,22 @@
      *
      * Corresponds to C11 atomic_store_explicit(..., memory_order_release).
      */
-    @HotSpotIntrinsicCandidate
-    public native void    putOrderedObject(Object o, long offset, Object x);
+    @ForceInline
+    public void putOrderedObject(Object o, long offset, Object x) {
+        theInternalUnsafe.putOrderedObject(o, offset, x);
+    }
 
     /** Ordered/Lazy version of {@link #putIntVolatile(Object, long, int)}  */
-    @HotSpotIntrinsicCandidate
-    public native void    putOrderedInt(Object o, long offset, int x);
+    @ForceInline
+    public void putOrderedInt(Object o, long offset, int x) {
+        theInternalUnsafe.putOrderedInt(o, offset, x);
+    }
 
     /** Ordered/Lazy version of {@link #putLongVolatile(Object, long, long)} */
-    @HotSpotIntrinsicCandidate
-    public native void    putOrderedLong(Object o, long offset, long x);
+    @ForceInline
+    public void putOrderedLong(Object o, long offset, long x) {
+        theInternalUnsafe.putOrderedLong(o, offset, x);
+    }
 
     /**
      * Unblocks the given thread blocked on {@code park}, or, if it is
@@ -847,8 +1095,10 @@
      *
      * @param thread the thread to unpark.
      */
-    @HotSpotIntrinsicCandidate
-    public native void unpark(Object thread);
+    @ForceInline
+    public void unpark(Object thread) {
+        theInternalUnsafe.unpark(thread);
+    }
 
     /**
      * Blocks current thread, returning when a balancing
@@ -861,8 +1111,10 @@
      * because {@code unpark} is, so it would be strange to place it
      * elsewhere.
      */
-    @HotSpotIntrinsicCandidate
-    public native void park(boolean isAbsolute, long time);
+    @ForceInline
+    public void park(boolean isAbsolute, long time) {
+        theInternalUnsafe.park(isAbsolute, time);
+    }
 
     /**
      * Gets the load average in the system run queue assigned
@@ -879,7 +1131,10 @@
      * @return the number of samples actually retrieved; or -1
      *         if the load average is unobtainable.
      */
-    public native int getLoadAverage(double[] loadavg, int nelems);
+    @ForceInline
+    public int getLoadAverage(double[] loadavg, int nelems) {
+        return theInternalUnsafe.getLoadAverage(loadavg, nelems);
+    }
 
     // The following contain CAS-based Java implementations used on
     // platforms not supporting native instructions
@@ -895,13 +1150,9 @@
      * @return the previous value
      * @since 1.8
      */
-    @HotSpotIntrinsicCandidate
+    @ForceInline
     public final int getAndAddInt(Object o, long offset, int delta) {
-        int v;
-        do {
-            v = getIntVolatile(o, offset);
-        } while (!compareAndSwapInt(o, offset, v, v + delta));
-        return v;
+        return theInternalUnsafe.getAndAddInt(o, offset, delta);
     }
 
     /**
@@ -915,13 +1166,9 @@
      * @return the previous value
      * @since 1.8
      */
-    @HotSpotIntrinsicCandidate
+    @ForceInline
     public final long getAndAddLong(Object o, long offset, long delta) {
-        long v;
-        do {
-            v = getLongVolatile(o, offset);
-        } while (!compareAndSwapLong(o, offset, v, v + delta));
-        return v;
+        return theInternalUnsafe.getAndAddLong(o, offset, delta);
     }
 
     /**
@@ -935,13 +1182,9 @@
      * @return the previous value
      * @since 1.8
      */
-    @HotSpotIntrinsicCandidate
+    @ForceInline
     public final int getAndSetInt(Object o, long offset, int newValue) {
-        int v;
-        do {
-            v = getIntVolatile(o, offset);
-        } while (!compareAndSwapInt(o, offset, v, newValue));
-        return v;
+        return theInternalUnsafe.getAndSetInt(o, offset, newValue);
     }
 
     /**
@@ -955,13 +1198,9 @@
      * @return the previous value
      * @since 1.8
      */
-    @HotSpotIntrinsicCandidate
+    @ForceInline
     public final long getAndSetLong(Object o, long offset, long newValue) {
-        long v;
-        do {
-            v = getLongVolatile(o, offset);
-        } while (!compareAndSwapLong(o, offset, v, newValue));
-        return v;
+        return theInternalUnsafe.getAndSetLong(o, offset, newValue);
     }
 
     /**
@@ -975,13 +1214,9 @@
      * @return the previous value
      * @since 1.8
      */
-    @HotSpotIntrinsicCandidate
+    @ForceInline
     public final Object getAndSetObject(Object o, long offset, Object newValue) {
-        Object v;
-        do {
-            v = getObjectVolatile(o, offset);
-        } while (!compareAndSwapObject(o, offset, v, newValue));
-        return v;
+        return theInternalUnsafe.getAndSetObject(o, offset, newValue);
     }
 
 
@@ -997,8 +1232,10 @@
      * provide a LoadLoad barrier also provide a LoadStore barrier for free.
      * @since 1.8
      */
-    @HotSpotIntrinsicCandidate
-    public native void loadFence();
+    @ForceInline
+    public void loadFence() {
+        theInternalUnsafe.loadFence();
+    }
 
     /**
      * Ensures that loads and stores before the fence will not be reordered with
@@ -1012,8 +1249,10 @@
      * provide a StoreStore barrier also provide a LoadStore barrier for free.
      * @since 1.8
      */
-    @HotSpotIntrinsicCandidate
-    public native void storeFence();
+    @ForceInline
+    public void storeFence() {
+        theInternalUnsafe.storeFence();
+    }
 
     /**
      * Ensures that loads and stores before the fence will not be reordered
@@ -1024,15 +1263,8 @@
      * Corresponds to C11 atomic_thread_fence(memory_order_seq_cst).
      * @since 1.8
      */
-    @HotSpotIntrinsicCandidate
-    public native void fullFence();
-
-    /**
-     * Throws IllegalAccessError; for use by the VM for access control
-     * error support.
-     * @since 1.8
-     */
-    private static void throwIllegalAccessError() {
-        throw new IllegalAccessError();
+    @ForceInline
+    public void fullFence() {
+        theInternalUnsafe.fullFence();
     }
 }
--- a/jdk/src/java.base/share/classes/sun/net/www/http/KeepAliveCache.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/sun/net/www/http/KeepAliveCache.java	Mon Mar 28 08:41:54 2016 -0700
@@ -96,12 +96,9 @@
             java.security.AccessController.doPrivileged(
                 new java.security.PrivilegedAction<>() {
                 public Void run() {
-                    keepAliveTimer = new InnocuousThread(cache, "Keep-Alive-Timer");
+                    keepAliveTimer = InnocuousThread.newSystemThread("Keep-Alive-Timer", cache);
                     keepAliveTimer.setDaemon(true);
                     keepAliveTimer.setPriority(Thread.MAX_PRIORITY - 2);
-                    // Set the context class loader to null in order to avoid
-                    // keeping a strong reference to an application classloader.
-                    keepAliveTimer.setContextClassLoader(null);
                     keepAliveTimer.start();
                     return null;
                 }
--- a/jdk/src/java.base/share/classes/sun/net/www/http/KeepAliveStream.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/sun/net/www/http/KeepAliveStream.java	Mon Mar 28 08:41:54 2016 -0700
@@ -173,12 +173,9 @@
                 java.security.AccessController.doPrivileged(
                     new java.security.PrivilegedAction<Void>() {
                     public Void run() {
-                        cleanerThread = new InnocuousThread(queue, "Keep-Alive-SocketCleaner");
+                        cleanerThread = InnocuousThread.newSystemThread("Keep-Alive-SocketCleaner", queue);
                         cleanerThread.setDaemon(true);
                         cleanerThread.setPriority(Thread.MAX_PRIORITY - 2);
-                        // Set the context class loader to null in order to avoid
-                        // keeping a strong reference to an application classloader.
-                        cleanerThread.setContextClassLoader(null);
                         cleanerThread.start();
                         return null;
                     }
--- a/jdk/src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java	Mon Mar 28 08:41:54 2016 -0700
@@ -41,8 +41,8 @@
 import jdk.internal.jimage.ImageReader;
 import jdk.internal.jimage.ImageReaderFactory;
 
-import sun.misc.URLClassPath;
-import sun.misc.Resource;
+import jdk.internal.loader.URLClassPath;
+import jdk.internal.loader.Resource;
 import sun.net.www.ParseUtil;
 import sun.net.www.URLConnection;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/sun/nio/ch/SocketOptionRegistry.java.template	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+@@END_COPYRIGHT@@
+
+#include <stdio.h>
+#ifdef _WIN32
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#else
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#endif
+
+/* Defines SO_REUSEPORT */
+#if !defined(SO_REUSEPORT)
+#ifdef _WIN32
+#define SO_REUSEPORT 0
+#elif __linux__
+#define SO_REUSEPORT 15
+#elif __solaris__
+#define SO_REUSEPORT 0x100e
+#elif defined(AIX) || defined(MACOSX)
+#define SO_REUSEPORT 0x0200
+#else
+#define SO_REUSEPORT 0
+#endif
+#endif
+
+/* On Solaris, "sun" is defined as a macro. Undefine to make package
+   declaration valid */
+#undef sun
+
+/* To be able to name the Java constants the same as the C constants without
+   having the preprocessor rewrite those identifiers, add PREFIX_ to all
+   identifiers matching a C constant. The PREFIX_ is filtered out in the
+   makefile. */
+
+@@START_HERE@@
+
+package sun.nio.ch;
+import java.net.SocketOption;
+import java.net.StandardSocketOptions;
+import java.net.ProtocolFamily;
+import java.net.StandardProtocolFamily;
+import java.util.Map;
+import java.util.HashMap;
+class SocketOptionRegistry {
+
+    private SocketOptionRegistry() { }
+
+    private static class RegistryKey {
+        private final SocketOption<?> name;
+        private final ProtocolFamily family;
+        RegistryKey(SocketOption<?> name, ProtocolFamily family) {
+            this.name = name;
+            this.family = family;
+        }
+        public int hashCode() {
+            return name.hashCode() + family.hashCode();
+        }
+        public boolean equals(Object ob) {
+            if (ob == null) return false;
+            if (!(ob instanceof RegistryKey)) return false;
+            RegistryKey other = (RegistryKey)ob;
+            if (this.name != other.name) return false;
+            if (this.family != other.family) return false;
+            return true;
+        }
+    }
+
+    private static class LazyInitialization {
+
+        static final Map<RegistryKey,OptionKey> options = options();
+
+        private static Map<RegistryKey,OptionKey> options() {
+            Map<RegistryKey,OptionKey> map =
+                new HashMap<RegistryKey,OptionKey>();
+            map.put(new RegistryKey(StandardSocketOptions.PREFIX_SO_BROADCAST,
+                Net.UNSPEC), new OptionKey(SOL_SOCKET, SO_BROADCAST));
+            map.put(new RegistryKey(StandardSocketOptions.PREFIX_SO_KEEPALIVE,
+                Net.UNSPEC), new OptionKey(SOL_SOCKET, SO_KEEPALIVE));
+            map.put(new RegistryKey(StandardSocketOptions.PREFIX_SO_LINGER,
+                Net.UNSPEC), new OptionKey(SOL_SOCKET, SO_LINGER));
+            map.put(new RegistryKey(StandardSocketOptions.PREFIX_SO_SNDBUF,
+                Net.UNSPEC), new OptionKey(SOL_SOCKET, SO_SNDBUF));
+            map.put(new RegistryKey(StandardSocketOptions.PREFIX_SO_RCVBUF,
+                Net.UNSPEC), new OptionKey(SOL_SOCKET, SO_RCVBUF));
+            map.put(new RegistryKey(StandardSocketOptions.PREFIX_SO_REUSEADDR,
+                Net.UNSPEC), new OptionKey(SOL_SOCKET, SO_REUSEADDR));
+            map.put(new RegistryKey(StandardSocketOptions.PREFIX_SO_REUSEPORT,
+                Net.UNSPEC), new OptionKey(SOL_SOCKET, SO_REUSEPORT));
+            // IPPROTO_TCP is 6
+            map.put(new RegistryKey(StandardSocketOptions.PREFIX_TCP_NODELAY,
+                Net.UNSPEC), new OptionKey(6, TCP_NODELAY));
+
+            // IPPROTO_IP is 0
+            map.put(new RegistryKey(StandardSocketOptions.PREFIX_IP_TOS,
+                StandardProtocolFamily.INET), new OptionKey(0, IP_TOS));
+            map.put(new RegistryKey(StandardSocketOptions.PREFIX_IP_MULTICAST_IF,
+                StandardProtocolFamily.INET), new OptionKey(0, IP_MULTICAST_IF));
+            map.put(new RegistryKey(StandardSocketOptions.PREFIX_IP_MULTICAST_TTL,
+                StandardProtocolFamily.INET), new OptionKey(0, IP_MULTICAST_TTL));
+            map.put(new RegistryKey(StandardSocketOptions.PREFIX_IP_MULTICAST_LOOP,
+                StandardProtocolFamily.INET), new OptionKey(0, IP_MULTICAST_LOOP));
+
+#ifdef AF_INET6
+            // IPPROTO_IPV6 is 41
+            map.put(new RegistryKey(StandardSocketOptions.PREFIX_IP_TOS,
+                StandardProtocolFamily.INET6), new OptionKey(41, IPV6_TCLASS));
+            map.put(new RegistryKey(StandardSocketOptions.PREFIX_IP_MULTICAST_IF,
+                StandardProtocolFamily.INET6), new OptionKey(41, IPV6_MULTICAST_IF));
+            map.put(new RegistryKey(StandardSocketOptions.PREFIX_IP_MULTICAST_TTL,
+                StandardProtocolFamily.INET6), new OptionKey(41, IPV6_MULTICAST_HOPS));
+            map.put(new RegistryKey(StandardSocketOptions.PREFIX_IP_MULTICAST_LOOP,
+                StandardProtocolFamily.INET6), new OptionKey(41, IPV6_MULTICAST_LOOP));
+#endif
+
+            map.put(new RegistryKey(ExtendedSocketOption.PREFIX_SO_OOBINLINE,
+                Net.UNSPEC), new OptionKey(SOL_SOCKET, SO_OOBINLINE));
+            return map;
+        }
+    }
+
+    public static OptionKey findOption(SocketOption<?> name, ProtocolFamily family) {
+        RegistryKey key = new RegistryKey(name, family);
+        return LazyInitialization.options.get(key);
+    }
+}
--- a/jdk/src/java.base/share/classes/sun/nio/ch/ThreadPool.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/sun/nio/ch/ThreadPool.java	Mon Mar 28 08:41:54 2016 -0700
@@ -82,7 +82,7 @@
         } else {
             return (Runnable r) -> {
                 PrivilegedAction<Thread> action = () -> {
-                    Thread t = new InnocuousThread(r);
+                    Thread t = InnocuousThread.newThread(r);
                     t.setDaemon(true);
                     return t;
                };
--- a/jdk/src/java.base/share/classes/sun/nio/fs/NativeBuffer.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/sun/nio/fs/NativeBuffer.java	Mon Mar 28 08:41:54 2016 -0700
@@ -25,8 +25,9 @@
 
 package sun.nio.fs;
 
+import java.lang.ref.Cleaner.Cleanable;
 import jdk.internal.misc.Unsafe;
-import jdk.internal.ref.Cleaner;
+import jdk.internal.ref.CleanerFactory;
 
 /**
  * A light-weight buffer in native memory.
@@ -37,7 +38,7 @@
 
     private final long address;
     private final int size;
-    private final Cleaner cleaner;
+    private final Cleanable cleanable;
 
     // optional "owner" to avoid copying
     // (only safe for use by thread-local caches)
@@ -56,7 +57,8 @@
     NativeBuffer(int size) {
         this.address = unsafe.allocateMemory(size);
         this.size = size;
-        this.cleaner = Cleaner.create(this, new Deallocator(address));
+        this.cleanable = CleanerFactory.cleaner()
+                                       .register(this, new Deallocator(address));
     }
 
     void release() {
@@ -72,7 +74,7 @@
     }
 
     void free() {
-        cleaner.clean();
+        cleanable.clean();
     }
 
     // not synchronized; only safe for use by thread-local caches
--- a/jdk/src/java.base/share/classes/sun/security/ssl/RSAClientKeyExchange.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/RSAClientKeyExchange.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -115,10 +115,31 @@
 
         byte[] encoded = null;
         try {
+            boolean needFailover = false;
             Cipher cipher = JsseJce.getCipher(JsseJce.CIPHER_RSA_PKCS1);
-            boolean needFailover = !KeyUtil.isOracleJCEProvider(
-                    cipher.getProvider().getName());
+            try {
+                // Try UNWRAP_MODE mode firstly.
+                cipher.init(Cipher.UNWRAP_MODE, privateKey,
+                        new TlsRsaPremasterSecretParameterSpec(
+                                maxVersion.v, currentVersion.v),
+                        generator);
+
+                // The provider selection can be delayed, please don't call
+                // any Cipher method before the call to Cipher.init().
+                needFailover = !KeyUtil.isOracleJCEProvider(
+                        cipher.getProvider().getName());
+            } catch (InvalidKeyException | UnsupportedOperationException iue) {
+                if (debug != null && Debug.isOn("handshake")) {
+                    System.out.println("The Cipher provider " +
+                        cipher.getProvider().getName() +
+                        " caused exception: " + iue.getMessage());
+                }
+
+                needFailover = true;
+            }
+
             if (needFailover) {
+                // Use DECRYPT_MODE and dispose the previous initialization.
                 cipher.init(Cipher.DECRYPT_MODE, privateKey);
                 boolean failed = false;
                 try {
@@ -134,10 +155,7 @@
                                 maxVersion.v, currentVersion.v,
                                 encoded, generator);
             } else {
-                cipher.init(Cipher.UNWRAP_MODE, privateKey,
-                        new TlsRsaPremasterSecretParameterSpec(
-                                maxVersion.v, currentVersion.v),
-                        generator);
+                // the cipher should have been initialized
                 preMaster = (SecretKey)cipher.unwrap(encrypted,
                         "TlsRsaPremasterSecret", Cipher.SECRET_KEY);
             }
--- a/jdk/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -366,17 +366,6 @@
     private static final Debug debug = Debug.getInstance("ssl");
 
     /*
-     * Is it the first application record to write?
-     */
-    private boolean isFirstAppOutputRecord = true;
-
-    /*
-     * If AppOutputStream needs to delay writes of small packets, we
-     * will use this to store the data until we actually do the write.
-     */
-    private ByteArrayOutputStream heldRecordBuffer = null;
-
-    /*
      * Whether local cipher suites preference in server side should be
      * honored during handshaking?
      */
@@ -998,9 +987,21 @@
             Plaintext plainText = null;
             while (((state = getConnectionState()) != cs_CLOSED) &&
                     (state != cs_ERROR) && (state != cs_APP_CLOSED)) {
-                // clean the buffer
+
+                /*
+                 * clean the buffer and check if it is too small, e.g. because
+                 * the AppInputStream did not have the chance to see the
+                 * current packet length but rather something like that of the
+                 * handshake before. In that case we return 0 at this point to
+                 * give the caller the chance to adjust the buffer.
+                 */
                 if (buffer != null) {
                     buffer.clear();
+
+                    if (buffer.remaining() <
+                            inputRecord.bytesInCompletePacket(sockInput)) {
+                        return 0;
+                    }
                 }
 
                 /*
--- a/jdk/src/java.base/share/native/libzip/zip_util.c	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/share/native/libzip/zip_util.c	Mon Mar 28 08:41:54 2016 -0700
@@ -1408,7 +1408,7 @@
             case Z_OK:
                 break;
             case Z_STREAM_END:
-                if (count != 0 || strm.total_out != entry->size) {
+                if (count != 0 || strm.total_out != (uInt)entry->size) {
                     *msg = "inflateFully: Unexpected end of stream";
                     inflateEnd(&strm);
                     return JNI_FALSE;
@@ -1528,7 +1528,7 @@
             case Z_OK:
                 break;
             case Z_STREAM_END:
-                if (strm.total_out != outLen) {
+                if (strm.total_out != (uInt)outLen) {
                     *pmsg = "INFLATER_inflateFully: Unexpected end of stream";
                     inflateEnd(&strm);
                     return JNI_FALSE;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/solaris/classes/sun/nio/fs/SolarisConstants.java.template	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+@@END_COPYRIGHT@@
+
+#include <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/acl.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+
+/* On Solaris, "sun" is defined as a macro. Undefine to make package
+   declaration valid */
+#undef sun
+
+/* To be able to name the Java constants the same as the C constants without
+   having the preprocessor rewrite those identifiers, add PREFIX_ to all
+   identifiers matching a C constant. The PREFIX_ is filtered out in the
+   makefile. */
+
+@@START_HERE@@
+
+package sun.nio.fs;
+class SolarisConstants {
+
+    private SolarisConstants() { }
+
+    static final int PREFIX_O_XATTR = O_XATTR;
+    static final int PREFIX__PC_XATTR_ENABLED = _PC_XATTR_ENABLED;
+    static final int PREFIX__PC_ACL_ENABLED = _PC_ACL_ENABLED;
+    static final int PREFIX__ACL_ACE_ENABLED = _ACL_ACE_ENABLED;
+    static final int PREFIX_ACE_GETACL = ACE_GETACL;
+    static final int PREFIX_ACE_SETACL = ACE_SETACL;
+    static final int PREFIX_ACE_ACCESS_ALLOWED_ACE_TYPE = ACE_ACCESS_ALLOWED_ACE_TYPE;
+    static final int PREFIX_ACE_ACCESS_DENIED_ACE_TYPE = ACE_ACCESS_DENIED_ACE_TYPE;
+    static final int PREFIX_ACE_SYSTEM_AUDIT_ACE_TYPE = ACE_SYSTEM_AUDIT_ACE_TYPE;
+    static final int PREFIX_ACE_SYSTEM_ALARM_ACE_TYPE = ACE_SYSTEM_ALARM_ACE_TYPE;
+    static final int PREFIX_ACE_READ_DATA = ACE_READ_DATA;
+    static final int PREFIX_ACE_LIST_DIRECTORY = ACE_LIST_DIRECTORY;
+    static final int PREFIX_ACE_WRITE_DATA = ACE_WRITE_DATA;
+    static final int PREFIX_ACE_ADD_FILE = ACE_ADD_FILE;
+    static final int PREFIX_ACE_APPEND_DATA = ACE_APPEND_DATA;
+    static final int PREFIX_ACE_ADD_SUBDIRECTORY = ACE_ADD_SUBDIRECTORY;
+    static final int PREFIX_ACE_READ_NAMED_ATTRS = ACE_READ_NAMED_ATTRS;
+    static final int PREFIX_ACE_WRITE_NAMED_ATTRS = ACE_WRITE_NAMED_ATTRS;
+    static final int PREFIX_ACE_EXECUTE = ACE_EXECUTE;
+    static final int PREFIX_ACE_DELETE_CHILD = ACE_DELETE_CHILD;
+    static final int PREFIX_ACE_READ_ATTRIBUTES = ACE_READ_ATTRIBUTES;
+    static final int PREFIX_ACE_WRITE_ATTRIBUTES = ACE_WRITE_ATTRIBUTES;
+    static final int PREFIX_ACE_DELETE = ACE_DELETE;
+    static final int PREFIX_ACE_READ_ACL = ACE_READ_ACL;
+    static final int PREFIX_ACE_WRITE_ACL = ACE_WRITE_ACL;
+    static final int PREFIX_ACE_WRITE_OWNER = ACE_WRITE_OWNER;
+    static final int PREFIX_ACE_SYNCHRONIZE = ACE_SYNCHRONIZE;
+    static final int PREFIX_ACE_FILE_INHERIT_ACE = ACE_FILE_INHERIT_ACE;
+    static final int PREFIX_ACE_DIRECTORY_INHERIT_ACE = ACE_DIRECTORY_INHERIT_ACE;
+    static final int PREFIX_ACE_NO_PROPAGATE_INHERIT_ACE = ACE_NO_PROPAGATE_INHERIT_ACE;
+    static final int PREFIX_ACE_INHERIT_ONLY_ACE = ACE_INHERIT_ONLY_ACE;
+    static final int PREFIX_ACE_SUCCESSFUL_ACCESS_ACE_FLAG = ACE_SUCCESSFUL_ACCESS_ACE_FLAG;
+    static final int PREFIX_ACE_FAILED_ACCESS_ACE_FLAG = ACE_FAILED_ACCESS_ACE_FLAG;
+    static final int PREFIX_ACE_IDENTIFIER_GROUP = ACE_IDENTIFIER_GROUP;
+    static final int PREFIX_ACE_OWNER = ACE_OWNER;
+    static final int PREFIX_ACE_GROUP = ACE_GROUP;
+    static final int PREFIX_ACE_EVERYONE = ACE_EVERYONE;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/unix/classes/jdk/internal/loader/FileURLMapper.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.internal.loader;
+
+import java.net.URL;
+import java.io.File;
+import sun.net.www.ParseUtil;
+
+/**
+ * (Solaris) platform specific handling for file: URLs .
+ * urls must not contain a hostname in the authority field
+ * other than "localhost".
+ *
+ * This implementation could be updated to map such URLs
+ * on to /net/host/...
+ *
+ * @author      Michael McMahon
+ */
+
+public class FileURLMapper {
+
+    URL url;
+    String path;
+
+    public FileURLMapper (URL url) {
+        this.url = url;
+    }
+
+    /**
+     * @return the platform specific path corresponding to the URL
+     *  so long as the URL does not contain a hostname in the authority field.
+     */
+
+    public String getPath () {
+        if (path != null) {
+            return path;
+        }
+        String host = url.getHost();
+        if (host == null || "".equals(host) || "localhost".equalsIgnoreCase (host)) {
+            path = url.getFile();
+            path = ParseUtil.decode (path);
+        }
+        return path;
+    }
+
+    /**
+     * Checks whether the file identified by the URL exists.
+     */
+    public boolean exists () {
+        String s = getPath ();
+        if (s == null) {
+            return false;
+        } else {
+            File f = new File (s);
+            return f.exists();
+        }
+    }
+}
--- a/jdk/src/java.base/unix/classes/sun/misc/FileURLMapper.java	Thu Mar 24 02:04:14 2016 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.misc;
-
-import java.net.URL;
-import java.io.File;
-import sun.net.www.ParseUtil;
-
-/**
- * (Solaris) platform specific handling for file: URLs .
- * urls must not contain a hostname in the authority field
- * other than "localhost".
- *
- * This implementation could be updated to map such URLs
- * on to /net/host/...
- *
- * @author      Michael McMahon
- */
-
-public class FileURLMapper {
-
-    URL url;
-    String path;
-
-    public FileURLMapper (URL url) {
-        this.url = url;
-    }
-
-    /**
-     * @return the platform specific path corresponding to the URL
-     *  so long as the URL does not contain a hostname in the authority field.
-     */
-
-    public String getPath () {
-        if (path != null) {
-            return path;
-        }
-        String host = url.getHost();
-        if (host == null || "".equals(host) || "localhost".equalsIgnoreCase (host)) {
-            path = url.getFile();
-            path = ParseUtil.decode (path);
-        }
-        return path;
-    }
-
-    /**
-     * Checks whether the file identified by the URL exists.
-     */
-    public boolean exists () {
-        String s = getPath ();
-        if (s == null) {
-            return false;
-        } else {
-            File f = new File (s);
-            return f.exists();
-        }
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/unix/classes/sun/nio/fs/UnixConstants.java.template	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+@@END_COPYRIGHT@@
+
+#include <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+
+/* On Solaris, "sun" is defined as a macro. Undefine to make package
+   declaration valid */
+#undef sun
+
+/* To be able to name the Java constants the same as the C constants without
+   having the preprocessor rewrite those identifiers, add PREFIX_ to all
+   identifiers matching a C constant. The PREFIX_ is filtered out in the
+   makefile. */
+
+@@START_HERE@@
+
+package sun.nio.fs;
+class UnixConstants {
+    private UnixConstants() { }
+    static final int PREFIX_O_RDONLY = O_RDONLY;
+    static final int PREFIX_O_WRONLY = O_WRONLY;
+    static final int PREFIX_O_RDWR = O_RDWR;
+    static final int PREFIX_O_APPEND = O_APPEND;
+    static final int PREFIX_O_CREAT = O_CREAT;
+    static final int PREFIX_O_EXCL = O_EXCL;
+    static final int PREFIX_O_TRUNC = O_TRUNC;
+    static final int PREFIX_O_SYNC = O_SYNC;
+
+#ifndef O_DSYNC
+    // At least FreeBSD doesn't define O_DSYNC
+    static final int PREFIX_O_DSYNC = O_SYNC;
+#else
+    static final int PREFIX_O_DSYNC = O_DSYNC;
+#endif
+
+#ifdef O_NOFOLLOW
+    static final int PREFIX_O_NOFOLLOW = O_NOFOLLOW;
+#else
+    // not supported (dummy values will not be used at runtime).
+    static final int PREFIX_O_NOFOLLOW = 00;
+#endif
+
+
+    static final int PREFIX_S_IAMB =
+        (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH);
+    static final int PREFIX_S_IRUSR = S_IRUSR;
+    static final int PREFIX_S_IWUSR = S_IWUSR;
+    static final int PREFIX_S_IXUSR = S_IXUSR;
+    static final int PREFIX_S_IRGRP = S_IRGRP;
+    static final int PREFIX_S_IWGRP = S_IWGRP;
+    static final int PREFIX_S_IXGRP = S_IXGRP;
+    static final int PREFIX_S_IROTH = S_IROTH;
+    static final int PREFIX_S_IWOTH = S_IWOTH;
+    static final int PREFIX_S_IXOTH = S_IXOTH;
+
+    static final int PREFIX_S_IFMT = S_IFMT;
+    static final int PREFIX_S_IFREG = S_IFREG;
+    static final int PREFIX_S_IFDIR = S_IFDIR;
+    static final int PREFIX_S_IFLNK = S_IFLNK;
+    static final int PREFIX_S_IFCHR = S_IFCHR;
+    static final int PREFIX_S_IFBLK = S_IFBLK;
+    static final int PREFIX_S_IFIFO = S_IFIFO;
+    static final int PREFIX_R_OK = R_OK;
+    static final int PREFIX_W_OK = W_OK;
+    static final int PREFIX_X_OK = X_OK;
+    static final int PREFIX_F_OK = F_OK;
+    static final int PREFIX_ENOENT = ENOENT;
+    static final int PREFIX_ENXIO = ENXIO;
+    static final int PREFIX_EACCES = EACCES;
+    static final int PREFIX_EEXIST = EEXIST;
+    static final int PREFIX_ENOTDIR = ENOTDIR;
+    static final int PREFIX_EINVAL = EINVAL;
+    static final int PREFIX_EXDEV = EXDEV;
+    static final int PREFIX_EISDIR = EISDIR;
+    static final int PREFIX_ENOTEMPTY = ENOTEMPTY;
+    static final int PREFIX_ENOSPC = ENOSPC;
+    static final int PREFIX_EAGAIN = EAGAIN;
+    static final int PREFIX_ENOSYS = ENOSYS;
+    static final int PREFIX_ELOOP = ELOOP;
+    static final int PREFIX_EROFS = EROFS;
+
+#ifndef ENODATA
+    // Only used in Linux java source, provide any value so it compiles
+    static final int PREFIX_ENODATA = ELAST;
+#else
+    static final int PREFIX_ENODATA = ENODATA;
+#endif
+
+    static final int PREFIX_ERANGE = ERANGE;
+    static final int PREFIX_EMFILE = EMFILE;
+
+    // flags used with openat/unlinkat/etc.
+#if defined(AT_SYMLINK_NOFOLLOW) && defined(AT_REMOVEDIR)
+    static final int PREFIX_AT_SYMLINK_NOFOLLOW = AT_SYMLINK_NOFOLLOW;
+    static final int PREFIX_AT_REMOVEDIR = AT_REMOVEDIR;
+#else
+    // not supported (dummy values will not be used at runtime).
+    static final int PREFIX_AT_SYMLINK_NOFOLLOW = 00;
+    static final int PREFIX_AT_REMOVEDIR = 00;
+#endif
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/windows/classes/jdk/internal/loader/FileURLMapper.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.internal.loader;
+
+import java.net.URL;
+import java.io.File;
+import sun.net.www.ParseUtil;
+
+/**
+ * (Windows) Platform specific handling for file: URLs . In particular deals
+ * with network paths mapping them to UNCs.
+ *
+ * @author      Michael McMahon
+ */
+
+public class FileURLMapper {
+
+    URL url;
+    String file;
+
+    public FileURLMapper (URL url) {
+        this.url = url;
+    }
+
+    /**
+     * @return the platform specific path corresponding to the URL, and in particular
+     *  returns a UNC when the authority contains a hostname
+     */
+
+    public String getPath () {
+        if (file != null) {
+            return file;
+        }
+        String host = url.getHost();
+        if (host != null && !host.equals("") &&
+            !"localhost".equalsIgnoreCase(host)) {
+            String rest = url.getFile();
+            String s = host + ParseUtil.decode (url.getFile());
+            file = "\\\\"+ s.replace('/', '\\');
+            return file;
+        }
+        String path = url.getFile().replace('/', '\\');
+        file = ParseUtil.decode(path);
+        return file;
+    }
+
+    public boolean exists() {
+        String path = getPath();
+        File f = new File (path);
+        return f.exists();
+    }
+}
--- a/jdk/src/java.base/windows/classes/sun/misc/FileURLMapper.java	Thu Mar 24 02:04:14 2016 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.misc;
-
-import java.net.URL;
-import java.io.File;
-import sun.net.www.ParseUtil;
-
-/**
- * (Windows) Platform specific handling for file: URLs . In particular deals
- * with network paths mapping them to UNCs.
- *
- * @author      Michael McMahon
- */
-
-public class FileURLMapper {
-
-    URL url;
-    String file;
-
-    public FileURLMapper (URL url) {
-        this.url = url;
-    }
-
-    /**
-     * @return the platform specific path corresponding to the URL, and in particular
-     *  returns a UNC when the authority contains a hostname
-     */
-
-    public String getPath () {
-        if (file != null) {
-            return file;
-        }
-        String host = url.getHost();
-        if (host != null && !host.equals("") &&
-            !"localhost".equalsIgnoreCase(host)) {
-            String rest = url.getFile();
-            String s = host + ParseUtil.decode (url.getFile());
-            file = "\\\\"+ s.replace('/', '\\');
-            return file;
-        }
-        String path = url.getFile().replace('/', '\\');
-        file = ParseUtil.decode(path);
-        return file;
-    }
-
-    public boolean exists() {
-        String path = getPath();
-        File f = new File (path);
-        return f.exists();
-    }
-}
--- a/jdk/src/java.base/windows/native/libnio/fs/WindowsNativeDispatcher.c	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.base/windows/native/libnio/fs/WindowsNativeDispatcher.c	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
  * 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,10 +23,6 @@
  * questions.
  */
 
-#ifndef _WIN32_WINNT
-#define _WIN32_WINNT 0x0501
-#endif
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <ctype.h>
@@ -77,21 +73,6 @@
 static jfieldID backupResult_context;
 
 
-/**
- * Win32 APIs not available in Windows XP
- */
-typedef HANDLE (WINAPI* FindFirstStream_Proc)(LPCWSTR, STREAM_INFO_LEVELS, LPVOID, DWORD);
-typedef BOOL (WINAPI* FindNextStream_Proc)(HANDLE, LPVOID);
-
-typedef BOOLEAN (WINAPI* CreateSymbolicLinkProc) (LPCWSTR, LPCWSTR, DWORD);
-typedef BOOL (WINAPI* GetFinalPathNameByHandleProc) (HANDLE, LPWSTR, DWORD, DWORD);
-
-static FindFirstStream_Proc FindFirstStream_func;
-static FindNextStream_Proc FindNextStream_func;
-
-static CreateSymbolicLinkProc CreateSymbolicLink_func;
-static GetFinalPathNameByHandleProc GetFinalPathNameByHandle_func;
-
 static void throwWindowsException(JNIEnv* env, DWORD lastError) {
     jobject x = JNU_NewObjectByName(env, "sun/nio/fs/WindowsException",
         "(I)V", lastError);
@@ -108,7 +89,6 @@
 Java_sun_nio_fs_WindowsNativeDispatcher_initIDs(JNIEnv* env, jclass this)
 {
     jclass clazz;
-    HMODULE h;
 
     clazz = (*env)->FindClass(env, "sun/nio/fs/WindowsNativeDispatcher$FirstFile");
     CHECK_NULL(clazz);
@@ -175,24 +155,6 @@
     CHECK_NULL(backupResult_bytesTransferred);
     backupResult_context = (*env)->GetFieldID(env, clazz, "context", "J");
     CHECK_NULL(backupResult_context);
-
-    // get handle to kernel32
-    if (GetModuleHandleExW((GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
-                            GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT),
-                           (LPCWSTR)&CreateFileW, &h) != 0)
-    {
-        // requires Windows Server 2003 or newer
-        FindFirstStream_func =
-            (FindFirstStream_Proc)GetProcAddress(h, "FindFirstStreamW");
-        FindNextStream_func =
-            (FindNextStream_Proc)GetProcAddress(h, "FindNextStreamW");
-
-        // requires Windows Vista or newer
-        CreateSymbolicLink_func =
-            (CreateSymbolicLinkProc)GetProcAddress(h, "CreateSymbolicLinkW");
-        GetFinalPathNameByHandle_func =
-            (GetFinalPathNameByHandleProc)GetProcAddress(h, "GetFinalPathNameByHandleW");
-    }
 }
 
 JNIEXPORT jlong JNICALL
@@ -404,12 +366,7 @@
     LPCWSTR lpFileName = jlong_to_ptr(address);
     HANDLE handle;
 
-    if (FindFirstStream_func == NULL) {
-        JNU_ThrowInternalError(env, "Should not get here");
-        return;
-    }
-
-    handle = (*FindFirstStream_func)(lpFileName, FindStreamInfoStandard, &data, 0);
+    handle = FindFirstStreamW(lpFileName, FindStreamInfoStandard, &data, 0);
     if (handle != INVALID_HANDLE_VALUE) {
         jstring name = (*env)->NewString(env, data.cStreamName, (jsize)wcslen(data.cStreamName));
         if (name == NULL)
@@ -433,12 +390,7 @@
     WIN32_FIND_STREAM_DATA data;
     HANDLE h = (HANDLE)jlong_to_ptr(handle);
 
-    if (FindNextStream_func == NULL) {
-        JNU_ThrowInternalError(env, "Should not get here");
-        return NULL;
-    }
-
-    if ((*FindNextStream_func)(h, &data) != 0) {
+    if (FindNextStreamW(h, &data) != 0) {
         return (*env)->NewString(env, data.cStreamName, (jsize)wcslen(data.cStreamName));
     } else {
         if (GetLastError() != ERROR_HANDLE_EOF)
@@ -1087,13 +1039,8 @@
     LPCWSTR link = jlong_to_ptr(linkAddress);
     LPCWSTR target = jlong_to_ptr(targetAddress);
 
-    if (CreateSymbolicLink_func == NULL) {
-        JNU_ThrowInternalError(env, "Should not get here");
-        return;
-    }
-
     /* On Windows 64-bit this appears to succeed even when there is insufficient privileges */
-    if ((*CreateSymbolicLink_func)(link, target, (DWORD)flags) == 0)
+    if (CreateSymbolicLinkW(link, target, (DWORD)flags) == 0)
         throwWindowsException(env, GetLastError());
 }
 
@@ -1155,12 +1102,7 @@
     HANDLE h = (HANDLE)jlong_to_ptr(handle);
     DWORD len;
 
-    if (GetFinalPathNameByHandle_func == NULL) {
-        JNU_ThrowInternalError(env, "Should not get here");
-        return NULL;
-    }
-
-    len = (*GetFinalPathNameByHandle_func)(h, path, MAX_PATH, 0);
+    len = GetFinalPathNameByHandleW(h, path, MAX_PATH, 0);
     if (len > 0) {
         if (len < MAX_PATH) {
             rv = (*env)->NewString(env, (const jchar *)path, (jsize)len);
@@ -1168,7 +1110,7 @@
             len += 1;  /* return length does not include terminator */
             lpBuf = (WCHAR*)malloc(len * sizeof(WCHAR));
             if (lpBuf != NULL) {
-                len = (*GetFinalPathNameByHandle_func)(h, lpBuf, len, 0);
+                len = GetFinalPathNameByHandleW(h, lpBuf, len, 0);
                 if (len > 0)  {
                     rv = (*env)->NewString(env, (const jchar *)lpBuf, (jsize)len);
                 } else {
--- a/jdk/src/java.httpclient/share/classes/java/net/http/Log.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/Log.java	Mon Mar 28 08:41:54 2016 -0700
@@ -24,7 +24,6 @@
 package java.net.http;
 
 import java.util.Locale;
-import sun.util.logging.PlatformLogger;
 
 /**
  * -Djava.net.HttpClient.log=errors,requests,headers,frames[:type:type2:..],content
@@ -35,9 +34,11 @@
  *
  * Logger name is "java.net.http.HttpClient"
  */
-class Log {
+// implements System.Logger in order to be skipped when printing the caller's
+// information
+abstract class Log implements System.Logger {
 
-    final static String logProp = "java.net.http.HttpClient.log";
+    static final String logProp = "java.net.http.HttpClient.log";
 
     public static final int OFF = 0;
     public static final int ERRORS = 0x1;
@@ -55,7 +56,7 @@
     public static final int ALL = CONTROL| DATA | WINDOW_UPDATES;
     static int frametypes;
 
-    static sun.util.logging.PlatformLogger logger;
+    static final System.Logger logger;
 
     static {
         String s = Utils.getNetProperty(logProp);
@@ -111,7 +112,9 @@
             }
         }
         if (logging != OFF) {
-            logger = PlatformLogger.getLogger("java.net.http.HttpClient");
+            logger = System.getLogger("java.net.http.HttpClient");
+        } else {
+            logger = null;
         }
     }
 
@@ -137,34 +140,38 @@
 
     static void logError(String s) {
         if (errors())
-            logger.info("ERROR: " + s);
+            logger.log(Level.INFO, "ERROR: " + s);
     }
 
     static void logError(Throwable t) {
         if (errors()) {
             String s = Utils.stackTrace(t);
-            logger.info("ERROR: " + s);
+            logger.log(Level.INFO, "ERROR: " + s);
         }
     }
 
     static void logSSL(String s) {
         if (ssl())
-            logger.info("SSL: " + s);
+            logger.log(Level.INFO, "SSL: " + s);
     }
 
     static void logRequest(String s) {
         if (requests())
-            logger.info("REQUEST: " + s);
+            logger.log(Level.INFO, "REQUEST: " + s);
     }
 
     static void logResponse(String s) {
         if (requests())
-            logger.info("RESPONSE: " + s);
+            logger.log(Level.INFO, "RESPONSE: " + s);
     }
 
     static void logHeaders(String s) {
         if (headers())
-            logger.info("HEADERS: " + s);
+            logger.log(Level.INFO, "HEADERS: " + s);
     }
+
+    // not instantiable
+    private Log() {}
+
 // END HTTP2
 }
--- a/jdk/src/java.logging/share/classes/java/util/logging/LogRecord.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.logging/share/classes/java/util/logging/LogRecord.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,8 +33,7 @@
 import java.security.PrivilegedAction;
 import java.time.Clock;
 import java.util.function.Predicate;
-
-import static jdk.internal.logger.SimpleConsoleLogger.isFilteredFrame;
+import static jdk.internal.logger.SurrogateLogger.isFilteredFrame;
 
 /**
  * LogRecord objects are used to pass logging requests between
--- a/jdk/src/java.logging/share/classes/java/util/logging/SimpleFormatter.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.logging/share/classes/java/util/logging/SimpleFormatter.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,7 @@
 import java.io.*;
 import java.time.ZoneId;
 import java.time.ZonedDateTime;
-import jdk.internal.logger.SimpleConsoleLogger;
+import jdk.internal.logger.SurrogateLogger;
 
 /**
  * Print a brief summary of the {@code LogRecord} in a human readable
@@ -64,7 +64,7 @@
     }
 
     private final String format =
-        SimpleConsoleLogger.getSimpleFormat(SimpleFormatter::getLoggingProperty);
+        SurrogateLogger.getSimpleFormat(SimpleFormatter::getLoggingProperty);
 
     /**
      * Format the given LogRecord.
--- a/jdk/src/java.rmi/share/classes/sun/rmi/registry/RegistryImpl.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/java.rmi/share/classes/sun/rmi/registry/RegistryImpl.java	Mon Mar 28 08:41:54 2016 -0700
@@ -25,10 +25,15 @@
 
 package sun.rmi.registry;
 
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.Hashtable;
+import java.util.List;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
+import java.io.File;
 import java.io.FilePermission;
 import java.io.IOException;
 import java.net.*;
@@ -333,6 +338,30 @@
     }
 
     /**
+     * Convert class path specification into an array of file URLs.
+     *
+     * The path of the file is converted to a URI then into URL
+     * form so that reserved characters can safely appear in the path.
+     */
+    private static URL[] pathToURLs(String path) {
+        List<URL> paths = new ArrayList<>();
+        for (String entry: path.split(File.pathSeparator)) {
+            Path p = Paths.get(entry);
+            try {
+                p = p.toRealPath();
+            } catch (IOException x) {
+                p = p.toAbsolutePath();
+            }
+            try {
+                paths.add(p.toUri().toURL());
+            } catch (MalformedURLException e) {
+                //ignore / skip entry
+            }
+        }
+        return paths.toArray(new URL[0]);
+    }
+
+    /**
      * Main program to start a registry. <br>
      * The port number can be specified on the command line.
      */
@@ -362,7 +391,7 @@
             if (envcp == null) {
                 envcp = ".";            // preserve old default behavior
             }
-            URL[] urls = sun.misc.URLClassPath.pathToURLs(envcp);
+            URL[] urls = pathToURLs(envcp);
             ClassLoader cl = new URLClassLoader(urls);
 
             /*
--- a/jdk/src/jdk.deploy.osx/macosx/classes/module-info.java	Thu Mar 24 02:04:14 2016 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-module jdk.deploy.osx {
-    requires java.desktop;
-    requires java.scripting;
-}
-
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java	Mon Mar 28 08:41:54 2016 -0700
@@ -155,9 +155,13 @@
 
     @Override
     public void configure(Map<String, String> config) {
-        priorityList = Arrays.stream(config.get(NAME).split(","))
-            .map(Locale.LanguageRange::new)
-            .collect(Collectors.toList());
+        try {
+            priorityList = Arrays.stream(config.get(NAME).split(","))
+                .map(Locale.LanguageRange::new)
+                .collect(Collectors.toList());
+        } catch (IllegalArgumentException iae) {
+            throw new PluginException(iae.getLocalizedMessage());
+        }
     }
 
     @Override
@@ -168,7 +172,7 @@
         // jdk.localedata module validation
         Set<String> packages = module.getAllPackages();
         if (!packages.containsAll(LOCALEDATA_PACKAGES)) {
-            throw new PluginException("Missing locale data packages in jdk.localedata:\n\t" +
+            throw new PluginException(PluginsResourceBundle.getMessage(NAME + ".missingpackages") +
                 LOCALEDATA_PACKAGES.stream()
                     .filter(pn -> !packages.contains(pn))
                     .collect(Collectors.joining(",\n\t")));
@@ -186,6 +190,10 @@
 
         filtered = filterLocales(available);
 
+        if (filtered.isEmpty()) {
+            throw new PluginException(PluginsResourceBundle.getMessage(NAME + ".nomatchinglocales"));
+        }
+
         try {
             String value = META_FILES + filtered.stream()
                 .map(s -> includeLocaleFilePatterns(s))
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties	Mon Mar 28 08:41:54 2016 -0700
@@ -68,9 +68,18 @@
 
 zip.description=ZIP Compression
 
-include-locales.argument=<langtag>[,<langtag>]*
+include-locales.argument=\
+<langtag>[,<langtag>]*
 
-include-locales.description=BCP 47 language tags separated by a comma, allowing locale matching\ndefined in RFC 4647. eg: en,ja,*-IN
+include-locales.description=\
+BCP 47 language tags separated by a comma, allowing locale matching\n\
+defined in RFC 4647. eg: en,ja,*-IN
+
+include-locales.missingpackages=\
+Missing locale data packages in jdk.localedata:\n\t
+
+include-locales.nomatchinglocales=\
+No matching locales found. Check the specified pattern.
 
 main.status.ok=Functional.
 
--- a/jdk/src/jdk.rmic/share/classes/sun/tools/java/RuntimeConstants.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/src/jdk.rmic/share/classes/sun/tools/java/RuntimeConstants.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -67,7 +67,7 @@
     /* Class File Constants */
     int JAVA_MAGIC                   = 0xcafebabe;
     int JAVA_MIN_SUPPORTED_VERSION   = 45;
-    int JAVA_MAX_SUPPORTED_VERSION   = 52;
+    int JAVA_MAX_SUPPORTED_VERSION   = 53;
     int JAVA_MAX_SUPPORTED_MINOR_VERSION = 0;
 
     /* Generate class file version for 1.1  by default */
--- a/jdk/test/ProblemList.txt	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/test/ProblemList.txt	Mon Mar 28 08:41:54 2016 -0700
@@ -198,6 +198,7 @@
 
 # 7158947, Solaris 11
 java/nio/file/WatchService/Basic.java				solaris-all
+java/nio/file/WatchService/MayFlies.java			solaris-all
 java/nio/file/WatchService/LotsOfEvents.java			solaris-all
 
 # 8149712
@@ -354,6 +355,9 @@
 # 8059906 fails on solaris and macosx, 8151901 
 tools/pack200/Pack200Test.java                                  generic-all
 
+# 8152622
+tools/pack200/Pack200Props.java                                 macosx-all
+
 # 8068049 
 tools/launcher/FXLauncherTest.java                              linux-all,macosx-all
 
--- a/jdk/test/TEST.groups	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/test/TEST.groups	Mon Mar 28 08:41:54 2016 -0700
@@ -32,6 +32,7 @@
     -java/util/WeakHashMap/GCDuringIteration.java \
     -java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java \
     -java/util/concurrent/forkjoin/FJExceptionTableLeak.java \
+    -java/util/TimeZone/Bug6772689.java \
     sun/nio/cs/ISO8859x.java \
     java/nio/Buffer \
     com/sun/crypto/provider/Cipher \
@@ -42,6 +43,7 @@
     java/util/WeakHashMap/GCDuringIteration.java \
     java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java \
     java/util/concurrent/forkjoin/FJExceptionTableLeak.java \
+    java/util/TimeZone/Bug6772689.java \
     :jdk_io \
     :jdk_nio \
     -sun/nio/cs/ISO8859x.java \
@@ -492,7 +494,8 @@
   sun/reflect/CallerSensitive/MissingCallerSensitive.java \
   sun/security/util/Resources/NewNamesFormat.java \
   vm/verifier/defaultMethods/DefaultMethodRegressionTestsRun.java \
-  javax/xml/ws/clientjar/TestWsImport.java
+  javax/xml/ws/clientjar/TestWsImport.java \
+  javax/xml/bind/xjc/8145039/JaxbMarshallTest.java
 
 # JRE adds further tests to compact3
 #
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/jdi/BadAgentPath.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import jdk.testlibrary.OutputAnalyzer;
+import jdk.testlibrary.ProcessTools;
+import jdk.testlibrary.Utils;
+
+/* @test
+ * @bug 8147456
+ * @summary Check that providing a non-existing -agentpath gives a proper error.
+ * @author Sharath Ballal
+ *
+ * @library /lib/testlibrary
+ * @modules java.management
+ * @build jdk.testlibrary.*
+ * @build BadAgentPath
+ * @run driver BadAgentPath
+ */
+
+public class BadAgentPath {
+
+    public static void main(String[] args) throws Throwable {
+        OutputAnalyzer output = ProcessTools.executeTestJvm("-agentpath:/badAgent/agent", "-version");
+        output.shouldContain("Could not find agent library /badAgent/agent");
+    }
+}
--- a/jdk/test/java/lang/System/LoggerFinder/internal/LoggerFinderLoaderTest/LoggerFinderLoaderTest.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/test/java/lang/System/LoggerFinder/internal/LoggerFinderLoaderTest/LoggerFinderLoaderTest.java	Mon Mar 28 08:41:54 2016 -0700
@@ -181,7 +181,7 @@
         }
 
         System.Logger createSimpleLogger(String name) {
-            PrivilegedAction<System.Logger> pa = () -> SimpleConsoleLogger.makeSimpleLogger(name, false);
+            PrivilegedAction<System.Logger> pa = () -> SimpleConsoleLogger.makeSimpleLogger(name);
             return AccessController.doPrivileged(pa);
         }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/System/LoggerFinder/internal/SimpleConsoleLoggerTest/SimpleConsoleLoggerTest.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,561 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.UncheckedIOException;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.ResourceBundle;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.function.Supplier;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import jdk.internal.logger.SimpleConsoleLogger;
+import jdk.internal.logger.SurrogateLogger;
+import sun.util.logging.PlatformLogger;
+
+/**
+ * @test
+ * @bug     8140364
+ * @summary JDK implementation specific unit test for SimpleConsoleLogger.
+ *          Tests the behavior of SimpleConsoleLogger.
+ * @modules java.base/sun.util.logging
+ *          java.base/jdk.internal.logger
+ * @build SimpleConsoleLoggerTest
+ * @run  main/othervm SimpleConsoleLoggerTest
+ * @run  main/othervm -Djdk.system.logger.level=OFF SimpleConsoleLoggerTest
+ * @run  main/othervm -Djdk.system.logger.level=ERROR SimpleConsoleLoggerTest
+ * @run  main/othervm -Djdk.system.logger.level=WARNING SimpleConsoleLoggerTest
+ * @run  main/othervm -Djdk.system.logger.level=INFO SimpleConsoleLoggerTest
+ * @run  main/othervm -Djdk.system.logger.level=DEBUG SimpleConsoleLoggerTest
+ * @run  main/othervm -Djdk.system.logger.level=TRACE SimpleConsoleLoggerTest
+ * @run  main/othervm -Djdk.system.logger.level=ALL SimpleConsoleLoggerTest
+ * @run  main/othervm -Djdk.system.logger.level=WOMBAT SimpleConsoleLoggerTest
+ * @run  main/othervm -Djdk.system.logger.level SimpleConsoleLoggerTest
+ * @run  main/othervm -Djdk.system.logger.level=FINEST SimpleConsoleLoggerTest
+ * @run  main/othervm -Djdk.system.logger.level=DEBUG -Djava.util.logging.SimpleFormatter.format=++++_%2$s%n%4$s:_%5$s%6$s%n SimpleConsoleLoggerTest
+ * @run  main/othervm -Djdk.system.logger.level=DEBUG -Djdk.system.logger.format=++++_%2$s%n%4$s:_%5$s%6$s%n SimpleConsoleLoggerTest
+ *
+ * @author danielfuchs
+ */
+public class SimpleConsoleLoggerTest {
+
+    static final RuntimePermission LOGGERFINDER_PERMISSION =
+                new RuntimePermission("loggerFinder");
+    final static boolean VERBOSE = false;
+
+    public static class MyBundle extends ResourceBundle {
+
+        final ConcurrentHashMap<String,String> map = new ConcurrentHashMap<>();
+
+        @Override
+        protected Object handleGetObject(String key) {
+            if (key.contains(" (translated)")) {
+                throw new RuntimeException("Unexpected key: " + key);
+            }
+            return map.computeIfAbsent(key, k -> k.toUpperCase(Locale.ROOT) + " (translated)");
+        }
+
+        @Override
+        public Enumeration<String> getKeys() {
+            return Collections.enumeration(map.keySet());
+        }
+
+    }
+    public static class MyLoggerBundle extends MyBundle {
+
+    }
+
+
+    static class ErrorStream extends PrintStream {
+
+        static AtomicBoolean forward = new AtomicBoolean();
+        ByteArrayOutputStream out;
+        String saved = "";
+        public ErrorStream(ByteArrayOutputStream out) {
+            super(out);
+            this.out = out;
+        }
+
+        @Override
+        public void write(int b) {
+            super.write(b);
+            if (forward.get()) err.write(b);
+        }
+
+        @Override
+        public void write(byte[] b) throws IOException {
+            super.write(b);
+            if (forward.get()) err.write(b);
+        }
+
+        @Override
+        public void write(byte[] buf, int off, int len) {
+            super.write(buf, off, len);
+            if (forward.get()) err.write(buf, off, len);
+        }
+
+        public String peek() {
+            flush();
+            return out.toString();
+        }
+
+        public String drain() {
+            flush();
+            String res = out.toString();
+            out.reset();
+            return res;
+        }
+
+        public void store() {
+            flush();
+            saved = out.toString();
+            out.reset();
+        }
+
+        public void restore() {
+            out.reset();
+            try {
+                out.write(saved.getBytes());
+            } catch(IOException io) {
+                throw new UncheckedIOException(io);
+            }
+        }
+
+        static final PrintStream err = System.err;
+        static final ErrorStream errorStream = new ErrorStream(new ByteArrayOutputStream());
+    }
+
+    private static StringBuilder appendProperty(StringBuilder b, String name) {
+        String value = System.getProperty(name);
+        if (value == null) return b;
+        return b.append(name).append("=").append(value).append('\n');
+    }
+
+    public static void main(String[] args) {
+        Locale.setDefault(Locale.ENGLISH);
+        System.setErr(ErrorStream.errorStream);
+        try {
+            test(args);
+        } finally {
+            try {
+                System.setErr(ErrorStream.err);
+            } catch (Error | RuntimeException x) {
+                x.printStackTrace(ErrorStream.err);
+            }
+        }
+    }
+
+
+    public static void test(String[] args) {
+
+        ErrorStream.errorStream.restore();
+        String l = System.getProperty("jdk.system.logger.level");
+        String f = System.getProperty("jdk.system.logger.format");
+        String jf = System.getProperty("java.util.logging.SimpleFormatter.format");
+        System.out.println("Running test: "
+            + "\n\tjdk.system.logger.level=\"" + l + "\""
+            + "\n\tjdk.system.logger.format=\"" + f + "\""
+            + "\n\tjava.util.logging.SimpleFormatter.format=\"" + jf + "\"");
+
+        test(l,f,jf);
+        System.out.println("\nPASSED: tested " + SEQUENCER.get() + " test cases");
+    }
+
+    static final AtomicLong SEQUENCER = new AtomicLong();
+    public static void test(String defaultLevel, String defaultFormat, String julFormat) {
+
+        final Map<Logger, String> loggerDescMap = new HashMap<>();
+
+        SimpleConsoleLogger simple = SimpleConsoleLogger.makeSimpleLogger("test.logger");
+        loggerDescMap.put(simple, "SimpleConsoleLogger.makeSimpleLogger(\"test.logger\")");
+        SimpleConsoleLogger temporary = SurrogateLogger.makeSurrogateLogger("test.logger");
+        loggerDescMap.put(temporary, "SurrogateLogger.makeSimpleLogger(\"test.logger\")");
+
+        Level level;
+        try {
+            level = defaultLevel == null ? null : Level.valueOf(defaultLevel);
+        } catch (IllegalArgumentException ex) {
+            level = null;
+        }
+        testLogger(loggerDescMap, simple, level, false, defaultFormat);
+        testLogger(loggerDescMap, temporary, null, true, julFormat);
+    }
+
+    public static class Foo {
+
+    }
+
+    static void verbose(String msg) {
+       if (VERBOSE) {
+           System.out.println(msg);
+       }
+    }
+
+    static String getName(Level level, boolean usePlatformLevel) {
+        if (usePlatformLevel) {
+            return PlatformLogger.toPlatformLevel(level).name();
+        } else {
+            return level.getName();
+        }
+    }
+
+    // Calls the 8 methods defined on Logger and verify the
+    // parameters received by the underlying TestProvider.LoggerImpl
+    // logger.
+    private static void testLogger(Map<Logger, String> loggerDescMap,
+            SimpleConsoleLogger simple,
+            Level defaultLevel,
+            boolean usePlatformLevel,
+            String defaultFormat) {
+
+        System.out.println("Testing " + loggerDescMap.get(simple) + " [" + simple +"]");
+
+        String formatStrMarker = defaultFormat == null ? ""
+                : defaultFormat.startsWith("++++") ? "++++" : "";
+        String unexpectedMarker = defaultFormat == null ? "++++"
+                : defaultFormat.startsWith("++++") ? "????" : "++++";
+        String formatStrSpec = defaultFormat == null ? "[date]"
+                : defaultFormat.startsWith("++++") ? "++++" : "????";
+        String sep = defaultFormat == null ? ": " : ":_";
+        String sepw = defaultFormat == null ? " " : "_";
+
+        Foo foo = new Foo();
+        String fooMsg = foo.toString();
+        for (Level loggerLevel : defaultLevel == null
+                ? EnumSet.of(Level.INFO) : EnumSet.of(defaultLevel)) {
+            for (Level messageLevel : Level.values()) {
+                ErrorStream.errorStream.drain();
+                String desc = "logger.log(messageLevel, foo): loggerLevel="
+                        + loggerLevel+", messageLevel="+messageLevel;
+                SEQUENCER.incrementAndGet();
+                simple.log(messageLevel, foo);
+                if (loggerLevel == Level.OFF || messageLevel == Level.OFF
+                    || messageLevel.compareTo(loggerLevel) < 0) {
+                    if (!ErrorStream.errorStream.peek().isEmpty()) {
+                        throw new RuntimeException("unexpected event in queue for "
+                                + desc +": " + "\n\t" + ErrorStream.errorStream.drain());
+                    }
+                } else {
+                    String logged = ErrorStream.errorStream.drain();
+                    String expected = getName(messageLevel, usePlatformLevel) + sep + fooMsg;
+                    if (!logged.contains("SimpleConsoleLoggerTest testLogger")
+                        || !logged.contains(formatStrMarker)
+                        || logged.contains(unexpectedMarker)
+                        || !logged.contains(expected)) {
+                        throw new RuntimeException("mismatch for " + desc
+                                + "\n\texpected:" + "\n<<<<\n"
+                                + formatStrSpec + sepw + "SimpleConsoleLoggerTest testLogger\n"
+                                + expected
+                                + "\n>>>>"
+                                + "\n\t  actual:"
+                                + "\n<<<<\n" + logged + ">>>>\n");
+                    } else {
+                        verbose("Got expected results for "
+                                + desc + "\n<<<<\n" + logged + ">>>>\n");
+                    }
+                }
+            }
+        }
+
+        String msg = "blah";
+        for (Level loggerLevel : defaultLevel == null
+                ? EnumSet.of(Level.INFO) : EnumSet.of(defaultLevel)) {
+            for (Level messageLevel : Level.values()) {
+                String desc = "logger.log(messageLevel, \"blah\"): loggerLevel="
+                        + loggerLevel+", messageLevel="+messageLevel;
+                SEQUENCER.incrementAndGet();
+                simple.log(messageLevel, msg);
+                if (loggerLevel == Level.OFF || messageLevel == Level.OFF
+                    || messageLevel.compareTo(loggerLevel) < 0) {
+                    if (!ErrorStream.errorStream.peek().isEmpty()) {
+                        throw new RuntimeException("unexpected event in queue for "
+                                + desc +": " + "\n\t" + ErrorStream.errorStream.drain());
+                    }
+                } else {
+                    String logged = ErrorStream.errorStream.drain();
+                    String expected = getName(messageLevel, usePlatformLevel) + sep + msg;
+                    if (!logged.contains("SimpleConsoleLoggerTest testLogger")
+                        || !logged.contains(formatStrMarker)
+                        || logged.contains(unexpectedMarker)
+                        || !logged.contains(expected)) {
+                        throw new RuntimeException("mismatch for " + desc
+                                + "\n\texpected:" + "\n<<<<\n"
+                                + formatStrSpec + sepw + "SimpleConsoleLoggerTest testLogger\n"
+                                + expected
+                                + "\n>>>>"
+                                + "\n\t  actual:"
+                                + "\n<<<<\n" + logged + ">>>>\n");
+                    } else {
+                        verbose("Got expected results for "
+                                + desc + "\n<<<<\n" + logged + ">>>>\n");
+                    }
+                }
+            }
+        }
+
+        Supplier<String> fooSupplier = new Supplier<String>() {
+            @Override
+            public String get() {
+                return this.toString();
+            }
+        };
+
+        for (Level loggerLevel : defaultLevel == null
+                ? EnumSet.of(Level.INFO) : EnumSet.of(defaultLevel)) {
+            for (Level messageLevel : Level.values()) {
+                String desc = "logger.log(messageLevel, fooSupplier): loggerLevel="
+                        + loggerLevel+", messageLevel="+messageLevel;
+                SEQUENCER.incrementAndGet();
+                simple.log(messageLevel, fooSupplier);
+                if (loggerLevel == Level.OFF || messageLevel == Level.OFF
+                    || messageLevel.compareTo(loggerLevel) < 0) {
+                    if (!ErrorStream.errorStream.peek().isEmpty()) {
+                        throw new RuntimeException("unexpected event in queue for "
+                                + desc +": " + "\n\t" + ErrorStream.errorStream.drain());
+                    }
+                } else {
+                    String logged = ErrorStream.errorStream.drain();
+                    String expected = getName(messageLevel, usePlatformLevel) + sep + fooSupplier.get();
+                    if (!logged.contains("SimpleConsoleLoggerTest testLogger")
+                        || !logged.contains(formatStrMarker)
+                        || logged.contains(unexpectedMarker)
+                        || !logged.contains(expected)) {
+                        throw new RuntimeException("mismatch for " + desc
+                                + "\n\texpected:" + "\n<<<<\n"
+                                + formatStrSpec + sepw + "SimpleConsoleLoggerTest testLogger\n"
+                                + expected
+                                + "\n>>>>"
+                                + "\n\t  actual:"
+                                + "\n<<<<\n" + logged + ">>>>\n");
+                    } else {
+                        verbose("Got expected results for "
+                                + desc + "\n<<<<\n" + logged + ">>>>\n");
+                    }
+                }
+            }
+        }
+
+
+        String format = "two params [{1} {2}]";
+        Object arg1 = foo;
+        Object arg2 = msg;
+        for (Level loggerLevel : defaultLevel == null
+                ? EnumSet.of(Level.INFO) : EnumSet.of(defaultLevel)) {
+            for (Level messageLevel : Level.values()) {
+                String desc = "logger.log(messageLevel, format, params...): loggerLevel="
+                        + loggerLevel+", messageLevel="+messageLevel;
+                SEQUENCER.incrementAndGet();
+                simple.log(messageLevel, format, foo, msg);
+                if (loggerLevel == Level.OFF || messageLevel == Level.OFF || messageLevel.compareTo(loggerLevel) < 0) {
+                    if (!ErrorStream.errorStream.peek().isEmpty()) {
+                        throw new RuntimeException("unexpected event in queue for "
+                                + desc +": " + "\n\t" + ErrorStream.errorStream.drain());
+                    }
+                } else {
+                    String logged = ErrorStream.errorStream.drain();
+                    String msgFormat = format;
+                    String text = java.text.MessageFormat.format(msgFormat, foo, msg);
+                    String expected = getName(messageLevel, usePlatformLevel) + sep + text;
+                    if (!logged.contains("SimpleConsoleLoggerTest testLogger")
+                        || !logged.contains(formatStrMarker)
+                        || !logged.contains(expected)) {
+                        throw new RuntimeException("mismatch for " + desc
+                                + "\n\texpected:" + "\n<<<<\n"
+                                + formatStrSpec + sepw + "SimpleConsoleLoggerTest testLogger\n"
+                                + expected
+                                + "\n>>>>"
+                                + "\n\t  actual:"
+                                + "\n<<<<\n" + logged + ">>>>\n");
+                    } else {
+                        verbose("Got expected results for "
+                                + desc + "\n<<<<\n" + logged + ">>>>\n");
+                    }
+                }
+            }
+        }
+
+        Throwable thrown = new Exception("OK: log me!");
+        for (Level loggerLevel : defaultLevel == null
+                ? EnumSet.of(Level.INFO) : EnumSet.of(defaultLevel)) {
+            for (Level messageLevel : Level.values()) {
+                String desc = "logger.log(messageLevel, \"blah\", thrown): loggerLevel="
+                        + loggerLevel+", messageLevel="+messageLevel;
+                SEQUENCER.incrementAndGet();
+                simple.log(messageLevel, msg, thrown);
+                if (loggerLevel == Level.OFF || messageLevel == Level.OFF || messageLevel.compareTo(loggerLevel) < 0) {
+                    if (!ErrorStream.errorStream.peek().isEmpty()) {
+                        throw new RuntimeException("unexpected event in queue for "
+                                + desc +": " + "\n\t" + ErrorStream.errorStream.drain());
+                    }
+                } else {
+                    String logged = ErrorStream.errorStream.drain();
+                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                    thrown.printStackTrace(new PrintStream(baos));
+                    String text = baos.toString();
+                    String expected = getName(messageLevel, usePlatformLevel) + sep + msg;
+                    if (!logged.contains("SimpleConsoleLoggerTest testLogger")
+                        || !logged.contains(formatStrMarker)
+                        || !logged.contains(expected)
+                        || logged.contains(unexpectedMarker)
+                        || !logged.contains(text)) {
+                        throw new RuntimeException("mismatch for " + desc
+                                + "\n\texpected:" + "\n<<<<\n"
+                                + formatStrSpec + sepw + "SimpleConsoleLoggerTest testLogger\n"
+                                + msg +"\n"
+                                + text
+                                + ">>>>"
+                                + "\n\t  actual:"
+                                + "\n<<<<\n" + logged + ">>>>\n");
+                    } else {
+                        verbose("Got expected results for "
+                                + desc + "\n<<<<\n" + logged + ">>>>\n");
+                    }
+                }
+            }
+        }
+
+
+        for (Level loggerLevel : defaultLevel == null
+                ? EnumSet.of(Level.INFO) : EnumSet.of(defaultLevel)) {
+            for (Level messageLevel : Level.values()) {
+                String desc = "logger.log(messageLevel, thrown, fooSupplier): loggerLevel="
+                        + loggerLevel+", messageLevel="+messageLevel;
+                SEQUENCER.incrementAndGet();
+                simple.log(messageLevel, fooSupplier, thrown);
+                if (loggerLevel == Level.OFF || messageLevel == Level.OFF || messageLevel.compareTo(loggerLevel) < 0) {
+                    if (!ErrorStream.errorStream.peek().isEmpty()) {
+                        throw new RuntimeException("unexpected event in queue for "
+                                + desc +": " + "\n\t" + ErrorStream.errorStream.drain());
+                    }
+                } else {
+                    String logged = ErrorStream.errorStream.drain();
+                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                    thrown.printStackTrace(new PrintStream(baos));
+                    String text = baos.toString();
+                    String expected = getName(messageLevel, usePlatformLevel) + sep + fooSupplier.get();
+                    if (!logged.contains("SimpleConsoleLoggerTest testLogger")
+                        || !logged.contains(formatStrMarker)
+                        || !logged.contains(expected)
+                        || logged.contains(unexpectedMarker)
+                        || !logged.contains(text)) {
+                        throw new RuntimeException("mismatch for " + desc
+                                + "\n\texpected:" + "\n<<<<\n"
+                                + formatStrSpec + sepw + "SimpleConsoleLoggerTest testLogger\n"
+                                + expected +"\n"
+                                + text
+                                + ">>>>"
+                                + "\n\t  actual:"
+                                + "\n<<<<\n" + logged + ">>>>\n");
+                    } else {
+                        verbose("Got expected results for "
+                                + desc + "\n<<<<\n" + logged + ">>>>\n");
+                    }
+                }
+            }
+        }
+
+        ResourceBundle bundle = ResourceBundle.getBundle(MyBundle.class.getName());
+        for (Level loggerLevel : defaultLevel == null
+                ? EnumSet.of(Level.INFO) : EnumSet.of(defaultLevel)) {
+            for (Level messageLevel : Level.values()) {
+                String desc = "logger.log(messageLevel, bundle, format, params...): loggerLevel="
+                        + loggerLevel+", messageLevel="+messageLevel;
+                SEQUENCER.incrementAndGet();
+                simple.log(messageLevel, bundle, format, foo, msg);
+                if (loggerLevel == Level.OFF || messageLevel == Level.OFF || messageLevel.compareTo(loggerLevel) < 0) {
+                    if (!ErrorStream.errorStream.peek().isEmpty()) {
+                        throw new RuntimeException("unexpected event in queue for "
+                                + desc +": " + "\n\t" + ErrorStream.errorStream.drain());
+                    }
+                } else {
+                    String logged = ErrorStream.errorStream.drain();
+                    String text = java.text.MessageFormat.format(bundle.getString(format), foo, msg);
+                    if (!logged.contains("SimpleConsoleLoggerTest testLogger")
+                        || !logged.contains(formatStrMarker)
+                        || logged.contains(unexpectedMarker)
+                        || !logged.contains(getName(messageLevel, usePlatformLevel) + sep + text)) {
+                        throw new RuntimeException("mismatch for " + desc
+                                + "\n\texpected:" + "\n<<<<\n"
+                                + formatStrSpec + sepw + "SimpleConsoleLoggerTest testLogger\n"
+                                + getName(messageLevel, usePlatformLevel) + " " + text
+                                + "\n>>>>"
+                                + "\n\t  actual:"
+                                + "\n<<<<\n" + logged + ">>>>\n");
+                    } else {
+                        verbose("Got expected results for "
+                                + desc + "\n<<<<\n" + logged + ">>>>\n");
+                    }
+                }
+            }
+        }
+
+        for (Level loggerLevel : defaultLevel == null
+                ? EnumSet.of(Level.INFO) : EnumSet.of(defaultLevel)) {
+            for (Level messageLevel : Level.values()) {
+                String desc = "logger.log(messageLevel, bundle, \"blah\", thrown): loggerLevel="
+                        + loggerLevel+", messageLevel="+messageLevel;
+                SEQUENCER.incrementAndGet();
+                simple.log(messageLevel, bundle, msg, thrown);
+                if (loggerLevel == Level.OFF || messageLevel == Level.OFF || messageLevel.compareTo(loggerLevel) < 0) {
+                    if (!ErrorStream.errorStream.peek().isEmpty()) {
+                        throw new RuntimeException("unexpected event in queue for "
+                                + desc +": " + "\n\t" + ErrorStream.errorStream.drain());
+                    }
+                } else {
+                    String logged = ErrorStream.errorStream.drain();
+                    String textMsg = bundle.getString(msg);
+                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                    thrown.printStackTrace(new PrintStream(baos));
+                    String text = baos.toString();
+                    String expected = getName(messageLevel, usePlatformLevel) + sep + textMsg;
+                    if (!logged.contains("SimpleConsoleLoggerTest testLogger")
+                        || !logged.contains(formatStrMarker)
+                        || !logged.contains(expected)
+                        || logged.contains(unexpectedMarker)
+                        || !logged.contains(text)) {
+                        throw new RuntimeException("mismatch for " + desc
+                                + "\n\texpected:" + "\n<<<<\n"
+                                + formatStrSpec + sepw + "SimpleConsoleLoggerTest testLogger\n"
+                                + expected +"\n"
+                                + text
+                                + ">>>>"
+                                + "\n\t  actual:"
+                                + "\n<<<<\n" + logged + ">>>>\n");
+                    } else {
+                        verbose("Got expected results for "
+                                + desc + "\n<<<<\n" + logged + ">>>>\n");
+                    }
+                }
+            }
+        }
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/invoke/t8150782/TestAccessClass.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @compile TestAccessClass.java TestCls.java
+ * @run testng/othervm -ea -esa test.java.lang.invoke.t8150782.TestAccessClass
+ */
+package test.java.lang.invoke.t8150782;
+
+import java.lang.invoke.*;
+
+import static java.lang.invoke.MethodHandles.*;
+
+import static org.testng.AssertJUnit.*;
+
+import org.testng.annotations.*;
+
+public class TestAccessClass {
+
+    private static boolean initializedClass1;
+
+    private static class Class1 {
+        static {
+            initializedClass1 = true;
+        }
+    }
+
+    @Test
+    public void initializerNotRun() throws IllegalAccessException {
+        lookup().accessClass(Class1.class);
+        assertFalse(initializedClass1);
+    }
+
+    @Test
+    public void returnsSameClass() throws IllegalAccessException, ClassNotFoundException {
+        Class<?> aClass = lookup().accessClass(Class1.class);
+        assertEquals(Class1.class, aClass);
+    }
+
+    @DataProvider
+    Object[][] illegalAccessAccess() {
+        return new Object[][] {
+                {publicLookup(), Class1.class},
+                {publicLookup(), TestCls.getPrivateSIC()}
+        };
+    }
+
+    @Test(dataProvider = "illegalAccessAccess", expectedExceptions = {IllegalAccessException.class})
+    public void illegalAccessExceptionTest(Lookup lookup, Class<?> klass) throws IllegalAccessException, ClassNotFoundException {
+        lookup.accessClass(klass);
+    }
+
+    @Test
+    public void okAccess() throws IllegalAccessException {
+        lookup().accessClass(TestCls.getPrivateSIC());
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/invoke/t8150782/TestCls.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package test.java.lang.invoke.t8150782;
+
+import static java.lang.invoke.MethodHandles.*;
+
+public class TestCls {
+
+    public static final Lookup LOOKUP = lookup();
+
+    private static class PrivateSIC {}
+    public static Class getPrivateSIC() { return PrivateSIC.class; }
+    public static Lookup getLookupForPrivateSIC() { return lookup(); }
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/invoke/t8150782/TestFindClass.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @compile TestFindClass.java TestCls.java
+ * @run testng/othervm -ea -esa test.java.lang.invoke.t8150782.TestFindClass
+ */
+package test.java.lang.invoke.t8150782;
+
+import java.lang.invoke.*;
+
+import static java.lang.invoke.MethodHandles.*;
+
+import static org.testng.AssertJUnit.*;
+
+import org.testng.annotations.*;
+
+public class TestFindClass {
+
+    private static final String PACKAGE_PREFIX = "test.java.lang.invoke.t8150782.";
+
+    private static boolean initializedClass1;
+
+    private static class Class1 {
+        static {
+            initializedClass1 = true;
+        }
+    }
+
+    @Test
+    public void initializerNotRun() throws IllegalAccessException, ClassNotFoundException {
+        lookup().findClass(PACKAGE_PREFIX + "TestFindClass$Class1");
+        assertFalse(initializedClass1);
+    }
+
+    @Test
+    public void returnsRequestedClass() throws IllegalAccessException, ClassNotFoundException {
+        Class<?> aClass = lookup().findClass(PACKAGE_PREFIX + "TestFindClass$Class1");
+        assertEquals(Class1.class, aClass);
+    }
+
+    @Test(expectedExceptions = {ClassNotFoundException.class})
+    public void classNotFoundExceptionTest() throws IllegalAccessException, ClassNotFoundException {
+        lookup().findClass(PACKAGE_PREFIX + "TestFindClass$NonExistent");
+    }
+
+    @DataProvider
+    Object[][] illegalAccessFind() {
+        return new Object[][] {
+                {publicLookup(), PACKAGE_PREFIX + "TestFindClass$Class1"},
+                {publicLookup(), PACKAGE_PREFIX + "TestCls$PrivateSIC"}
+        };
+    }
+
+    /**
+     * Assertion: @throws IllegalAccessException if the class is not accessible, using the allowed access modes.
+     */
+    @Test(dataProvider = "illegalAccessFind", expectedExceptions = {ClassNotFoundException.class})
+    public void illegalAccessExceptionTest(Lookup lookup, String className) throws IllegalAccessException, ClassNotFoundException {
+        lookup.findClass(className);
+    }
+
+    @Test
+    public void okAccess() throws IllegalAccessException, ClassNotFoundException {
+        lookup().findClass(PACKAGE_PREFIX + "TestCls$PrivateSIC");
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/invoke/t8150782/TestLookup.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @compile TestLookup.java TestCls.java
+ * @run testng/othervm -ea -esa test.java.lang.invoke.t8150782.TestLookup
+ */
+package test.java.lang.invoke.t8150782;
+
+import org.testng.annotations.Test;
+
+import static java.lang.invoke.MethodHandles.*;
+
+import static org.testng.AssertJUnit.*;
+
+public class TestLookup {
+
+    @Test
+    public void testClassLoaderChange() {
+        Lookup lookup = lookup();
+        assertNotNull(lookup.lookupClass().getClassLoader());
+        Lookup lookup2 = lookup.in(Object.class);
+        assertNull(lookup2.lookupClass().getClassLoader());
+    }
+
+    @Test(expectedExceptions = {ClassNotFoundException.class})
+    public void testPublicCannotLoadUserClass() throws IllegalAccessException, ClassNotFoundException {
+        Lookup lookup = publicLookup();
+        lookup.findClass("test.java.lang.invoke.t8150782.TestCls");
+    }
+
+    @Test
+    public void testPublicCanLoadSystemClass() throws IllegalAccessException, ClassNotFoundException {
+        Lookup lookup = publicLookup();
+        lookup.findClass("java.util.HashMap");
+    }
+
+    @Test
+    public void testPublicInChangesClassLoader() {
+        Lookup lookup = publicLookup();
+        // Temporarily exclude until 8148697 is resolved, specifically:
+        // "publicLookup changed so that the lookup class is in an unnamed module"
+        //assertNull(lookup.lookupClass().getClassLoader());
+        Lookup lookup2 = lookup.in(TestCls.class);
+        assertNotNull(lookup2.lookupClass().getClassLoader());
+    }
+
+}
--- a/jdk/test/java/lang/reflect/AccessibleObject/ModuleSetAccessibleTest.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/test/java/lang/reflect/AccessibleObject/ModuleSetAccessibleTest.java	Mon Mar 28 08:41:54 2016 -0700
@@ -24,7 +24,7 @@
 /**
  * @test
  * @build ModuleSetAccessibleTest
- * @modules java.base/sun.misc
+ * @modules java.base/jdk.internal.misc
  * @run testng ModuleSetAccessibleTest
  * @summary Test java.lang.reflect.AccessibleObject with modules
  */
@@ -38,7 +38,7 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.Module;
 
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 import org.testng.annotations.Test;
 import static org.testng.Assert.*;
--- a/jdk/test/java/nio/channels/AsyncCloseAndInterrupt.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/test/java/nio/channels/AsyncCloseAndInterrupt.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
 
 /* @test
  * @bug 4460583 4470470 4840199 6419424 6710579 6596323 6824135 6395224 7142919
+ *      8151582
  * @run main/othervm AsyncCloseAndInterrupt
  * @summary Comprehensive test of asynchronous closing and interruption
  * @author Mark Reinhold
@@ -89,7 +90,7 @@
 
     private static void initRefuser() throws IOException {
         refuser = ServerSocketChannel.open();
-        refuser.socket().bind(wildcardAddress);
+        refuser.bind(wildcardAddress, 1);      // use minimum backlog
     }
 
     // Dead pipe source and sink
@@ -349,7 +350,7 @@
 
     static final Op CONNECT = new Op("connect") {
             void setup() {
-                waitPump("connect wait for pumping refuser ...");
+                waitPump("connect waiting for pumping refuser ...");
             }
             void doIO(InterruptibleChannel ich) throws IOException {
                 SocketChannel sc = (SocketChannel)ich;
@@ -361,7 +362,7 @@
 
     static final Op FINISH_CONNECT = new Op("finishConnect") {
             void setup() {
-                waitPump("finishConnect wait for pumping refuser ...");
+                waitPump("finishConnect waiting for pumping refuser ...");
             }
             void doIO(InterruptibleChannel ich) throws IOException {
                 SocketChannel sc = (SocketChannel)ich;
@@ -498,12 +499,11 @@
     private static volatile boolean pumpReady = false;
 
     private static void waitPump(String msg){
-        pumpReady = false;
         log.println(msg);
-
         while (!pumpReady){
             sleep(200);
         }
+        log.println(msg + " done");
     }
 
     // Create a pump thread dedicated to saturate refuser's connection backlog
@@ -520,28 +520,34 @@
 
                 // Saturate the refuser's connection backlog so that further connection
                 // attempts will be blocked
+                pumpReady = false;
                 while (!pumpDone) {
                     SocketChannel sc = SocketChannel.open();
                     sc.configureBlocking(false);
                     boolean connected = sc.connect(refuser.socket().getLocalSocketAddress());
 
                     // Assume that the connection backlog is saturated if a
-                    // client cannot connect to the refuser within 50 miliseconds
+                    // client cannot connect to the refuser within 50 milliseconds
                     long start = System.currentTimeMillis();
-                    while (!connected && (System.currentTimeMillis() - start < 50)) {
+                    while (!pumpReady && !connected
+                            && (System.currentTimeMillis() - start < 50)) {
                         connected = sc.finishConnect();
                     }
 
                     if (connected) {
                         // Retain so that finalizer doesn't close
                         refuserClients.add(sc);
-                        pumpReady = false;
                     } else {
                         sc.close();
                         pumpReady = true;
                     }
                 }
 
+                for (SocketChannel sc : refuserClients) {
+                    sc.close();
+                }
+                refuser.close();
+
                 log.println("Stop pumping refuser ...");
                 return refuserClients.size();
             }
@@ -565,8 +571,6 @@
             sleep(50);
         } while (!t.ready);
 
-        sleep(100);
-
         switch (test) {
 
         case TEST_INTR:
--- a/jdk/test/java/nio/channels/Selector/ChangingInterests.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/test/java/nio/channels/Selector/ChangingInterests.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
 
 /* @test
  * @bug 7200742
+ * @key intermittent
  * @summary Test that Selector doesn't spin when changing interest ops
  */
 
--- a/jdk/test/java/nio/channels/etc/AdaptorCloseAndInterrupt.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/test/java/nio/channels/etc/AdaptorCloseAndInterrupt.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,7 @@
 /* @test
  * @bug 7184932
  * @summary Test asynchronous close and interrupt of timed socket adapter methods
- * @key randomness
+ * @key randomness intermittent
  */
 
 import java.io.*;
--- a/jdk/test/java/time/tck/java/time/TCKZonedDateTime.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/test/java/time/tck/java/time/TCKZonedDateTime.java	Mon Mar 28 08:41:54 2016 -0700
@@ -761,6 +761,7 @@
                 {"2012-06-30T12:30:40-01:00[UT-01:00]", 2012, 6, 30, 12, 30, 40, 0, "UT-01:00"},
                 {"2012-06-30T12:30:40-01:00[UTC-01:00]", 2012, 6, 30, 12, 30, 40, 0, "UTC-01:00"},
                 {"2012-06-30T12:30:40+01:00[Europe/London]", 2012, 6, 30, 12, 30, 40, 0, "Europe/London"},
+                {"2012-06-30T12:30:40+01", 2012, 6, 30, 12, 30, 40, 0, "+01:00"},
         };
     }
 
--- a/jdk/test/java/time/tck/java/time/format/TCKDateTimeFormatterBuilder.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/test/java/time/tck/java/time/format/TCKDateTimeFormatterBuilder.java	Mon Mar 28 08:41:54 2016 -0700
@@ -59,11 +59,13 @@
  */
 package tck.java.time.format;
 
+import static java.time.format.DateTimeFormatter.BASIC_ISO_DATE;
 import static java.time.temporal.ChronoField.DAY_OF_MONTH;
 import static java.time.temporal.ChronoField.HOUR_OF_DAY;
 import static java.time.temporal.ChronoField.MINUTE_OF_HOUR;
 import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
 import static java.time.temporal.ChronoField.NANO_OF_SECOND;
+import static java.time.temporal.ChronoField.OFFSET_SECONDS;
 import static java.time.temporal.ChronoField.YEAR;
 import static org.testng.Assert.assertEquals;
 
@@ -73,6 +75,7 @@
 import java.time.ZoneOffset;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatterBuilder;
+import java.time.format.DateTimeParseException;
 import java.time.format.SignStyle;
 import java.time.format.TextStyle;
 import java.time.temporal.Temporal;
@@ -339,6 +342,18 @@
                 {"+HH", 2, 0, 45, "+02"},
                 {"+HH", 2, 30, 45, "+02"},
 
+                {"+HHmm", 2, 0, 0, "+02"},
+                {"+HHmm", -2, 0, 0, "-02"},
+                {"+HHmm", 2, 30, 0, "+0230"},
+                {"+HHmm", 2, 0, 45, "+02"},
+                {"+HHmm", 2, 30, 45, "+0230"},
+
+                {"+HH:mm", 2, 0, 0, "+02"},
+                {"+HH:mm", -2, 0, 0, "-02"},
+                {"+HH:mm", 2, 30, 0, "+02:30"},
+                {"+HH:mm", 2, 0, 45, "+02"},
+                {"+HH:mm", 2, 30, 45, "+02:30"},
+
                 {"+HHMM", 2, 0, 0, "+0200"},
                 {"+HHMM", -2, 0, 0, "-0200"},
                 {"+HHMM", 2, 30, 0, "+0230"},
@@ -374,6 +389,20 @@
                 {"+HH:MM:SS", 2, 30, 0, "+02:30:00"},
                 {"+HH:MM:SS", 2, 0, 45, "+02:00:45"},
                 {"+HH:MM:SS", 2, 30, 45, "+02:30:45"},
+
+                {"+HHmmss", 2, 0, 0, "+02"},
+                {"+HHmmss", -2, 0, 0, "-02"},
+                {"+HHmmss", 2, 30, 0, "+0230"},
+                {"+HHmmss", 2, 0, 45, "+020045"},
+                {"+HHmmss", 2, 30, 45, "+023045"},
+
+                {"+HH:mm:ss", 2, 0, 0, "+02"},
+                {"+HH:mm:ss", -2, 0, 0, "-02"},
+                {"+HH:mm:ss", 2, 30, 0, "+02:30"},
+                {"+HH:mm:ss", 2, 0, 45, "+02:00:45"},
+                {"+HH:mm:ss", 2, 30, 45, "+02:30:45"},
+
+
         };
     }
 
@@ -878,4 +907,82 @@
         assertEquals(parsed.getLong(MINUTE_OF_HOUR), 30L);
     }
 
+    @DataProvider(name="lenientOffsetParseData")
+    Object[][] data_lenient_offset_parse() {
+        return new Object[][] {
+            {"+HH", "+01", 3600},
+            {"+HH", "+0101", 3660},
+            {"+HH", "+010101", 3661},
+            {"+HH", "+01", 3600},
+            {"+HH", "+01:01", 3660},
+            {"+HH", "+01:01:01", 3661},
+            {"+HHmm", "+01", 3600},
+            {"+HHmm", "+0101", 3660},
+            {"+HHmm", "+010101", 3661},
+            {"+HH:mm", "+01", 3600},
+            {"+HH:mm", "+01:01", 3660},
+            {"+HH:mm", "+01:01:01", 3661},
+            {"+HHMM", "+01", 3600},
+            {"+HHMM", "+0101", 3660},
+            {"+HHMM", "+010101", 3661},
+            {"+HH:MM", "+01", 3600},
+            {"+HH:MM", "+01:01", 3660},
+            {"+HH:MM", "+01:01:01", 3661},
+            {"+HHMMss", "+01", 3600},
+            {"+HHMMss", "+0101", 3660},
+            {"+HHMMss", "+010101", 3661},
+            {"+HH:MM:ss", "+01", 3600},
+            {"+HH:MM:ss", "+01:01", 3660},
+            {"+HH:MM:ss", "+01:01:01", 3661},
+            {"+HHMMSS", "+01", 3600},
+            {"+HHMMSS", "+0101", 3660},
+            {"+HHMMSS", "+010101", 3661},
+            {"+HH:MM:SS", "+01", 3600},
+            {"+HH:MM:SS", "+01:01", 3660},
+            {"+HH:MM:SS", "+01:01:01", 3661},
+            {"+HHmmss", "+01", 3600},
+            {"+HHmmss", "+0101", 3660},
+            {"+HHmmss", "+010101", 3661},
+            {"+HH:mm:ss", "+01", 3600},
+            {"+HH:mm:ss", "+01:01", 3660},
+            {"+HH:mm:ss", "+01:01:01", 3661},
+        };
+    }
+
+    @Test(dataProvider="lenientOffsetParseData")
+    public void test_lenient_offset_parse_1(String pattern, String offset, int offsetSeconds) {
+        assertEquals(new DateTimeFormatterBuilder().parseLenient().appendOffset(pattern, "Z").toFormatter().parse(offset).get(OFFSET_SECONDS),
+                     offsetSeconds);
+    }
+
+    @Test
+    public void test_lenient_offset_parse_2() {
+        assertEquals(new DateTimeFormatterBuilder().parseLenient().appendOffsetId().toFormatter().parse("+01").get(OFFSET_SECONDS),
+                     3600);
+    }
+
+    @Test(expectedExceptions=DateTimeParseException.class)
+    public void test_strict_appendOffsetId() {
+        assertEquals(new DateTimeFormatterBuilder().appendOffsetId().toFormatter().parse("+01").get(OFFSET_SECONDS),
+                     3600);
+    }
+
+    @Test(expectedExceptions=DateTimeParseException.class)
+    public void test_strict_appendOffset_1() {
+        assertEquals(new DateTimeFormatterBuilder().appendOffset("+HH:MM:ss", "Z").toFormatter().parse("+01").get(OFFSET_SECONDS),
+                     3600);
+    }
+
+    @Test(expectedExceptions=DateTimeParseException.class)
+    public void test_strict_appendOffset_2() {
+        assertEquals(new DateTimeFormatterBuilder().appendOffset("+HHMMss", "Z").toFormatter().parse("+01").get(OFFSET_SECONDS),
+                     3600);
+    }
+
+    @Test
+    public void test_basic_iso_date() {
+        assertEquals(BASIC_ISO_DATE.parse("20021231+01").get(OFFSET_SECONDS), 3600);
+        assertEquals(BASIC_ISO_DATE.parse("20021231+0101").get(OFFSET_SECONDS), 3660);
+    }
+
 }
--- a/jdk/test/java/time/tck/java/time/format/TCKOffsetPrinterParser.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/test/java/time/tck/java/time/format/TCKOffsetPrinterParser.java	Mon Mar 28 08:41:54 2016 -0700
@@ -199,6 +199,30 @@
                 {"+HH:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-00:23:00"},
                 {"+HH:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-01:23:45"},
                 {"+HH:MM:SS", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-00:00:45"},
+
+                {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
+                {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+01"},
+                {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+01:23"},
+                {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+00:23"},
+                {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+01:23:45"},
+                {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-00:00:45"},
+                {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-01"},
+                {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-01:23"},
+                {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-00:23"},
+                {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-01:23:45"},
+                {"+HH:mm:ss", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-00:00:45"},
+
+                {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_UTC, "Z"},
+                {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0100, "+01"},
+                {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0123, "+0123"},
+                {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P0023, "+0023"},
+                {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P012345, "+012345"},
+                {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_P000045, "+000045"},
+                {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0100, "-01"},
+                {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0123, "-0123"},
+                {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M0023, "-0023"},
+                {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M012345, "-012345"},
+                {"+HHmmss", "Z", DT_2012_06_30_12_30_40, OFFSET_M000045, "-000045"},
         };
     }
 
--- a/jdk/test/java/time/test/java/time/format/TestDateTimeFormatter.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/test/java/time/test/java/time/format/TestDateTimeFormatter.java	Mon Mar 28 08:41:54 2016 -0700
@@ -79,19 +79,24 @@
 import java.time.ZoneId;
 import java.time.ZoneOffset;
 import java.time.ZonedDateTime;
+import java.time.chrono.Chronology;
 import java.time.chrono.ThaiBuddhistChronology;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatterBuilder;
 import java.time.format.DecimalStyle;
 import java.time.format.SignStyle;
+import java.time.format.TextStyle;
+import java.time.temporal.Temporal;
 import java.time.temporal.TemporalAccessor;
 import java.util.Locale;
 import java.util.function.Function;
 
+import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
 /**
  * Test DateTimeFormatter.
+ * @bug 8085887
  */
 @Test
 public class TestDateTimeFormatter {
@@ -196,4 +201,75 @@
         assertTrue(msg.contains("11:30:56"), msg);
     }
 
+    @DataProvider(name="nozone_exception_cases")
+    Object[][] exceptionCases() {
+        return new Object[][] {
+                {LocalDateTime.of(2000, 1, 1, 1, 1), "z", "ZoneId"},
+                {OffsetDateTime.of(2000, 1, 1, 3, 3, 3, 0, ZoneOffset.ofTotalSeconds(60)), "z", "ZoneId"},
+        };
+    }
+
+    // Test cases that should throw an exception with a cogent message
+    // containing the Type being queried and the Temporal being queried.
+    @Test(dataProvider="nozone_exception_cases")
+    public void test_throws_message(Temporal temporal, String pattern, String queryName) {
+        DateTimeFormatter fmt = DateTimeFormatter.ofPattern(pattern);
+        try {
+            fmt.format(temporal);
+            fail("Format using \"" + pattern + "\" with " +
+                    temporal + " should have failed");
+        } catch (DateTimeException dte) {
+            String msg = dte.getMessage();
+            // Verify message contains the type that is missing and the temporal value
+            assertTrue(msg.contains(queryName),
+                    String.format("\"%s\" missing from %s", queryName, msg));
+            String s = temporal.toString();
+            assertTrue(msg.contains(s),
+                    String.format("\"%s\" missing from %s", s, msg));
+        }
+
+    }
+
+    // Test cases that should throw an exception with a cogent message when missing the Chronology
+    @Test
+    public void test_throws_message_chrono() {
+        Chronology chrono = ThaiBuddhistChronology.INSTANCE;
+        DateTimeFormatter fmt = new DateTimeFormatterBuilder().appendZoneId().toFormatter()
+                .withChronology(chrono);
+        LocalTime now = LocalTime.now();
+        try {
+            fmt.format(now);
+            fail("Format using appendZoneId() should have failed");
+        } catch (DateTimeException dte) {
+            String msg = dte.getMessage();
+            // Verify message contains the type that is missing and the temporal value
+            assertTrue(msg.contains("ZoneId"),
+                    String.format("\"%s\" missing from %s", "ZoneId", msg));
+            assertTrue(msg.contains(chrono.toString()),
+                    String.format("\"%s\" missing from %s", chrono.toString(), msg));
+        }
+
+    }
+
+    // Test cases that should throw an exception with a cogent message when missing the ZoneId
+    @Test
+    public void test_throws_message_zone() {
+        ZoneId zone = ZoneId.of("Pacific/Honolulu");
+        DateTimeFormatter fmt = new DateTimeFormatterBuilder().appendChronologyId().toFormatter()
+                .withZone(zone);
+        LocalTime now = LocalTime.now();
+        try {
+            fmt.format(now);
+            fail("Format using appendChronologyId() should have failed");
+        } catch (DateTimeException dte) {
+            String msg = dte.getMessage();
+            // Verify message contains the type that is missing and the temporal value
+            assertTrue(msg.contains("Chronology"),
+                    String.format("\"%s\" missing from %s", "Chronology", msg));
+            assertTrue(msg.contains(zone.toString()),
+                    String.format("\"%s\" missing from %s", zone.toString(), msg));
+        }
+
+    }
+
 }
--- a/jdk/test/java/util/Spliterator/SpliteratorLateBindingFailFastTest.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/test/java/util/Spliterator/SpliteratorLateBindingFailFastTest.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,6 +52,7 @@
 
 /**
  * @test
+ * @bug 8148748
  * @summary Spliterator last-binding and fail-fast tests
  * @run testng SpliteratorLateBindingFailFastTest
  */
@@ -120,8 +121,8 @@
         }
 
         void addList(Function<Collection<T>, ? extends List<T>> l) {
-            // @@@ If collection is instance of List then add sub-list tests
             addCollection(l);
+            addCollection(l.andThen(list -> list.subList(0, list.size())));
         }
 
         void addMap(Function<Map<T, T>, ? extends Map<T, T>> mapConstructor) {
--- a/jdk/test/java/util/TimeZone/Bug6772689.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/test/java/util/TimeZone/Bug6772689.java	Mon Mar 28 08:41:54 2016 -0700
@@ -24,6 +24,7 @@
 /*
  * @test
  * @bug 6772689
+ * @key intermittent
  * @summary Test for standard-to-daylight transitions at midnight:
  * date stays on the given day.
  */
--- a/jdk/test/javax/net/ssl/DTLS/WeakCipherSuite.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/test/javax/net/ssl/DTLS/WeakCipherSuite.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
 /*
  * @test
  * @bug 8043758
+ * @key intermittent
  * @summary Datagram Transport Layer Security (DTLS)
  * @modules java.base/sun.security.util
  * @build DTLSOverDatagram
--- a/jdk/test/javax/net/ssl/templates/SSLSocketSSLEngineTemplate.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/test/javax/net/ssl/templates/SSLSocketSSLEngineTemplate.java	Mon Mar 28 08:41:54 2016 -0700
@@ -101,9 +101,6 @@
     private static final boolean debug = false;
     private final SSLContext sslc;
     private SSLEngine serverEngine;     // server-side SSLEngine
-    private SSLSocket sslSocket;        // client-side socket
-    private ServerSocket serverSocket;  // server-side Socket, generates the...
-    private Socket socket;              // server-side socket that will read
 
     private final byte[] serverMsg =
         "Hi there Client, I'm a Server.".getBytes();
@@ -217,132 +214,128 @@
     private void runTest(boolean direct) throws Exception {
         boolean serverClose = direct;
 
-        serverSocket = new ServerSocket();
-        serverSocket.setReuseAddress(false);
-        serverSocket.bind(null);
-        int port = serverSocket.getLocalPort();
-        Thread thread = createClientThread(port, serverClose);
+        // generates the server-side Socket
+        try (ServerSocket serverSocket = new ServerSocket()) {
+            serverSocket.setReuseAddress(false);
+            serverSocket.bind(null);
+            int port = serverSocket.getLocalPort();
+            Thread thread = createClientThread(port, serverClose);
 
-        socket = serverSocket.accept();
-        socket.setSoTimeout(500);
-        serverSocket.close();
-
-        createSSLEngine();
-        createBuffers(direct);
-
-        try {
-            boolean closed = false;
-            // will try to read one more time in case client message
-            // is fragmented to multiple pieces
-            boolean retry = true;
+            createSSLEngine();
+            createBuffers(direct);
 
-            InputStream is = socket.getInputStream();
-            OutputStream os = socket.getOutputStream();
-
-            SSLEngineResult serverResult;   // results from last operation
+            // server-side socket that will read
+            try (Socket socket = serverSocket.accept()) {
+                socket.setSoTimeout(500);
 
-            /*
-             * Examining the SSLEngineResults could be much more involved,
-             * and may alter the overall flow of the application.
-             *
-             * For example, if we received a BUFFER_OVERFLOW when trying
-             * to write to the output pipe, we could reallocate a larger
-             * pipe, but instead we wait for the peer to drain it.
-             */
-            byte[] inbound = new byte[8192];
-            byte[] outbound = new byte[8192];
+                boolean closed = false;
+                // will try to read one more time in case client message
+                // is fragmented to multiple pieces
+                boolean retry = true;
 
-            while (!isEngineClosed(serverEngine)) {
-                int len;
+                InputStream is = socket.getInputStream();
+                OutputStream os = socket.getOutputStream();
 
-                // Inbound data
-                log("================");
+                SSLEngineResult serverResult;   // results from last operation
 
-                // Read from the Client side.
-                try {
-                    len = is.read(inbound);
-                    if (len == -1) {
-                        throw new Exception("Unexpected EOF");
-                    }
-                    cTOs.put(inbound, 0, len);
-                } catch (SocketTimeoutException ste) {
-                    // swallow.  Nothing yet, probably waiting on us.
-                }
-
-                cTOs.flip();
-
-                serverResult = serverEngine.unwrap(cTOs, serverIn);
-                log("server unwrap: ", serverResult);
-                runDelegatedTasks(serverResult, serverEngine);
-                cTOs.compact();
-
-                // Outbound data
-                log("----");
-
-                serverResult = serverEngine.wrap(serverOut, sTOc);
-                log("server wrap: ", serverResult);
-                runDelegatedTasks(serverResult, serverEngine);
-
-                sTOc.flip();
+                /*
+                 * Examining the SSLEngineResults could be much more involved,
+                 * and may alter the overall flow of the application.
+                 *
+                 * For example, if we received a BUFFER_OVERFLOW when trying
+                 * to write to the output pipe, we could reallocate a larger
+                 * pipe, but instead we wait for the peer to drain it.
+                 */
+                byte[] inbound = new byte[8192];
+                byte[] outbound = new byte[8192];
 
-                if ((len = sTOc.remaining()) != 0) {
-                    sTOc.get(outbound, 0, len);
-                    os.write(outbound, 0, len);
-                    // Give the other side a chance to process
-                }
+                while (!isEngineClosed(serverEngine)) {
+                    int len;
 
-                sTOc.compact();
-
-                if (!closed && (serverOut.remaining() == 0)) {
-                    closed = true;
+                    // Inbound data
+                    log("================");
 
-                    /*
-                     * We'll alternate initiatating the shutdown.
-                     * When the server initiates, it will take one more
-                     * loop, but tests the orderly shutdown.
-                     */
-                    if (serverClose) {
-                        serverEngine.closeOutbound();
-                    }
-                    serverIn.flip();
-
-                    /*
-                     * A sanity check to ensure we got what was sent.
-                     */
-                    if (serverIn.remaining() !=  clientMsg.length) {
-                        if (retry && serverIn.remaining() < clientMsg.length) {
-                            log("Need to read more from client");
-                            retry = false;
-                            continue;
-                        } else {
-                            throw new Exception("Client:  Data length error");
+                    // Read from the Client side.
+                    try {
+                        len = is.read(inbound);
+                        if (len == -1) {
+                            throw new Exception("Unexpected EOF");
                         }
+                        cTOs.put(inbound, 0, len);
+                    } catch (SocketTimeoutException ste) {
+                        // swallow.  Nothing yet, probably waiting on us.
                     }
 
-                    for (int i = 0; i < clientMsg.length; i++) {
-                        if (clientMsg[i] != serverIn.get()) {
-                            throw new Exception("Client:  Data content error");
+                    cTOs.flip();
+
+                    serverResult = serverEngine.unwrap(cTOs, serverIn);
+                    log("server unwrap: ", serverResult);
+                    runDelegatedTasks(serverResult, serverEngine);
+                    cTOs.compact();
+
+                    // Outbound data
+                    log("----");
+
+                    serverResult = serverEngine.wrap(serverOut, sTOc);
+                    log("server wrap: ", serverResult);
+                    runDelegatedTasks(serverResult, serverEngine);
+
+                    sTOc.flip();
+
+                    if ((len = sTOc.remaining()) != 0) {
+                        sTOc.get(outbound, 0, len);
+                        os.write(outbound, 0, len);
+                        // Give the other side a chance to process
+                    }
+
+                    sTOc.compact();
+
+                    if (!closed && (serverOut.remaining() == 0)) {
+                        closed = true;
+
+                        /*
+                         * We'll alternate initiatating the shutdown.
+                         * When the server initiates, it will take one more
+                         * loop, but tests the orderly shutdown.
+                         */
+                        if (serverClose) {
+                            serverEngine.closeOutbound();
                         }
+                        serverIn.flip();
+
+                        /*
+                         * A sanity check to ensure we got what was sent.
+                         */
+                        if (serverIn.remaining() !=  clientMsg.length) {
+                            if (retry &&
+                                    serverIn.remaining() < clientMsg.length) {
+                                log("Need to read more from client");
+                                retry = false;
+                                continue;
+                            } else {
+                                throw new Exception(
+                                        "Client: Data length error");
+                            }
+                        }
+
+                        for (int i = 0; i < clientMsg.length; i++) {
+                            if (clientMsg[i] != serverIn.get()) {
+                                throw new Exception(
+                                        "Client: Data content error");
+                            }
+                        }
+                        serverIn.compact();
                     }
-                    serverIn.compact();
+                }
+            } catch (Exception e) {
+                serverException = e;
+            } finally {
+                // Wait for the client to join up with us.
+                if (thread != null) {
+                    thread.join();
                 }
             }
-        } catch (Exception e) {
-            serverException = e;
         } finally {
-            if (socket != null) {
-                socket.close();
-            }
-
-            // Wait for the client to join up with us.
-            if (thread != null) {
-                thread.join();
-            }
-
-            if (sslSocket != null) {
-                sslSocket.close();
-            }
-
             if (serverException != null) {
                 if (clientException != null) {
                     serverException.initCause(clientException);
@@ -369,11 +362,9 @@
 
             @Override
             public void run() {
-                try {
-                    Thread.sleep(1000);  // Give server time to finish setup.
-
-                    sslSocket = (SSLSocket) sslc.getSocketFactory().
-                            createSocket("localhost", port);
+                // client-side socket
+                try (SSLSocket sslSocket = (SSLSocket)sslc.getSocketFactory().
+                            createSocket("localhost", port)) {
                     OutputStream os = sslSocket.getOutputStream();
                     InputStream is = sslSocket.getInputStream();
 
--- a/jdk/test/javax/net/ssl/templates/SSLSocketTemplate.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/test/javax/net/ssl/templates/SSLSocketTemplate.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -85,26 +85,26 @@
      */
     void doServerSide() throws Exception {
         SSLServerSocketFactory sslssf =
-            (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
-        SSLServerSocket sslServerSocket =
-            (SSLServerSocket) sslssf.createServerSocket(serverPort);
+            (SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
+        try (SSLServerSocket sslServerSocket =
+                (SSLServerSocket)sslssf.createServerSocket(serverPort)) {
 
-        serverPort = sslServerSocket.getLocalPort();
+            serverPort = sslServerSocket.getLocalPort();
 
-        /*
-         * Signal Client, we're ready for his connect.
-         */
-        serverReady = true;
+            /*
+             * Signal Client, we're ready for his connect.
+             */
+            serverReady = true;
 
-        SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
-        InputStream sslIS = sslSocket.getInputStream();
-        OutputStream sslOS = sslSocket.getOutputStream();
+            try (SSLSocket sslSocket = (SSLSocket)sslServerSocket.accept()) {
+                InputStream sslIS = sslSocket.getInputStream();
+                OutputStream sslOS = sslSocket.getOutputStream();
 
-        sslIS.read();
-        sslOS.write(85);
-        sslOS.flush();
-
-        sslSocket.close();
+                sslIS.read();
+                sslOS.write(85);
+                sslOS.flush();
+            }
+        }
     }
 
     /*
@@ -123,18 +123,17 @@
         }
 
         SSLSocketFactory sslsf =
-            (SSLSocketFactory) SSLSocketFactory.getDefault();
-        SSLSocket sslSocket = (SSLSocket)
-            sslsf.createSocket("localhost", serverPort);
+            (SSLSocketFactory)SSLSocketFactory.getDefault();
+        try (SSLSocket sslSocket =
+                (SSLSocket)sslsf.createSocket("localhost", serverPort)) {
 
-        InputStream sslIS = sslSocket.getInputStream();
-        OutputStream sslOS = sslSocket.getOutputStream();
+            InputStream sslIS = sslSocket.getInputStream();
+            OutputStream sslOS = sslSocket.getOutputStream();
 
-        sslOS.write(280);
-        sslOS.flush();
-        sslIS.read();
-
-        sslSocket.close();
+            sslOS.write(280);
+            sslOS.flush();
+            sslIS.read();
+        }
     }
 
     /*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/xml/bind/xjc/8145039/JaxbMarshallTest.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8145039
+ * @summary Check that marshalling of xjc generated class doesn't throw
+ *          ClassCast exception.
+ * @modules javax.xml.bind
+ * @library /lib/testlibrary
+ * @run testng/othervm JaxbMarshallTest
+ */
+
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
+import java.util.Arrays;
+import java.util.List;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+import jdk.testlibrary.JDKToolLauncher;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+public class JaxbMarshallTest {
+
+    @BeforeTest
+    public void setUp() throws IOException {
+        // Create test directory inside scratch
+        testWorkDir = Paths.get(System.getProperty("user.dir", "."));
+        // Save its URL
+        testWorkDirUrl = testWorkDir.toUri().toURL();
+        // Get test source directory path
+        testSrcDir = Paths.get(System.getProperty("test.src", "."));
+        // Get path of xjc result folder
+        xjcResultDir = testWorkDir.resolve(TEST_PACKAGE);
+        // Copy schema document file to scratch directory
+        Files.copy(testSrcDir.resolve(XSD_FILENAME), testWorkDir.resolve(XSD_FILENAME), REPLACE_EXISTING);
+    }
+
+
+    /*
+     * Test does the following steps to reproduce problem reported by 8145039:
+     * 1. Copy test schema to JTREG scratch folder
+     * 2. Run xjc on test schema file
+     * 3. Compile generated java files with test javac
+     * 4. Marshall the new list instance to ensure that
+     *    ClassCastException is not thrown
+     */
+    @Test
+    public void marshallClassCastExceptionTest() throws Exception {
+        JAXBContext jaxbContext;
+        Marshaller marshaller;
+        URLClassLoader jaxbContextClassLoader;
+        // Generate java classes by xjc
+        runXjc(XSD_FILENAME);
+        // Compile xjc generated java files
+        compileXjcGeneratedClasses();
+
+        // Create JAXB context based on xjc generated package.
+        // Need to create URL class loader ot make compiled classes discoverable
+        // by JAXB context
+        jaxbContextClassLoader = URLClassLoader.newInstance(new URL[] {testWorkDirUrl});
+        jaxbContext = JAXBContext.newInstance( TEST_PACKAGE, jaxbContextClassLoader);
+
+        // Create instance of Xjc generated data type.
+        // Java classes were compiled during the test execution hence reflection
+        // is needed here
+        Class classLongListClass = jaxbContextClassLoader.loadClass(TEST_CLASS);
+        Object objectLongListClass = classLongListClass.newInstance();
+        // Get 'getIn' method object
+        Method getInMethod = classLongListClass.getMethod( GET_LIST_METHOD, (Class [])null );
+        // Invoke 'getIn' method
+        List<Long> inList = (List<Long>)getInMethod.invoke(objectLongListClass);
+        // Add values into the jaxb object list
+        inList.add(Long.valueOf(0));
+        inList.add(Long.valueOf(43));
+        inList.add(Long.valueOf(1000000123));
+
+        // Marshall constructed complex type variable to standard output.
+        // In case of failure the ClassCastException will be thrown
+        marshaller = jaxbContext.createMarshaller();
+        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+        marshaller.marshal(objectLongListClass, System.out);
+    }
+
+    // Compile schema file into java classes definitions
+    void runXjc(String xsdFileName) throws Exception {
+        // Prepare process builder to run schemagen tool and save its output
+        JDKToolLauncher xjcLauncher = JDKToolLauncher.createUsingTestJDK("xjc");
+        xjcLauncher.addToolArg(xsdFileName);
+        System.out.println("Executing xjc command: " + Arrays.asList(xjcLauncher.getCommand()));
+        ProcessBuilder pb = new ProcessBuilder(xjcLauncher.getCommand());
+        // Set xjc work directory with the input java file
+        pb.directory(testWorkDir.toFile());
+        pb.inheritIO();
+        Process p = pb.start();
+        p.waitFor();
+        p.destroy();
+    }
+
+    // Compile java classes with javac tool
+    void compileXjcGeneratedClasses() throws Exception {
+        JDKToolLauncher javacLauncher = JDKToolLauncher.createUsingTestJDK("javac");
+        javacLauncher.addToolArg(xjcResultDir.resolve("ObjectFactory.java").toString());
+        javacLauncher.addToolArg(xjcResultDir.resolve("TypesLongList.java").toString());
+        javacLauncher.addToolArg(xjcResultDir.resolve("package-info.java").toString());
+        System.out.println("Compiling xjc generated classes: " + Arrays.asList(javacLauncher.getCommand()));
+        ProcessBuilder pb = new ProcessBuilder(javacLauncher.getCommand());
+        pb.inheritIO();
+        pb.directory(testWorkDir.toFile());
+        Process p = pb.start();
+        p.waitFor();
+        p.destroy();
+    }
+
+    // Test schema filename
+    static final String XSD_FILENAME = "testSchema.xsd";
+    // Package of java classes generated by xjc
+    static final String TEST_PACKAGE = "testns_package";
+    // Name of generated java class
+    static final String TEST_CLASS = TEST_PACKAGE+".TypesLongList";
+    // Method to get the list from xjc generated class
+    static final String GET_LIST_METHOD = "getIn";
+    // Test working directory
+    Path testWorkDir;
+    // Test working directory URL
+    URL testWorkDirUrl;
+    // Directory with test src
+    Path testSrcDir;
+    // Directory with java files generated by xjc
+    Path xjcResultDir;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/xml/bind/xjc/8145039/testSchema.xsd	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,21 @@
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+            xmlns:tns="http://testns_package"
+            xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0"
+            targetNamespace="http://testns_package">
+    <!-- Simple type list -->
+    <xsd:simpleType name="LongList">
+        <xsd:list>
+            <xsd:simpleType>
+                <xsd:restriction base="xsd:unsignedInt"/>
+            </xsd:simpleType>
+        </xsd:list>
+    </xsd:simpleType>
+    <!--- Complex test type -->
+    <xsd:element name="typesLongList">
+        <xsd:complexType>
+            <xsd:sequence>
+                <xsd:element name="in" type="tns:LongList"/>
+            </xsd:sequence>
+        </xsd:complexType>
+    </xsd:element>
+</xsd:schema>
--- a/jdk/test/jdk/internal/jline/console/StripAnsiTest.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/test/jdk/internal/jline/console/StripAnsiTest.java	Mon Mar 28 08:41:54 2016 -0700
@@ -23,14 +23,16 @@
 
 /**
  * @test
- * @bug 8080679
- * @modules jdk.internal.le/jdk.internal.jline.console
+ * @bug 8080679 8131913
+ * @modules jdk.internal.le/jdk.internal.jline
+ *          jdk.internal.le/jdk.internal.jline.console
  * @summary Verify ConsoleReader.stripAnsi strips escape sequences from its input correctly.
  */
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.lang.reflect.Method;
+import jdk.internal.jline.UnsupportedTerminal;
 import jdk.internal.jline.console.ConsoleReader;
 
 public class StripAnsiTest {
@@ -41,7 +43,7 @@
     void run() throws Exception {
         ByteArrayInputStream in = new ByteArrayInputStream(new byte[0]);
         ByteArrayOutputStream out = new ByteArrayOutputStream();
-        ConsoleReader reader = new ConsoleReader(in, out);
+        ConsoleReader reader = new ConsoleReader(in, out, new UnsupportedTerminal());
 
         String withAnsi = "0\033[s1\033[2J2\033[37;4m3";
         String expected = "0123";
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/jdk/internal/misc/Unsafe/CopyCommon.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,607 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import jdk.internal.misc.Unsafe;
+import java.lang.reflect.Field;
+
+/**
+ * Helper class to support testing of Unsafe.copyMemory and Unsafe.copySwapMemory
+ */
+public class CopyCommon {
+    private static final boolean DEBUG = Boolean.getBoolean("CopyCommon.DEBUG");
+
+    public static final long KB = 1024;
+    public static final long MB = KB * 1024;
+    public static final long GB = MB * 1024;
+
+    static final int SMALL_COPY_SIZE = 32;
+    static final int BASE_ALIGNMENT = 16;
+
+    protected static final Unsafe UNSAFE;
+
+    static {
+        try {
+            Field f = jdk.internal.misc.Unsafe.class.getDeclaredField("theUnsafe");
+            f.setAccessible(true);
+            UNSAFE = (jdk.internal.misc.Unsafe) f.get(null);
+        } catch (Exception e) {
+            throw new RuntimeException("Unable to get Unsafe instance.", e);
+        }
+    }
+
+    static long alignDown(long value, long alignment) {
+        return value & ~(alignment - 1);
+    }
+
+    static long alignUp(long value, long alignment) {
+        return (value + alignment - 1) & ~(alignment - 1);
+    }
+
+    static boolean isAligned(long value, long alignment) {
+        return value == alignDown(value, alignment);
+    }
+
+    CopyCommon() {
+    }
+
+    /**
+     * Generate verification data for a given offset
+     *
+     * The verification data is used to verify that the correct bytes
+     * have indeed been copied and byte swapped.
+     *
+     * The data is generated based on the offset (in bytes) into the
+     * source buffer. For a native buffer the offset is relative to
+     * the base pointer. For a heap array it is relative to the
+     * address of the first array element.
+     *
+     * This method will return the result of doing an elementSize byte
+     * read starting at offset (in bytes).
+     *
+     * @param offset offset into buffer
+     * @param elemSize size (in bytes) of the element
+     *
+     * @return the verification data, only the least significant
+     * elemSize*8 bits are set, zero extended
+     */
+    private long getVerificationDataForOffset(long offset, long elemSize) {
+        byte[] bytes = new byte[(int)elemSize];
+
+        for (long i = 0; i < elemSize; i++) {
+            bytes[(int)i] = (byte)(offset + i);
+        }
+
+        long o = UNSAFE.arrayBaseOffset(byte[].class);
+
+        switch ((int)elemSize) {
+        case 1: return Byte.toUnsignedLong(UNSAFE.getByte(bytes, o));
+        case 2: return Short.toUnsignedLong(UNSAFE.getShortUnaligned(bytes, o));
+        case 4: return Integer.toUnsignedLong(UNSAFE.getIntUnaligned(bytes, o));
+        case 8: return UNSAFE.getLongUnaligned(bytes, o);
+        default: throw new IllegalArgumentException("Invalid element size: " + elemSize);
+        }
+    }
+
+    /**
+     * Verify byte swapped data
+     *
+     * @param ptr the data to verify
+     * @param srcOffset the srcOffset (in bytes) from which the copy started,
+     *        used as key to regenerate the verification data
+     * @param dstOffset the offset (in bytes) in the array at which to start
+     *        the verification, relative to the first element in the array
+     * @param size size (in bytes) of data to to verify
+     * @param elemSize size (in bytes) of the individual array elements
+     *
+     * @throws RuntimeException if an error is found
+     */
+    private void verifySwappedData(GenericPointer ptr, long srcOffset, long dstOffset, long size, long elemSize) {
+        for (long offset = 0; offset < size; offset += elemSize) {
+            long expectedUnswapped = getVerificationDataForOffset(srcOffset + offset, elemSize);
+            long expected = byteSwap(expectedUnswapped, elemSize);
+
+            long actual = getArrayElem(ptr, dstOffset + offset, elemSize);
+
+            if (expected != actual) {
+                throw new RuntimeException("srcOffset: 0x" + Long.toHexString(srcOffset) +
+                                           " dstOffset: 0x" + Long.toHexString(dstOffset) +
+                                           " size: 0x" + Long.toHexString(size) +
+                                           " offset: 0x" + Long.toHexString(offset) +
+                                           " expectedUnswapped: 0x" + Long.toHexString(expectedUnswapped) +
+                                           " expected: 0x" + Long.toHexString(expected) +
+                                           " != actual: 0x" + Long.toHexString(actual));
+            }
+        }
+    }
+
+    /**
+     * Initialize an array with verification friendly data
+     *
+     * @param ptr pointer to the data to initialize
+     * @param size size (in bytes) of the data
+     * @param elemSize size (in bytes) of the individual elements
+     */
+    private void initVerificationData(GenericPointer ptr, long size, long elemSize) {
+        for (long offset = 0; offset < size; offset++) {
+            byte data = (byte)getVerificationDataForOffset(offset, 1);
+
+            if (ptr.isOnHeap()) {
+                UNSAFE.putByte(ptr.getObject(), ptr.getOffset() + offset, data);
+            } else {
+                UNSAFE.putByte(ptr.getOffset() + offset, data);
+            }
+        }
+    }
+
+    /**
+     * Allocate a primitive array
+     *
+     * @param size size (in bytes) of all the array elements (elemSize * length)
+     * @param elemSize the size of the array elements
+     *
+     * @return a newly allocated primitive array
+     */
+    Object allocArray(long size, long elemSize) {
+        int length = (int)(size / elemSize);
+
+        switch ((int)elemSize) {
+        case 1: return new byte[length];
+        case 2: return new short[length];
+        case 4: return new int[length];
+        case 8: return new long[length];
+        default:
+            throw new IllegalArgumentException("Invalid element size: " + elemSize);
+        }
+    }
+
+    /**
+     * Get the value of a primitive array entry
+     *
+     * @param ptr pointer to the data
+     * @param offset offset (in bytes) of the array element, relative to the first element in the array
+     *
+     * @return the array element, as an unsigned long
+     */
+    private long getArrayElem(GenericPointer ptr, long offset, long elemSize) {
+        if (ptr.isOnHeap()) {
+            Object o = ptr.getObject();
+            int index = (int)(offset / elemSize);
+
+            if (o instanceof short[]) {
+                short[] arr = (short[])o;
+                return Short.toUnsignedLong(arr[index]);
+            } else if (o instanceof int[]) {
+                int[] arr = (int[])o;
+                return Integer.toUnsignedLong(arr[index]);
+            } else if (o instanceof long[]) {
+                long[] arr = (long[])o;
+                return arr[index];
+            } else {
+                throw new IllegalArgumentException("Invalid object type: " + o.getClass().getName());
+            }
+        } else {
+            long addr = ptr.getOffset() + offset;
+
+            switch ((int)elemSize) {
+            case 1: return Byte.toUnsignedLong(UNSAFE.getByte(addr));
+            case 2: return Short.toUnsignedLong(UNSAFE.getShortUnaligned(null, addr));
+            case 4: return Integer.toUnsignedLong(UNSAFE.getIntUnaligned(null, addr));
+            case 8: return UNSAFE.getLongUnaligned(null, addr);
+            default: throw new IllegalArgumentException("Invalid element size: " + elemSize);
+            }
+        }
+    }
+
+    private void putValue(long addr, long elemSize, long value) {
+        switch ((int)elemSize) {
+        case 1: UNSAFE.putByte(addr, (byte)value); break;
+        case 2: UNSAFE.putShortUnaligned(null, addr, (short)value); break;
+        case 4: UNSAFE.putIntUnaligned(null, addr, (int)value); break;
+        case 8: UNSAFE.putLongUnaligned(null, addr, value); break;
+        default: throw new IllegalArgumentException("Invalid element size: " + elemSize);
+        }
+    }
+
+    /**
+     * Get the size of the elements for an array
+     *
+     * @param o a primitive heap array
+     *
+     * @return the size (in bytes) of the individual array elements
+     */
+    private long getArrayElemSize(Object o) {
+        if (o instanceof short[]) {
+            return 2;
+        } else if (o instanceof int[]) {
+            return 4;
+        } else if (o instanceof long[]) {
+            return 8;
+        } else {
+            throw new IllegalArgumentException("Invalid object type: " + o.getClass().getName());
+        }
+    }
+
+    /**
+     * Byte swap a value
+     *
+     * @param value the value to swap, only the bytes*8 least significant bits are used
+     * @param size size (in bytes) of the value
+     *
+     * @return the byte swapped value in the bytes*8 least significant bits
+     */
+    private long byteSwap(long value, long size) {
+        switch ((int)size) {
+        case 2: return Short.toUnsignedLong(Short.reverseBytes((short)value));
+        case 4: return Integer.toUnsignedLong(Integer.reverseBytes((int)value));
+        case 8: return Long.reverseBytes(value);
+        default: throw new IllegalArgumentException("Invalid element size: " + size);
+        }
+    }
+
+    /**
+     * Verify data which has *not* been byte swapped
+     *
+     * @param ptr the data to verify
+     * @param startOffset the offset (in bytes) at which to start the verification
+     * @param size size (in bytes) of the data to verify
+     *
+     * @throws RuntimeException if an error is found
+     */
+    private void verifyUnswappedData(GenericPointer ptr, long startOffset, long srcOffset, long size) {
+        for (long i = 0; i < size; i++) {
+            byte expected = (byte)getVerificationDataForOffset(srcOffset + i, 1);
+
+            byte actual;
+            if (ptr.isOnHeap()) {
+                actual = UNSAFE.getByte(ptr.getObject(), ptr.getOffset() + startOffset + i);
+            } else {
+                actual = UNSAFE.getByte(ptr.getOffset() + startOffset + i);
+            }
+
+            if (expected != actual) {
+                throw new RuntimeException("startOffset: 0x" + Long.toHexString(startOffset) +
+                                           " srcOffset: 0x" + Long.toHexString(srcOffset) +
+                                           " size: 0x" + Long.toHexString(size) +
+                                           " i: 0x" + Long.toHexString(i) +
+                                           " expected: 0x" + Long.toHexString(expected) +
+                                           " != actual: 0x" + Long.toHexString(actual));
+            }
+        }
+    }
+
+
+    /**
+     * Copy and byte swap data from the source to the destination
+     *
+     * This method will pre-populate the whole source and destination
+     * buffers with verification friendly data. It will then copy data
+     * to fill part of the destination buffer with data from the
+     * source, optionally byte swapping the copied elements on the
+     * fly. Some space (padding) will be left before and after the
+     * data in the destination buffer, which should not be
+     * touched/overwritten by the copy call.
+     *
+     * Note: Both source and destination buffers will be overwritten!
+     *
+     * @param src source buffer to copy from
+     * @param srcOffset the offset (in bytes) in the source buffer, relative to
+     *        the first array element, at which to start reading data
+     * @param dst destination buffer to copy to
+     * @param dstOffset the offset (in bytes) in the destination
+     *        buffer, relative to the first array element, at which to
+     *        start writing data
+     * @param bufSize the size (in bytes) of the src and dst arrays
+     * @param copyBytes the size (in bytes) of the copy to perform,
+     *        must be a multiple of elemSize
+     * @param elemSize the size (in bytes) of the elements
+     * @param swap true if elements should be byte swapped
+     *
+     * @throws RuntimeException if an error is found
+     */
+    void testCopyGeneric(GenericPointer src, long srcOffset,
+                         GenericPointer dst, long dstOffset,
+                         long bufSize, long copyBytes, long elemSize, boolean swap) {
+        if (swap) {
+            if (!isAligned(copyBytes, elemSize)) {
+                throw new IllegalArgumentException(
+                    "copyBytes (" + copyBytes + ") must be a multiple of elemSize (" + elemSize + ")");
+            }
+            if (src.isOnHeap() && !isAligned(srcOffset, elemSize)) {
+                throw new IllegalArgumentException(
+                    "srcOffset (" + srcOffset + ") must be a multiple of elemSize (" + elemSize + ")");
+            }
+            if (dst.isOnHeap() && !isAligned(dstOffset, elemSize)) {
+                throw new IllegalArgumentException(
+                    "dstOffset (" + dstOffset + ") must be a multiple of elemSize (" + elemSize + ")");
+            }
+        }
+
+        if (srcOffset + copyBytes > bufSize) {
+            throw new IllegalArgumentException(
+                "srcOffset (" + srcOffset + ") + copyBytes (" + copyBytes + ") > bufSize (" + bufSize + ")");
+        }
+        if (dstOffset + copyBytes > bufSize) {
+            throw new IllegalArgumentException(
+                "dstOffset (" + dstOffset + ") + copyBytes (" + copyBytes + ") > bufSize (" + bufSize + ")");
+        }
+
+        // Initialize the whole source buffer with a verification friendly pattern (no 0x00 bytes)
+        initVerificationData(src, bufSize, elemSize);
+        if (!src.equals(dst)) {
+            initVerificationData(dst, bufSize, elemSize);
+        }
+
+        if (DEBUG) {
+            System.out.println("===before===");
+            for (int offset = 0; offset < bufSize; offset += elemSize) {
+                long srcValue = getArrayElem(src, offset, elemSize);
+                long dstValue = getArrayElem(dst, offset, elemSize);
+
+                System.out.println("offs=0x" + Long.toHexString(Integer.toUnsignedLong(offset)) +
+                                 " src=0x" + Long.toHexString(srcValue) +
+                                 " dst=0x" + Long.toHexString(dstValue));
+            }
+        }
+
+        if (swap) {
+            // Copy & swap data into the middle of the destination buffer
+            UNSAFE.copySwapMemory(src.getObject(),
+                                  src.getOffset() + srcOffset,
+                                  dst.getObject(),
+                                  dst.getOffset() + dstOffset,
+                                  copyBytes,
+                                  elemSize);
+        } else {
+            // Copy & swap data into the middle of the destination buffer
+            UNSAFE.copyMemory(src.getObject(),
+                              src.getOffset() + srcOffset,
+                              dst.getObject(),
+                              dst.getOffset() + dstOffset,
+                              copyBytes);
+        }
+
+        if (DEBUG) {
+            System.out.println("===after===");
+            for (int offset = 0; offset < bufSize; offset += elemSize) {
+                long srcValue = getArrayElem(src, offset, elemSize);
+                long dstValue = getArrayElem(dst, offset, elemSize);
+
+                System.out.println("offs=0x" + Long.toHexString(Integer.toUnsignedLong(offset)) +
+                                 " src=0x" + Long.toHexString(srcValue) +
+                                 " dst=0x" + Long.toHexString(dstValue));
+            }
+        }
+
+        // Verify the the front padding is unchanged
+        verifyUnswappedData(dst, 0, 0, dstOffset);
+
+        if (swap) {
+            // Verify swapped data
+            verifySwappedData(dst, srcOffset, dstOffset, copyBytes, elemSize);
+        } else {
+            // Verify copied/unswapped data
+            verifyUnswappedData(dst, dstOffset, srcOffset, copyBytes);
+        }
+
+        // Verify that the back padding is unchanged
+        long frontAndCopyBytes = dstOffset + copyBytes;
+        long trailingBytes = bufSize - frontAndCopyBytes;
+        verifyUnswappedData(dst, frontAndCopyBytes, frontAndCopyBytes, trailingBytes);
+    }
+
+    /**
+     * Test various configurations of copying and optionally swapping data
+     *
+     * @param src the source buffer to copy from
+     * @param dst the destination buffer to copy to
+     * @param size size (in bytes) of the buffers
+     * @param elemSize size (in bytes) of the individual elements
+     *
+     * @throws RuntimeException if an error is found
+     */
+    public void testBufferPair(GenericPointer src, GenericPointer dst, long size, long elemSize, boolean swap) {
+        // offset in source from which to start reading data
+        for (long srcOffset = 0; srcOffset < size; srcOffset += (src.isOnHeap() ? elemSize : 1)) {
+
+            // offset in destination at which to start writing data
+            for (int dstOffset = 0; dstOffset < size; dstOffset += (dst.isOnHeap() ? elemSize : 1)) {
+
+                // number of bytes to copy
+                long maxCopyBytes = Math.min(size - srcOffset, size - dstOffset);
+                for (long copyBytes = 0; copyBytes < maxCopyBytes; copyBytes += elemSize) {
+                    try {
+                        testCopyGeneric(src, srcOffset, dst, dstOffset, size, copyBytes, elemSize, swap);
+                    } catch (RuntimeException e) {
+                        // Wrap the exception in another exception to catch the relevant configuration data
+                        throw new RuntimeException("testBufferPair: " +
+                                                   "src=" + src +
+                                                   " dst=" + dst +
+                                                   " elemSize=0x" + Long.toHexString(elemSize) +
+                                                   " copyBytes=0x" + Long.toHexString(copyBytes) +
+                                                   " srcOffset=0x" + Long.toHexString(srcOffset) +
+                                                   " dstOffset=0x" + Long.toHexString(dstOffset) +
+                                                   " swap=" + swap,
+                                                   e);
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Test copying between various permutations of buffers
+     *
+     * @param buffers buffers to permute (src x dst)
+     * @param size size (in bytes) of buffers
+     * @param elemSize size (in bytes) of individual elements
+     *
+     * @throws RuntimeException if an error is found
+     */
+    public void testPermuteBuffers(GenericPointer[] buffers, long size, long elemSize, boolean swap) {
+        System.out.println("testPermuteBuffers(buffers, " + size + ", " + elemSize + ", " + swap + ")");
+        for (int srcIndex = 0; srcIndex < buffers.length; srcIndex++) {
+            for (int dstIndex = 0; dstIndex < buffers.length; dstIndex++) {
+                testBufferPair(buffers[srcIndex], buffers[dstIndex], size, elemSize, swap);
+            }
+        }
+    }
+
+    /**
+     * Test copying of a specific element size
+     *
+     * @param size size (in bytes) of buffers to allocate
+     * @param elemSize size (in bytes) of individual elements
+     *
+     * @throws RuntimeException if an error is found
+     */
+    private void testElemSize(long size, long elemSize, boolean swap) {
+        long buf1Raw = 0;
+        long buf2Raw = 0;
+
+        try {
+            buf1Raw = UNSAFE.allocateMemory(size + BASE_ALIGNMENT);
+            long buf1 = alignUp(buf1Raw, BASE_ALIGNMENT);
+
+            buf2Raw = UNSAFE.allocateMemory(size + BASE_ALIGNMENT);
+            long buf2 = alignUp(buf2Raw, BASE_ALIGNMENT);
+
+            GenericPointer[] buffers = {
+                new GenericPointer(buf1),
+                new GenericPointer(buf2),
+                new GenericPointer(allocArray(size, elemSize)),
+                new GenericPointer(allocArray(size, elemSize))
+            };
+
+            testPermuteBuffers(buffers, size, elemSize, swap);
+        } finally {
+            if (buf1Raw != 0) {
+                UNSAFE.freeMemory(buf1Raw);
+            }
+            if (buf2Raw != 0) {
+                UNSAFE.freeMemory(buf2Raw);
+            }
+        }
+    }
+
+    /**
+     * Verify that small copies work
+     */
+    void testSmallCopy(boolean swap) {
+        int smallBufSize = SMALL_COPY_SIZE;
+        int minElemSize = swap ? 2 : 1;
+        int maxElemSize = swap ? 8 : 1;
+
+        // Test various element types and heap/native combinations
+        for (long elemSize = minElemSize; elemSize <= maxElemSize; elemSize <<= 1) {
+            testElemSize(smallBufSize, elemSize, swap);
+        }
+    }
+
+
+    /**
+     * Verify that large copies work
+     */
+    void testLargeCopy(boolean swap) {
+        long size = 2 * GB + 8;
+        long bufRaw = 0;
+
+        // Check that a large native copy succeeds
+        try {
+            try {
+                bufRaw = UNSAFE.allocateMemory(size + BASE_ALIGNMENT);
+            } catch (OutOfMemoryError e) {
+                // Accept failure, skip test
+                return;
+            }
+
+            long buf = alignUp(bufRaw, BASE_ALIGNMENT);
+
+            if (swap) {
+                UNSAFE.copySwapMemory(null, buf, null, buf, size, 8);
+            } else {
+                UNSAFE.copyMemory(null, buf, null, buf, size);
+            }
+        } catch (Exception e) {
+            throw new RuntimeException("copy of large buffer failed (swap=" + swap + ")");
+        } finally {
+            if (bufRaw != 0) {
+                UNSAFE.freeMemory(bufRaw);
+            }
+        }
+    }
+
+    /**
+     * Helper class to represent a "pointer" - either a heap array or
+     * a pointer to a native buffer.
+     *
+     * In the case of a native pointer, the Object is null and the offset is
+     * the absolute address of the native buffer.
+     *
+     * In the case of a heap object, the Object is a primitive array, and
+     * the offset will be set to the base offset to the first element, meaning
+     * the object and the offset together form a double-register pointer.
+     */
+    static class GenericPointer {
+        private final Object o;
+        private final long offset;
+
+        private GenericPointer(Object o, long offset) {
+            this.o = o;
+            this.offset = offset;
+        }
+
+        public String toString() {
+            return "GenericPointer(o={" + o + "}, offset=0x" + Long.toHexString(offset) + ")";
+        }
+
+        public boolean equals(Object other) {
+            if (!(other instanceof GenericPointer)) {
+                return false;
+            }
+
+            GenericPointer otherp = (GenericPointer)other;
+
+            return o == otherp.o && offset == otherp.offset;
+        }
+
+        GenericPointer(Object o) {
+            this(o, UNSAFE.arrayBaseOffset(o.getClass()));
+        }
+
+        GenericPointer(long offset) {
+            this(null, offset);
+        }
+
+        public boolean isOnHeap() {
+            return o != null;
+        }
+
+        public Object getObject() {
+            return o;
+        }
+
+        public long getOffset() {
+            return offset;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/jdk/internal/misc/Unsafe/CopyMemory.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import jdk.internal.misc.Unsafe;
+import java.lang.reflect.Field;
+
+/*
+ * @test
+ * @summary Test Unsafe.copyMemory
+ * @modules java.base/jdk.internal.misc
+ */
+public class CopyMemory extends CopyCommon {
+    private CopyMemory() {
+    }
+
+    /**
+     * Run positive tests
+     *
+     * @throws RuntimeException if an error is found
+     */
+    private void testPositive() {
+        testSmallCopy(false);
+        testLargeCopy(false);
+    }
+
+    /**
+     * Run negative tests, testing corner cases and the various exceptions
+     *
+     * @throws RuntimeException if an error is found
+     */
+    private void testNegative() {
+        long bufRaw = 0;
+
+        try {
+            bufRaw = UNSAFE.allocateMemory(1024);
+            long buf = CopyCommon.alignUp(bufRaw, CopyCommon.BASE_ALIGNMENT);
+            short[] arr = new short[16];
+
+            // Check illegal sizes
+            System.out.println("Testing negative size");
+            try {
+                UNSAFE.copyMemory(null, buf, null, buf, -1);
+                throw new RuntimeException("copyMemory failed to throw IAE for size=-1");
+            } catch (IllegalArgumentException e) {
+                // good
+            }
+
+            System.out.println("Testing negative srcOffset");
+            try {
+                // Check that negative srcOffset throws an IAE
+                UNSAFE.copyMemory(arr, -1, arr, UNSAFE.arrayBaseOffset(arr.getClass()), 16);
+                throw new RuntimeException("copyMemory failed to throw IAE for srcOffset=-1");
+            } catch (IllegalArgumentException e) {
+                // good
+            }
+
+            System.out.println("Testing negative destOffset");
+            try {
+                // Check that negative dstOffset throws an IAE
+                UNSAFE.copyMemory(arr, UNSAFE.arrayBaseOffset(arr.getClass()), arr, -1, 16);
+                throw new RuntimeException("copyMemory failed to throw IAE for destOffset=-1");
+            } catch (IllegalArgumentException e) {
+                // good
+            }
+
+            System.out.println("Testing reference array");
+            try {
+                // Check that a reference array destination throws IAE
+                UNSAFE.copyMemory(null, buf, new Object[16], UNSAFE.arrayBaseOffset(Object[].class), 16);
+                throw new RuntimeException("copyMemory failed to throw IAE");
+            } catch (IllegalArgumentException e) {
+                // good
+            }
+
+            // Check that invalid source & dest pointers throw IAEs (only relevant on 32-bit platforms)
+            if (UNSAFE.addressSize() == 4) {
+                long invalidPtr = (long)1 << 35; // Pick a random bit in upper 32 bits
+
+                try {
+                    // Check that an invalid (not 32-bit clean) source pointer throws IAE
+                    UNSAFE.copyMemory(null, invalidPtr, null, buf, 16);
+                    throw new RuntimeException("copyMemory failed to throw IAE for srcOffset 0x" +
+                                               Long.toHexString(invalidPtr));
+                } catch (IllegalArgumentException e) {
+                    // good
+                }
+
+                try {
+                    // Check that an invalid (not 32-bit clean) source pointer throws IAE
+                    UNSAFE.copyMemory(null, buf, null, invalidPtr, 16);
+                    throw new RuntimeException("copyMemory failed to throw IAE for destOffset 0x" +
+                                               Long.toHexString(invalidPtr));
+                } catch (IllegalArgumentException e) {
+                    // good
+                }
+            }
+        } finally {
+            if (bufRaw != 0) {
+                UNSAFE.freeMemory(bufRaw);
+            }
+        }
+    }
+
+    /**
+     * Run all tests
+     *
+     * @throws RuntimeException if an error is found
+     */
+    private void test() {
+        testPositive();
+        testNegative();
+    }
+
+    public static void main(String[] args) {
+        CopyMemory cs = new CopyMemory();
+        cs.test();
+    }
+}
--- a/jdk/test/jdk/internal/misc/Unsafe/CopySwap.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/test/jdk/internal/misc/Unsafe/CopySwap.java	Mon Mar 28 08:41:54 2016 -0700
@@ -29,507 +29,18 @@
  * @summary Test Unsafe.copySwapMemory
  * @modules java.base/jdk.internal.misc
  */
-public class CopySwap {
-    private static final boolean DEBUG = Boolean.getBoolean("CopySwap.DEBUG");
-
-    public static final long KB = 1024;
-    public static final long MB = KB * 1024;
-    public static final long GB = MB * 1024;
-
-    private static final Unsafe UNSAFE;
-    private static final int SMALL_COPY_SIZE = 32;
-    private static final int BASE_ALIGNMENT = 16;
-
-    static {
-        try {
-            Field f = jdk.internal.misc.Unsafe.class.getDeclaredField("theUnsafe");
-            f.setAccessible(true);
-            UNSAFE = (jdk.internal.misc.Unsafe) f.get(null);
-        } catch (Exception e) {
-            throw new RuntimeException("Unable to get Unsafe instance.", e);
-        }
-    }
-
-    private static long alignDown(long value, long alignment) {
-        return value & ~(alignment - 1);
-    }
-
-    private static long alignUp(long value, long alignment) {
-        return (value + alignment - 1) & ~(alignment - 1);
-    }
-
-    private static boolean isAligned(long value, long alignment) {
-        return value == alignDown(value, alignment);
-    }
-
+public class CopySwap extends CopyCommon {
     private CopySwap() {
     }
 
     /**
-     * Generate verification data for a given offset
-     *
-     * The verification data is used to verify that the correct bytes
-     * have indeed been copied and byte swapped.
-     *
-     * The data is generated based on the offset (in bytes) into the
-     * source buffer. For a native buffer the offset is relative to
-     * the base pointer. For a heap array it is relative to the
-     * address of the first array element.
-     *
-     * This method will return the result of doing an elementSize byte
-     * read starting at offset (in bytes).
-     *
-     * @param offset offset into buffer
-     * @param elemSize size (in bytes) of the element
-     *
-     * @return the verification data, only the least significant
-     * elemSize*8 bits are set, zero extended
-     */
-    private long getVerificationDataForOffset(long offset, long elemSize) {
-        byte[] bytes = new byte[(int)elemSize];
-
-        for (long i = 0; i < elemSize; i++) {
-            bytes[(int)i] = (byte)(offset + i);
-        }
-
-        long o = UNSAFE.arrayBaseOffset(byte[].class);
-
-        switch ((int)elemSize) {
-        case 1: return Byte.toUnsignedLong(UNSAFE.getByte(bytes, o));
-        case 2: return Short.toUnsignedLong(UNSAFE.getShortUnaligned(bytes, o));
-        case 4: return Integer.toUnsignedLong(UNSAFE.getIntUnaligned(bytes, o));
-        case 8: return UNSAFE.getLongUnaligned(bytes, o);
-        default: throw new IllegalArgumentException("Invalid element size: " + elemSize);
-        }
-    }
-
-    /**
-     * Verify byte swapped data
-     *
-     * @param ptr the data to verify
-     * @param srcOffset the srcOffset (in bytes) from which the copy started,
-     *        used as key to regenerate the verification data
-     * @param dstOffset the offset (in bytes) in the array at which to start
-     *        the verification, relative to the first element in the array
-     * @param size size (in bytes) of data to to verify
-     * @param elemSize size (in bytes) of the individual array elements
-     *
-     * @throws RuntimeException if an error is found
-     */
-    private void verifySwappedData(GenericPointer ptr, long srcOffset, long dstOffset, long size, long elemSize) {
-        for (long offset = 0; offset < size; offset += elemSize) {
-            long expectedUnswapped = getVerificationDataForOffset(srcOffset + offset, elemSize);
-            long expected = byteSwap(expectedUnswapped, elemSize);
-
-            long actual = getArrayElem(ptr, dstOffset + offset, elemSize);
-
-            if (expected != actual) {
-                throw new RuntimeException("srcOffset: 0x" + Long.toHexString(srcOffset) +
-                                           " dstOffset: 0x" + Long.toHexString(dstOffset) +
-                                           " size: 0x" + Long.toHexString(size) +
-                                           " offset: 0x" + Long.toHexString(offset) +
-                                           " expectedUnswapped: 0x" + Long.toHexString(expectedUnswapped) +
-                                           " expected: 0x" + Long.toHexString(expected) +
-                                           " != actual: 0x" + Long.toHexString(actual));
-            }
-        }
-    }
-
-    /**
-     * Initialize an array with verification friendly data
-     *
-     * @param ptr pointer to the data to initialize
-     * @param size size (in bytes) of the data
-     * @param elemSize size (in bytes) of the individual elements
-     */
-    private void initVerificationData(GenericPointer ptr, long size, long elemSize) {
-        for (long offset = 0; offset < size; offset++) {
-            byte data = (byte)getVerificationDataForOffset(offset, 1);
-
-            if (ptr.isOnHeap()) {
-                UNSAFE.putByte(ptr.getObject(), ptr.getOffset() + offset, data);
-            } else {
-                UNSAFE.putByte(ptr.getOffset() + offset, data);
-            }
-        }
-    }
-
-    /**
-     * Allocate a primitive array
-     *
-     * @param size size (in bytes) of all the array elements (elemSize * length)
-     * @param elemSize the size of the array elements
-     *
-     * @return a newly allocated primitive array
-     */
-    Object allocArray(long size, long elemSize) {
-        int length = (int)(size / elemSize);
-
-        switch ((int)elemSize) {
-        case 2: return new short[length];
-        case 4: return new int[length];
-        case 8: return new long[length];
-        default:
-            throw new IllegalArgumentException("Invalid element size: " + elemSize);
-        }
-    }
-
-    /**
-     * Get the value of a primitive array entry
-     *
-     * @param ptr pointer to the data
-     * @param offset offset (in bytes) of the array element, relative to the first element in the array
-     *
-     * @return the array element, as an unsigned long
-     */
-    private long getArrayElem(GenericPointer ptr, long offset, long elemSize) {
-        if (ptr.isOnHeap()) {
-            Object o = ptr.getObject();
-            int index = (int)(offset / elemSize);
-
-            if (o instanceof short[]) {
-                short[] arr = (short[])o;
-                return Short.toUnsignedLong(arr[index]);
-            } else if (o instanceof int[]) {
-                int[] arr = (int[])o;
-                return Integer.toUnsignedLong(arr[index]);
-            } else if (o instanceof long[]) {
-                long[] arr = (long[])o;
-                return arr[index];
-            } else {
-                throw new IllegalArgumentException("Invalid object type: " + o.getClass().getName());
-            }
-        } else {
-            long addr = ptr.getOffset() + offset;
-
-            switch ((int)elemSize) {
-            case 1: return Byte.toUnsignedLong(UNSAFE.getByte(addr));
-            case 2: return Short.toUnsignedLong(UNSAFE.getShortUnaligned(null, addr));
-            case 4: return Integer.toUnsignedLong(UNSAFE.getIntUnaligned(null, addr));
-            case 8: return UNSAFE.getLongUnaligned(null, addr);
-            default: throw new IllegalArgumentException("Invalid element size: " + elemSize);
-            }
-        }
-    }
-
-    private void putValue(long addr, long elemSize, long value) {
-        switch ((int)elemSize) {
-        case 1: UNSAFE.putByte(addr, (byte)value); break;
-        case 2: UNSAFE.putShortUnaligned(null, addr, (short)value); break;
-        case 4: UNSAFE.putIntUnaligned(null, addr, (int)value); break;
-        case 8: UNSAFE.putLongUnaligned(null, addr, value); break;
-        default: throw new IllegalArgumentException("Invalid element size: " + elemSize);
-        }
-    }
-
-    /**
-     * Get the size of the elements for an array
-     *
-     * @param o a primitive heap array
-     *
-     * @return the size (in bytes) of the individual array elements
-     */
-    private long getArrayElemSize(Object o) {
-        if (o instanceof short[]) {
-            return 2;
-        } else if (o instanceof int[]) {
-            return 4;
-        } else if (o instanceof long[]) {
-            return 8;
-        } else {
-            throw new IllegalArgumentException("Invalid object type: " + o.getClass().getName());
-        }
-    }
-
-    /**
-     * Byte swap a value
-     *
-     * @param value the value to swap, only the bytes*8 least significant bits are used
-     * @param size size (in bytes) of the value
-     *
-     * @return the byte swapped value in the bytes*8 least significant bits
-     */
-    private long byteSwap(long value, long size) {
-        switch ((int)size) {
-        case 2: return Short.toUnsignedLong(Short.reverseBytes((short)value));
-        case 4: return Integer.toUnsignedLong(Integer.reverseBytes((int)value));
-        case 8: return Long.reverseBytes(value);
-        default: throw new IllegalArgumentException("Invalid element size: " + size);
-        }
-    }
-
-    /**
-     * Verify data in a heap array which has *not* been byte swapped
-     *
-     * @param ptr the data to verify
-     * @param startOffset the offset (in bytes) at which to start the verification
-     * @param size size (in bytes) of the data to verify
-     *
-     * @throws RuntimeException if an error is found
-     */
-    private void verifyUnswappedData(GenericPointer ptr, long startOffset, long size) {
-        for (long elemOffset = startOffset; elemOffset < startOffset + size; elemOffset++) {
-            byte expected = (byte)getVerificationDataForOffset(elemOffset, 1);
-
-            byte actual;
-            if (ptr.isOnHeap()) {
-                actual = UNSAFE.getByte(ptr.getObject(), ptr.getOffset() + elemOffset);
-            } else {
-                actual = UNSAFE.getByte(ptr.getOffset() + elemOffset);
-            }
-
-            if (expected != actual) {
-                throw new RuntimeException("startOffset: 0x" + Long.toHexString(startOffset) +
-                                           " size: 0x" + Long.toHexString(size) +
-                                           " elemOffset: 0x" + Long.toHexString(elemOffset) +
-                                           " expected: 0x" + Long.toHexString(expected) +
-                                           " != actual: 0x" + Long.toHexString(actual));
-            }
-        }
-    }
-
-
-    /**
-     * Copy and byte swap data from the source to the destination
-     *
-     * This method will pre-populate the whole source and destination
-     * buffers with verification friendly data. It will then use
-     * copySwapMemory to fill part of the destination buffer with
-     * swapped data from the source. Some space (padding) will be
-     * left before and after the data in the destination buffer, which
-     * should not be touched/overwritten by the copy call.
-     *
-     * Note: Both source and destination buffers will be overwritten!
-     *
-     * @param src source buffer to copy from
-     * @param srcOffset the offset (in bytes) in the source buffer, relative to
-     *        the first array element, at which to start reading data
-     * @param dst destination buffer to copy to
-     * @param dstOffset the offset (in bytes) in the destination
-     *        buffer, relative to the first array element, at which to
-     *        start writing data
-     * @param bufSize the size (in bytes) of the src and dst arrays
-     * @param copyBytes the size (in bytes) of the copy to perform,
-     *        must be a multiple of elemSize
-     * @param elemSize the size (in bytes) of the elements to byte swap
-     *
-     * @throws RuntimeException if an error is found
-     */
-    private void testCopySwap(GenericPointer src, long srcOffset,
-                              GenericPointer dst, long dstOffset,
-                              long bufSize, long copyBytes, long elemSize) {
-        if (!isAligned(copyBytes, elemSize)) {
-            throw new IllegalArgumentException(
-                "copyBytes (" + copyBytes + ") must be a multiple of elemSize (" + elemSize + ")");
-        }
-        if (src.isOnHeap() && !isAligned(srcOffset, elemSize)) {
-            throw new IllegalArgumentException(
-                "srcOffset (" + srcOffset + ") must be a multiple of elemSize (" + elemSize + ")");
-        }
-        if (dst.isOnHeap() && !isAligned(dstOffset, elemSize)) {
-            throw new IllegalArgumentException(
-                "dstOffset (" + dstOffset + ") must be a multiple of elemSize (" + elemSize + ")");
-        }
-        if (srcOffset + copyBytes > bufSize) {
-            throw new IllegalArgumentException(
-                "srcOffset (" + srcOffset + ") + copyBytes (" + copyBytes + ") > bufSize (" + bufSize + ")");
-        }
-        if (dstOffset + copyBytes > bufSize) {
-            throw new IllegalArgumentException(
-                "dstOffset (" + dstOffset + ") + copyBytes (" + copyBytes + ") > bufSize (" + bufSize + ")");
-        }
-
-        // Initialize the whole source buffer with a verification friendly pattern (no 0x00 bytes)
-        initVerificationData(src, bufSize, elemSize);
-        if (!src.equals(dst)) {
-            initVerificationData(dst, bufSize, elemSize);
-        }
-
-        if (DEBUG) {
-            System.out.println("===before===");
-            for (int offset = 0; offset < bufSize; offset += elemSize) {
-                long srcValue = getArrayElem(src, offset, elemSize);
-                long dstValue = getArrayElem(dst, offset, elemSize);
-
-                System.out.println("offs=0x" + Long.toHexString(Integer.toUnsignedLong(offset)) +
-                                 " src=0x" + Long.toHexString(srcValue) +
-                                 " dst=0x" + Long.toHexString(dstValue));
-            }
-        }
-
-        // Copy & swap data into the middle of the destination buffer
-        UNSAFE.copySwapMemory(src.getObject(),
-                              src.getOffset() + srcOffset,
-                              dst.getObject(),
-                              dst.getOffset() + dstOffset,
-                              copyBytes,
-                              elemSize);
-
-        if (DEBUG) {
-            System.out.println("===after===");
-            for (int offset = 0; offset < bufSize; offset += elemSize) {
-                long srcValue = getArrayElem(src, offset, elemSize);
-                long dstValue = getArrayElem(dst, offset, elemSize);
-
-                System.out.println("offs=0x" + Long.toHexString(Integer.toUnsignedLong(offset)) +
-                                 " src=0x" + Long.toHexString(srcValue) +
-                                 " dst=0x" + Long.toHexString(dstValue));
-            }
-        }
-
-        // Verify the the front padding is unchanged
-        verifyUnswappedData(dst, 0, dstOffset);
-
-        // Verify swapped data
-        verifySwappedData(dst, srcOffset, dstOffset, copyBytes, elemSize);
-
-        // Verify that the back back padding is unchanged
-        long frontAndDataBytes = dstOffset + copyBytes;
-        long trailingBytes = bufSize - frontAndDataBytes;
-        verifyUnswappedData(dst, frontAndDataBytes, trailingBytes);
-    }
-
-    /**
-     * Test various configurations copy-swapping from one buffer to the other
-     *
-     * @param src the source buffer to copy from
-     * @param dst the destination buffer to copy to
-     * @param size size (in bytes) of the buffers
-     * @param elemSize size (in bytes) of the individual elements
-     *
-     * @throws RuntimeException if an error is found
-     */
-    public void testBufferPair(GenericPointer src, GenericPointer dst, long size, long elemSize) {
-        // offset in source from which to start reading data
-        for (long srcOffset = 0; srcOffset < size; srcOffset += (src.isOnHeap() ? elemSize : 1)) {
-
-            // offset in destination at which to start writing data
-            for (int dstOffset = 0; dstOffset < size; dstOffset += (dst.isOnHeap() ? elemSize : 1)) {
-
-                // number of bytes to copy
-                long maxCopyBytes = Math.min(size - srcOffset, size - dstOffset);
-                for (long copyBytes = 0; copyBytes < maxCopyBytes; copyBytes += elemSize) {
-                    try {
-                        testCopySwap(src, srcOffset, dst, dstOffset, size, copyBytes, elemSize);
-                    } catch (RuntimeException e) {
-                        // Wrap the exception in another exception to catch the relevant configuration data
-                        throw new RuntimeException("testBufferPair: " +
-                                                   "src=" + src +
-                                                   " dst=" + dst +
-                                                   " elemSize=0x" + Long.toHexString(elemSize) +
-                                                   " copyBytes=0x" + Long.toHexString(copyBytes) +
-                                                   " srcOffset=0x" + Long.toHexString(srcOffset) +
-                                                   " dstOffset=0x" + Long.toHexString(dstOffset),
-                                                   e);
-                    }
-                }
-            }
-        }
-    }
-
-    /**
-     * Test copying between various permutations of buffers
-     *
-     * @param buffers buffers to permute (src x dst)
-     * @param size size (in bytes) of buffers
-     * @param elemSize size (in bytes) of individual elements
-     *
-     * @throws RuntimeException if an error is found
-     */
-    public void testPermuteBuffers(GenericPointer[] buffers, long size, long elemSize) {
-        for (int srcIndex = 0; srcIndex < buffers.length; srcIndex++) {
-            for (int dstIndex = 0; dstIndex < buffers.length; dstIndex++) {
-                testBufferPair(buffers[srcIndex], buffers[dstIndex], size, elemSize);
-            }
-        }
-    }
-
-    /**
-     * Test copying of a specific element size
-     *
-     * @param size size (in bytes) of buffers to allocate
-     * @param elemSize size (in bytes) of individual elements
-     *
-     * @throws RuntimeException if an error is found
-     */
-    private void testElemSize(long size, long elemSize) {
-        long buf1Raw = 0;
-        long buf2Raw = 0;
-
-        try {
-            buf1Raw = UNSAFE.allocateMemory(size + BASE_ALIGNMENT);
-            long buf1 = alignUp(buf1Raw, BASE_ALIGNMENT);
-
-            buf2Raw = UNSAFE.allocateMemory(size + BASE_ALIGNMENT);
-            long buf2 = alignUp(buf2Raw, BASE_ALIGNMENT);
-
-            GenericPointer[] buffers = {
-                new GenericPointer(buf1),
-                new GenericPointer(buf2),
-                new GenericPointer(allocArray(size, elemSize)),
-                new GenericPointer(allocArray(size, elemSize))
-            };
-
-            testPermuteBuffers(buffers, size, elemSize);
-        } finally {
-            if (buf1Raw != 0) {
-                UNSAFE.freeMemory(buf1Raw);
-            }
-            if (buf2Raw != 0) {
-                UNSAFE.freeMemory(buf2Raw);
-            }
-        }
-    }
-
-    /**
-     * Verify that small copy swaps work
-     */
-    private void testSmallCopy() {
-        int smallBufSize = SMALL_COPY_SIZE;
-
-        // Test various element types and heap/native combinations
-        for (long elemSize = 2; elemSize <= 8; elemSize <<= 1) {
-            testElemSize(smallBufSize, elemSize);
-        }
-    }
-
-
-    /**
-     * Verify that large copy swaps work
-     */
-    private void testLargeCopy() {
-        long size = 2 * GB + 8;
-        long bufRaw = 0;
-
-        // Check that a large native copy succeeds
-        try {
-            try {
-                bufRaw = UNSAFE.allocateMemory(size + BASE_ALIGNMENT);
-            } catch (OutOfMemoryError e) {
-                // Accept failure, skip test
-                return;
-            }
-
-            long buf = alignUp(bufRaw, BASE_ALIGNMENT);
-
-            UNSAFE.copySwapMemory(null, buf, null, buf, size, 8);
-        } catch (Exception e) {
-            throw new RuntimeException("copySwapMemory of large buffer failed");
-        } finally {
-            if (bufRaw != 0) {
-                UNSAFE.freeMemory(bufRaw);
-            }
-        }
-    }
-
-    /**
      * Run positive tests
      *
      * @throws RuntimeException if an error is found
      */
     private void testPositive() {
-        testSmallCopy();
-        testLargeCopy();
+        testSmallCopy(true);
+        testLargeCopy(true);
     }
 
     /**
@@ -542,7 +53,7 @@
 
         try {
             bufRaw = UNSAFE.allocateMemory(1024);
-            long buf = alignUp(bufRaw, BASE_ALIGNMENT);
+            long buf = CopyCommon.alignUp(bufRaw, CopyCommon.BASE_ALIGNMENT);
             short[] arr = new short[16];
 
             // Check various illegal element sizes
@@ -587,22 +98,6 @@
             }
 
             try {
-                // Check that a NULL source throws NPE
-                UNSAFE.copySwapMemory(null, 0, null, buf, 16, 2);
-                throw new RuntimeException("copySwapMemory failed to throw NPE");
-            } catch (NullPointerException e) {
-                // good
-            }
-
-            try {
-                // Check that a NULL destination throws NPE
-                UNSAFE.copySwapMemory(null, buf, null, 0, 16, 2);
-                throw new RuntimeException("copySwapMemory failed to throw NPE");
-            } catch (NullPointerException e) {
-                // good
-            }
-
-            try {
                 // Check that a reference array destination throws IAE
                 UNSAFE.copySwapMemory(null, buf, new Object[16], UNSAFE.arrayBaseOffset(Object[].class), 16, 8);
                 throw new RuntimeException("copySwapMemory failed to throw NPE");
@@ -653,59 +148,4 @@
         CopySwap cs = new CopySwap();
         cs.test();
     }
-
-    /**
-     * Helper class to represent a "pointer" - either a heap array or
-     * a pointer to a native buffer.
-     *
-     * In the case of a native pointer, the Object is null and the offset is
-     * the absolute address of the native buffer.
-     *
-     * In the case of a heap object, the Object is a primitive array, and
-     * the offset will be set to the base offset to the first element, meaning
-     * the object and the offset together form a double-register pointer.
-     */
-    static class GenericPointer {
-        private final Object o;
-        private final long offset;
-
-        private GenericPointer(Object o, long offset) {
-            this.o = o;
-            this.offset = offset;
-        }
-
-        public String toString() {
-            return "GenericPointer(o={" + o + "}, offset=0x" + Long.toHexString(offset) + ")";
-        }
-
-        public boolean equals(Object other) {
-            if (!(other instanceof GenericPointer)) {
-                return false;
-            }
-
-            GenericPointer otherp = (GenericPointer)other;
-
-            return o == otherp.o && offset == otherp.offset;
-        }
-
-        GenericPointer(Object o) {
-            this(o, UNSAFE.arrayBaseOffset(o.getClass()));
-        }
-
-        GenericPointer(long offset) {
-            this(null, offset);
-        }
-
-        public boolean isOnHeap() {
-            return o != null;
-        }
-
-        public Object getObject() {
-            return o;
-        }
-
-        public long getOffset() {
-            return offset;
-        }
-    }
 }
--- a/jdk/test/sun/net/idn/TestStringPrep.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/test/sun/net/idn/TestStringPrep.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,7 @@
 /*
  * @test
  * @summary Unit test for sun.net.idn.Punycode
- * @bug 4737170
+ * @bug 4737170 8060097
  * @modules java.base/sun.net.idn java.base/sun.text.normalizer
  * @library .
  * @compile -XDignore.symbol.file TestStringPrep.java NFS4StringPrep.java
@@ -41,6 +41,7 @@
 
 import java.text.ParseException;
 import java.io.InputStream;
+import java.util.Locale;
 
 import sun.net.idn.StringPrep;
 import sun.text.normalizer.UCharacterIterator;
@@ -209,7 +210,7 @@
             src = "THISISATEST";
             byte[] dest = NFS4StringPrep.cs_prepare(src.getBytes("UTF-8"), false);
             String destStr = new String(dest, "UTF-8");
-            if(!src.toLowerCase().equals(destStr)){
+            if(!src.toLowerCase(Locale.ROOT).equals(destStr)){
                 fail("Did not get expected output. Expected: "+ prettify(src)+
                       " Got: " + prettify(destStr));
             }
@@ -275,7 +276,7 @@
 
     private static String hex(char ch) {
         StringBuffer result = new StringBuffer();
-        String foo = Integer.toString(ch,16).toUpperCase();
+        String foo = Integer.toString(ch,16).toUpperCase(Locale.ROOT);
         for (int i = foo.length(); i < 4; ++i) {
             result.append('0');
         }
--- a/jdk/test/sun/security/jca/PreferredProviderNegativeTest.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/test/sun/security/jca/PreferredProviderNegativeTest.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,55 +21,52 @@
  * questions.
  */
 
-/**
- * @test
- * @bug 8076359 8133151
- * @summary Test for jdk.security.provider.preferred security property
- * @requires os.name == "SunOS"
- * @run main/othervm  PreferredProviderNegativeTest preJCESet AES:OracleUcrypto false
- * @run main/othervm  PreferredProviderNegativeTest preJCESet AES:SunNegative true
- * @run main/othervm  PreferredProviderNegativeTest afterJCESet AES:SunJGSS
- * @run main/othervm  PreferredProviderNegativeTest afterJCESet AES:SunECNegative
- * @run main/othervm  PreferredProviderNegativeTest invalidAlg AESNegative:SunJCE
- */
-
 import java.security.Security;
 import java.security.NoSuchAlgorithmException;
 import javax.crypto.Cipher;
 import javax.crypto.NoSuchPaddingException;
 
+/**
+ * @test
+ * @bug 8076359 8133151 8150512
+ * @summary Test for jdk.security.provider.preferred security property
+ * @run main/othervm  PreferredProviderNegativeTest preSet AES false
+ * @run main/othervm  PreferredProviderNegativeTest preSet AES:SunNegative true
+ * @run main/othervm  PreferredProviderNegativeTest afterSet AES:SunJGSS
+ * @run main/othervm  PreferredProviderNegativeTest afterSet AES:SunECNegative
+ * @run main/othervm  PreferredProviderNegativeTest invalidAlg AESInvalid:SunJCE
+ */
 public class PreferredProviderNegativeTest {
 
+    static final String SEC_PREF_PROP = "jdk.security.provider.preferred";
+
     /*
      * Test security property could be set by valid and invalid provider
      * before JCE was loaded
      */
     public static void preJCESet(String value, boolean negativeProvider)
             throws NoSuchAlgorithmException, NoSuchPaddingException {
-        Security.setProperty("jdk.security.provider.preferred", value);
+
+        Security.setProperty(SEC_PREF_PROP, value);
 
-        if (!Security.getProperty("jdk.security.provider.preferred")
-                .equals(value)) {
-            throw new RuntimeException(
-                    "Test Failed:The property wasn't set");
+        if (!Security.getProperty(SEC_PREF_PROP).equals(value)) {
+            throw new RuntimeException("Test Failed:The property wasn't set");
         }
 
         String[] arrays = value.split(":");
         Cipher cipher = Cipher.getInstance(arrays[0]);
-
         if (negativeProvider) {
             if (cipher.getProvider().getName().equals(arrays[1])) {
                 throw new RuntimeException(
-                        "Test Failed:The provider shouldn't be set");
+                        "Test Failed:The provider shouldn't be set.");
             }
         } else {
             if (!cipher.getProvider().getName().equals(arrays[1])) {
-                throw new RuntimeException(
-                        "Test Faild:The provider could be set "
-                                + "by valid provider ");
+                throw new RuntimeException("Test Faild:The provider could be "
+                        + "set by valid provider.");
             }
         }
-        System.out.println("Test Pass");
+        System.out.println("Test Pass.");
     }
 
     /*
@@ -81,10 +78,10 @@
         String[] arrays = value.split(":");
         Cipher cipher = Cipher.getInstance(arrays[0]);
 
-        Security.setProperty("jdk.security.provider.preferred", value);
+        Security.setProperty(SEC_PREF_PROP, value);
         if (!cipher.getProvider().getName().equals("SunJCE")) {
-            throw new RuntimeException(
-                    "Test Failed:The security property can't be updated after JCE load.");
+            throw new RuntimeException("Test Failed:The security property can't"
+                    + " be updated after JCE load.");
         }
         System.out.println("Test Pass");
     }
@@ -94,10 +91,11 @@
         String[] arrays = value.split(":");
 
         try {
-            Security.setProperty("jdk.security.provider.preferred", value);
+            Security.setProperty(SEC_PREF_PROP, value);
             Cipher.getInstance(arrays[0]);
         } catch (NoSuchAlgorithmException e) {
-            System.out.println("Test Pass:Got NoSuchAlgorithmException as expired");
+            System.out.println(
+                    "Test Pass:Got NoSuchAlgorithmException as expired");
             return;
         }
         throw new RuntimeException(
@@ -106,15 +104,25 @@
 
     public static void main(String[] args)
             throws NoSuchAlgorithmException, NoSuchPaddingException {
-        boolean negativeProvider;
 
         if (args.length >= 2) {
             switch (args[0]) {
-                case "preJCESet":
-                    negativeProvider = Boolean.valueOf(args[2]);
-                    PreferredProviderNegativeTest.preJCESet(args[1], negativeProvider);
+                case "preSet":
+                    boolean negativeProvider = Boolean.valueOf(args[2]);
+                    boolean solaris = System.getProperty("os.name")
+                            .toLowerCase().contains("sun");
+                    String value = args[1];
+                    if (args[1].split(":").length < 2) {
+                        if (solaris) {
+                            value += ":OracleUcrypto";
+                        } else {
+                            value += ":SunJCE";
+                        }
+                    }
+                    PreferredProviderNegativeTest.preJCESet(
+                            value, negativeProvider);
                     break;
-                case "afterJCESet":
+                case "afterSet":
                     PreferredProviderNegativeTest.afterJCESet(args[1]);
                     break;
                 case "invalidAlg":
@@ -127,4 +135,3 @@
         }
     }
 }
-
--- a/jdk/test/sun/security/jca/PreferredProviderTest.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/test/sun/security/jca/PreferredProviderTest.java	Mon Mar 28 08:41:54 2016 -0700
@@ -21,97 +21,131 @@
  * questions.
  */
 
-/**
- * @test
- * @bug 8076359 8133151 8145344
- * @summary Test the value for new jdk.security.provider.preferred security property
- * @requires os.name == "SunOS"
- */
-
+import java.security.MessageDigest;
 import java.security.KeyFactory;
-import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.security.Security;
+import java.security.Provider;
 import java.util.Arrays;
 import java.util.List;
 import javax.crypto.Cipher;
 import javax.crypto.NoSuchPaddingException;
 
+/**
+ * @test
+ * @bug 8076359 8133151 8145344 8150512
+ * @summary Test the value for new jdk.security.provider.preferred
+ *          security property
+ */
 public class PreferredProviderTest {
 
-    private static final List<DataTuple> SPARC_DATA = Arrays.asList(
-            new DataTuple("SHA1", "SUN"), new DataTuple("SHA-1", "SUN"),
-            new DataTuple("SHA-224", "SUN"), new DataTuple("SHA-256", "SUN"),
-            new DataTuple("SHA-384", "SUN"), new DataTuple("SHA-512", "SUN"));
-    private static final List<DataTuple> X86_DATA = Arrays
-            .asList(new DataTuple("RSA", "SunRsaSign"));
-
-    public void RunTest(String type)
+    public void RunTest(String type, String os)
             throws NoSuchAlgorithmException, NoSuchPaddingException {
-        String preferredProvider = Security
-                .getProperty("jdk.security.provider.preferred");
+
         String actualProvider = null;
-        if (type.equals("sparcv9")) {
-            if (!preferredProvider.equals(
-                    "AES:SunJCE, SHA1:SUN, SHA-224:SUN, SHA-256:SUN, SHA-384:SUN, SHA-512:SUN")) {
-                throw new RuntimeException(
-                        "Test Failed: wrong jdk.security.provider.preferred "
-                                + "value on solaris-sparcv9");
+        boolean solaris = os.contains("sun");
+        String preferredProp
+                = "AES/GCM/NoPadding:SunJCE, MessageDigest.SHA-256:SUN";
+        System.out.printf("%nExecuting test for the platform '%s'%n", os);
+        if (!solaris) {
+            //For other platform it will try to set the preferred algorithm and
+            //Provider and verify the usage of it.
+            Security.setProperty(
+                    "jdk.security.provider.preferred", preferredProp);
+            verifyPreferredProviderProperty(os, type, preferredProp);
+
+            verifyDigestProvider(os, type, Arrays.asList(
+                    new DataTuple("SHA-256", "SUN")));
+        } else {
+            //For solaris the preferred algorithm/provider is already set in
+            //java.security file which will be verified.
+            switch (type) {
+                case "sparcv9":
+                    preferredProp = "AES:SunJCE, SHA1:SUN, SHA-224:SUN,"
+                            + " SHA-256:SUN, SHA-384:SUN, SHA-512:SUN";
+                    verifyPreferredProviderProperty(os, type, preferredProp);
+
+                    verifyDigestProvider(os, type, Arrays.asList(
+                            new DataTuple("SHA1", "SUN"),
+                            new DataTuple("SHA-1", "SUN"),
+                            new DataTuple("SHA-224", "SUN"),
+                            new DataTuple("SHA-256", "SUN"),
+                            new DataTuple("SHA-384", "SUN"),
+                            new DataTuple("SHA-512", "SUN")));
+                    break;
+                case "amd64":
+                    preferredProp = "AES:SunJCE, RSA:SunRsaSign";
+                    verifyPreferredProviderProperty(os, type, preferredProp);
+
+                    verifyKeyFactoryProvider(os, type, Arrays.asList(
+                            new DataTuple("RSA", "SunRsaSign")));
+                    break;
             }
-            for (DataTuple dataTuple : SPARC_DATA) {
-                MessageDigest md = MessageDigest
-                        .getInstance(dataTuple.algorithm);
-                actualProvider = md.getProvider().getName();
-                if (!actualProvider.equals(dataTuple.provider)) {
-                    throw new RuntimeException(String.format(
-                            "Test Failed:Got wrong "
-                                    + "provider from Solaris-sparcv9 platform,"
-                                    + "Expected Provider: %s, Returned Provider: %s",
-                            dataTuple.provider, actualProvider));
-                }
-            }
-        } else if (type.equals("amd64")) {
-            if (!preferredProvider.equals("AES:SunJCE, RSA:SunRsaSign")) {
-                throw new RuntimeException(
-                        "Test Failed: wrong jdk.security.provider.preferred "
-                                + "value on solaris-x86");
-            }
-            for (DataTuple dataTuple : X86_DATA) {
-                KeyFactory keyFactory = KeyFactory
-                        .getInstance(dataTuple.algorithm);
-                actualProvider = keyFactory.getProvider().getName();
-                if (!actualProvider.equals(dataTuple.provider)) {
-                    throw new RuntimeException(String.format(
-                            "Test Failed:Got wrong "
-                                    + "provider from Solaris-x86 platform,"
-                                    + "Expected Provider: %s, Returned Provider: %s",
-                            dataTuple.provider, actualProvider));
-                }
-            }
-        } else {
-            throw new RuntimeException("Test Failed: wrong platform value");
+            verifyDigestProvider(os, type, Arrays.asList(
+                    new DataTuple("MD5", "OracleUcrypto")));
         }
 
         Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
         actualProvider = cipher.getProvider().getName();
         if (!actualProvider.equals("SunJCE")) {
+            throw new RuntimeException(String.format("Test Failed:Got wrong "
+                    + "provider from %s-%s platform, Expected Provider: SunJCE,"
+                    + " Returned Provider: %s", os, type, actualProvider));
+        }
+    }
+
+    private static void verifyPreferredProviderProperty(String os, String arch,
+            String preferred) {
+        String preferredProvider
+                = Security.getProperty("jdk.security.provider.preferred");
+        if (!preferredProvider.equals(preferred)) {
             throw new RuntimeException(String.format(
-                    "Test Failed:Got wrong provider from Solaris-%s platform, "
-                            + "Expected Provider: SunJCE, Returned Provider: %s",
-                    type, actualProvider));
+                    "Test Failed: wrong jdk.security.provider.preferred value "
+                    + "on %s-%s", os, arch));
         }
+        System.out.println(
+                "Preferred provider security property verification complete.");
+    }
 
-        MessageDigest md = MessageDigest.getInstance("MD5");
-        actualProvider = md.getProvider().getName();
-        if (!actualProvider.equals("OracleUcrypto")) {
+    private static void verifyDigestProvider(String os, String arch,
+            List<DataTuple> algoProviders) throws NoSuchAlgorithmException {
+        for (DataTuple dataTuple : algoProviders) {
+            System.out.printf(
+                    "Verifying MessageDigest for '%s'%n", dataTuple.algorithm);
+            MessageDigest md = MessageDigest.getInstance(dataTuple.algorithm);
+            matchProvider(md.getProvider(), dataTuple.provider,
+                    dataTuple.algorithm, os, arch);
+        }
+        System.out.println(
+                "Preferred MessageDigest algorithm verification successful.");
+    }
+
+    private static void verifyKeyFactoryProvider(String os, String arch,
+            List<DataTuple> algoProviders) throws NoSuchAlgorithmException {
+        for (DataTuple dataTuple : algoProviders) {
+            System.out.printf(
+                    "Verifying KeyFactory for '%s'%n", dataTuple.algorithm);
+            KeyFactory kf = KeyFactory.getInstance(dataTuple.algorithm);
+            matchProvider(kf.getProvider(), dataTuple.provider,
+                    dataTuple.algorithm, os, arch);
+        }
+        System.out.println(
+                "Preferred KeyFactory algorithm verification successful.");
+    }
+
+    private static void matchProvider(Provider provider, String expected,
+            String algo, String os, String arch) {
+        if (!provider.getName().equals(expected)) {
             throw new RuntimeException(String.format(
-                    "Test Failed:Got wrong provider from Solaris-%s platform,"
-                            + "Expected Provider: OracleUcrypto, Returned Provider: %s",
-                    type, actualProvider));
+                    "Test Failed:Got wrong provider from %s-%s platform, "
+                    + "for algorithm %s. Expected Provider: %s,"
+                    + " Returned Provider: %s", os, arch, algo,
+                    expected, provider.getName()));
         }
     }
 
     private static class DataTuple {
+
         private final String provider;
         private final String algorithm;
 
@@ -123,10 +157,9 @@
 
     public static void main(String[] args)
             throws NoSuchAlgorithmException, NoSuchPaddingException {
-
-        String arch = System.getProperty("os.arch");
+        String os = System.getProperty("os.name").toLowerCase();
+        String arch = System.getProperty("os.arch").toLowerCase();
         PreferredProviderTest pp = new PreferredProviderTest();
-        pp.RunTest(arch);
+        pp.RunTest(arch, os);
     }
 }
-
--- a/jdk/test/sun/security/krb5/auto/MaxRetries.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/test/sun/security/krb5/auto/MaxRetries.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
 /*
  * @test
  * @bug 6844193
+ * @key intermittent
  * @compile -XDignore.symbol.file MaxRetries.java
  * @run main/othervm/timeout=300 MaxRetries
  * @summary support max_retries in krb5.conf
--- a/jdk/test/sun/security/krb5/auto/Unreachable.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/test/sun/security/krb5/auto/Unreachable.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
 /*
  * @test
  * @bug 7162687
+ * @key intermittent
  * @summary enhance KDC server availability detection
  * @compile -XDignore.symbol.file Unreachable.java
  * @run main/othervm/timeout=10 Unreachable
--- a/jdk/test/sun/security/mscapi/SmallPrimeExponentP.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/test/sun/security/mscapi/SmallPrimeExponentP.java	Mon Mar 28 08:41:54 2016 -0700
@@ -32,6 +32,7 @@
 /*
  * @test
  * @bug 8023546
+ * @key intermittent
  * @modules java.base/sun.security.x509
  *          java.base/sun.security.tools.keytool
  * @summary sun/security/mscapi/ShortRSAKey1024.sh fails intermittently
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/SSLSocketImpl/LargePacketAfterHandshakeTest.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,183 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+//
+// SunJSSE does not support dynamic system properties, no way to re-use
+// system properties in samevm/agentvm mode.
+//
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+
+import javax.net.ssl.SSLServerSocket;
+import javax.net.ssl.SSLServerSocketFactory;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.SSLSocketFactory;
+
+/*
+ * @test
+ * @bug 8149169
+ * @summary Test for BufferOverflowException during read from SSLSocket when
+ *          large packet is coming from server after server initiated handshake
+ * @run main/othervm LargePacketAfterHandshakeTest
+ */
+public class LargePacketAfterHandshakeTest {
+    static String pathToStores = "../../../../javax/net/ssl/etc";
+    static String keyStoreFile = "keystore";
+    static String trustStoreFile = "truststore";
+    static String passwd = "passphrase";
+
+    volatile static int serverport = -1;
+    volatile static boolean serverReady = false;
+    volatile static boolean clientDone = false;
+    volatile static Exception serverException = null;
+
+    public static void runServer() {
+        try {
+            System.out.println("Server: Started server thread.");
+            SSLServerSocketFactory ssf =
+                (SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
+            SSLServerSocket s = (SSLServerSocket)ssf.createServerSocket(0);
+            serverport = s.getLocalPort();
+            System.out.println("Server: Started, listening on port " +
+                    serverport + ".");
+            serverReady = true;
+            SSLSocket c = (SSLSocket)s.accept();
+            s.close();
+            System.out.println(
+                "Server: Accepted client connection and closed server socket.");
+            BufferedReader r = new BufferedReader(
+                    new InputStreamReader(c.getInputStream()));
+            BufferedWriter w = new BufferedWriter(
+                    new OutputStreamWriter(c.getOutputStream()));
+            String echostring = r.readLine();
+            System.out.println("Server: Read " + echostring.length() +
+                    " chars of input data.");
+            c.startHandshake();
+            System.out.println("Server: Kicked new handshake.");
+            w.write(echostring);
+            w.newLine();
+            w.flush();
+            System.out.println("Server: Echoed " + echostring.length() +
+                    " chars of input data.");
+            while (!clientDone) {
+                try {
+                    Thread.sleep(10);
+                } catch (InterruptedException e) {
+                    System.out.println("Server: Caught InterruptedException.");
+                }
+            }
+            r.close();
+            w.close();
+            c.close();
+            System.out.println(
+                    "Server: Closed streams and client socket, exiting.");
+        } catch (Exception e) {
+            System.out.println("Server: Caught Exception.");
+            e.printStackTrace();
+            serverReady = true;
+            serverException = e;
+        }
+    }
+
+    public static void runClient() throws IOException {
+        try {
+            SSLSocketFactory f =
+                    (SSLSocketFactory)SSLSocketFactory.getDefault();
+            System.out.println("Client: Initialized.");
+            while (!serverReady) {
+                try {
+                    Thread.sleep(10);
+                } catch (InterruptedException e) {
+                    System.out.println("Client: Caught InterruptedException.");
+                }
+            }
+            SSLSocket c = (SSLSocket)f.createSocket("localhost", serverport);
+            BufferedWriter w = new BufferedWriter(
+                    new OutputStreamWriter(c.getOutputStream()));
+            BufferedReader r = new BufferedReader(
+                    new InputStreamReader(c.getInputStream()));
+            System.out.println("Client: Connected.");
+            String echoPattern = "Otto";
+            StringBuilder echoBuilder =
+                    new StringBuilder(4500 + echoPattern.length());
+            while (echoBuilder.length() < 4500) {
+                echoBuilder.append(echoPattern);
+            }
+            String echostring = echoBuilder.toString();
+            w.write(echostring);
+            w.newLine();
+            w.flush();
+            System.out.println("Client: Sent " + echostring.length() +
+                    " chars of data.");
+            String echoresponse = r.readLine();
+            clientDone = true;
+            System.out.println("Client: Read " + echoresponse.length() +
+                    " chars of data.");
+            w.close();
+            r.close();
+            c.close();
+            System.out.println("Client: Closed streams and socket, exiting.");
+        } catch (IOException e) {
+            System.out.println("Client: Caught Exception.");
+            e.printStackTrace();
+            clientDone = true;
+            throw e;
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        String keyFilename = System.getProperty("test.src", "./") + "/" +
+                pathToStores + "/" + keyStoreFile;
+        String trustFilename = System.getProperty("test.src", "./") + "/" +
+                pathToStores + "/" + trustStoreFile;
+
+        System.setProperty("javax.net.ssl.keyStore", keyFilename);
+        System.setProperty("javax.net.ssl.keyStorePassword", passwd);
+        System.setProperty("javax.net.ssl.trustStore", trustFilename);
+        System.setProperty("javax.net.ssl.trustStorePassword", passwd);
+
+        Thread serverThread = new Thread() {
+            @Override
+            public void run() {
+                runServer();
+            }
+        };
+        serverThread.start();
+        runClient();
+        while (serverThread.isAlive()) {
+            try {
+                serverThread.join();
+            } catch (InterruptedException e) {
+                System.out.println("Main: Caught InterruptedException " +
+                        " waiting for server Thread.");
+            }
+        }
+        if (serverException != null) {
+            throw serverException;
+        }
+    }
+}
--- a/jdk/test/tools/jlink/SecurityTest.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/test/tools/jlink/SecurityTest.java	Mon Mar 28 08:41:54 2016 -0700
@@ -25,7 +25,7 @@
  * @test
  * @summary Test JlinkPermission
  * @author Jean-Francois Denise
- * @run main SecurityTest
+ * @run main/othervm SecurityTest
  */
 
 import java.security.AccessControlException;
@@ -36,16 +36,11 @@
     public static void main(String[] args) throws Exception {
         new Jlink();
         System.setSecurityManager(new SecurityManager());
-        boolean failed = false;
         try {
             new Jlink();
-            failed = true;
+            throw new Exception("Call should have failed");
         } catch (AccessControlException ex) {
-            //XXX OK.
+            // expected exception
         }
-        if (failed) {
-            throw new Exception("Call should have failed");
-        }
-
     }
 }
--- a/jdk/test/tools/jlink/plugins/IncludeLocalesPluginTest.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/jdk/test/tools/jlink/plugins/IncludeLocalesPluginTest.java	Mon Mar 28 08:41:54 2016 -0700
@@ -21,26 +21,18 @@
  * questions.
  */
 
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.lang.reflect.Layer;
-import java.nio.file.Files;
 import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
-import java.util.stream.Stream;
 
 import jdk.tools.jlink.plugin.Plugin;
+import jdk.tools.jlink.plugin.PluginException;
 import jdk.tools.jlink.internal.PluginRepository;
+import jdk.tools.jlink.internal.TaskHelper;
+import jdk.tools.jlink.internal.plugins.PluginsResourceBundle;
 import tests.Helper;
 import tests.JImageGenerator;
 import tests.JImageValidator;
+import tests.Result;
 
 /*
  * @test
@@ -50,6 +42,7 @@
  * @modules java.base/jdk.internal.jimage
  *          jdk.jdeps/com.sun.tools.classfile
  *          jdk.jlink/jdk.tools.jlink.internal
+ *          jdk.jlink/jdk.tools.jlink.internal.plugins
  *          jdk.jlink/jdk.tools.jmod
  *          jdk.jlink/jdk.tools.jimage
  *          jdk.compiler
@@ -65,6 +58,7 @@
     private final static int EXPECTED_LOCATIONS     = 1;
     private final static int UNEXPECTED_PATHS       = 2;
     private final static int AVAILABLE_LOCALES      = 3;
+    private final static int ERROR_MESSAGE          = 4;
 
     private final static Object[][] testData = {
         // without --include-locales option: should include all locales
@@ -144,6 +138,7 @@
             "yav_CM yo yo_BJ yo_NG zgh zgh_MA zh zh_CN zh_CN_#Hans zh_HK " +
             "zh_HK_#Hans zh_HK_#Hant zh_MO_#Hans zh_MO_#Hant zh_SG zh_SG_#Hans " +
             "zh_TW zh_TW_#Hant zh__#Hans zh__#Hant zu zu_ZA",
+            "",
         },
 
         // All English/Japanese locales
@@ -173,6 +168,7 @@
             "en_PW en_RW en_SB en_SC en_SD en_SG en_SH en_SL en_SS en_SX en_SZ " +
             "en_TC en_TK en_TO en_TT en_TV en_TZ en_UG en_UM en_US en_US_POSIX " +
             "en_VC en_VG en_VI en_VU en_WS en_ZA en_ZM en_ZW ja ja_JP ja_JP_JP_#u-ca-japanese",
+            "",
         },
 
         // All locales in India
@@ -201,6 +197,7 @@
                 "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_zh.class"),
             " as_IN bn_IN bo_IN brx_IN en en_IN en_US en_US_POSIX gu_IN hi_IN kn_IN " +
             "kok_IN ks_IN_#Arab ml_IN mr_IN ne_IN or_IN pa_IN_#Guru ta_IN te_IN ur_IN",
+            "",
         },
 
         // Thai
@@ -220,6 +217,7 @@
                 "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class",
                 "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_zh.class"),
             " en en_US en_US_POSIX th th_TH th_TH_TH_#u-nu-thai",
+            "",
         },
 
         // Hong Kong
@@ -242,6 +240,7 @@
                 "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class",
                 "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_th.class"),
             " en en_US en_US_POSIX zh_HK zh_HK_#Hans zh_HK_#Hant",
+            "",
         },
 
         // Norwegian
@@ -265,6 +264,7 @@
                 "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class",
                 "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_th.class"),
             " en en_US en_US_POSIX nb nb_NO nb_SJ nn nn_NO no no_NO no_NO_NY",
+            "",
         },
 
         // Hebrew/Indonesian/Yiddish
@@ -290,6 +290,25 @@
                 "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class",
                 "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_th.class"),
             " en en_US en_US_POSIX in in_ID iw iw_IL ji ji_001",
+            "",
+        },
+
+        // Error case: No matching locales
+        {"--include-locales=xyz",
+            null,
+            null,
+            null,
+            new PluginException(
+                PluginsResourceBundle.getMessage("include-locales.nomatchinglocales"))
+                .toString(),
+        },
+
+        // Error case: Invalid argument
+        {"--include-locales=zh_HK",
+            null,
+            null,
+            null,
+            "range=zh_hk",
         },
     };
 
@@ -304,20 +323,28 @@
 
         for (Object[] data : testData) {
             // create image for each test data
-            Path image = JImageGenerator.getJLinkTask()
+            Result result = JImageGenerator.getJLinkTask()
                     .modulePath(helper.defaultModulePath())
                     .output(helper.createNewImageDir(moduleName))
                     .addMods("jdk.localedata")
                     .option((String)data[INCLUDE_LOCALES_OPTION])
-                    .call().assertSuccess();
+                    .call();
+
+            String errorMsg = (String)data[ERROR_MESSAGE];
+            if (errorMsg.isEmpty()) {
+                Path image = result.assertSuccess();
 
-            // test locale data entries
-            testLocaleDataEntries(image,
-                (List<String>)data[EXPECTED_LOCATIONS],
-                (List<String>)data[UNEXPECTED_PATHS]);
+                // test locale data entries
+                testLocaleDataEntries(image,
+                    (List<String>)data[EXPECTED_LOCATIONS],
+                    (List<String>)data[UNEXPECTED_PATHS]);
 
-            // test available locales
-            testAvailableLocales(image, (String)data[AVAILABLE_LOCALES]);
+                // test available locales
+                testAvailableLocales(image, (String)data[AVAILABLE_LOCALES]);
+            } else {
+                result.assertFailure(new TaskHelper(TaskHelper.JLINK_BUNDLE)
+                    .getMessage("error.prefix") + " " +errorMsg);
+            }
         }
     }
 
--- a/langtools/.hgtags	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/.hgtags	Mon Mar 28 08:41:54 2016 -0700
@@ -353,3 +353,4 @@
 fd18a155ad22f62e06a9b74850ab8609d415c752 jdk-9+108
 f5991c73ed73b9a355a090b65c8d7fb9a1901f89 jdk-9+109
 9b4c916633f8d61509a3dc6175efdf185b421343 jdk-9+110
+9adfb22ff08f2e82c7801b272607cd685976dbb1 jdk-9+111
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Mon Mar 28 08:41:54 2016 -0700
@@ -282,7 +282,9 @@
      *  @param env    The current environment.
      */
     void checkAssignable(DiagnosticPosition pos, VarSymbol v, JCTree base, Env<AttrContext> env) {
-        if ((v.flags() & FINAL) != 0 &&
+        if (v.name == names._this) {
+            log.error(pos, Errors.CantAssignValToThis);
+        } else if ((v.flags() & FINAL) != 0 &&
             ((v.flags() & HASINIT) != 0
              ||
              !((base == null ||
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/InferenceContext.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/InferenceContext.java	Mon Mar 28 08:41:54 2016 -0700
@@ -356,6 +356,7 @@
         ListBuffer<Type> minUndetVars = new ListBuffer<>();
         for (Type minVar : minVars) {
             UndetVar uv = (UndetVar)asUndetVar(minVar);
+            Assert.check(uv.incorporationActions.size() == 0);
             UndetVar uv2 = new UndetVar((TypeVar)minVar, infer.incorporationEngine(), types);
             for (InferenceBound ib : InferenceBound.values()) {
                 List<Type> newBounds = uv.getBounds(ib).stream()
@@ -403,15 +404,17 @@
         public Void visitUndetVar(UndetVar t, Void _unused) {
             if (min.add(t.qtype)) {
                 Set<Type> deps = minMap.getOrDefault(t.qtype, new HashSet<>(Collections.singleton(t.qtype)));
-                for (Type b : t.getBounds(InferenceBound.values())) {
-                    Type undet = asUndetVar(b);
-                    if (!undet.hasTag(TypeTag.UNDETVAR)) {
-                        visit(undet);
-                    } else if (isEquiv((UndetVar)undet, b)){
-                        deps.add(b);
-                        equiv.add(b);
-                    } else {
-                        visit(undet);
+                for (InferenceBound boundKind : InferenceBound.values()) {
+                    for (Type b : t.getBounds(boundKind)) {
+                        Type undet = asUndetVar(b);
+                        if (!undet.hasTag(TypeTag.UNDETVAR)) {
+                            visit(undet);
+                        } else if (isEquiv(t, b, boundKind)) {
+                            deps.add(b);
+                            equiv.add(b);
+                        } else {
+                            visit(undet);
+                        }
                     }
                 }
                 minMap.put(t.qtype, deps);
@@ -447,11 +450,17 @@
             return null;
         }
 
-        boolean isEquiv(UndetVar from, Type t) {
+        boolean isEquiv(UndetVar from, Type t, InferenceBound boundKind) {
             UndetVar uv = (UndetVar)asUndetVar(t);
             for (InferenceBound ib : InferenceBound.values()) {
-                List<Type> b1 = uv.getBounds(ib);
-                List<Type> b2 = from.getBounds(ib);
+                List<Type> b1 = from.getBounds(ib);
+                if (ib == boundKind) {
+                    b1 = b1.diff(List.of(t));
+                }
+                List<Type> b2 = uv.getBounds(ib);
+                if (ib == boundKind.complement()) {
+                    b2 = b2.diff(List.of(from.qtype));
+                }
                 if (!b1.containsAll(b2) || !b2.containsAll(b1)) {
                     return false;
                 }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Mon Mar 28 08:41:54 2016 -0700
@@ -274,6 +274,9 @@
 compiler.err.cant.assign.val.to.final.var=\
     cannot assign a value to final variable {0}
 
+compiler.err.cant.assign.val.to.this=\
+    cannot assign to ''this''
+
 # 0: symbol, 1: message segment
 compiler.err.cant.ref.non.effectively.final.var=\
     local variables referenced from {1} must be final or effectively final
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/JavacState.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/JavacState.java	Mon Mar 28 08:41:54 2016 -0700
@@ -361,22 +361,22 @@
             // Silently create a new javac_state file.
             noFileFound = true;
         } catch (IOException e) {
-            Log.info("Dropping old javac_state because of errors when reading it.");
+            Log.warn("Dropping old javac_state because of errors when reading it.");
             db = new JavacState(options, true);
             foundCorrectVerNr = true;
             newCommandLine = false;
             syntaxError = false;
     }
         if (foundCorrectVerNr == false && !noFileFound) {
-            Log.info("Dropping old javac_state since it is of an old version.");
+            Log.debug("Dropping old javac_state since it is of an old version.");
             db = new JavacState(options, true);
         } else
         if (newCommandLine == true && !noFileFound) {
-            Log.info("Dropping old javac_state since a new command line is used!");
+            Log.debug("Dropping old javac_state since a new command line is used!");
             db = new JavacState(options, true);
         } else
         if (syntaxError == true) {
-            Log.info("Dropping old javac_state since it contains syntax errors.");
+            Log.warn("Dropping old javac_state since it contains syntax errors.");
             db = new JavacState(options, true);
         }
         db.prev.calculateDependents();
@@ -868,7 +868,7 @@
                         // This is an incremental compile! The pubapi
                         // did change. Trigger recompilation of dependents.
                         packagesWithChangedPublicApis.add(pkg);
-                        Log.info("The API of " + Util.justPackageName(pkg) + " has changed!");
+                        Log.debug("The API of " + Util.justPackageName(pkg) + " has changed!");
                     }
                 }
             }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/client/SjavacClient.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/client/SjavacClient.java	Mon Mar 28 08:41:54 2016 -0700
@@ -139,7 +139,11 @@
                 String content = typeAndContent[1];
 
                 try {
-                    Log.log(Log.Level.valueOf(type), "[server] " + content);
+                    if (Log.isDebugging()) {
+                        // Distinguish server generated output if debugging.
+                        content = "[sjavac-server] " + content;
+                    }
+                    Log.log(Log.Level.valueOf(type), content);
                     continue;
                 } catch (IllegalArgumentException e) {
                     // Parsing of 'type' as log level failed.
@@ -172,7 +176,7 @@
         makeSureServerIsRunning(portFile);
         int attempt = 0;
         while (true) {
-            Log.info("Trying to connect. Attempt " + (++attempt) + " of " + MAX_CONNECT_ATTEMPTS);
+            Log.debug("Trying to connect. Attempt " + (++attempt) + " of " + MAX_CONNECT_ATTEMPTS);
             try {
                 return makeConnectionAttempt();
             } catch (IOException ex) {
@@ -191,7 +195,7 @@
         InetAddress localhost = InetAddress.getByName(null);
         InetSocketAddress address = new InetSocketAddress(localhost, portFile.getPort());
         socket.connect(address, CONNECTION_TIMEOUT);
-        Log.info("Connected");
+        Log.debug("Connected");
         return socket;
     }
 
@@ -238,7 +242,7 @@
               + ",keepalive="+ keepalive);
 
         Process serverProcess;
-        Log.info("Starting server. Command: " + String.join(" ", cmd));
+        Log.debug("Starting server. Command: " + String.join(" ", cmd));
         try {
             // If the cmd for some reason can't be executed (file is not found,
             // or is not executable for instance) this will throw an
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/SjavacServer.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/SjavacServer.java	Mon Mar 28 08:41:54 2016 -0700
@@ -165,7 +165,7 @@
             portFile.lock();
             portFile.getValues();
             if (portFile.containsPortInfo()) {
-                Log.info("Javac server not started because portfile exists!");
+                Log.debug("Javac server not started because portfile exists!");
                 portFile.unlock();
                 return -1;
             }
@@ -192,10 +192,10 @@
         portFileMonitor = new PortFileMonitor(portFile, this);
         portFileMonitor.start();
 
-        Log.info("Sjavac server started. Accepting connections...");
-        Log.info("    port: " + getPort());
-        Log.info("    time: " + new java.util.Date());
-        Log.info("    poolsize: " + poolsize);
+        Log.debug("Sjavac server started. Accepting connections...");
+        Log.debug("    port: " + getPort());
+        Log.debug("    time: " + new java.util.Date());
+        Log.debug("    poolsize: " + poolsize);
 
 
         keepAcceptingRequests.set(true);
@@ -208,7 +208,7 @@
             }
         } while (keepAcceptingRequests.get());
 
-        Log.info("Shutting down.");
+        Log.debug("Shutting down.");
 
         // No more connections accepted. If any client managed to connect after
         // the accept() was interrupted but before the server socket is closed
@@ -216,7 +216,7 @@
         // IOException on the client side.
 
         long realTime = System.currentTimeMillis() - serverStart;
-        Log.info("Total wall clock time " + realTime + "ms build time " + totalBuildTime + "ms");
+        Log.debug("Total wall clock time " + realTime + "ms build time " + totalBuildTime + "ms");
 
         // Shut down
         sjavac.shutdown();
@@ -231,7 +231,7 @@
             return;
         }
 
-        Log.info("Quitting: " + quitMsg);
+        Log.debug("Quitting: " + quitMsg);
 
         portFileMonitor.shutdown(); // No longer any need to monitor port file
 
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ConsoleIOContext.java	Mon Mar 28 08:41:54 2016 -0700
@@ -48,7 +48,7 @@
 import jdk.internal.jline.NoInterruptUnixTerminal;
 import jdk.internal.jline.Terminal;
 import jdk.internal.jline.TerminalFactory;
-import jdk.internal.jline.UnsupportedTerminal;
+import jdk.internal.jline.TerminalSupport;
 import jdk.internal.jline.WindowsTerminal;
 import jdk.internal.jline.console.ConsoleReader;
 import jdk.internal.jline.console.KeyMap;
@@ -70,7 +70,7 @@
         this.input = new StopDetectingInputStream(() -> repl.state.stop(), ex -> repl.hard("Error on input: %s", ex));
         Terminal term;
         if (System.getProperty("test.jdk") != null) {
-            term = new UnsupportedTerminal();
+            term = new TestTerminal(input);
         } else if (System.getProperty("os.name").toLowerCase(Locale.US).contains(TerminalFactory.WINDOWS)) {
             term = new JShellWindowsTerminal(input);
         } else {
@@ -80,7 +80,7 @@
         in = new ConsoleReader(cmdin, cmdout, term);
         in.setExpandEvents(false);
         in.setHandleUserInterrupt(true);
-        in.setHistory(history = new EditingHistory(JShellTool.PREFS) {
+        in.setHistory(history = new EditingHistory(repl.prefs) {
             @Override protected CompletionInfo analyzeCompletion(String input) {
                 return repl.analysis.analyzeCompletion(input);
             }
@@ -538,4 +538,22 @@
         }
 
     }
+
+    private static final class TestTerminal extends TerminalSupport {
+
+        private final StopDetectingInputStream input;
+
+        public TestTerminal(StopDetectingInputStream input) throws Exception {
+            super(true);
+            setAnsiSupported(false);
+            setEchoEnabled(true);
+            this.input = input;
+        }
+
+        @Override
+        public InputStream wrapInIfNeeded(InputStream in) throws IOException {
+            return input.setInputStream(super.wrapInIfNeeded(in));
+        }
+
+    }
 }
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/Feedback.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/Feedback.java	Mon Mar 28 08:41:54 2016 -0700
@@ -28,18 +28,16 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.EnumMap;
 import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
-import java.util.Set;
 import java.util.function.Function;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-import java.util.stream.Collectors;
 import java.util.stream.Stream;
+import static java.util.stream.Collectors.joining;
 
 /**
  * Feedback customization support
@@ -57,29 +55,38 @@
     // Mapping of mode names to mode modes
     private final Map<String, Mode> modeMap = new HashMap<>();
 
+    // Mapping selector enum names to enums
+    private final Map<String, Selector<?>> selectorMap = new HashMap<>();
+
+    private static final long ALWAYS = bits(FormatCase.all, FormatAction.all, FormatWhen.all,
+            FormatResolve.all, FormatUnresolved.all, FormatErrors.all);
+    private static final long ANY = 0L;
+
     public boolean shouldDisplayCommandFluff() {
         return mode.commandFluff;
     }
 
     public String getPre() {
-        return mode.pre;
+        return mode.format("pre", ANY);
     }
 
     public String getPost() {
-        return mode.post;
+        return mode.format("post", ANY);
     }
 
     public String getErrorPre() {
-        return mode.errorPre;
+        return mode.format("errorpre", ANY);
     }
 
     public String getErrorPost() {
-        return mode.errorPost;
+        return mode.format("errorpost", ANY);
     }
 
-    public String getFormat(FormatCase fc, FormatWhen fw, FormatAction fa, FormatResolve fr,
-            boolean hasName, boolean hasType, boolean hasResult) {
-        return mode.getFormat(fc, fw, fa, fr, hasName, hasType, hasResult);
+    public String format(FormatCase fc, FormatAction fa, FormatWhen fw,
+                    FormatResolve fr, FormatUnresolved fu, FormatErrors fe,
+                    String name, String type, String value, String unresolved, List<String> errorLines) {
+        return mode.format(fc, fa, fw, fr, fu, fe,
+                name, type, value, unresolved, errorLines);
     }
 
     public String getPrompt(String nextId) {
@@ -91,184 +98,76 @@
     }
 
     public boolean setFeedback(JShellTool tool, ArgTokenizer at) {
-        return new FormatSetter(tool, at).setFeedback();
-    }
-
-    public boolean setField(JShellTool tool, ArgTokenizer at) {
-        return new FormatSetter(tool, at).setField();
+        return new Setter(tool, at).setFeedback();
     }
 
     public boolean setFormat(JShellTool tool, ArgTokenizer at) {
-        return new FormatSetter(tool, at).setFormat();
+        return new Setter(tool, at).setFormat();
     }
 
     public boolean setNewMode(JShellTool tool, ArgTokenizer at) {
-        return new FormatSetter(tool, at).setNewMode();
+        return new Setter(tool, at).setNewMode();
     }
 
     public boolean setPrompt(JShellTool tool, ArgTokenizer at) {
-        return new FormatSetter(tool, at).setPrompt();
+        return new Setter(tool, at).setPrompt();
     }
 
     public void printFeedbackHelp(JShellTool tool) {
-        new FormatSetter(tool, null).printFeedbackHelp();
-    }
-
-    public void printFieldHelp(JShellTool tool) {
-        new FormatSetter(tool, null).printFieldHelp();
+        new Setter(tool, null).printFeedbackHelp();
     }
 
     public void printFormatHelp(JShellTool tool) {
-        new FormatSetter(tool, null).printFormatHelp();
+        new Setter(tool, null).printFormatHelp();
     }
 
     public void printNewModeHelp(JShellTool tool) {
-        new FormatSetter(tool, null).printNewModeHelp();
+        new Setter(tool, null).printNewModeHelp();
     }
 
     public void printPromptHelp(JShellTool tool) {
-        new FormatSetter(tool, null).printPromptHelp();
+        new Setter(tool, null).printPromptHelp();
+    }
+
+    {
+        for (FormatCase e : EnumSet.allOf(FormatCase.class))
+            selectorMap.put(e.name().toLowerCase(Locale.US), e);
+        for (FormatAction e : EnumSet.allOf(FormatAction.class))
+            selectorMap.put(e.name().toLowerCase(Locale.US), e);
+        for (FormatResolve e : EnumSet.allOf(FormatResolve.class))
+            selectorMap.put(e.name().toLowerCase(Locale.US), e);
+        for (FormatUnresolved e : EnumSet.allOf(FormatUnresolved.class))
+            selectorMap.put(e.name().toLowerCase(Locale.US), e);
+        for (FormatErrors e : EnumSet.allOf(FormatErrors.class))
+            selectorMap.put(e.name().toLowerCase(Locale.US), e);
+        for (FormatWhen e : EnumSet.allOf(FormatWhen.class))
+            selectorMap.put(e.name().toLowerCase(Locale.US), e);
     }
 
     /**
      * Holds all the context of a mode mode
      */
-    private class Mode {
+    private static class Mode {
 
-        // Use name of mode mode
-
+        // Name of mode
         final String name;
 
         // Display command verification/information
         final boolean commandFluff;
 
-        // event cases: class, method
-        final EnumMap<FormatCase, EnumMap<FormatAction, EnumMap<FormatWhen, String>>> cases;
-
-        // action names: add. modified, replaced, ...
-        final EnumMap<FormatAction, EnumMap<FormatWhen, String>> actions;
-
-        // resolution status description format with %s for unresolved
-        final EnumMap<FormatResolve, EnumMap<FormatWhen, String>> resolves;
-
-        // primary snippet vs update
-        final EnumMap<FormatWhen, String> whens;
-
-        // fixed map of how to get format string for a field, given a specific formatting contet
-        final EnumMap<FormatField, Function<Context, String>> fields;
-
-        // format wrappers for name, type, and result
-        String fname = "%s";
-        String ftype = "%s";
-        String fresult = "%s";
-
-        // start and end, also used by hard-coded output
-        String pre = "|  ";
-        String post = "\n";
-        String errorPre = "|  Error: ";
-        String errorPost = "\n";
+        // Event cases: class, method, expression, ...
+        final Map<String, List<Setting>> cases;
 
         String prompt = "\n-> ";
         String continuationPrompt = ">> ";
 
-        /**
-         * The context of a specific mode to potentially display.
-         */
-        class Context {
-
-            final FormatCase fc;
-            final FormatAction fa;
-            final FormatResolve fr;
-            final FormatWhen fw;
-            final boolean hasName;
-            final boolean hasType;
-            final boolean hasResult;
-
-            Context(FormatCase fc, FormatWhen fw, FormatAction fa, FormatResolve fr,
-                    boolean hasName, boolean hasType, boolean hasResult) {
-                this.fc = fc;
-                this.fa = fa;
-                this.fr = fr;
-                this.fw = fw;
-                this.hasName = hasName;
-                this.hasType = hasType;
-                this.hasResult = hasResult;
-            }
-
-            String when() {
-                return whens.get(fw);
-            }
-
-            String action() {
-                return actions.get(fa).get(fw);
-            }
-
-            String resolve() {
-                return String.format(resolves.get(fr).get(fw), FormatField.RESOLVE.form);
-            }
-
-            String name() {
-                return hasName
-                        ? String.format(fname, FormatField.NAME.form)
-                        : "";
-            }
-
-            String type() {
-                return hasType
-                        ? String.format(ftype, FormatField.TYPE.form)
-                        : "";
+        static class Setting {
+            final long enumBits;
+            final String format;
+            Setting(long enumBits, String format) {
+                this.enumBits = enumBits;
+                this.format = format;
             }
-
-            String result() {
-                return hasResult
-                        ? String.format(fresult, FormatField.RESULT.form)
-                        : "";
-            }
-
-            /**
-             * Lookup format based on case, action, and whether it update.
-             * Replace fields with context specific formats.
-             *
-             * @return format string
-             */
-            String format() {
-                String format = cases.get(fc).get(fa).get(fw);
-                if (format == null) {
-                    return "";
-                }
-                Matcher m = FIELD_PATTERN.matcher(format);
-                StringBuffer sb = new StringBuffer(format.length());
-                while (m.find()) {
-                    String fieldName = m.group(1).toUpperCase(Locale.US);
-                    String sub = null;
-                    for (FormatField f : FormatField.values()) {
-                        if (f.name().startsWith(fieldName)) {
-                            sub = fields.get(f).apply(this);
-                            break;
-                        }
-                    }
-                    if (sub != null) {
-                        m.appendReplacement(sb, Matcher.quoteReplacement(sub));
-                    }
-                }
-                m.appendTail(sb);
-                return sb.toString();
-            }
-        }
-
-        {
-            // set fixed mappings of fields
-            fields = new EnumMap<>(FormatField.class);
-            fields.put(FormatField.WHEN, c -> c.when());
-            fields.put(FormatField.ACTION, c -> c.action());
-            fields.put(FormatField.RESOLVE, c -> c.resolve());
-            fields.put(FormatField.NAME, c -> c.name());
-            fields.put(FormatField.TYPE, c -> c.type());
-            fields.put(FormatField.RESULT, c -> c.result());
-            fields.put(FormatField.PRE, c -> pre);
-            fields.put(FormatField.POST, c -> post);
-            fields.put(FormatField.ERRORPRE, c -> errorPre);
-            fields.put(FormatField.ERRORPOST, c -> errorPost);
         }
 
         /**
@@ -280,41 +179,20 @@
         Mode(String name, boolean commandFluff) {
             this.name = name;
             this.commandFluff = commandFluff;
-            cases = new EnumMap<>(FormatCase.class);
-            for (FormatCase fc : FormatCase.values()) {
-                EnumMap<FormatAction, EnumMap<FormatWhen, String>> ac = new EnumMap<>(FormatAction.class);
-                cases.put(fc, ac);
-                for (FormatAction fa : FormatAction.values()) {
-                    EnumMap<FormatWhen, String> aw = new EnumMap<>(FormatWhen.class);
-                    ac.put(fa, aw);
-                    for (FormatWhen fw : FormatWhen.values()) {
-                        aw.put(fw, "");
-                    }
-                }
-            }
+            cases = new HashMap<>();
+            add("name",       new Setting(ALWAYS, "%1$s"));
+            add("type",       new Setting(ALWAYS, "%2$s"));
+            add("value",      new Setting(ALWAYS, "%3$s"));
+            add("unresolved", new Setting(ALWAYS, "%4$s"));
+            add("errors",     new Setting(ALWAYS, "%5$s"));
+            add("err",        new Setting(ALWAYS, "%6$s"));
 
-            actions = new EnumMap<>(FormatAction.class);
-            for (FormatAction fa : FormatAction.values()) {
-                EnumMap<FormatWhen, String> afw = new EnumMap<>(FormatWhen.class);
-                actions.put(fa, afw);
-                for (FormatWhen fw : FormatWhen.values()) {
-                    afw.put(fw, fa.name() + "-" + fw.name());
-                }
-            }
+            add("errorline",  new Setting(ALWAYS, "    {err}%n"));
 
-            resolves = new EnumMap<>(FormatResolve.class);
-            for (FormatResolve fr : FormatResolve.values()) {
-                EnumMap<FormatWhen, String> arw = new EnumMap<>(FormatWhen.class);
-                resolves.put(fr, arw);
-                for (FormatWhen fw : FormatWhen.values()) {
-                    arw.put(fw, fr.name() + "-" + fw.name() + ": %s");
-                }
-            }
-
-            whens = new EnumMap<>(FormatWhen.class);
-            for (FormatWhen fw : FormatWhen.values()) {
-                whens.put(fw, fw.name());
-            }
+            add("pre",        new Setting(ALWAYS, "|  "));
+            add("post",       new Setting(ALWAYS, "%n"));
+            add("errorpre",   new Setting(ALWAYS, "|  "));
+            add("errorpost",  new Setting(ALWAYS, "%n"));
         }
 
         /**
@@ -322,132 +200,91 @@
          *
          * @param name
          * @param commandFluff True if should display command fluff messages
-         * @param m Mode to copy
+         * @param m Mode to copy, or null for no fresh
          */
         Mode(String name, boolean commandFluff, Mode m) {
             this.name = name;
             this.commandFluff = commandFluff;
-            cases = new EnumMap<>(FormatCase.class);
-            for (FormatCase fc : FormatCase.values()) {
-                EnumMap<FormatAction, EnumMap<FormatWhen, String>> ac = new EnumMap<>(FormatAction.class);
-                EnumMap<FormatAction, EnumMap<FormatWhen, String>> mc = m.cases.get(fc);
-                cases.put(fc, ac);
-                for (FormatAction fa : FormatAction.values()) {
-                    EnumMap<FormatWhen, String> aw = new EnumMap<>(mc.get(fa));
-                    ac.put(fa, aw);
-                }
-            }
+            cases = new HashMap<>();
 
-            actions = new EnumMap<>(FormatAction.class);
-            for (FormatAction fa : FormatAction.values()) {
-                EnumMap<FormatWhen, String> afw = new EnumMap<>(m.actions.get(fa));
-                actions.put(fa, afw);
-            }
+            m.cases.entrySet().stream()
+                    .forEach(fes -> fes.getValue()
+                    .forEach(ing -> add(fes.getKey(), ing)));
 
-            resolves = new EnumMap<>(FormatResolve.class);
-            for (FormatResolve fr : FormatResolve.values()) {
-                EnumMap<FormatWhen, String> arw = new EnumMap<>(m.resolves.get(fr));
-                resolves.put(fr, arw);
-            }
-
-            whens = new EnumMap<>(m.whens);
-
-            this.fname = m.fname;
-            this.ftype = m.ftype;
-            this.fresult = m.fresult;
-            this.pre = m.pre;
-            this.post = m.post;
-            this.errorPre = m.errorPre;
-            this.errorPost = m.errorPost;
             this.prompt = m.prompt;
             this.continuationPrompt = m.continuationPrompt;
         }
 
-        String getFormat(FormatCase fc, FormatWhen fw, FormatAction fa, FormatResolve fr,
-                boolean hasName, boolean hasType, boolean hasResult) {
-            Context context = new Context(fc, fw, fa, fr,
-                    hasName, hasType, hasResult);
-            return context.format();
-        }
-
-        void setCases(String format, Collection<FormatCase> cc, Collection<FormatAction> ca, Collection<FormatWhen> cw) {
-            for (FormatCase fc : cc) {
-                EnumMap<FormatAction, EnumMap<FormatWhen, String>> ma = cases.get(fc);
-                for (FormatAction fa : ca) {
-                    EnumMap<FormatWhen, String> mw = ma.get(fa);
-                    for (FormatWhen fw : cw) {
-                        mw.put(fw, format);
-                    }
-                }
+        private boolean add(String field, Setting ing) {
+            List<Setting> settings =  cases.computeIfAbsent(field, k -> new ArrayList<>());
+            if (settings == null) {
+                return false;
             }
+            settings.add(ing);
+            return true;
         }
 
-        void setActions(String format, Collection<FormatAction> ca, Collection<FormatWhen> cw) {
-            for (FormatAction fa : ca) {
-                EnumMap<FormatWhen, String> mw = actions.get(fa);
-                for (FormatWhen fw : cw) {
-                    mw.put(fw, format);
-                }
-            }
+        void set(String field,
+                Collection<FormatCase> cc, Collection<FormatAction> ca, Collection<FormatWhen> cw,
+                Collection<FormatResolve> cr, Collection<FormatUnresolved> cu, Collection<FormatErrors> ce,
+                String format) {
+            long bits = bits(cc, ca, cw, cr, cu, ce);
+            set(field, bits, format);
         }
 
-        void setResolves(String format, Collection<FormatResolve> cr, Collection<FormatWhen> cw) {
-            for (FormatResolve fr : cr) {
-                EnumMap<FormatWhen, String> mw = resolves.get(fr);
-                for (FormatWhen fw : cw) {
-                    mw.put(fw, format);
-                }
-            }
-        }
-
-        void setWhens(String format, Collection<FormatWhen> cw) {
-            for (FormatWhen fw : cw) {
-                whens.put(fw, format);
-            }
+        void set(String field, long bits, String format) {
+            add(field, new Setting(bits, format));
         }
 
-        void setName(String s) {
-            fname = s;
-        }
-
-        void setType(String s) {
-            ftype = s;
-        }
-
-        void setResult(String s) {
-            fresult = s;
-        }
-
-        void setPre(String s) {
-            pre = s;
-        }
-
-        void setPost(String s) {
-            post = s;
+        /**
+         * Lookup format Replace fields with context specific formats.
+         *
+         * @return format string
+         */
+        String format(String field, long bits) {
+            List<Setting> settings = cases.get(field);
+            if (settings == null) {
+                return ""; //TODO error?
+            }
+            String format = null;
+            for (int i = settings.size() - 1; i >= 0; --i) {
+                Setting ing = settings.get(i);
+                long mask = ing.enumBits;
+                if ((bits & mask) == bits) {
+                    format = ing.format;
+                    break;
+                }
+            }
+            if (format == null || format.isEmpty()) {
+                return "";
+            }
+            Matcher m = FIELD_PATTERN.matcher(format);
+            StringBuffer sb = new StringBuffer(format.length());
+            while (m.find()) {
+                String fieldName = m.group(1);
+                String sub = format(fieldName, bits);
+                m.appendReplacement(sb, Matcher.quoteReplacement(sub));
+            }
+            m.appendTail(sb);
+            return sb.toString();
         }
 
-        void setErrorPre(String s) {
-            errorPre = s;
-        }
-
-        void setErrorPost(String s) {
-            errorPost = s;
-        }
-
-        String getPre() {
-            return pre;
-        }
-
-        String getPost() {
-            return post;
-        }
-
-        String getErrorPre() {
-            return errorPre;
-        }
-
-        String getErrorPost() {
-            return errorPost;
+        String format(FormatCase fc, FormatAction fa, FormatWhen fw,
+                    FormatResolve fr, FormatUnresolved fu, FormatErrors fe,
+                    String name, String type, String value, String unresolved, List<String> errorLines) {
+            long bits = bits(fc, fa, fw, fr, fu, fe);
+            String fname = name==null? "" : name;
+            String ftype = type==null? "" : type;
+            String fvalue = value==null? "" : value;
+            String funresolved = unresolved==null? "" : unresolved;
+            String errors = errorLines.stream()
+                    .map(el -> String.format(
+                            format("errorline", bits),
+                            fname, ftype, fvalue, funresolved, "*cannot-use-errors-here*", el))
+                    .collect(joining());
+            return String.format(
+                    format("display", bits),
+                    fname, ftype, fvalue, funresolved, errors, "*cannot-use-err-here*");
         }
 
         void setPrompts(String prompt, String continuationPrompt) {
@@ -464,50 +301,82 @@
         }
     }
 
-    /**
-     * The brace delimited substitutions
-     */
-    public enum FormatField {
-        WHEN,
-        ACTION,
-        RESOLVE("%1$s"),
-        NAME("%2$s"),
-        TYPE("%3$s"),
-        RESULT("%4$s"),
-        PRE,
-        POST,
-        ERRORPRE,
-        ERRORPOST;
-        String form;
+    // Representation of one instance of all the enum values as bits in a long
+    private static long bits(FormatCase fc, FormatAction fa, FormatWhen fw,
+            FormatResolve fr, FormatUnresolved fu, FormatErrors fe) {
+        long res = 0L;
+        res |= 1 << fc.ordinal();
+        res <<= FormatAction.count;
+        res |= 1 << fa.ordinal();
+        res <<= FormatWhen.count;
+        res |= 1 << fw.ordinal();
+        res <<= FormatResolve.count;
+        res |= 1 << fr.ordinal();
+        res <<= FormatUnresolved.count;
+        res |= 1 << fu.ordinal();
+        res <<= FormatErrors.count;
+        res |= 1 << fe.ordinal();
+        return res;
+    }
 
-        FormatField(String s) {
-            this.form = s;
-        }
+    // Representation of a space of enum values as or'edbits in a long
+    private static long bits(Collection<FormatCase> cc, Collection<FormatAction> ca, Collection<FormatWhen> cw,
+                Collection<FormatResolve> cr, Collection<FormatUnresolved> cu, Collection<FormatErrors> ce) {
+        long res = 0L;
+        for (FormatCase fc : cc)
+            res |= 1 << fc.ordinal();
+        res <<= FormatAction.count;
+        for (FormatAction fa : ca)
+            res |= 1 << fa.ordinal();
+        res <<= FormatWhen.count;
+        for (FormatWhen fw : cw)
+            res |= 1 << fw.ordinal();
+        res <<= FormatResolve.count;
+        for (FormatResolve fr : cr)
+            res |= 1 << fr.ordinal();
+        res <<= FormatUnresolved.count;
+        for (FormatUnresolved fu : cu)
+            res |= 1 << fu.ordinal();
+        res <<= FormatErrors.count;
+        for (FormatErrors fe : ce)
+            res |= 1 << fe.ordinal();
+        return res;
+    }
 
-        FormatField() {
-            this.form = null;
-        }
+    interface Selector<E extends Enum<E> & Selector<E>> {
+        SelectorCollector<E> collector(Setter.SelectorList sl);
+        String doc();
     }
 
     /**
      * The event cases
      */
-    public enum FormatCase {
-        IMPORT("import declaration: {action} {name}"),
-        CLASS("class, interface, enum, or annotation declaration: {action} {name} {resolve}"),
-        INTERFACE("class, interface, enum, or annotation declaration: {action} {name} {resolve}"),
-        ENUM("class, interface, enum, or annotation declaration: {action} {name} {resolve}"),
-        ANNOTATION("annotation interface declaration: {action} {name} {resolve}"),
-        METHOD("method declaration: {action} {name} {type}==parameter-types {resolve}"),
-        VARDECL("variable declaration: {action} {name} {type} {resolve}"),
-        VARDECLRECOVERABLE("recoverably failed variable declaration: {action} {name} {resolve}"),
-        VARINIT("variable declaration with init: {action} {name} {type} {resolve} {result}"),
-        VARRESET("variable reset on update: {action} {name}"),
-        EXPRESSION("expression: {action}=='Saved to scratch variable' {name} {type} {result}"),
-        VARVALUE("variable value expression: {action} {name} {type} {result}"),
-        ASSIGNMENT("assign variable: {action} {name} {type} {result}"),
-        STATEMENT("statement: {action}");
+    public enum FormatCase implements Selector<FormatCase> {
+        IMPORT("import declaration"),
+        CLASS("class declaration"),
+        INTERFACE("interface declaration"),
+        ENUM("enum declaration"),
+        ANNOTATION("annotation interface declaration"),
+        METHOD("method declaration -- note: {type}==parameter-types"),
+        VARDECL("variable declaration without init"),
+        VARINIT("variable declaration with init"),
+        EXPRESSION("expression -- note: {name}==scratch-variable-name"),
+        VARVALUE("variable value expression"),
+        ASSIGNMENT("assign variable"),
+        STATEMENT("statement");
         String doc;
+        static final EnumSet<FormatCase> all = EnumSet.allOf(FormatCase.class);
+        static final int count = all.size();
+
+        @Override
+        public SelectorCollector<FormatCase> collector(Setter.SelectorList sl) {
+            return sl.cases;
+        }
+
+        @Override
+        public String doc() {
+            return doc;
+        }
 
         private FormatCase(String doc) {
             this.doc = doc;
@@ -517,14 +386,26 @@
     /**
      * The event actions
      */
-    public enum FormatAction {
+    public enum FormatAction implements Selector<FormatAction> {
         ADDED("snippet has been added"),
         MODIFIED("an existing snippet has been modified"),
         REPLACED("an existing snippet has been replaced with a new snippet"),
         OVERWROTE("an existing snippet has been overwritten"),
         DROPPED("snippet has been dropped"),
-        REJECTED("snippet has failed and been rejected");
+        USED("snippet was used when it cannot be");
         String doc;
+        static final EnumSet<FormatAction> all = EnumSet.allOf(FormatAction.class);
+        static final int count = all.size();
+
+        @Override
+        public SelectorCollector<FormatAction> collector(Setter.SelectorList sl) {
+            return sl.actions;
+        }
+
+        @Override
+        public String doc() {
+            return doc;
+        }
 
         private FormatAction(String doc) {
             this.doc = doc;
@@ -534,10 +415,22 @@
     /**
      * When the event occurs: primary or update
      */
-    public enum FormatWhen {
+    public enum FormatWhen implements Selector<FormatWhen> {
         PRIMARY("the entered snippet"),
         UPDATE("an update to a dependent snippet");
         String doc;
+        static final EnumSet<FormatWhen> all = EnumSet.allOf(FormatWhen.class);
+        static final int count = all.size();
+
+        @Override
+        public SelectorCollector<FormatWhen> collector(Setter.SelectorList sl) {
+            return sl.whens;
+        }
+
+        @Override
+        public String doc() {
+            return doc;
+        }
 
         private FormatWhen(String doc) {
             this.doc = doc;
@@ -545,46 +438,119 @@
     }
 
     /**
-     * Resolution problems with event
+     * Resolution problems
      */
-    public enum FormatResolve {
+    public enum FormatResolve implements Selector<FormatResolve> {
         OK("resolved correctly"),
         DEFINED("defined despite recoverably unresolved references"),
         NOTDEFINED("not defined because of recoverably unresolved references");
         String doc;
+        static final EnumSet<FormatResolve> all = EnumSet.allOf(FormatResolve.class);
+        static final int count = all.size();
+
+        @Override
+        public SelectorCollector<FormatResolve> collector(Setter.SelectorList sl) {
+            return sl.resolves;
+        }
+
+        @Override
+        public String doc() {
+            return doc;
+        }
 
         private FormatResolve(String doc) {
             this.doc = doc;
         }
     }
 
+    /**
+     * Count of unresolved references
+     */
+    public enum FormatUnresolved implements Selector<FormatUnresolved> {
+        UNRESOLVED0("no names are unresolved"),
+        UNRESOLVED1("one name is unresolved"),
+        UNRESOLVED2("two or more names are unresolved");
+        String doc;
+        static final EnumSet<FormatUnresolved> all = EnumSet.allOf(FormatUnresolved.class);
+        static final int count = all.size();
+
+        @Override
+        public SelectorCollector<FormatUnresolved> collector(Setter.SelectorList sl) {
+            return sl.unresolvedCounts;
+        }
+
+        @Override
+        public String doc() {
+            return doc;
+        }
+
+        private FormatUnresolved(String doc) {
+            this.doc = doc;
+        }
+    }
+
+    /**
+     * Count of unresolved references
+     */
+    public enum FormatErrors implements Selector<FormatErrors> {
+        ERROR0("no errors"),
+        ERROR1("one error"),
+        ERROR2("two or more errors");
+        String doc;
+        static final EnumSet<FormatErrors> all = EnumSet.allOf(FormatErrors.class);
+        static final int count = all.size();
+
+        @Override
+        public SelectorCollector<FormatErrors> collector(Setter.SelectorList sl) {
+            return sl.errorCounts;
+        }
+
+        @Override
+        public String doc() {
+            return doc;
+        }
+
+        private FormatErrors(String doc) {
+            this.doc = doc;
+        }
+    }
+
+    class SelectorCollector<E extends Enum<E> & Selector<E>> {
+        final EnumSet<E> all;
+        EnumSet<E> set = null;
+        SelectorCollector(EnumSet<E> all) {
+            this.all = all;
+        }
+        void add(Object o) {
+            @SuppressWarnings("unchecked")
+            E e = (E) o;
+            if (set == null) {
+                set = EnumSet.of(e);
+            } else {
+                set.add(e);
+            }
+        }
+
+        boolean isEmpty() {
+            return set == null;
+        }
+
+        EnumSet<E> getSet() {
+            return set == null
+                    ? all
+                    : set;
+        }
+    }
+
     // Class used to set custom eval output formats
-    // For both /set format  and /set field -- Parse arguments, setting custom format, or printing error
-    private class FormatSetter {
+    // For both /set format  -- Parse arguments, setting custom format, or printing error
+    private class Setter {
 
         private final ArgTokenizer at;
         private final JShellTool tool;
         boolean valid = true;
 
-        class Case<E1 extends Enum<E1>, E2 extends Enum<E2>, E3 extends Enum<E3>> {
-
-            Set<E1> e1;
-            Set<E2> e2;
-            Set<E3> e3;
-
-            Case(Set<E1> e1, Set<E2> e2, Set<E3> e3) {
-                this.e1 = e1;
-                this.e2 = e2;
-                this.e3 = e3;
-            }
-
-            Case(Set<E1> e1, Set<E2> e2) {
-                this.e1 = e1;
-                this.e2 = e2;
-            }
-        }
-
-        FormatSetter(JShellTool tool, ArgTokenizer at) {
+        Setter(JShellTool tool, ArgTokenizer at) {
             this.tool = tool;
             this.at = at;
         }
@@ -593,6 +559,10 @@
             tool.hard(format, args);
         }
 
+        void hardrb(String key) {
+            tool.hardrb(key);
+        }
+
         <E extends Enum<E>> void hardEnums(EnumSet<E> es, Function<E, String> e2s) {
             hardPairs(es.stream(), ev -> ev.name().toLowerCase(Locale.US), e2s);
         }
@@ -681,137 +651,31 @@
         // For /set format <mode> "<format>" <selector>...
         boolean setFormat() {
             Mode m = nextMode();
-            String format = nextFormat();
-            if (valid) {
-                List<Case<FormatCase, FormatAction, FormatWhen>> specs = new ArrayList<>();
-                String s;
-                while ((s = at.next()) != null) {
-                    String[] d = s.split("-");
-                    specs.add(new Case<>(
-                            parseFormatCase(d, 0),
-                            parseFormatAction(d, 1),
-                            parseFormatWhen(d, 2)
-                    ));
-                }
-                if (valid && specs.isEmpty()) {
-                    errorat("At least one selector required");
-                    valid = false;
-                }
-                if (valid) {
-                    // set the format in the specified cases
-                    specs.stream()
-                            .forEach(c -> m.setCases(format, c.e1, c.e2, c.e3));
-                }
+            String field = at.next();
+            if (field == null || at.isQuoted()) {
+                errorat("Expected field name missing");
+                valid = false;
             }
-            if (!valid) {
-                fluff("See '/help /set format' for help");
+            String format = valid? nextFormat() : null;
+            String slRaw;
+            List<SelectorList> slList = new ArrayList<>();
+            while (valid && (slRaw = at.next()) != null) {
+                SelectorList sl = new SelectorList();
+                sl.parseSelectorList(slRaw);
+                slList.add(sl);
             }
-            return valid;
-        }
-
-        // For /set field mode <field> "<format>" <selector>...
-        boolean setField() {
-            Mode m = nextMode();
-            String fieldName = at.next();
-            FormatField field = parseFormatSelector(fieldName, EnumSet.allOf(FormatField.class), "field");
-            String format = nextFormat();
             if (valid) {
-                switch (field) {
-                    case ACTION: {
-                        List<Case<FormatAction, FormatWhen, FormatWhen>> specs = new ArrayList<>();
-                        String s;
-                        while ((s = at.next()) != null) {
-                            String[] d = s.split("-");
-                            specs.add(new Case<>(
-                                    parseFormatAction(d, 0),
-                                    parseFormatWhen(d, 1)
-                            ));
-                        }
-                        if (valid && specs.isEmpty()) {
-                            errorat("At least one selector required");
-                            valid = false;
-                        }
-                        if (valid) {
-                            // set the format of the specified actions
-                            specs.stream()
-                                    .forEach(c -> m.setActions(format, c.e1, c.e2));
-                        }
-                        break;
-                    }
-                    case RESOLVE: {
-                        List<Case<FormatResolve, FormatWhen, FormatWhen>> specs = new ArrayList<>();
-                        String s;
-                        while ((s = at.next()) != null) {
-                            String[] d = s.split("-");
-                            specs.add(new Case<>(
-                                    parseFormatResolve(d, 0),
-                                    parseFormatWhen(d, 1)
-                            ));
-                        }
-                        if (valid && specs.isEmpty()) {
-                            errorat("At least one selector required");
-                            valid = false;
-                        }
-                        if (valid) {
-                            // set the format of the specified resolves
-                            specs.stream()
-                                    .forEach(c -> m.setResolves(format, c.e1, c.e2));
-                        }
-                        break;
-                    }
-                    case WHEN: {
-                        List<Case<FormatWhen, FormatWhen, FormatWhen>> specs = new ArrayList<>();
-                        String s;
-                        while ((s = at.next()) != null) {
-                            String[] d = s.split("-");
-                            specs.add(new Case<>(
-                                    parseFormatWhen(d, 1),
-                                    null
-                            ));
-                        }
-                        if (valid && specs.isEmpty()) {
-                            errorat("At least one selector required");
-                            valid = false;
-                        }
-                        if (valid) {
-                            // set the format of the specified whens
-                            specs.stream()
-                                    .forEach(c -> m.setWhens(format, c.e1));
-                        }
-                        break;
-                    }
-                    case NAME: {
-                        m.setName(format);
-                        break;
-                    }
-                    case TYPE: {
-                        m.setType(format);
-                        break;
-                    }
-                    case RESULT: {
-                        m.setResult(format);
-                        break;
-                    }
-                    case PRE: {
-                        m.setPre(format);
-                        break;
-                    }
-                    case POST: {
-                        m.setPost(format);
-                        break;
-                    }
-                    case ERRORPRE: {
-                        m.setErrorPre(format);
-                        break;
-                    }
-                    case ERRORPOST: {
-                        m.setErrorPost(format);
-                        break;
-                    }
+                if (slList.isEmpty()) {
+                    m.set(field, ALWAYS, format);
+                } else {
+                    slList.stream()
+                            .forEach(sl -> m.set(field,
+                                sl.cases.getSet(), sl.actions.getSet(), sl.whens.getSet(),
+                                sl.resolves.getSet(), sl.unresolvedCounts.getSet(), sl.errorCounts.getSet(),
+                                format));
                 }
-            }
-            if (!valid) {
-                fluff("See '/help /set field' for help");
+            } else {
+                fluff("See '/help /set format' for help");
             }
             return valid;
         }
@@ -843,12 +707,11 @@
                 if (matches.length == 0) {
                     errorat("Does not match any current feedback mode: %s", umode);
                 } else {
-                    errorat("Matchs more then one current feedback mode: %s", umode);
+                    errorat("Matches more then one current feedback mode: %s", umode);
                 }
                 fluff("The feedback mode should be one of the following:");
                 modeMap.keySet().stream()
                         .forEach(mk -> fluff("   %s", mk));
-                fluff("You may also use just enough letters to make it unique.");
                 return null;
             }
         }
@@ -869,181 +732,75 @@
             return format;
         }
 
-        final Set<FormatCase> parseFormatCase(String[] s, int i) {
-            return parseFormatSelectorStar(s, i, FormatCase.class, EnumSet.allOf(FormatCase.class), "case");
-        }
-
-        final Set<FormatAction> parseFormatAction(String[] s, int i) {
-            return parseFormatSelectorStar(s, i, FormatAction.class,
-                    EnumSet.of(FormatAction.ADDED, FormatAction.MODIFIED, FormatAction.REPLACED), "action");
-        }
+        class SelectorList {
 
-        final Set<FormatResolve> parseFormatResolve(String[] s, int i) {
-            return parseFormatSelectorStar(s, i, FormatResolve.class,
-                    EnumSet.of(FormatResolve.DEFINED, FormatResolve.NOTDEFINED), "resolve");
-        }
-
-        final Set<FormatWhen> parseFormatWhen(String[] s, int i) {
-            return parseFormatSelectorStar(s, i, FormatWhen.class, EnumSet.of(FormatWhen.PRIMARY), "when");
-        }
+            SelectorCollector<FormatCase> cases = new SelectorCollector<>(FormatCase.all);
+            SelectorCollector<FormatAction> actions = new SelectorCollector<>(FormatAction.all);
+            SelectorCollector<FormatWhen> whens = new SelectorCollector<>(FormatWhen.all);
+            SelectorCollector<FormatResolve> resolves = new SelectorCollector<>(FormatResolve.all);
+            SelectorCollector<FormatUnresolved> unresolvedCounts = new SelectorCollector<>(FormatUnresolved.all);
+            SelectorCollector<FormatErrors> errorCounts = new SelectorCollector<>(FormatErrors.all);
 
-        /**
-         * In a selector x-y-z , parse x, y, or z -- whether they are missing,
-         * or a comma separated list of identifiers and stars.
-         *
-         * @param <E> The enum this selector should belong to
-         * @param sa The array of selector strings
-         * @param i The index of which selector string to use
-         * @param klass The class of the enum that should be used
-         * @param defaults The set of enum values to use if the selector is
-         * missing
-         * @return The set of enum values specified by this selector
-         */
-        final <E extends Enum<E>> Set<E> parseFormatSelectorStar(String[] sa, int i, Class<E> klass, EnumSet<E> defaults, String label) {
-            String s = sa.length > i
-                    ? sa[i]
-                    : null;
-            if (s == null || s.isEmpty()) {
-                return defaults;
-            }
-            Set<E> set = EnumSet.noneOf(klass);
-            EnumSet<E> values = EnumSet.allOf(klass);
-            for (String as : s.split(",")) {
-                if (as.equals("*")) {
-                    set.addAll(values);
-                } else if (!as.isEmpty()) {
-                    set.add(parseFormatSelector(as, values, label));
+            final void parseSelectorList(String sl) {
+                for (String s : sl.split("-")) {
+                    SelectorCollector<?> lastCollector = null;
+                    for (String as : s.split(",")) {
+                        if (!as.isEmpty()) {
+                            Selector<?> sel = selectorMap.get(as);
+                            if (sel == null) {
+                                errorat("Not a valid selector %s in %s", as, s);
+                                valid = false;
+                                return;
+                            }
+                            SelectorCollector<?> collector = sel.collector(this);
+                            if (lastCollector == null) {
+                                if (!collector.isEmpty()) {
+                                    errorat("Selector kind in multiple sections of selector list %s in %s", as, s);
+                                    valid = false;
+                                    return;
+                                }
+                            } else if (collector != lastCollector) {
+                                errorat("Different selector kinds in same sections of selector list %s in %s", as, s);
+                                valid = false;
+                                return;
+                            }
+                            collector.add(sel);
+                            lastCollector = collector;
+                        }
+                    }
                 }
             }
-            return set;
-        }
-
-        /**
-         * In a x-y-a,b selector, parse an x, y, a, or b -- that is an
-         * identifier
-         *
-         * @param <E> The enum this selector should belong to
-         * @param s The string to parse: x, y, or z
-         * @param values The allowed of this enum
-         * @return The enum value
-         */
-        final <E extends Enum<E>> E parseFormatSelector(String s, EnumSet<E> values, String label) {
-            if (s == null) {
-                valid = false;
-                return null;
-            }
-            String u = s.toUpperCase(Locale.US);
-            for (E c : values) {
-                if (c.name().startsWith(u)) {
-                    return c;
-                }
-            }
-
-            errorat("Not a valid %s: %s, must be one of: %s", label, s,
-                    values.stream().map(v -> v.name().toLowerCase(Locale.US)).collect(Collectors.joining(" ")));
-            valid = false;
-            return values.iterator().next();
         }
 
         final void printFormatHelp() {
-            hard("Set the format for reporting a snippet event.");
-            hard("");
-            hard("/set format <mode> \"<format>\" <selector>...");
-            hard("");
-            hard("Where <mode> is the name of a previously defined feedback mode -- see '/help /set newmode'.");
-            hard("Where <format> is a quoted string which will have these field substitutions:");
-            hard("   {action}    == The action, e.g.: Added, Modified, Assigned, ...");
-            hard("   {name}      == The name, e.g.: the variable name, ...");
-            hard("   {type}      == The type name");
-            hard("   {resolve}   == Unresolved info, e.g.: ', however, it cannot be invoked until'");
-            hard("   {result}    == The result value");
-            hard("   {when}      == The entered snippet or a resultant update");
-            hard("   {pre}       == The feedback prefix");
-            hard("   {post}      == The feedback postfix");
-            hard("   {errorpre}  == The error prefix");
-            hard("   {errorpost} == The error postfix");
-            hard("Use '/set field' to set the format of these substitutions.");
-            hard("Where <selector> is the context in which the format is applied.");
-            hard("The structure of selector is: <case>[-<action>[-<when>]]");
-            hard("Where each field component may be missing (indicating defaults),");
-            hard("star (indicating all), or a comma separated list of field values.");
-            hard("For case, the field values are:");
+            hardrb("help.set.format");
+            hardrb("help.set.format.case");
             hardEnums(EnumSet.allOf(FormatCase.class), ev -> ev.doc);
-            hard("For action, the field values are:");
+            hardrb("help.set.format.action");
             hardEnums(EnumSet.allOf(FormatAction.class), ev -> ev.doc);
-            hard("For when, the field values are:");
+            hardrb("help.set.format.when");
             hardEnums(EnumSet.allOf(FormatWhen.class), ev -> ev.doc);
-            hard("");
-            hard("Example:");
-            hard("   /set format example '{pre}{action} variable {name}, reset to null{post}' varreset-*-update");
-        }
-
-        final void printFieldHelp() {
-            hard("Set the format of a field substitution as used in '/set format'.");
-            hard("");
-            hard("/set field <mode> <field> \"<format>\" <selector>...");
-            hard("");
-            hard("Where <mode> is the name of a previously defined feedback mode -- see '/set newmode'.");
-            hard("Where <field> is context-specific format to set, each with its own selector structure:");
-            hard("   action    == The action. The selector: <action>-<when>.");
-            hard("   name      == The name.  '%%s' is the name.  No selectors.");
-            hard("   type      == The type name.  '%%s' is the type. No selectors.");
-            hard("   resolve   == Unresolved info.  '%%s' is the unresolved list. The selector: <resolve>-<when>.");
-            hard("   result    == The result value.  '%%s' is the result value. No selectors.");
-            hard("   when      == The entered snippet or a resultant update. The selector: <when>");
-            hard("   pre       == The feedback prefix. No selectors.");
-            hard("   post      == The feedback postfix. No selectors.");
-            hard("   errorpre  == The error prefix. No selectors.");
-            hard("   errorpost == The error postfix. No selectors.");
-            hard("Where <format> is a quoted string -- see the description specific to the field (above).");
-            hard("Where <selector> is the context in which the format is applied (see above).");
-            hard("For action, the field values are:");
-            hardEnums(EnumSet.allOf(FormatAction.class), ev -> ev.doc);
-            hard("For when, the field values are:");
-            hardEnums(EnumSet.allOf(FormatWhen.class), ev -> ev.doc);
-            hard("For resolve, the field values are:");
+            hardrb("help.set.format.resolve");
             hardEnums(EnumSet.allOf(FormatResolve.class), ev -> ev.doc);
-            hard("");
-            hard("Example:");
-            hard("   /set field example resolve ' which cannot be invoked until%%s is declared' defined-update");
+            hardrb("help.set.format.unresolved");
+            hardEnums(EnumSet.allOf(FormatUnresolved.class), ev -> ev.doc);
+            hardrb("help.set.format.errors");
+            hardEnums(EnumSet.allOf(FormatErrors.class), ev -> ev.doc);
+            hardrb("help.set.format.end");
         }
 
         final void printFeedbackHelp() {
-            hard("Set the feedback mode describing displayed feedback for entered snippets and commands.");
-            hard("");
-            hard("/set feedback <mode>");
-            hard("");
-            hard("Where <mode> is the name of a previously defined feedback mode.");
-            hard("Currently defined feedback modes:");
+            hardrb("help.set.feedback");
             modeMap.keySet().stream()
                     .forEach(m -> hard("   %s", m));
-            hard("User-defined modes can be added, see '/help /set newmode'");
         }
 
         final void printNewModeHelp() {
-            hard("Create a user-defined feedback mode, optionally copying from an existing mode.");
-            hard("");
-            hard("/set newmode <new-mode> [command|quiet [<old-mode>]]");
-            hard("");
-            hard("Where <new-mode> is the name of a mode you wish to create.");
-            hard("Where <old-mode> is the name of a previously defined feedback mode.");
-            hard("If <old-mode> is present, its settings are copied to the new mode.");
-            hard("'command' vs 'quiet' determines if informative/verifying command feedback is displayed.");
-            hard("");
-            hard("Once the new mode is created, use '/set format', '/set field', and '/set prompt' to configure it.");
-            hard("Use '/set feedback' to use the new mode.");
+            hardrb("help.set.newmode");
         }
 
         final void printPromptHelp() {
-            hard("Set the prompts.  Both the normal prompt and the continuation-prompt must be set.");
-            hard("");
-            hard("/set prompt <mode> \"<prompt>\" \"<continuation-propmt>\"");
-            hard("");
-            hard("Where <mode> is the name of a previously defined feedback mode.");
-            hard("Where <prompt> and <continuation-propmt> are quoted strings printed as input promptds;");
-            hard("Both may optionally contain '%%s' which will be substituted with the next snippet id --");
-            hard("note that what is entered may not be assigned that id, for example it may be an error or command.");
-            hard("The continuation-prompt is used on the second and subsequent lines of a multi-line snippet.");
+            hardrb("help.set.prompt");
         }
     }
 }
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Mon Mar 28 08:41:54 2016 -0700
@@ -75,7 +75,6 @@
 import jdk.jshell.PersistentSnippet;
 import jdk.jshell.Snippet;
 import jdk.jshell.Snippet.Status;
-import jdk.jshell.Snippet.SubKind;
 import jdk.jshell.SnippetEvent;
 import jdk.jshell.SourceCodeAnalysis;
 import jdk.jshell.SourceCodeAnalysis.CompletionInfo;
@@ -95,10 +94,11 @@
 import java.util.function.Supplier;
 import jdk.internal.jshell.tool.Feedback.FormatAction;
 import jdk.internal.jshell.tool.Feedback.FormatCase;
+import jdk.internal.jshell.tool.Feedback.FormatErrors;
 import jdk.internal.jshell.tool.Feedback.FormatResolve;
+import jdk.internal.jshell.tool.Feedback.FormatUnresolved;
 import jdk.internal.jshell.tool.Feedback.FormatWhen;
 import static java.util.stream.Collectors.toList;
-import static jdk.jshell.Snippet.Kind.METHOD;
 import static java.util.stream.Collectors.toMap;
 import static jdk.jshell.Snippet.SubKind.VAR_VALUE_SUBKIND;
 
@@ -113,6 +113,12 @@
     private static final Pattern HISTORY_ALL_START_FILENAME = Pattern.compile(
             "((?<cmd>(all|history|start))(\\z|\\p{javaWhitespace}+))?(?<filename>.*)");
     private static final String RECORD_SEPARATOR = "\u241E";
+    private static final String RB_NAME_PREFIX  = "jdk.internal.jshell.tool.resources";
+    private static final String VERSION_RB_NAME = RB_NAME_PREFIX + ".version";
+    private static final String L10N_RB_NAME    = RB_NAME_PREFIX + ".l10n";
+    private static ResourceBundle versionRB = null;
+    private static ResourceBundle outputRB  = null;
+
 
     final InputStream cmdin;
     final PrintStream cmdout;
@@ -121,6 +127,7 @@
     final InputStream userin;
     final PrintStream userout;
     final PrintStream usererr;
+    final Preferences prefs;
 
     final Feedback feedback = new Feedback();
 
@@ -137,7 +144,8 @@
      */
     public JShellTool(InputStream cmdin, PrintStream cmdout, PrintStream cmderr,
             PrintStream console,
-            InputStream userin, PrintStream userout, PrintStream usererr) {
+            InputStream userin, PrintStream userout, PrintStream usererr,
+            Preferences prefs) {
         this.cmdin = cmdin;
         this.cmdout = cmdout;
         this.cmderr = cmderr;
@@ -145,82 +153,19 @@
         this.userin = userin;
         this.userout = userout;
         this.usererr = usererr;
-        initializeFeedbackModes();
-    }
-
-    /**
-     * Create the default set of feedback modes
-     */
-    final void initializeFeedbackModes() {
-        // Initialize normal feedback mode
-        cmdSet("newmode normal command");
-        cmdSet("prompt normal '\n-> ' '>> '");
-        cmdSet("field normal pre '|  '");
-        cmdSet("field normal post '%n'");
-        cmdSet("field normal errorpre '|  '");
-        cmdSet("field normal errorpost '%n'");
-        cmdSet("field normal action 'Added' added-primary");
-        cmdSet("field normal action 'Modified' modified-primary");
-        cmdSet("field normal action 'Replaced' replaced-primary");
-        cmdSet("field normal action 'Overwrote' overwrote-primary");
-        cmdSet("field normal action 'Dropped' dropped-primary");
-        cmdSet("field normal action 'Rejected' rejected-primary");
-        cmdSet("field normal action '  Update added' added-update");
-        cmdSet("field normal action '  Update modified' modified-update");
-        cmdSet("field normal action '  Update replaced' replaced-update");
-        cmdSet("field normal action '  Update overwrote' overwrote-update");
-        cmdSet("field normal action '  Update dropped' dropped-update");
-        cmdSet("field normal action '  Update rejected' rejected-update");
-        cmdSet("field normal resolve '' ok-*");
-        cmdSet("field normal resolve ', however, it cannot be invoked until%s is declared' defined-primary");
-        cmdSet("field normal resolve ', however, it cannot be referenced until%s is declared' notdefined-primary");
-        cmdSet("field normal resolve ' which cannot be invoked until%s is declared' defined-update");
-        cmdSet("field normal resolve ' which cannot be referenced until%s is declared' notdefined-update");
-        cmdSet("field normal name '%s'");
-        cmdSet("field normal type '%s'");
-        cmdSet("field normal result '%s'");
-
-        cmdSet("format normal '' *-*-*");
-
-        cmdSet("format normal '{pre}{action} class {name}{resolve}{post}' class");
-        cmdSet("format normal '{pre}{action} interface {name}{resolve}{post}' interface");
-        cmdSet("format normal '{pre}{action} enum {name}{resolve}{post}' enum");
-        cmdSet("format normal '{pre}{action} annotation interface {name}{resolve}{post}' annotation");
-
-        cmdSet("format normal '{pre}{action} method {name}({type}){resolve}{post}' method");
-
-        cmdSet("format normal '{pre}{action} variable {name} of type {type}{resolve}{post}' vardecl");
-        cmdSet("format normal '{pre}{action} variable {name} of type {type} with initial value {result}{resolve}{post}' varinit");
-        cmdSet("format normal '{pre}{action} variable {name}{resolve}{post}' vardeclrecoverable");
-        cmdSet("format normal '{pre}{action} variable {name}, reset to null{post}' varreset-*-update");
-
-        cmdSet("format normal '{pre}Expression value is: {result}{post}" +
-                "{pre}  assigned to temporary variable {name} of type {type}{post}' expression");
-        cmdSet("format normal '{pre}Variable {name} of type {type} has value {result}{post}' varvalue");
-        cmdSet("format normal '{pre}Variable {name} has been assigned the value {result}{post}' assignment");
-
-        cmdSet("feedback normal");
-
-        // Initialize off feedback mode
-        cmdSet("newmode off quiet");
-        cmdSet("prompt off '-> ' '>> '");
-        cmdSet("field off pre '|  '");
-        cmdSet("field off post '%n'");
-        cmdSet("field off errorpre '|  '");
-        cmdSet("field off errorpost '%n'");
-        cmdSet("format off '' *-*-*");
+        this.prefs = prefs;
     }
 
     private IOContext input = null;
     private boolean regenerateOnDeath = true;
     private boolean live = false;
+    private boolean feedbackInitialized = false;
 
     SourceCodeAnalysis analysis;
     JShell state = null;
     Subscription shutdownSubscription = null;
 
     private boolean debug = false;
-    private boolean displayPrompt = true;
     public boolean testPrompt = false;
     private String cmdlineClasspath = null;
     private String cmdlineStartup = null;
@@ -230,8 +175,6 @@
     private List<String> replayableHistory;
     private List<String> replayableHistoryPrevious;
 
-    static final Preferences PREFS = Preferences.userRoot().node("tool/JShell");
-
     static final String STARTUP_KEY = "STARTUP";
     static final String REPLAY_RESTORE_KEY = "REPLAY_RESTORE";
 
@@ -325,6 +268,43 @@
         }
     }
 
+    /**
+     * Print using resource bundle look-up and adding prefix and postfix
+     *
+     * @param key the resource key
+     */
+    String getResourceString(String key) {
+        if (outputRB == null) {
+            try {
+                outputRB = ResourceBundle.getBundle(L10N_RB_NAME);
+            } catch (MissingResourceException mre) {
+                error("Cannot find ResourceBundle: %s", L10N_RB_NAME);
+                return "";
+            }
+        }
+        String s;
+        try {
+            s = outputRB.getString(key);
+        } catch (MissingResourceException mre) {
+            error("Missing resource: %s in %s", key, L10N_RB_NAME);
+            return "";
+        }
+        return s;
+    }
+
+    /**
+     * Print using resource bundle look-up and adding prefix and postfix
+     *
+     * @param key the resource key
+     */
+    void hardrb(String key) {
+        String s = getResourceString(key);
+        String out = feedback.getPre()
+                + s.substring(0, s.length() - 1).replaceAll("\\R", "\n" + feedback.getPre())
+                + s.substring(s.length() - 1, s.length());
+        cmdout.print(out);
+    }
+
     <T> void hardPairs(Stream<T> stream, Function<T, String> a, Function<T, String> b) {
         Map<String, String> a2b = stream.collect(toMap(a, b,
                 (m1, m2) -> m1,
@@ -342,26 +322,6 @@
     }
 
     /**
-     * User custom feedback mode only
-     *
-     * @param fcase Event to report
-     * @param update Is this an update (rather than primary)
-     * @param fa Action
-     * @param fr Resolution status
-     * @param name Name string
-     * @param type Type string or null
-     * @param result Result value or null
-     * @param unresolved The unresolved symbols
-     */
-    void custom(FormatCase fcase, boolean update, FormatAction fa, FormatResolve fr,
-            String name, String type, String unresolved, String result) {
-        String format = feedback.getFormat(fcase,
-                (update ? FormatWhen.UPDATE : FormatWhen.PRIMARY), fa, fr,
-                name != null, type != null, result != null);
-        fluffRaw(format, unresolved, name, type, result);
-    }
-
-    /**
      * Trim whitespace off end of string
      *
      * @param s
@@ -387,7 +347,8 @@
      */
     public static void main(String[] args) throws Exception {
         new JShellTool(System.in, System.out, System.err, System.out,
-                 new ByteArrayInputStream(new byte[0]), System.out, System.err)
+                 new ByteArrayInputStream(new byte[0]), System.out, System.err,
+                 Preferences.userRoot().node("tool/JShell"))
                 .start(args);
     }
 
@@ -406,7 +367,7 @@
         resetState(); // Initialize
 
         // Read replay history from last jshell session into previous history
-        String prevReplay = PREFS.get(REPLAY_RESTORE_KEY, null);
+        String prevReplay = prefs.get(REPLAY_RESTORE_KEY, null);
         if (prevReplay != null) {
             replayableHistoryPrevious = Arrays.asList(prevReplay.split(RECORD_SEPARATOR));
         }
@@ -542,7 +503,6 @@
                         ? currentNameSpace.tid(sn)
                         : errorNamespace.tid(sn))
                 .build();
-        analysis = state.sourceCodeAnalysis();
         shutdownSubscription = state.onShutdown((JShell deadState) -> {
             if (deadState == state) {
                 hard("State engine terminated.");
@@ -550,7 +510,12 @@
                 live = false;
             }
         });
+        analysis = state.sourceCodeAnalysis();
         live = true;
+        if (!feedbackInitialized) {
+            startUpRun(getResourceString("startup.feedback"));
+            feedbackInitialized = true;
+        }
 
         if (cmdlineClasspath != null) {
             state.addToClasspath(cmdlineClasspath);
@@ -558,20 +523,24 @@
 
         String start;
         if (cmdlineStartup == null) {
-            start = PREFS.get(STARTUP_KEY, "<nada>");
+            start = prefs.get(STARTUP_KEY, "<nada>");
             if (start.equals("<nada>")) {
                 start = DEFAULT_STARTUP;
-                PREFS.put(STARTUP_KEY, DEFAULT_STARTUP);
+                prefs.put(STARTUP_KEY, DEFAULT_STARTUP);
             }
         } else {
             start = cmdlineStartup;
         }
+        startUpRun(start);
+        currentNameSpace = mainNamespace;
+    }
+    //where
+    private void startUpRun(String start) {
         try (IOContext suin = new FileScannerIOContext(new StringReader(start))) {
             run(suin);
         } catch (Exception ex) {
             hard("Unexpected exception reading start-up: %s\n", ex);
         }
-        currentNameSpace = mainNamespace;
     }
 
     private void closeState() {
@@ -594,7 +563,7 @@
             String incomplete = "";
             while (live) {
                 String prompt;
-                if (displayPrompt) {
+                if (currentNameSpace == mainNamespace) {
                     prompt = testPrompt
                                     ? incomplete.isEmpty()
                                             ? "\u0005" //ENQ
@@ -677,21 +646,22 @@
             cmd = cmd.substring(0, idx);
         }
         Command[] candidates = findCommand(cmd, c -> c.kind.isRealCommand);
-        if (candidates.length == 0) {
-            if (!rerunHistoryEntryById(cmd.substring(1))) {
-                error("No such command or snippet id: %s", cmd);
+        switch (candidates.length) {
+            case 0:
+                if (!rerunHistoryEntryById(cmd.substring(1))) {
+                    error("No such command or snippet id: %s", cmd);
+                    fluff("Type /help for help.");
+                }   break;
+            case 1:
+                Command command = candidates[0];
+                // If comand was successful and is of a replayable kind, add it the replayable history
+                if (command.run.apply(arg) && command.kind == CommandKind.REPLAY) {
+                    addToReplayHistory((command.command + " " + arg).trim());
+                }   break;
+            default:
+                error("Command: %s is ambiguous: %s", cmd, Arrays.stream(candidates).map(c -> c.command).collect(Collectors.joining(", ")));
                 fluff("Type /help for help.");
-            }
-        } else if (candidates.length == 1) {
-            Command command = candidates[0];
-
-            // If comand was successful and is of a replayable kind, add it the replayable history
-            if (command.run.apply(arg) && command.kind == CommandKind.REPLAY) {
-                addToReplayHistory((command.command + " " + arg).trim());
-            }
-        } else {
-            error("Command: %s is ambiguous: %s", cmd, Arrays.stream(candidates).map(c -> c.command).collect(Collectors.joining(", ")));
-            fluff("Type /help for help.");
+                break;
         }
     }
 
@@ -1020,7 +990,7 @@
                 "  -- Display information about the specified help subject. Example: /help intro\n",
                 arg -> cmdHelp(arg),
                 EMPTY_COMPLETION_PROVIDER));
-        registerCommand(new Command("/set", "editor|start|feedback|newmode|prompt|format|field ...", "set jshell configuration information",
+        registerCommand(new Command("/set", "editor|start|feedback|newmode|prompt|format ...", "set jshell configuration information",
                 "Set jshell configuration information, including:\n" +
                 "the external editor to use, the start-up definitions to use, a new feedback mode,\n" +
                 "the command prompt, the feedback mode to use, or the format of output.\n" +
@@ -1041,16 +1011,13 @@
                 "/set prompt <mode> \"<prompt>\" \"<continuation-prompt>\"\n" +
                 "  -- Set the displayed prompts for a given feedback mode.\n" +
                 "\n" +
-                "/set format <mode> \"<format>\" <selector>...\n" +
-                "  -- Configure a feedback mode by setting the format to use in a specified set of cases.\n" +
-                "\n" +
-                "/set field name|type|result|when|action|resolve|pre|post|errorpre|errorpost \"<format>\"  <format-case>...\n" +
-                "  -- Set the format of a field within the <format-string> of a \"/set format\" command\n" +
+                "/set format <mode> <field> \"<format>\" <selector>...\n" +
+                "  -- Configure a feedback mode by setting the format of a field when the selector matchs.\n" +
                 "\n" +
                 "To get more information about one of these forms, use /help with the form specified.\n" +
                 "For example:   /help /set format\n",
                 arg -> cmdSet(arg),
-                new FixedCompletionProvider("format", "field", "feedback", "prompt", "newmode", "start", "editor")));
+                new FixedCompletionProvider("format", "feedback", "prompt", "newmode", "start", "editor")));
         registerCommand(new Command("/?", "", "get information about jshell",
                 "Display information about jshell (abbreviation for /help).\n" +
                 "/?\n" +
@@ -1151,11 +1118,9 @@
 
     // --- Command implementations ---
 
-    private static final String[] setSub = new String[]{
-        "format", "field", "feedback", "newmode", "prompt", "editor", "start"};
+    private static final String[] SET_SUBCOMMANDS = new String[]{
+        "format", "feedback", "newmode", "prompt", "editor", "start"};
 
-    // The /set command.  Currently /set format, /set field and /set feedback.
-    // Other commands will fold here, see: 8148317
     final boolean cmdSet(String arg) {
         ArgTokenizer at = new ArgTokenizer(arg.trim());
         String which = setSubCommand(at);
@@ -1165,8 +1130,6 @@
         switch (which) {
             case "format":
                 return feedback.setFormat(this, at);
-            case "field":
-                return feedback.setField(this, at);
             case "feedback":
                 return feedback.setFeedback(this, at);
             case "newmode":
@@ -1198,7 +1161,7 @@
                     try {
                         byte[] encoded = Files.readAllBytes(toPathResolvingUserHome(filename));
                         String init = new String(encoded);
-                        PREFS.put(STARTUP_KEY, init);
+                        prefs.put(STARTUP_KEY, init);
                     } catch (AccessDeniedException e) {
                         hard("File '%s' for /set start is not accessible.", filename);
                         return false;
@@ -1227,9 +1190,6 @@
             case "format":
                 feedback.printFormatHelp(this);
                 return true;
-            case "field":
-                feedback.printFieldHelp(this);
-                return true;
             case "feedback":
                 feedback.printFeedbackHelp(this);
                 return true;
@@ -1263,13 +1223,13 @@
     }
 
     String setSubCommand(ArgTokenizer at) {
-        String[] matches = at.next(setSub);
+        String[] matches = at.next(SET_SUBCOMMANDS);
         if (matches == null) {
             error("The /set command requires arguments. See: /help /set");
             return null;
         } else if (matches.length == 0) {
             error("Not a valid argument to /set: %s", at.val());
-            fluff("/set is followed by one of: %s", Arrays.stream(setSub)
+            fluff("/set is followed by one of: %s", Arrays.stream(SET_SUBCOMMANDS)
                     .collect(Collectors.joining(", "))
             );
             return null;
@@ -1347,8 +1307,20 @@
         regenerateOnDeath = false;
         live = false;
         if (!replayableHistory.isEmpty()) {
-            PREFS.put(REPLAY_RESTORE_KEY, replayableHistory.stream().reduce(
-                    (a, b) -> a + RECORD_SEPARATOR + b).get());
+            // Prevent history overflow by calculating what will fit, starting
+            // with must recent
+            int sepLen = RECORD_SEPARATOR.length();
+            int length = 0;
+            int first = replayableHistory.size();
+            while(length < Preferences.MAX_VALUE_LENGTH && --first >= 0) {
+                length += replayableHistory.get(first).length() + sepLen;
+            }
+            String hist = replayableHistory
+                    .subList(first + 1, replayableHistory.size())
+                    .stream()
+                    .reduce( (a, b) -> a + RECORD_SEPARATOR + b)
+                    .get();
+            prefs.put(REPLAY_RESTORE_KEY, hist);
         }
         fluff("Goodbye\n");
         return true;
@@ -1839,68 +1811,55 @@
                 .collect(toList());
     }
 
-    void printDiagnostics(String source, List<Diag> diagnostics, boolean embed) {
-        String padding = embed? "    " : "";
-        for (Diag diag : diagnostics) {
-            //assert diag.getSource().equals(source);
+    void displayDiagnostics(String source, Diag diag, List<String> toDisplay) {
+        for (String line : diag.getMessage(null).split("\\r?\\n")) { // TODO: Internationalize
+            if (!line.trim().startsWith("location:")) {
+                toDisplay.add(line);
+            }
+        }
 
-            if (!embed) {
-                if (diag.isError()) {
-                    hard("Error:");
-                } else {
-                    hard("Warning:");
-                }
+        int pstart = (int) diag.getStartPosition();
+        int pend = (int) diag.getEndPosition();
+        Matcher m = LINEBREAK.matcher(source);
+        int pstartl = 0;
+        int pendl = -2;
+        while (m.find(pstartl)) {
+            pendl = m.start();
+            if (pendl >= pstart) {
+                break;
+            } else {
+                pstartl = m.end();
             }
-
-            for (String line : diag.getMessage(null).split("\\r?\\n")) { // TODO: Internationalize
-                if (!line.trim().startsWith("location:")) {
-                    hard("%s%s", padding, line);
-                }
-            }
+        }
+        if (pendl < pstart) {
+            pendl = source.length();
+        }
+        toDisplay.add(source.substring(pstartl, pendl));
 
-            int pstart = (int) diag.getStartPosition();
-            int pend = (int) diag.getEndPosition();
-            Matcher m = LINEBREAK.matcher(source);
-            int pstartl = 0;
-            int pendl = -2;
-            while (m.find(pstartl)) {
-                pendl = m.start();
-                if (pendl >= pstart) {
-                    break;
-                } else {
-                    pstartl = m.end();
-                }
+        StringBuilder sb = new StringBuilder();
+        int start = pstart - pstartl;
+        for (int i = 0; i < start; ++i) {
+            sb.append(' ');
+        }
+        sb.append('^');
+        boolean multiline = pend > pendl;
+        int end = (multiline ? pendl : pend) - pstartl - 1;
+        if (end > start) {
+            for (int i = start + 1; i < end; ++i) {
+                sb.append('-');
             }
-            if (pendl < pstart) {
-                pendl = source.length();
+            if (multiline) {
+                sb.append("-...");
+            } else {
+                sb.append('^');
             }
-            fluff("%s%s", padding, source.substring(pstartl, pendl));
+        }
+        toDisplay.add(sb.toString());
 
-            StringBuilder sb = new StringBuilder();
-            int start = pstart - pstartl;
-            for (int i = 0; i < start; ++i) {
-                sb.append(' ');
-            }
-            sb.append('^');
-            boolean multiline = pend > pendl;
-            int end = (multiline ? pendl : pend) - pstartl - 1;
-            if (end > start) {
-                for (int i = start + 1; i < end; ++i) {
-                    sb.append('-');
-                }
-                if (multiline) {
-                    sb.append("-...");
-                } else {
-                    sb.append('^');
-                }
-            }
-            fluff("%s%s", padding, sb.toString());
-
-            debug("printDiagnostics start-pos = %d ==> %d -- wrap = %s", diag.getStartPosition(), start, this);
-            debug("Code: %s", diag.getCode());
-            debug("Pos: %d (%d - %d)", diag.getPosition(),
-                    diag.getStartPosition(), diag.getEndPosition());
-        }
+        debug("printDiagnostics start-pos = %d ==> %d -- wrap = %s", diag.getStartPosition(), start, this);
+        debug("Code: %s", diag.getCode());
+        debug("Pos: %d (%d - %d)", diag.getPosition(),
+                diag.getStartPosition(), diag.getEndPosition());
     }
 
     private String processSource(String srcInput) throws IllegalStateException {
@@ -1941,6 +1900,7 @@
         return failed;
     }
 
+    // Handle incoming snippet events -- return true on failure
     private boolean handleEvent(SnippetEvent ste) {
         Snippet sn = ste.snippet();
         if (sn == null) {
@@ -1951,162 +1911,49 @@
         String source = sn.source();
         if (ste.causeSnippet() == null) {
             // main event
-            printDiagnostics(source, diagnostics, false);
-            if (ste.status().isActive) {
+            for (Diag d : diagnostics) {
+                if (d.isError()) {
+                    hard("Error:");
+                } else {
+                    hard("Warning:");
+                }
+                List<String> disp = new ArrayList<>();
+                displayDiagnostics(source, d, disp);
+                disp.stream()
+                        .forEach(l -> hard(l));
+            }
+
+            if (ste.status() != Status.REJECTED) {
                 if (ste.exception() != null) {
                     if (ste.exception() instanceof EvalException) {
                         printEvalException((EvalException) ste.exception());
                         return true;
                     } else if (ste.exception() instanceof UnresolvedReferenceException) {
-                        printUnresolved((UnresolvedReferenceException) ste.exception());
+                        printUnresolvedException((UnresolvedReferenceException) ste.exception());
                     } else {
                         hard("Unexpected execution exception: %s", ste.exception());
                         return true;
                     }
                 } else {
-                    displayDeclarationAndValue(ste, false, ste.value());
+                    new DisplayEvent(ste, false, ste.value(), diagnostics).displayDeclarationAndValue();
                 }
-            } else if (ste.status() == Status.REJECTED) {
+            } else {
                 if (diagnostics.isEmpty()) {
                     hard("Failed.");
                 }
                 return true;
             }
-        } else if (ste.status() == Status.REJECTED) {
-            //TODO -- I don't believe updates can cause failures any more
-            hard("Caused failure of dependent %s --", ((DeclarationSnippet) sn).name());
-            printDiagnostics(source, diagnostics, true);
         } else {
             // Update
             if (sn instanceof DeclarationSnippet) {
-                // display update information
-                displayDeclarationAndValue(ste, true, ste.value());
+                List<Diag> other = errorsOnly(diagnostics);
 
-                List<Diag> other = errorsOnly(diagnostics);
-                if (other.size() > 0) {
-                    printDiagnostics(source, other, true);
-                }
+                // display update information
+                new DisplayEvent(ste, true, ste.value(), other).displayDeclarationAndValue();
             }
         }
         return false;
     }
-
-    @SuppressWarnings("fallthrough")
-    private void displayDeclarationAndValue(SnippetEvent ste, boolean update, String value) {
-        Snippet key = ste.snippet();
-        FormatAction action;
-        Status status = ste.status();
-        switch (status) {
-            case VALID:
-            case RECOVERABLE_DEFINED:
-            case RECOVERABLE_NOT_DEFINED:
-                if (ste.previousStatus().isActive) {
-                    action = ste.isSignatureChange()
-                        ? FormatAction.REPLACED
-                        : FormatAction.MODIFIED;
-                } else {
-                    action = FormatAction.ADDED;
-                }
-                break;
-            case OVERWRITTEN:
-                action = FormatAction.OVERWROTE;
-                break;
-            case DROPPED:
-                action = FormatAction.DROPPED;
-                break;
-            case REJECTED:
-                action = FormatAction.REJECTED;
-                break;
-            case NONEXISTENT:
-            default:
-                // Should not occur
-                error("Unexpected status: " + ste.previousStatus().toString() + "=>" + status.toString());
-                return;
-        }
-        FormatResolve resolution;
-        String unresolved;
-        if (key instanceof DeclarationSnippet && (status == Status.RECOVERABLE_DEFINED || status == Status.RECOVERABLE_NOT_DEFINED)) {
-            resolution = (status == Status.RECOVERABLE_NOT_DEFINED)
-                    ? FormatResolve.NOTDEFINED
-                    : FormatResolve.DEFINED;
-            unresolved = unresolved((DeclarationSnippet) key);
-        } else {
-            resolution = FormatResolve.OK;
-            unresolved = "";
-        }
-        switch (key.subKind()) {
-            case CLASS_SUBKIND:
-                custom(FormatCase.CLASS, update, action, resolution,
-                        ((TypeDeclSnippet) key).name(), null, unresolved, null);
-                break;
-            case INTERFACE_SUBKIND:
-                custom(FormatCase.INTERFACE, update, action, resolution,
-                        ((TypeDeclSnippet) key).name(), null, unresolved, null);
-                break;
-            case ENUM_SUBKIND:
-                custom(FormatCase.ENUM, update, action, resolution,
-                        ((TypeDeclSnippet) key).name(), null, unresolved, null);
-                break;
-            case ANNOTATION_TYPE_SUBKIND:
-                custom(FormatCase.ANNOTATION, update, action, resolution,
-                        ((TypeDeclSnippet) key).name(), null, unresolved, null);
-                break;
-            case METHOD_SUBKIND:
-                custom(FormatCase.METHOD, update, action, resolution,
-                        ((MethodSnippet) key).name(), ((MethodSnippet) key).parameterTypes(), unresolved, null);
-                break;
-            case VAR_DECLARATION_SUBKIND:
-            case VAR_DECLARATION_WITH_INITIALIZER_SUBKIND: {
-                VarSnippet vk = (VarSnippet) key;
-                if (status == Status.RECOVERABLE_NOT_DEFINED) {
-                    custom(FormatCase.VARDECLRECOVERABLE, update, action, resolution,
-                            vk.name(), null, unresolved, null);
-                } else if (update && ste.isSignatureChange()) {
-                    custom(FormatCase.VARRESET, update, action, resolution,
-                            vk.name(), null, unresolved, value);
-                } else if (key.subKind() == SubKind.VAR_DECLARATION_WITH_INITIALIZER_SUBKIND) {
-                    custom(FormatCase.VARINIT, update, action, resolution,
-                            vk.name(), vk.typeName(), unresolved, value);
-                } else {
-                    custom(FormatCase.VARDECL, update, action, resolution,
-                            vk.name(), vk.typeName(), unresolved, value);
-                }
-                break;
-            }
-            case TEMP_VAR_EXPRESSION_SUBKIND: {
-                VarSnippet vk = (VarSnippet) key;
-                custom(FormatCase.EXPRESSION, update, action, resolution,
-                        vk.name(), vk.typeName(), null, value);
-                break;
-            }
-            case OTHER_EXPRESSION_SUBKIND:
-                error("Unexpected expression form -- value is: %s", (value));
-                break;
-            case VAR_VALUE_SUBKIND: {
-                ExpressionSnippet ek = (ExpressionSnippet) key;
-                custom(FormatCase.VARVALUE, update, action, resolution,
-                        ek.name(), ek.typeName(), null, value);
-                break;
-            }
-            case ASSIGNMENT_SUBKIND: {
-                ExpressionSnippet ek = (ExpressionSnippet) key;
-                custom(FormatCase.ASSIGNMENT, update, action, resolution,
-                        ek.name(), ek.typeName(), null, value);
-                break;
-            }
-            case SINGLE_TYPE_IMPORT_SUBKIND:
-            case TYPE_IMPORT_ON_DEMAND_SUBKIND:
-            case SINGLE_STATIC_IMPORT_SUBKIND:
-            case STATIC_IMPORT_ON_DEMAND_SUBKIND:
-                custom(FormatCase.IMPORT, update, action, resolution,
-                        ((ImportSnippet) key).name(), null, null, null);
-                break;
-            case STATEMENT_SUBKIND:
-                custom(FormatCase.STATEMENT, update, action, resolution,
-                        null, null, null, null);
-                break;
-        }
-    }
     //where
     void printStackTrace(StackTraceElement[] stes) {
         for (StackTraceElement ste : stes) {
@@ -2139,31 +1986,11 @@
         }
     }
     //where
-    void printUnresolved(UnresolvedReferenceException ex) {
+    void printUnresolvedException(UnresolvedReferenceException ex) {
         DeclarationSnippet corralled =  ex.getSnippet();
         List<Diag> otherErrors = errorsOnly(state.diagnostics(corralled));
-        StringBuilder sb = new StringBuilder();
-        if (otherErrors.size() > 0) {
-            if (state.unresolvedDependencies(corralled).size() > 0) {
-                sb.append(" and");
-            }
-            if (otherErrors.size() == 1) {
-                sb.append(" this error is addressed --");
-            } else {
-                sb.append(" these errors are addressed --");
-            }
-        } else {
-            sb.append(".");
-        }
-
-        String format = corralled.kind() == METHOD
-                ? "Attempted to call %s which cannot be invoked until%s"
-                : "Attempted to use %s which cannot be accessed until%s";
-        hard(format, corralled.name(),
-                unresolved(corralled), sb.toString());
-        if (otherErrors.size() > 0) {
-            printDiagnostics(corralled.source(), otherErrors, true);
-        }
+        new DisplayEvent(corralled, state.status(corralled), FormatAction.USED, true, null, otherErrors)
+                .displayDeclarationAndValue();
     }
     //where
     void printEvalException(EvalException ex) {
@@ -2174,26 +2001,180 @@
         }
         printStackTrace(ex.getStackTrace());
     }
-    //where
-    String unresolved(DeclarationSnippet key) {
-        List<String> unr = state.unresolvedDependencies(key);
-        StringBuilder sb = new StringBuilder();
-        int fromLast = unr.size();
-        if (fromLast > 0) {
-            sb.append(" ");
+
+    private FormatAction toAction(Status status, Status previousStatus, boolean isSignatureChange) {
+        FormatAction act;
+        switch (status) {
+            case VALID:
+            case RECOVERABLE_DEFINED:
+            case RECOVERABLE_NOT_DEFINED:
+                if (previousStatus.isActive) {
+                    act = isSignatureChange
+                            ? FormatAction.REPLACED
+                            : FormatAction.MODIFIED;
+                } else {
+                    act = FormatAction.ADDED;
+                }
+                break;
+            case OVERWRITTEN:
+                act = FormatAction.OVERWROTE;
+                break;
+            case DROPPED:
+                act = FormatAction.DROPPED;
+                break;
+            case REJECTED:
+            case NONEXISTENT:
+            default:
+                // Should not occur
+                error("Unexpected status: " + previousStatus.toString() + "=>" + status.toString());
+                act = FormatAction.DROPPED;
+        }
+        return act;
+    }
+
+    class DisplayEvent {
+        private final Snippet sn;
+        private final FormatAction action;
+        private final boolean update;
+        private final String value;
+        private final List<String> errorLines;
+        private final FormatResolve resolution;
+        private final String unresolved;
+        private final FormatUnresolved unrcnt;
+        private final FormatErrors errcnt;
+
+        DisplayEvent(SnippetEvent ste, boolean update, String value, List<Diag> errors) {
+            this(ste.snippet(), ste.status(), toAction(ste.status(), ste.previousStatus(), ste.isSignatureChange()), update, value, errors);
         }
-        for (String u : unr) {
-            --fromLast;
-            sb.append(u);
-            if (fromLast == 0) {
-                // No suffix
-            } else if (fromLast == 1) {
-                sb.append(", and ");
+
+        DisplayEvent(Snippet sn, Status status, FormatAction action, boolean update, String value, List<Diag> errors) {
+            this.sn = sn;
+            this.action = action;
+            this.update = update;
+            this.value = value;
+            this.errorLines = new ArrayList<>();
+            for (Diag d : errors) {
+                displayDiagnostics(sn.source(), d, errorLines);
+            }
+            int unresolvedCount;
+            if (sn instanceof DeclarationSnippet && (status == Status.RECOVERABLE_DEFINED || status == Status.RECOVERABLE_NOT_DEFINED)) {
+                resolution = (status == Status.RECOVERABLE_NOT_DEFINED)
+                        ? FormatResolve.NOTDEFINED
+                        : FormatResolve.DEFINED;
+                unresolved = unresolved((DeclarationSnippet) sn);
+                unresolvedCount = state.unresolvedDependencies((DeclarationSnippet) sn).size();
             } else {
-                sb.append(", ");
+                resolution = FormatResolve.OK;
+                unresolved = "";
+                unresolvedCount = 0;
+            }
+            unrcnt = unresolvedCount == 0
+                    ? FormatUnresolved.UNRESOLVED0
+                    : unresolvedCount == 1
+                        ? FormatUnresolved.UNRESOLVED1
+                        : FormatUnresolved.UNRESOLVED2;
+            errcnt = errors.isEmpty()
+                    ? FormatErrors.ERROR0
+                    : errors.size() == 1
+                        ? FormatErrors.ERROR1
+                        : FormatErrors.ERROR2;
+        }
+
+        private String unresolved(DeclarationSnippet key) {
+            List<String> unr = state.unresolvedDependencies(key);
+            StringBuilder sb = new StringBuilder();
+            int fromLast = unr.size();
+            if (fromLast > 0) {
+                sb.append(" ");
+            }
+            for (String u : unr) {
+                --fromLast;
+                sb.append(u);
+                switch (fromLast) {
+                    // No suffix
+                    case 0:
+                        break;
+                    case 1:
+                        sb.append(", and ");
+                        break;
+                    default:
+                        sb.append(", ");
+                        break;
+                }
+            }
+            return sb.toString();
+        }
+
+        private void custom(FormatCase fcase, String name) {
+            custom(fcase, name, null);
+        }
+
+        private void custom(FormatCase fcase, String name, String type) {
+            String display = feedback.format(fcase, action, (update ? FormatWhen.UPDATE : FormatWhen.PRIMARY),
+                    resolution, unrcnt, errcnt,
+                    name, type, value, unresolved, errorLines);
+            if (interactive()) {
+                cmdout.print(display);
             }
         }
-        return sb.toString();
+
+        @SuppressWarnings("fallthrough")
+        private void displayDeclarationAndValue() {
+            switch (sn.subKind()) {
+                case CLASS_SUBKIND:
+                    custom(FormatCase.CLASS, ((TypeDeclSnippet) sn).name());
+                    break;
+                case INTERFACE_SUBKIND:
+                    custom(FormatCase.INTERFACE, ((TypeDeclSnippet) sn).name());
+                    break;
+                case ENUM_SUBKIND:
+                    custom(FormatCase.ENUM, ((TypeDeclSnippet) sn).name());
+                    break;
+                case ANNOTATION_TYPE_SUBKIND:
+                    custom(FormatCase.ANNOTATION, ((TypeDeclSnippet) sn).name());
+                    break;
+                case METHOD_SUBKIND:
+                    custom(FormatCase.METHOD, ((MethodSnippet) sn).name(), ((MethodSnippet) sn).parameterTypes());
+                    break;
+                case VAR_DECLARATION_SUBKIND: {
+                    VarSnippet vk = (VarSnippet) sn;
+                    custom(FormatCase.VARDECL, vk.name(), vk.typeName());
+                    break;
+                }
+                case VAR_DECLARATION_WITH_INITIALIZER_SUBKIND: {
+                    VarSnippet vk = (VarSnippet) sn;
+                    custom(FormatCase.VARINIT, vk.name(), vk.typeName());
+                    break;
+                }
+                case TEMP_VAR_EXPRESSION_SUBKIND: {
+                    VarSnippet vk = (VarSnippet) sn;
+                    custom(FormatCase.EXPRESSION, vk.name(), vk.typeName());
+                    break;
+                }
+                case OTHER_EXPRESSION_SUBKIND:
+                    error("Unexpected expression form -- value is: %s", (value));
+                    break;
+                case VAR_VALUE_SUBKIND: {
+                    ExpressionSnippet ek = (ExpressionSnippet) sn;
+                    custom(FormatCase.VARVALUE, ek.name(), ek.typeName());
+                    break;
+                }
+                case ASSIGNMENT_SUBKIND: {
+                    ExpressionSnippet ek = (ExpressionSnippet) sn;
+                    custom(FormatCase.ASSIGNMENT, ek.name(), ek.typeName());
+                    break;
+                }
+                case SINGLE_TYPE_IMPORT_SUBKIND:
+                case TYPE_IMPORT_ON_DEMAND_SUBKIND:
+                case SINGLE_STATIC_IMPORT_SUBKIND:
+                case STATIC_IMPORT_ON_DEMAND_SUBKIND:
+                    custom(FormatCase.IMPORT, ((ImportSnippet) sn).name());
+                    break;
+                case STATEMENT_SUBKIND:
+                    custom(FormatCase.STATEMENT, null);
+                    break;
+            }
+        }
     }
 
     /** The current version number as a string.
@@ -2208,13 +2189,10 @@
         return version("full"); // mm.mm.oo[-milestone]-build
     }
 
-    private static final String versionRBName = "jdk.internal.jshell.tool.resources.version";
-    private static ResourceBundle versionRB;
-
     private static String version(String key) {
         if (versionRB == null) {
             try {
-                versionRB = ResourceBundle.getBundle(versionRBName);
+                versionRB = ResourceBundle.getBundle(VERSION_RB_NAME);
             } catch (MissingResourceException e) {
                 return "(version info not available)";
             }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,179 @@
+#
+# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+help.set.format = \
+Set the format for reporting a snippet event.\n\
+\n\
+/set format <mode> <field> "<format>" <selector>...\n\
+\n\
+Where <mode> is the name of a previously defined feedback mode -- see '/help /set newmode'.\n\
+Where <field> is the name of context-specific format to define.\n\
+Where <format> is a quoted string which will be the value of the field if one of\n\
+the selectors matches (or there are no selectors). When the format is used,\n\
+field names enclosed in braces are replaced with the value of the field at that\n\
+time. These fields may have been previously defined with this command or may be\n\
+one of these predefined fields specific to the context:\n\t\
+{name}       == The name, e.g.: the variable name, ...\n\t\
+{type}       == The type name. The type of a variable or expression, the\n\t\t\t\
+                 parameter types of a method\n\t\
+{value}      == The result value of an expression or variable initialization\n\t\
+{unresolved} == The list of unresolved references\n\t\
+{errors}     == The list of recoverable errors (during the processing of the\n\t\t\t\
+                "display" field only)\n\t\
+{err}        == An unformatted error line (during the processing of the\n\t\t\t\
+                "errorline" field only)\n\
+The following fields are accessed by the tool to determine the displayed feedback:\n\t\
+{display}    == The displayed message for a snippet event\n\t\
+{errorline}  == The format of one error line within the "errors" field\n\t\
+{pre}        == The feedback prefix (begins command feedback)\n\t\
+{post}       == The feedback postfix (ends command feedback)\n\t\
+{errorpre}   == The error prefix (begins error feedback)\n\t\
+{errorpost}  == The error postfix (ends error feedback)\n\
+These fields have default settings (which may be overwritten).\n\
+Where <selector> is the context in which the format is applied.\n\
+The structure of selector is a hyphen separated list of selector kind lists.\n\
+A selector kind list is a comma separated list of values of one selector kind.\n\
+A selector matches if each selector kind list matches; A selector kind list\n\
+matches if one of the values matches.\n
+help.set.format.case = The case selector kind describes the kind of snippet.  The values are:\n
+help.set.format.action = The action selector kind describes what happened to the snippet.  The values are:\n
+help.set.format.when = The when-did-it-occur selector kind describes if this is a direct or indirect action.  The values are:\n
+help.set.format.resolve = The resolution-state selector kind describes the state of resolution/definition of the snippet.  The values are:\n
+help.set.format.unresolved = The unresolved-count selector kind describes the number of unresolved references.  The values are:\n
+help.set.format.errors = The errors-count selector kind describes the number of errors.  The values are:\n
+help.set.format.end = \n\
+Examples:\n\t\
+/set format myformat action 'Created' added-primary\n\t\
+/set format myformat action 'Update replaced' replaced-update\n\t\
+/set format myformat display '{pre}{action} class {name}{post}' class-ok\n\t\
+/set format myformat display '{pre}{action} variable {name}, reset to null{post}' replaced-vardecl,varinit-ok-update\n\n\
+Note that subsequent selectors for a field may overwrite some or all of previous used selectors -- last one wins\n
+
+help.set.feedback = \
+Set the feedback mode describing displayed feedback for entered snippets and commands.\n\
+\n\
+/set feedback <mode>\n\
+\n\
+Where <mode> is the name of a previously defined feedback mode.\n\
+You may use just enough letters to make it unique.\n\
+User-defined modes can be added, see '/help /set newmode'\n\
+Currently defined feedback modes:\n
+
+help.set.newmode = \
+Create a user-defined feedback mode, optionally copying from an existing mode.\n\
+\n\
+/set newmode <new-mode> [command|quiet [<old-mode>]]\n\
+\n\
+Where <new-mode> is the name of a mode you wish to create.\n\
+Where <old-mode> is the name of a previously defined feedback mode.\n\
+If <old-mode> is present, its settings are copied to the new mode.\n\
+'command' vs 'quiet' determines if informative/verifying command feedback is displayed.\n\
+\n\
+Once the new mode is created, use '/set format' and '/set prompt' to configure it.\n\
+Use '/set feedback' to use the new mode.\n\
+
+help.set.prompt = \
+Set the prompts.  Both the normal prompt and the continuation-prompt must be set.\n\
+\n\
+/set prompt <mode> \"<prompt>\" \"<continuation-propmt>\"\n\
+\n\
+Where <mode> is the name of a previously defined feedback mode.\n\
+Where <prompt> and <continuation-propmt> are quoted strings printed as input prompts;\n\
+Both may optionally contain '%s' which will be substituted with the next snippet id --\n\
+note that what is entered may not be assigned that id, for example it may be an error or command.\n\
+The continuation-prompt is used on the second and subsequent lines of a multi-line snippet.\n
+
+startup.feedback = \
+/set newmode normal command    \n\
+/set prompt normal '\\n-> ' '>> '    \n\
+/set format normal pre '|  '    \n\
+/set format normal post '%n'    \n\
+/set format normal errorpre '|  '    \n\
+/set format normal errorpost '%n'    \n\
+    \n\
+/set format normal errorline '{post}{pre}    {err}'    \n\
+    \n\
+/set format normal action 'Added' added-primary    \n\
+/set format normal action 'Modified' modified-primary    \n\
+/set format normal action 'Replaced' replaced-primary    \n\
+/set format normal action 'Overwrote' overwrote-primary    \n\
+/set format normal action 'Dropped' dropped-primary    \n\
+/set format normal action '  Update added' added-update    \n\
+/set format normal action '  Update modified' modified-update    \n\
+/set format normal action '  Update replaced' replaced-update    \n\
+/set format normal action '  Update overwrote' overwrote-update    \n\
+/set format normal action '  Update dropped' dropped-update    \n\
+    \n\
+/set format normal until ', however, it cannot be instanciated or its methods invoked until'  defined-class-primary    \n\
+/set format normal until ', however, its methods cannot be invoked until'                     defined-interface-primary    \n\
+/set format normal until ', however, it cannot be used until'                                 defined-enum,annotation-primary    \n\
+/set format normal until ', however, it cannot be invoked until'                              defined-method-primary    \n\
+/set format normal until ', however, it cannot be referenced until'                           notdefined-primary    \n\
+/set format normal until ' which cannot be instanciated or its methods invoked until'         defined-class-update    \n\
+/set format normal until ' whose methods cannot be invoked until'                             defined-interface-update    \n\
+/set format normal until ' which cannot be invoked until'                                     defined-method-update    \n\
+/set format normal until ' which cannot be referenced until'                                  notdefined-update    \n\
+    \n\
+/set format normal unrerr '{unresolved} is declared'                                           unresolved1-error0    \n\
+/set format normal unrerr '{unresolved} are declared'                                          unresolved2-error0    \n\
+/set format normal unrerr ' this error is corrected: {errors}'                                 unresolved0-error1    \n\
+/set format normal unrerr '{unresolved} is declared and this error is corrected: {errors}'     unresolved1-error1    \n\
+/set format normal unrerr '{unresolved} are declared and this error is corrected: {errors}'    unresolved2-error1    \n\
+/set format normal unrerr ' these errors are corrected: {errors}'                              unresolved0-error2    \n\
+/set format normal unrerr '{unresolved} is declared and these errors are corrected: {errors}'  unresolved1-error2    \n\
+/set format normal unrerr '{unresolved} are declared and these errors are corrected: {errors}' unresolved2-error2    \n\
+    \n\
+/set format normal resolve '{until}{unrerr}'                                                added,modified,replaced,used    \n\
+    \n\
+/set format normal typeKind 'class'                  class    \n\
+/set format normal typeKind 'interface'              interface    \n\
+/set format normal typeKind 'enum'                   enum    \n\
+/set format normal typeKind 'annotation interface'   annotation    \n\
+    \n\
+/set format normal display '{pre}{action} {typeKind} {name}{resolve}{post}'                 class,interface,enum,annotation    \n\
+/set format normal display '{pre}{action} method {name}({type}){resolve}{post}'             method    \n\
+    \n\
+/set format normal display '{pre}{action} variable {name} of type {type}{resolve}{post}'    vardecl    \n\
+/set format normal display '{pre}{action} variable {name} of type {type} with initial value {value}{resolve}{post}'    varinit    \n\
+/set format normal display '{pre}{action} variable {name}, reset to null{post}'             replaced-vardecl,varinit-ok-update    \n\
+/set format normal display '{pre}{action} variable {name}{resolve}{post}'                   vardecl,varinit-notdefined    \n\
+/set format normal display '{pre}{action} variable {name}{post}'                            overwrote,dropped-vardecl,varinit    \n\
+    \n\
+/set format normal display '{pre}Expression value is: {value}{post}{pre}  assigned to temporary variable {name} of type {type}{post}' expression    \n\
+/set format normal display '{pre}Variable {name} of type {type} has value {value}{post}'    varvalue    \n\
+/set format normal display '{pre}Variable {name} has been assigned the value {value}{post}' assignment    \n\
+    \n\
+/set format normal display '{pre}Attempted to use {typeKind} {name}{resolve}{post}'         used-class,interface,enum,annotation    \n\
+/set format normal display '{pre}Attempted to call method {name}({type}){resolve}{post}'    used-method    \n\
+    \n\
+/set feedback normal    \n\
+    \n\
+/set newmode off quiet    \n\
+/set prompt off '-> ' '>> '    \n\
+/set format off pre '|  '    \n\
+/set format off post '%n'    \n\
+/set format off errorpre '|  '    \n\
+/set format off errorpost '%n'    \n\
+/set format off display ''    \n
--- a/langtools/test/ProblemList.txt	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/ProblemList.txt	Mon Mar 28 08:41:54 2016 -0700
@@ -23,8 +23,77 @@
 #
 ###########################################################################
 
+###########################################################################
+#
+# javadoc
 
-##### javac ####################################################################
+com/sun/javadoc/testTypeAnnotations/TestTypeAnnotations.java                    8006735    generic-all    output type annotations in javadoc
+com/sun/javadoc/typeAnnotations/smoke/TestSmoke.java                            8013406    generic-all    Test cases fail in javadoc test TestSmoke.java
+
+jdk/javadoc/tool/6176978/T6176978.java                                          8152049    generic-all    no longer applicable, should delete
+jdk/javadoc/tool/InlineTagsWithBraces.java                                      8152050    generic-all    API, re-evaluate @bold, @maybe causes doclint to throw up.
+jdk/javadoc/tool/LangVers.java                                                  8152051    generic-all    API, re-evaluate, unsure of this test.
+jdk/javadoc/tool/VerifyLocale.java                                              8149565    generic-all    -locale option issues
+jdk/javadoc/tool/enum/docComments/Main.java                                     8152054    generic-all    API modifications
+jdk/javadoc/tool/enum/enumType/Main.java                                        8152054    generic-all    API modifications
+jdk/javadoc/tool/generics/genericClass/Main.java                                8152054    generic-all    API modifications
+jdk/javadoc/tool/generics/genericInnerAndOuter/Main.java                        8152054    generic-all    API modifications
+jdk/javadoc/tool/generics/genericInterface/Main.java                            8152054    generic-all    API modifications
+jdk/javadoc/tool/generics/genericMethod/Main.java                               8152054    generic-all    API modifications
+jdk/javadoc/tool/generics/genericSuper/Main.java                                8152054    generic-all    API modifications
+jdk/javadoc/tool/generics/supertypes/Main.java                                  8152054    generic-all    API modifications
+jdk/javadoc/tool/generics/throwsGeneric/Main.java                               8152054    generic-all    API modifications
+jdk/javadoc/tool/generics/tparamCycle/Main.java                                 8152054    generic-all    API modifications
+jdk/javadoc/tool/generics/tparamTagOnMethod/Main.java                           8152054    generic-all    API modifications
+jdk/javadoc/tool/generics/tparamTagOnType/Main.java                             8152054    generic-all    API modifications
+jdk/javadoc/tool/generics/wildcards/Main.java                                   8152054    generic-all    API modifications
+jdk/javadoc/tool/imports/MissingImport.java                                     8152054    generic-all    API modifications, testing deprecated APIs.
+jdk/javadoc/tool/sourceOnly/Test.java                                           8152054    generic-all    API modifications
+jdk/javadoc/tool/sourceOption/SourceOption.java                                 8152054    generic-all    API modifications
+jdk/javadoc/tool/subpackageIgnore/SubpackageIgnore.java                         8152054    generic-all    API modifications
+jdk/javadoc/tool/varArgs/Main.java                                              8152054    generic-all    API modifications
+
+###########################################################################
+#
+# jshell
 
-tools/javac/Paths/MineField.sh                                                  8149599	generic-all   needs rewrite
+jdk/jshell/EditorPadTest.java                                                   8139872    generic-all    test requires a non-headless environment
+jdk/jshell/ExternalEditorTest.java                                              8080843    generic-all    invalid key error occurs when external editor is used.
+jdk/jshell/ToolBasicTest.java                                                   8139873    generic-all    JShell tests failing
+
+###########################################################################
+#
+# javac
 
+tools/javac/Paths/AbsolutePathTest.java                                         8055768    generic-all    ToolBox does not close opened files
+tools/javac/Paths/MineField.sh                                                  8149599	   generic-all    needs rewrite
+tools/javac/annotations/typeAnnotations/failures/CantAnnotatePackages.java      8057679    generic-all    clarify error messages trying to annotate scoping
+tools/javac/annotations/typeAnnotations/failures/CantAnnotateScoping.java       8057679    generic-all    clarify error messages trying to annotate scoping
+tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass2.java  8057679    generic-all    clarify error messages trying to annotate scoping
+tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass2.java  8057683    generic-all    improve ordering of errors with type annotations
+tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass3.java  8057679    generic-all    clarify error messages trying to annotate scoping
+tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass3.java  8057683    generic-all    improve order of errors with type annotations
+tools/javac/annotations/typeAnnotations/newlocations/RepeatingTypeAnnotations.java 8057683 generic-all    improve ordering of errors with type annotations
+tools/javac/annotations/typeAnnotations/referenceinfos/Lambda.java              8057687    generic-all    emit correct byte code an attributes for type annotations
+tools/javac/annotations/typeAnnotations/referenceinfos/NestedTypes.java         8057687    generic-all    emit correct byte code an attributes for type annotations
+tools/javac/warnings/suppress/TypeAnnotations.java                              8057683    generic-all    improve ordering of errors with type annotations
+
+###########################################################################
+#
+# javap
+
+tools/javap/output/RepeatingTypeAnnotations.java                                8057687    generic-all    emit correct byte code an attributes for type annotations
+
+###########################################################################
+#
+# sjavac
+
+tools/sjavac/IncCompileFullyQualifiedRef.java                                   8152055    generic-all    Requires dependency code to deal with in-method dependencies.
+tools/sjavac/IncCompileWithChanges.java                                         8152055    generic-all    Requires dependency code to deal with in-method dependencies.
+
+###########################################################################
+#
+# jdeps 
+
+tools/jdeps/modules/GenModuleInfo.java                                          8152502    windows-all    fails to clean up files
+
--- a/langtools/test/jdk/javadoc/doclet/testAnnotationTypes/TestAnnotationTypes.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testAnnotationTypes/TestAnnotationTypes.java	Mon Mar 28 08:41:54 2016 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug      4973609 8015249 8025633 8026567 6469561
+ * @bug      4973609 8015249 8025633 8026567 6469561 8071982
  * @summary  Make sure that annotation types with 0 members does not have
  *           extra HR tags.
  * @author   jamieh
@@ -42,7 +42,7 @@
 
     @Test
     void test() {
-        javadoc("-d", "out",
+        javadoc("-d", "out-1",
                 "-sourcepath", testSrc,
                 "pkg");
         checkExit(Exit.OK);
@@ -90,5 +90,27 @@
                 + "<P>\n\n"
                 + "<P>"
                 + "<!-- ========= END OF CLASS DATA ========= -->" + "<HR>");
+
+        javadoc("-d", "out-2",
+                "-linksource",
+                "-sourcepath", testSrc,
+                "pkg");
+        checkExit(Exit.OK);
+
+        checkOutput("src-html/pkg/AnnotationType.html", true,
+                "<title>Source code</title>",
+                "@Documented public @interface AnnotationType {");
+
+        checkOutput("src-html/pkg/AnnotationTypeField.html", true,
+                "<title>Source code</title>",
+                "@Documented public @interface AnnotationTypeField {");
+
+        checkOutput("pkg/AnnotationType.html", true,
+                "public @interface <a href=\"../src-html/pkg/AnnotationType.html#line.34"
+                + "\">AnnotationType</a></pre>");
+
+        checkOutput("pkg/AnnotationTypeField.html", true,
+                "public @interface <a href=\"../src-html/pkg/AnnotationTypeField.html#line.31"
+                + "\">AnnotationTypeField</a></pre>");
     }
 }
--- a/langtools/test/jdk/javadoc/doclet/testClassCrossReferences/C.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testClassCrossReferences/C.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
  * Cross link to inner class: {@link javax.swing.text.AbstractDocument.AttributeContext Link to AttributeContext innerclass} <br>
  * Cross link to class: {@link java.math.BigDecimal Link to external class BigDecimal}<br>
  * Cross link to member: {@link java.math.BigInteger#gcd(java.math.BigInteger) Link to external member gcd}<br>
+ * Cross link to package: {@link javax.tools.SimpleJavaFileObject#URI Link to external member URI}<br>
  */
 public class C {
 
--- a/langtools/test/jdk/javadoc/doclet/testClassCrossReferences/TestClassCrossReferences.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testClassCrossReferences/TestClassCrossReferences.java	Mon Mar 28 08:41:54 2016 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 4652655 4857717 8025633 8026567
+ * @bug 4652655 4857717 8025633 8026567 8071982
  * @summary This test verifies that class cross references work properly.
  * @author jamieh
  * @library ../lib
@@ -42,9 +42,10 @@
 
     @Test
     void test() {
-        final String uri = "http://java.sun.com/j2se/1.4/docs/api/";
+        final String uri = "http://docs.oracle.com/javase/8/docs/api/";
 
         javadoc("-d", "out",
+                "-Xdoclint:none",
                 "-sourcepath", testSrc,
                 "-linkoffline", uri, testSrc,
                 testSrc("C.java"));
@@ -59,6 +60,8 @@
                 + "title=\"class or interface in java.math\"><code>Link to external class BigDecimal</code></a>",
                 "<a href=\"" + uri + "java/math/BigInteger.html?is-external=true#gcd-java.math.BigInteger-\" "
                 + "title=\"class or interface in java.math\"><code>Link to external member gcd</code></a>",
+                "<a href=\"" + uri + "javax/tools/SimpleJavaFileObject.html?is-external=true#URI\" "
+                + "title=\"class or interface in javax.tools\"><code>Link to external member URI</code></a>",
                 "<dl>\n"
                 + "<dt><span class=\"overrideSpecifyLabel\">Overrides:</span></dt>\n"
                 + "<dd><code>toString</code>&nbsp;in class&nbsp;<code>java.lang.Object</code></dd>\n"
--- a/langtools/test/jdk/javadoc/doclet/testClassCrossReferences/package-list	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testClassCrossReferences/package-list	Mon Mar 28 08:41:54 2016 -0700
@@ -1,2 +1,3 @@
 java.math
+javax.tools
 javax.swing.text
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testClassDocCatalog/TestClassDocCatalog.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8071982
+ * @summary Test for package-frame.html.
+ * @library ../lib
+ * @modules jdk.javadoc/jdk.javadoc.internal.tool
+ * @build JavadocTester
+ * @run main TestClassDocCatalog
+ */
+
+public class TestClassDocCatalog extends JavadocTester {
+
+    public static void main(String... args) throws Exception {
+        TestClassDocCatalog tester = new TestClassDocCatalog();
+        tester.runTests();
+    }
+
+    @Test
+    void test() {
+        javadoc("-d", "out",
+                testSrc("pkg1/EmptyAnnotation.java"),
+                testSrc("pkg1/EmptyClass.java"),
+                testSrc("pkg1/EmptyEnum.java"),
+                testSrc("pkg1/EmptyError.java"),
+                testSrc("pkg1/EmptyException.java"),
+                testSrc("pkg1/EmptyInterface.java"),
+                testSrc("pkg2/EmptyAnnotation.java"),
+                testSrc("pkg2/EmptyClass.java"),
+                testSrc("pkg2/EmptyEnum.java"),
+                testSrc("pkg2/EmptyError.java"),
+                testSrc("pkg2/EmptyException.java"),
+                testSrc("pkg2/EmptyInterface.java"));
+        checkExit(Exit.OK);
+
+        checkOutput("overview-frame.html", true,
+                "<li><a href=\"pkg1/package-frame.html\" target=\"packageFrame\">pkg1</a>"
+                + "</li>\n<li><a href=\"pkg2/package-frame.html\" target=\"packageFrame\">pkg2</a></li>");
+
+        checkOutput("pkg1/package-frame.html", true,
+                "<li><a href=\"EmptyInterface.html\" title=\"interface in pkg1\" "
+                + "target=\"classFrame\"><span class=\"interfaceName\">EmptyInterface"
+                + "</span></a></li>",
+                "<li><a href=\"EmptyClass.html\" title=\"class in pkg1\" "
+                + "target=\"classFrame\">EmptyClass</a></li>",
+                "<li><a href=\"EmptyEnum.html\" title=\"enum in pkg1\" "
+                + "target=\"classFrame\">EmptyEnum</a></li>",
+                "<li><a href=\"EmptyError.html\" title=\"class in pkg1\" "
+                + "target=\"classFrame\">EmptyError</a></li>",
+                "<li><a href=\"EmptyAnnotation.html\" title=\"annotation in pkg1\""
+                + " target=\"classFrame\">EmptyAnnotation</a></li>");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testClassDocCatalog/pkg1/EmptyAnnotation.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg1;
+
+import java.lang.annotation.Documented;
+
+@Documented public @interface EmptyAnnotation {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testClassDocCatalog/pkg1/EmptyClass.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg1;
+
+public class EmptyClass {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testClassDocCatalog/pkg1/EmptyEnum.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg1;
+
+public enum EmptyEnum {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testClassDocCatalog/pkg1/EmptyError.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg1;
+
+public class EmptyError extends Error {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testClassDocCatalog/pkg1/EmptyException.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg1;
+
+public class EmptyException extends Exception {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testClassDocCatalog/pkg1/EmptyInterface.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg1;
+
+public interface EmptyInterface {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testClassDocCatalog/pkg2/EmptyAnnotation.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg2;
+
+import java.lang.annotation.Documented;
+
+@Documented public @interface EmptyAnnotation {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testClassDocCatalog/pkg2/EmptyClass.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg2;
+
+public class EmptyClass {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testClassDocCatalog/pkg2/EmptyEnum.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg2;
+
+public enum EmptyEnum {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testClassDocCatalog/pkg2/EmptyError.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg2;
+
+public class EmptyError extends Error {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testClassDocCatalog/pkg2/EmptyException.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg2;
+
+public class EmptyException extends Exception {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testClassDocCatalog/pkg2/EmptyInterface.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg2;
+
+public interface EmptyInterface {
+}
--- a/langtools/test/jdk/javadoc/doclet/testDeprecatedDocs/TestDeprecatedDocs.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testDeprecatedDocs/TestDeprecatedDocs.java	Mon Mar 28 08:41:54 2016 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug      4927552 8026567
+ * @bug      4927552 8026567 8071982
  * @summary  <DESC>
  * @author   jamieh
  * @library  ../lib
@@ -50,6 +50,7 @@
                 "annotation_test1 passes",
                 "annotation_test2 passes",
                 "annotation_test3 passes",
+                "annotation_test4 passes.",
                 "class_test1 passes",
                 "class_test2 passes",
                 "class_test3 passes",
--- a/langtools/test/jdk/javadoc/doclet/testDeprecatedDocs/pkg/TestAnnotationType.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testDeprecatedDocs/pkg/TestAnnotationType.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,4 +39,9 @@
      * @deprecated annotation_test3 passes.
      */
     int required();
+
+    /**
+     * @deprecated annotation_test4 passes.
+     */
+    int field = 0;
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testGroupOption/C.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+public class C {}
--- a/langtools/test/jdk/javadoc/doclet/testGroupOption/TestGroupOption.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testGroupOption/TestGroupOption.java	Mon Mar 28 08:41:54 2016 -0700
@@ -25,7 +25,7 @@
  * @test
  * @bug      4924383
  * @summary  Test to make sure the -group option does not cause a bad warning
- *           to be printed.
+ *           to be printed. Test for the group defined using patterns.
  * @author   jamieh
  * @library  ../lib
  * @modules jdk.javadoc/jdk.javadoc.internal.tool
@@ -42,7 +42,7 @@
 
     @Test
     void test1() {
-        //Make sure the warning is not printed when -group is used correctly.
+        // Make sure the warning is not printed when -group is used correctly.
         javadoc("-d", "out-1",
                 "-sourcepath", testSrc,
                 "-group", "Package One", "pkg1",
@@ -55,11 +55,29 @@
                 "-group");
     }
 
-    @Test
+    // @Test
+    // @ignore 8149402
+    // Make sure the "Other packages" section is printed and the header for empty section is not.
+    // Make sure that the headers of group that is defined using patterns are printed.
     void test2() {
-        //Make sure the warning is printed when -group is not used correctly.
         javadoc("-d", "out-2",
                 "-sourcepath", testSrc,
+                "-group", "Group pkg*", "pkg*",
+                "-group", "Group abc*", "abc*",
+                "-group", "Empty group", "qwerty*",
+                "-group", "Group a*", "a*",
+                "pkg1", "pkg2", "pkg3", "abc1",  "abc2", "abc3", "other", testSrc("C.java"));
+        checkExit(Exit.OK);
+
+        checkOutput("overview-summary.html", true, "Group pkg*", "Group abc*", "Other Packages");
+        checkOutput("overview-summary.html", false, "Empty group", "Group a*");
+    }
+
+    @Test
+    void test3() {
+        // Make sure the warning is printed when -group is not used correctly.
+        javadoc("-d", "out-3",
+                "-sourcepath", testSrc,
                 "-group", "Package One", "pkg1",
                 "-group", "Package One", "pkg2",
                 "-group", "Package One", "pkg3",
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testGroupOption/abc1/C.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package abc1;
+
+public class C {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testGroupOption/abc2/C.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package abc2;
+
+public class C {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testGroupOption/abc3/C.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package abc3;
+
+public class C {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testGroupOption/other/C.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package other;
+
+public class C {}
--- a/langtools/test/jdk/javadoc/doclet/testHelpOption/TestHelpOption.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testHelpOption/TestHelpOption.java	Mon Mar 28 08:41:54 2016 -0700
@@ -64,6 +64,7 @@
                 "-sourcepath", testSrc,
                 "-nohelp",
                 testSrc("Sample.java"));
+        checkOutput("Sample.html", false, "<li><a href=\"../help-doc.html\">Help</a></li>");
         checkExit(Exit.OK);
     }
 
@@ -76,6 +77,8 @@
         checkExit(Exit.OK);
         checkOutput("Sample.html", true,
                 "<li><a href=\"test-help.html\">Help</a></li>");
+        checkOutput("test-help.html", true,
+                "Help, help.");
     }
 
     @Test
@@ -135,7 +138,15 @@
                 "-sourcetab ",
                 "-keywords ",
                 "-stylesheetfile ",
-                "-docencoding ");
+                "-docencoding ",
+                "-html4 ",
+                "-html5 ",
+                "-top ",
+                "-author ",
+                "-noqualifier ",
+                "-nosince ",
+                "-notimestamp ",
+                "-sourcetab ");
 
         checkOutput("Sample.html", !withOption,
                 "<li><a href=\"help-doc.html\">Help</a></li>");
--- a/langtools/test/jdk/javadoc/doclet/testIndex/TestIndex.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testIndex/TestIndex.java	Mon Mar 28 08:41:54 2016 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug      4852280 4517115 4973608 4994589 8026567
+ * @bug      4852280 4517115 4973608 4994589 8026567 8071982
  * @summary  Perform tests on index.html file.
  *           Also test that index-all.html has the appropriate output.
  *           Test for unnamed package in index.
@@ -75,6 +75,8 @@
                 + "- Static variable in class pkg.<a href=\"pkg/C.html\" title=\"class in pkg\">"
                 + "C</a></dt>\n"
                 + "<dd>&nbsp;</dd>\n"
-                + "</dl>");
+                + "</dl>",
+                "<dt><span class=\"searchTagLink\"><a href=\"pkg/Coin.html#Enum\">Enum</a>"
+                + "</span> - Search tag in pkg.Coin</dt>");
     }
 }
--- a/langtools/test/jdk/javadoc/doclet/testIndex/pkg/Coin.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testIndex/pkg/Coin.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,14 +24,13 @@
 package pkg;
 
 /**
- * This is a sample Enum.
- *
+ * This is a sample {@index Enum} Enum.
  * @author Jamie Ho
  */
 public enum Coin {
 
-  Penny, Nickel, Dime;
+  Penny(1), Nickel(2), Dime(3);
 
-public Coin(int i) {}
+Coin(int i) {}
 
 }
--- a/langtools/test/jdk/javadoc/doclet/testLinkTaglet/TestLinkTaglet.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testLinkTaglet/TestLinkTaglet.java	Mon Mar 28 08:41:54 2016 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug      4732864 6280605 7064544 8014636 8016328 8025633
+ * @bug      4732864 6280605 7064544 8014636 8016328 8025633 8071982
  * @summary  Make sure that you can link from one member to another using
  *           non-qualified name, furthermore, ensure the right one is linked.
  * @author   jamieh
@@ -54,7 +54,8 @@
                 + " Unqualified Link2: <a href=\"../pkg/C.InnerC.html\" title=\"class in pkg\"><code>C.InnerC</code></a>.<br/>\n"
                 + " Qualified Link: <a href=\"../pkg/C.html#method-pkg.C.InnerC-pkg.C.InnerC2-\"><code>method(pkg.C.InnerC, pkg.C.InnerC2)</code></a>.<br/>\n"
                 + " Unqualified Link: <a href=\"../pkg/C.html#method-pkg.C.InnerC-pkg.C.InnerC2-\"><code>method(C.InnerC, C.InnerC2)</code></a>.<br/>\n"
-                + " Unqualified Link: <a href=\"../pkg/C.html#method-pkg.C.InnerC-pkg.C.InnerC2-\"><code>method(InnerC, InnerC2)</code></a>.<br/>");
+                + " Unqualified Link: <a href=\"../pkg/C.html#method-pkg.C.InnerC-pkg.C.InnerC2-\"><code>method(InnerC, InnerC2)</code></a>.<br/>\n"
+                + " Package Link: <a href=\"../pkg/package-summary.html\"><code>pkg</code></a>.<br/>");
 
         checkOutput("pkg/C.InnerC.html", true,
                 "Link to member in outer class: <a href=\"../pkg/C.html#MEMBER\"><code>C.MEMBER</code></a> <br/>\n"
--- a/langtools/test/jdk/javadoc/doclet/testLinkTaglet/checkPkg/B.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testLinkTaglet/checkPkg/B.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * 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,10 +27,8 @@
  * @see A
  */
 public class B {
-
-        /**
+    /**
      * @see A#m()
      */
-        public void m2();
-
+    public void m2() {};
 }
--- a/langtools/test/jdk/javadoc/doclet/testLinkTaglet/pkg/C.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testLinkTaglet/pkg/C.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,9 @@
  * Qualified Link: {@link #method(pkg.C.InnerC, pkg.C.InnerC2)}.<br/>
  * Unqualified Link: {@link #method(C.InnerC, C.InnerC2)}.<br/>
  * Unqualified Link: {@link #method(InnerC, InnerC2)}.<br/>
+ * Package Link: {@link pkg}.<br/>
+ *
+ *
  */
 public class C {
 
--- a/langtools/test/jdk/javadoc/doclet/testNavigation/TestNavigation.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testNavigation/TestNavigation.java	Mon Mar 28 08:41:54 2016 -0700
@@ -42,22 +42,25 @@
 
     @Test
     void test() {
-        javadoc("-d", "out",
+        javadoc("-d", "out", "-overview", testSrc("overview.html"),
                 "-sourcepath", testSrc,
                 "pkg");
         checkExit(Exit.OK);
 
         checkOutput("pkg/A.html", true,
                 "<li>Prev&nbsp;Class</li>",
-                "<a href=\"../pkg/C.html\" title=\"class in pkg\"><span class=\"typeNameLink\">Next&nbsp;Class</span></a>");
+                "<a href=\"../pkg/C.html\" title=\"class in pkg\"><span class=\"typeNameLink\">Next&nbsp;Class</span></a>",
+                "<li><a href=\"../overview-summary.html\">Overview</a></li>");
 
         checkOutput("pkg/C.html", true,
                 "<a href=\"../pkg/A.html\" title=\"annotation in pkg\"><span class=\"typeNameLink\">Prev&nbsp;Class</span></a>",
-                "<a href=\"../pkg/E.html\" title=\"enum in pkg\"><span class=\"typeNameLink\">Next&nbsp;Class</span></a>");
+                "<a href=\"../pkg/E.html\" title=\"enum in pkg\"><span class=\"typeNameLink\">Next&nbsp;Class</span></a>",
+                "<li><a href=\"../overview-summary.html\">Overview</a></li>");
 
         checkOutput("pkg/E.html", true,
                 "<a href=\"../pkg/C.html\" title=\"class in pkg\"><span class=\"typeNameLink\">Prev&nbsp;Class</span></a>",
-                "<a href=\"../pkg/I.html\" title=\"interface in pkg\"><span class=\"typeNameLink\">Next&nbsp;Class</span></a>");
+                "<a href=\"../pkg/I.html\" title=\"interface in pkg\"><span class=\"typeNameLink\">Next&nbsp;Class</span></a>",
+                "<li><a href=\"../overview-summary.html\">Overview</a></li>");
 
         checkOutput("pkg/I.html", true,
                 "<a href=\"../pkg/E.html\" title=\"enum in pkg\"><span class=\"typeNameLink\">Prev&nbsp;Class</span></a>",
@@ -66,7 +69,8 @@
                 "<div class=\"skipNav\"><a href=\"#skip.navbar.top\" title=\"Skip navigation links\">Skip navigation links</a></div>\n"
                 + "<a name=\"navbar.top.firstrow\">\n"
                 + "<!--   -->\n"
-                + "</a>");
+                + "</a>",
+                "<li><a href=\"../overview-summary.html\">Overview</a></li>");
 
         // Remaining tests check for additional padding to offset the fixed navigation bar.
         checkOutput("pkg/A.html", true,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testNavigation/overview.html	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+</head>
+<body bgcolor="white">
+
+This document is generated from sample source code and HTML files 
+with examples of a wide variety of Java language constructs: packages, 
+subclasses, subinterfaces, nested classes, nested interfaces,
+inheriting from other packages, constructors, fields,
+methods, and so forth.
+
+</body>
+</html>
--- a/langtools/test/jdk/javadoc/doclet/testOptions/TestOptions.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testOptions/TestOptions.java	Mon Mar 28 08:41:54 2016 -0700
@@ -23,8 +23,8 @@
 
 /*
  * @test
- * @bug      4749567
- * @summary  Test the output for -header and -footer options.
+ * @bug      4749567 8071982
+ * @summary  Test the output for -header, -footer, -nooverview, -nodeprecatedlist, -nonavbar, -notree, -stylesheetfile options.
  * @author   Bhavesh Patel
  * @library  ../lib
  * @modules jdk.javadoc/jdk.javadoc.internal.tool
@@ -32,6 +32,8 @@
  * @run main TestOptions
  */
 
+import java.io.File;
+
 public class TestOptions extends JavadocTester {
 
     public static void main(String... args) throws Exception {
@@ -40,8 +42,8 @@
     }
 
     @Test
-    void test() {
-        javadoc("-d", "out",
+    void testHeaderFooter() {
+        javadoc("-d", "out-1",
                 "-header", "Test header",
                 "-footer", "Test footer",
                 "-sourcepath", testSrc,
@@ -52,5 +54,163 @@
                 "<div class=\"aboutLanguage\">Test header</div>",
                 "<div class=\"aboutLanguage\">Test footer</div>");
     }
+
+    @Test
+    void testNoOverview() {
+        javadoc("-d", "out-4",
+                "-nooverview",
+                "-sourcepath", testSrc,
+                "pkg", "deprecated");
+
+        checkExit(Exit.OK);
+
+        checkFiles(false, "overview-summary.html");
+    }
+
+    @Test
+    void testNoDeprecatedList() {
+        javadoc("-d", "out-5",
+                "-nodeprecatedlist",
+                "-sourcepath", testSrc,
+                "deprecated");
+        checkExit(Exit.OK);
+
+        checkFiles(false, "deprecated-list.html");
+    }
+
+    @Test
+    void testNoNavbar() {
+        javadoc("-d", "out-6",
+                "-nonavbar",
+                "-bottom", "Bottom text",
+                "-sourcepath", testSrc,
+                "pkg");
+        checkExit(Exit.OK);
+
+        checkOutput("pkg/Foo.html", false, "navbar");
+        checkOutput("pkg/Foo.html", true, "Bottom text");
+    }
+
+    @Test
+    void testNoTree() {
+        javadoc("-d", "out-7",
+                "-notree",
+                "-sourcepath", testSrc,
+                "pkg");
+        checkExit(Exit.OK);
+
+        checkFiles(false, "overview-tree.html");
+        checkFiles(false, "pkg/package-tree.html");
+        checkOutput("pkg/Foo.html", false, "<li><a href=\"package-tree.html\">Tree</a></li>");
+    }
+
+    @Test
+    void testStylesheetFile() {
+        javadoc("-d", "out-8",
+                "-stylesheetfile", new File(testSrc, "custom-stylesheet.css").getAbsolutePath(),
+                "-sourcepath", testSrc,
+                "pkg");
+        checkExit(Exit.OK);
+
+        checkOutput("custom-stylesheet.css", true, "Custom javadoc style sheet");
+        checkOutput("pkg/Foo.html", true, "<link rel=\"stylesheet\" type=\"text/css\" "
+                + "href=\"../custom-stylesheet.css\" title=\"Style\">");
+    }
+
+    @Test
+    void testLinkSource() {
+        javadoc("-d", "out-9",
+                "-linksource",
+                "-javafx",
+                "-sourcepath", testSrc,
+                "-package",
+                "linksource");
+        checkExit(Exit.OK);
+
+        checkOutput("linksource/AnnotationTypeField.html", true,
+                "<pre>@Documented\npublic @interface <a href="
+                + "\"../src-html/linksource/AnnotationTypeField.html#line.31\">"
+                + "AnnotationTypeField</a></pre>",
+                "<h4>DEFAULT_NAME</h4>\n<pre>static final&nbsp;java.lang.String&nbsp;"
+                + "<a href=\"../src-html/linksource/AnnotationTypeField.html#line.32\">"
+                + "DEFAULT_NAME</a></pre>",
+                "<h4>name</h4>\n<pre>java.lang.String&nbsp;<a href="
+                + "\"../src-html/linksource/AnnotationTypeField.html#line.34\">name</a></pre>");
+
+        checkOutput("src-html/linksource/AnnotationTypeField.html", true,
+                "<title>Source code</title>",
+                "<span class=\"sourceLineNo\">031</span><a name=\"line.31\">"
+                + "@Documented public @interface AnnotationTypeField {</a>");
+
+        checkOutput("linksource/Properties.html", true,
+                "<pre>public class <a href=\"../src-html/linksource/Properties.html#line.29\">"
+                + "Properties</a>",
+                "<pre>public&nbsp;java.lang.Object <a href="
+                + "\"../src-html/linksource/Properties.html#line.31\">someProperty</a></pre>",
+                "<pre>public&nbsp;java.lang.Object&nbsp;<a href="
+                + "\"../src-html/linksource/Properties.html#line.31\">someProperty</a>()</pre>");
+
+        checkOutput("src-html/linksource/Properties.html", true,
+                "<title>Source code</title>",
+                "<span class=\"sourceLineNo\">031</span><a name=\"line.31\">    "
+                + "public Object someProperty() {</a>");
+
+        checkOutput("linksource/SomeClass.html", true,
+                "<pre>public class <a href=\"../src-html/linksource/SomeClass.html#line.29\">"
+                + "SomeClass</a>\nextends java.lang.Object</pre>",
+                "<pre>public&nbsp;int <a href=\"../src-html/linksource/SomeClass.html#line.31\">"
+                + "field</a></pre>",
+                "<pre>public&nbsp;<a href=\"../src-html/linksource/SomeClass.html#line.33\">"
+                + "SomeClass</a>()</pre>",
+                "<pre>public&nbsp;int&nbsp;<a href=\"../src-html/linksource/SomeClass.html#line.36\">"
+                + "method</a>()</pre>");
+
+        checkOutput("src-html/linksource/SomeClass.html", true,
+                "<title>Source code</title>",
+                "<span class=\"sourceLineNo\">029</span><a name=\"line.29\">"
+                + "public class SomeClass {</a>",
+                "<span class=\"sourceLineNo\">031</span><a name=\"line.31\">    "
+                + "public int field;</a>",
+                "<span class=\"sourceLineNo\">033</span><a name=\"line.33\">    "
+                + "public SomeClass() {</a>",
+                "<span class=\"sourceLineNo\">036</span><a name=\"line.36\">    "
+                + "public int method() {</a>");
+
+        checkOutput("linksource/SomeEnum.html", true,
+                "<pre>public static final&nbsp;<a href=\"../linksource/SomeEnum.html\" "
+                + "title=\"enum in linksource\">SomeEnum</a> <a href="
+                + "\"../src-html/linksource/SomeEnum.html#line.29\">VALUE1</a></pre>",
+                "<pre>public static final&nbsp;<a href=\"../linksource/SomeEnum.html\" "
+                + "title=\"enum in linksource\">SomeEnum</a> <a href="
+                + "\"../src-html/linksource/SomeEnum.html#line.30\">VALUE2</a></pre>");
+
+        checkOutput("src-html/linksource/SomeEnum.html", true,
+                "<span class=\"sourceLineNo\">029</span><a name=\"line.29\">    VALUE1,</a>",
+                "<span class=\"sourceLineNo\">030</span><a name=\"line.30\">    VALUE2</a>");
+    }
+
+    @Test
+    void testNoQualifier() {
+        javadoc("-d", "out-10",
+                "-noqualifier", "pkg",
+                "-sourcepath", testSrc,
+                "pkg", "deprecated");
+        checkExit(Exit.OK);
+
+        checkOutput("pkg/Foo.html", true,
+                "<li>Foo</li>");
+        checkOutput("deprecated/Foo.html", true,
+                "<li>deprecated.Foo</li>");
+
+        javadoc("-d", "out-10a",
+                "-noqualifier", "all",
+                "-sourcepath", testSrc,
+                "pkg", "deprecated");
+        checkExit(Exit.OK);
+
+        checkOutput("pkg/Foo.html", true,
+                "<li>Foo</li>");
+        checkOutput("deprecated/Foo.html", true,
+                "<li>Foo</li>");
+    }
 }
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testOptions/custom-stylesheet.css	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,751 @@
+/* Custom javadoc style sheet */
+/*
+Overall document style
+*/
+
+@import url('resources/fonts/dejavu.css');
+
+body {
+    background-color:#ffffff;
+    color:#353833;
+    font-family:'DejaVu Sans', Arial, Helvetica, sans-serif;
+    font-size:14px;
+    margin:0;
+    padding:0;
+    height:100%;
+    width:100%;
+}
+iframe {
+    margin:0;
+    padding:0;
+    height:100%;
+    width:100%;
+    overflow-y:scroll;
+    border:none;
+}
+a:link, a:visited {
+    text-decoration:none;
+    color:#4A6782;
+}
+a:hover, a:focus {
+    text-decoration:none;
+    color:#bb7a2a;
+}
+a:active {
+    text-decoration:none;
+    color:#4A6782;
+}
+a[name] {
+    color:#353833;
+}
+a[name]:hover {
+    text-decoration:none;
+    color:#353833;
+}
+a[name]:before, a[name]:target {
+    content:"";
+    display:block;
+    height:120px;
+    margin:-120px 0 0;
+}
+a[id]:before, a[id]:target {
+    padding-top:129px;
+    margin-top:-129px;
+    color:red;
+}
+pre {
+    font-family:'DejaVu Sans Mono', monospace;
+    font-size:14px;
+}
+h1 {
+    font-size:20px;
+}
+h2 {
+    font-size:18px;
+}
+h3 {
+    font-size:16px;
+    font-style:italic;
+}
+h4 {
+    font-size:13px;
+}
+h5 {
+    font-size:12px;
+}
+h6 {
+    font-size:11px;
+}
+ul {
+    list-style-type:disc;
+}
+code, tt {
+    font-family:'DejaVu Sans Mono', monospace;
+    font-size:14px;
+    padding-top:4px;
+    margin-top:8px;
+    line-height:1.4em;
+}
+dt code {
+    font-family:'DejaVu Sans Mono', monospace;
+    font-size:14px;
+    padding-top:4px;
+}
+table tr td dt code {
+    font-family:'DejaVu Sans Mono', monospace;
+    font-size:14px;
+    vertical-align:top;
+    padding-top:4px;
+}
+sup {
+    font-size:8px;
+}
+/*
+Document title and Copyright styles
+*/
+.clear {
+    clear:both;
+    height:0px;
+    overflow:hidden;
+}
+.aboutLanguage {
+    float:right;
+    padding:0px 21px;
+    font-size:11px;
+    z-index:200;
+    margin-top:-9px;
+}
+.legalCopy {
+    margin-left:.5em;
+}
+.bar a, .bar a:link, .bar a:visited, .bar a:active {
+    color:#FFFFFF;
+    text-decoration:none;
+}
+.bar a:hover, .bar a:focus {
+    color:#bb7a2a;
+}
+.tab {
+    background-color:#0066FF;
+    color:#ffffff;
+    padding:8px;
+    width:5em;
+    font-weight:bold;
+}
+/*
+Navigation bar styles
+*/
+.bar {
+    background-color:#4D7A97;
+    color:#FFFFFF;
+    padding:.8em .5em .4em .8em;
+    height:auto;/*height:1.8em;*/
+    font-size:11px;
+    margin:0;
+}
+.fixedNav {
+    position:fixed;
+    width:100%;
+    z-index:999;
+    background-color:#ffffff;
+}
+.topNav {
+    background-color:#4D7A97;
+    color:#FFFFFF;
+    float:left;
+    padding:0;
+    width:100%;
+    clear:right;
+    height:2.8em;
+    padding-top:10px;
+    overflow:hidden;
+    font-size:12px; 
+}
+.bottomNav {
+    margin-top:10px;
+    background-color:#4D7A97;
+    color:#FFFFFF;
+    float:left;
+    padding:0;
+    width:100%;
+    clear:right;
+    height:2.8em;
+    padding-top:10px;
+    overflow:hidden;
+    font-size:12px;
+}
+.subNav {
+    background-color:#dee3e9;
+    float:left;
+    width:100%;
+    overflow:hidden;
+    font-size:12px;
+}
+.subNav div {
+    clear:left;
+    float:left;
+    padding:0 0 5px 6px;
+    text-transform:uppercase;
+}
+ul.navList, ul.subNavList {
+    float:left;
+    margin:0 25px 0 0;
+    padding:0;
+}
+ul.navList li{
+    list-style:none;
+    float:left;
+    padding: 5px 6px;
+    text-transform:uppercase;
+}
+ul.navListSearch {
+    float:right;
+    margin:0 0 0 0;
+    padding:0;
+}
+ul.navListSearch li {
+    list-style:none;
+    float:right;
+    padding: 5px 6px;
+    text-transform:uppercase;
+}
+ul.navListSearch li span {
+    position:relative;
+    right:-16px;
+}
+ul.subNavList li {
+    list-style:none;
+    float:left;
+}
+.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited {
+    color:#FFFFFF;
+    text-decoration:none;
+    text-transform:uppercase;
+}
+.topNav a:hover, .bottomNav a:hover {
+    text-decoration:none;
+    color:#bb7a2a;
+    text-transform:uppercase;
+}
+.navBarCell1Rev {
+    background-color:#F8981D;
+    color:#253441;
+    margin: auto 5px;
+}
+.skipNav {
+    position:absolute;
+    top:auto;
+    left:-9999px;
+    overflow:hidden;
+}
+/*
+Page header and footer styles
+*/
+.header, .footer {
+    clear:both;
+    margin:0 20px;
+    padding:5px 0 0 0;
+}
+.indexNav {
+    margin:10px;
+    position:relative;
+}
+.indexNav ul {
+    padding:0;
+    margin:0;
+}
+.indexNav ul li {
+    display:inline;
+    list-style-type:none;
+    padding-right:10px;
+}
+.indexNav h1 {
+    font-size:13px;
+}
+.title {
+    color:#2c4557;
+    margin:10px 0;
+    padding-top:5.4em;
+}
+.subTitle {
+    margin:5px 0 0 0;
+}
+.header ul {
+    margin:0 0 15px 0;
+    padding:0;
+}
+.footer ul {
+    margin:20px 0 5px 0;
+}
+.header ul li, .footer ul li {
+    list-style:none;
+    font-size:13px;
+}
+/*
+Heading styles
+*/
+div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 {
+    background-color:#dee3e9;
+    border:1px solid #d0d9e0;
+    margin:0 0 6px -8px;
+    padding:7px 5px;
+}
+ul.blockList ul.blockList ul.blockList li.blockList h3 {
+    background-color:#dee3e9;
+    border:1px solid #d0d9e0;
+    margin:0 0 6px -8px;
+    padding:7px 5px;
+}
+ul.blockList ul.blockList li.blockList h3 {
+    padding:0;
+    margin:15px 0;
+}
+ul.blockList li.blockList h2 {
+    padding:0px 0 20px 0;
+}
+/*
+Page layout container styles
+*/
+.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer {
+    clear:both;
+    padding:10px 20px;
+    position:relative;
+}
+.indexContainer {
+    margin:10px;
+    position:relative;
+    font-size:12px;
+}
+.indexContainer h2 {
+    font-size:13px;
+    padding:0 0 3px 0;
+}
+.indexContainer ul {
+    margin:0;
+    padding:0;
+}
+.indexContainer ul li {
+    list-style:none;
+    padding-top:2px;
+}
+.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt {
+    font-size:12px;
+    font-weight:bold;
+    margin:10px 0 0 0;
+    color:#4E4E4E;
+}
+.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd {
+    margin:5px 0 10px 0px;
+    font-size:14px;
+    font-family:'DejaVu Sans Mono',monospace;
+}
+.serializedFormContainer dl.nameValue dt {
+    margin-left:1px;
+    font-size:1.1em;
+    display:inline;
+    font-weight:bold;
+}
+.serializedFormContainer dl.nameValue dd {
+    margin:0 0 0 1px;
+    font-size:1.1em;
+    display:inline;
+}
+/*
+List styles
+*/
+li.circle {
+    list-style:circle;
+}
+ul.horizontal li {
+    display:inline;
+    font-size:0.9em;
+}
+ul.inheritance {
+    margin:0;
+    padding:0;
+}
+ul.inheritance li {
+    display:inline;
+    list-style:none;
+}
+ul.inheritance li ul.inheritance {
+    margin-left:15px;
+    padding-left:15px;
+    padding-top:1px;
+}
+ul.blockList, ul.blockListLast {
+    margin:10px 0 10px 0;
+    padding:0;
+}
+ul.blockList li.blockList, ul.blockListLast li.blockList {
+    list-style:none;
+    margin-bottom:15px;
+    line-height:1.4;
+}
+ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList {
+    padding:0px 20px 5px 10px;
+    border:1px solid #ededed; 
+    background-color:#f8f8f8;
+}
+ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList {
+    padding:0 0 5px 8px;
+    background-color:#ffffff;
+    border:none;
+}
+ul.blockList ul.blockList ul.blockList ul.blockList li.blockList {
+    margin-left:0;
+    padding-left:0;
+    padding-bottom:15px;
+    border:none;
+}
+ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast {
+    list-style:none;
+    border-bottom:none;
+    padding-bottom:0;
+}
+table tr td dl, table tr td dl dt, table tr td dl dd {
+    margin-top:0;
+    margin-bottom:1px;
+}
+/*
+Table styles
+*/
+.overviewSummary, .memberSummary, .typeSummary, .useSummary, .constantsSummary, .deprecatedSummary {
+    width:100%;
+    border-spacing:0;
+    border-left:1px solid #EEE; 
+    border-right:1px solid #EEE; 
+    border-bottom:1px solid #EEE; 
+}
+.overviewSummary, .memberSummary  {
+    padding:0px;
+}
+.overviewSummary caption, .memberSummary caption, .typeSummary caption,
+.useSummary caption, .constantsSummary caption, .deprecatedSummary caption {
+    position:relative;
+    text-align:left;
+    background-repeat:no-repeat;
+    color:#253441;
+    font-weight:bold;
+    clear:none;
+    overflow:hidden;
+    padding:0px;
+    padding-top:10px;
+    padding-left:1px;
+    margin:0px;
+    white-space:pre;
+}
+.overviewSummary caption a:link, .memberSummary caption a:link, .typeSummary caption a:link,
+.useSummary caption a:link, .constantsSummary caption a:link, .deprecatedSummary caption a:link,
+.overviewSummary caption a:hover, .memberSummary caption a:hover, .typeSummary caption a:hover,
+.useSummary caption a:hover, .constantsSummary caption a:hover, .deprecatedSummary caption a:hover,
+.overviewSummary caption a:active, .memberSummary caption a:active, .typeSummary caption a:active,
+.useSummary caption a:active, .constantsSummary caption a:active, .deprecatedSummary caption a:active,
+.overviewSummary caption a:visited, .memberSummary caption a:visited, .typeSummary caption a:visited,
+.useSummary caption a:visited, .constantsSummary caption a:visited, .deprecatedSummary caption a:visited {
+    color:#FFFFFF;
+}
+.overviewSummary caption span, .memberSummary caption span, .typeSummary caption span,
+.useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span {
+    white-space:nowrap;
+    padding-top:5px;
+    padding-left:12px;
+    padding-right:12px;
+    padding-bottom:7px;
+    display:inline-block;
+    float:left;
+    background-color:#F8981D;
+    border: none;
+    height:16px;
+}
+.memberSummary caption span.activeTableTab span {
+    white-space:nowrap;
+    padding-top:5px;
+    padding-left:12px;
+    padding-right:12px;
+    margin-right:3px;
+    display:inline-block;
+    float:left;
+    background-color:#F8981D;
+    height:16px;
+}
+.memberSummary caption span.tableTab span {
+    white-space:nowrap;
+    padding-top:5px;
+    padding-left:12px;
+    padding-right:12px;
+    margin-right:3px;
+    display:inline-block;
+    float:left;
+    background-color:#4D7A97;
+    height:16px;
+}
+.memberSummary caption span.tableTab, .memberSummary caption span.activeTableTab {
+    padding-top:0px;
+    padding-left:0px;
+    padding-right:0px;
+    background-image:none;
+    float:none;
+    display:inline;
+}
+.overviewSummary .tabEnd, .memberSummary .tabEnd, .typeSummary .tabEnd,
+.useSummary .tabEnd, .constantsSummary .tabEnd, .deprecatedSummary .tabEnd {
+    display:none;
+    width:5px;
+    position:relative;
+    float:left;
+    background-color:#F8981D;
+}
+.memberSummary .activeTableTab .tabEnd {
+    display:none;
+    width:5px;
+    margin-right:3px;
+    position:relative; 
+    float:left;
+    background-color:#F8981D;
+}
+.memberSummary .tableTab .tabEnd {
+    display:none;
+    width:5px;
+    margin-right:3px;
+    position:relative;
+    background-color:#4D7A97;
+    float:left;
+
+}
+.overviewSummary td, .memberSummary td, .typeSummary td,
+.useSummary td, .constantsSummary td, .deprecatedSummary td {
+    text-align:left;
+    padding:0px 0px 12px 10px;
+}
+th.colOne, th.colFirst, th.colLast, .useSummary th, .constantsSummary th,
+td.colOne, td.colFirst, td.colLast, .useSummary td, .constantsSummary td{
+    vertical-align:top;
+    padding-right:0px;
+    padding-top:8px;
+    padding-bottom:3px;
+}
+th.colFirst, th.colLast, th.colOne, .constantsSummary th {
+    background:#dee3e9;
+    text-align:left;
+    padding:8px 3px 3px 7px;
+}
+td.colFirst, th.colFirst {
+    white-space:nowrap;
+    font-size:13px;
+}
+td.colLast, th.colLast {
+    font-size:13px;
+}
+td.colOne, th.colOne {
+    font-size:13px;
+}
+.overviewSummary td.colFirst, .overviewSummary th.colFirst,
+.useSummary td.colFirst, .useSummary th.colFirst,
+.overviewSummary td.colOne, .overviewSummary th.colOne,
+.memberSummary td.colFirst, .memberSummary th.colFirst,
+.memberSummary td.colOne, .memberSummary th.colOne,
+.typeSummary td.colFirst{
+    width:25%;
+    vertical-align:top;
+}
+td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover {
+    font-weight:bold;
+}
+.tableSubHeadingColor {
+    background-color:#EEEEFF;
+}
+.altColor {
+    background-color:#FFFFFF;
+}
+.rowColor {
+    background-color:#EEEEEF;
+}
+/*
+Content styles
+*/
+.description pre {
+    margin-top:0;
+}
+.deprecatedContent {
+    margin:0;
+    padding:10px 0;
+}
+.docSummary {
+    padding:0;
+}
+
+ul.blockList ul.blockList ul.blockList li.blockList h3 {
+    font-style:normal;
+}
+
+div.block {
+    font-size:14px;
+    font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif;
+}
+
+td.colLast div {
+    padding-top:0px;
+}
+
+
+td.colLast a {
+    padding-bottom:3px;
+}
+/*
+Formatting effect styles
+*/
+.sourceLineNo {
+    color:green;
+    padding:0 30px 0 0;
+}
+h1.hidden {
+    visibility:hidden;
+    overflow:hidden;
+    font-size:10px;
+}
+.block {
+    display:block;
+    margin:3px 10px 2px 0px;
+    color:#474747;
+}
+.deprecatedLabel, .descfrmTypeLabel, .memberNameLabel, .memberNameLink,
+.overrideSpecifyLabel, .packageHierarchyLabel, .paramLabel, .returnLabel,
+.seeLabel, .simpleTagLabel, .throwsLabel, .typeNameLabel, .typeNameLink, .searchTagLink {
+    font-weight:bold;
+}
+.deprecationComment, .emphasizedPhrase, .interfaceName {
+    font-style:italic;
+}
+
+div.block div.block span.deprecationComment, div.block div.block span.emphasizedPhrase,
+div.block div.block span.interfaceName {
+    font-style:normal;
+}
+
+div.contentContainer ul.blockList li.blockList h2 {
+    padding-bottom:0px;
+}
+/*
+IFRAME specific styles
+*/
+.mainContainer {
+    margin:0 auto; 
+    padding:0; 
+    height:100%; 
+    width:100%; 
+    position:fixed; 
+    top:0; 
+    left:0;
+}
+.leftContainer {
+    height:100%;
+    position:fixed;
+    width:320px;
+}
+.leftTop {
+    position:relative;
+    float:left;
+    width:315px;
+    top:0;
+    left:0;
+    height:30%;
+    border-right:6px solid #ccc;
+    border-bottom:6px solid #ccc;
+}
+.leftBottom {
+    position:relative;
+    float:left;
+    width:315px;
+    bottom:0;
+    left:0;
+    height:70%;
+    border-right:6px solid #ccc;
+    border-top:1px solid #000;
+}
+.rightContainer {
+    position:absolute;
+    left:320px;
+    top:0;
+    bottom:0;
+    height:100%;
+    right:0;
+    border-left:1px solid #000;
+}
+.rightIframe {
+    margin:0;
+    padding:0;
+    height:100%;
+    right:30px;
+    width:100%;
+    overflow:visible;
+    margin-bottom:30px;
+}
+/*
+HTML5 specific styles
+*/
+main, nav, header, footer, section {
+    display:block;
+}
+.ui-autocomplete-category {
+    font-weight:bold;
+    font-size:15px;
+    padding:7px 0 7px 3px;
+    background-color:#4D7A97;
+    color:#FFFFFF;
+}
+.resultItem {
+    font-size:13px;
+}
+.ui-autocomplete {
+    max-height:85%;
+    max-width:65%;
+    overflow-y:scroll;
+    overflow-x:scroll;
+    white-space:nowrap;
+    box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
+}
+ul.ui-autocomplete {
+    position:fixed;
+    z-index:999999;
+}
+ul.ui-autocomplete  li {
+    float:left;
+    clear:both;
+    width:100%;
+}
+.resultHighlight {
+    font-weight:bold;
+}
+#search {
+    background-image:url('resources/glass.png');
+    background-size:13px;
+    background-repeat:no-repeat;
+    background-position:2px 3px;
+    padding-left:20px;
+    position:relative;
+    right:-18px;
+}
+#reset {
+    background-color: rgb(255,255,255);
+    border:0 none;
+    width:16px;
+    height:17px;
+    position:relative;
+    left:-2px;
+    background-image:url('resources/x.png');
+    background-repeat:no-repeat;
+    background-size:12px;
+    background-position:center;
+}
+.watermark {
+    color:#888;
+}
+.searchTagDescResult {
+    font-style:italic;
+    font-size:11px;
+}
+.searchTagHolderResult {
+    font-style:italic;
+    font-size:12px;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testOptions/deprecated/Foo.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package deprecated;
+
+import pkg.*;
+
+@Deprecated
+public class Foo {}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testOptions/help.html	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,242 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!-- NewPage -->
+<html lang="ru">
+<head>
+<!-- Generated by javadoc (9-internal) on Mon Jan 04 22:47:26 MSK 2016 -->
+<title>API Help</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<meta name="date" content="2016-01-04">
+<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
+<link rel="stylesheet" type="text/css" href="jquery/jquery-ui.css" title="Style">
+<script type="text/javascript" src="script.js"></script>
+<script type="text/javascript" src="jquery/jszip/dist/jszip.min.js"></script>
+<script type="text/javascript" src="jquery/jszip-utils/dist/jszip-utils.min.js"></script>
+<!--[if IE]>
+<script type="text/javascript" src="jquery/jszip-utils/dist/jszip-utils-ie.min.js"></script>
+<![endif]-->
+<script type="text/javascript" src="jquery/jquery-1.10.2.js"></script>
+<script type="text/javascript" src="jquery/jquery-ui.js"></script>
+</head>
+<body>
+<script type="text/javascript"><!--
+    try {
+        if (location.href.indexOf('is-external=true') == -1) {
+            parent.document.title="API Help";
+        }
+    }
+    catch(err) {
+    }
+//-->
+var pathtoroot = "./";loadScripts(document, 'script');</script>
+<noscript>
+<div>JavaScript is disabled on your browser.</div>
+</noscript>
+<div class="fixedNav">
+<!-- ========= START OF TOP NAVBAR ======= -->
+<div class="topNav"><a name="navbar.top">
+<!--   -->
+</a>
+<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
+<a name="navbar.top.firstrow">
+<!--   -->
+</a>
+<ul class="navList" title="Navigation">
+<li><a href="pkg/package-summary.html">Package</a></li>
+<li>Class</li>
+<li><a href="pkg/package-tree.html">Tree</a></li>
+<li><a href="deprecated-list.html">Deprecated</a></li>
+<li><a href="index-all.html">Index</a></li>
+<li class="navBarCell1Rev">Help</li>
+</ul>
+<div class="aboutLanguage">Test header</div>
+</div>
+<div class="subNav">
+<ul class="navList">
+<li>Prev</li>
+<li>Next</li>
+</ul>
+<ul class="navList">
+<li><a href="index.html?help-doc.html" target="_top">Frames</a></li>
+<li><a href="help-doc.html" target="_top">No&nbsp;Frames</a></li>
+</ul>
+<ul class="navList" id="allclasses_navbar_top">
+<li><a href="allclasses-noframe.html">All&nbsp;Classes</a></li>
+</ul>
+<ul class="navListSearch">
+<li><span>SEARCH:&nbsp;</span>
+<input type="text" id="search" value=" " disabled="disabled">
+<input type="reset" id="reset" value=" " disabled="disabled">
+</li>
+</ul>
+<div>
+<script type="text/javascript"><!--
+  allClassesLink = document.getElementById("allclasses_navbar_top");
+  if(window==top) {
+    allClassesLink.style.display = "block";
+  }
+  else {
+    allClassesLink.style.display = "none";
+  }
+  //-->
+</script>
+<noscript>
+<div>JavaScript is disabled on your browser.</div>
+</noscript>
+</div>
+<a name="skip.navbar.top">
+<!--   -->
+</a></div>
+<!-- ========= END OF TOP NAVBAR ========= -->
+</div>
+<div class="header">
+<h1 class="title">How This API Document Is Organized (custom help file)</h1>
+<div class="subTitle">This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.</div>
+</div>
+<div class="contentContainer">
+<ul class="blockList">
+<li class="blockList">
+<h2>Package</h2>
+<p>Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:</p>
+<ul>
+<li>Interfaces (italic)</li>
+<li>Classes</li>
+<li>Enums</li>
+<li>Exceptions</li>
+<li>Errors</li>
+<li>Annotation Types</li>
+</ul>
+</li>
+<li class="blockList">
+<h2>Class/Interface</h2>
+<p>Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:</p>
+<ul>
+<li>Class inheritance diagram</li>
+<li>Direct Subclasses</li>
+<li>All Known Subinterfaces</li>
+<li>All Known Implementing Classes</li>
+<li>Class/interface declaration</li>
+<li>Class/interface description</li>
+</ul>
+<ul>
+<li>Nested Class Summary</li>
+<li>Field Summary</li>
+<li>Constructor Summary</li>
+<li>Method Summary</li>
+</ul>
+<ul>
+<li>Field Detail</li>
+<li>Constructor Detail</li>
+<li>Method Detail</li>
+</ul>
+<p>Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.</p>
+</li>
+<li class="blockList">
+<h2>Annotation Type</h2>
+<p>Each annotation type has its own separate page with the following sections:</p>
+<ul>
+<li>Annotation Type declaration</li>
+<li>Annotation Type description</li>
+<li>Required Element Summary</li>
+<li>Optional Element Summary</li>
+<li>Element Detail</li>
+</ul>
+</li>
+<li class="blockList">
+<h2>Enum</h2>
+<p>Each enum has its own separate page with the following sections:</p>
+<ul>
+<li>Enum declaration</li>
+<li>Enum description</li>
+<li>Enum Constant Summary</li>
+<li>Enum Constant Detail</li>
+</ul>
+</li>
+<li class="blockList">
+<h2>Tree (Class Hierarchy)</h2>
+<p>There is a <a href="overview-tree.html">Class Hierarchy</a> page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with <code>java.lang.Object</code>. The interfaces do not inherit from <code>java.lang.Object</code>.</p>
+<ul>
+<li>When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.</li>
+<li>When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.</li>
+</ul>
+</li>
+<li class="blockList">
+<h2>Deprecated API</h2>
+<p>The <a href="deprecated-list.html">Deprecated API</a> page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.</p>
+</li>
+<li class="blockList">
+<h2>Index</h2>
+<p>The <a href="index-all.html">Index</a> contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.</p>
+</li>
+<li class="blockList">
+<h2>Prev/Next</h2>
+<p>These links take you to the next or previous class, interface, package, or related page.</p>
+</li>
+<li class="blockList">
+<h2>Frames/No Frames</h2>
+<p>These links show and hide the HTML frames.  All pages are available with or without frames.</p>
+</li>
+<li class="blockList">
+<h2>All Classes</h2>
+<p>The <a href="allclasses-noframe.html">All Classes</a> link shows all classes and interfaces except non-static nested types.</p>
+</li>
+<li class="blockList">
+<h2>Serialized Form</h2>
+<p>Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.</p>
+</li>
+<li class="blockList">
+<h2>Constant Field Values</h2>
+<p>The <a href="constant-values.html">Constant Field Values</a> page lists the static final fields and their values.</p>
+</li>
+</ul>
+<span class="emphasizedPhrase">This help file applies to API documentation generated using the standard doclet.</span></div>
+<!-- ======= START OF BOTTOM NAVBAR ====== -->
+<div class="bottomNav"><a name="navbar.bottom">
+<!--   -->
+</a>
+<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
+<a name="navbar.bottom.firstrow">
+<!--   -->
+</a>
+<ul class="navList" title="Navigation">
+<li><a href="pkg/package-summary.html">Package</a></li>
+<li>Class</li>
+<li><a href="pkg/package-tree.html">Tree</a></li>
+<li><a href="deprecated-list.html">Deprecated</a></li>
+<li><a href="index-all.html">Index</a></li>
+<li class="navBarCell1Rev">Help</li>
+</ul>
+<div class="aboutLanguage">Test footer</div>
+</div>
+<div class="subNav">
+<ul class="navList">
+<li>Prev</li>
+<li>Next</li>
+</ul>
+<ul class="navList">
+<li><a href="index.html?help-doc.html" target="_top">Frames</a></li>
+<li><a href="help-doc.html" target="_top">No&nbsp;Frames</a></li>
+</ul>
+<ul class="navList" id="allclasses_navbar_bottom">
+<li><a href="allclasses-noframe.html">All&nbsp;Classes</a></li>
+</ul>
+<div>
+<script type="text/javascript"><!--
+  allClassesLink = document.getElementById("allclasses_navbar_bottom");
+  if(window==top) {
+    allClassesLink.style.display = "block";
+  }
+  else {
+    allClassesLink.style.display = "none";
+  }
+  //-->
+</script>
+<noscript>
+<div>JavaScript is disabled on your browser.</div>
+</noscript>
+</div>
+<a name="skip.navbar.bottom">
+<!--   -->
+</a></div>
+<!-- ======== END OF BOTTOM NAVBAR ======= -->
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testOptions/linksource/AnnotationTypeField.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package linksource;
+
+import java.lang.annotation.*;
+
+/**
+ * This is just a test for annotation type fields.
+ */
+@Documented public @interface AnnotationTypeField {
+    String DEFAULT_NAME = "test";
+
+    String name() default DEFAULT_NAME;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testOptions/linksource/Properties.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package linksource;
+
+/**
+ * This is just a test for property writer.
+ */
+public class Properties {
+
+    public Object someProperty() {
+        return null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testOptions/linksource/SomeClass.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package linksource;
+
+/**
+ * This is just a test for constructor, field and method writers.
+ */
+public class SomeClass {
+
+    public int field;
+
+    public SomeClass() {
+    }
+
+    public int method() {
+        return 0;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testOptions/linksource/SomeEnum.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package linksource;
+
+/**
+ * This is just a test for enum constant writers.
+ */
+public enum SomeEnum {
+    VALUE1,
+    VALUE2
+}
--- a/langtools/test/jdk/javadoc/doclet/testSearch/TestSearch.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testSearch/TestSearch.java	Mon Mar 28 08:41:54 2016 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8141492
+ * @bug 8141492 8071982
  * @summary Test the search feature of javadoc.
  * @author bpatel
  * @library ../lib
@@ -234,6 +234,12 @@
         checkOutput("index-all.html", expectedOutput,
                 "<dt><span class=\"searchTagLink\"><a href=\"pkg/package-summary.html#phrasewithspaces\">"
                         + "phrase with spaces</a></span> - Search tag in pkg</dt>",
+                "<dt><span class=\"searchTagLink\"><a href=\"pkg/package-summary.html#pkg\">"
+                        + "pkg</a></span> - Search tag in pkg</dt>",
+                "<dt><span class=\"searchTagLink\"><a href=\"pkg/package-summary.html#pkg2.5\">"
+                        + "pkg2.5</a></span> - Search tag in pkg</dt>",
+                "<dt><span class=\"searchTagLink\"><a href=\"pkg/package-summary.html#r\">"
+                        + "r</a></span> - Search tag in pkg</dt>",
                 "<dt><span class=\"searchTagLink\"><a href=\"pkg1/RegClass.html#searchphrase\">"
                         + "search phrase</a></span> - Search tag in pkg1.RegClass</dt>",
                 "<dt><span class=\"searchTagLink\"><a href=\"pkg1/RegClass.html#SearchWordWithDescription\">"
@@ -290,7 +296,14 @@
                         + "SingleWord</a></span> - Search tag in pkg</dt>");
         checkOutput("index-files/index-9.html", true,
                 "<dt><span class=\"searchTagLink\"><a href=\"../pkg/package-summary.html#phrasewithspaces\">"
-                        + "phrase with spaces</a></span> - Search tag in pkg</dt>");
+                        + "phrase with spaces</a></span> - Search tag in pkg</dt>",
+                "<dt><span class=\"searchTagLink\"><a href=\"../pkg/package-summary.html#pkg\">"
+                        + "pkg</a></span> - Search tag in pkg</dt>",
+                "<dt><span class=\"searchTagLink\"><a href=\"../pkg/package-summary.html#pkg2.5\">"
+                        + "pkg2.5</a></span> - Search tag in pkg</dt>");
+        checkOutput("index-files/index-11.html", true,
+                "<dt><span class=\"searchTagLink\"><a href=\"../pkg/package-summary.html#r\">"
+                        + "r</a></span> - Search tag in pkg</dt>");
         checkOutput("index-files/index-8.html", true,
                 "<dt><span class=\"searchTagLink\"><a href=\"../pkg/AnotherClass.ModalExclusionType.html"
                         + "#nested%7B@indexnested_tag_test%7D\">nested {@index nested_tag_test}</a></span> - "
@@ -309,6 +322,12 @@
         checkOutput("index-all.html", false,
                 "<dt><span class=\"searchTagLink\"><a href=\"pkg/package-summary.html#phrasewithspaces\">"
                         + "phrase with spaces</a></span> - Search tag in pkg</dt>",
+                "<dt><span class=\"searchTagLink\"><a href=\"pkg/package-summary.html#pkg\">"
+                        + "pkg</a></span> - Search tag in pkg</dt>",
+                "<dt><span class=\"searchTagLink\"><a href=\"pkg/package-summary.html#pkg2.5\">"
+                        + "pkg2.5</a></span> - Search tag in pkg</dt>",
+                "<dt><span class=\"searchTagLink\"><a href=\"pkg/package-summary.html#r\">"
+                        + "r</a></span> - Search tag in pkg</dt>",
                 "<dt><span class=\"searchTagLink\"><a href=\"pkg1/RegClass.html#searchphrase\">"
                         + "search phrase</a></span> - Search tag in pkg1.RegClass</dt>",
                 "<dt><span class=\"searchTagLink\"><a href=\"pkg1/RegClass.html#SearchWordWithDescription\">"
--- a/langtools/test/jdk/javadoc/doclet/testSearch/pkg/AnotherClass.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testSearch/pkg/AnotherClass.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -72,7 +72,7 @@
      * @param param some parameter.
      * @return a test object.
      */
-    public Class method(pkg1.RegClass param) {
+    public pkg1.RegClass method(pkg1.RegClass param) {
         return param;
     }
 }
--- a/langtools/test/jdk/javadoc/doclet/testSearch/pkg/package-info.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testSearch/pkg/package-info.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,9 @@
 
 /**
  * Test package. Testing search tag for package. Single {@index SingleWord} search tag.
- * Search {@index "phrase with spaces"}.
+ * Search tag 1 {@index "phrase with spaces"}.
+ * Search tag 2 {@index "pkg"}.
+ * Search tag 3 {@index "pkg2.5"}.
+ * Search tag 5 {@index "r"}.
  */
 package pkg;
--- a/langtools/test/jdk/javadoc/doclet/testSearch/pkgfx/C.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testSearch/pkgfx/C.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -60,24 +60,24 @@
 
     public final void setRate(double value) {}
 
-    public final double getRate() {}
+    public final double getRate() {return 0.0;}
 
-    public final DoubleProperty rateProperty() {}
+    public final DoubleProperty rateProperty() {return null;}
 
     private BooleanProperty paused;
 
     public final void setPaused(boolean value) {}
 
-    public final double isPaused() {}
+    public final double isPaused() {return 0.0;}
 
     class DoubleProperty {}
 
     class BooleanProperty {}
 
-    public final BooleanProperty setTestMethodProperty() {}
+    public final BooleanProperty setTestMethodProperty() {return null;}
 
     private class Inner {
-        private BooleanProperty testMethodProperty() {}
+        private BooleanProperty testMethodProperty() {return null;}
 
         /**
          * Defines the direction/speed at which the {@code Timeline} is expected to
@@ -88,8 +88,8 @@
 
         public final void setRate(double value) {}
 
-        public final double getRate() {}
+        public final double getRate() {return 0.0;}
 
-        public final DoubleProperty rateProperty() {}
+        public final DoubleProperty rateProperty() {return null;}
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testSerializedForm/ExternalizedForm.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+public class ExternalizedForm implements Externalizable {
+
+    /**
+     * @throws IOException when there is an I/O error.
+     */
+    public void writeExternal(ObjectOutput oo) throws IOException {}
+
+    /**
+     * @throws IOException when there is an I/O error.
+     * @throws ClassNotFoundException if no class found.
+     * @serialData This is a serial data comment.
+     */
+    public void readExternal(ObjectInput oi) throws IOException, ClassNotFoundException {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testSerializedForm/SerializedForm.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamField;
+import java.io.Serializable;
+
+public class SerializedForm implements Serializable {
+
+    /**
+     * @serialField name String a test
+     * @see TestSerializedForm
+     */
+    @Deprecated
+    private static final ObjectStreamField[] serialPersistentFields = {
+        new ObjectStreamField("i", int.class),
+        new ObjectStreamField("count", Integer.TYPE),
+        new ObjectStreamField("name", String.class)
+    };
+
+    /**
+     * The entry point of the test.
+     * @param args the array of command line arguments.
+     */
+
+    /**
+     * @param s ObjectInputStream.
+     * @throws IOException when there is an I/O error.
+     * @serial
+     */
+    private void readObject(ObjectInputStream s) throws IOException {}
+
+    /**
+     * @param s ObjectOutputStream.
+     * @throws IOException when there is an I/O error.
+     * @serial
+     */
+    private void writeObject(ObjectOutputStream s) throws IOException {}
+
+    /**
+     * @throws IOException when there is an I/O error.
+     * @serialData This is a serial data comment.
+     * @return an object.
+     */
+    protected Object readResolve() throws IOException {return null;}
+
+    /**
+     * @throws IOException when there is an I/O error.
+     * @serialData This is a serial data comment.
+     * @return an object.
+     */
+    protected Object writeReplace() throws IOException {return null;}
+
+    /**
+     * @throws IOException when there is an I/O error.
+     * @serialData This is a serial data comment.
+     * @return an object.
+     */
+    protected Object readObjectNoData() throws IOException {
+        return null;
+    }
+}
--- a/langtools/test/jdk/javadoc/doclet/testSerializedForm/TestSerializedForm.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testSerializedForm/TestSerializedForm.java	Mon Mar 28 08:41:54 2016 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 4341304 4485668 4966728 8032066
+ * @bug 4341304 4485668 4966728 8032066 8071982
  * @summary Test that methods readResolve and writeReplace show
  * up in serialized-form.html the same way that readObject and writeObject do.
  * If the doclet includes readResolve and writeReplace in the serialized-form
@@ -41,7 +41,7 @@
 
 import java.io.*;
 
-public class TestSerializedForm extends JavadocTester implements Serializable {
+public class TestSerializedForm extends JavadocTester {
     public static void main(String... args) throws Exception {
         TestSerializedForm tester = new TestSerializedForm();
         tester.runTests();
@@ -50,18 +50,23 @@
 //        tester.printSummary();
     }
 
-    @Test
+    // @ignore 8146022
+    // @Test
     void testDefault() {
-        javadoc("-d", "out-default",
+        javadoc("-d", "out-default", "-serialwarn", "-Xdoclint:none",
                 "-sourcepath", testSrc,
-                testSrc("TestSerializedForm.java"), "pkg1");
+                testSrc("SerializedForm.java"), testSrc("ExternalizedForm.java"), "pkg1");
         checkExit(Exit.OK);
 
         checkOutput("serialized-form.html", true,
                 "protected&nbsp;java.lang.Object&nbsp;readResolve()",
                 "protected&nbsp;java.lang.Object&nbsp;writeReplace()",
                 "protected&nbsp;java.lang.Object&nbsp;readObjectNoData()",
-                "See Also",
+                "<h3>Serialization Overview</h3>\n<ul class=\"blockList\">\n"
+                + "<li class=\"blockListLast\">\n<div class=\"block\">"
+                + "<span class=\"deprecatedLabel\">Deprecated.</span>&nbsp;</div>\n"
+                + "<dl>\n<dt><span class=\"seeLabel\">See Also:</span></dt>\n"
+                + "<dd><code>TestSerializedForm</code></dd>\n</dl>",
                 "<h3>Class pkg1.NestedInnerClass.InnerClass.ProNestedInnerClass "
                 + "extends java.lang.Object implements Serializable</h3>",
                 "<h3>Class pkg1.PrivateIncludeInnerClass.PriInnerClass extends "
@@ -86,7 +91,7 @@
         javadoc("-private",
                 "-d", "out-private",
                 "-sourcepath", testSrc,
-                testSrc("TestSerializedForm.java"), "pkg1");
+                testSrc("SerializedForm.java"), testSrc("ExternalizedForm.java"), "pkg1");
         checkExit(Exit.OK);
 
         checkOutput("serialized-form.html", true,
@@ -109,53 +114,4 @@
                 + "title=\"class in pkg1\">pkg1.PublicExcludeInnerClass.PubInnerClass</a> "
                 + "extends java.lang.Object implements Serializable</h3>");
     }
-
-    /**
-     * @serial
-     * @see TestSerializedForm
-     */
-    public final int SERIALIZABLE_CONSTANT = 1;
-
-    /**
-     * The entry point of the test.
-     * @param args the array of command line arguments.
-     */
-
-    /**
-     * @param s ObjectInputStream.
-     * @throws IOException when there is an I/O error.
-     * @serial
-     */
-    private void readObject(ObjectInputStream s) throws IOException {}
-
-    /**
-     * @param s ObjectOutputStream.
-     * @throws IOException when there is an I/O error.
-     * @serial
-     */
-    private void writeObject(ObjectOutputStream s) throws IOException {}
-
-    /**
-     * @throws IOException when there is an I/O error.
-     * @serialData This is a serial data comment.
-     * @return an object.
-     */
-    protected Object readResolve() throws IOException {return null;}
-
-    /**
-     * @throws IOException when there is an I/O error.
-     * @serialData This is a serial data comment.
-     * @return an object.
-     */
-    protected Object writeReplace() throws IOException {return null;}
-
-    /**
-     * @throws IOException when there is an I/O error.
-     * @serialData This is a serial data comment.
-     * @return an object.
-     */
-    protected Object readObjectNoData() throws IOException {
-        return null;
-    }
-
 }
--- a/langtools/test/jdk/javadoc/doclet/testSimpleTag/C.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testSimpleTag/C.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,4 +28,10 @@
  * @tag-with-hyphens a tag that contains hyphens.
  */
 
-public class C {}
+public class C {
+    /**
+     * @param arg this is an int argument.
+     */
+    public void m(int arg) {
+    }
+}
--- a/langtools/test/jdk/javadoc/doclet/testSimpleTag/TestSimpleTag.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testSimpleTag/TestSimpleTag.java	Mon Mar 28 08:41:54 2016 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 4695326 4750173 4920381 8078320
+ * @bug 4695326 4750173 4920381 8078320 8071982
  * @summary Test the declaration of simple tags using -tag. Verify that
  * "-tag name" is a shortcut for "-tag name:a:Name:".  Also verity that
  * you can escape the ":" character with a back slash so that it is not
@@ -46,6 +46,7 @@
     void test() {
         javadoc("-d", "out",
                 "-sourcepath", testSrc,
+                "-tag", "param",
                 "-tag", "todo",
                 "-tag", "ejb\\:bean:a:EJB Beans:",
                 "-tag", "regular:a:Regular Tag:",
@@ -57,6 +58,8 @@
                 "<span class=\"simpleTagLabel\">Todo:</span>",
                 "<span class=\"simpleTagLabel\">EJB Beans:</span>",
                 "<span class=\"simpleTagLabel\">Regular Tag:</span>",
-                "<span class=\"simpleTagLabel\">Tag-With-Hyphens:</span>");
+                "<span class=\"simpleTagLabel\">Tag-With-Hyphens:</span>",
+                "<dt><span class=\"paramLabel\">Parameters:</span></dt>\n"
+                + "<dd><code>arg</code> - this is an int argument.</dd>");
     }
 }
--- a/langtools/test/jdk/javadoc/doclet/testTypeAnnotations/TestTypeAnnotations.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testTypeAnnotations/TestTypeAnnotations.java	Mon Mar 28 08:41:54 2016 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug      8005091 8009686 8025633 8026567 6469562
+ * @bug      8005091 8009686 8025633 8026567 6469562 8071982 8071984
  * @summary  Make sure that type annotations are displayed correctly
  * @author   Bhavesh Patel
  * @library  ../lib
@@ -355,5 +355,369 @@
         checkOutput("typeannos/Generic2.html", true,
                 "<pre>void&nbsp;test2(<a href=\"../typeannos/RcvrA.html\" title=\""
                 + "annotation in typeannos\">@RcvrA</a>&nbsp;Generic2&lt;X&gt;&nbsp;this)</pre>");
+
+
+        // Test for repeated type annotations (RepeatedAnnotations.java).
+        checkOutput("typeannos/RepeatingAtClassLevel.html", true,
+                "<pre><a href=\"../typeannos/RepTypeA.html\" title=\"annotation in "
+                + "typeannos\">@RepTypeA</a> <a href=\"../typeannos/RepTypeA.html\" "
+                + "title=\"annotation in typeannos\">@RepTypeA</a>\n<a href="
+                + "\"../typeannos/RepTypeB.html\" title=\"annotation in typeannos\">"
+                + "@RepTypeB</a> <a href=\"../typeannos/RepTypeB.html\" title="
+                + "\"annotation in typeannos\">@RepTypeB</a>\nclass <span class="
+                + "\"typeNameLabel\">RepeatingAtClassLevel</span>\nextends "
+                + "java.lang.Object</pre>");
+
+// @ignore 8146008
+//        checkOutput("typeannos/RepeatingAtClassLevel2.html", true,
+//                "<pre><a href=\"../typeannos/RepTypeUseA.html\" title=\"annotation "
+//                + "in typeannos\">@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseA.html"
+//                + "\" title=\"annotation in typeannos\">@RepTypeUseA</a>\n<a href="
+//                + "\"../typeannos/RepTypeUseB.html\" title=\"annotation in typeannos"
+//                + "\">@RepTypeUseB</a> <a href=\"../typeannos/RepTypeUseB.html\" "
+//                + "title=\"annotation in typeannos\">@RepTypeUseB</a>\nclass <span "
+//                + "class=\"typeNameLabel\">RepeatingAtClassLevel2</span>\nextends "
+//                + "java.lang.Object</pre>");
+//
+//        checkOutput("typeannos/RepeatingAtClassLevel2.html", true,
+//                "<pre><a href=\"../typeannos/RepAllContextsA.html\" title=\"annotation"
+//                + " in typeannos\">@RepAllContextsA</a> <a href=\"../typeannos/RepAllContextsA.html"
+//                + "\" title=\"annotation in typeannos\">@RepAllContextsA</a>\n<a href="
+//                + "\"../typeannos/RepAllContextsB.html\" title=\"annotation in typeannos"
+//                + "\">@RepAllContextsB</a> <a href=\"../typeannos/RepAllContextsB.html"
+//                + "\" title=\"annotation in typeannos\">@RepAllContextsB</a>\n"
+//                + "class <span class=\"typeNameLabel\">RepeatingAtClassLevel3</span>\n"
+//                + "extends java.lang.Object</pre>");
+
+        checkOutput("typeannos/RepeatingOnConstructor.html", true,
+                "<pre><a href=\"../typeannos/RepConstructorA.html\" title=\"annotation "
+                + "in typeannos\">@RepConstructorA</a> <a href=\"../typeannos/RepConstructorA.html"
+                + "\" title=\"annotation in typeannos\">@RepConstructorA</a>\n<a href="
+                + "\"../typeannos/RepConstructorB.html\" title=\"annotation in typeannos"
+                + "\">@RepConstructorB</a> <a href=\"../typeannos/RepConstructorB.html"
+                + "\" title=\"annotation in typeannos\">@RepConstructorB</a>\n"
+                + "RepeatingOnConstructor()</pre>",
+
+                "<pre><a href=\"../typeannos/RepConstructorA.html\" title=\"annotation in typeannos"
+                + "\">@RepConstructorA</a> <a href=\"../typeannos/RepConstructorA.html"
+                + "\" title=\"annotation in typeannos\">@RepConstructorA</a>\n<a href="
+                + "\"../typeannos/RepConstructorB.html\" title=\"annotation in typeannos"
+                + "\">@RepConstructorB</a> <a href=\"../typeannos/RepConstructorB.html"
+                + "\" title=\"annotation in typeannos\">@RepConstructorB</a>\n"
+                + "RepeatingOnConstructor(int&nbsp;i,\n                       int&nbsp;j)</pre>",
+
+                "<pre><a href=\"../typeannos/RepAllContextsA.html\" title=\"annotation in typeannos"
+                + "\">@RepAllContextsA</a> <a href=\"../typeannos/RepAllContextsA.html"
+                + "\" title=\"annotation in typeannos\">@RepAllContextsA</a>\n"
+                + "<a href=\"../typeannos/RepAllContextsB.html\" title=\"annotation in typeannos"
+                + "\">@RepAllContextsB</a> <a href=\"../typeannos/RepAllContextsB.html"
+                + "\" title=\"annotation in typeannos\">@RepAllContextsB</a>\n"
+                + "RepeatingOnConstructor(int&nbsp;i,\n                       int&nbsp;j,\n"
+                + "                       int&nbsp;k)</pre>",
+
+                "<pre>RepeatingOnConstructor(<a href=\"../typeannos/RepParameterA.html"
+                + "\" title=\"annotation in typeannos\">@RepParameterA</a> <a href="
+                + "\"../typeannos/RepParameterA.html\" title=\"annotation in typeannos"
+                + "\">@RepParameterA</a> <a href=\"../typeannos/RepParameterB.html"
+                + "\" title=\"annotation in typeannos\">@RepParameterB</a> "
+                + "<a href=\"../typeannos/RepParameterB.html\" title=\"annotation in typeannos"
+                + "\">@RepParameterB</a>\n                       java.lang.String&nbsp;parameter,\n"
+                + "                       <a href=\"../typeannos/RepParameterA.html\" "
+                + "title=\"annotation in typeannos\">@RepParameterA</a> <a href="
+                + "\"../typeannos/RepParameterA.html\" title=\"annotation in typeannos\">"
+                + "@RepParameterA</a> <a href=\"../typeannos/RepParameterB.html\" "
+                + "title=\"annotation in typeannos\">@RepParameterB</a> <a href="
+                + "\"../typeannos/RepParameterB.html\" title=\"annotation in typeannos\">"
+                + "@RepParameterB</a>\n                       java.lang.String "
+                + "<a href=\"../typeannos/RepTypeUseA.html\" title=\"annotation in typeannos\">"
+                + "@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseA.html\" "
+                + "title=\"annotation in typeannos\">@RepTypeUseA</a> <a href="
+                + "\"../typeannos/RepTypeUseB.html\" title=\"annotation in typeannos\">@RepTypeUseB</a> "
+                + "<a href=\"../typeannos/RepTypeUseB.html\" title=\"annotation in typeannos\">"
+                + "@RepTypeUseB</a> ...&nbsp;vararg)</pre>"
+        );
+
+        checkOutput("typeannos/RepeatingOnConstructor.Inner.html", true,
+                "<code><span class=\"memberNameLink\"><a href=\"../typeannos/RepeatingOnConstructor.Inner.html"
+                + "#Inner-java.lang.String-java.lang.String...-\">Inner</a></span>"
+                + "(java.lang.String&nbsp;parameter,\n     java.lang.String <a href="
+                + "\"../typeannos/RepTypeUseA.html\" title=\"annotation in typeannos\">"
+                + "@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseA.html\" title="
+                + "\"annotation in typeannos\">@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseB.html"
+                + "\" title=\"annotation in typeannos\">@RepTypeUseB</a> <a href="
+                + "\"../typeannos/RepTypeUseB.html\" title=\"annotation in typeannos\">"
+                + "@RepTypeUseB</a> ...&nbsp;vararg)</code>",
+
+                "Inner(<a href=\"../typeannos/RepTypeUseA.html\" title=\"annotation in typeannos\">"
+                + "@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseA.html\" title="
+                + "\"annotation in typeannos\">@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseB.html"
+                + "\" title=\"annotation in typeannos\">@RepTypeUseB</a> <a href="
+                + "\"../typeannos/RepTypeUseB.html\" title=\"annotation in typeannos\">"
+                + "@RepTypeUseB</a>&nbsp;RepeatingOnConstructor&nbsp;this,\n      <a href="
+                + "\"../typeannos/RepParameterA.html\" title=\"annotation in typeannos\">"
+                + "@RepParameterA</a> <a href=\"../typeannos/RepParameterA.html\" title="
+                + "\"annotation in typeannos\">@RepParameterA</a> <a href=\"../typeannos/RepParameterB.html"
+                + "\" title=\"annotation in typeannos\">@RepParameterB</a> <a href="
+                + "\"../typeannos/RepParameterB.html\" title=\"annotation in typeannos\">"
+                + "@RepParameterB</a>\n      java.lang.String&nbsp;parameter,\n"
+                + "      <a href=\"../typeannos/RepParameterA.html\" title=\"annotation in typeannos\">"
+                + "@RepParameterA</a> <a href=\"../typeannos/RepParameterA.html\" title="
+                + "\"annotation in typeannos\">@RepParameterA</a> <a href=\"../typeannos/RepParameterB.html"
+                + "\" title=\"annotation in typeannos\">@RepParameterB</a> <a href="
+                + "\"../typeannos/RepParameterB.html\" title=\"annotation in typeannos\">"
+                + "@RepParameterB</a>\n      java.lang.String <a href=\"../typeannos/RepTypeUseA.html"
+                + "\" title=\"annotation in typeannos\">@RepTypeUseA</a> <a href="
+                + "\"../typeannos/RepTypeUseA.html\" title=\"annotation in typeannos\">"
+                + "@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseB.html\" title="
+                + "\"annotation in typeannos\">@RepTypeUseB</a> <a href=\"../typeannos/RepTypeUseB.html"
+                + "\" title=\"annotation in typeannos\">@RepTypeUseB</a> ...&nbsp;vararg)");
+
+        checkOutput("typeannos/RepeatingOnField.html", true,
+                "<code>(package private) java.lang.Integer</code></td>\n<td class=\"colLast\">"
+                + "<code><span class=\"memberNameLink\"><a href=\"../typeannos/RepeatingOnField.html#i1"
+                + "\">i1</a></span></code>",
+
+                "<code>(package private) <a href=\"../typeannos/RepTypeUseA.html\" "
+                + "title=\"annotation in typeannos\">@RepTypeUseA</a> <a href=\""
+                + "../typeannos/RepTypeUseA.html\" title=\"annotation in typeannos\">"
+                + "@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseB.html\" title="
+                + "\"annotation in typeannos\">@RepTypeUseB</a> <a href=\"../typeannos/RepTypeUseB.html"
+                + "\" title=\"annotation in typeannos\">@RepTypeUseB</a> java.lang.Integer</code></td>\n"
+                + "<td class=\"colLast\"><code><span class=\"memberNameLink\"><a href="
+                + "\"../typeannos/RepeatingOnField.html#i2\">i2</a></span></code>",
+
+                "<code>(package private) <a href=\"../typeannos/RepTypeUseA.html\" title="
+                + "\"annotation in typeannos\">@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseA.html\" "
+                + "title=\"annotation in typeannos\">@RepTypeUseA</a> <a href="
+                + "\"../typeannos/RepTypeUseB.html\" title=\"annotation in typeannos\">"
+                + "@RepTypeUseB</a> <a href=\"../typeannos/RepTypeUseB.html\" title="
+                + "\"annotation in typeannos\">@RepTypeUseB</a> java.lang.Integer</code>"
+                + "</td>\n<td class=\"colLast\"><code><span class=\"memberNameLink\">"
+                + "<a href=\"../typeannos/RepeatingOnField.html#i3\">i3</a></span></code>",
+
+                "<code>(package private) <a href=\"../typeannos/RepAllContextsA.html\" title=\""
+                + "annotation in typeannos\">@RepAllContextsA</a> <a href=\"../typeannos/RepAllContextsA.html"
+                + "\" title=\"annotation in typeannos\">@RepAllContextsA</a> <a href="
+                + "\"../typeannos/RepAllContextsB.html\" title=\"annotation in typeannos\">"
+                + "@RepAllContextsB</a> <a href=\"../typeannos/RepAllContextsB.html\" title="
+                + "\"annotation in typeannos\">@RepAllContextsB</a> java.lang.Integer</code>"
+                + "</td>\n<td class=\"colLast\"><code><span class=\"memberNameLink\">"
+                + "<a href=\"../typeannos/RepeatingOnField.html#i4\">i4</a></span></code>",
+
+                "<code>(package private) java.lang.String <a href=\"../typeannos/RepTypeUseA.html"
+                + "\" title=\"annotation in typeannos\">@RepTypeUseA</a> <a href="
+                + "\"../typeannos/RepTypeUseA.html\" title=\"annotation in typeannos\">"
+                + "@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseB.html\" title="
+                + "\"annotation in typeannos\">@RepTypeUseB</a> <a href=\"../typeannos/RepTypeUseB.html"
+                + "\" title=\"annotation in typeannos\">@RepTypeUseB</a> [] <a href="
+                + "\"../typeannos/RepTypeUseA.html\" title=\"annotation in typeannos\">"
+                + "@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseA.html\" title="
+                + "\"annotation in typeannos\">@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseB.html"
+                + "\" title=\"annotation in typeannos\">@RepTypeUseB</a> <a href="
+                + "\"../typeannos/RepTypeUseB.html\" title=\"annotation in typeannos\">"
+                + "@RepTypeUseB</a> []</code></td>\n<td class=\"colLast\"><code><span class="
+                + "\"memberNameLink\"><a href=\"../typeannos/RepeatingOnField.html#sa"
+                + "\">sa</a></span></code>",
+
+                "<pre><a href=\"../typeannos/RepFieldA.html\" title=\"annotation in typeannos\">"
+                + "@RepFieldA</a> <a href=\"../typeannos/RepFieldA.html\" title="
+                + "\"annotation in typeannos\">@RepFieldA</a>\n<a href=\"../typeannos/RepFieldB.html"
+                + "\" title=\"annotation in typeannos\">@RepFieldB</a> <a href="
+                + "\"../typeannos/RepFieldB.html\" title=\"annotation in typeannos\">"
+                + "@RepFieldB</a>\njava.lang.Integer i1</pre>",
+
+                "<pre><a href=\"../typeannos/RepTypeUseA.html\" title=\"annotation in typeannos"
+                + "\">@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseA.html"
+                + "\" title=\"annotation in typeannos\">@RepTypeUseA</a> "
+                + "<a href=\"../typeannos/RepTypeUseB.html\" title=\"annotation in typeannos\">"
+                + "@RepTypeUseB</a> <a href=\"../typeannos/RepTypeUseB.html\" title="
+                + "\"annotation in typeannos\">@RepTypeUseB</a> java.lang.Integer i2</pre>",
+
+                "<pre><a href=\"../typeannos/RepFieldA.html\" title=\"annotation in typeannos\">"
+                + "@RepFieldA</a> <a href=\"../typeannos/RepFieldA.html\" title="
+                + "\"annotation in typeannos\">@RepFieldA</a>\n<a href=\"../typeannos/RepFieldB.html"
+                + "\" title=\"annotation in typeannos\">@RepFieldB</a> <a href="
+                + "\"../typeannos/RepFieldB.html\" title=\"annotation in typeannos\">"
+                + "@RepFieldB</a>\n<a href=\"../typeannos/RepTypeUseA.html\" title="
+                + "\"annotation in typeannos\">@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseA.html"
+                + "\" title=\"annotation in typeannos\">@RepTypeUseA</a> <a href="
+                + "\"../typeannos/RepTypeUseB.html\" title=\"annotation in typeannos\">"
+                + "@RepTypeUseB</a> <a href=\"../typeannos/RepTypeUseB.html\" title="
+                + "\"annotation in typeannos\">@RepTypeUseB</a> java.lang.Integer i3</pre>",
+
+                "<pre><a href=\"../typeannos/RepAllContextsA.html\" title=\"annotation in typeannos\">"
+                + "@RepAllContextsA</a> <a href=\"../typeannos/RepAllContextsA.html"
+                + "\" title=\"annotation in typeannos\">@RepAllContextsA</a>\n<a href="
+                + "\"../typeannos/RepAllContextsB.html\" title=\"annotation in typeannos\">"
+                + "@RepAllContextsB</a> <a href=\"../typeannos/RepAllContextsB.html"
+                + "\" title=\"annotation in typeannos\">@RepAllContextsB</a>\n"
+                + "<a href=\"../typeannos/RepAllContextsA.html\" title=\"annotation in typeannos\">"
+                + "@RepAllContextsA</a> <a href=\"../typeannos/RepAllContextsA.html\" "
+                + "title=\"annotation in typeannos\">@RepAllContextsA</a> <a href="
+                + "\"../typeannos/RepAllContextsB.html\" title=\"annotation in typeannos\">"
+                + "@RepAllContextsB</a> <a href=\"../typeannos/RepAllContextsB.html"
+                + "\" title=\"annotation in typeannos\">@RepAllContextsB</a> java.lang.Integer i4</pre>",
+
+                "<pre>java.lang.String <a href=\"../typeannos/RepTypeUseA.html\" title="
+                + "\"annotation in typeannos\">@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseA.html"
+                + "\" title=\"annotation in typeannos\">@RepTypeUseA</a> <a href="
+                + "\"../typeannos/RepTypeUseB.html\" title=\"annotation in typeannos\">"
+                + "@RepTypeUseB</a> <a href=\"../typeannos/RepTypeUseB.html\" title="
+                + "\"annotation in typeannos\">@RepTypeUseB</a> [] <a href="
+                + "\"../typeannos/RepTypeUseA.html\" title=\"annotation in typeannos\">"
+                + "@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseA.html\" title="
+                + "\"annotation in typeannos\">@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseB.html\" "
+                + "title=\"annotation in typeannos\">@RepTypeUseB</a> <a href="
+                + "\"../typeannos/RepTypeUseB.html\" title=\"annotation in typeannos\">"
+                + "@RepTypeUseB</a> [] sa</pre>");
+
+        checkOutput("typeannos/RepeatingOnMethod.html", true,
+                "<code>(package private) java.lang.String</code></td>\n<td class="
+                + "\"colLast\"><code><span class=\"memberNameLink\"><a href="
+                + "\"../typeannos/RepeatingOnMethod.html#test1--\">test1</a></span>()</code>",
+
+                "<code>(package private) <a href=\"../typeannos/RepTypeUseA.html\" "
+                + "title=\"annotation in typeannos\">@RepTypeUseA</a> <a href="
+                + "\"../typeannos/RepTypeUseA.html\" title=\"annotation in typeannos\">"
+                + "@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseB.html\" title="
+                + "\"annotation in typeannos\">@RepTypeUseB</a> <a href=\"../typeannos/RepTypeUseB.html"
+                + "\" title=\"annotation in typeannos\">@RepTypeUseB</a> java.lang.String</code>"
+                + "</td>\n<td class=\"colLast\"><code><span class=\"memberNameLink\">"
+                + "<a href=\"../typeannos/RepeatingOnMethod.html#test2--\">test2</a>"
+                + "</span>()</code>",
+
+                "<code>(package private) <a href=\"../typeannos/RepTypeUseA.html\" "
+                + "title=\"annotation in typeannos\">@RepTypeUseA</a> <a href="
+                + "\"../typeannos/RepTypeUseA.html\" title=\"annotation in typeannos\">"
+                + "@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseB.html\" title="
+                + "\"annotation in typeannos\">@RepTypeUseB</a> <a href=\"../typeannos/RepTypeUseB.html\" "
+                + "title=\"annotation in typeannos\">@RepTypeUseB</a> java.lang.String</code>"
+                + "</td>\n<td class=\"colLast\"><code><span class=\"memberNameLink\">"
+                + "<a href=\"../typeannos/RepeatingOnMethod.html#test3--\">test3</a>"
+                + "</span>()</code>",
+
+                "<code>(package private) <a href=\"../typeannos/RepAllContextsA.html\" "
+                + "title=\"annotation in typeannos\">@RepAllContextsA</a> <a href="
+                + "\"../typeannos/RepAllContextsA.html\" title=\"annotation in typeannos\">"
+                + "@RepAllContextsA</a> <a href=\"../typeannos/RepAllContextsB.html\" "
+                + "title=\"annotation in typeannos\">@RepAllContextsB</a> <a href="
+                + "\"../typeannos/RepAllContextsB.html\" title=\"annotation in typeannos\">"
+                + "@RepAllContextsB</a> java.lang.String</code></td>\n<td class=\"colLast\">"
+                + "<code><span class=\"memberNameLink\"><a href=\"../typeannos/RepeatingOnMethod.html"
+                + "#test4--\">test4</a></span>()</code>",
+
+                "<code><span class=\"memberNameLink\"><a href=\"../typeannos/RepeatingOnMethod.html"
+                + "#test5-java.lang.String-java.lang.String...-\">test5</a></span>"
+                + "(java.lang.String&nbsp;parameter,\n     java.lang.String <a href="
+                + "\"../typeannos/RepTypeUseA.html\" title=\"annotation in typeannos\">"
+                + "@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseA.html\" title="
+                + "\"annotation in typeannos\">@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseB.html"
+                + "\" title=\"annotation in typeannos\">@RepTypeUseB</a> <a href="
+                + "\"../typeannos/RepTypeUseB.html\" title=\"annotation in typeannos\">"
+                + "@RepTypeUseB</a> ...&nbsp;vararg)</code>",
+
+                "<a href=\"../typeannos/RepMethodA.html\" title=\"annotation in typeannos\">"
+                + "@RepMethodA</a> <a href=\"../typeannos/RepMethodA.html\" title="
+                + "\"annotation in typeannos\">@RepMethodA</a>\n<a href=\"../typeannos/RepMethodB.html\""
+                + " title=\"annotation in typeannos\">@RepMethodB</a> <a href="
+                + "\"../typeannos/RepMethodB.html\" title=\"annotation in typeannos\">"
+                + "@RepMethodB</a>\njava.lang.String&nbsp;test1()",
+
+                "<a href=\"../typeannos/RepTypeUseA.html\" title=\"annotation in typeannos\">"
+                + "@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseA.html\" title="
+                + "\"annotation in typeannos\">@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseB.html\" "
+                + "title=\"annotation in typeannos\">@RepTypeUseB</a> <a href=\"../typeannos/RepTypeUseB.html\" "
+                + "title=\"annotation in typeannos\">@RepTypeUseB</a> java.lang.String&nbsp;test2()",
+
+                "<a href=\"../typeannos/RepMethodA.html\" title=\"annotation in typeannos\">"
+                + "@RepMethodA</a> <a href=\"../typeannos/RepMethodA.html\" title="
+                + "\"annotation in typeannos\">@RepMethodA</a>\n<a href=\"../typeannos/RepMethodB.html\" "
+                + "title=\"annotation in typeannos\">@RepMethodB</a> <a href="
+                + "\"../typeannos/RepMethodB.html\" title=\"annotation in typeannos\">"
+                + "@RepMethodB</a>\n<a href=\"../typeannos/RepTypeUseA.html\" title="
+                + "\"annotation in typeannos\">@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseA.html\" "
+                + "title=\"annotation in typeannos\">@RepTypeUseA</a> <a href="
+                + "\"../typeannos/RepTypeUseB.html\" title=\"annotation in typeannos\">"
+                + "@RepTypeUseB</a> <a href=\"../typeannos/RepTypeUseB.html\" title="
+                + "\"annotation in typeannos\">@RepTypeUseB</a> java.lang.String&nbsp;test3()",
+
+                "<a href=\"../typeannos/RepAllContextsA.html\" title=\"annotation in typeannos\">"
+                + "@RepAllContextsA</a> <a href=\"../typeannos/RepAllContextsA.html\" "
+                + "title=\"annotation in typeannos\">@RepAllContextsA</a>\n<a href="
+                + "\"../typeannos/RepAllContextsB.html\" title=\"annotation in typeannos\">"
+                + "@RepAllContextsB</a> <a href=\"../typeannos/RepAllContextsB.html\" "
+                + "title=\"annotation in typeannos\">@RepAllContextsB</a>\n<a href="
+                + "\"../typeannos/RepAllContextsA.html\" title=\"annotation in typeannos\">"
+                + "@RepAllContextsA</a> <a href=\"../typeannos/RepAllContextsA.html\" "
+                + "title=\"annotation in typeannos\">@RepAllContextsA</a> <a href="
+                + "\"../typeannos/RepAllContextsB.html\" title=\"annotation in typeannos\">"
+                + "@RepAllContextsB</a> <a href=\"../typeannos/RepAllContextsB.html\" "
+                + "title=\"annotation in typeannos\">@RepAllContextsB</a> java.lang.String&nbsp;test4()",
+
+                "java.lang.String&nbsp;test5(<a href=\"../typeannos/RepTypeUseA.html\" "
+                + "title=\"annotation in typeannos\">@RepTypeUseA</a> <a href="
+                + "\"../typeannos/RepTypeUseA.html\" title=\"annotation in typeannos\">"
+                + "@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseB.html\" title="
+                + "\"annotation in typeannos\">@RepTypeUseB</a> <a href=\"../typeannos/RepTypeUseB.html\" "
+                + "title=\"annotation in typeannos\">@RepTypeUseB</a>&nbsp;RepeatingOnMethod&nbsp;"
+                + "this,\n                       <a href=\"../typeannos/RepParameterA.html\" "
+                + "title=\"annotation in typeannos\">@RepParameterA</a> <a href="
+                + "\"../typeannos/RepParameterA.html\" title=\"annotation in typeannos\">"
+                + "@RepParameterA</a> <a href=\"../typeannos/RepParameterB.html\" "
+                + "title=\"annotation in typeannos\">@RepParameterB</a> <a href="
+                + "\"../typeannos/RepParameterB.html\" title=\"annotation in typeannos\">"
+                + "@RepParameterB</a>\n                       java.lang.String&nbsp;parameter,\n"
+                + "                       <a href=\"../typeannos/RepParameterA.html\" title="
+                + "\"annotation in typeannos\">@RepParameterA</a> <a href=\"../typeannos/RepParameterA.html\""
+                + " title=\"annotation in typeannos\">@RepParameterA</a> <a href="
+                + "\"../typeannos/RepParameterB.html\" title=\"annotation in typeannos\">"
+                + "@RepParameterB</a> <a href=\"../typeannos/RepParameterB.html\" title="
+                + "\"annotation in typeannos\">@RepParameterB</a>\n                       "
+                + "java.lang.String <a href=\"../typeannos/RepTypeUseA.html\" title="
+                + "\"annotation in typeannos\">@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseA.html\" "
+                + "title=\"annotation in typeannos\">@RepTypeUseA</a> <a href="
+                + "\"../typeannos/RepTypeUseB.html\" title=\"annotation in typeannos\">"
+                + "@RepTypeUseB</a> <a href=\"../typeannos/RepTypeUseB.html\" title="
+                + "\"annotation in typeannos\">@RepTypeUseB</a> ...&nbsp;vararg)");
+
+        checkOutput("typeannos/RepeatingOnTypeParametersBoundsTypeArgumentsOnMethod.html", true,
+                "<code>(package private) &lt;T&gt;&nbsp;java.lang.String</code></td>\n"
+                + "<td class=\"colLast\"><code><span class=\"memberNameLink\"><a href="
+                + "\"../typeannos/RepeatingOnTypeParametersBoundsTypeArgumentsOnMethod.html#"
+                + "genericMethod-T-\">genericMethod</a></span>(T&nbsp;t)</code>",
+
+                "<code>(package private) &lt;T&gt;&nbsp;java.lang.String</code></td>\n"
+                + "<td class=\"colLast\"><code><span class=\"memberNameLink\"><a href="
+                + "\"../typeannos/RepeatingOnTypeParametersBoundsTypeArgumentsOnMethod.html#"
+                + "genericMethod2-T-\">genericMethod2</a></span>(<a href=\"../typeannos/RepTypeUseA.html"
+                + "\" title=\"annotation in typeannos\">@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseA.html"
+                + "\" title=\"annotation in typeannos\">@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseB.html"
+                + "\" title=\"annotation in typeannos\">@RepTypeUseB</a> <a href=\"../typeannos/RepTypeUseB.html"
+                + "\" title=\"annotation in typeannos\">@RepTypeUseB</a> T&nbsp;t)</code>",
+
+                "<code>(package private) java.lang.String</code></td>\n<td class=\"colLast\"><code>"
+                + "<span class=\"memberNameLink\"><a href=\"../typeannos/RepeatingOnTypeParametersBoundsTypeArgumentsOnMethod.html#"
+                + "test--\">test</a></span>()</code>",
+
+                "java.lang.String&nbsp;test(<a href=\"../typeannos/RepTypeUseA.html\" "
+                + "title=\"annotation in typeannos\">@RepTypeUseA</a> <a href="
+                + "\"../typeannos/RepTypeUseA.html\" title=\"annotation in typeannos\">"
+                + "@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseB.html\" title="
+                + "\"annotation in typeannos\">@RepTypeUseB</a> <a href=\"../typeannos/RepTypeUseB.html\" "
+                + "title=\"annotation in typeannos\">@RepTypeUseB</a>&nbsp;"
+                + "RepeatingOnTypeParametersBoundsTypeArgumentsOnMethod&lt;<a href="
+                + "\"../typeannos/RepTypeUseA.html\" title=\"annotation in typeannos\">"
+                + "@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseA.html\" title="
+                + "\"annotation in typeannos\">@RepTypeUseA</a> <a href=\"../typeannos/RepTypeUseB.html"
+                + "\" title=\"annotation in typeannos\">@RepTypeUseB</a> <a href=\"../typeannos/RepTypeUseB.html\" "
+                + "title=\"annotation in typeannos\">@RepTypeUseB</a> T&gt;&nbsp;this)");
+
+        checkOutput("typeannos/RepeatingOnVoidMethodDeclaration.html", true,
+                "<a href=\"../typeannos/RepMethodA.html\" title=\"annotation in typeannos\">"
+                + "@RepMethodA</a> <a href=\"../typeannos/RepMethodA.html\" title="
+                + "\"annotation in typeannos\">@RepMethodA</a>\n<a href=\"../typeannos/RepMethodB.html"
+                + "\" title=\"annotation in typeannos\">@RepMethodB</a> <a href="
+                + "\"../typeannos/RepMethodB.html\" title=\"annotation in typeannos\">"
+                + "@RepMethodB</a>\nvoid&nbsp;test()");
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testTypeAnnotations/typeannos/RepeatedAnnotations.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,346 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * 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 RepeatingA PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package typeannos;
+
+import java.lang.annotation.*;
+import static java.lang.annotation.ElementType.*;
+
+/*
+ * This class is partially replicated from test/tools/javac/annotations/typeAnnotations/classfile/CombinationsTargetTest1.java; CombinationsTargetTest2.java; CombinationsTargetTest3.java
+ */
+@RepTypeA @RepTypeA @RepTypeB @RepTypeB class RepeatingAtClassLevel {
+}
+
+@RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB class RepeatingAtClassLevel2 {
+}
+
+@RepAllContextsA @RepAllContextsA @RepAllContextsB @RepAllContextsB class RepeatingAtClassLevel3 {
+}
+
+class RepeatingOnConstructor {
+
+    @RepConstructorA @RepConstructorA @RepConstructorB @RepConstructorB
+    RepeatingOnConstructor() {
+    }
+
+    @RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB RepeatingOnConstructor(int i) {
+    }
+
+    @RepConstructorA @RepConstructorA @RepConstructorB @RepConstructorB
+    @RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB RepeatingOnConstructor(int i, int j) {
+    }
+
+    @RepAllContextsA @RepAllContextsA @RepAllContextsB @RepAllContextsB RepeatingOnConstructor(int i, int j, int k) {
+    }
+
+    RepeatingOnConstructor(@RepParameterA @RepParameterA @RepParameterB @RepParameterB String parameter, @RepParameterA @RepParameterA @RepParameterB @RepParameterB String @RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB ... vararg) {
+    }
+
+    class Inner {
+        Inner(@RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB RepeatingOnConstructor RepeatingOnConstructor.this, @RepParameterA @RepParameterA @RepParameterB @RepParameterB String parameter, @RepParameterA @RepParameterA @RepParameterB @RepParameterB String @RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB ... vararg) {
+        }
+    }
+}
+
+class RepeatingOnField {
+    @RepFieldA @RepFieldA @RepFieldB @RepFieldB
+    Integer i1;
+
+    @RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB Integer i2;
+
+    @RepFieldA @RepFieldA @RepFieldB @RepFieldB
+    @RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB Integer i3;
+
+    @RepAllContextsA @RepAllContextsA @RepAllContextsB @RepAllContextsB Integer i4;
+
+    String @RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB [] @RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB [] sa = null;
+}
+
+class RepeatingOnMethod {
+
+    @RepMethodA @RepMethodA @RepMethodB @RepMethodB
+    String test1() {
+        return null;
+    }
+
+    @RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB String test2() {
+        return null;
+    }
+
+    @RepMethodA @RepMethodA @RepMethodB @RepMethodB
+    @RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB String test3() {
+        return null;
+    }
+
+    @RepAllContextsA @RepAllContextsA @RepAllContextsB @RepAllContextsB String test4() {
+        return null;
+    }
+
+    String test5(@RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB RepeatingOnMethod this, @RepParameterA @RepParameterA @RepParameterB @RepParameterB String parameter, @RepParameterA @RepParameterA @RepParameterB @RepParameterB String @RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB ... vararg) {
+        return null;
+    }
+}
+
+class RepeatingOnTypeParametersBoundsTypeArgumentsOnClassDecl <@RepTypeParameterA @RepTypeParameterA @RepTypeParameterB @RepTypeParameterB T extends @RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB Object> {
+
+    <T> String genericMethod(T t) {
+        return null;
+    }
+}
+
+class RepeatingOnTypeParametersBoundsTypeArgumentsOnClassDecl2 <@RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB T extends @RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB Object> {
+
+    <T> String genericMethod(T t) {
+        return null;
+    }
+}
+
+class RepeatingOnTypeParametersBoundsTypeArgumentsOnMethod <T extends Object> {
+
+    String test(@RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB RepeatingOnTypeParametersBoundsTypeArgumentsOnMethod<@RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB T> this) {
+        return null;
+    }
+
+    <@RepTypeParameterA @RepTypeParameterA @RepTypeParameterB @RepTypeParameterB T> String genericMethod(@RepParameterA @RepParameterA @RepParameterB @RepParameterB T t) {
+        return null;
+    }
+
+    <@RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB T> String genericMethod2(@RepTypeUseA @RepTypeUseA @RepTypeUseB @RepTypeUseB T t) {
+        return null;
+    }
+}
+
+class RepeatingOnVoidMethodDeclaration {
+
+    @RepMethodA @RepMethodA @RepMethodB @RepMethodB void test() {}
+}
+
+class RepeatingOnStaticMethodOfInterface {
+
+    interface I {
+        static @RepMethodA @RepMethodA @RepMethodB @RepMethodB String m() {
+            return null;
+        }
+    }
+}
+
+//------------------------------------------------------------------------------
+@Target({TYPE})
+@Repeatable(ContTypeA.class)
+@Documented
+@interface RepTypeA { }
+
+@Target({TYPE})
+@Documented
+@interface ContTypeA { RepTypeA[] value(); }
+
+@Target({TYPE})
+@Repeatable(ContTypeB.class)
+@Documented
+@interface RepTypeB { }
+
+@Target({TYPE})
+@Documented
+@interface ContTypeB { RepTypeB[] value(); }
+
+//------------------------------------------------------------------------------
+@Target({CONSTRUCTOR})
+@Repeatable(ContConstructorA.class)
+@Documented
+@interface RepConstructorA { }
+
+@Target({CONSTRUCTOR})
+@Documented
+@interface ContConstructorA { RepConstructorA[] value(); }
+
+@Target({CONSTRUCTOR})
+@Repeatable(ContConstructorB.class )
+@Documented
+@interface RepConstructorB { }
+
+@Target({CONSTRUCTOR})
+@Documented
+@interface ContConstructorB { RepConstructorB[] value(); }
+
+//------------------------------------------------------------------------------
+@Target({METHOD})
+@Repeatable(ContMethodA.class)
+@Documented
+@interface RepMethodA {}
+
+@Target({METHOD})
+@Documented
+@interface ContMethodA {
+    RepMethodA[] value();
+}
+
+@Target({METHOD})
+@Repeatable(ContMethodB.class)
+@Documented
+@interface RepMethodB {}
+
+@Target({METHOD})
+@Documented
+@interface ContMethodB {
+    RepMethodB[] value();
+}
+
+//------------------------------------------------------------------------------
+@Target({FIELD})
+@Repeatable(ContFieldA.class)
+@Documented
+@interface RepFieldA {}
+
+@Target({FIELD})
+@Documented
+@interface ContFieldA {
+    RepFieldA[] value();
+}
+
+@Target({FIELD})
+@Repeatable(ContFieldB.class)
+@Documented
+@interface RepFieldB {}
+
+@Target({FIELD})
+@Documented
+@interface ContFieldB {
+    RepFieldB[] value();
+}
+
+//------------------------------------------------------------------------------
+@Target({TYPE_USE})
+@Repeatable(ContTypeUseA.class)
+@Documented
+@interface RepTypeUseA {}
+
+@Target({TYPE_USE})
+@Documented
+@interface ContTypeUseA {
+    RepTypeUseA[] value();
+}
+
+@Target({TYPE_USE})
+@Repeatable(ContTypeUseB.class)
+@Documented
+@interface RepTypeUseB {}
+
+@Target({TYPE_USE})
+@Documented
+@interface ContTypeUseB {
+    RepTypeUseB[] value();
+}
+
+//------------------------------------------------------------------------------
+@Target({TYPE_PARAMETER})
+@Repeatable(ContTypeParameterA.class)
+@Documented
+@interface RepTypeParameterA {}
+
+@Target({TYPE_PARAMETER})
+@Documented
+@interface ContTypeParameterA {
+    RepTypeParameterA[] value();
+}
+
+@Target({TYPE_PARAMETER})
+@Repeatable(ContTypeParameterB.class)
+@Documented
+@interface RepTypeParameterB {}
+
+@Target({TYPE_PARAMETER})
+@Documented
+@interface ContTypeParameterB {
+    RepTypeParameterB[] value();
+}
+
+//------------------------------------------------------------------------------
+@Target({PARAMETER})
+@Repeatable(ContParameterA.class)
+@Documented
+@interface RepParameterA {}
+
+@Target({PARAMETER})
+@Documented
+@interface ContParameterA {
+    RepParameterA[] value();
+}
+
+@Target({PARAMETER})
+@Repeatable(ContParameterB.class)
+@Documented
+@interface RepParameterB {}
+
+@Target({PARAMETER})
+@Documented
+@interface ContParameterB {
+    RepParameterB[] value();
+}
+
+
+//------------------------------------------------------------------------------
+@Target({PACKAGE})
+@Repeatable(ContPackageA.class)
+@Documented
+@interface RepPackageA {}
+
+@Target({PACKAGE})
+@Documented
+@interface ContPackageA {
+    RepPackageA[] value();
+}
+
+@Target({PACKAGE})
+@Repeatable(ContPackageB.class)
+@Documented
+@interface RepPackageB {}
+
+@Target({PACKAGE})
+@Documented
+@interface ContPackageB {
+    RepPackageB[] value();
+}
+
+//------------------------------------------------------------------------------
+@Target({TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE, ANNOTATION_TYPE, PACKAGE, TYPE_PARAMETER, TYPE_USE})
+@Repeatable(ContAllContextsA.class)
+@Documented
+@interface RepAllContextsA {}
+
+@Target({TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE, ANNOTATION_TYPE, PACKAGE, TYPE_PARAMETER, TYPE_USE})
+@Documented
+@interface ContAllContextsA {
+    RepAllContextsA[] value();
+}
+
+@Target({TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE, ANNOTATION_TYPE, PACKAGE, TYPE_PARAMETER, TYPE_USE})
+@Repeatable(ContAllContextsB.class)
+@Documented
+@interface RepAllContextsB {}
+
+@Target({TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE, ANNOTATION_TYPE, PACKAGE, TYPE_PARAMETER, TYPE_USE})
+@Documented
+@interface ContAllContextsB {
+    RepAllContextsB[] value();
+}
--- a/langtools/test/jdk/javadoc/doclet/testUseOption/TestUseOption.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testUseOption/TestUseOption.java	Mon Mar 28 08:41:54 2016 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 4496290 4985072 7006178 7068595 8016328 8050031 8048351 8081854
+ * @bug 4496290 4985072 7006178 7068595 8016328 8050031 8048351 8081854 8071982
  * @summary A simple test to ensure class-use files are correct.
  * @author jamieh
  * @library ../lib
@@ -121,6 +121,21 @@
             "<a href=\"../../pkg1/C10.html#withTypeParametersOfType-java.lang.Class-\">" +
             "withTypeParametersOfType</a>"
         );
+        checkOutput("pkg1/class-use/UsedInterface.html", true,
+            "Subinterfaces of <a href=\"../../pkg1/UsedInterface.html\" title=\"interface in pkg1\">"
+            + "UsedInterface</a> in <a href=\"../../pkg1/package-summary.html\">pkg1",
+            "<td class=\"colFirst\"><code>interface&nbsp;</code></td>\n<td class=\"colLast\">"
+            + "<code><span class=\"memberNameLink\"><a href=\"../../pkg1/SubInterface.html\" "
+            + "title=\"interface in pkg1\">SubInterface</a>&lt;T&gt;</span></code>&nbsp;</td>"
+        );
+        checkOutput("pkg1/class-use/UsedThrowable.html", true,
+            "Methods in <a href=\"../../pkg1/package-summary.html\">pkg1</a> that throw "
+            + "<a href=\"../../pkg1/UsedThrowable.html\" title=\"class in pkg1\">UsedThrowable</a>",
+            "<td class=\"colFirst\"><code>void</code></td>\n<td class=\"colLast\"><span class="
+            + "\"typeNameLabel\">C1.</span><code><span class=\"memberNameLink\">"
+            + "<a href=\"../../pkg1/C1.html#methodInC1ThrowsThrowable--\">methodInC1ThrowsThrowable"
+            + "</a></span>()</code>&nbsp;</td>"
+        );
     }
 
     @Test
@@ -128,7 +143,7 @@
         javadoc("-d", "out-2",
                 "-sourcepath", testSrc,
                 "-use",
-                testSrc("C.java"), testSrc("UsedInC.java"));
+                testSrc("C.java"), testSrc("UsedInC.java"), "pkg3");
         checkExit(Exit.OK);
 
         checkOutput("class-use/UsedInC.html", true,
@@ -140,7 +155,9 @@
         );
         checkOutput("package-use.html", true,
                 "<td class=\"colOne\">"
-                + "<a href=\"class-use/UsedInC.html#unnamed.package\">UsedInC</a>&nbsp;</td>"
+                + "<a href=\"class-use/UsedInC.html#unnamed.package\">UsedInC</a>&nbsp;</td>",
+                "<td class=\"colFirst\"><a href=\"#-Unnamed-\">&lt;Unnamed&gt;</a></td>\n"
+                + "<td class=\"colLast\">&nbsp;</td>"
         );
     }
 
--- a/langtools/test/jdk/javadoc/doclet/testUseOption/pkg1/C1.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testUseOption/pkg1/C1.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -47,10 +47,13 @@
         return null;
     }
 
+    public void methodInC1ThrowsThrowable() throws UsedThrowable {
+    }
+
     /*
      * this must not appear anywhere.
      */
     UsedClass methodInC1Protected(List<UsedClass> p){
-        return p;
+        return p.get(0);
     }
 }
--- a/langtools/test/jdk/javadoc/doclet/testUseOption/pkg1/C9.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/javadoc/doclet/testUseOption/pkg1/C9.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,5 +28,10 @@
  *
  */
 public class C9 implements UsedInterface, UsedInterfaceA {
+    @Override
     public void doNothing(){}
+
+    @Override
+    public void doNothingA() {
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testUseOption/pkg1/SubInterface.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * An interface
+ *
+ */
+
+package pkg1;
+
+public interface SubInterface<T> extends UsedInterface {
+
+    /**
+     * Does nothing
+     */
+    void doNothingS();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testUseOption/pkg1/UsedThrowable.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg1;
+
+public class UsedThrowable extends Throwable {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testUseOption/pkg3/C.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg3;
+
+public class C {}
--- a/langtools/test/jdk/javadoc/tool/VerifyLocale.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/javadoc/tool/VerifyLocale.java	Mon Mar 28 08:41:54 2016 -0700
@@ -26,6 +26,7 @@
  * @bug 8035473
  * @summary Verify that init method works correctly.
  * @modules jdk.javadoc/jdk.javadoc.internal.tool
+ * @ignore 8149565
  */
 
 import java.util.Collections;
@@ -40,6 +41,10 @@
 import jdk.javadoc.doclet.DocletEnvironment;
 
 public class VerifyLocale implements Doclet {
+    static String language;
+    static String country;
+    static String variant;
+
     Locale locale;
     Reporter reporter;
 
@@ -48,20 +53,29 @@
             new java.io.File(System.getProperty("test.src", "."),
                              "VerifyLocale.java");
 
-        String[] argarray = {
-            // jumble the options in some weird order
-            "-doclet", "VerifyLocale",
-            "-locale", "ja",
-            "-docletpath", System.getProperty("test.classes", "."),
-            thisFile
-        };
-        if (jdk.javadoc.internal.tool.Main.execute(argarray) != 0)
-            throw new Error("Javadoc encountered warnings or errors.");
+        for (Locale loc : Locale.getAvailableLocales()) {
+            language = loc.getLanguage();
+            country = loc.getCountry();
+            variant = loc.getVariant();
+            if (!language.equals("")) {
+                String[] command_line = {
+                    // jumble the options in some weird order
+                    "-doclet", "VerifyLocale",
+                    "-locale", language + (country.equals("") ? "" : ("_" + country + (variant.equals("") ? "" : "_" + variant))),
+                    "-docletpath", System.getProperty("test.classes", "."),
+                    thisFile
+                };
+                if (jdk.javadoc.internal.tool.Main.execute(command_line) != 0)
+                    throw new Error("Javadoc encountered warnings or errors.");
+            }
+        }
     }
 
     public boolean run(DocletEnvironment root) {
         reporter.print(Kind.NOTE, "just a test: Locale is: " + locale.getDisplayName());
-        return locale.getDisplayName(Locale.ENGLISH).contains("Japan");
+        return language.equals(locale.getLanguage())
+               && country.equals(locale.getCountry())
+               && variant.equals(locale.getVariant());
     }
 
     @Override
--- a/langtools/test/jdk/jshell/ReplToolTesting.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/jshell/ReplToolTesting.java	Mon Mar 28 08:41:54 2016 -0700
@@ -33,6 +33,9 @@
 import java.util.function.Consumer;
 import java.util.function.Function;
 import java.util.function.Predicate;
+import java.util.prefs.AbstractPreferences;
+import java.util.prefs.BackingStoreException;
+import java.util.prefs.Preferences;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
@@ -41,6 +44,8 @@
 import jdk.internal.jshell.tool.JShellTool;
 import jdk.jshell.SourceCodeAnalysis.Suggestion;
 
+import org.testng.annotations.BeforeMethod;
+
 import static java.util.stream.Collectors.toList;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertNotNull;
@@ -83,6 +88,7 @@
     private Map<String, ClassInfo> classes;
     private Map<String, ImportInfo> imports;
     private boolean isDefaultStartUp = true;
+    private Preferences prefs;
 
     public JShellTool repl = null;
 
@@ -219,6 +225,11 @@
         }
     }
 
+    @BeforeMethod
+    public void setUp() {
+        prefs = new MemoryPreferences();
+    }
+
     public void testRaw(String[] args, ReplTest... tests) {
         cmdin = new WaitingTestingInputStream();
         cmdout = new ByteArrayOutputStream();
@@ -234,7 +245,8 @@
                 new PrintStream(console),
                 userin,
                 new PrintStream(userout),
-                new PrintStream(usererr));
+                new PrintStream(usererr),
+                prefs);
         repl.testPrompt = true;
         try {
             repl.start(args);
@@ -362,8 +374,8 @@
         }
     }
 
-    private void dropKey(boolean after, String cmd, String name, Map<String, ? extends MemberInfo> map) {
-        assertCommand(after, cmd, "");
+    private void dropKey(boolean after, String cmd, String name, Map<String, ? extends MemberInfo> map, String output) {
+        assertCommand(after, cmd, output);
         if (after) {
             map.remove(name);
             for (int i = 0; i < keys.size(); ++i) {
@@ -377,20 +389,20 @@
         }
     }
 
-    public void dropVariable(boolean after, String cmd, String name) {
-        dropKey(after, cmd, name, variables);
+    public void dropVariable(boolean after, String cmd, String name, String output) {
+        dropKey(after, cmd, name, variables, output);
     }
 
-    public void dropMethod(boolean after, String cmd, String name) {
-        dropKey(after, cmd, name, methods);
+    public void dropMethod(boolean after, String cmd, String name, String output) {
+        dropKey(after, cmd, name, methods, output);
     }
 
-    public void dropClass(boolean after, String cmd, String name) {
-        dropKey(after, cmd, name, classes);
+    public void dropClass(boolean after, String cmd, String name, String output) {
+        dropKey(after, cmd, name, classes, output);
     }
 
-    public void dropImport(boolean after, String cmd, String name) {
-        dropKey(after, cmd, name, imports);
+    public void dropImport(boolean after, String cmd, String name, String output) {
+        dropKey(after, cmd, name, imports, output);
     }
 
     public void assertCommand(boolean after, String cmd, String out) {
@@ -424,10 +436,10 @@
             }
             setCommandInput(cmd + "\n");
         } else {
-            assertOutput(getCommandOutput(), out, "command");
-            assertOutput(getCommandErrorOutput(), err, "command error");
-            assertOutput(getUserOutput(), print, "user");
-            assertOutput(getUserErrorOutput(), usererr, "user error");
+            assertOutput(getCommandOutput(), out, "command output: " + cmd);
+            assertOutput(getCommandErrorOutput(), err, "command error: " + cmd);
+            assertOutput(getUserOutput(), print, "user output: " + cmd);
+            assertOutput(getUserErrorOutput(), usererr, "user error: " + cmd);
         }
     }
 
@@ -447,7 +459,7 @@
 
     private List<String> computeCompletions(String code, boolean isSmart) {
         JShellTool js = this.repl != null ? this.repl
-                                      : new JShellTool(null, null, null, null, null, null, null);
+                                      : new JShellTool(null, null, null, null, null, null, null, prefs);
         int cursor =  code.indexOf('|');
         code = code.replace("|", "");
         assertTrue(cursor > -1, "'|' not found: " + code);
@@ -464,9 +476,9 @@
         return (output) -> assertTrue(output.startsWith(prefix), "Output: \'" + output + "' does not start with: " + prefix);
     }
 
-    public void assertOutput(String got, String expected, String kind) {
+    public void assertOutput(String got, String expected, String display) {
         if (expected != null) {
-            assertEquals(got, expected, "Kind: " + kind + ".\n");
+            assertEquals(got, expected, display + ".\n");
         }
     }
 
@@ -762,4 +774,62 @@
             }
         }
     }
+
+    public static final class MemoryPreferences extends AbstractPreferences {
+
+        private final Map<String, String> values = new HashMap<>();
+        private final Map<String, MemoryPreferences> nodes = new HashMap<>();
+
+        public MemoryPreferences() {
+            this(null, "");
+        }
+
+        public MemoryPreferences(MemoryPreferences parent, String name) {
+            super(parent, name);
+        }
+
+        @Override
+        protected void putSpi(String key, String value) {
+            values.put(key, value);
+        }
+
+        @Override
+        protected String getSpi(String key) {
+            return values.get(key);
+        }
+
+        @Override
+        protected void removeSpi(String key) {
+            values.remove(key);
+        }
+
+        @Override
+        protected void removeNodeSpi() throws BackingStoreException {
+            ((MemoryPreferences) parent()).nodes.remove(name());
+        }
+
+        @Override
+        protected String[] keysSpi() throws BackingStoreException {
+            return values.keySet().toArray(new String[0]);
+        }
+
+        @Override
+        protected String[] childrenNamesSpi() throws BackingStoreException {
+            return nodes.keySet().toArray(new String[0]);
+        }
+
+        @Override
+        protected AbstractPreferences childSpi(String name) {
+            return nodes.computeIfAbsent(name, n -> new MemoryPreferences(this, name));
+        }
+
+        @Override
+        protected void syncSpi() throws BackingStoreException {
+        }
+
+        @Override
+        protected void flushSpi() throws BackingStoreException {
+        }
+
+    }
 }
--- a/langtools/test/jdk/jshell/StartOptionTest.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/jshell/StartOptionTest.java	Mon Mar 28 08:41:54 2016 -0700
@@ -54,7 +54,8 @@
     private ByteArrayOutputStream err;
 
     private JShellTool getShellTool() {
-        return new JShellTool(null, new PrintStream(out), new PrintStream(err), null, null, null, null);
+        return new JShellTool(null, new PrintStream(out), new PrintStream(err), null, null, null,
+                              null, new ReplToolTesting.MemoryPreferences());
     }
 
     private String getOutput() {
--- a/langtools/test/jdk/jshell/ToolBasicTest.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/jshell/ToolBasicTest.java	Mon Mar 28 08:41:54 2016 -0700
@@ -755,13 +755,13 @@
     public void testDrop() {
         test(false, new String[]{"-nostartup"},
                 a -> assertVariable(a, "int", "a"),
-                a -> dropVariable(a, "/drop 1", "int a = 0"),
+                a -> dropVariable(a, "/drop 1", "int a = 0", "|  Dropped variable a\n"),
                 a -> assertMethod(a, "int b() { return 0; }", "()I", "b"),
-                a -> dropMethod(a, "/drop 2", "b ()I"),
+                a -> dropMethod(a, "/drop 2", "b ()I", "|  Dropped method b()\n"),
                 a -> assertClass(a, "class A {}", "class", "A"),
-                a -> dropClass(a, "/drop 3", "class A"),
+                a -> dropClass(a, "/drop 3", "class A", "|  Dropped class A\n"),
                 a -> assertImport(a, "import java.util.stream.*;", "", "java.util.stream.*"),
-                a -> dropImport(a, "/drop 4", "import java.util.stream.*"),
+                a -> dropImport(a, "/drop 4", "import java.util.stream.*", ""),
                 a -> assertCommandCheckOutput(a, "/vars", assertVariables()),
                 a -> assertCommandCheckOutput(a, "/methods", assertMethods()),
                 a -> assertCommandCheckOutput(a, "/classes", assertClasses()),
@@ -769,11 +769,11 @@
         );
         test(false, new String[]{"-nostartup"},
                 a -> assertVariable(a, "int", "a"),
-                a -> dropVariable(a, "/drop a", "int a = 0"),
+                a -> dropVariable(a, "/drop a", "int a = 0", "|  Dropped variable a\n"),
                 a -> assertMethod(a, "int b() { return 0; }", "()I", "b"),
-                a -> dropMethod(a, "/drop b", "b ()I"),
+                a -> dropMethod(a, "/drop b", "b ()I", "|  Dropped method b()\n"),
                 a -> assertClass(a, "class A {}", "class", "A"),
-                a -> dropClass(a, "/drop A", "class A"),
+                a -> dropClass(a, "/drop A", "class A", "|  Dropped class A\n"),
                 a -> assertCommandCheckOutput(a, "/vars", assertVariables()),
                 a -> assertCommandCheckOutput(a, "/methods", assertMethods()),
                 a -> assertCommandCheckOutput(a, "/classes", assertClasses()),
--- a/langtools/test/jdk/jshell/ToolFormatTest.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/jshell/ToolFormatTest.java	Mon Mar 28 08:41:54 2016 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8148316 8148317
+ * @bug 8148316 8148317 8151755 8152246
  * @summary Tests for output customization
  * @library /tools/lib
  * @modules jdk.compiler/com.sun.tools.javac.api
@@ -33,6 +33,8 @@
  * @build KullaTesting TestingInputStream ToolBox Compiler
  * @run testng ToolFormatTest
  */
+import java.util.ArrayList;
+import java.util.List;
 import org.testng.annotations.Test;
 
 @Test
@@ -42,28 +44,34 @@
         try {
             test(
                     (a) -> assertCommandOutputStartsWith(a, "/set newmode test command", "|  Created new feedback mode: test"),
-                    (a) -> assertCommand(a, "/set field test pre '$ '", ""),
-                    (a) -> assertCommand(a, "/set field test post ''", ""),
-                    (a) -> assertCommand(a, "/set field test action 'ADD ' added-primary", ""),
-                    (a) -> assertCommand(a, "/set field test action 'MOD ' modified-primary", ""),
-                    (a) -> assertCommand(a, "/set field test action 'REP ' replaced-primary", ""),
-                    (a) -> assertCommand(a, "/set field test action 'UP-ADD ' added-update", ""),
-                    (a) -> assertCommand(a, "/set field test action 'UP-MOD ' modified-update", ""),
-                    (a) -> assertCommand(a, "/set field test action 'UP-REP ' replaced-update", ""),
-                    (a) -> assertCommand(a, "/set field test resolve 'OK' ok-*", ""),
-                    (a) -> assertCommand(a, "/set field test resolve 'DEF' defined-*", ""),
-                    (a) -> assertCommand(a, "/set field test resolve 'NODEF' notdefined-*", ""),
-                    (a) -> assertCommand(a, "/set field test name ':%s ' ", ""),
-                    (a) -> assertCommand(a, "/set field test type '[%s]' ", ""),
-                    (a) -> assertCommand(a, "/set field test result '=%s ' ", ""),
-                    (a) -> assertCommand(a, "/set format test '{pre}{action}{type}{name}{result}{resolve}' *-*-*", ""),
-                    (a) -> assertCommand(a, "/set format test '{pre}HI this is enum' enum", ""),
+                    (a) -> assertCommand(a, "/set format test pre '$ '", ""),
+                    (a) -> assertCommand(a, "/set format test post ''", ""),
+                    (a) -> assertCommand(a, "/set format test act 'ADD' added", ""),
+                    (a) -> assertCommand(a, "/set format test act 'MOD' modified", ""),
+                    (a) -> assertCommand(a, "/set format test act 'REP' replaced", ""),
+                    (a) -> assertCommand(a, "/set format test act 'OVR' overwrote", ""),
+                    (a) -> assertCommand(a, "/set format test act 'USE' used", ""),
+                    (a) -> assertCommand(a, "/set format test act 'DRP' dropped", ""),
+                    (a) -> assertCommand(a, "/set format test up 'UP-' update", ""),
+                    (a) -> assertCommand(a, "/set format test action '{up}{act} '", ""),
+                    (a) -> assertCommand(a, "/set format test resolve 'OK' ok", ""),
+                    (a) -> assertCommand(a, "/set format test resolve 'DEF' defined", ""),
+                    (a) -> assertCommand(a, "/set format test resolve 'NODEF' notdefined", ""),
+                    (a) -> assertCommand(a, "/set format test fname ':{name} ' ", ""),
+                    (a) -> assertCommand(a, "/set format test ftype '[{type}]' method,expression", ""),
+                    (a) -> assertCommand(a, "/set format test result '={value} ' expression", ""),
+                    (a) -> assertCommand(a, "/set format test display '{pre}{action}{ftype}{fname}{result}{resolve}'", ""),
+                    (a) -> assertCommand(a, "/set format test display '{pre}HI this is enum' enum", ""),
                     (a) -> assertCommand(a, "/set feedback test", "$ Feedback mode: test"),
                     (a) -> assertCommand(a, "class D {}", "$ ADD :D OK"),
                     (a) -> assertCommand(a, "void m() {}", "$ ADD []:m OK"),
                     (a) -> assertCommand(a, "interface EX extends EEX {}", "$ ADD :EX NODEF"),
                     (a) -> assertCommand(a, "56", "$ ADD [int]:$4 =56 OK"),
-                    (a) -> assertCommand(a, "class D { int hh; }", "$ REP :D OK$ OVERWROTE-UPDATE:D OK"),
+                    (a) -> assertCommand(a, "class D { int hh; }", "$ REP :D OK$ UP-OVR :D OK"),
+                    (a) -> assertCommand(a, "enum E {A,B}", "$ HI this is enum"),
+                    (a) -> assertCommand(a, "int z() { return f(); }", "$ ADD []:z DEF"),
+                    (a) -> assertCommand(a, "z()", "$ UP-USE []:z DEF"),
+                    (a) -> assertCommand(a, "/drop z", "$ DRP []:z OK"),
                     (a) -> assertCommandOutputStartsWith(a, "/set feedback normal", "|  Feedback mode: normal")
             );
         } finally {
@@ -72,7 +80,82 @@
         }
     }
 
-    public void testNewModeQuiet() {
+    public void testSetFormatSelector() {
+        List<ReplTest> tests = new ArrayList<>();
+        tests.add((a) -> assertCommandOutputStartsWith(a, "/set newmode ate quiet",
+                            "|  Created new feedback mode: ate"));
+        tests.add((a) -> assertCommand(a, "/set feedback ate", ""));
+        StringBuilder sb = new StringBuilder();
+        class KindList {
+            final String[] values;
+            final int matchIndex;
+            int current;
+            boolean match;
+            KindList(String[] values, int matchIndex) {
+                this.values = values;
+                this.matchIndex = matchIndex;
+                this.current = 1 << values.length;
+            }
+            boolean next() {
+                if (current <= 0) {
+                    return false;
+                }
+                --current;
+                return true;
+            }
+            boolean append(boolean ahead) {
+                boolean any = false;
+                match = false;
+                for (int i = values.length - 1; i >= 0 ; --i) {
+                    if ((current & (1 << i)) != 0) {
+                        match |= i == matchIndex;
+                        if (any) {
+                            sb.append(",");
+                        } else {
+                            if (ahead) {
+                                sb.append("-");
+                            }
+                        }
+                        sb.append(values[i]);
+                        any = true;
+                    }
+                }
+                match |= !any;
+                return ahead || any;
+            }
+        }
+        KindList klcase = new KindList(new String[] {"class", "method", "expression", "vardecl"}, 2);
+        while (klcase.next()) {
+            KindList klact  = new KindList(new String[] {"added", "modified", "replaced"}, 0);
+            while (klact.next()) {
+                KindList klwhen = new KindList(new String[] {"update", "primary"}, 1);
+                while (klwhen.next()) {
+                    sb.setLength(0);
+                    klwhen.append(
+                        klact.append(
+                            klcase.append(false)));
+                    boolean match = klcase.match && klact.match && klwhen.match;
+                    String select = sb.toString();
+                    String yes = "+++" + select + "+++";
+                    String no  = "---" + select + "---";
+                    String expect = match? yes : no;
+                    tests.add((a) -> assertCommand(a, "/set format ate display '" + no  + "'", ""));
+                    tests.add((a) -> assertCommand(a, "/set format ate display '" + yes + "' " + select, ""));
+                    tests.add((a) -> assertCommand(a, "\"" + select + "\"", expect));
+                }
+            }
+        }
+        tests.add((a) -> assertCommandOutputStartsWith(a, "/set feedback normal", "|  Feedback mode: normal"));
+
+        try {
+            test(tests.toArray(new ReplTest[tests.size()]));
+        } finally {
+            assertCommandCheckOutput(false, "/set feedback normal", s -> {
+            });
+        }
+    }
+
+    public void testSetNewModeQuiet() {
         try {
             test(
                     (a) -> assertCommandOutputStartsWith(a, "/set newmode nmq quiet normal", "|  Created new feedback mode: nmq"),
@@ -82,7 +165,8 @@
                     (a) -> assertCommand(a, "/set newmode nmc command normal", ""),
                     (a) -> assertCommandOutputStartsWith(a, "/set feedback nmc", "|  Feedback mode: nmc"),
                     (a) -> assertCommandOutputStartsWith(a, "/set newmode nm", "|  Created new feedback mode: nm"),
-                    (a) -> assertCommandOutputStartsWith(a, "/set feedback nm", "|  Feedback mode: nm")
+                    (a) -> assertCommandOutputStartsWith(a, "/set feedback nm", "|  Feedback mode: nm"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set feedback normal", "|  Feedback mode: normal")
             );
         } finally {
             assertCommandCheckOutput(false, "/set feedback normal", s -> {
@@ -93,38 +177,75 @@
     public void testSetError() {
         try {
             test(
-                    (a) -> assertCommandOutputStartsWith(a, "/set newmode te command normal", "|  Created new feedback mode: te"),
-                    (a) -> assertCommand(a, "/set field te errorpre 'ERROR: '", ""),
-                    (a) -> assertCommandOutputStartsWith(a, "/set feedback te", ""),
-                    (a) -> assertCommandCheckOutput(a, "/set ", assertStartsWith("ERROR: The /set command requires arguments")),
-                    (a) -> assertCommandCheckOutput(a, "/set xyz", assertStartsWith("ERROR: Not a valid argument to /set")),
-                    (a) -> assertCommandCheckOutput(a, "/set f", assertStartsWith("ERROR: Ambiguous argument to /set")),
-                    (a) -> assertCommandCheckOutput(a, "/set feedback", assertStartsWith("ERROR: Expected a feedback mode")),
-                    (a) -> assertCommandCheckOutput(a, "/set feedback xyz", assertStartsWith("ERROR: Does not match any current feedback mode")),
-                    (a) -> assertCommandCheckOutput(a, "/set format", assertStartsWith("ERROR: Expected a feedback mode")),
-                    (a) -> assertCommandCheckOutput(a, "/set format xyz", assertStartsWith("ERROR: Does not match any current feedback mode")),
-                    (a) -> assertCommandCheckOutput(a, "/set format te", assertStartsWith("ERROR: Expected format missing")),
-                    (a) -> assertCommandCheckOutput(a, "/set format te aaa", assertStartsWith("ERROR: Format 'aaa' must be quoted")),
-                    (a) -> assertCommandCheckOutput(a, "/set format te 'aaa'", assertStartsWith("ERROR: At least one selector required")),
-                    (a) -> assertCommandCheckOutput(a, "/set format te 'aaa' frog", assertStartsWith("ERROR: Not a valid case")),
-                    (a) -> assertCommandCheckOutput(a, "/set format te 'aaa' import-frog", assertStartsWith("ERROR: Not a valid action")),
-                    (a) -> assertCommandCheckOutput(a, "/set newmode", assertStartsWith("ERROR: Expected new feedback mode")),
-                    (a) -> assertCommandCheckOutput(a, "/set newmode te", assertStartsWith("ERROR: Expected a new feedback mode name")),
-                    (a) -> assertCommandCheckOutput(a, "/set newmode x xyz", assertStartsWith("ERROR: Specify either 'command' or 'quiet'")),
-                    (a) -> assertCommandCheckOutput(a, "/set newmode x quiet y", assertStartsWith("ERROR: Does not match any current feedback mode")),
-                    (a) -> assertCommandCheckOutput(a, "/set prompt", assertStartsWith("ERROR: Expected a feedback mode")),
-                    (a) -> assertCommandCheckOutput(a, "/set prompt te", assertStartsWith("ERROR: Expected format missing")),
-                    (a) -> assertCommandCheckOutput(a, "/set prompt te aaa xyz", assertStartsWith("ERROR: Format 'aaa' must be quoted")),
-                    (a) -> assertCommandCheckOutput(a, "/set prompt te 'aaa' xyz", assertStartsWith("ERROR: Format 'xyz' must be quoted")),
-                    (a) -> assertCommandCheckOutput(a, "/set prompt", assertStartsWith("ERROR: Expected a feedback mode")),
-                    (a) -> assertCommandCheckOutput(a, "/set prompt te", assertStartsWith("ERROR: Expected format missing")),
-                    (a) -> assertCommandCheckOutput(a, "/set prompt te aaa", assertStartsWith("ERROR: Format 'aaa' must be quoted")),
-                    (a) -> assertCommandCheckOutput(a, "/set prompt te 'aaa'", assertStartsWith("ERROR: Expected format missing")),
-                    (a) -> assertCommandCheckOutput(a, "/set field", assertStartsWith("ERROR: Expected a feedback mode")),
-                    (a) -> assertCommandCheckOutput(a, "/set field xyz", assertStartsWith("ERROR: Does not match any current feedback mode: xyz")),
-                    (a) -> assertCommandCheckOutput(a, "/set field te xyz", assertStartsWith("ERROR: Not a valid field: xyz, must be one of: when")),
-                    (a) -> assertCommandCheckOutput(a, "/set field te action", assertStartsWith("ERROR: Expected format missing")),
-                    (a) -> assertCommandCheckOutput(a, "/set field te action 'act'", assertStartsWith("ERROR: At least one selector required"))
+                    (a) -> assertCommandOutputStartsWith(a, "/set newmode tee command foo",
+                            "|  Does not match any current feedback mode: foo"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set newmode tee flurb",
+                            "|  Specify either 'command' or 'quiet'"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set newmode te2",
+                            "|  Created new feedback mode: te2"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set newmode te2 command",
+                            "|  Expected a new feedback mode name. te2 is a known feedback mode"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set newmode te command normal",
+                            "|  Created new feedback mode: te"),
+                    (a) -> assertCommand(a, "/set format te errorpre 'ERROR: '", ""),
+                    (a) -> assertCommandOutputStartsWith(a, "/set feedback te",
+                            ""),
+                    (a) -> assertCommandOutputStartsWith(a, "/set ",
+                            "ERROR: The /set command requires arguments"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set xyz",
+                            "ERROR: Not a valid argument to /set"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set f",
+                            "ERROR: Ambiguous argument to /set"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set feedback",
+                            "ERROR: Expected a feedback mode"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set feedback xyz",
+                            "ERROR: Does not match any current feedback mode"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set format",
+                            "ERROR: Expected a feedback mode"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set format xyz",
+                            "ERROR: Does not match any current feedback mode"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set format t",
+                            "ERROR: Matches more then one current feedback mode: t"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set format te",
+                            "ERROR: Expected field name missing"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set format te fld",
+                            "ERROR: Expected format missing"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set format te fld aaa",
+                            "ERROR: Format 'aaa' must be quoted"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set format te fld 'aaa' frog",
+                            "ERROR: Not a valid selector"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set format te fld 'aaa' import-frog",
+                            "ERROR: Not a valid selector"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set format te fld 'aaa' import-import",
+                            "ERROR: Selector kind in multiple sections of"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set format te fld 'aaa' import,added",
+                            "ERROR: Different selector kinds in same sections of"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set newmode",
+                            "ERROR: Expected new feedback mode"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set newmode te",
+                            "ERROR: Expected a new feedback mode name"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set newmode x xyz",
+                            "ERROR: Specify either 'command' or 'quiet'"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set newmode x quiet y",
+                            "ERROR: Does not match any current feedback mode"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set prompt",
+                            "ERROR: Expected a feedback mode"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set prompt te",
+                            "ERROR: Expected format missing"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set prompt te aaa xyz",
+                            "ERROR: Format 'aaa' must be quoted"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set prompt te 'aaa' xyz",
+                            "ERROR: Format 'xyz' must be quoted"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set prompt",
+                            "ERROR: Expected a feedback mode"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set prompt te",
+                            "ERROR: Expected format missing"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set prompt te aaa",
+                            "ERROR: Format 'aaa' must be quoted"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set prompt te 'aaa'",
+                            "ERROR: Expected format missing"),
+                    (a) -> assertCommandOutputStartsWith(a, "/set feedback normal",
+                            "|  Feedback mode: normal")
             );
         } finally {
             assertCommandCheckOutput(false, "/set feedback normal", s -> {
@@ -136,7 +257,7 @@
         try {
             test(
                     (a) -> assertCommandOutputContains(a, "/help /set", "command to launch"),
-                    (a) -> assertCommandOutputContains(a, "/help /set format", "vardecl"),
+                    (a) -> assertCommandOutputContains(a, "/help /set format", "display"),
                     (a) -> assertCommandOutputContains(a, "/hel /se for", "vardecl"),
                     (a) -> assertCommandOutputContains(a, "/help /set editor", "temporary file")
             );
@@ -150,7 +271,7 @@
         try {
             test(
                     (a) -> assertCommandOutputStartsWith(a, "/set newmode te command normal", "|  Created new feedback mode: te"),
-                    (a) -> assertCommand(a, "/set field te errorpre 'ERROR: '", ""),
+                    (a) -> assertCommand(a, "/set format te errorpre 'ERROR: '", ""),
                     (a) -> assertCommandOutputStartsWith(a, "/set feedback te", "|  Feedback mode: te"),
                     (a) -> assertCommandOutputContains(a, "/help /set xyz", "ERROR: Not a valid argument to /set: xyz"),
                     (a) -> assertCommandOutputContains(a, "/help /set f", "ERROR: Ambiguous argument to /set: f")
--- a/langtools/test/jdk/jshell/ToolReloadTest.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/jdk/jshell/ToolReloadTest.java	Mon Mar 28 08:41:54 2016 -0700
@@ -92,11 +92,11 @@
     public void testReloadDrop() {
         test(false, new String[]{"-nostartup"},
                 a -> assertVariable(a, "int", "a"),
-                a -> dropVariable(a, "/dr 1", "int a = 0"),
+                a -> dropVariable(a, "/dr 1", "int a = 0", "|  Dropped variable a\n"),
                 a -> assertMethod(a, "int b() { return 0; }", "()I", "b"),
-                a -> dropMethod(a, "/drop b", "b ()I"),
+                a -> dropMethod(a, "/drop b", "b ()I", "|  Dropped method b()\n"),
                 a -> assertClass(a, "class A {}", "class", "A"),
-                a -> dropClass(a, "/dr A", "class A"),
+                a -> dropClass(a, "/dr A", "class A", "|  Dropped class A\n"),
                 a -> assertCommand(a, "/reload",
                         "|  Restarting and restoring state.\n" +
                         "-: int a;\n" +
@@ -115,11 +115,11 @@
     public void testReloadQuiet() {
         test(false, new String[]{"-nostartup"},
                 a -> assertVariable(a, "int", "a"),
-                a -> dropVariable(a, "/dr 1", "int a = 0"),
+                a -> dropVariable(a, "/dr 1", "int a = 0", "|  Dropped variable a\n"),
                 a -> assertMethod(a, "int b() { return 0; }", "()I", "b"),
-                a -> dropMethod(a, "/drop b", "b ()I"),
+                a -> dropMethod(a, "/drop b", "b ()I", "|  Dropped method b()\n"),
                 a -> assertClass(a, "class A {}", "class", "A"),
-                a -> dropClass(a, "/dr A", "class A"),
+                a -> dropClass(a, "/dr A", "class A", "|  Dropped class A\n"),
                 a -> assertCommand(a, "/reload quiet",
                         "|  Restarting and restoring state.\n"),
                 a -> assertCommandCheckOutput(a, "/vars", assertVariables()),
--- a/langtools/test/tools/javac/completionDeps/DepsAndAnno.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/langtools/test/tools/javac/completionDeps/DepsAndAnno.java	Mon Mar 28 08:41:54 2016 -0700
@@ -26,6 +26,10 @@
  * @bug 8078600
  * @summary Make sure -XDcompletionDeps does not cause an infinite loop.
  * @library /tools/lib
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ *          jdk.compiler/com.sun.tools.javac.file
+ *          jdk.compiler/com.sun.tools.javac.main
+ *          jdk.jdeps/com.sun.tools.javap
  * @build ToolBox
  * @run main/othervm/timeout=10 DepsAndAnno
  */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/CantAssignToThis.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.cant.assign.val.to.this
+
+class CantAssignToThis {
+    void m() {
+        this = null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/8152411/T8152411.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8152411
+ * @summary Regression: nested unchecked call does not trigger erasure of return type
+ *
+ * @compile/fail/ref=T8152411.out -XDrawDiagnostics T8152411.java
+ */
+import java.util.List;
+
+class T8152411 {
+        <A2 extends A, A> A m(List<? super A2> a2) { return null; }
+        <B> B g(B b) { return null; }
+
+        void test() {
+                List<Integer> I = null;
+                String s = g(m(I));
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/8152411/T8152411.out	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,2 @@
+T8152411.java:16:29: compiler.err.prob.found.req: (compiler.misc.incompatible.upper.bounds: A2, java.lang.String,B,java.lang.Object,java.lang.Integer,A)
+1 error
--- a/make/Images.gmk	Thu Mar 24 02:04:14 2016 +0300
+++ b/make/Images.gmk	Mon Mar 28 08:41:54 2016 -0700
@@ -38,61 +38,23 @@
 
 ############################################################################
 
-MAIN_MODULES += java.se.ee java.smartcardio jdk.httpserver jdk.sctp \
-               jdk.security.auth jdk.security.jgss jdk.pack200 jdk.xml.dom \
-               jdk.accessibility jdk.internal.le jdk.dynalink \
-               jdk.scripting.nashorn jdk.scripting.nashorn.shell \
-               jdk.vm.ci jdk.management jdk.jsobject
-
-# providers
-PROVIDER_MODULES += jdk.charsets jdk.crypto.ec jdk.crypto.pkcs11 jdk.jvmstat jdk.jvmstat.rmi \
-               jdk.localedata jdk.naming.dns jdk.naming.rmi jdk.zipfs
-
-# tools
-TOOLS_MODULES += jdk.attach jdk.compiler \
-               jdk.javadoc jdk.jcmd jdk.jconsole jdk.hotspot.agent jdk.jartool \
-               jdk.jdeps jdk.jdi jdk.jdwp.agent jdk.jlink jdk.jshell \
-               jdk.policytool jdk.rmic jdk.xml.bind jdk.xml.ws jdk.internal.opt
-
-ifeq ($(OPENJDK_TARGET_OS), windows)
-  PROVIDER_MODULES += jdk.crypto.mscapi
-endif
-
-ifeq ($(OPENJDK_TARGET_OS), solaris)
-  PROVIDER_MODULES += jdk.crypto.ucrypto
-endif
+# All modules for the current target platform.
+ALL_MODULES := $(call FindAllModules)
 
-JRE_MODULES := $(filter-out $(MODULES_FILTER), $(MAIN_MODULES) $(PROVIDER_MODULES))
-JDK_MODULES := $(filter-out $(MODULES_FILTER), $(JRE_MODULES) $(TOOLS_MODULES))
+$(eval $(call ReadImportMetaData))
 
-# Param 1 - Name of module
-define ReadImportMetaData
-  ifneq ($$(wildcard $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties), )
-    include_in_jre :=
-    include_in_jdk :=
-    include $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties
-    ifeq ($$(include_in_jre), true)
-      JRE_MODULES += $1
-    endif
-    ifeq ($$(include_in_jdk), true)
-      JDK_MODULES += $1
-    endif
-  else
-    # Default to include in all
-    JRE_MODULES += $1
-    JDK_MODULES += $1
-  endif
-endef
-
-IMPORTED_MODULES := $(call FindImportedModules)
-$(foreach m, $(IMPORTED_MODULES), $(eval $(call ReadImportMetaData, $m)))
+JRE_MODULES += $(filter-out $(MODULES_FILTER), $(BOOT_MODULES) $(PLATFORM_MODULES) $(JRE_TOOL_MODULES))
+JDK_MODULES += $(filter-out $(MODULES_FILTER), $(ALL_MODULES))
 
 # Compact builds have additional modules
-COMPACT_EXTRA_MODULES := jdk.localedata jdk.crypto.pkcs11 jdk.crypto.ec
-JRE_COMPACT1_MODULES := $(COMPACT_EXTRA_MODULES) java.compact1
-JRE_COMPACT2_MODULES := $(JRE_COMPACT1_MODULES) java.compact2 jdk.xml.dom jdk.httpserver
-JRE_COMPACT3_MODULES := $(JRE_COMPACT2_MODULES) java.compact3 java.smartcardio jdk.management \
-                        jdk.naming.dns jdk.naming.rmi jdk.sctp jdk.security.auth
+COMPACT1_EXTRA_MODULES := jdk.localedata jdk.crypto.pkcs11 jdk.crypto.ec
+COMPACT2_EXTRA_MODULES := jdk.xml.dom jdk.httpserver
+COMPACT3_EXTRA_MODULES := java.smartcardio jdk.management \
+    jdk.naming.dns jdk.naming.rmi jdk.sctp jdk.security.auth
+
+JRE_COMPACT1_MODULES := java.compact1 $(COMPACT1_EXTRA_MODULES)
+JRE_COMPACT2_MODULES := $(JRE_COMPACT1_MODULES) java.compact2 $(COMPACT2_EXTRA_MODULES)
+JRE_COMPACT3_MODULES := $(JRE_COMPACT2_MODULES) java.compact3 $(COMPACT3_EXTRA_MODULES)
 
 # Replacing double-comma with a single comma is to workaround the issue
 # with some version of make on windows that doesn't substitute spaces
--- a/make/common/Modules.gmk	Thu Mar 24 02:04:14 2016 +0300
+++ b/make/common/Modules.gmk	Mon Mar 28 08:41:54 2016 -0700
@@ -26,11 +26,109 @@
 ifndef _MODULES_GMK
 _MODULES_GMK := 1
 
+################################################################################
+#
+# BOOT_MODULES are modules defined by the boot loader
+# PLATFORM_MODULES are modules defined by the platform loader
+# JRE_TOOL_MODULES are tools included in JRE and defined by the application loader
+#
+# All other modules not declared below are defined by the application loader
+# and are not included in JRE.
+
+BOOT_MODULES :=
+PLATFORM_MODULES :=
+JRE_TOOL_MODULES :=
+
 # Hook to include the corresponding custom file, if present.
 $(eval $(call IncludeCustomExtension, , common/Modules.gmk))
 
+UPGRADEABLE_MDOULES :=
+AGGREGATOR_MDOULES :=
+
+BOOT_MODULES += \
+    java.base \
+    java.datatransfer \
+    java.desktop \
+    java.httpclient \
+    java.instrument \
+    java.logging \
+    java.management \
+    java.naming \
+    java.prefs \
+    java.rmi \
+    java.security.jgss \
+    java.security.sasl \
+    java.sql \
+    java.xml \
+    java.xml.crypto \
+    jdk.httpserver \
+    jdk.management \
+    jdk.sctp \
+    jdk.security.auth \
+    jdk.security.jgss \
+    jdk.vm.ci \
+    #
+
+# to be deprivileged
+BOOT_MODULES += \
+    java.compiler \
+    java.scripting \
+    java.sql.rowset \
+    java.smartcardio \
+    jdk.charsets \
+    jdk.naming.rmi \
+    #
+
+UPGRADEABLE_MODULES += \
+    java.activation \
+    java.annotations.common \
+    java.corba \
+    java.transaction \
+    java.xml.bind \
+    java.xml.ws \
+    #
+
+AGGREGATOR_MODULES += \
+    java.compact1 \
+    java.compact2 \
+    java.compact3 \
+    java.se \
+    java.se.ee \
+    #
+
+PLATFORM_MODULES += \
+    $(UPGRADEABLE_MODULES) \
+    $(AGGREGATOR_MODULES)
+    #
+
+PLATFORM_MODULES += \
+    jdk.accessibility \
+    jdk.crypto.ec \
+    jdk.crypto.pkcs11 \
+    jdk.dynalink \
+    jdk.jsobject \
+    jdk.xml.dom \
+    jdk.localedata \
+    jdk.naming.dns \
+    jdk.scripting.nashorn \
+    jdk.zipfs \
+    #
+
+JRE_TOOL_MODULES += \
+    jdk.pack200 \
+    jdk.scripting.nashorn.shell \
+    #
+
+ifeq ($(OPENJDK_TARGET_OS), windows)
+  PLATFORM_MODULES += jdk.crypto.mscapi
+endif
+ifeq ($(OPENJDK_TARGET_OS), solaris)
+  PLATFORM_MODULES += jdk.crypto.ucrypto
+endif
+
 ################################################################################
 # Some platforms don't have the serviceability agent
+
 ifeq ($(INCLUDE_SA), false)
   MODULES_FILTER += jdk.hotspot.agent
 endif
@@ -120,4 +218,44 @@
 
 ################################################################################
 
+# Param 1 - Name of module
+define ReadSingleImportMetaData
+    ifneq ($$(wildcard $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties), )
+      classloader :=
+      include_in_jre :=
+      include_in_jdk :=
+      include $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties
+      ifeq ($$(include_in_jre), true)
+        JRE_MODULES += $1
+      endif
+      ifeq ($$(include_in_jdk), true)
+        JDK_MODULES += $1
+      endif
+      ifeq ($$(classloader), boot)
+        BOOT_MODULES += $1
+      else ifeq ($$(classloader), ext)
+        PLATFORM_MODULES += $1
+      endif
+    else
+      # Default to include in all
+      JRE_MODULES += $1
+      JDK_MODULES += $1
+    endif
+endef
+
+# Reading the imported modules metadata has a cost, so to make it available,
+# a makefile needs to eval-call this macro first. After calling this, the
+# following variables are populated with data from the imported modules:
+# * JRE_MODULES
+# * JDK_MODULES
+# * BOOT_MODULES
+# * PLATFORM_MODULES
+# * JRE_TOOL_MODULES
+define ReadImportMetaData
+    IMPORTED_MODULES := $(call FindImportedModules)
+    $(foreach m, $(IMPORTED_MODULES), $(eval $(call ReadImportMetaData, $m)))
+endef
+
+################################################################################
+
 endif # _MODULES_GMK
--- a/nashorn/.hgtags	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/.hgtags	Mon Mar 28 08:41:54 2016 -0700
@@ -344,3 +344,4 @@
 58409eff7e3e0c07f12f543341769964619c0acf jdk-9+108
 70f0c397021116d7dbd79b01c6711c5d2e68dab4 jdk-9+109
 9937077e48f19e98af07c4954790fe09b94ca510 jdk-9+110
+133ea8746b37739a0510c80b42888bd85ace9477 jdk-9+111
--- a/nashorn/make/build-benchmark.xml	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/make/build-benchmark.xml	Mon Mar 28 08:41:54 2016 -0700
@@ -278,8 +278,14 @@
   -->
   <target name="octane-nashorn" depends="jar">
     <property name="runtime" value="nashorn"/>
-    <antcall target="octane-process-separate"/>
-    <antcall target="octane-process-single"/>
+    <!--
+       Temporarily disabled because ant script tag is broken with
+       jdk9. See also: JDK-8152533.
+
+       <antcall target="octane-process-separate"/>
+       <antcall target="octane-process-single"/>
+    -->
+    <echo message="octane target temporarily disabled"/>
   </target>
 
   <!-- alias for 'octane' -->
--- a/nashorn/make/build.xml	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/make/build.xml	Mon Mar 28 08:41:54 2016 -0700
@@ -93,7 +93,21 @@
         <os family="windows"/>
       </not>
     </condition>
-  </target>
+
+    <!--set windows cygwin/cmd specific properties-->
+    <property environment="env"/>
+    <condition property="test-sys-prop-no-security.os.not.windows.cmd">
+     <not>
+      <and>
+        <os family="windows"/>
+        <not>
+          <isset property="env.SHELL"/>
+        </not>
+      </and>
+     </not>
+    </condition>
+   </target>
+  
 
   <!-- check minimum ant version required to be 1.8.4 -->
   <target name="check-ant-version">
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/CallSiteDescriptor.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/CallSiteDescriptor.java	Mon Mar 28 08:41:54 2016 -0700
@@ -83,7 +83,6 @@
 
 package jdk.dynalink;
 
-import java.lang.invoke.MethodHandles;
 import java.lang.invoke.MethodHandles.Lookup;
 import java.lang.invoke.MethodType;
 import java.util.Objects;
@@ -105,28 +104,28 @@
  * descriptors (typically, values passed in additional parameters to the
  * bootstrap method. Since the descriptors must be immutable, you can set up a
  * cache for equivalent descriptors to have the call sites share them.
+ * <p>
+ * The class extends {@link SecureLookupSupplier} for security-checked access to
+ * the {@code MethodHandles.Lookup} object it carries. This lookup should be used
+ * to find method handles to set as targets of the call site described by this
+ * descriptor.
  */
-public class CallSiteDescriptor {
-    private final MethodHandles.Lookup lookup;
+public class CallSiteDescriptor extends SecureLookupSupplier {
     private final Operation operation;
     private final MethodType methodType;
 
     /**
-     * The name of a runtime permission to invoke the {@link #getLookup()}
-     * method.
-     */
-    public static final String GET_LOOKUP_PERMISSION_NAME = "dynalink.getLookup";
-
-    private static final RuntimePermission GET_LOOKUP_PERMISSION = new RuntimePermission(GET_LOOKUP_PERMISSION_NAME);
-
-    /**
      * Creates a new call site descriptor.
      * @param lookup the lookup object describing the class the call site belongs to.
+     * When creating descriptors from a {@link java.lang.invoke} bootstrap method,
+     * it should be the lookup passed to the bootstrap.
      * @param operation the dynamic operation at the call site.
-     * @param methodType the method type of the call site.
+     * @param methodType the method type of the call site. When creating
+     * descriptors from a {@link java.lang.invoke} bootstrap method, it should be
+     * the method type passed to the bootstrap.
      */
     public CallSiteDescriptor(final Lookup lookup, final Operation operation, final MethodType methodType) {
-        this.lookup = Objects.requireNonNull(lookup, "lookup");
+        super(lookup);
         this.operation = Objects.requireNonNull(operation, "name");
         this.methodType = Objects.requireNonNull(methodType, "methodType");
     }
@@ -149,34 +148,6 @@
     }
 
     /**
-     * Returns the lookup that should be used to find method handles to set as
-     * targets of the call site described by this descriptor. When creating
-     * descriptors from a {@link java.lang.invoke} bootstrap method, it should
-     * be the lookup passed to the bootstrap.
-     * @return the lookup that should be used to find method handles to set as
-     * targets of the call site described by this descriptor.
-     * @throws SecurityException if the lookup isn't the
-     * {@link MethodHandles#publicLookup()} and a security manager is present,
-     * and a check for {@code RuntimePermission("dynalink.getLookup")} fails.
-     */
-    public final Lookup getLookup() {
-        final SecurityManager sm = System.getSecurityManager();
-        if (sm != null && lookup != MethodHandles.publicLookup()) {
-            sm.checkPermission(GET_LOOKUP_PERMISSION);
-        }
-        return lookup;
-    }
-
-    /**
-     * Returns the value of {@link #getLookup()} without a security check. Can
-     * be used by subclasses to access the lookup quickly.
-     * @return same as returned value of {@link #getLookup()}.
-     */
-    protected final Lookup getLookupPrivileged() {
-        return lookup;
-    }
-
-    /**
      * Creates a new call site descriptor from this descriptor, which is
      * identical to this, except it changes the method type. Invokes
      * {@link #changeMethodTypeInternal(MethodType)} and checks that it returns
@@ -211,7 +182,7 @@
      * @return a new call site descriptor, with the method type changed.
      */
     protected CallSiteDescriptor changeMethodTypeInternal(final MethodType newMethodType) {
-        return new CallSiteDescriptor(lookup, operation, newMethodType);
+        return new CallSiteDescriptor(getLookupPrivileged(), operation, newMethodType);
     }
 
     /**
@@ -233,7 +204,7 @@
         final CallSiteDescriptor other = (CallSiteDescriptor)obj;
         return operation.equals(other.operation) &&
                methodType.equals(other.methodType) &&
-               lookupsEqual(lookup, other.lookup);
+               lookupsEqual(getLookupPrivileged(), other.getLookupPrivileged());
     }
 
     /**
@@ -257,7 +228,7 @@
      */
     @Override
     public int hashCode() {
-        return operation.hashCode() + 31 * methodType.hashCode() + 31 * 31 * lookupHashCode(lookup);
+        return operation.hashCode() + 31 * methodType.hashCode() + 31 * 31 * lookupHashCode(getLookupPrivileged());
     }
 
     /**
@@ -279,7 +250,7 @@
     @Override
     public String toString() {
         final String mt = methodType.toString();
-        final String l = lookup.toString();
+        final String l = getLookupPrivileged().toString();
         final String o = operation.toString();
         final StringBuilder b = new StringBuilder(o.length() + mt.length() + 1 + l.length());
         return b.append(o).append(mt).append('@').append(l).toString();
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/LinkerServicesImpl.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/LinkerServicesImpl.java	Mon Mar 28 08:41:54 2016 -0700
@@ -85,7 +85,10 @@
 
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodHandles.Lookup;
 import java.lang.invoke.MethodType;
+import java.util.Objects;
+import java.util.function.Supplier;
 import jdk.dynalink.linker.ConversionComparator.Comparison;
 import jdk.dynalink.linker.GuardedInvocation;
 import jdk.dynalink.linker.GuardingDynamicLinker;
@@ -97,7 +100,7 @@
  * Default implementation of the {@link LinkerServices} interface.
  */
 final class LinkerServicesImpl implements LinkerServices {
-    private static final ThreadLocal<LinkRequest> threadLinkRequest = new ThreadLocal<>();
+    private static final ThreadLocal<SecureLookupSupplier> threadLookupSupplier = new ThreadLocal<>();
 
     private final TypeConverterFactory typeConverterFactory;
     private final GuardingDynamicLinker topLevelLinker;
@@ -138,14 +141,31 @@
         return typeConverterFactory.compareConversion(sourceType, targetType1, targetType2);
     }
 
+    /**
+     * Used to marshal a checked exception out of Supplier.get() in getGuardedInvocation.
+     */
+    private static class LinkerException extends RuntimeException {
+        private static final long serialVersionUID = 1L;
+
+        public LinkerException(final Exception cause) {
+            super(null, cause, true, false);
+        }
+    }
+
     @Override
     public GuardedInvocation getGuardedInvocation(final LinkRequest linkRequest) throws Exception {
-        final LinkRequest prevLinkRequest = threadLinkRequest.get();
-        threadLinkRequest.set(linkRequest);
         try {
-            return topLevelLinker.getGuardedInvocation(linkRequest, this);
-        } finally {
-            threadLinkRequest.set(prevLinkRequest);
+            return getWithLookupInternal(() -> {
+                try {
+                    return topLevelLinker.getGuardedInvocation(linkRequest, this);
+                } catch (final RuntimeException e) {
+                    throw e;
+                } catch (final Exception e) {
+                    throw new LinkerException(e);
+                }
+            }, linkRequest.getCallSiteDescriptor());
+        } catch (final LinkerException e) {
+            throw (Exception)e.getCause();
         }
     }
 
@@ -154,10 +174,32 @@
         return internalObjectsFilter != null ? internalObjectsFilter.transform(target) : target;
     }
 
-    static MethodHandles.Lookup getCurrentLookup() {
-        final LinkRequest currentRequest = threadLinkRequest.get();
-        if (currentRequest != null) {
-            return currentRequest.getCallSiteDescriptor().getLookup();
+    @Override
+    public <T> T getWithLookup(final Supplier<T> operation, final SecureLookupSupplier lookupSupplier) {
+        return getWithLookupInternal(
+                Objects.requireNonNull(operation, "action"),
+                Objects.requireNonNull(lookupSupplier, "lookupSupplier"));
+    }
+
+    private static <T> T getWithLookupInternal(final Supplier<T> operation, final SecureLookupSupplier lookupSupplier) {
+        final SecureLookupSupplier prevLookupSupplier = threadLookupSupplier.get();
+        final boolean differ = prevLookupSupplier != lookupSupplier;
+        if (differ) {
+            threadLookupSupplier.set(lookupSupplier);
+        }
+        try {
+            return operation.get();
+        } finally {
+            if (differ) {
+                threadLookupSupplier.set(prevLookupSupplier);
+            }
+        }
+    }
+
+    static Lookup getCurrentLookup() {
+        final SecureLookupSupplier lookupSupplier = threadLookupSupplier.get();
+        if (lookupSupplier != null) {
+            return lookupSupplier.getLookup();
         }
         return MethodHandles.publicLookup();
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/SecureLookupSupplier.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.dynalink;
+
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodHandles.Lookup;
+import java.util.Objects;
+
+/**
+ * Provides security-checked access to a {@code MethodHandles.Lookup} object.
+ * See {@link #getLookup()} for details.
+ */
+public class SecureLookupSupplier {
+    /**
+     * The name of a runtime permission required to successfully invoke the
+     * {@link #getLookup()} method.
+     */
+    public static final String GET_LOOKUP_PERMISSION_NAME = "dynalink.getLookup";
+
+    private static final RuntimePermission GET_LOOKUP_PERMISSION = new RuntimePermission(SecureLookupSupplier.GET_LOOKUP_PERMISSION_NAME);
+
+    private final MethodHandles.Lookup lookup;
+
+    /**
+     * Creates a new secure lookup supplier, securing the passed lookup.
+     * @param lookup the lookup to secure. Can not be null.
+     * @throws NullPointerException if null is passed.
+     */
+    public SecureLookupSupplier(final MethodHandles.Lookup lookup) {
+        this.lookup = Objects.requireNonNull(lookup, "lookup");
+    }
+
+    /**
+     * Returns the lookup secured by this {@code SecureLookupSupplier}.
+     * @return the lookup secured by this {@code SecureLookupSupplier}.
+     * @throws SecurityException if the secured lookup isn't the
+     * {@link MethodHandles#publicLookup()}, and a security manager is present,
+     * and a check for {@code RuntimePermission("dynalink.getLookup")} fails.
+     */
+    public final Lookup getLookup() {
+        final SecurityManager sm = System.getSecurityManager();
+        if (sm != null && lookup != MethodHandles.publicLookup()) {
+            sm.checkPermission(GET_LOOKUP_PERMISSION);
+        }
+        return lookup;
+    }
+
+    /**
+     * Returns the value of {@link #getLookup()} without a security check. Can
+     * be used by subclasses to access the lookup quickly.
+     * @return same as returned value of {@link #getLookup()}.
+     */
+    protected final Lookup getLookupPrivileged() {
+        return lookup;
+    }
+}
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/CallerSensitiveDynamicMethod.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/CallerSensitiveDynamicMethod.java	Mon Mar 28 08:41:54 2016 -0700
@@ -95,6 +95,7 @@
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import jdk.dynalink.CallSiteDescriptor;
+import jdk.dynalink.SecureLookupSupplier;
 import jdk.dynalink.internal.AccessControlContextFactory;
 import jdk.dynalink.linker.support.Lookup;
 
@@ -107,7 +108,7 @@
 class CallerSensitiveDynamicMethod extends SingleDynamicMethod {
     private static final AccessControlContext GET_LOOKUP_CONTEXT =
             AccessControlContextFactory.createAccessControlContext(
-                    CallSiteDescriptor.GET_LOOKUP_PERMISSION_NAME);
+                    SecureLookupSupplier.GET_LOOKUP_PERMISSION_NAME);
 
     // Typed as "AccessibleObject" as it can be either a method or a constructor.
     // If we were Java8-only, we could use java.lang.reflect.Executable
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/ClassLinker.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/ClassLinker.java	Mon Mar 28 08:41:54 2016 -0700
@@ -84,7 +84,6 @@
 package jdk.dynalink.beans;
 
 import java.lang.invoke.MethodHandle;
-import java.lang.invoke.MethodHandles;
 import java.lang.invoke.MethodType;
 import jdk.dynalink.beans.GuardedInvocationComponent.ValidationType;
 import jdk.dynalink.linker.support.Lookup;
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/LinkerServicesWithMissingMemberHandlerFactory.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/LinkerServicesWithMissingMemberHandlerFactory.java	Mon Mar 28 08:41:54 2016 -0700
@@ -27,6 +27,8 @@
 
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodType;
+import java.util.function.Supplier;
+import jdk.dynalink.SecureLookupSupplier;
 import jdk.dynalink.linker.ConversionComparator.Comparison;
 import jdk.dynalink.linker.GuardedInvocation;
 import jdk.dynalink.linker.LinkRequest;
@@ -77,4 +79,9 @@
     public MethodHandle filterInternalObjects(final MethodHandle target) {
         return linkerServices.filterInternalObjects(target);
     }
+
+    @Override
+    public <T> T getWithLookup(final Supplier<T> operation, final SecureLookupSupplier lookupSupplier) {
+        return linkerServices.getWithLookup(operation, lookupSupplier);
+    }
 }
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/OverloadedDynamicMethod.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/OverloadedDynamicMethod.java	Mon Mar 28 08:41:54 2016 -0700
@@ -98,6 +98,7 @@
 import java.util.Map;
 import java.util.Set;
 import jdk.dynalink.CallSiteDescriptor;
+import jdk.dynalink.SecureLookupSupplier;
 import jdk.dynalink.beans.ApplicableOverloadedMethods.ApplicabilityTest;
 import jdk.dynalink.internal.AccessControlContextFactory;
 import jdk.dynalink.internal.InternalTypeUtilities;
@@ -148,7 +149,7 @@
     }
 
     @Override
-    public MethodHandle getInvocation(final CallSiteDescriptor callSiteDescriptor, final LinkerServices linkerServices) {
+    MethodHandle getInvocation(final CallSiteDescriptor callSiteDescriptor, final LinkerServices linkerServices) {
         final MethodType callSiteType = callSiteDescriptor.getMethodType();
         // First, find all methods applicable to the call site by subtyping (JLS 15.12.2.2)
         final ApplicableOverloadedMethods subtypingApplicables = getApplicables(callSiteType,
@@ -218,14 +219,14 @@
                 for(final SingleDynamicMethod method: invokables) {
                     methodHandles.add(method.getTarget(callSiteDescriptor));
                 }
-                return new OverloadedMethod(methodHandles, this, getCallSiteClassLoader(callSiteDescriptor), callSiteType, linkerServices).getInvoker();
+                return new OverloadedMethod(methodHandles, this, getCallSiteClassLoader(callSiteDescriptor), callSiteType, linkerServices, callSiteDescriptor).getInvoker();
             }
         }
     }
 
     private static final AccessControlContext GET_CALL_SITE_CLASS_LOADER_CONTEXT =
             AccessControlContextFactory.createAccessControlContext(
-                    "getClassLoader", CallSiteDescriptor.GET_LOOKUP_PERMISSION_NAME);
+                    "getClassLoader", SecureLookupSupplier.GET_LOOKUP_PERMISSION_NAME);
 
     private static ClassLoader getCallSiteClassLoader(final CallSiteDescriptor callSiteDescriptor) {
         return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/OverloadedMethod.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/OverloadedMethod.java	Mon Mar 28 08:41:54 2016 -0700
@@ -91,6 +91,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
+import jdk.dynalink.SecureLookupSupplier;
 import jdk.dynalink.internal.InternalTypeUtilities;
 import jdk.dynalink.linker.LinkerServices;
 import jdk.dynalink.linker.support.Lookup;
@@ -108,6 +109,7 @@
     private final MethodType callSiteType;
     private final MethodHandle invoker;
     private final LinkerServices linkerServices;
+    private final SecureLookupSupplier lookupSupplier;
     private final ArrayList<MethodHandle> fixArgMethods;
     private final ArrayList<MethodHandle> varArgMethods;
 
@@ -115,12 +117,14 @@
             final OverloadedDynamicMethod parent,
             final ClassLoader callSiteClassLoader,
             final MethodType callSiteType,
-            final LinkerServices linkerServices) {
+            final LinkerServices linkerServices,
+            final SecureLookupSupplier lookupSupplier) {
         this.parent = parent;
         this.callSiteClassLoader = callSiteClassLoader;
         final Class<?> commonRetType = getCommonReturnType(methodHandles);
         this.callSiteType = callSiteType.changeReturnType(commonRetType);
         this.linkerServices = linkerServices;
+        this.lookupSupplier = lookupSupplier;
 
         fixArgMethods = new ArrayList<>(methodHandles.size());
         varArgMethods = new ArrayList<>(methodHandles.size());
@@ -173,11 +177,14 @@
                     break;
                 }
                 case 1: {
-                    method = SingleDynamicMethod.getInvocation(methods.get(0), callSiteType, linkerServices);
+                    final List<MethodHandle> fmethods = methods;
+                    method = linkerServices.getWithLookup(
+                            ()->SingleDynamicMethod.getInvocation(fmethods.get(0), callSiteType, linkerServices),
+                            lookupSupplier);
                     break;
                 }
                 default: {
-                    // This is unfortunate - invocation time ambiguity. We can still save the day if
+                    // This is unfortunate - invocation time ambiguity.
                     method = getAmbiguousMethodThrower(argTypes, methods);
                     break;
                 }
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/SingleDynamicMethod.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/SingleDynamicMethod.java	Mon Mar 28 08:41:54 2016 -0700
@@ -99,7 +99,6 @@
  * arity).
  */
 abstract class SingleDynamicMethod extends DynamicMethod {
-
     private static final MethodHandle CAN_CONVERT_TO = Lookup.findOwnStatic(MethodHandles.lookup(), "canConvertTo", boolean.class, LinkerServices.class, Class.class, Object.class);
 
     SingleDynamicMethod(final String name) {
@@ -129,8 +128,8 @@
 
     @Override
     MethodHandle getInvocation(final CallSiteDescriptor callSiteDescriptor, final LinkerServices linkerServices) {
-        return getInvocation(getTarget(callSiteDescriptor), callSiteDescriptor.getMethodType(),
-                linkerServices);
+        return linkerServices.getWithLookup(()->getInvocation(getTarget(callSiteDescriptor),
+                callSiteDescriptor.getMethodType(), linkerServices), callSiteDescriptor);
     }
 
     @Override
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/messages.properties	Thu Mar 24 02:04:14 2016 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-#  Copyright 2009-2013 Attila Szegedi
-#
-#  Licensed under either the Apache License, Version 2.0 (the "Apache 
-#  License") or the BSD License (the "BSD License"), with licensee
-#  being free to choose either of the two at their discretion.
-#
-#  You may not use this file except in compliance with either the Apache 
-#  License or the BSD License.
-#
-#  A copy of the BSD License is available in the root directory of the 
-#  source distribution of the project under the file name
-#  "Dynalink-License-BSD.txt".
-#
-#  A copy of the Apache License is available in the root directory of the
-#  source distribution of the project under the file name 
-#  "Dynalink-License-Apache-2.0.txt". Alternatively, you may obtain a 
-#  copy of the Apache License at <http://www.apache.org/licenses/LICENSE-2.0>
-#
-#  Unless required by applicable law or agreed to in writing, software
-#  distributed under the License is distributed on an "AS IS" BASIS,
-#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#  See your chosen License for the specific language governing permissions
-#  and limitations under that License.
-
-couldNotDiscoverAccessibleMethods=Could not discover accessible methods of class {0}, trying its superclasses and interfaces.
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/linker/GuardingTypeConverterFactory.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/linker/GuardingTypeConverterFactory.java	Mon Mar 28 08:41:54 2016 -0700
@@ -85,7 +85,7 @@
 
 import java.lang.invoke.MethodHandles;
 import java.util.function.Supplier;
-import jdk.dynalink.CallSiteDescriptor;
+import jdk.dynalink.SecureLookupSupplier;
 import jdk.dynalink.beans.BeansLinker;
 import jdk.dynalink.linker.support.TypeUtilities;
 
@@ -132,7 +132,7 @@
      * (e.g. to convert some object from the dynamic language into a Java
      * interface for interoperability). Invoking the {@link Supplier#get()}
      * method on the passed supplier will be subject to the same security checks
-     * as {@link CallSiteDescriptor#getLookup()}. An implementation should avoid
+     * as {@link SecureLookupSupplier#getLookup()}. An implementation should avoid
      * retrieving the lookup if it is not needed so as to avoid the expense of
      * {@code AccessController.doPrivileged} call.
      * @return a guarded invocation that can take an object (if it passes guard)
@@ -142,6 +142,7 @@
      * can always handle the conversion, it can return an unconditional
      * invocation (one whose guard is null).
      * @throws Exception if there was an error during creation of the converter
+     * @see LinkerServices#getWithLookup(Supplier, SecureLookupSupplier)
      */
     public GuardedInvocation convertToType(Class<?> sourceType, Class<?> targetType, Supplier<MethodHandles.Lookup> lookupSupplier) throws Exception;
 }
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/linker/LinkerServices.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/linker/LinkerServices.java	Mon Mar 28 08:41:54 2016 -0700
@@ -86,8 +86,10 @@
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.MethodType;
+import java.util.function.Supplier;
 import jdk.dynalink.DynamicLinker;
 import jdk.dynalink.DynamicLinkerFactory;
+import jdk.dynalink.SecureLookupSupplier;
 import jdk.dynalink.linker.ConversionComparator.Comparison;
 import jdk.dynalink.linker.support.TypeUtilities;
 
@@ -217,4 +219,34 @@
      * filtered for wrapping and unwrapping.
      */
     public MethodHandle filterInternalObjects(final MethodHandle target);
+
+    /**
+     * Executes an operation within the context of a particular
+     * {@code MethodHandles.Lookup} lookup object. Normally, methods on
+     * {@code LinkerServices} are invoked as part of the linking mechanism in
+     * which case Dynalink internally maintains a per-thread current lookup
+     * (the one belonging to the descriptor of the call site being linked). This
+     * lookup can be retrieved by any {@link GuardingTypeConverterFactory}
+     * involved in linking if it needs to generate lookup-sensitive converters.
+     * However, linker services' methods can be invoked outside the linking
+     * process too when implementing invocation-time dispatch schemes, invoking
+     * conversions at runtime, etc. If it becomes necessary to use any type
+     * converter in this situation, and it needs a lookup, it will normally only
+     * get {@link MethodHandles#publicLookup()} as the thread is not engaged in
+     * a linking operation. If there is a way to meaningfully associate the
+     * operation to the context of some caller class, consider performing it
+     * within an invocation of this method and passing a full-strength lookup
+     * for that class, as it will associate that lookup with the current thread
+     * for the duration of the operation. Note that since you are passing a
+     * {@link SecureLookupSupplier}, any invoked type converter factories will
+     * still need to hold the necessary runtime permission to be able to get the
+     * lookup should they need it.
+     * @param <T> the type of the return value provided by the passed-in supplier.
+     * @param operation the operation to execute in context of the specified lookup.
+     * @param lookupSupplier secure supplier of the lookup
+     * @return the return value of the action
+     * @throws NullPointerException if either action or lookupSupplier are null.
+     * @see GuardingTypeConverterFactory#convertToType(Class, Class, Supplier)
+     */
+    public <T> T getWithLookup(final Supplier<T> operation, final SecureLookupSupplier lookupSupplier);
 }
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/ScriptUtils.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/ScriptUtils.java	Mon Mar 28 08:41:54 2016 -0700
@@ -171,7 +171,7 @@
 
         final LinkerServices linker = Bootstrap.getLinkerServices();
         final Object objToConvert = unwrap(obj);
-        final MethodHandle converter = linker.getTypeConverter(objToConvert.getClass(),  clazz);
+        final MethodHandle converter = linker.getTypeConverter(objToConvert.getClass(), clazz);
         if (converter == null) {
             // no supported conversion!
             throw new UnsupportedOperationException("conversion not supported");
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/AssignSymbols.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/AssignSymbols.java	Mon Mar 28 08:41:54 2016 -0700
@@ -803,7 +803,7 @@
 
     @Override
     public Node leaveForNode(final ForNode forNode) {
-        if (forNode.isForIn()) {
+        if (forNode.isForInOrOf()) {
             return forNode.setIterator(lc, newObjectInternal(ITERATOR_PREFIX)); //NASHORN-73
         }
 
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java	Mon Mar 28 08:41:54 2016 -0700
@@ -257,6 +257,9 @@
     //is this a rest of compilation
     private final int[] continuationEntryPoints;
 
+    // Scope object creators needed for for-of and for-in loops
+    private Deque<FieldObjectCreator<?>> scopeObjectCreators = new ArrayDeque<>();
+
     /**
      * Constructor.
      *
@@ -1297,6 +1300,9 @@
     private void popBlockScope(final Block block) {
         final Label breakLabel = block.getBreakLabel();
 
+        if (block.providesScopeCreator()) {
+            scopeObjectCreators.pop();
+        }
         if(!block.needsScope() || lc.isFunctionBody()) {
             emitBlockBreakLabel(breakLabel);
             return;
@@ -1747,7 +1753,7 @@
             return false;
         }
         enterStatement(forNode);
-        if (forNode.isForIn()) {
+        if (forNode.isForInOrOf()) {
             enterForIn(forNode);
         } else {
             final Expression init = forNode.getInit();
@@ -1762,7 +1768,15 @@
 
     private void enterForIn(final ForNode forNode) {
         loadExpression(forNode.getModify(), TypeBounds.OBJECT);
-        method.invoke(forNode.isForEach() ? ScriptRuntime.TO_VALUE_ITERATOR : ScriptRuntime.TO_PROPERTY_ITERATOR);
+        if (forNode.isForEach()) {
+            method.invoke(ScriptRuntime.TO_VALUE_ITERATOR);
+        } else if (forNode.isForIn()) {
+            method.invoke(ScriptRuntime.TO_PROPERTY_ITERATOR);
+        } else if (forNode.isForOf()) {
+            method.invoke(ScriptRuntime.TO_ES6_ITERATOR);
+        } else {
+            throw new IllegalArgumentException("Unexpected for node");
+        }
         final Symbol iterSymbol = forNode.getIterator();
         final int iterSlot = iterSymbol.getSlot(Type.OBJECT);
         method.store(iterSymbol, ITERATOR_TYPE);
@@ -1812,6 +1826,14 @@
         }.store();
         body.accept(this);
 
+        if (forNode.needsScopeCreator() && lc.getCurrentBlock().providesScopeCreator()) {
+            // for-in loops with lexical declaration need a new scope for each iteration.
+            final FieldObjectCreator<?> creator = scopeObjectCreators.peek();
+            assert creator != null;
+            creator.createForInIterationScope(method);
+            method.storeCompilerConstant(SCOPE);
+        }
+
         if(method.isReachable()) {
             method._goto(continueLabel);
         }
@@ -1923,12 +1945,16 @@
              * Create a new object based on the symbols and values, generate
              * bootstrap code for object
              */
-            new FieldObjectCreator<Symbol>(this, tuples, true, hasArguments) {
+            final FieldObjectCreator<Symbol> creator = new FieldObjectCreator<Symbol>(this, tuples, true, hasArguments) {
                 @Override
                 protected void loadValue(final Symbol value, final Type type) {
                     method.load(value, type);
                 }
-            }.makeObject(method);
+            };
+            creator.makeObject(method);
+            if (block.providesScopeCreator()) {
+                scopeObjectCreators.push(creator);
+            }
             // program function: merge scope into global
             if (isFunctionBody && function.isProgram()) {
                 method.invoke(ScriptRuntime.MERGE_SCOPE);
@@ -3294,11 +3320,13 @@
         final boolean needsScope = identSymbol.isScope();
 
         if (init == null) {
-            if (needsScope && varNode.isBlockScoped()) {
-                // block scoped variables need a DECLARE flag to signal end of temporal dead zone (TDZ)
+            // Block-scoped variables need a DECLARE flag to signal end of temporal dead zone (TDZ).
+            // However, don't do this for CONST which always has an initializer except in the special case of
+            // for-in/of loops, in which it is initialized in the loop header and should be left untouched here.
+            if (needsScope && varNode.isLet()) {
                 method.loadCompilerConstant(SCOPE);
                 method.loadUndefined(Type.OBJECT);
-                final int flags = getScopeCallSiteFlags(identSymbol) | (varNode.isBlockScoped() ? CALLSITE_DECLARE : 0);
+                final int flags = getScopeCallSiteFlags(identSymbol) | CALLSITE_DECLARE;
                 assert isFastScope(identSymbol);
                 storeFastScopeVar(identSymbol, flags);
             }
@@ -4480,7 +4508,7 @@
                     final Symbol symbol = node.getSymbol();
                     assert symbol != null;
                     if (symbol.isScope()) {
-                        final int flags = getScopeCallSiteFlags(symbol);
+                        final int flags = getScopeCallSiteFlags(symbol) | (node.isDeclaredHere() ? CALLSITE_DECLARE : 0);
                         if (isFastScope(symbol)) {
                             storeFastScopeVar(symbol, flags);
                         } else {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FieldObjectCreator.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FieldObjectCreator.java	Mon Mar 28 08:41:54 2016 -0700
@@ -120,6 +120,25 @@
         }
     }
 
+    /**
+     * Create a scope for a for-in/of loop as defined in ES6 13.7.5.13 step 5.g.iii
+     *
+     * @param method the method emitter
+     */
+    void createForInIterationScope(final MethodEmitter method) {
+        assert fieldObjectClass != null;
+        assert isScope();
+        assert getMap() != null;
+
+        final String className = getClassName();
+        method._new(fieldObjectClass).dup();
+        loadMap(method); //load the map
+        loadScope(method);
+        // We create a scope identical to the currently active one, so use its parent as our parent
+        method.invoke(ScriptObject.GET_PROTO);
+        method.invoke(constructorNoLookup(className, PropertyMap.class, ScriptObject.class));
+    }
+
     @Override
     public void populateRange(final MethodEmitter method, final Type objectType, final int objectSlot, final int start, final int end) {
         method.load(objectType, objectSlot);
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java	Mon Mar 28 08:41:54 2016 -0700
@@ -595,7 +595,7 @@
         }
 
         final Expression init = forNode.getInit();
-        if(forNode.isForIn()) {
+        if(forNode.isForInOrOf()) {
             final JoinPredecessorExpression iterable = forNode.getModify();
             visitExpression(iterable);
             enterTestFirstLoop(forNode, null, init,
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Lower.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Lower.java	Mon Mar 28 08:41:54 2016 -0700
@@ -97,6 +97,7 @@
 final class Lower extends NodeOperatorVisitor<BlockLexicalContext> implements Loggable {
 
     private final DebugLogger log;
+    private final boolean es6;
 
     // Conservative pattern to test if element names consist of characters valid for identifiers.
     // This matches any non-zero length alphanumeric string including _ and $ and not starting with a digit.
@@ -144,6 +145,7 @@
         });
 
         this.log = initLogger(compiler.getContext());
+        this.es6 = compiler.getScriptEnvironment()._es6;
     }
 
     @Override
@@ -252,13 +254,14 @@
         ForNode newForNode = forNode;
 
         final Expression test = forNode.getTest();
-        if (!forNode.isForIn() && isAlwaysTrue(test)) {
+        if (!forNode.isForInOrOf() && isAlwaysTrue(test)) {
             newForNode = forNode.setTest(lc, null);
         }
 
         newForNode = checkEscape(newForNode);
-        if(newForNode.isForIn()) {
-            // Wrap it in a block so its internally created iterator is restricted in scope
+        if(!es6 && newForNode.isForInOrOf()) {
+            // Wrap it in a block so its internally created iterator is restricted in scope, unless we are running
+            // in ES6 mode, in which case the parser already created a block to capture let/const declarations.
             addStatementEnclosedInBlock(newForNode);
         } else {
             addStatement(newForNode);
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/OptimisticTypesCalculator.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/OptimisticTypesCalculator.java	Mon Mar 28 08:41:54 2016 -0700
@@ -130,7 +130,7 @@
 
     @Override
     public boolean enterForNode(final ForNode forNode) {
-        if(forNode.isForIn()) {
+        if(forNode.isForInOrOf()) {
             // for..in has the iterable in its "modify"
             tagNeverOptimistic(forNode.getModify());
         } else {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/Block.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/Block.java	Mon Mar 28 08:41:54 2016 -0700
@@ -462,6 +462,19 @@
         return next;
     }
 
+    /**
+     * Determine whether this block needs to provide its scope object creator for use by its child nodes.
+     * This is only necessary for synthetic parent blocks of for-in loops with lexical declarations.
+     *
+     * @see ForNode#needsScopeCreator()
+     * @return true if child nodes need access to this block's scope creator
+     */
+    public boolean providesScopeCreator() {
+        return needsScope() && isSynthetic()
+                && (getLastStatement() instanceof ForNode)
+                && ((ForNode) getLastStatement()).needsScopeCreator();
+    }
+
     @Override
     public boolean isBreakableWithoutLabel() {
         return false;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/ForNode.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/ForNode.java	Mon Mar 28 08:41:54 2016 -0700
@@ -51,8 +51,11 @@
     /** Is this a normal for each in loop? */
     public static final int IS_FOR_EACH         = 1 << 1;
 
+    /** Is this a ES6 for-of loop? */
+    public static final int IS_FOR_OF           = 1 << 2;
+
     /** Does this loop need a per-iteration scope because its init contain a LET declaration? */
-    public static final int PER_ITERATION_SCOPE = 1 << 2;
+    public static final int PER_ITERATION_SCOPE = 1 << 3;
 
     private final int flags;
 
@@ -127,6 +130,10 @@
             init.toString(sb, printTypes);
             sb.append(" in ");
             modify.toString(sb, printTypes);
+        } else if (isForOf()) {
+            init.toString(sb, printTypes);
+            sb.append(" of ");
+            modify.toString(sb, printTypes);
         } else {
             if (init != null) {
                 init.toString(sb, printTypes);
@@ -146,12 +153,12 @@
 
     @Override
     public boolean hasGoto() {
-        return !isForIn() && test == null;
+        return !isForInOrOf() && test == null;
     }
 
     @Override
     public boolean mustEnter() {
-        if (isForIn()) {
+        if (isForInOrOf()) {
             return false; //may be an empty set to iterate over, then we skip the loop
         }
         return test == null;
@@ -185,6 +192,23 @@
     public boolean isForIn() {
         return (flags & IS_FOR_IN) != 0;
     }
+
+    /**
+     * Is this a for-of loop?
+     * @return true if this is a for-of loop
+     */
+    public boolean isForOf() {
+        return (flags & IS_FOR_OF) != 0;
+    }
+
+    /**
+     * Is this a for-in or for-of statement?
+     * @return true if this is a for-in or for-of loop
+     */
+    public boolean isForInOrOf() {
+        return isForIn() || isForOf();
+    }
+
     /**
      * Is this a for each construct, known from e.g. Rhino. This will be a for of construct
      * in ECMAScript 6
@@ -274,4 +298,15 @@
     public boolean hasPerIterationScope() {
         return (flags & PER_ITERATION_SCOPE) != 0;
     }
+
+    /**
+     * Returns true if this for-node needs the scope creator of its containing block to create
+     * per-iteration scope. This is only true for for-in loops with lexical declarations.
+     *
+     * @see Block#providesScopeCreator()
+     * @return true if the containing block's scope object creator is required in codegen
+     */
+    public boolean needsScopeCreator() {
+        return isForInOrOf() && hasPerIterationScope();
+    }
 }
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/AbstractIterator.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/AbstractIterator.java	Mon Mar 28 08:41:54 2016 -0700
@@ -110,6 +110,41 @@
         return new IteratorResult(value, done, global);
     }
 
+    static MethodHandle getIteratorInvoker(final Global global) {
+        return global.getDynamicInvoker(ITERATOR_INVOKER_KEY,
+                () -> Bootstrap.createDynamicCallInvoker(Object.class, Object.class, Object.class));
+    }
+
+    /**
+     * Get the invoker for the ES6 iterator {@code next} method.
+     * @param global the global object
+     * @return the next invoker
+     */
+    public static InvokeByName getNextInvoker(final Global global) {
+        return global.getInvokeByName(AbstractIterator.NEXT_INVOKER_KEY,
+                () -> new InvokeByName("next", Object.class, Object.class, Object.class));
+    }
+
+    /**
+     * Get the invoker for the ES6 iterator result {@code done} property.
+     * @param global the global object
+     * @return the done invoker
+     */
+    public static MethodHandle getDoneInvoker(final Global global) {
+        return global.getDynamicInvoker(AbstractIterator.DONE_INVOKER_KEY,
+                () -> Bootstrap.createDynamicInvoker("done", NashornCallSiteDescriptor.GET_PROPERTY, Object.class, Object.class));
+    }
+
+    /**
+     * Get the invoker for the ES6 iterator result {@code value} property.
+     * @param global the global object
+     * @return the value invoker
+     */
+    public static MethodHandle getValueInvoker(final Global global) {
+        return global.getDynamicInvoker(AbstractIterator.VALUE_INVOKER_KEY,
+                () -> Bootstrap.createDynamicInvoker("value", NashornCallSiteDescriptor.GET_PROPERTY, Object.class, Object.class));
+    }
+
     /**
      * ES6 7.4.1 GetIterator abstract operation
      *
@@ -126,8 +161,7 @@
 
             if (Bootstrap.isCallable(getter)) {
                 try {
-                    final MethodHandle invoker = global.getDynamicInvoker(ITERATOR_INVOKER_KEY,
-                            () -> Bootstrap.createDynamicCallInvoker(Object.class, Object.class, Object.class));
+                    final MethodHandle invoker = getIteratorInvoker(global);
 
                     final Object value = invoker.invokeExact(getter, iterable);
                     if (JSType.isPrimitive(value)) {
@@ -156,12 +190,9 @@
 
         final Object iterator = AbstractIterator.getIterator(Global.toObject(iterable), global);
 
-        final InvokeByName nextInvoker = global.getInvokeByName(AbstractIterator.NEXT_INVOKER_KEY,
-                () -> new InvokeByName("next", Object.class, Object.class, Object.class));
-        final MethodHandle doneInvoker = global.getDynamicInvoker(AbstractIterator.DONE_INVOKER_KEY,
-                () -> Bootstrap.createDynamicInvoker("done", NashornCallSiteDescriptor.GET_PROPERTY, Object.class, Object.class));
-        final MethodHandle valueInvoker = global.getDynamicInvoker(AbstractIterator.VALUE_INVOKER_KEY,
-                () -> Bootstrap.createDynamicInvoker("value", NashornCallSiteDescriptor.GET_PROPERTY, Object.class, Object.class));
+        final InvokeByName nextInvoker = getNextInvoker(global);
+        final MethodHandle doneInvoker = getDoneInvoker(global);
+        final MethodHandle valueInvoker = getValueInvoker(global);
 
         try {
             do {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java	Mon Mar 28 08:41:54 2016 -0700
@@ -1057,6 +1057,9 @@
     private ScriptObject   builtinArrayIteratorPrototype;
     private ScriptObject   builtinStringIteratorPrototype;
 
+    private ScriptFunction builtInJavaExtend;
+    private ScriptFunction builtInJavaTo;
+
     /*
      * ECMA section 13.2.3 The [[ThrowTypeError]] Function Object
      */
@@ -2085,10 +2088,39 @@
     private synchronized ScriptObject getBuiltinJavaApi() {
         if (this.builtinJavaApi == null) {
             this.builtinJavaApi = initConstructor("Java", ScriptObject.class);
+            this.builtInJavaExtend = (ScriptFunction)builtinJavaApi.get("extend");
+            this.builtInJavaTo = (ScriptFunction)builtinJavaApi.get("to");
         }
         return this.builtinJavaApi;
     }
 
+    /**
+     * Returns true if the passed function is the built-in "Java.extend".
+     * @param fn the function in question
+     * @return true if the function is built-in "Java.extend"
+     */
+    public static boolean isBuiltInJavaExtend(final ScriptFunction fn) {
+        if(!"extend".equals(fn.getName())) {
+            // Avoid hitting the thread local if the name doesn't match.
+            return false;
+        }
+        return fn == Context.getGlobal().builtInJavaExtend;
+    }
+
+    /**
+     * Returns true if the passed function is the built-in "Java.to".
+     * @param fn the function in question
+     * @return true if the function is built-in "Java.to"
+     */
+    public static boolean isBuiltInJavaTo(final ScriptFunction fn) {
+        if(!"to".equals(fn.getName())) {
+            // Avoid hitting the thread local if the name doesn't match.
+            return false;
+        }
+        return fn == Context.getGlobal().builtInJavaTo;
+    }
+
+
     private synchronized ScriptFunction getBuiltinRangeError() {
         if (this.builtinRangeError == null) {
             this.builtinRangeError = initErrorSubtype("RangeError", getErrorPrototype());
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/LinkedMap.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/LinkedMap.java	Mon Mar 28 08:41:54 2016 -0700
@@ -62,7 +62,7 @@
      */
     static class Node {
         private final Object key;
-        private final Object value;
+        private volatile Object value;
 
         private volatile boolean alive = true;
         private volatile Node prev;
@@ -103,6 +103,14 @@
         public Object getValue() {
             return value;
         }
+
+        /**
+         * Set the node's value
+         * @param value the new value
+         */
+        void setValue(final Object value) {
+            this.value = value;
+        }
     }
 
     /**
@@ -150,12 +158,14 @@
      * @param value the value
      */
     public void set(final Object key, final Object value) {
-        final Node newNode = new Node(key, value);
-        final Node oldNode = data.put(key, newNode);
-        if (oldNode != null) {
-            unlink(oldNode);
+        Node node = data.get(key);
+        if (node != null) {
+            node.setValue(value);
+        } else {
+            node = new Node(key, value);
+            data.put(key, node);
+            link(node);
         }
-        link(newNode);
     }
 
     /**
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeJava.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeJava.java	Mon Mar 28 08:41:54 2016 -0700
@@ -37,6 +37,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Queue;
+import jdk.dynalink.SecureLookupSupplier;
 import jdk.dynalink.beans.BeansLinker;
 import jdk.dynalink.beans.StaticClass;
 import jdk.dynalink.linker.support.TypeUtilities;
@@ -64,7 +65,6 @@
  */
 @ScriptClass("Java")
 public final class NativeJava {
-
     // initialized by nasgen
     @SuppressWarnings("unused")
     private static PropertyMap $nasgenmap$;
@@ -391,6 +391,9 @@
 
         if(targetClass.isArray()) {
             try {
+                if (self instanceof SecureLookupSupplier) {
+                    return JSType.toJavaArrayWithLookup(obj, targetClass.getComponentType(), (SecureLookupSupplier)self);
+                }
                 return JSType.toJavaArray(obj, targetClass.getComponentType());
             } catch (final Exception exp) {
                 throw typeError(exp, "java.array.conversion.failed", targetClass.getName());
@@ -468,7 +471,7 @@
                 // Usually writable properties are a subset as 'write-only' properties are rare
                 props.addAll(BeansLinker.getReadableStaticPropertyNames(clazz));
                 props.addAll(BeansLinker.getStaticMethodNames(clazz));
-            } catch (Exception ignored) {}
+            } catch (final Exception ignored) {}
             return props;
         } else if (object instanceof JSObject) {
             final JSObject jsObj = ((JSObject)object);
@@ -484,7 +487,7 @@
                 // Usually writable properties are a subset as 'write-only' properties are rare
                 props.addAll(BeansLinker.getReadableInstancePropertyNames(clazz));
                 props.addAll(BeansLinker.getInstanceMethodNames(clazz));
-            } catch (Exception ignored) {}
+            } catch (final Exception ignored) {}
             return props;
         }
 
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Parser.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Parser.java	Mon Mar 28 08:41:54 2016 -0700
@@ -892,7 +892,7 @@
             block();
             break;
         case VAR:
-            variableStatement(type, true);
+            variableStatement(type);
             break;
         case SEMICOLON:
             emptyStatement();
@@ -946,11 +946,11 @@
                 if (singleStatement) {
                     throw error(AbstractParser.message("expected.stmt", type.getName() + " declaration"), token);
                 }
-                variableStatement(type, true);
+                variableStatement(type);
                 break;
             }
             if (env._const_as_var && type == CONST) {
-                variableStatement(TokenType.VAR, true);
+                variableStatement(TokenType.VAR);
                 break;
             }
 
@@ -1047,7 +1047,7 @@
         }
     }
 
-    /**
+    /*
      * VariableStatement :
      *      var VariableDeclarationList ;
      *
@@ -1066,8 +1066,8 @@
      * Parse a VAR statement.
      * @param isStatement True if a statement (not used in a FOR.)
      */
-    private List<VarNode> variableStatement(final TokenType varType, final boolean isStatement) {
-        return variableStatement(varType, isStatement, -1);
+    private List<VarNode> variableStatement(final TokenType varType) {
+        return variableStatement(varType, true, -1);
     }
 
     private List<VarNode> variableStatement(final TokenType varType, final boolean isStatement, final int sourceOrder) {
@@ -1104,12 +1104,14 @@
                 } finally {
                     defaultNames.pop();
                 }
-            } else if (varType == CONST) {
+            } else if (varType == CONST && isStatement) {
                 throw error(AbstractParser.message("missing.const.assignment", name.getName()));
             }
 
+            // Only set declaration flag on lexically scoped let/const as it adds runtime overhead.
+            final IdentNode actualName = varType == LET || varType == CONST ? name.setIsDeclaredHere() : name;
             // Allocate var node.
-            final VarNode var = new VarNode(varLine, varToken, sourceOrder, finish, name.setIsDeclaredHere(), init, varFlags);
+            final VarNode var = new VarNode(varLine, varToken, sourceOrder, finish, actualName, init, varFlags);
             vars.add(var);
             appendStatement(var);
 
@@ -1213,6 +1215,7 @@
      *
      * Parse a FOR statement.
      */
+    @SuppressWarnings("fallthrough")
     private void forStatement() {
         final long forToken = token;
         final int forLine = line;
@@ -1233,6 +1236,7 @@
         JoinPredecessorExpression modify = null;
 
         int flags = 0;
+        boolean isForOf = false;
 
         try {
             // FOR tested in caller.
@@ -1247,7 +1251,6 @@
 
             expect(LPAREN);
 
-
             switch (type) {
             case VAR:
                 // Var declaration captured in for outer block.
@@ -1257,9 +1260,7 @@
                 break;
             default:
                 if (useBlockScope() && (type == LET || type == CONST)) {
-                    if (type == LET) {
-                        flags |= ForNode.PER_ITERATION_SCOPE;
-                    }
+                    flags |= ForNode.PER_ITERATION_SCOPE;
                     // LET/CONST declaration captured in container block created above.
                     vars = variableStatement(type, false, forStart);
                     break;
@@ -1293,8 +1294,17 @@
                 }
                 break;
 
+            case IDENT:
+                if (env._es6 && "of".equals(getValue())) {
+                    isForOf = true;
+                    // fall through
+                } else {
+                    expect(SEMICOLON); // fail with expected message
+                    break;
+                }
             case IN:
-                flags |= ForNode.IS_FOR_IN;
+
+                flags |= isForOf ? ForNode.IS_FOR_OF : ForNode.IS_FOR_IN;
                 test = new JoinPredecessorExpression();
                 if (vars != null) {
                     // for (var i in obj)
@@ -1302,32 +1312,31 @@
                         init = new IdentNode(vars.get(0).getName());
                     } else {
                         // for (var i, j in obj) is invalid
-                        throw error(AbstractParser.message("many.vars.in.for.in.loop"), vars.get(1).getToken());
+                        throw error(AbstractParser.message("many.vars.in.for.in.loop", isForOf ? "of" : "in"), vars.get(1).getToken());
                     }
-
                 } else {
                     // for (expr in obj)
-                    assert init != null : "for..in init expression can not be null here";
+                    assert init != null : "for..in/of init expression can not be null here";
 
                     // check if initial expression is a valid L-value
                     if (!(init instanceof AccessNode ||
                           init instanceof IndexNode ||
                           init instanceof IdentNode)) {
-                        throw error(AbstractParser.message("not.lvalue.for.in.loop"), init.getToken());
+                        throw error(AbstractParser.message("not.lvalue.for.in.loop", isForOf ? "of" : "in"), init.getToken());
                     }
 
                     if (init instanceof IdentNode) {
                         if (!checkIdentLValue((IdentNode)init)) {
-                            throw error(AbstractParser.message("not.lvalue.for.in.loop"), init.getToken());
+                            throw error(AbstractParser.message("not.lvalue.for.in.loop", isForOf ? "of" : "in"), init.getToken());
                         }
-                        verifyStrictIdent((IdentNode)init, "for-in iterator");
+                        verifyStrictIdent((IdentNode)init, isForOf ? "for-of iterator" : "for-in iterator");
                     }
                 }
 
                 next();
 
-                // Get the collection expression.
-                modify = joinPredecessorExpression();
+                // For-of only allows AssignmentExpression.
+                modify = isForOf ? new JoinPredecessorExpression(assignmentExpression(false)) : joinPredecessorExpression();
                 break;
 
             default:
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/JSType.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/JSType.java	Mon Mar 28 08:41:54 2016 -0700
@@ -35,6 +35,7 @@
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
+import jdk.dynalink.SecureLookupSupplier;
 import jdk.dynalink.beans.StaticClass;
 import jdk.nashorn.api.scripting.JSObject;
 import jdk.nashorn.internal.codegen.CompilerConstants.Call;
@@ -175,6 +176,9 @@
     /** Method handle to convert a JS Object to a Java array. */
     public static final Call TO_JAVA_ARRAY = staticCall(JSTYPE_LOOKUP, JSType.class, "toJavaArray", Object.class, Object.class, Class.class);
 
+    /** Method handle to convert a JS Object to a Java array. */
+    public static final Call TO_JAVA_ARRAY_WITH_LOOKUP = staticCall(JSTYPE_LOOKUP, JSType.class, "toJavaArrayWithLookup", Object.class, Object.class, Class.class, SecureLookupSupplier.class);
+
     /** Method handle for void returns. */
     public static final Call VOID_RETURN = staticCall(JSTYPE_LOOKUP, JSType.class, "voidReturn", void.class);
 
@@ -798,7 +802,7 @@
      * @return the value converted to Integer or Double
      */
     public static Number toNarrowestNumber(final long l) {
-        return isRepresentableAsInt(l) ? Integer.valueOf((int) l) : Double.valueOf((double) l);
+        return isRepresentableAsInt(l) ? Integer.valueOf((int) l) : Double.valueOf(l);
     }
 
     /**
@@ -1108,7 +1112,7 @@
      * @return the uint32 value as double
      */
     public static double toUint32Double(final int num) {
-        return (double) toUint32(num);
+        return toUint32(num);
     }
 
     /**
@@ -1319,6 +1323,20 @@
     }
 
     /**
+     * Script object to Java array conversion.
+     *
+     * @param obj script object to be converted to Java array
+     * @param componentType component type of the destination array required
+     * @param lookupSupplier supplier for the lookup of the class invoking the
+     * conversion. Can be used to use protection-domain specific converters
+     * if the target type is a SAM.
+     * @return converted Java array
+     */
+    public static Object toJavaArrayWithLookup(final Object obj, final Class<?> componentType, final SecureLookupSupplier lookupSupplier) {
+        return Bootstrap.getLinkerServices().getWithLookup(()->toJavaArray(obj, componentType), lookupSupplier);
+    }
+
+    /**
      * Java array to java array conversion - but using type conversions implemented by linker.
      *
      * @param src source array
@@ -1744,9 +1762,9 @@
     public static MethodHandle unboxConstant(final Object o) {
         if (o != null) {
             if (o.getClass() == Integer.class) {
-                return MH.constant(int.class, ((Integer)o));
+                return MH.constant(int.class, o);
             } else if (o.getClass() == Double.class) {
-                return MH.constant(double.class, ((Double)o));
+                return MH.constant(double.class, o);
             }
         }
         return MH.constant(Object.class, o);
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunction.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptFunction.java	Mon Mar 28 08:41:54 2016 -0700
@@ -29,6 +29,7 @@
 import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
 import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED;
 import static jdk.nashorn.internal.runtime.UnwarrantedOptimismException.INVALID_PROGRAM_POINT;
+
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.MethodHandles.Lookup;
@@ -45,6 +46,7 @@
 import java.util.List;
 import java.util.concurrent.atomic.LongAdder;
 import jdk.dynalink.CallSiteDescriptor;
+import jdk.dynalink.SecureLookupSupplier;
 import jdk.dynalink.linker.GuardedInvocation;
 import jdk.dynalink.linker.LinkRequest;
 import jdk.dynalink.linker.support.Guards;
@@ -129,7 +131,7 @@
     private static final Object LAZY_PROTOTYPE = new Object();
 
     private static final AccessControlContext GET_LOOKUP_PERMISSION_CONTEXT =
-            AccessControlContextFactory.createAccessControlContext(CallSiteDescriptor.GET_LOOKUP_PERMISSION_NAME);
+            AccessControlContextFactory.createAccessControlContext(SecureLookupSupplier.GET_LOOKUP_PERMISSION_NAME);
 
     private static PropertyMap createStrictModeMap(final PropertyMap map) {
         final int flags = Property.NOT_ENUMERABLE | Property.NOT_CONFIGURABLE;
@@ -955,10 +957,14 @@
                 // It's already (callee, this, args...), just what we need
                 boundHandle = callHandle;
             }
-        } else if (data.isBuiltin() && "extend".equals(data.getName())) {
-            // NOTE: the only built-in named "extend" is NativeJava.extend. As a special-case we're binding the
-            // current lookup as its "this" so it can do security-sensitive creation of adapter classes.
+        } else if (data.isBuiltin() && Global.isBuiltInJavaExtend(this)) {
+            // We're binding the current lookup as "self" so the function can do
+            // security-sensitive creation of adapter classes.
             boundHandle = MH.dropArguments(MH.bindTo(callHandle, getLookupPrivileged(desc)), 0, type.parameterType(0), type.parameterType(1));
+        } else if (data.isBuiltin() && Global.isBuiltInJavaTo(this)) {
+            // We're binding the current call site descriptor as "self" so the function can do
+            // security-sensitive creation of adapter classes.
+            boundHandle = MH.dropArguments(MH.bindTo(callHandle, desc), 0, type.parameterType(0), type.parameterType(1));
         } else if (scopeCall && needsWrappedThis()) {
             // Make a handle that drops the passed "this" argument and substitutes either Global or Undefined
             // (this, args...) => ([this], args...)
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptRuntime.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptRuntime.java	Mon Mar 28 08:41:54 2016 -0700
@@ -52,10 +52,12 @@
 import jdk.nashorn.internal.codegen.CompilerConstants;
 import jdk.nashorn.internal.codegen.CompilerConstants.Call;
 import jdk.nashorn.internal.ir.debug.JSONWriter;
+import jdk.nashorn.internal.objects.AbstractIterator;
 import jdk.nashorn.internal.objects.Global;
 import jdk.nashorn.internal.objects.NativeObject;
 import jdk.nashorn.internal.parser.Lexer;
 import jdk.nashorn.internal.runtime.linker.Bootstrap;
+import jdk.nashorn.internal.runtime.linker.InvokeByName;
 
 /**
  * Utilities to be called by JavaScript runtime API and generated classes.
@@ -103,6 +105,11 @@
     public static final Call TO_VALUE_ITERATOR = staticCallNoLookup(ScriptRuntime.class, "toValueIterator", Iterator.class, Object.class);
 
     /**
+     * Return an appropriate iterator for the elements in a ES6 for-of loop
+     */
+    public static final Call TO_ES6_ITERATOR = staticCallNoLookup(ScriptRuntime.class, "toES6Iterator", Iterator.class, Object.class);
+
+    /**
       * Method handle for apply. Used from {@link ScriptFunction} for looking up calls to
       * call sites that are known to be megamorphic. Using an invoke dynamic here would
       * lead to the JVM deoptimizing itself to death
@@ -366,6 +373,77 @@
     }
 
     /**
+     * Returns an iterator over property values used in the {@code for ... of} statement. The iterator uses the
+     * Iterator interface defined in version 6 of the ECMAScript specification.
+     *
+     * @param obj object to iterate on.
+     * @return iterator based on the ECMA 6 Iterator interface.
+     */
+    public static Iterator<?> toES6Iterator(final Object obj) {
+        final Global global = Global.instance();
+        final Object iterator = AbstractIterator.getIterator(Global.toObject(obj), global);
+
+        final InvokeByName nextInvoker = AbstractIterator.getNextInvoker(global);
+        final MethodHandle doneInvoker = AbstractIterator.getDoneInvoker(global);
+        final MethodHandle valueInvoker = AbstractIterator.getValueInvoker(global);
+
+        return new Iterator<Object>() {
+
+            private Object nextResult = nextResult();
+
+            private Object nextResult() {
+                try {
+                    final Object next = nextInvoker.getGetter().invokeExact(iterator);
+                    if (Bootstrap.isCallable(next)) {
+                        return nextInvoker.getInvoker().invokeExact(next, iterator, (Object) null);
+                    }
+                } catch (final RuntimeException|Error r) {
+                    throw r;
+                } catch (final Throwable t) {
+                    throw new RuntimeException(t);
+                }
+                return null;
+            }
+
+            @Override
+            public boolean hasNext() {
+                if (nextResult == null) {
+                    return false;
+                }
+                try {
+                    final Object done = doneInvoker.invokeExact(nextResult);
+                    return !JSType.toBoolean(done);
+                } catch (final RuntimeException|Error r) {
+                    throw r;
+                } catch (final Throwable t) {
+                    throw new RuntimeException(t);
+                }
+            }
+
+            @Override
+            public Object next() {
+                if (nextResult == null) {
+                    return Undefined.getUndefined();
+                }
+                try {
+                    final Object result = nextResult;
+                    nextResult = nextResult();
+                    return valueInvoker.invokeExact(result);
+                } catch (final RuntimeException|Error r) {
+                    throw r;
+                } catch (final Throwable t) {
+                    throw new RuntimeException(t);
+                }
+            }
+
+            @Override
+            public void remove() {
+                throw new UnsupportedOperationException("remove");
+            }
+        };
+    }
+
+    /**
      * Merge a scope into its prototype's map.
      * Merge a scope into its prototype.
      *
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/SetMethodCreator.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/SetMethodCreator.java	Mon Mar 28 08:41:54 2016 -0700
@@ -145,8 +145,7 @@
         final boolean isStrict  = NashornCallSiteDescriptor.isStrict(desc);
         final MethodHandle methodHandle;
 
-        if (NashornCallSiteDescriptor.isDeclaration(desc)) {
-            assert property.needsDeclaration();
+        if (NashornCallSiteDescriptor.isDeclaration(desc) && property.needsDeclaration()) {
             // This is a LET or CONST being declared. The property is already there but flagged as needing declaration.
             // We create a new PropertyMap with the flag removed. The map is installed with a fast compare-and-set
             // method if the pre-callsite map is stable (which should be the case for function scopes except for
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornBeansLinker.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornBeansLinker.java	Mon Mar 28 08:41:54 2016 -0700
@@ -32,8 +32,10 @@
 import java.lang.invoke.MethodType;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
+import java.util.function.Supplier;
 import jdk.dynalink.CallSiteDescriptor;
 import jdk.dynalink.NamedOperation;
+import jdk.dynalink.SecureLookupSupplier;
 import jdk.dynalink.StandardOperation;
 import jdk.dynalink.beans.BeansLinker;
 import jdk.dynalink.linker.ConversionComparator.Comparison;
@@ -153,7 +155,7 @@
         if (arg instanceof ConsString) {
             return arg.toString();
         } else if (mirrorAlways && arg instanceof ScriptObject) {
-            return ScriptUtils.wrap((ScriptObject)arg);
+            return ScriptUtils.wrap(arg);
         } else {
             return arg;
         }
@@ -250,5 +252,10 @@
         public MethodHandle filterInternalObjects(final MethodHandle target) {
             return linkerServices.filterInternalObjects(target);
         }
+
+        @Override
+        public <T> T getWithLookup(final Supplier<T> operation, final SecureLookupSupplier lookupSupplier) {
+            return linkerServices.getWithLookup(operation, lookupSupplier);
+        }
     }
 }
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornCallSiteDescriptor.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornCallSiteDescriptor.java	Mon Mar 28 08:41:54 2016 -0700
@@ -43,6 +43,7 @@
 import jdk.dynalink.CompositeOperation;
 import jdk.dynalink.NamedOperation;
 import jdk.dynalink.Operation;
+import jdk.dynalink.SecureLookupSupplier;
 import jdk.dynalink.StandardOperation;
 import jdk.nashorn.internal.ir.debug.NashornTextifier;
 import jdk.nashorn.internal.runtime.AccessControlContextFactory;
@@ -161,7 +162,7 @@
     };
 
     private static final AccessControlContext GET_LOOKUP_PERMISSION_CONTEXT =
-            AccessControlContextFactory.createAccessControlContext(CallSiteDescriptor.GET_LOOKUP_PERMISSION_NAME);
+            AccessControlContextFactory.createAccessControlContext(SecureLookupSupplier.GET_LOOKUP_PERMISSION_NAME);
 
     @SuppressWarnings("unchecked")
     private static final Map<String, Reference<NamedOperation>>[] NAMED_OPERATIONS =
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornLinker.java	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornLinker.java	Mon Mar 28 08:41:54 2016 -0700
@@ -42,6 +42,7 @@
 import java.util.function.Supplier;
 import javax.script.Bindings;
 import jdk.dynalink.CallSiteDescriptor;
+import jdk.dynalink.SecureLookupSupplier;
 import jdk.dynalink.linker.ConversionComparator;
 import jdk.dynalink.linker.GuardedInvocation;
 import jdk.dynalink.linker.GuardingTypeConverterFactory;
@@ -53,6 +54,7 @@
 import jdk.nashorn.api.scripting.JSObject;
 import jdk.nashorn.api.scripting.ScriptObjectMirror;
 import jdk.nashorn.api.scripting.ScriptUtils;
+import jdk.nashorn.internal.codegen.CompilerConstants.Call;
 import jdk.nashorn.internal.objects.NativeArray;
 import jdk.nashorn.internal.runtime.AccessControlContextFactory;
 import jdk.nashorn.internal.runtime.JSType;
@@ -67,7 +69,7 @@
  */
 final class NashornLinker implements TypeBasedGuardingDynamicLinker, GuardingTypeConverterFactory, ConversionComparator {
     private static final AccessControlContext GET_LOOKUP_PERMISSION_CONTEXT =
-            AccessControlContextFactory.createAccessControlContext(CallSiteDescriptor.GET_LOOKUP_PERMISSION_NAME);
+            AccessControlContextFactory.createAccessControlContext(SecureLookupSupplier.GET_LOOKUP_PERMISSION_NAME);
 
     private static final ClassValue<MethodHandle> ARRAY_CONVERTERS = new ClassValue<MethodHandle>() {
         @Override
@@ -111,7 +113,7 @@
 
     @Override
     public GuardedInvocation convertToType(final Class<?> sourceType, final Class<?> targetType, final Supplier<MethodHandles.Lookup> lookupSupplier) throws Exception {
-        GuardedInvocation gi = convertToTypeNoCast(sourceType, targetType);
+        GuardedInvocation gi = convertToTypeNoCast(sourceType, targetType, lookupSupplier);
         if(gi == null) {
             gi = getSamTypeConverter(sourceType, targetType, lookupSupplier);
         }
@@ -128,13 +130,13 @@
      * @return a guarded invocation that converts from the source type to the target type.
      * @throws Exception if something goes wrong
      */
-    private static GuardedInvocation convertToTypeNoCast(final Class<?> sourceType, final Class<?> targetType) throws Exception {
+    private static GuardedInvocation convertToTypeNoCast(final Class<?> sourceType, final Class<?> targetType, final Supplier<MethodHandles.Lookup> lookupSupplier) throws Exception {
         final MethodHandle mh = JavaArgumentConverters.getConverter(targetType);
         if (mh != null) {
             return new GuardedInvocation(mh, canLinkTypeStatic(sourceType) ? null : IS_NASHORN_OR_UNDEFINED_TYPE);
         }
 
-        final GuardedInvocation arrayConverter = getArrayConverter(sourceType, targetType);
+        final GuardedInvocation arrayConverter = getArrayConverter(sourceType, targetType, lookupSupplier);
         if(arrayConverter != null) {
             return arrayConverter;
         }
@@ -183,7 +185,7 @@
      * either the source type is neither NativeArray, nor a superclass of it, or if the target type is not an array
      * type, List, Queue, Deque, or Collection.
      */
-    private static GuardedInvocation getArrayConverter(final Class<?> sourceType, final Class<?> targetType) {
+    private static GuardedInvocation getArrayConverter(final Class<?> sourceType, final Class<?> targetType, final Supplier<MethodHandles.Lookup> lookupSupplier) {
         final boolean isSourceTypeNativeArray = sourceType == NativeArray.class;
         // If source type is more generic than NativeArray class, we'll need to use a guard
         final boolean isSourceTypeGeneric = !isSourceTypeNativeArray && sourceType.isAssignableFrom(NativeArray.class);
@@ -191,7 +193,25 @@
         if (isSourceTypeNativeArray || isSourceTypeGeneric) {
             final MethodHandle guard = isSourceTypeGeneric ? IS_NATIVE_ARRAY : null;
             if(targetType.isArray()) {
-                return new GuardedInvocation(ARRAY_CONVERTERS.get(targetType), guard);
+                final MethodHandle mh = ARRAY_CONVERTERS.get(targetType);
+                final MethodHandle mhWithLookup;
+                if (mh.type().parameterCount() == 2) {
+                    assert mh.type().parameterType(1) == SecureLookupSupplier.class;
+                    // We enter this branch when the array's ultimate component
+                    // type is a SAM type; we use a handle to JSType.toJavaArrayWithLookup
+                    // for these in the converter MH and must bind it here with
+                    // a secure supplier for the current lookup. By retrieving
+                    // the lookup, we'll also (correctly) inform the type
+                    // converter that this array converter is lookup specific.
+                    // We then need to wrap the returned lookup into a
+                    // new SecureLookupSupplier in order to bind it to the
+                    // JSType.toJavaArrayWithLookup() parameter.
+                    mhWithLookup = MH.insertArguments(mh, 1,
+                            new SecureLookupSupplier(getCurrentLookup(lookupSupplier)));
+                } else {
+                    mhWithLookup = mh;
+                }
+                return new GuardedInvocation(mhWithLookup, guard);
             } else if(targetType == List.class) {
                 return new GuardedInvocation(TO_LIST, guard);
             } else if(targetType == Deque.class) {
@@ -207,8 +227,24 @@
 
     private static MethodHandle createArrayConverter(final Class<?> type) {
         assert type.isArray();
-        final MethodHandle converter = MH.insertArguments(JSType.TO_JAVA_ARRAY.methodHandle(), 1, type.getComponentType());
-        return MH.asType(converter, converter.type().changeReturnType(type));
+
+        final Class<?> componentType = type.getComponentType();
+        final Call converterCall;
+        // Is the ultimate component type of this array a SAM type?
+        if (isComponentTypeAutoConvertibleFromFunction(componentType)) {
+            converterCall = JSType.TO_JAVA_ARRAY_WITH_LOOKUP;
+        } else {
+            converterCall = JSType.TO_JAVA_ARRAY;
+        }
+        final MethodHandle typeBoundConverter = MH.insertArguments(converterCall.methodHandle(), 1, componentType);
+        return MH.asType(typeBoundConverter, typeBoundConverter.type().changeReturnType(type));
+    }
+
+    private static boolean isComponentTypeAutoConvertibleFromFunction(final Class<?> targetType) {
+        if (targetType.isArray()) {
+            return isComponentTypeAutoConvertibleFromFunction(targetType.getComponentType());
+        }
+        return isAutoConvertibleFromFunction(targetType);
     }
 
     private static GuardedInvocation getMirrorConverter(final Class<?> sourceType, final Class<?> targetType) {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/Messages.properties	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/Messages.properties	Mon Mar 28 08:41:54 2016 -0700
@@ -52,8 +52,9 @@
 parser.error.property.redefinition=Property "{0}" already defined
 parser.error.unexpected.token=Unexpected token: {0}
 parser.error.for.each.without.in=for each can only be used with for..in
-parser.error.many.vars.in.for.in.loop=Only one variable allowed in for..in loop
-parser.error.not.lvalue.for.in.loop=Invalid left side value of for..in loop
+parser.error.many.vars.in.for.in.loop=Only one variable allowed in for..{0} loop
+parser.error.not.lvalue.for.in.loop=Invalid left side value of for..{0} loop
+parser.error.for.in.loop.initializer=for..{0] loop declaration must not have an initializer
 parser.error.missing.catch.or.finally=Missing catch or finally after try
 parser.error.regex.unsupported.flag=Unsupported RegExp flag: {0}
 parser.error.regex.repeated.flag=Repeated RegExp flag: {0}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8150218.js	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8150218: Autoconversion SAM adapters sometimes don't get privileges
+ *
+ * @test
+ * @run
+ */
+
+function f() {
+    java.lang.System.getProperty("user.dir")
+}
+
+java.security.AccessController.doPrivileged(new java.security.PrivilegedAction(function () {
+    // Control: this used to work even before this improvement
+    new java.lang.Runnable(f).run()
+
+    // SAM type explicitly created through an array needs to get the right permissions too
+    Java.to([f], Java.type("java.lang.Runnable[]"))[0].run()
+
+    // Even when more deeply nested
+    Java.to([[[f]]], Java.type("java.lang.Runnable[][][]"))[0][0][0].run()
+
+    var rt = new (Java.type("jdk.dynalink.test.ArrayRunnableTest"))
+    var n = "runnables"
+
+    // Explicit array passed to vararg setter chosen at run time
+    rt[n] = [f]
+    rt.firstRunnable.run()
+
+    // Automatically packed one-element array passed to vararg setter chosen at run time
+    rt[n] = f
+    rt.firstRunnable.run()
+
+    // Explicit array passed to vararg method overload chosen at run time
+    rt.setRunnablesOverloaded([f])
+    rt.firstRunnable.run()
+
+    // Automatically packed one-element array passed to vararg method overload chosen at run time
+    rt.setRunnablesOverloaded(f)
+    rt.firstRunnable.run()
+}))
--- a/nashorn/test/script/basic/es6.js	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/test/script/basic/es6.js	Mon Mar 28 08:41:54 2016 -0700
@@ -64,3 +64,8 @@
 expectError('`${ x }`', 'template literal', 'SyntaxError');
 expectError('`text ${ x } text`', 'template literal', 'SyntaxError');
 expectError('f`text`', 'template literal', 'SyntaxError');
+expectError('for (a of [1, 2, 3]) print(a)', 'for-of', 'SyntaxError');
+expectError('for (var a of [1, 2, 3]) print(a)', 'for-of', 'SyntaxError');
+expectError('for (let a of [1, 2, 3]) print(a)', 'for-of', 'SyntaxError');
+expectError('for (const a of [1, 2, 3]) print(a)', 'for-of', 'SyntaxError');
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/es6/JDK-8151809.js	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8151809: ES6 Map/Set insertion with existing keys changes iteration order
+ *
+ * @test
+ * @run
+ * @option --language=es6
+ */
+
+function assertSetIteratorResult(result, expectedDone, expectedValue) {
+    Assert.assertEquals(result.done, expectedDone);
+    Assert.assertEquals(result.value, expectedValue);
+}
+
+function assertMapIteratorResult(result, expectedDone, expectedKey, expectedValue) {
+    Assert.assertEquals(result.done, expectedDone);
+    if (expectedDone) {
+        Assert.assertEquals(result.value, undefined);
+    } else {
+        Assert.assertEquals(result.value[0], expectedKey);
+        Assert.assertEquals(result.value[1], expectedValue);
+    }
+}
+
+let set = new Set(["foo", "bar", "foo"]);
+let iter = set[Symbol.iterator]();
+assertSetIteratorResult(iter.next(), false, "foo");
+assertSetIteratorResult(iter.next(), false, "bar");
+assertSetIteratorResult(iter.next(), true);
+
+set.add ("foo");
+iter = set[Symbol.iterator]();
+assertSetIteratorResult(iter.next(), false, "foo", false);
+assertSetIteratorResult(iter.next(), false, "bar", false);
+assertSetIteratorResult(iter.next(), true);
+
+set.delete("foo");
+set.add ("foo");
+assertSetIteratorResult(iter.next(), true);
+iter = set[Symbol.iterator]();
+assertSetIteratorResult(iter.next(), false, "bar", false);
+assertSetIteratorResult(iter.next(), false, "foo", false);
+assertSetIteratorResult(iter.next(), true);
+
+
+let map = new Map([["foo", 1], ["bar", 2], ["foo", 3]]);
+iter = map[Symbol.iterator]();
+assertMapIteratorResult(iter.next(), false, "foo", 3);
+assertMapIteratorResult(iter.next(), false, "bar", 2);
+assertMapIteratorResult(iter.next(), true);
+
+
+map.set("foo", 4);
+iter = map[Symbol.iterator]();
+assertMapIteratorResult(iter.next(), false, "foo", 4);
+assertMapIteratorResult(iter.next(), false, "bar", 2);
+assertMapIteratorResult(iter.next(), true);
+
+map.delete("foo");
+map.set("foo", 5);
+assertMapIteratorResult(iter.next(), true);
+iter = map[Symbol.iterator]();
+assertMapIteratorResult(iter.next(), false, "bar", 2);
+assertMapIteratorResult(iter.next(), false, "foo", 5);
+assertMapIteratorResult(iter.next(), true);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/es6/JDK-8151810.js	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8151810: for-in iteration does not provide per-iteration scope
+ *
+ * @test
+ * @run
+ * @option --language=es6
+ */
+
+"use strict";
+
+let array = ["a", "b", "c"];
+let funcs = [];
+
+for (let i in array) {
+    funcs.push(function() { return array[i]; });
+}
+
+Assert.assertEquals(funcs.length, 3);
+
+for (let i = 0; i < 3; i++) {
+    Assert.assertEquals(funcs[i](), array[i]);
+}
+
+funcs = [];
+
+for (let i in array) {
+    for (let j in array) {
+        for (let k in array) {
+            funcs.push(function () {
+                return array[i] + array[j] + array[k];
+            });
+        }
+    }
+}
+
+Assert.assertEquals(funcs.length, 3 * 3 * 3);
+let count = 0;
+
+for (let i = 0; i < 3; i++) {
+    for (let j = 0; j < 3; j++) {
+        for (let k = 0; k < 3; k++) {
+            Assert.assertEquals(funcs[count++](), array[i] + array[j] + array[k]);
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/es6/JDK-8151811.js	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8151811: Const declarations do not work in for..in loops
+ *
+ * @test
+ * @run
+ * @option --language=es6
+ */
+
+let array = ["a", "b", "c"];
+let count = 0;
+
+for (const i in array) {
+    try {
+        eval("i = 5");
+        fail("const assignment should have thrown")
+    } catch (e) {
+        Assert.assertTrue(e instanceof TypeError);
+    }
+    Assert.assertTrue(i == count++);
+}
+
+let funcs = [];
+
+for (const i in array) {
+    try {
+        eval("i = 5");
+        fail("const assignment should have thrown")
+    } catch (e) {
+        Assert.assertTrue(e instanceof TypeError);
+    }
+    for (const j in array) {
+        for (const k in array) {
+            funcs.push(function () {
+                return array[i] + array[j] + array[k];
+            });
+        }
+    }
+}
+
+Assert.assertEquals(funcs.length, 3 * 3 * 3);
+count = 0;
+
+for (let i = 0; i < 3; i++) {
+    for (let j = 0; j < 3; j++) {
+        for (let k = 0; k < 3; k++) {
+            Assert.assertEquals(funcs[count++](), array[i] + array[j] + array[k]);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/es6/for-of.js	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,196 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8151700: Add support for ES6 for-of
+ *
+ * @test
+ * @run
+ * @option --language=es6
+ */
+
+let result = "";
+for (let a of [1, 2, "foo"]) {
+    result += a;
+}
+
+if (result !== "12foo") {
+    throw new Error("unexpcected result: " + result);
+}
+
+let sum = 0;
+let numbers = [1, 2, 3, 4];
+numbers.ten = 10; // not iterated over
+
+for (let n of numbers) {
+    sum += n;
+}
+
+if (sum !== 10) {
+    throw new Error("unexpected sum: " + sum);;
+}
+
+if (typeof n !== "undefined") {
+    throw new Error("n is visible outside of for-of");
+}
+
+let message = "Hello";
+result = "";
+
+for(const c of message) {
+    result += c;
+}
+
+if (result !== "Hello") {
+    throw new Error("unexpected result: " + result);
+}
+
+if (typeof c !== "undefined") {
+    throw new Error("c is visible outside of for-of")
+}
+
+// Callbacks with per-iteration scope
+
+result = "";
+let funcs = [];
+
+for (let a of [1, 2, "foo"]) {
+    funcs.push(function() { result += a; });
+}
+
+funcs.forEach(function(f) { f(); });
+if (result !== "12foo") {
+    throw new Error("unexpcected result: " + result);
+}
+
+result = "";
+funcs = [];
+
+for (const a of [1, 2, "foo"]) {
+    funcs.push(function() { result += a; });
+}
+
+funcs.forEach(function(f) { f(); });
+if (result !== "12foo") {
+    throw new Error("unexpcected result: " + result);
+}
+
+// Set
+var set = new Set(["foo", "bar", "foo"]);
+result = "";
+
+for (var w of set) {
+    result += w;
+}
+
+if (result !== "foobar") {
+    throw new Error("unexpected result: " + result);
+}
+
+// Maps
+var map = new Map([["a", 1], ["b", 2]]);
+result = "";
+
+for (var entry of map) {
+    result += entry;
+}
+
+if (result !== "a,1b,2") {
+    throw new Error("unexpected result: " + result);
+}
+
+// per-iteration scope
+
+let array = ["a", "b", "c"];
+funcs = [];
+
+for (let i of array) {
+    for (let j of array) {
+        for (let k of array) {
+            funcs.push(function () {
+                return i + j + k;
+            });
+        }
+    }
+}
+
+Assert.assertEquals(funcs.length, 3 * 3 * 3);
+let count = 0;
+
+for (let i = 0; i < 3; i++) {
+    for (let j = 0; j < 3; j++) {
+        for (let k = 0; k < 3; k++) {
+            Assert.assertEquals(funcs[count++](), array[i] + array[j] + array[k]);
+        }
+    }
+}
+
+// per-iteration scope with const declaration
+
+funcs = [];
+
+for (const i of array) {
+    for (const j of array) {
+        for (const k of array) {
+            funcs.push(function () {
+                return i + j + k;
+            });
+        }
+    }
+}
+
+Assert.assertEquals(funcs.length, 3 * 3 * 3);
+count = 0;
+
+for (let i = 0; i < 3; i++) {
+    for (let j = 0; j < 3; j++) {
+        for (let k = 0; k < 3; k++) {
+            Assert.assertEquals(funcs[count++](), array[i] + array[j] + array[k]);
+        }
+    }
+}
+
+// fibonacci iterator
+
+let fibonacci = {};
+
+fibonacci[Symbol.iterator] = function() {
+    let previous = 0, current = 1;
+    return {
+        next: function() {
+            let tmp = current;
+            current = previous + current;
+            previous = tmp;
+            return { done: false, value: current };
+        }
+    }
+};
+
+for (f of fibonacci) {
+    if (f > 100000) {
+        break;
+    }
+}
+
+Assert.assertTrue(f === 121393);
+
--- a/nashorn/test/script/nosecurity/JDK-8144221.js	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/test/script/nosecurity/JDK-8144221.js	Mon Mar 28 08:41:54 2016 -0700
@@ -26,7 +26,7 @@
  *
  * @test
  * @option -scripting
- * @run
+ * @runif os.not.windows.cmd
  */
 
 // The test generates three different JavaScript source files. The first two
--- a/nashorn/test/script/nosecurity/JDK-8151291.js	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/test/script/nosecurity/JDK-8151291.js	Mon Mar 28 08:41:54 2016 -0700
@@ -27,7 +27,7 @@
  *
  * @test
  * @option -scripting
- * @run
+ * @runif os.not.windows.cmd
  */
 
 $EXEC(["java", "-version"])
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/nosecurity/JDK-util.js	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * This file contains utility functions used by other tests.
+ * @subtest
+ */
+
+var Files = Java.type('java.nio.file.Files'),
+    Paths = Java.type('java.nio.file.Paths'),
+    System = Java.type('java.lang.System')
+
+var File = java.io.File
+var windows = System.getProperty("os.name").startsWith("Windows")
+var winCyg = false
+
+var outPath = {
+    windows:0, //C:\dir
+    mixed:1    //C:/dir
+}
+
+if (windows) {
+    //Is there any better way to diffrentiate between cygwin/command prompt on windows
+    var term = System.getenv("TERM")
+    winCyg = term ? true:false
+}
+
+/**
+ * Returns which command is selected from PATH
+ * @param cmd name of the command searched from PATH
+ */
+function which(cmd) {
+    var path = System.getenv("PATH")
+    var st = new java.util.StringTokenizer(path, File.pathSeparator)
+    while (st.hasMoreTokens()) {
+        var file = new File(st.nextToken(), cmd)
+        if (file.exists()) {
+            return (file.getAbsolutePath())
+        }
+    }
+}
+
+/**
+ * Removes a given file
+ * @param pathname name of the file
+ */
+function rm(pathname) {
+    var Path = Paths.get(pathname)
+    if (!Files.deleteIfExists(Path))
+        print("File \"${pathname}\" doesn't exist")
+}
+    
+
+
+/**
+ * Unix cygpath implementation
+ * Supports only two outputs,windows(C:\dir\) and mixed(C:/dir/)
+ */
+function cygpath(path,mode) {
+   
+    var newpath = path
+    if(path.startsWith("/cygdrive/")){
+        var str = path.substring(10)
+        var index = str.indexOf('/',0)
+        var drv = str.substring(0,index)
+        var rstr = drv.toUpperCase() + ":"
+        newpath = str.replaceFirst(drv,rstr)
+    }
+    if (mode == outPath.windows)
+        return Paths.get(newpath).toString()
+    else {
+        newpath = newpath.replaceAll('\\\\','/')
+        return newpath
+    }                   
+
+}
+
+/**
+ * convert given path based on underlying shell programme runs on
+ */
+function toShellPath(path) {
+    if (windows) {
+        if (winCyg) {
+            return cygpath(path,outPath.mixed)
+        }else {
+         var path = cygpath(path,outPath.windows)
+         //convert '\' ->'\\',cmd shell expects this.
+         return path.replaceAll('\\\\','\\\\\\\\')
+       }
+    }else {
+        return path
+    }
+} 
+
--- a/nashorn/test/script/nosecurity/jjs-common.js	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/test/script/nosecurity/jjs-common.js	Mon Mar 28 08:41:54 2016 -0700
@@ -26,15 +26,29 @@
  * @subtest
  * @summary test used by all other jjs-option* test cases
  */
-var javaHome = $ENV.JAVA_HOME,
-    homeJjs = "${javaHome}/bin/jjs",
-    altJjs = $EXEC('which jjs').trim(),
-    homejavac = "${javaHome}/bin/javac",
-    altjavac = $EXEC('which javac').trim()
+
+load(__DIR__ + "JDK-util.js")
+
+var javaHome = System.getenv("JAVA_HOME"),
+    homeJjs = "${javaHome}" + "/bin/jjs",
+    altJjs = which('jjs'),
+    homejavac = "${javaHome}" + "/bin/javac",
+    altjavac = which('javac')
 
-var Files = Java.type('java.nio.file.Files'),
-    Paths = Java.type('java.nio.file.Paths'),
-    System = Java.type('java.lang.System')
+if (windows) {
+    if (winCyg) {
+        //Files.exists() expects proper extension as it talks to windows filesystem even on cygwin
+        //make paths work on on underlying shells cygwin/cmd/linux.
+        homeJjs = toShellPath("${javaHome}" + "/bin/jjs.exe")
+        homejavac = toShellPath("${javaHome}" + "/bin/javac.exe")
+    }
+    else {
+        homeJjs = toShellPath("${javaHome}" + "\\bin\\jjs.exe")
+        homejavac = toShellPath("${javaHome}" + "\\bin\\javac.exe")
+    }
+    altJjs = which('jjs.exe')
+    altjavac = which('javac.exe')
+}
 
 // Initialize default values for variables used in different functions
 var func_cond_p = <<EOD
@@ -62,12 +76,11 @@
 
 // create file to check -flag passing
 var path_f = Paths.get("temp-flag.js")
-var testflag_file = path_f.toAbsolutePath()
+var testflag_file = toShellPath(path_f.toAbsolutePath().toString())
 
 // create file to check -flag functionality
 var path_func = Paths.get("temp-func.js")
-var testfunc_file = path_func.toAbsolutePath()
-
+var testfunc_file = toShellPath(path_func.toAbsolutePath().toString())
 
 function exists(f) {
     return Files.exists(Paths.get(f))
@@ -82,12 +95,12 @@
 
 // write code to testflag_file
 function write_testflag_file() {
-    Files.write(testflag_file, msg_flag.getBytes())
+    Files.write(Paths.get(testflag_file), msg_flag.getBytes())
 }
 
 // write code to testfunc_file
 function write_testfunc_file() {
-    Files.write(testfunc_file, msg_func.getBytes())
+    Files.write(Paths.get(testfunc_file), msg_func.getBytes())
 }
 
 function flag_test_pass() {
@@ -106,7 +119,7 @@
     if (positive) {
         if (eval(func_cond_p))
             print("functionality test PASSED")
-        else
+        else 
             print("functionality test FAILED. stdout: ${out} -- stderr: ${err}")
     }
     else {
@@ -156,8 +169,8 @@
         print("${flag} flag negative test:")
         testjjs_opt("${args_n} ${testflag_file}", false, true)        // negative test
     } finally {
-        $EXEC("rm ${testflag_file}")
-        $EXEC("rm ${testfunc_file}")
+        rm("${testflag_file}")
+        rm("${testfunc_file}")
     }
 }
 
@@ -171,7 +184,7 @@
         print("${flag} flag negative test:")
         testjjs_opt_func("${args_n} ${testfunc_file}", false)        // negative test
     } finally {
-        $EXEC("rm ${testfunc_file}")
+        rm("${testfunc_file}")
     }
 }
 
@@ -185,6 +198,6 @@
         print("${flag} flag negative test:")
         testjjs_opt("${args_n} ${testflag_file}", false, false)        // negative test
     } finally {
-        $EXEC("rm ${testflag_file}")
+        rm("${testflag_file}")
     }
 }
--- a/nashorn/test/script/nosecurity/jjs-option-cp.js	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/test/script/nosecurity/jjs-option-cp.js	Mon Mar 28 08:41:54 2016 -0700
@@ -25,37 +25,44 @@
  * JDK-8144113: Nashorn: enable jjs testing. 
  * @test
  * @option -scripting
- * @runif os.not.windows
  * @run
  * @summary Test to check if -cp flag and its basic functionality
  */
 
 load(__DIR__ + "jjs-common.js")
 
-var hello = __DIR__ + "Hello.class";
-var helloj = __DIR__ + "Hello.java";
+var hello = __DIR__ + "Hello.class"
+var helloj = __DIR__ + "Hello.java"
+
+hello = toShellPath(hello)
+helloj = toShellPath(helloj)
 
 // code to check -flag
 var msg_flag = "print($OPTIONS._classpath)"
 
 // code to check basic functionality
 var msg_func = <<EOD
-$EXEC("rm -f ${hello}")
+var Files = Java.type('java.nio.file.Files')
+var Paths = Java.type('java.nio.file.Paths')
+Files.deleteIfExists(Paths.get("${hello}"))
 $EXEC("${javac} ${helloj}")
-var v = new Packages.Hello();
+var v = new Packages.Hello()
 if (v.string != 'hello') {
-    throw new Error("Unexpected property value");
+    throw new Error("Unexpected property value")
 }
 EOD
 
+var dir = toShellPath(__DIR__)
+
 // flag test expected output variables
-var e_outp = "__DIR__"
+var e_outp = "${dir}"
 var e_outn = "null"
 
 // functionality test arguments
-var arg_p = "-scripting -cp ${__DIR__}  ${testfunc_file}"
+var arg_p = "-scripting -cp ${dir}  ${testfunc_file}"
 var arg_n = "-scripting ${testfunc_file}"
 
 // Testing starts here
-testjjs_flag_and_func("-cp", " __DIR__")
-$EXEC("rm -f ${hello}")
+testjjs_flag_and_func("-cp", " ${dir}")
+rm("${hello}")
+
--- a/nashorn/test/script/nosecurity/jjs-option-define.js	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/test/script/nosecurity/jjs-option-define.js	Mon Mar 28 08:41:54 2016 -0700
@@ -25,7 +25,6 @@
  * JDK-8144113: Nashorn: enable jjs testing. 
  * @test
  * @option -scripting
- * @runif os.not.windows
  * @run
  * @summary Test to check -D flag basic functionality
  */
@@ -38,7 +37,7 @@
 // code to check basic functionality
 var msg_func = <<EOD
 try {
-    var System = Java.type('java.lang.System');
+    var System = Java.type('java.lang.System')
     print(System.getProperty('user.name'))
     if (System.getProperty('user.name') != "nashorn9")
         throw new Error("un expected system property user.name value")
--- a/nashorn/test/script/nosecurity/jjs-option-doe.js	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/test/script/nosecurity/jjs-option-doe.js	Mon Mar 28 08:41:54 2016 -0700
@@ -25,7 +25,6 @@
  * JDK-8144113: Nashorn: enable jjs testing. 
  * @test
  * @option -scripting
- * @runif os.not.windows
  * @run
  * @summary Test -doe flag and its basic functionality
  */
--- a/nashorn/test/script/nosecurity/jjs-option-fv.js	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/test/script/nosecurity/jjs-option-fv.js	Mon Mar 28 08:41:54 2016 -0700
@@ -25,7 +25,6 @@
  * JDK-8144113: Nashorn: enable jjs testing. 
  * @test
  * @option -scripting
- * @runif os.not.windows
  * @run
  * @summary Test if -fv flag its basic funnctionality
  */
--- a/nashorn/test/script/nosecurity/jjs-option-fx.js	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/test/script/nosecurity/jjs-option-fx.js	Mon Mar 28 08:41:54 2016 -0700
@@ -26,7 +26,6 @@
  * check -fx option.
  * @test
  * @option -scripting
- * @runif os.not.windows
  * @run
  * @summary Test -fx flag and its basic functionality
  * the JavaFX primary stage is available to Nashorn as a global property $STAGE with -fx
@@ -35,7 +34,7 @@
 
 load(__DIR__ + "jjs-common.js")
 
-var msg_flag = "print(typeof($STAGE)); exit();";
+var msg_flag = "print(typeof($STAGE)); exit();"
 
 // flag test expected output variables
 var e_outn = "undefined"
--- a/nashorn/test/script/nosecurity/jjs-option-lang.js	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/test/script/nosecurity/jjs-option-lang.js	Mon Mar 28 08:41:54 2016 -0700
@@ -25,7 +25,6 @@
  * JDK-8144113: Nashorn: enable jjs testing. 
  * @test
  * @option -scripting
- * @runif os.not.windows
  * @run
  * @summary Test -lang flag and its basic functionality
  */
--- a/nashorn/test/script/nosecurity/jjs-option-ot.js	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/test/script/nosecurity/jjs-option-ot.js	Mon Mar 28 08:41:54 2016 -0700
@@ -25,7 +25,6 @@
  * JDK-8144113: Nashorn: enable jjs testing. 
  * @test
  * @option -scripting
- * @runif os.not.windows
  * @run
  * @summary Test -ot flag
  */
@@ -33,7 +32,7 @@
 load(__DIR__ + "jjs-common.js")
 
 var args_n = "-scripting -ot=false"
-var msg_flag = "print($OPTIONS._optimistic_types);";
+var msg_flag = "print($OPTIONS._optimistic_types)"
 
 // flag test expected output variables
 var e_outp = "true"
--- a/nashorn/test/script/nosecurity/jjs-option-scripting.js	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/test/script/nosecurity/jjs-option-scripting.js	Mon Mar 28 08:41:54 2016 -0700
@@ -25,7 +25,6 @@
  * JDK-8144113: Nashorn: enable jjs testing. 
  * @test
  * @option -scripting
- * @runif os.not.windows
  * @run
  * @summary Test -scripting flag and its basic functionality
  */
@@ -40,7 +39,7 @@
 var x = "Nashorn"
 var hello = "Hello ${x}"
 if (hello != "Hello Nashorn") {
-    throw new Error("string interploation not working");
+    throw new Error("string interploation not working")
 }
 EOD
 
--- a/nashorn/test/script/nosecurity/jjs-option-strict.js	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/test/script/nosecurity/jjs-option-strict.js	Mon Mar 28 08:41:54 2016 -0700
@@ -25,7 +25,6 @@
  * JDK-8144113: Nashorn: enable jjs testing. 
  * @test
  * @option -scripting
- * @runif os.not.windows
  * @run
  * @summary Test  -strict flag and its basic functionality
  */
--- a/nashorn/test/script/nosecurity/jjs-option-version.js	Thu Mar 24 02:04:14 2016 +0300
+++ b/nashorn/test/script/nosecurity/jjs-option-version.js	Mon Mar 28 08:41:54 2016 -0700
@@ -26,7 +26,6 @@
  * check if jjs version is same as of java.
  * @test
  * @option -scripting
- * @runif os.not.windows
  * @run
  * @summary Test -version flag and its functionality 
  */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/dynalink/test/ArrayRunnableTest.java	Mon Mar 28 08:41:54 2016 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.dynalink.test;
+
+public class ArrayRunnableTest {
+    private Runnable[] r;
+    public void setRunnables(final Runnable... r) {
+        this.r = r;
+    }
+
+    public Runnable getFirstRunnable() {
+        return r[0];
+    }
+
+    public void setRunnablesOverloaded(final Runnable... r) {
+        this.r = r;
+    }
+
+    public void setRunnablesOverloaded(final Object... r) {
+        throw new UnsupportedOperationException();
+    }
+}