Merge
diff --git a/.hgtags b/.hgtags
index 324a20e..68dc70e 100644
--- a/.hgtags
+++ b/.hgtags
@@ -1,3 +1,46 @@
+a7f55c3506ec8927f498d427c4cff476e34d8bcd jdk8u92-b32
+0b14732c52bfdbb220b97969a9889a7575eaee1b jdk8u92-b33
+f130ddae68457255a580d6ce54649f7caeefd0d8 jdk8u92-b34
+1e28c9661ee1ef629545348378681e0e07c156cf jdk8u101-b12
+bd60b9315bec4943fc2f0633a44f2b13d5363265 jdk8u101-b13
+e5d252082e88c80b5e2e724ed39034e217dc0415 jdk8u101-b11
+76310db2fd9471a94f1182fbb5765c5e20d87910 jdk8u101-b10
+9cd552ad986f9960c22bd2b3aaee225b67a097ff jdk8u101-b09
+30e317f7ff64b6fdeae22e00aef6f81728be732c jdk8u101-b06
+a71a221ca301dfbceef7e0ecaf8a535dc2ddb426 jdk8u101-b07
+0958713c5b839a3f76f7a1d1fbc390d902c8cbb5 jdk8u101-b08
+7b8233189f9e7dcf6f387f065b4a62bd1bf325c4 jdk8u92-b31
+a5f2a9ac659c87ef43abfcf925698bd10bb4a3af jdk8u77-b31
+bae6a22f41e3e3b75726ff50a7025d844e4e9cae jdk8u74-b31
+041e81da22e1064fd127b43bb1826a4738837cd7 jdk8u74-b32
+1800f64a5ac07880bdf89d65cb7afaafe352e512 jdk8u40-b32
+79e019c6567bada9eb1631002cb6a7a08a5440e2 jdk8u40-b33
+0ea94733fdc1bcb97ffa564f2e084c5ec485a9b6 jdk8u101-b01
+f05498bbb53ca98f4280c4b14c74460275e8303b jdk8u101-b02
+b57f69bd6a5d5059fea57cf18e862b855f72c36a jdk8u101-b03
+e839a7decc7b9647253fd7eb0e0da2a3b1c7bc28 jdk8u101-b04
+2c4a454554b61a4cabc7ec40618d53801f7a07f0 jdk8u111-b00
+d101006ec8b17284e63c923c2c0821562429b578 jdk8u101-b05
+3110c7d37456dfccc63d9619934ffdc759f49d86 jdk8u91-b15
+271eb6d931011ae41702a3e8540fed43495f0e08 jdk8u91-b13
+1812facb1d3fe2de45bd3e49a592756af54e0336 jdk8u91-b14
+8377d6635997d158b46b3baa10c18f128187b831 jdk8u76-b12
+d0872c50149cbddbbff6b82def59fcdae0837c5f jdk8u92-b00
+1d2ae70e0a4e581672f6ce189694bc0f98ce6193 jdk8u92-b13
+071ed9f02ea0827092d4276f9db86a0bcae6a612 jdk8u92-b14
+8a026a218e3f3d1dbe12a20c68b426e0528851cf jdk8u73-b01
+ed45f38f56ddec1a29fba7d326b4a55f3b3effba jdk8u73-b02
+e23d9791627814c692557734c6e59236fee111f5 jdk8u74-b01
+822c4fef1fdbeb5fee92cabdd459310e0e9ec862 jdk8u74-b02
+a796ebfcd2a0e2d8d7ca2d5196996accfae1c96c jdk8u77-b00
+c7805e546e4ee785e0b7159d3d4c0ec2bccd2d72 jdk8u77-b01
+0231f000d6c150f4f0fb04a50b1858080dac8a64 jdk8u77-b02
+cda171d04f1eb4839c1a0b80e91067f52cb96437 jdk8u77-b03
+35327dc72196ce7a1c377bc96270087082c169dd jdk8u76-b04
+c443548707f3eac52d9aa00e290e6e837a32a0bf jdk8u102-b00
+0e04f11e15def7a9735cdb1abcc3d2a8e73c52a0 jdk8u82-b00
+9b9bc5e6480f9688a7372790cd1c2cfecd3c52dd jdk8u102-b01
+c989179d6e2e4658b65a2f7630101850bce777f1 jdk8u102-b02
 074555f5740fe64f2dc7585a6a33248b859e5c67 jdk8u75-b10
 27852d87dc377944172b082ee2dc9ce02b421c11 jdk8u75-b12
 44e818159e0cf26ecd727d73765c7a7320589bad jdk8u91-b00
@@ -554,6 +597,13 @@
 c6bcf1e2e1ff7ae02924049100fa94b5280d7488 jdk8u76-b09
 f8024b5b8e903171b913d7099f76b1c31a3ffb88 jdk8u76-b10
 593e4acabaf686c40be914d1fb77e982ebe9fc13 jdk8u76-b11
-a7f55c3506ec8927f498d427c4cff476e34d8bcd jdk8u92-b32
-0b14732c52bfdbb220b97969a9889a7575eaee1b jdk8u92-b33
-f130ddae68457255a580d6ce54649f7caeefd0d8 jdk8u92-b34
+f746ec1a576bf8b34618a5509c3d6ff6bae71d51 jdk8u102-b03
+97391507a185793348818c20a42bd80fd1208cf9 jdk8u102-b05
+7dfe79789fd9da8eab74c4f6d89c796f86cb268b jdk8u102-b06
+75c41f2a7094e7f6b4228ed0a6d6443dbd8213fc jdk8u102-b07
+8bb9d6b719ed706c835043317eaadb20b55db2de jdk8u102-b08
+b7f1707866adfaa5ccbe35419b4bd9875d3d968a jdk8u102-b09
+c4680d92e8f2b49dcf6a1bab91773f147bcb5347 jdk8u102-b10
+bb0f34bb2651368b53d0e786ef9534bebacfc1b2 jdk8u102-b11
+e69de9d8aea08ad449696e5b5e7f281ab7cd3a99 jdk8u102-b12
+bc2b59e8aabe5be743241e0f970f32935db7e258 jdk8u102-b13
diff --git a/.hgtags-top-repo b/.hgtags-top-repo
index def8256..776110e 100644
--- a/.hgtags-top-repo
+++ b/.hgtags-top-repo
@@ -386,6 +386,7 @@
 12deacac825756e266e91a906db9edab73c4c90b jdk8u40-b27
 eee2ebbb97f136cd458d4f3a825ee40d0046f425 jdk8u40-b31
 b92f3d486e47d29dfb1ea2096db295077328368e jdk8u40-b32
+8b3c10f939d77adacf2a3ff7510de66bd024cfe4 jdk8u40-b33
 ec4bcc6e4dcf190a165106627ed3eef1e7d94d0c jdk8u45-b00
 635ba0c81b894a88ff737fefc9d7af398f761643 jdk8u45-b01
 801c65bb74b770600a2d48189764e416e5cfe265 jdk8u45-b02
@@ -550,10 +551,12 @@
 33b310c85259e0d7ed112ab2e01008228e263371 jdk8u74-b01
 bee679b986f51fe4d65d6df11fea93d1543b6502 jdk8u74-b02
 fd813938f2dd5f8e9d7caa2c1628af6da6683831 jdk8u74-b31
+9d7c49d756f01acbcbe8d0d3c5d5d4e92a7cf119 jdk8u74-b32
 ac4e9dfd23236821432786b27566fa2f800aa3d4 jdk8u75-b00
 d63a77fb06149b75dbb043a175a9c4a906ac26ef jdk8u75-b01
 320f984ac52b56da66aff581a2c4830eadc0404e jdk8u75-b02
 53dc743a34f164a9eb4e336f90cb21a58291a0b1 jdk8u75-b03
+722fc7e276ff8b4b6460b399e4eb65da518435f0 jdk8u101-b00
 722fc7e276ff8b4b6460b399e4eb65da518435f0 jdk8u75-b04
 57f1232cccbdfb8716f7258bc42982eb3e236e51 jdk8u75-b05
 9ea73143a5184a4034a1276733a9f9f356b67278 jdk8u75-b06
@@ -570,6 +573,7 @@
 4c41657db1862352b0e107b910be32c86eb5b1ff jdk8u91-b00
 0c798868f18548af144de0f0ab69f09a4c968cd2 jdk8u91-b13
 5744173381186940733aecf7904053ba6e83180e jdk8u91-b14
+dca1ae1fd0fdb55a4fa12f58726a1fa7086e7ae0 jdk8u91-b15
 e8bed1496ff254d91d52c8da7c6d8d361862d773 jdk8u76-b00
 832508a6165c877aa1de03ca9b6520c7bfe5a28e jdk8u76-b01
 0861105394355ad24c07cb2ff58a731ef91502a8 jdk8u76-b02
@@ -589,3 +593,39 @@
 9005b6faa5f616a8b403ea3aa660b963a7cdde24 jdk8u92-b31
 7e728e8e6120e276d05f82c1a01c3d8fe4a63584 jdk8u92-b32
 5e69844e2c69d21e6f139845451ad8c5acdef709 jdk8u92-b33
+f8ea719757e3bee133e59c7fd69589e190785292 jdk8u92-b34
+722fc7e276ff8b4b6460b399e4eb65da518435f0 jdk8u81-b00
+534d4e07c81fc8656cdb0856e22aafbdc54e474a jdk8u101-b01
+18e1f0ee965b0565514027543546348ed99bf4a4 jdk8u101-b02
+fe138c6f5aa8455ee704e58d7d7ffc90fdd230c3 jdk8u101-b03
+fe901996777f50198be2c785cd7e3b8198692bbe jdk8u101-b04
+9c51e0213472d584b91cf42c4c454c1caf7dbaf4 jdk8u101-b05
+1babb07d0e02471f947b9166f869720e3ae805ab jdk8u101-b06
+93e821287367a5bccbae1cfef8d3ce6c8f632d03 jdk8u101-b07
+7ede5c151d790625552ed9c683844be820d9277b jdk8u101-b08
+0b1358bc93ca7a30bab6cf2d7da09bb5a11f5a93 jdk8u101-b09
+1db5081d8ee77caffa0f534496af5fb908e9b61f jdk8u101-b10
+81cdb3e279f8f245f740e7d3e79a1629b6599325 jdk8u101-b11
+d6f920823feb4d44e67cec383d8c6e4a5dba9d76 jdk8u101-b12
+e983a19c64390d18004d1d0c7907394714e697b3 jdk8u101-b13
+e8bed1496ff254d91d52c8da7c6d8d361862d773 jdk8u76-b00
+832508a6165c877aa1de03ca9b6520c7bfe5a28e jdk8u76-b01
+0861105394355ad24c07cb2ff58a731ef91502a8 jdk8u76-b02
+4db8c011697524c7ba76fb317763940d85af0c12 jdk8u76-b03
+120282f77af0321604f51edcbcd368aff23b42b7 jdk8u76-b04
+f6d50bd27913fe801a6ec445437d7503b458a422 jdk8u102-b00
+f6d50bd27913fe801a6ec445437d7503b458a422 jdk8u82-b00
+c0b0fb35c047fe3a654c5899e7204e9c68de532a jdk8u102-b01
+914eb7d20df00012875ddd3a26c2452671c6134c jdk8u102-b02
+c3596cd9b5c8a3774e6f200ac8d055b031a5e25b jdk8u102-b03
+067570c5c0b2604ff422d2eee6f07dfc4953e44a jdk8u102-b04
+9c5541aa49f4a6bd7206085be175bf4d6a5294e9 jdk8u102-b05
+b1de940771d47cbc7b9702fea16efda94b7fa654 jdk8u102-b06
+f428f6a9060b1ac1dad41ee8a3850efdeb564bc4 jdk8u102-b07
+6bef5f85b095d712cbab5c8cbaf8330036e8593b jdk8u102-b08
+3489cf2e35b743ab5d122136e7af46895bb9739c jdk8u102-b09
+96dac192aa74ccefa6fe7a7984ac3f8acabe5dc2 jdk8u102-b10
+5839c5f4292a8755a4c102cb0f983536f5bfe8be jdk8u102-b11
+163dc486915300b020f203e89fdf1985cc3c4814 jdk8u102-b12
+04471bfd1cc2e8f4d8d198e79b21e64dd4499db8 jdk8u102-b13
+daafd7d3a76a0c448e4982afd7c4e9471ab1c916 jdk8u102-b14
diff --git a/corba/.hgtags b/corba/.hgtags
index ed12e65..938b002 100644
--- a/corba/.hgtags
+++ b/corba/.hgtags
@@ -384,6 +384,7 @@
 bd0186cd2419129357b110fe3f13519f68b29774 jdk8u40-b27
 28a1dbd4bb9ec97427790c88d21514af2f878c94 jdk8u40-b31
 663a3151c688bc3f4c092bcad21cc81e29139d62 jdk8u40-b32
+5b700e0c00471ba1b7575fc6d03d6b0a0e041b50 jdk8u40-b33
 5761efbc739fdedcbff224e22f920e88b29af4cf jdk8u45-b00
 6a52852476c9ccb2d52153d1b94b675e863bb28c jdk8u45-b01
 3b9d342f9f584465ea5976e06357b45682f9681d jdk8u45-b02
@@ -574,6 +575,11 @@
 cd7cec8fd295c0462a813b5f54dc5457c2bade2d jdk8u91-b00
 4ea02753e66e348ee4639e157061bcbdef1d7ff3 jdk8u91-b13
 f8d0cfaa9900ebda679fa9df8319fb753858f283 jdk8u91-b14
+9f89788050d38ba4e19e24894eb8b3dd24c1a9d0 jdk8u91-b15
+7b719c1dec62535c34030cf3457abe6f478f13a0 jdk8u77-b00
+cafc1648f432eff2c392040af2db4505c3d290b6 jdk8u77-b01
+0f0077ee5e53365562ff77a01aa97d0c7374f447 jdk8u77-b02
+e8dc6eb11c761f20b44d8c4b8acb0846268872f1 jdk8u77-b03
 7deeb4f70404e4f52306f9d0bcfc482fc5f16fb3 jdk8u76-b00
 5786892e7c7d512ef9104a469ff7eafeaac12c38 jdk8u76-b01
 239155e48af89968b62e695a3233d42bed1a3282 jdk8u76-b02
@@ -593,3 +599,68 @@
 fe88377e18b0c5f3da8e6741e0d5b9bfd45d2648 jdk8u92-b31
 11e4e7e901bc86d14163afbc5d28345e36737344 jdk8u92-b32
 9ed665d319590e0b9997b3703314c6b0341d4362 jdk8u92-b33
+5b5f76caf6e4ffa51f25e64d0d79a3f0913c633e jdk8u92-b34
+073b951904b3ee7c54fb79a169478fa66d925320 jdk8u75-b00
+5b48f7defe40eab668fe554df0afd87d84d60722 jdk8u75-b01
+0015f4a7f0d02a9bb79b7a0c737590f01feaabd4 jdk8u75-b02
+74b2903babf0f4138c367e3f9eea8958f5d71b94 jdk8u75-b03
+aa99436ccf826b3a2eecdaf646814e58cf514efb jdk8u101-b00
+aa99436ccf826b3a2eecdaf646814e58cf514efb jdk8u75-b04
+e4dd4a6a2e67aa42d1e22246216f56a5280f83fb jdk8u75-b05
+6ca185377097c44ee1768f2f817b1b9e3b89068c jdk8u75-b06
+77880a70d92dbfc0ab1dab1aefad179c711ea852 jdk8u75-b07
+d267b16e3ecc006200ec6478904b7ea119df5b19 jdk8u75-b08
+1030aea873cdecfb6f55ab652abc67c901f61f60 jdk8u75-b09
+964fe4bba121592325cb346e3a4fa677b277d0ec jdk8u75-b10
+f7cfd44464c3c3efd6d6f29921fad4ed0de75d83 jdk8u75-b12
+7b719c1dec62535c34030cf3457abe6f478f13a0 jdk8u77-b00
+cafc1648f432eff2c392040af2db4505c3d290b6 jdk8u77-b01
+0f0077ee5e53365562ff77a01aa97d0c7374f447 jdk8u77-b02
+e8dc6eb11c761f20b44d8c4b8acb0846268872f1 jdk8u77-b03
+cd7cec8fd295c0462a813b5f54dc5457c2bade2d jdk8u91-b00
+4ea02753e66e348ee4639e157061bcbdef1d7ff3 jdk8u91-b13
+7deeb4f70404e4f52306f9d0bcfc482fc5f16fb3 jdk8u76-b00
+5786892e7c7d512ef9104a469ff7eafeaac12c38 jdk8u76-b01
+239155e48af89968b62e695a3233d42bed1a3282 jdk8u76-b02
+137e5c45fd5422ecd6c758c6b83a2f184abef91b jdk8u76-b03
+7bbceb589f5ddb6eefab2b23de0003de67cfc667 jdk8u76-b04
+ca66a2dd5cfd6d4d0d05ee9861ff3cadd7166761 jdk8u76-b05
+f8453e7a3185060e5625127fe76b5cd7ae64150a jdk8u76-b06
+dd1d572083b0b11f70f03408f6bb154bbdef4272 jdk8u76-b07
+fc122918583747b114b246babc82841a827c56c7 jdk8u76-b08
+afb55372bcc787b75e24afd28b00cfaaa45bb77d jdk8u76-b09
+d2f26e6433db89354b028fb75abcc6ca266d035f jdk8u76-b10
+df2dcefb08f9e3c65a4cbea75e54600649d063d0 jdk8u76-b11
+94c775e05eb053b8440d82298927a144ed73f340 jdk8u76-b12
+e0fbd6a51e061025f2d6ad0311a587f7ce3c2b43 jdk8u92-b00
+8f0466c0dce60b1df3bc01785b01a7f09fa7b564 jdk8u92-b13
+aa99436ccf826b3a2eecdaf646814e58cf514efb jdk8u81-b00
+8674aec1be6459f33451690fb106eec314964116 jdk8u101-b01
+96a43945cb6a69989294b511ecdfc0493ea09bf1 jdk8u101-b02
+371b0c5477d8613c06fd1206deed27759f18e42e jdk8u101-b03
+52cca1ce8b473ecd751da2350d4b3ef111b5676e jdk8u101-b04
+3edb6296456161d67bf33a73faf18dc57ef548de jdk8u101-b05
+37bd092c2a7a9e71c027a33757429e02e00050de jdk8u101-b06
+df3cd274d224e22e156556bc0d7b8927b72a7608 jdk8u101-b07
+b8914ce62047d20076a64fd43a6ca8f5bb470047 jdk8u101-b08
+317ccda98b74d445f6d3b241783a22cc167cedbf jdk8u101-b09
+7c90acc432738bdc1506d510daeadf9376279dfa jdk8u101-b10
+4942432b3da1afbc2c2c87bdf896b112800e537c jdk8u101-b11
+f8511bfb19c35d8d396dc53245c06cc3710657b1 jdk8u101-b12
+2bb2aec4b3e51aab96e9c25603c7c92fcbac46de jdk8u101-b13
+223d0e48a55b92255f5a613743a99e7deacaf455 jdk8u102-b00
+223d0e48a55b92255f5a613743a99e7deacaf455 jdk8u82-b00
+9d09a2f1395561fe71b1a83f53907ddc52e699d6 jdk8u102-b01
+564fbe28cbb0ff2e6f55623807ea816042de00ff jdk8u102-b02
+ab7dbd58a766fb01c6643f3a80c9e96ac1278a06 jdk8u102-b03
+626d8fa7a1bfd9e65b94117a526ba57b25ec3d14 jdk8u102-b04
+3c35b66b5345f615a3ff626111587c452c8c3893 jdk8u102-b05
+2a265ab91dd234348630dab92f622a616ab76a0e jdk8u102-b06
+8d44271dd11dd4bdc88ef647fd144e544791ecc4 jdk8u102-b07
+329501e6cc220884f005afc7cd330e227931fb21 jdk8u102-b08
+e108e30edcca932832e4e5edf1a15349d3be2fed jdk8u102-b09
+e0d70741f35cd16289de3fd6049834879725dae5 jdk8u102-b10
+360a2772486dd1aa818132222ea0b7fcfa5707ef jdk8u102-b11
+57546b5b575dec9ecfbb1e9a77d87c391a44ab96 jdk8u102-b12
+a7c292080d5ed76ea5e3b123c0dee4c340aa174f jdk8u102-b13
+56b133772ec1aa4f44f2eee2c4103c645f764935 jdk8u102-b14
diff --git a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/ORBUtility.java b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/ORBUtility.java
index 41dba4d..81bb3e0 100644
--- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/ORBUtility.java
+++ b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/ORBUtility.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, 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
@@ -34,21 +34,13 @@
 import java.security.Policy;
 import java.security.PrivilegedAction;
 import java.security.ProtectionDomain;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Map;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Set;
-import java.util.Map.Entry;
-import java.util.Collection;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.Enumeration;
-import java.util.Properties;
-import java.util.IdentityHashMap;
 import java.util.StringTokenizer;
 import java.util.NoSuchElementException;
 
@@ -165,8 +157,18 @@
      * Return default ValueHandler
      */
     public static ValueHandler createValueHandler() {
+        ValueHandler vh;
+        try {
+            vh = AccessController.doPrivileged(new PrivilegedExceptionAction<ValueHandler>() {
+                public ValueHandler run() throws Exception {
         return Util.createValueHandler();
     }
+            });
+        } catch (PrivilegedActionException e) {
+            throw new InternalError(e.getMessage());
+        }
+        return vh;
+    }
 
     /**
      * Returns true if it was accurately determined that the remote ORB is
@@ -664,7 +666,16 @@
      * ValueHandler.
      */
     public static byte getMaxStreamFormatVersion() {
-        ValueHandler vh = Util.createValueHandler();
+        ValueHandler vh;
+        try {
+            vh = AccessController.doPrivileged(new PrivilegedExceptionAction<ValueHandler>() {
+                public ValueHandler run() throws Exception {
+                    return Util.createValueHandler();
+                }
+            });
+        } catch (PrivilegedActionException e) {
+            throw new InternalError(e.getMessage());
+        }
 
         if (!(vh instanceof javax.rmi.CORBA.ValueHandlerMultiFormat))
             return ORBConstants.STREAM_FORMAT_VERSION_1;
diff --git a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_zh_TW.properties b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_zh_TW.properties
index 17f0137..84ada02 100644
--- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_zh_TW.properties
+++ b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_zh_TW.properties
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2000, 2013, 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
@@ -103,5 +103,5 @@
 tnameserv.hs3=\u5C31\u7DD2\u3002
 
 orbd.commfailure=\n\u56E0\u70BA ORBinitialPort \u5728\u4F7F\u7528\u4E2D\uFF0C\u6240\u4EE5\u7121\u6CD5\u555F\u52D5 ORBD\u3002
-orbd.internalexception=\n\u56E0\u70BA\u5167\u90E8\u767C\u751F\u7570\u5E38\uFF0C\u6240\u4EE5\u7121\u6CD5\u555F\u52D5 ORBD\u3002 \n\u53EF\u80FD\u7684\u539F\u56E0: \n1. \u6307\u5B9A\u7684 ORBInitialPort \u6216 ORBActivationPort \u5728\u4F7F\u7528\u4E2D\u3002 \n2. \u6C92\u6709\u5BEB\u5165 orb.db \u7684\u6B0A\u9650\u3002 
+orbd.internalexception=\n\u56E0\u70BA\u5167\u90E8\u767C\u751F\u7570\u5E38\uFF0C\u6240\u4EE5\u7121\u6CD5\u555F\u52D5 ORBD\u3002\n\u53EF\u80FD\u7684\u539F\u56E0: \n1. \u6307\u5B9A\u7684 ORBInitialPort \u6216 ORBActivationPort \u5728\u4F7F\u7528\u4E2D\u3002\n2. \u6C92\u6709\u5BEB\u5165 orb.db \u7684\u6B0A\u9650\u3002
 
diff --git a/corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/StubFactoryDynamicBase.java b/corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/StubFactoryDynamicBase.java
index ae7c9f8..c71eb5d 100644
--- a/corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/StubFactoryDynamicBase.java
+++ b/corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/StubFactoryDynamicBase.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
diff --git a/corba/src/share/classes/com/sun/corba/se/impl/transport/CorbaInboundConnectionCacheImpl.java b/corba/src/share/classes/com/sun/corba/se/impl/transport/CorbaInboundConnectionCacheImpl.java
index 220c787..1f2f855 100644
--- a/corba/src/share/classes/com/sun/corba/se/impl/transport/CorbaInboundConnectionCacheImpl.java
+++ b/corba/src/share/classes/com/sun/corba/se/impl/transport/CorbaInboundConnectionCacheImpl.java
@@ -54,11 +54,17 @@
 {
     protected Collection connectionCache;
 
+    private Acceptor acceptor;
+
     public CorbaInboundConnectionCacheImpl(ORB orb, Acceptor acceptor)
     {
         super(orb, acceptor.getConnectionCacheType(),
               ((CorbaAcceptor)acceptor).getMonitoringName());
         this.connectionCache = new ArrayList();
+        this.acceptor = acceptor;
+        if (orb.transportDebugFlag) {
+            dprint(": " + acceptor );
+        }
     }
 
     ////////////////////////////////////////////////////
@@ -66,11 +72,25 @@
     // pept.transport.InboundConnectionCache
     //
 
+    public void close () {
+
+        super.close();
+        if (orb.transportDebugFlag) {
+            dprint(".close: " + acceptor );
+        }
+        this.acceptor.close();
+
+    }
+
     public Connection get(Acceptor acceptor)
     {
         throw wrapper.methodShouldNotBeCalled();
     }
 
+    public Acceptor getAcceptor () {
+        return acceptor;
+    }
+
     public void put(Acceptor acceptor, Connection connection)
     {
         if (orb.transportDebugFlag) {
diff --git a/corba/src/share/classes/com/sun/corba/se/impl/transport/CorbaTransportManagerImpl.java b/corba/src/share/classes/com/sun/corba/se/impl/transport/CorbaTransportManagerImpl.java
index 12c0be6..970fde4 100644
--- a/corba/src/share/classes/com/sun/corba/se/impl/transport/CorbaTransportManagerImpl.java
+++ b/corba/src/share/classes/com/sun/corba/se/impl/transport/CorbaTransportManagerImpl.java
@@ -188,8 +188,9 @@
             for (Object cc : outboundConnectionCaches.values()) {
                 ((ConnectionCache)cc).close() ;
             }
-            for (Object cc : inboundConnectionCaches.values()) {
-                ((ConnectionCache)cc).close() ;
+            for (Object icc : inboundConnectionCaches.values()) {
+                ((ConnectionCache)icc).close() ;
+                unregisterAcceptor(((InboundConnectionCache)icc).getAcceptor());
             }
             getSelector(0).close();
         } finally {
diff --git a/corba/src/share/classes/com/sun/corba/se/impl/transport/SelectorImpl.java b/corba/src/share/classes/com/sun/corba/se/impl/transport/SelectorImpl.java
index 054071b..7756ef2 100644
--- a/corba/src/share/classes/com/sun/corba/se/impl/transport/SelectorImpl.java
+++ b/corba/src/share/classes/com/sun/corba/se/impl/transport/SelectorImpl.java
@@ -26,16 +26,20 @@
 package com.sun.corba.se.impl.transport;
 
 import java.io.IOException;
+import java.net.ServerSocket;
 import java.nio.channels.ClosedChannelException;
 import java.nio.channels.SelectableChannel;
+import java.nio.channels.ServerSocketChannel;
 import java.nio.channels.SelectionKey;
 import java.nio.channels.Selector;
+import java.nio.channels.ClosedSelectorException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Iterator;
 import java.util.List;
 
+
 import com.sun.corba.se.pept.broker.Broker;
 import com.sun.corba.se.pept.transport.Acceptor;
 import com.sun.corba.se.pept.transport.Connection;
@@ -111,7 +115,16 @@
                 interestOpsList.add(keyAndOp);
             }
             // tell Selector Thread there's an update to a SelectorKey's Ops
-            selector.wakeup();
+            try {
+                if (selector != null) {
+                    // wakeup Selector thread to process close request
+                    selector.wakeup();
+                }
+            } catch (Throwable t) {
+                if (orb.transportDebugFlag) {
+                    dprint(".registerInterestOps: selector.wakeup: ", t);
+                }
+            }
         }
         else {
             wrapper.selectionKeyInvalid(eventHandler.toString());
@@ -186,7 +199,9 @@
             if (selectionKey != null) {
                 selectionKey.cancel();
             }
-            selector.wakeup();
+            if (selector != null) {
+                selector.wakeup();
+            }
             return;
         }
 
@@ -239,6 +254,8 @@
             readerThread.close();
         }
 
+       clearDeferredRegistrations();
+
         // Selector
 
         try {
@@ -248,7 +265,7 @@
             }
         } catch (Throwable t) {
             if (orb.transportDebugFlag) {
-                dprint(".close: selector.close: " + t);
+                dprint(".close: selector.wakeup: ", t);
             }
         }
     }
@@ -273,15 +290,16 @@
                     n = selector.select(timeout);
                 } catch (IOException  e) {
                     if (orb.transportDebugFlag) {
-                        dprint(".run: selector.select: " + e);
+                        dprint(".run: selector.select: ", e);
                     }
+                } catch (ClosedSelectorException csEx) {
+                    if (orb.transportDebugFlag) {
+                        dprint(".run: selector.select: ", csEx);
+                    }
+                    break;
                 }
                 if (closed) {
-                    selector.close();
-                    if (orb.transportDebugFlag) {
-                        dprint(".run: closed - .run return");
-                    }
-                    return;
+                    break;
                 }
                 /*
                   if (timeout == 0 && orb.transportDebugFlag) {
@@ -321,6 +339,18 @@
                 }
             }
         }
+        try {
+            if (selector != null) {
+                if (orb.transportDebugFlag) {
+                    dprint(".run: selector.close ");
+                }
+                selector.close();
+            }
+        } catch (Throwable t) {
+            if (orb.transportDebugFlag) {
+                dprint(".run: selector.close: ", t);
+            }
+        }
     }
 
     /////////////////////////////////////////////////////
@@ -328,6 +358,44 @@
     // Implementation.
     //
 
+    private void clearDeferredRegistrations() {
+        synchronized (deferredRegistrations) {
+            int deferredListSize = deferredRegistrations.size();
+            if (orb.transportDebugFlag) {
+                dprint(".clearDeferredRegistrations:deferred list size == " + deferredListSize);
+            }
+            for (int i = 0; i < deferredListSize; i++) {
+                EventHandler eventHandler =
+                    (EventHandler)deferredRegistrations.get(i);
+                if (orb.transportDebugFlag) {
+                    dprint(".clearDeferredRegistrations: " + eventHandler);
+                }
+                SelectableChannel channel = eventHandler.getChannel();
+                SelectionKey selectionKey = null;
+
+                try {
+                    if (orb.transportDebugFlag) {
+                        dprint(".clearDeferredRegistrations:close channel == "
+                                + channel);
+                        dprint(".clearDeferredRegistrations:close channel class == "
+                                + channel.getClass().getName());
+                    }
+                    channel.close();
+                    selectionKey = eventHandler.getSelectionKey();
+                    if (selectionKey != null) {
+                        selectionKey.cancel();
+                        selectionKey.attach(null);
+                    }
+                } catch (IOException ioEx) {
+                    if (orb.transportDebugFlag) {
+                        dprint(".clearDeferredRegistrations: ", ioEx);
+                    }
+                }
+            }
+            deferredRegistrations.clear();
+        }
+    }
+
     private synchronized boolean isClosed ()
     {
         return closed;
@@ -344,7 +412,7 @@
             selector = Selector.open();
         } catch (IOException e) {
             if (orb.transportDebugFlag) {
-                dprint(".startSelector: Selector.open: IOException: " + e);
+                dprint(".startSelector: Selector.open: IOException: ", e);
             }
             // REVISIT - better handling/reporting
             RuntimeException rte =
@@ -379,7 +447,7 @@
                                          (Object)eventHandler);
                 } catch (ClosedChannelException e) {
                     if (orb.transportDebugFlag) {
-                        dprint(".handleDeferredRegistrations: " + e);
+                        dprint(".handleDeferredRegistrations: ", e);
                     }
                 }
                 eventHandler.setSelectionKey(selectionKey);
diff --git a/corba/src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelAcceptorImpl.java b/corba/src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelAcceptorImpl.java
index 18023b5..4b24c6b 100644
--- a/corba/src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelAcceptorImpl.java
+++ b/corba/src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelAcceptorImpl.java
@@ -264,7 +264,12 @@
 
             if (connection.shouldRegisterServerReadEvent()) {
                 Selector selector = orb.getTransportManager().getSelector(0);
-                selector.registerForEvent(connection.getEventHandler());
+                if (selector != null) {
+                    if (orb.transportDebugFlag) {
+                        dprint(".accept: registerForEvent: " + connection);
+                    }
+                    selector.registerForEvent(connection.getEventHandler());
+                }
             }
 
             getConnectionCache().reclaim();
@@ -273,12 +278,15 @@
             if (orb.transportDebugFlag) {
                 dprint(".accept:", e);
             }
-            orb.getTransportManager().getSelector(0).unregisterForEvent(this);
-            // REVISIT - need to close - recreate - then register new one.
-            orb.getTransportManager().getSelector(0).registerForEvent(this);
-            // NOTE: if register cycling we do not want to shut down ORB
-            // since local beans will still work.  Instead one will see
-            // a growing log file to alert admin of problem.
+            Selector selector = orb.getTransportManager().getSelector(0);
+            if (selector != null) {
+                selector.unregisterForEvent(this);
+                // REVISIT - need to close - recreate - then register new one.
+                selector.registerForEvent(this);
+                // NOTE: if register cycling we do not want to shut down ORB
+                // since local beans will still work.  Instead one will see
+                // a growing log file to alert admin of problem.
+            }
         }
     }
 
@@ -289,7 +297,9 @@
                 dprint(".close->:");
             }
             Selector selector = orb.getTransportManager().getSelector(0);
-            selector.unregisterForEvent(this);
+            if (selector != null) {
+                selector.unregisterForEvent(this);
+            }
             if (serverSocketChannel != null) {
                 serverSocketChannel.close();
             }
@@ -480,7 +490,9 @@
             // of calling SelectionKey.interestOps(<interest op>).
 
             Selector selector = orb.getTransportManager().getSelector(0);
-            selector.registerInterestOps(this);
+            if (selector != null) {
+                selector.registerInterestOps(this);
+            }
 
             if (orb.transportDebugFlag) {
                 dprint(".doWork<-:" + this);
diff --git a/corba/src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelConnectionImpl.java b/corba/src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelConnectionImpl.java
index fa87b56..f7c1e31 100644
--- a/corba/src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelConnectionImpl.java
+++ b/corba/src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelConnectionImpl.java
@@ -367,7 +367,10 @@
                 }
             }
             // REVISIT - make sure reader thread is killed.
-            orb.getTransportManager().getSelector(0).unregisterForEvent(this);
+            Selector selector = orb.getTransportManager().getSelector(0);
+            if (selector != null) {
+                selector.unregisterForEvent(this);
+            }
             // Notify anyone waiting.
             purgeCalls(wrapper.connectionAbort(ex), true, false);
             // REVISIT
@@ -801,7 +804,9 @@
             }
             try {
                 Selector selector = orb.getTransportManager().getSelector(0);
-                selector.unregisterForEvent(this);
+                if (selector != null) {
+                    selector.unregisterForEvent(this);
+                }
                 if (socketChannel != null) {
                     socketChannel.close();
                 }
@@ -824,7 +829,9 @@
                dprint(".closeConnectionResources->: " + this);
            }
            Selector selector = orb.getTransportManager().getSelector(0);
-           selector.unregisterForEvent(this);
+           if (selector != null) {
+               selector.unregisterForEvent(this);
+           }
            try {
              if (socketChannel != null)
               socketChannel.close() ;
diff --git a/corba/src/share/classes/com/sun/corba/se/pept/transport/InboundConnectionCache.java b/corba/src/share/classes/com/sun/corba/se/pept/transport/InboundConnectionCache.java
index a79e1ff..3aee071 100644
--- a/corba/src/share/classes/com/sun/corba/se/pept/transport/InboundConnectionCache.java
+++ b/corba/src/share/classes/com/sun/corba/se/pept/transport/InboundConnectionCache.java
@@ -36,6 +36,8 @@
     public void put(Acceptor acceptor, Connection connection);
 
     public void remove(Connection connection);
+
+    public Acceptor getAcceptor();
 }
 
 // End of file.
diff --git a/corba/src/share/classes/javax/rmi/CORBA/Util.java b/corba/src/share/classes/javax/rmi/CORBA/Util.java
index 61d91c7..549fe76 100644
--- a/corba/src/share/classes/javax/rmi/CORBA/Util.java
+++ b/corba/src/share/classes/javax/rmi/CORBA/Util.java
@@ -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
@@ -45,6 +45,7 @@
 import java.rmi.Remote;
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.SerializablePermission;
 import java.net.MalformedURLException ;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
@@ -63,8 +64,22 @@
     private static final javax.rmi.CORBA.UtilDelegate utilDelegate;
     private static final String UtilClassKey = "javax.rmi.CORBA.UtilClass";
 
+    private static final String ALLOW_CREATEVALUEHANDLER_PROP = "jdk.rmi.CORBA.allowCustomValueHandler";
+    private static boolean allowCustomValueHandler;
+
     static {
         utilDelegate = (javax.rmi.CORBA.UtilDelegate)createDelegate(UtilClassKey);
+        allowCustomValueHandler = readAllowCustomValueHandlerProperty();
+    }
+
+    private static boolean readAllowCustomValueHandlerProperty () {
+       return AccessController
+        .doPrivileged(new PrivilegedAction<Boolean>() {
+            @Override
+            public Boolean run() {
+                return Boolean.getBoolean(ALLOW_CREATEVALUEHANDLER_PROP);
+            }
+        });
     }
 
     private Util(){}
@@ -111,7 +126,7 @@
      * Writes a java.lang.Object as a CORBA Object. If <code>obj</code> is
      * an exported RMI-IIOP server object, the tie is found
      * and wired to <code>obj</code>, then written to
-<code>out.write_Object(org.omg.CORBA.Object)</code>.
+     * <code>out.write_Object(org.omg.CORBA.Object)</code>.
      * If <code>obj</code> is a CORBA Object, it is written to
      * <code>out.write_Object(org.omg.CORBA.Object)</code>.
      * @param out the stream in which to write the object.
@@ -196,6 +211,8 @@
      */
     public static ValueHandler createValueHandler() {
 
+        isCustomSerializationPermitted();
+
         if (utilDelegate != null) {
             return utilDelegate.createValueHandler();
         }
@@ -336,6 +353,7 @@
     // security reasons. If you know a better solution how to share this code
     // then remove it from PortableRemoteObject. Also in Stub.java
     private static Object createDelegate(String classKey) {
+
         String className = (String)
             AccessController.doPrivileged(new GetPropertyAction(classKey));
         if (className == null) {
@@ -388,4 +406,16 @@
             new GetORBPropertiesFileAction());
     }
 
+    private static void isCustomSerializationPermitted() {
+        SecurityManager sm = System.getSecurityManager();
+        if (!allowCustomValueHandler) {
+            if ( sm != null) {
+                // check that a serialization permission has been
+                // set to allow the loading of the Util delegate
+                // which provides access to custom ValueHandler
+                sm.checkPermission(new SerializablePermission(
+                        "enableCustomValueHanlder"));
+            }
+        }
+    }
 }
diff --git a/hotspot/.hgtags b/hotspot/.hgtags
index 485863a..80a1be6 100644
--- a/hotspot/.hgtags
+++ b/hotspot/.hgtags
@@ -598,6 +598,7 @@
 6824e2475e0432e27f9cc51838bc34ea5fbf5113 jdk8u40-b27
 8220f68a195f6eeed2f5fb6e8a303726b512e899 jdk8u40-b31
 850a290eb1088a61178d1910c500e170ef4f4386 jdk8u40-b32
+e6aa4a8c1b46a05b6c493b4ffe5c2555013f5c99 jdk8u40-b33
 1b3abbeee961dee49780c0e4af5337feb918c555 jdk8u40-b10
 f10fe402dfb1543723b4b117a7cba3ea3d4159f1 hs25.40-b15
 99372b2fee0eb8b3452f47230e84aa6e97003184 jdk8u40-b11
@@ -815,11 +816,14 @@
 1b4072e4bb3ad54c4e894998486a8b33f0689160 jdk8u77-b02
 223b64a19e94222dd97b92bb40abcfbc0bf6ef1f jdk8u77-b03
 dd8507f51d786572dae18af8ffdc5a1ea34c755e jdk8u77-b31
+
+94ec11846b18111e73929b6caa9fbe7262e142c1 jdk8u74-b32
 da43260704c28b9f19cb652090ae65c258220fd6 jdk8u72-b31
 c0242ea4bde19d72be5149feda112a39e8c89b0a jdk8u75-b00
 ca3b8c8e390ab0540b0cc2e5def869b38e460d86 jdk8u75-b01
 9aef5b5e0a68f20059cfa9e2806b4ff0e11a3d31 jdk8u75-b02
 2df9fe896819362b9075a670b78106b249e50d6d jdk8u75-b03
+b374548dcb4834eb8731a06b52faddd0f10bd45d jdk8u101-b00
 32b682649973231b54740c09b10889660f6ebde5 jdk8u75-b04
 1f43bd4fab06d2ca5d1964611df14d8506d6b36e jdk8u75-b05
 916712f178c39d0acbc590f38802133fc86a7346 jdk8u75-b06
@@ -835,6 +839,11 @@
 bbbb05e91c629f8d9eef2ba43933767f68a898b0 jdk8u91-b00
 e36b6ade0499eadfd8673fe62ef0a613af2e6d67 jdk8u91-b13
 fa8991ccf6e5b74890a0b5672440b3c09d8d8732 jdk8u91-b14
+e1ea97ad19af4d1e0bda449aa43be7e1b118ffe9 jdk8u91-b15
+1b6d4fd2730e58f17820930f797938dc182117c4 jdk8u77-b00
+ddd297e340b1170d3cec011ee64e729f8b493c86 jdk8u77-b01
+1b4072e4bb3ad54c4e894998486a8b33f0689160 jdk8u77-b02
+223b64a19e94222dd97b92bb40abcfbc0bf6ef1f jdk8u77-b03
 d7b01fb81aa8a5437cb03bc36afe15cf0e55fb89 jdk8u76-b00
 c1679cc87ba045219169cabb6b9b378c2b5cc578 jdk8u76-b01
 218483967e52b419d885d34af4488a81c5133804 jdk8u76-b02
@@ -854,3 +863,34 @@
 445941ba41c0e3829fe02140690b144281ac2141 jdk8u92-b31
 f958bebdee267695e37aadd27753ac8b1e1823c8 jdk8u92-b32
 d1bb0e79ff79d21068388d9c62ca01e3c072fd0d jdk8u92-b33
+d0388be32561e4bd00c1a79adbe301cfdd6ba9f2 jdk8u92-b34
+b374548dcb4834eb8731a06b52faddd0f10bd45d jdk8u81-b00
+ead07188d11107e877e8e4ad215ff6cb238a8a92 jdk8u101-b01
+34429bad9986677f4991c80aeb22665842881cba jdk8u101-b02
+b41d5faaf1d32ed1bf9592f65f2f94ddd4c60fc4 jdk8u101-b03
+ceecf88e5c2c09bfabf5926581e6d0b0f65f5148 jdk8u101-b04
+19e74265fc8def6a7fc96c836d8ebe38ad1cf199 jdk8u101-b05
+7c60503b0888ac16eac80a6cd074195973f8dedb jdk8u101-b06
+cb4af293fe70549b51039bb9197f373e6750fafb jdk8u101-b07
+8ed377d2cec94435d1617a37999960a24be73ad9 jdk8u101-b08
+9be452c4e7161e60d623d55bb72ad013386aefd1 jdk8u101-b09
+218a44a163fa8c2532fd5f2e8ea9bc3c9c2ca8cf jdk8u101-b10
+0095e54dcaa1acfe1614feff9600734c26af7ae8 jdk8u101-b11
+286fe17d81c3d153611a28e50926083ae934cc56 jdk8u101-b12
+77df35b662ed98236f67ab18e23691460f986981 jdk8u101-b13
+d6c92b9e192ef97305a699e868387d55821c81ad jdk8u102-b00
+d6c92b9e192ef97305a699e868387d55821c81ad jdk8u82-b00
+516a64e6d7c2dc29fd932bf3b8313e560a01bcd0 jdk8u102-b01
+83dc7e55f71596e6e76fabfa56b6008e070ff44c jdk8u102-b02
+ef01a1634bb41dd5b36fc9824f8d35f745c6bd5a jdk8u102-b03
+2094cac55c5955b4f19cd9e35e3be8b467e59b57 jdk8u102-b04
+a96cf90239c64f51679d106b852c9a5b343b9488 jdk8u102-b05
+12cd1f9b403eb5024e8642bfa59136cd275899a4 jdk8u102-b06
+9ff5455815c1864ef7ca2d5232decd2023d1d043 jdk8u102-b07
+69f5f6c2beeb3bb126494ed779ae1686f61602b9 jdk8u102-b08
+b5ecd8067e899c4bfb8d327ee7583a32129772d4 jdk8u102-b09
+2672cfc2d7b6ffa07b7714208f9d46a405211d94 jdk8u102-b10
+36a1a2875ed55fa17818f3eb203e27922a7b4589 jdk8u102-b11
+340e1a736ef7169786e70db7f31ffd32bc3be24d jdk8u102-b12
+f6daf04c0f48dab5420ad63d21da82a7fa4e3ad7 jdk8u102-b13
+ac29c9c1193aef5d480b200ed94c5d579243c17b jdk8u102-b14
diff --git a/hotspot/agent/src/os/linux/symtab.c b/hotspot/agent/src/os/linux/symtab.c
index 4403227..fbe6999 100644
--- a/hotspot/agent/src/os/linux/symtab.c
+++ b/hotspot/agent/src/os/linux/symtab.c
@@ -514,6 +514,7 @@
      return (uintptr_t)NULL;
 
   item.key = (char*) strdup(sym_name);
+  item.data = NULL;
   hsearch_r(item, FIND, &ret, symtab->hash_table);
   if (ret) {
     struct elf_symbol * sym = (struct elf_symbol *)(ret->data);
diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java
index aa5f2bc..80da199 100644
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java
@@ -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
@@ -219,7 +219,7 @@
     if (threadNameField == null) {
       SystemDictionary sysDict = VM.getVM().getSystemDictionary();
       InstanceKlass k = sysDict.getThreadKlass();
-      threadNameField  = (OopField) k.findField("name", "[C");
+      threadNameField  = (OopField) k.findField("name", "Ljava/lang/String;");
       threadGroupField = (OopField) k.findField("group", "Ljava/lang/ThreadGroup;");
       threadEETopField = (LongField) k.findField("eetop", "J");
       threadTIDField = (LongField) k.findField("tid", "J");
@@ -258,7 +258,7 @@
 
   public static String threadOopGetName(Oop threadOop) {
     initThreadFields();
-    return charArrayToString((TypeArray) threadNameField.getValue(threadOop));
+    return stringOopToString(threadNameField.getValue(threadOop));
   }
 
   /** May return null if, e.g., thread was not started */
diff --git a/hotspot/make/windows/makefiles/sa.make b/hotspot/make/windows/makefiles/sa.make
index d75e2aa..84a34a7 100644
--- a/hotspot/make/windows/makefiles/sa.make
+++ b/hotspot/make/windows/makefiles/sa.make
@@ -44,9 +44,11 @@
 HS_ALT_SRC_REL=src/closed
 HS_ALT_SRC = $(WorkSpace)/$(HS_ALT_SRC_REL)
 !ifndef HS_ALT_MAKE
+!if exist($(WorkSpace)/make/closed)
 HS_ALT_MAKE=$(WorkSpace)/make/closed
 !endif
 !endif
+!endif
 
 HS_COMMON_SRC = $(WorkSpace)/$(HS_COMMON_SRC_REL)
 
diff --git a/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp b/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp
index 664f29e..72e98c6 100644
--- a/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp
+++ b/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp
@@ -40,7 +40,10 @@
 unsigned int VM_Version::_L2_data_cache_line_size = 0;
 
 void VM_Version::initialize() {
-  _features = determine_features();
+
+  assert(_features != VM_Version::unknown_m, "System pre-initialization is not complete.");
+  guarantee(VM_Version::has_v9(), "only SPARC v9 is supported");
+
   PrefetchCopyIntervalInBytes = prefetch_copy_interval_in_bytes();
   PrefetchScanIntervalInBytes = prefetch_scan_interval_in_bytes();
   PrefetchFieldsAhead         = prefetch_fields_ahead();
@@ -76,8 +79,6 @@
     FLAG_SET_DEFAULT(AllocatePrefetchStyle, 1);
   }
 
-  guarantee(VM_Version::has_v9(), "only SPARC v9 is supported");
-
   assert(ArraycopySrcPrefetchDistance < 4096, "invalid value");
   if (ArraycopySrcPrefetchDistance >= 4096)
     ArraycopySrcPrefetchDistance = 4064;
diff --git a/hotspot/src/cpu/sparc/vm/vm_version_sparc.hpp b/hotspot/src/cpu/sparc/vm/vm_version_sparc.hpp
index 59969ed..c493100 100644
--- a/hotspot/src/cpu/sparc/vm/vm_version_sparc.hpp
+++ b/hotspot/src/cpu/sparc/vm/vm_version_sparc.hpp
@@ -124,6 +124,8 @@
   // Initialization
   static void initialize();
 
+  static void init_before_ergo()        { _features = determine_features(); }
+
   // Instruction support
   static bool has_v8()                  { return (_features & v8_instructions_m) != 0; }
   static bool has_v9()                  { return (_features & v9_instructions_m) != 0; }
diff --git a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp
index 34e6b6d..45fd761 100644
--- a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp
@@ -1714,8 +1714,8 @@
   Register Rtmp1 = noreg;
 
   // check if it needs to be profiled
-  ciMethodData* md;
-  ciProfileData* data;
+  ciMethodData* md = NULL;
+  ciProfileData* data = NULL;
 
   if (op->should_profile()) {
     ciMethod* method = op->profiled_method();
@@ -1874,8 +1874,8 @@
     CodeStub* stub = op->stub();
 
     // check if it needs to be profiled
-    ciMethodData* md;
-    ciProfileData* data;
+    ciMethodData* md = NULL;
+    ciProfileData* data = NULL;
 
     if (op->should_profile()) {
       ciMethod* method = op->profiled_method();
@@ -2052,7 +2052,8 @@
     case lir_cond_greater:      acond = Assembler::greater;      ncond = Assembler::lessEqual;    break;
     case lir_cond_belowEqual:   acond = Assembler::belowEqual;   ncond = Assembler::above;        break;
     case lir_cond_aboveEqual:   acond = Assembler::aboveEqual;   ncond = Assembler::below;        break;
-    default:                    ShouldNotReachHere();
+    default:                    acond = Assembler::equal;        ncond = Assembler::notEqual;
+                                ShouldNotReachHere();
   }
 
   if (opr1->is_cpu_register()) {
@@ -3237,27 +3238,23 @@
   assert(default_type != NULL && default_type->is_array_klass() && default_type->is_loaded(), "must be true at this point");
 
   int elem_size = type2aelembytes(basic_type);
-  int shift_amount;
   Address::ScaleFactor scale;
 
   switch (elem_size) {
     case 1 :
-      shift_amount = 0;
       scale = Address::times_1;
       break;
     case 2 :
-      shift_amount = 1;
       scale = Address::times_2;
       break;
     case 4 :
-      shift_amount = 2;
       scale = Address::times_4;
       break;
     case 8 :
-      shift_amount = 3;
       scale = Address::times_8;
       break;
     default:
+      scale = Address::no_scale;
       ShouldNotReachHere();
   }
 
diff --git a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp
index 290c0b1..70176a2 100644
--- a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp
@@ -195,7 +195,7 @@
 
 
 LIR_Opr LIRGenerator::load_immediate(int x, BasicType type) {
-  LIR_Opr r;
+  LIR_Opr r = NULL;
   if (type == T_LONG) {
     r = LIR_OprFact::longConst(x);
   } else if (type == T_INT) {
@@ -485,7 +485,7 @@
     __ cmp(lir_cond_equal, right.result(), LIR_OprFact::longConst(0));
     __ branch(lir_cond_equal, T_LONG, new DivByZeroStub(info));
 
-    address entry;
+    address entry = NULL;
     switch (x->op()) {
     case Bytecodes::_lrem:
       entry = CAST_FROM_FN_PTR(address, SharedRuntime::lrem);
@@ -1025,7 +1025,7 @@
 
 void LIRGenerator::do_Convert(Convert* x) {
   // flags that vary for the different operations and different SSE-settings
-  bool fixed_input, fixed_result, round_result, needs_stub;
+  bool fixed_input = false, fixed_result = false, round_result = false, needs_stub = false;
 
   switch (x->op()) {
     case Bytecodes::_i2l: // fall through
diff --git a/hotspot/src/cpu/x86/vm/jniFastGetField_x86_32.cpp b/hotspot/src/cpu/x86/vm/jniFastGetField_x86_32.cpp
index e4fb943..a45e0eb 100644
--- a/hotspot/src/cpu/x86/vm/jniFastGetField_x86_32.cpp
+++ b/hotspot/src/cpu/x86/vm/jniFastGetField_x86_32.cpp
@@ -48,7 +48,7 @@
 // between loads, which is much more efficient than lfence.
 
 address JNI_FastGetField::generate_fast_get_int_field0(BasicType type) {
-  const char *name;
+  const char *name = NULL;
   switch (type) {
     case T_BOOLEAN: name = "jni_fast_GetBooleanField"; break;
     case T_BYTE:    name = "jni_fast_GetByteField";    break;
@@ -122,7 +122,7 @@
 
   slowcase_entry_pclist[count++] = __ pc();
   __ bind (slow);
-  address slow_case_addr;
+  address slow_case_addr = NULL;
   switch (type) {
     case T_BOOLEAN: slow_case_addr = jni_GetBooleanField_addr(); break;
     case T_BYTE:    slow_case_addr = jni_GetByteField_addr();    break;
@@ -256,7 +256,7 @@
 }
 
 address JNI_FastGetField::generate_fast_get_float_field0(BasicType type) {
-  const char *name;
+  const char *name = NULL;
   switch (type) {
     case T_FLOAT:  name = "jni_fast_GetFloatField";  break;
     case T_DOUBLE: name = "jni_fast_GetDoubleField"; break;
@@ -337,7 +337,7 @@
 
   slowcase_entry_pclist[count++] = __ pc();
   __ bind (slow);
-  address slow_case_addr;
+  address slow_case_addr = NULL;
   switch (type) {
     case T_FLOAT:  slow_case_addr = jni_GetFloatField_addr();  break;
     case T_DOUBLE: slow_case_addr = jni_GetDoubleField_addr(); break;
diff --git a/hotspot/src/cpu/x86/vm/jniFastGetField_x86_64.cpp b/hotspot/src/cpu/x86/vm/jniFastGetField_x86_64.cpp
index 1f523c7..7286fd1 100644
--- a/hotspot/src/cpu/x86/vm/jniFastGetField_x86_64.cpp
+++ b/hotspot/src/cpu/x86/vm/jniFastGetField_x86_64.cpp
@@ -51,7 +51,7 @@
 // since that may scratch r10!
 
 address JNI_FastGetField::generate_fast_get_int_field0(BasicType type) {
-  const char *name;
+  const char *name = NULL;
   switch (type) {
     case T_BOOLEAN: name = "jni_fast_GetBooleanField"; break;
     case T_BYTE:    name = "jni_fast_GetByteField";    break;
@@ -111,7 +111,7 @@
 
   slowcase_entry_pclist[count++] = __ pc();
   __ bind (slow);
-  address slow_case_addr;
+  address slow_case_addr = NULL;
   switch (type) {
     case T_BOOLEAN: slow_case_addr = jni_GetBooleanField_addr(); break;
     case T_BYTE:    slow_case_addr = jni_GetByteField_addr();    break;
@@ -153,7 +153,7 @@
 }
 
 address JNI_FastGetField::generate_fast_get_float_field0(BasicType type) {
-  const char *name;
+  const char *name = NULL;
   switch (type) {
     case T_FLOAT:     name = "jni_fast_GetFloatField";     break;
     case T_DOUBLE:    name = "jni_fast_GetDoubleField";    break;
@@ -206,7 +206,7 @@
 
   slowcase_entry_pclist[count++] = __ pc();
   __ bind (slow);
-  address slow_case_addr;
+  address slow_case_addr = NULL;
   switch (type) {
     case T_FLOAT:     slow_case_addr = jni_GetFloatField_addr();  break;
     case T_DOUBLE:    slow_case_addr = jni_GetDoubleField_addr();
diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp
index 4f7c38a..c59b702 100644
--- a/hotspot/src/os/linux/vm/os_linux.cpp
+++ b/hotspot/src/os/linux/vm/os_linux.cpp
@@ -2755,7 +2755,7 @@
 
 
 int os::Linux::sched_getcpu_syscall(void) {
-  unsigned int cpu;
+  unsigned int cpu = 0;
   int retval = -1;
 
 #if defined(IA32)
@@ -4263,8 +4263,8 @@
       sigaddset(&(actp->sa_mask), sig);
     }
 
-    sa_handler_t hand;
-    sa_sigaction_t sa;
+    sa_handler_t hand = NULL;
+    sa_sigaction_t sa = NULL;
     bool siginfo_flag_set = (actp->sa_flags & SA_SIGINFO) != 0;
     // retrieve the chained handler
     if (siginfo_flag_set) {
@@ -4469,7 +4469,7 @@
 
 static const char* get_signal_handler_name(address handler,
                                            char* buf, int buflen) {
-  int offset;
+  int offset = 0;
   bool found = os::dll_address_to_library_name(handler, buf, buflen, &offset);
   if (found) {
     // skip directory names
diff --git a/hotspot/src/os/posix/vm/os_posix.cpp b/hotspot/src/os/posix/vm/os_posix.cpp
index 3035aa0..d1bf84f 100644
--- a/hotspot/src/os/posix/vm/os_posix.cpp
+++ b/hotspot/src/os/posix/vm/os_posix.cpp
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 1999, 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
@@ -678,6 +678,21 @@
 #if defined(IA64) && !defined(AIX)
     { SIGSEGV, SEGV_PSTKOVF, "SEGV_PSTKOVF", "Paragraph stack overflow" },
 #endif
+#if defined(__sparc) && defined(SOLARIS)
+// define Solaris Sparc M7 ADI SEGV signals
+#if !defined(SEGV_ACCADI)
+#define SEGV_ACCADI 3
+#endif
+    { SIGSEGV, SEGV_ACCADI,  "SEGV_ACCADI",  "ADI not enabled for mapped object." },
+#if !defined(SEGV_ACCDERR)
+#define SEGV_ACCDERR 4
+#endif
+    { SIGSEGV, SEGV_ACCDERR, "SEGV_ACCDERR", "ADI disrupting exception." },
+#if !defined(SEGV_ACCPERR)
+#define SEGV_ACCPERR 5
+#endif
+    { SIGSEGV, SEGV_ACCPERR, "SEGV_ACCPERR", "ADI precise exception." },
+#endif // defined(__sparc) && defined(SOLARIS)
     { SIGBUS,  BUS_ADRALN,   "BUS_ADRALN",   "Invalid address alignment." },
     { SIGBUS,  BUS_ADRERR,   "BUS_ADRERR",   "Nonexistent physical address." },
     { SIGBUS,  BUS_OBJERR,   "BUS_OBJERR",   "Object-specific hardware error." },
diff --git a/hotspot/src/os_cpu/linux_x86/vm/copy_linux_x86.inline.hpp b/hotspot/src/os_cpu/linux_x86/vm/copy_linux_x86.inline.hpp
index 175019b..c35f855 100644
--- a/hotspot/src/os_cpu/linux_x86/vm/copy_linux_x86.inline.hpp
+++ b/hotspot/src/os_cpu/linux_x86/vm/copy_linux_x86.inline.hpp
@@ -30,7 +30,7 @@
   (void)memmove(to, from, count * HeapWordSize);
 #else
   // Includes a zero-count check.
-  intx temp;
+  intx temp = 0;
   __asm__ volatile("        testl   %6,%6         ;"
                    "        jz      7f            ;"
                    "        cmpl    %4,%5         ;"
@@ -88,7 +88,7 @@
   }
 #else
   // Includes a zero-count check.
-  intx temp;
+  intx temp = 0;
   __asm__ volatile("        testl   %6,%6       ;"
                    "        jz      3f          ;"
                    "        cmpl    $32,%6      ;"
@@ -145,7 +145,7 @@
   (void)memmove(to, from, count);
 #else
   // Includes a zero-count check.
-  intx temp;
+  intx temp = 0;
   __asm__ volatile("        testl   %6,%6          ;"
                    "        jz      13f            ;"
                    "        cmpl    %4,%5          ;"
diff --git a/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp b/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp
index 859a156..4775be2 100644
--- a/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp
+++ b/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp
@@ -244,7 +244,6 @@
 bool PICL::open_library() {
   _dl_handle = dlopen("libpicl.so.1", RTLD_LAZY);
   if (_dl_handle == NULL) {
-    warning("PICL (libpicl.so.1) is missing. Performance will not be optimal.");
     return false;
   }
   if (!bind_library_functions()) {
diff --git a/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp b/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp
index 9f04d70..4455ac61 100644
--- a/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp
+++ b/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp
@@ -640,7 +640,7 @@
 
   if (l == r && !lt->is_float_kind()) {
     // pattern: If (a cond a) => simplify to Goto
-    BlockBegin* sux;
+    BlockBegin* sux = NULL;
     switch (x->cond()) {
     case If::eql: sux = x->sux_for(true);  break;
     case If::neq: sux = x->sux_for(false); break;
@@ -648,6 +648,7 @@
     case If::leq: sux = x->sux_for(true);  break;
     case If::gtr: sux = x->sux_for(false); break;
     case If::geq: sux = x->sux_for(true);  break;
+    default: ShouldNotReachHere();
     }
     // If is a safepoint then the debug information should come from the state_before of the If.
     set_canonical(new Goto(sux, x->state_before(), is_safepoint(x, sux)));
@@ -685,7 +686,7 @@
       } else {
         // two successors differ and two successors are the same => simplify to: If (x cmp y)
         // determine new condition & successors
-        If::Condition cond;
+        If::Condition cond = If::eql;
         BlockBegin* tsux = NULL;
         BlockBegin* fsux = NULL;
              if (lss_sux == eql_sux) { cond = If::leq; tsux = lss_sux; fsux = gtr_sux; }
diff --git a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
index 4f82b7e..844bf76 100644
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
@@ -3971,8 +3971,8 @@
   caller_state->truncate_stack(args_base);
   assert(callee_state->stack_size() == 0, "callee stack must be empty");
 
-  Value lock;
-  BlockBegin* sync_handler;
+  Value lock = NULL;
+  BlockBegin* sync_handler = NULL;
 
   // Inline the locking of the receiver if the callee is synchronized
   if (callee->is_synchronized()) {
diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp
index 472f9f8..ed937fe 100644
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp
@@ -3347,7 +3347,7 @@
 }
 
 void LIRGenerator::increment_event_counter(CodeEmitInfo* info, int bci, bool backedge) {
-  int freq_log;
+  int freq_log = 0;
   int level = compilation()->env()->comp_level();
   if (level == CompLevel_limited_profile) {
     freq_log = (backedge ? Tier2BackedgeNotifyFreqLog : Tier2InvokeNotifyFreqLog);
@@ -3368,7 +3368,7 @@
   assert(level > CompLevel_simple, "Shouldn't be here");
 
   int offset = -1;
-  LIR_Opr counter_holder;
+  LIR_Opr counter_holder = NULL;
   if (level == CompLevel_limited_profile) {
     MethodCounters* counters_adr = method->ensure_method_counters();
     if (counters_adr == NULL) {
diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp
index 6be6671..8312a4b 100644
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp
@@ -410,7 +410,7 @@
   }
 
   static LIR_Condition lir_cond(If::Condition cond) {
-    LIR_Condition l;
+    LIR_Condition l = lir_cond_unknown;
     switch (cond) {
     case If::eql: l = lir_cond_equal;        break;
     case If::neq: l = lir_cond_notEqual;     break;
@@ -420,6 +420,7 @@
     case If::gtr: l = lir_cond_greater;      break;
     case If::aeq: l = lir_cond_aboveEqual;   break;
     case If::beq: l = lir_cond_belowEqual;   break;
+    default: fatal("You must pass valid If::Condition");
     };
     return l;
   }
diff --git a/hotspot/src/share/vm/c1/c1_Runtime1.cpp b/hotspot/src/share/vm/c1/c1_Runtime1.cpp
index ca6a35e..f64c60e 100644
--- a/hotspot/src/share/vm/c1/c1_Runtime1.cpp
+++ b/hotspot/src/share/vm/c1/c1_Runtime1.cpp
@@ -312,6 +312,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
@@ -347,6 +348,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);
@@ -363,6 +365,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
diff --git a/hotspot/src/share/vm/ci/ciObjectFactory.cpp b/hotspot/src/share/vm/ci/ciObjectFactory.cpp
index c741531..079974f 100644
--- a/hotspot/src/share/vm/ci/ciObjectFactory.cpp
+++ b/hotspot/src/share/vm/ci/ciObjectFactory.cpp
@@ -413,6 +413,7 @@
     metadata_owner_klass = m->as_method()->get_Method()->constants()->pool_holder();
   } else {
     fatal("Not implemented for other types of metadata");
+    return;
   }
 
   oop metadata_holder = metadata_owner_klass->klass_holder();
diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp
index 2a7e780..e2a64cd 100644
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp
@@ -3188,19 +3188,19 @@
 
   // Field size and offset computation
   int nonstatic_field_size = _super_klass() == NULL ? 0 : _super_klass()->nonstatic_field_size();
-  int next_static_oop_offset;
-  int next_static_double_offset;
-  int next_static_word_offset;
-  int next_static_short_offset;
-  int next_static_byte_offset;
-  int next_nonstatic_oop_offset;
-  int next_nonstatic_double_offset;
-  int next_nonstatic_word_offset;
-  int next_nonstatic_short_offset;
-  int next_nonstatic_byte_offset;
-  int first_nonstatic_oop_offset;
-  int next_nonstatic_field_offset;
-  int next_nonstatic_padded_offset;
+  int next_static_oop_offset = 0;
+  int next_static_double_offset = 0;
+  int next_static_word_offset = 0;
+  int next_static_short_offset = 0;
+  int next_static_byte_offset = 0;
+  int next_nonstatic_oop_offset = 0;
+  int next_nonstatic_double_offset = 0;
+  int next_nonstatic_word_offset = 0;
+  int next_nonstatic_short_offset = 0;
+  int next_nonstatic_byte_offset = 0;
+  int first_nonstatic_oop_offset = 0;
+  int next_nonstatic_field_offset = 0;
+  int next_nonstatic_padded_offset = 0;
 
   // Count the contended fields by type.
   //
@@ -3353,14 +3353,14 @@
     ShouldNotReachHere();
   }
 
-  int nonstatic_oop_space_count   = 0;
-  int nonstatic_word_space_count  = 0;
-  int nonstatic_short_space_count = 0;
-  int nonstatic_byte_space_count  = 0;
-  int nonstatic_oop_space_offset;
-  int nonstatic_word_space_offset;
-  int nonstatic_short_space_offset;
-  int nonstatic_byte_space_offset;
+  int nonstatic_oop_space_count    = 0;
+  int nonstatic_word_space_count   = 0;
+  int nonstatic_short_space_count  = 0;
+  int nonstatic_byte_space_count   = 0;
+  int nonstatic_oop_space_offset   = 0;
+  int nonstatic_word_space_offset  = 0;
+  int nonstatic_short_space_offset = 0;
+  int nonstatic_byte_space_offset  = 0;
 
   // Try to squeeze some of the fields into the gaps due to
   // long/double alignment.
@@ -3432,7 +3432,7 @@
     // contended instance fields are handled below
     if (fs.is_contended() && !fs.access_flags().is_static()) continue;
 
-    int real_offset;
+    int real_offset = 0;
     FieldAllocationType atype = (FieldAllocationType) fs.allocation_type();
 
     // pack the rest of the fields
@@ -3565,7 +3565,7 @@
         // handle statics below
         if (fs.access_flags().is_static()) continue;
 
-        int real_offset;
+        int real_offset = 0;
         FieldAllocationType atype = (FieldAllocationType) fs.allocation_type();
 
         switch (atype) {
diff --git a/hotspot/src/share/vm/classfile/dictionary.cpp b/hotspot/src/share/vm/classfile/dictionary.cpp
index 5e8f5a5..c9a43de 100644
--- a/hotspot/src/share/vm/classfile/dictionary.cpp
+++ b/hotspot/src/share/vm/classfile/dictionary.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2014, 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
@@ -25,6 +25,7 @@
 #include "precompiled.hpp"
 #include "classfile/dictionary.hpp"
 #include "classfile/systemDictionary.hpp"
+#include "classfile/systemDictionaryShared.hpp"
 #include "memory/iterator.hpp"
 #include "oops/oop.inline.hpp"
 #include "prims/jvmtiRedefineClassesTrace.hpp"
@@ -36,9 +37,16 @@
 DictionaryEntry*  Dictionary::_current_class_entry = NULL;
 int               Dictionary::_current_class_index =    0;
 
+size_t Dictionary::entry_size() {
+  if (DumpSharedSpaces) {
+    return SystemDictionaryShared::dictionary_entry_size();
+  } else {
+    return sizeof(DictionaryEntry);
+  }
+}
 
 Dictionary::Dictionary(int table_size)
-  : TwoOopHashtable<Klass*, mtClass>(table_size, sizeof(DictionaryEntry)) {
+  : TwoOopHashtable<Klass*, mtClass>(table_size, (int)entry_size()) {
   _current_class_index = 0;
   _current_class_entry = NULL;
   _pd_cache_table = new ProtectionDomainCacheTable(defaultProtectionDomainCacheSize);
@@ -47,7 +55,7 @@
 
 Dictionary::Dictionary(int table_size, HashtableBucket<mtClass>* t,
                        int number_of_entries)
-  : TwoOopHashtable<Klass*, mtClass>(table_size, sizeof(DictionaryEntry), t, number_of_entries) {
+  : TwoOopHashtable<Klass*, mtClass>(table_size, (int)entry_size(), t, number_of_entries) {
   _current_class_index = 0;
   _current_class_entry = NULL;
   _pd_cache_table = new ProtectionDomainCacheTable(defaultProtectionDomainCacheSize);
@@ -63,6 +71,9 @@
   entry->set_loader_data(loader_data);
   entry->set_pd_set(NULL);
   assert(klass->oop_is_instance(), "Must be");
+  if (DumpSharedSpaces) {
+    SystemDictionaryShared::init_shared_dictionary_entry(klass, entry);
+  }
   return entry;
 }
 
diff --git a/hotspot/src/share/vm/classfile/dictionary.hpp b/hotspot/src/share/vm/classfile/dictionary.hpp
index 180f07e..504e735 100644
--- a/hotspot/src/share/vm/classfile/dictionary.hpp
+++ b/hotspot/src/share/vm/classfile/dictionary.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2014, 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
@@ -53,6 +53,7 @@
   DictionaryEntry* get_entry(int index, unsigned int hash,
                              Symbol* name, ClassLoaderData* loader_data);
 
+protected:
   DictionaryEntry* bucket(int i) {
     return (DictionaryEntry*)Hashtable<Klass*, mtClass>::bucket(i);
   }
@@ -66,6 +67,8 @@
     Hashtable<Klass*, mtClass>::add_entry(index, (HashtableEntry<Klass*, mtClass>*)new_entry);
   }
 
+  static size_t entry_size();
+
 public:
   Dictionary(int table_size);
   Dictionary(int table_size, HashtableBucket<mtClass>* t, int number_of_entries);
diff --git a/hotspot/src/share/vm/classfile/javaClasses.cpp b/hotspot/src/share/vm/classfile/javaClasses.cpp
index c245cc5..65900a2 100644
--- a/hotspot/src/share/vm/classfile/javaClasses.cpp
+++ b/hotspot/src/share/vm/classfile/javaClasses.cpp
@@ -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
@@ -936,7 +936,7 @@
   assert(_group_offset == 0, "offsets should be initialized only once");
 
   Klass* k = SystemDictionary::Thread_klass();
-  compute_offset(_name_offset,      k, vmSymbols::name_name(),      vmSymbols::char_array_signature());
+  compute_offset(_name_offset,      k, vmSymbols::name_name(),      vmSymbols::string_signature());
   compute_offset(_group_offset,     k, vmSymbols::group_name(),     vmSymbols::threadgroup_signature());
   compute_offset(_contextClassLoader_offset, k, vmSymbols::contextClassLoader_name(), vmSymbols::classloader_signature());
   compute_offset(_inheritedAccessControlContext_offset, k, vmSymbols::inheritedAccessControlContext_name(), vmSymbols::accesscontrolcontext_signature());
@@ -966,15 +966,12 @@
 }
 
 
-typeArrayOop java_lang_Thread::name(oop java_thread) {
-  oop name = java_thread->obj_field(_name_offset);
-  assert(name == NULL || (name->is_typeArray() && TypeArrayKlass::cast(name->klass())->element_type() == T_CHAR), "just checking");
-  return typeArrayOop(name);
+oop java_lang_Thread::name(oop java_thread) {
+  return java_thread->obj_field(_name_offset);
 }
 
 
-void java_lang_Thread::set_name(oop java_thread, typeArrayOop name) {
-  assert(java_thread->obj_field(_name_offset) == NULL, "name should be NULL");
+void java_lang_Thread::set_name(oop java_thread, oop name) {
   java_thread->obj_field_put(_name_offset, name);
 }
 
diff --git a/hotspot/src/share/vm/classfile/javaClasses.hpp b/hotspot/src/share/vm/classfile/javaClasses.hpp
index 5e497e6..02784dc 100644
--- a/hotspot/src/share/vm/classfile/javaClasses.hpp
+++ b/hotspot/src/share/vm/classfile/javaClasses.hpp
@@ -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
@@ -343,8 +343,8 @@
   // Set JavaThread for instance
   static void set_thread(oop java_thread, JavaThread* thread);
   // Name
-  static typeArrayOop name(oop java_thread);
-  static void set_name(oop java_thread, typeArrayOop name);
+  static oop name(oop java_thread);
+  static void set_name(oop java_thread, oop name);
   // Priority
   static ThreadPriority priority(oop java_thread);
   static void set_priority(oop java_thread, ThreadPriority priority);
diff --git a/hotspot/src/share/vm/classfile/placeholders.hpp b/hotspot/src/share/vm/classfile/placeholders.hpp
index ca0d85a..f5fc9b4 100644
--- a/hotspot/src/share/vm/classfile/placeholders.hpp
+++ b/hotspot/src/share/vm/classfile/placeholders.hpp
@@ -220,7 +220,7 @@
   }
 
   SeenThread* actionToQueue(PlaceholderTable::classloadAction action) {
-    SeenThread* queuehead;
+    SeenThread* queuehead = NULL;
     switch (action) {
       case PlaceholderTable::LOAD_INSTANCE:
          queuehead = _loadInstanceThreadQ;
diff --git a/hotspot/src/share/vm/classfile/systemDictionary.cpp b/hotspot/src/share/vm/classfile/systemDictionary.cpp
index 46b8847..31be14b 100644
--- a/hotspot/src/share/vm/classfile/systemDictionary.cpp
+++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, 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
@@ -1198,8 +1198,13 @@
 
     if (ik->super() != NULL) {
       Symbol*  cn = ik->super()->name();
-      resolve_super_or_fail(class_name, cn,
-                            class_loader, protection_domain, true, CHECK_(nh));
+      Klass *s = resolve_super_or_fail(class_name, cn,
+                                       class_loader, protection_domain, true, CHECK_(nh));
+      if (s != ik->super()) {
+        // The dynamically resolved super class is not the same as the one we used during dump time,
+        // so we cannot use ik.
+        return nh;
+      }
     }
 
     Array<Klass*>* interfaces = ik->local_interfaces();
@@ -1212,7 +1217,12 @@
       // reinitialized yet (they will be once the interface classes
       // are loaded)
       Symbol*  name  = k->name();
-      resolve_super_or_fail(class_name, name, class_loader, protection_domain, false, CHECK_(nh));
+      Klass* i = resolve_super_or_fail(class_name, name, class_loader, protection_domain, false, CHECK_(nh));
+      if (k != i) {
+        // The dynamically resolved interface class is not the same as the one we used during dump time,
+        // so we cannot use ik.
+        return nh;
+      }
     }
 
     // Adjust methods to recover missing data.  They need addresses for
diff --git a/hotspot/src/share/vm/classfile/systemDictionaryShared.hpp b/hotspot/src/share/vm/classfile/systemDictionaryShared.hpp
index bc68879..e1adf8b 100644
--- a/hotspot/src/share/vm/classfile/systemDictionaryShared.hpp
+++ b/hotspot/src/share/vm/classfile/systemDictionaryShared.hpp
@@ -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
@@ -26,6 +26,7 @@
 #ifndef SHARE_VM_CLASSFILE_SYSTEMDICTIONARYSHARED_HPP
 #define SHARE_VM_CLASSFILE_SYSTEMDICTIONARYSHARED_HPP
 
+#include "classfile/dictionary.hpp"
 #include "classfile/systemDictionary.hpp"
 
 class SystemDictionaryShared: public SystemDictionary {
@@ -42,6 +43,22 @@
     oop class_loader = loader_data->class_loader();
     return (class_loader == NULL);
   }
+
+  static size_t dictionary_entry_size() {
+    return sizeof(DictionaryEntry);
+  }
+  static void init_shared_dictionary_entry(Klass* k, DictionaryEntry* entry) {}
+
+  // The (non-application) CDS implementation supports only classes in the boot
+  // class loader, which ensures that the verification dependencies are the same
+  // during archive creation time and runtime. Thus we can do the dependency checks
+  // entirely during archive creation time.
+  static void add_verification_dependency(Klass* k, Symbol* accessor_clsname,
+                                          Symbol* target_clsname) {}
+  static void finalize_verification_dependencies() {}
+  static bool check_verification_dependencies(Klass* k, Handle class_loader,
+                                              Handle protection_domain,
+                                              char** message_buffer, TRAPS) {return true;}
 };
 
 #endif // SHARE_VM_CLASSFILE_SYSTEMDICTIONARYSHARED_HPP
diff --git a/hotspot/src/share/vm/classfile/verificationType.cpp b/hotspot/src/share/vm/classfile/verificationType.cpp
index 120d9a3..716a72d 100644
--- a/hotspot/src/share/vm/classfile/verificationType.cpp
+++ b/hotspot/src/share/vm/classfile/verificationType.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2014, 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
@@ -24,6 +24,7 @@
 
 #include "precompiled.hpp"
 #include "classfile/symbolTable.hpp"
+#include "classfile/systemDictionaryShared.hpp"
 #include "classfile/verificationType.hpp"
 #include "classfile/verifier.hpp"
 
@@ -73,7 +74,23 @@
       Klass* from_class = SystemDictionary::resolve_or_fail(
           from.name(), Handle(THREAD, klass->class_loader()),
           Handle(THREAD, klass->protection_domain()), true, CHECK_false);
-      return InstanceKlass::cast(from_class)->is_subclass_of(this_class());
+      bool result = InstanceKlass::cast(from_class)->is_subclass_of(this_class());
+      if (result && DumpSharedSpaces) {
+        if (klass()->is_subclass_of(from_class) && klass()->is_subclass_of(this_class())) {
+          // No need to save verification dependency. At run time, <klass> will be
+          // loaded from the archived only if <from_class> and <this_class> are
+          // also loaded from the archive. I.e., all 3 classes are exactly the same
+          // as we saw at archive creation time.
+        } else {
+          // Save the dependency. At run time, we need to check that the condition
+          // from_class->is_subclass_of(this_class() is still true.
+          Symbol* accessor_clsname = from.name();
+          Symbol* target_clsname = this_class()->name();
+          SystemDictionaryShared::add_verification_dependency(klass(),
+                       accessor_clsname, target_clsname);
+        }
+      }
+      return result;
     }
   } else if (is_array() && from.is_array()) {
     VerificationType comp_this = get_component(context, CHECK_false);
diff --git a/hotspot/src/share/vm/classfile/verifier.cpp b/hotspot/src/share/vm/classfile/verifier.cpp
index ed65f0d..e1f9f23 100644
--- a/hotspot/src/share/vm/classfile/verifier.cpp
+++ b/hotspot/src/share/vm/classfile/verifier.cpp
@@ -2323,9 +2323,17 @@
       case Bytecodes::_ifnonnull:
         target = bcs.dest();
         if (visited_branches->contains(bci)) {
-          if (bci_stack->is_empty()) return true;
-          // Pop a bytecode starting offset and scan from there.
-          bcs.set_start(bci_stack->pop());
+          if (bci_stack->is_empty()) {
+            if (handler_stack->is_empty()) {
+              return true;
+            } else {
+              // Parse the catch handlers for try blocks containing athrow.
+              bcs.set_start(handler_stack->pop());
+            }
+          } else {
+            // Pop a bytecode starting offset and scan from there.
+            bcs.set_start(bci_stack->pop());
+          }
         } else {
           if (target > bci) { // forward branch
             if (target >= code_length) return false;
@@ -2348,9 +2356,17 @@
       case Bytecodes::_goto_w:
         target = (opcode == Bytecodes::_goto ? bcs.dest() : bcs.dest_w());
         if (visited_branches->contains(bci)) {
-          if (bci_stack->is_empty()) return true;
-          // Been here before, pop new starting offset from stack.
-          bcs.set_start(bci_stack->pop());
+          if (bci_stack->is_empty()) {
+            if (handler_stack->is_empty()) {
+              return true;
+            } else {
+              // Parse the catch handlers for try blocks containing athrow.
+              bcs.set_start(handler_stack->pop());
+            }
+          } else {
+            // Been here before, pop new starting offset from stack.
+            bcs.set_start(bci_stack->pop());
+          }
         } else {
           if (target >= code_length) return false;
           // Continue scanning from the target onward.
diff --git a/hotspot/src/share/vm/compiler/oopMap.hpp b/hotspot/src/share/vm/compiler/oopMap.hpp
index 0a73fc5..f7f0a1e 100644
--- a/hotspot/src/share/vm/compiler/oopMap.hpp
+++ b/hotspot/src/share/vm/compiler/oopMap.hpp
@@ -75,8 +75,8 @@
 
   // Constructors
   OopMapValue () { set_value(0); set_content_reg(VMRegImpl::Bad()); }
-  OopMapValue (VMReg reg, oop_types t) { set_reg_type(reg,t); }
-  OopMapValue (VMReg reg, oop_types t, VMReg reg2) { set_reg_type(reg,t); set_content_reg(reg2); }
+  OopMapValue (VMReg reg, oop_types t) { set_reg_type(reg, t); set_content_reg(VMRegImpl::Bad()); }
+  OopMapValue (VMReg reg, oop_types t, VMReg reg2) { set_reg_type(reg, t); set_content_reg(reg2); }
   OopMapValue (CompressedReadStream* stream) { read_from(stream); }
 
   // Archiving
@@ -89,7 +89,7 @@
 
   void read_from(CompressedReadStream* stream) {
     set_value(stream->read_int());
-    if(is_callee_saved() || is_derived_oop()) {
+    if (is_callee_saved() || is_derived_oop()) {
       set_content_reg(VMRegImpl::as_VMReg(stream->read_int(), true));
     }
   }
diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp
index de5555f..14f09d1 100644
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp
@@ -2288,7 +2288,7 @@
   }
 
   // Used for PrintGC
-  size_t prev_used;
+  size_t prev_used = 0;
   if (PrintGC && Verbose) {
     prev_used = _cmsGen->used(); // XXXPERM
   }
@@ -8624,7 +8624,7 @@
 
   HeapWord* const fc_addr = (HeapWord*) fc;
 
-  bool coalesce;
+  bool coalesce = false;
   const size_t left  = pointer_delta(fc_addr, freeFinger());
   const size_t right = chunkSize;
   switch (FLSCoalescePolicy) {
diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
index 6b654a5..76bfcd6 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
@@ -3991,8 +3991,15 @@
 
     TraceCPUTime tcpu(G1Log::finer(), true, gclog_or_tty);
 
-    uint active_workers = (G1CollectedHeap::use_parallel_gc_threads() ?
-                                workers()->active_workers() : 1);
+    uint active_workers = AdaptiveSizePolicy::calc_active_workers(workers()->total_workers(),
+                                                                  workers()->active_workers(),
+                                                                  Threads::number_of_non_daemon_threads());
+    assert(UseDynamicNumberOfGCThreads ||
+           active_workers == workers()->total_workers(),
+           "If not dynamic should be using all the  workers");
+    workers()->set_active_workers(active_workers);
+
+
     double pause_start_sec = os::elapsedTime();
     g1_policy()->phase_times()->note_gc_start(active_workers, mark_in_progress());
     log_gc_header();
@@ -5761,23 +5768,11 @@
   hot_card_cache->reset_hot_cache_claimed_index();
   hot_card_cache->set_use_cache(false);
 
-  uint n_workers;
-  if (G1CollectedHeap::use_parallel_gc_threads()) {
-    n_workers =
-      AdaptiveSizePolicy::calc_active_workers(workers()->total_workers(),
-                                     workers()->active_workers(),
-                                     Threads::number_of_non_daemon_threads());
+  const uint n_workers = workers()->active_workers();
     assert(UseDynamicNumberOfGCThreads ||
            n_workers == workers()->total_workers(),
            "If not dynamic should be using all the  workers");
-    workers()->set_active_workers(n_workers);
     set_par_threads(n_workers);
-  } else {
-    assert(n_par_threads() == 0,
-           "Should be the original non-parallel value");
-    n_workers = 1;
-  }
-
 
   init_for_evac_failure(NULL);
 
diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.cpp
index 9891e10..c037110 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.cpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.cpp
@@ -154,28 +154,28 @@
     _has_new_data = true;
   }
 
-  double average(){
-    calculate_totals();
+  double average(uint active_threads){
+    calculate_totals(active_threads);
     return _average;
   }
 
-  T sum() {
-    calculate_totals();
+  T sum(uint active_threads) {
+    calculate_totals(active_threads);
     return _sum;
   }
 
-  T minimum() {
-    calculate_totals();
+  T minimum(uint active_threads) {
+    calculate_totals(active_threads);
     return _min;
   }
 
-  T maximum() {
-    calculate_totals();
+  T maximum(uint active_threads) {
+    calculate_totals(active_threads);
     return _max;
   }
 
   void reset() PRODUCT_RETURN;
-  void verify() PRODUCT_RETURN;
+  void verify(uint active_threads) PRODUCT_RETURN;
 
   void set_enabled(bool enabled) { _enabled = enabled; }
 
@@ -183,7 +183,7 @@
 
  private:
 
-  void calculate_totals(){
+  void calculate_totals(uint active_threads){
     if (!_has_new_data) {
       return;
     }
@@ -191,13 +191,14 @@
     _sum = (T)0;
     _min = _data[0];
     _max = _min;
-    for (uint i = 0; i < _length; ++i) {
+    assert(active_threads <= _length, "Wrong number of active threads");
+    for (uint i = 0; i < active_threads; ++i) {
       T val = _data[i];
       _sum += val;
       _min = MIN2(_min, val);
       _max = MAX2(_max, val);
     }
-    _average = (double)_sum / (double)_length;
+    _average = (double)_sum / (double)active_threads;
     _has_new_data = false;
   }
 };
@@ -226,17 +227,18 @@
 }
 
 template <class T>
-void WorkerDataArray<T>::verify() {
+void WorkerDataArray<T>::verify(uint active_threads) {
   if (!_enabled) {
     return;
   }
 
-  for (uint i = 0; i < _length; i++) {
+  assert(active_threads <= _length, "Wrong number of active threads");
+  for (uint i = 0; i < active_threads; i++) {
     assert(_data[i] != WorkerDataArray<T>::uninitialized(),
         err_msg("Invalid data for worker %u in '%s'", i, _title));
   }
   if (_thread_work_items != NULL) {
-    _thread_work_items->verify();
+    _thread_work_items->verify(active_threads);
   }
 }
 
@@ -321,7 +323,7 @@
   }
 
   for (int i = 0; i < GCParPhasesSentinel; i++) {
-    _gc_par_phases[i]->verify();
+    _gc_par_phases[i]->verify(_active_gc_threads);
   }
 }
 
@@ -378,7 +380,7 @@
 
 // return the average time for a phase in milliseconds
 double G1GCPhaseTimes::average_time_ms(GCParPhases phase) {
-  return _gc_par_phases[phase]->average() * 1000.0;
+  return _gc_par_phases[phase]->average(_active_gc_threads) * 1000.0;
 }
 
 double G1GCPhaseTimes::get_time_ms(GCParPhases phase, uint worker_i) {
@@ -386,15 +388,15 @@
 }
 
 double G1GCPhaseTimes::sum_time_ms(GCParPhases phase) {
-  return _gc_par_phases[phase]->sum() * 1000.0;
+  return _gc_par_phases[phase]->sum(_active_gc_threads) * 1000.0;
 }
 
 double G1GCPhaseTimes::min_time_ms(GCParPhases phase) {
-  return _gc_par_phases[phase]->minimum() * 1000.0;
+  return _gc_par_phases[phase]->minimum(_active_gc_threads) * 1000.0;
 }
 
 double G1GCPhaseTimes::max_time_ms(GCParPhases phase) {
-  return _gc_par_phases[phase]->maximum() * 1000.0;
+  return _gc_par_phases[phase]->maximum(_active_gc_threads) * 1000.0;
 }
 
 size_t G1GCPhaseTimes::get_thread_work_item(GCParPhases phase, uint worker_i) {
@@ -404,22 +406,22 @@
 
 size_t G1GCPhaseTimes::sum_thread_work_items(GCParPhases phase) {
   assert(_gc_par_phases[phase]->thread_work_items() != NULL, "No sub count");
-  return _gc_par_phases[phase]->thread_work_items()->sum();
+  return _gc_par_phases[phase]->thread_work_items()->sum(_active_gc_threads);
 }
 
 double G1GCPhaseTimes::average_thread_work_items(GCParPhases phase) {
   assert(_gc_par_phases[phase]->thread_work_items() != NULL, "No sub count");
-  return _gc_par_phases[phase]->thread_work_items()->average();
+  return _gc_par_phases[phase]->thread_work_items()->average(_active_gc_threads);
 }
 
 size_t G1GCPhaseTimes::min_thread_work_items(GCParPhases phase) {
   assert(_gc_par_phases[phase]->thread_work_items() != NULL, "No sub count");
-  return _gc_par_phases[phase]->thread_work_items()->minimum();
+  return _gc_par_phases[phase]->thread_work_items()->minimum(_active_gc_threads);
 }
 
 size_t G1GCPhaseTimes::max_thread_work_items(GCParPhases phase) {
   assert(_gc_par_phases[phase]->thread_work_items() != NULL, "No sub count");
-  return _gc_par_phases[phase]->thread_work_items()->maximum();
+  return _gc_par_phases[phase]->thread_work_items()->maximum(_active_gc_threads);
 }
 
 class G1GCParPhasePrinter : public StackObj {
@@ -455,14 +457,16 @@
   }
 
   void print_time_values(LineBuffer& buf, G1GCPhaseTimes::GCParPhases phase_id, WorkerDataArray<double>* phase) {
-    for (uint i = 0; i < phase->_length; ++i) {
+    uint active_length = _phase_times->_active_gc_threads;
+    for (uint i = 0; i < active_length; ++i) {
       buf.append("  %.1lf", _phase_times->get_time_ms(phase_id, i));
     }
     buf.print_cr();
   }
 
   void print_count_values(LineBuffer& buf, G1GCPhaseTimes::GCParPhases phase_id, WorkerDataArray<size_t>* thread_work_items) {
-    for (uint i = 0; i < thread_work_items->_length; ++i) {
+    uint active_length = _phase_times->_active_gc_threads;
+    for (uint i = 0; i < active_length; ++i) {
       buf.append("  " SIZE_FORMAT, _phase_times->get_thread_work_item(phase_id, i));
     }
     buf.print_cr();
diff --git a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp
index d95d379..ef5b437 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp
@@ -794,7 +794,9 @@
                                  "in region "HR_FORMAT,
                                  (void*) obj,
                                  HR_FORMAT_PARAMS(to));
-          obj->print_on(gclog_or_tty);
+          if (obj->is_oop()) {
+            obj->print_on(gclog_or_tty);
+          }
           gclog_or_tty->print_cr("Obj head CTE = %d, field CTE = %d.",
                         cv_obj, cv_field);
           gclog_or_tty->print_cr("----------");
diff --git a/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp b/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp
index 7a6cfdf..662f4f1 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp
@@ -572,7 +572,7 @@
   assert(_n_fine_entries == _max_fine_entries, "Precondition");
   PerRegionTable* max = NULL;
   jint max_occ = 0;
-  PerRegionTable** max_prev;
+  PerRegionTable** max_prev = NULL;
   size_t max_ind;
 
   size_t i = _fine_eviction_start;
@@ -608,6 +608,7 @@
   }
 
   guarantee(max != NULL, "Since _n_fine_entries > 0");
+  guarantee(max_prev != NULL, "Since max != NULL.");
 
   // Set the corresponding coarse bit.
   size_t max_hrm_index = (size_t) max->hr()->hrm_index();
@@ -1168,7 +1169,7 @@
 
 void HeapRegionRemSet::print_recorded() {
   int cur_evnt = 0;
-  Event cur_evnt_kind;
+  Event cur_evnt_kind = Event_illegal;
   int cur_evnt_ind = 0;
   if (_n_recorded_events > 0) {
     cur_evnt_kind = _recorded_events[cur_evnt];
diff --git a/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.hpp b/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.hpp
index 221651c..1646e8c 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.hpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.hpp
@@ -232,7 +232,7 @@
 
 public:
   enum Event {
-    Event_EvacStart, Event_EvacEnd, Event_RSUpdateEnd
+    Event_EvacStart, Event_EvacEnd, Event_RSUpdateEnd, Event_illegal
   };
 
 private:
diff --git a/hotspot/src/share/vm/gc_implementation/shared/adaptiveSizePolicy.cpp b/hotspot/src/share/vm/gc_implementation/shared/adaptiveSizePolicy.cpp
index 72cda5e..3bfbddc 100644
--- a/hotspot/src/share/vm/gc_implementation/shared/adaptiveSizePolicy.cpp
+++ b/hotspot/src/share/vm/gc_implementation/shared/adaptiveSizePolicy.cpp
@@ -168,7 +168,7 @@
 
   if (TraceDynamicGCThreads) {
      gclog_or_tty->print_cr("GCTaskManager::calc_default_active_workers() : "
-       "active_workers(): %d  new_acitve_workers: %d  "
+       "active_workers(): %d  new_active_workers: %d  "
        "prev_active_workers: %d\n"
        " active_workers_by_JT: %d  active_workers_by_heap_size: %d",
        (int) active_workers, (int) new_active_workers, (int) prev_active_workers,
@@ -193,8 +193,9 @@
      (!FLAG_IS_DEFAULT(ParallelGCThreads) && !ForceDynamicNumberOfGCThreads)) {
     new_active_workers = total_workers;
   } else {
+    uintx min_workers = (total_workers == 1) ? 1 : 2;
     new_active_workers = calc_default_active_workers(total_workers,
-                                                     2, /* Minimum number of workers */
+                                                     min_workers,
                                                      active_workers,
                                                      application_workers);
   }
diff --git a/hotspot/src/share/vm/interpreter/bytecodeStream.cpp b/hotspot/src/share/vm/interpreter/bytecodeStream.cpp
index bf03c08..6f6d7ea 100644
--- a/hotspot/src/share/vm/interpreter/bytecodeStream.cpp
+++ b/hotspot/src/share/vm/interpreter/bytecodeStream.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, 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
@@ -31,12 +31,12 @@
   // set next bytecode position
   address bcp = RawBytecodeStream::bcp();
   address end = method()->code_base() + end_bci();
-  int l = Bytecodes::raw_special_length_at(bcp, end);
-  if (l <= 0 || (_bci + l) > _end_bci) {
+  int len = Bytecodes::raw_special_length_at(bcp, end);
+  // Very large tableswitch or lookupswitch size can cause _next_bci to overflow.
+  if (len <= 0 || (_bci > _end_bci - len) || (_bci - len >= _next_bci)) {
     code = Bytecodes::_illegal;
   } else {
-    _next_bci += l;
-    assert(_bci < _next_bci, "length must be > 0");
+    _next_bci += len;
     // set attributes
     _is_wide = false;
     // check for special (uncommon) cases
diff --git a/hotspot/src/share/vm/interpreter/bytecodeStream.hpp b/hotspot/src/share/vm/interpreter/bytecodeStream.hpp
index cf5500a..a931079 100644
--- a/hotspot/src/share/vm/interpreter/bytecodeStream.hpp
+++ b/hotspot/src/share/vm/interpreter/bytecodeStream.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, 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
@@ -149,12 +149,15 @@
     code        = Bytecodes::code_or_bp_at(bcp);
 
     // set next bytecode position
-    int l = Bytecodes::length_for(code);
-    if (l > 0 && (_bci + l) <= _end_bci) {
+    int len = Bytecodes::length_for(code);
+    if (len > 0 && (_bci <= _end_bci - len)) {
       assert(code != Bytecodes::_wide && code != Bytecodes::_tableswitch
              && code != Bytecodes::_lookupswitch, "can't be special bytecode");
       _is_wide = false;
-      _next_bci += l;
+      _next_bci += len;
+      if (_next_bci <= _bci) { // Check for integer overflow
+        code = Bytecodes::_illegal;
+      }
       _raw_code = code;
       return code;
     } else {
@@ -203,19 +206,23 @@
       // note that we cannot advance before having the
       // tty bytecode otherwise the stepping is wrong!
       // (carefull: length_for(...) must be used first!)
-      int l = Bytecodes::length_for(code);
-      if (l == 0) l = Bytecodes::length_at(_method(), bcp);
-      _next_bci  += l;
-      assert(_bci < _next_bci, "length must be > 0");
-      // set attributes
-      _is_wide      = false;
-      // check for special (uncommon) cases
-      if (code == Bytecodes::_wide) {
-        raw_code = (Bytecodes::Code)bcp[1];
-        code = raw_code;  // wide BCs are always Java-normal
-        _is_wide = true;
+      int len = Bytecodes::length_for(code);
+      if (len == 0) len = Bytecodes::length_at(_method(), bcp);
+      if (len <= 0 || (_bci > _end_bci - len) || (_bci - len >= _next_bci)) {
+        raw_code = code = Bytecodes::_illegal;
+      } else {
+        _next_bci  += len;
+        assert(_bci < _next_bci, "length must be > 0");
+        // set attributes
+        _is_wide      = false;
+        // check for special (uncommon) cases
+        if (code == Bytecodes::_wide) {
+          raw_code = (Bytecodes::Code)bcp[1];
+          code = raw_code;  // wide BCs are always Java-normal
+          _is_wide = true;
+        }
+        assert(Bytecodes::is_java_code(code), "sanity check");
       }
-      assert(Bytecodes::is_java_code(code), "sanity check");
     }
     _raw_code = raw_code;
     _code = code;
diff --git a/hotspot/src/share/vm/interpreter/templateInterpreter.cpp b/hotspot/src/share/vm/interpreter/templateInterpreter.cpp
index 4af52d8..1520c7b 100644
--- a/hotspot/src/share/vm/interpreter/templateInterpreter.cpp
+++ b/hotspot/src/share/vm/interpreter/templateInterpreter.cpp
@@ -528,7 +528,7 @@
   if (StopInterpreterAt > 0)                                     stop_interpreter_at();
   __ verify_FPU(1, t->tos_in());
 #endif // !PRODUCT
-  int step;
+  int step = 0;
   if (!t->does_dispatch()) {
     step = t->is_wide() ? Bytecodes::wide_length_for(t->bytecode()) : Bytecodes::length_for(t->bytecode());
     if (tos_out == ilgl) tos_out = t->tos_out();
diff --git a/hotspot/src/share/vm/memory/allocation.cpp b/hotspot/src/share/vm/memory/allocation.cpp
index 97143e8..1fe4b36 100644
--- a/hotspot/src/share/vm/memory/allocation.cpp
+++ b/hotspot/src/share/vm/memory/allocation.cpp
@@ -83,7 +83,7 @@
 }
 
 void* ResourceObj::operator new(size_t size, allocation_type type, MEMFLAGS flags) throw() {
-  address res;
+  address res = NULL;
   switch (type) {
    case C_HEAP:
     res = (address)AllocateHeap(size, flags, CALLER_PC);
@@ -105,8 +105,8 @@
 
 void* ResourceObj::operator new(size_t size, const std::nothrow_t&  nothrow_constant,
     allocation_type type, MEMFLAGS flags) throw() {
-  //should only call this with std::nothrow, use other operator new() otherwise
-  address res;
+  // should only call this with std::nothrow, use other operator new() otherwise
+  address res = NULL;
   switch (type) {
    case C_HEAP:
     res = (address)AllocateHeap(size, flags, CALLER_PC, AllocFailStrategy::RETURN_NULL);
diff --git a/hotspot/src/share/vm/memory/metaspaceShared.cpp b/hotspot/src/share/vm/memory/metaspaceShared.cpp
index 71fbcb9..d5826d6 100644
--- a/hotspot/src/share/vm/memory/metaspaceShared.cpp
+++ b/hotspot/src/share/vm/memory/metaspaceShared.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2014, 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
@@ -30,6 +30,7 @@
 #include "classfile/sharedClassUtil.hpp"
 #include "classfile/symbolTable.hpp"
 #include "classfile/systemDictionary.hpp"
+#include "classfile/systemDictionaryShared.hpp"
 #include "code/codeCache.hpp"
 #include "memory/filemap.hpp"
 #include "memory/gcLocker.hpp"
@@ -53,6 +54,7 @@
 bool MetaspaceShared::_check_classes_made_progress;
 bool MetaspaceShared::_has_error_classes;
 bool MetaspaceShared::_archive_loading_failed = false;
+bool MetaspaceShared::_remapped_readwrite = false;
 // Read/write a data stream for restoring/preserving metadata pointers and
 // miscellaneous data from/to the shared archive file.
 
@@ -684,6 +686,10 @@
       exit(1);
     }
   }
+
+  // Copy the dependencies from C_HEAP-alloced GrowableArrays to RO-alloced
+  // Arrays
+  SystemDictionaryShared::finalize_verification_dependencies();
 }
 
 void MetaspaceShared::prepare_for_dumping() {
@@ -1096,6 +1102,7 @@
     if (!mapinfo->remap_shared_readonly_as_readwrite()) {
       return false;
     }
+    _remapped_readwrite = true;
   }
   return true;
 }
diff --git a/hotspot/src/share/vm/memory/metaspaceShared.hpp b/hotspot/src/share/vm/memory/metaspaceShared.hpp
index 837625b..2f3abae 100644
--- a/hotspot/src/share/vm/memory/metaspaceShared.hpp
+++ b/hotspot/src/share/vm/memory/metaspaceShared.hpp
@@ -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
@@ -55,6 +55,7 @@
   static bool _check_classes_made_progress;
   static bool _has_error_classes;
   static bool _archive_loading_failed;
+  static bool _remapped_readwrite;
  public:
   enum {
     vtbl_list_size         = 17,   // number of entries in the shared space vtable list.
@@ -123,6 +124,10 @@
   // sharing is enabled. Simply returns true if sharing is not enabled
   // or if the remapping has already been done by a prior call.
   static bool remap_shared_readonly_as_readwrite() NOT_CDS_RETURN_(true);
+  static bool remapped_readwrite() {
+    CDS_ONLY(return _remapped_readwrite);
+    NOT_CDS(return false);
+  }
 
   static void print_shared_spaces();
 
diff --git a/hotspot/src/share/vm/memory/universe.cpp b/hotspot/src/share/vm/memory/universe.cpp
index a0febc5..2e1e90f 100644
--- a/hotspot/src/share/vm/memory/universe.cpp
+++ b/hotspot/src/share/vm/memory/universe.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, 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
@@ -124,6 +124,7 @@
 objArrayOop Universe::_preallocated_out_of_memory_error_array = NULL;
 volatile jint Universe::_preallocated_out_of_memory_error_avail_count = 0;
 bool Universe::_verify_in_progress                    = false;
+long Universe::verify_flags                           = Universe::Verify_All;
 oop Universe::_null_ptr_exception_instance            = NULL;
 oop Universe::_arithmetic_exception_instance          = NULL;
 oop Universe::_virtual_machine_error_instance         = NULL;
@@ -683,6 +684,9 @@
       MetaspaceShared::prepare_for_dumping();
     }
   }
+  if (strlen(VerifySubSet) > 0) {
+    Universe::initialize_verify_flags();
+  }
 
   return JNI_OK;
 }
@@ -1361,6 +1365,53 @@
   st->print_cr("}");
 }
 
+void Universe::initialize_verify_flags() {
+  verify_flags = 0;
+  const char delimiter[] = " ,";
+
+  size_t length = strlen(VerifySubSet);
+  char* subset_list = NEW_C_HEAP_ARRAY(char, length + 1, mtInternal);
+  strncpy(subset_list, VerifySubSet, length + 1);
+
+  char* token = strtok(subset_list, delimiter);
+  while (token != NULL) {
+    if (strcmp(token, "threads") == 0) {
+      verify_flags |= Verify_Threads;
+    } else if (strcmp(token, "heap") == 0) {
+      verify_flags |= Verify_Heap;
+    } else if (strcmp(token, "symbol_table") == 0) {
+      verify_flags |= Verify_SymbolTable;
+    } else if (strcmp(token, "string_table") == 0) {
+      verify_flags |= Verify_StringTable;
+    } else if (strcmp(token, "codecache") == 0) {
+      verify_flags |= Verify_CodeCache;
+    } else if (strcmp(token, "dictionary") == 0) {
+      verify_flags |= Verify_SystemDictionary;
+    } else if (strcmp(token, "classloader_data_graph") == 0) {
+      verify_flags |= Verify_ClassLoaderDataGraph;
+    } else if (strcmp(token, "metaspace") == 0) {
+      verify_flags |= Verify_MetaspaceAux;
+    } else if (strcmp(token, "jni_handles") == 0) {
+      verify_flags |= Verify_JNIHandles;
+    } else if (strcmp(token, "c-heap") == 0) {
+      verify_flags |= Verify_CHeap;
+    } else if (strcmp(token, "codecache_oops") == 0) {
+      verify_flags |= Verify_CodeCacheOops;
+    } else {
+      vm_exit_during_initialization(err_msg("VerifySubSet: \'%s\' memory sub-system is unknown, please correct it", token));
+    }
+    token = strtok(NULL, delimiter);
+  }
+  FREE_C_HEAP_ARRAY(char, subset_list, mtInternal);
+}
+
+bool Universe::should_verify_subset(uint subset) {
+  if (verify_flags & subset) {
+    return true;
+  }
+  return false;
+}
+
 void Universe::verify(VerifyOption option, const char* prefix, bool silent) {
   // The use of _verify_in_progress is a temporary work around for
   // 6320749.  Don't bother with a creating a class to set and clear
@@ -1380,33 +1431,55 @@
 
   if (!silent) gclog_or_tty->print("%s", prefix);
   if (!silent) gclog_or_tty->print("[Verifying ");
-  if (!silent) gclog_or_tty->print("threads ");
-  Threads::verify();
-  if (!silent) gclog_or_tty->print("heap ");
-  heap()->verify(silent, option);
-  if (!silent) gclog_or_tty->print("syms ");
-  SymbolTable::verify();
-  if (!silent) gclog_or_tty->print("strs ");
-  StringTable::verify();
+  if (should_verify_subset(Verify_Threads)) {
+    if (!silent) gclog_or_tty->print("Threads ");
+    Threads::verify();
+  }
+  if (should_verify_subset(Verify_Heap)) {
+    if (!silent) gclog_or_tty->print("Heap ");
+    heap()->verify(silent, option);
+  }
+  if (should_verify_subset(Verify_SymbolTable)) {
+    if (!silent) gclog_or_tty->print("SymbolTable ");
+    SymbolTable::verify();
+  }
+  if (should_verify_subset(Verify_StringTable)) {
+    if (!silent) gclog_or_tty->print("StringTable ");
+    StringTable::verify();
+  }
+  if (should_verify_subset(Verify_CodeCache)) {
   {
     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
-    if (!silent) gclog_or_tty->print("zone ");
+    if (!silent) gclog_or_tty->print("CodeCache ");
     CodeCache::verify();
   }
-  if (!silent) gclog_or_tty->print("dict ");
-  SystemDictionary::verify();
+  }
+  if (should_verify_subset(Verify_SystemDictionary)) {
+    if (!silent) gclog_or_tty->print("SystemDictionary ");
+    SystemDictionary::verify();
+  }
 #ifndef PRODUCT
-  if (!silent) gclog_or_tty->print("cldg ");
-  ClassLoaderDataGraph::verify();
+  if (should_verify_subset(Verify_ClassLoaderDataGraph)) {
+    if (!silent) gclog_or_tty->print("ClassLoaderDataGraph ");
+    ClassLoaderDataGraph::verify();
+  }
 #endif
-  if (!silent) gclog_or_tty->print("metaspace chunks ");
-  MetaspaceAux::verify_free_chunks();
-  if (!silent) gclog_or_tty->print("hand ");
-  JNIHandles::verify();
-  if (!silent) gclog_or_tty->print("C-heap ");
-  os::check_heap();
-  if (!silent) gclog_or_tty->print("code cache ");
-  CodeCache::verify_oops();
+  if (should_verify_subset(Verify_MetaspaceAux)) {
+    if (!silent) gclog_or_tty->print("MetaspaceAux ");
+    MetaspaceAux::verify_free_chunks();
+  }
+  if (should_verify_subset(Verify_JNIHandles)) {
+    if (!silent) gclog_or_tty->print("JNIHandles ");
+    JNIHandles::verify();
+  }
+  if (should_verify_subset(Verify_CHeap)) {
+    if (!silent) gclog_or_tty->print("C-heap ");
+    os::check_heap();
+  }
+  if (should_verify_subset(Verify_CodeCacheOops)) {
+    if (!silent) gclog_or_tty->print("CodeCache Oops ");
+    CodeCache::verify_oops();
+  }
   if (!silent) gclog_or_tty->print_cr("]");
 
   _verify_in_progress = false;
diff --git a/hotspot/src/share/vm/memory/universe.hpp b/hotspot/src/share/vm/memory/universe.hpp
index db806ef..3c6a89d 100644
--- a/hotspot/src/share/vm/memory/universe.hpp
+++ b/hotspot/src/share/vm/memory/universe.hpp
@@ -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
@@ -247,6 +247,7 @@
   static int _verify_count;                           // number of verifies done
   // True during call to verify().  Should only be set/cleared in verify().
   static bool _verify_in_progress;
+  static long verify_flags;
 
   static void compute_verify_oop_data();
 
@@ -425,6 +426,22 @@
   static void init_self_patching_vtbl_list(void** list, int count);
 
   // Debugging
+  enum VERIFY_FLAGS {
+    Verify_Threads = 1,
+    Verify_Heap = 2,
+    Verify_SymbolTable = 4,
+    Verify_StringTable = 8,
+    Verify_CodeCache = 16,
+    Verify_SystemDictionary = 32,
+    Verify_ClassLoaderDataGraph = 64,
+    Verify_MetaspaceAux = 128,
+    Verify_JNIHandles = 256,
+    Verify_CHeap = 512,
+    Verify_CodeCacheOops = 1024,
+    Verify_All = -1
+  };
+  static void initialize_verify_flags();
+  static bool should_verify_subset(uint subset);
   static bool verify_in_progress() { return _verify_in_progress; }
   static void verify(VerifyOption option, const char* prefix, bool silent = VerifySilently);
   static void verify(const char* prefix, bool silent = VerifySilently) {
diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp
index c6a5bdd..481742d 100644
--- a/hotspot/src/share/vm/oops/instanceKlass.cpp
+++ b/hotspot/src/share/vm/oops/instanceKlass.cpp
@@ -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
@@ -25,6 +25,7 @@
 #include "precompiled.hpp"
 #include "classfile/javaClasses.hpp"
 #include "classfile/systemDictionary.hpp"
+#include "classfile/systemDictionaryShared.hpp"
 #include "classfile/verifier.hpp"
 #include "classfile/vmSymbols.hpp"
 #include "compiler/compileBroker.hpp"
@@ -706,6 +707,16 @@
 
         // also sets rewritten
         this_oop->rewrite_class(CHECK_false);
+      } else if (this_oop()->is_shared()) {
+        ResourceMark rm(THREAD);
+        char* message_buffer; // res-allocated by check_verification_dependencies
+        Handle loader = this_oop()->class_loader();
+        Handle pd     = this_oop()->protection_domain();
+        bool verified = SystemDictionaryShared::check_verification_dependencies(this_oop(),
+                        loader, pd, &message_buffer, THREAD);
+        if (!verified) {
+          THROW_MSG_(vmSymbols::java_lang_VerifyError(), message_buffer, false);
+        }
       }
 
       // relocate jsrs and link methods after they are all rewritten
@@ -715,7 +726,12 @@
       // methods have been rewritten since rewrite may
       // fabricate new Method*s.
       // also does loader constraint checking
-      if (!this_oop()->is_shared()) {
+      //
+      // Initialize_vtable and initialize_itable need to be rerun for
+      // a shared class if the class is not loaded by the NULL classloader.
+      ClassLoaderData * loader_data = this_oop->class_loader_data();
+      if (!(this_oop()->is_shared() &&
+            loader_data->is_the_null_class_loader_data())) {
         ResourceMark rm(THREAD);
         this_oop->vtable()->initialize_vtable(true, CHECK_false);
         this_oop->itable()->initialize_itable(true, CHECK_false);
diff --git a/hotspot/src/share/vm/oops/klassVtable.cpp b/hotspot/src/share/vm/oops/klassVtable.cpp
index f7adf47..639ce01 100644
--- a/hotspot/src/share/vm/oops/klassVtable.cpp
+++ b/hotspot/src/share/vm/oops/klassVtable.cpp
@@ -27,6 +27,7 @@
 #include "classfile/vmSymbols.hpp"
 #include "gc_implementation/shared/markSweep.inline.hpp"
 #include "memory/gcLocker.hpp"
+#include "memory/metaspaceShared.hpp"
 #include "memory/resourceArea.hpp"
 #include "memory/universe.inline.hpp"
 #include "oops/instanceKlass.hpp"
@@ -47,6 +48,10 @@
   return (InstanceKlass*)k;
 }
 
+bool klassVtable::is_preinitialized_vtable() {
+  return _klass->is_shared() && !MetaspaceShared::remapped_readwrite();
+}
+
 
 // this function computes the vtable size (including the size needed for miranda
 // methods) and the number of miranda methods in this class.
@@ -128,6 +133,12 @@
 int klassVtable::initialize_from_super(KlassHandle super) {
   if (super.is_null()) {
     return 0;
+  } else if (is_preinitialized_vtable()) {
+    // A shared class' vtable is preinitialized at dump time. No need to copy
+    // methods from super class for shared class, as that was already done
+    // during archiving time. However, if Jvmti has redefined a class,
+    // copy super class's vtable in case the super class has changed.
+    return super->vtable()->length();
   } else {
     // copy methods from superKlass
     // can't inherit from array class, so must be InstanceKlass
@@ -157,6 +168,8 @@
   KlassHandle super (THREAD, klass()->java_super());
   int nofNewEntries = 0;
 
+  bool is_shared = _klass->is_shared();
+
   if (PrintVtables && !klass()->oop_is_array()) {
     ResourceMark rm(THREAD);
     tty->print_cr("Initializing: %s", _klass->name()->as_C_string());
@@ -169,6 +182,7 @@
 #endif
 
   if (Universe::is_bootstrapping()) {
+    assert(!is_shared, "sanity");
     // just clear everything
     for (int i = 0; i < _length; i++) table()[i].clear();
     return;
@@ -208,6 +222,7 @@
       if (len > 0) {
         Array<int>* def_vtable_indices = NULL;
         if ((def_vtable_indices = ik()->default_vtable_indices()) == NULL) {
+          assert(!is_shared, "shared class def_vtable_indices does not exist");
           def_vtable_indices = ik()->create_new_default_vtable_indices(len, CHECK);
         } else {
           assert(def_vtable_indices->length() == len, "reinit vtable len?");
@@ -222,7 +237,15 @@
           // needs new entry
           if (needs_new_entry) {
             put_method_at(mh(), initialized);
-            def_vtable_indices->at_put(i, initialized); //set vtable index
+            if (is_preinitialized_vtable()) {
+              // At runtime initialize_vtable is rerun for a shared class
+              // (loaded by the non-boot loader) as part of link_class_impl().
+              // The dumptime vtable index should be the same as the runtime index.
+              assert(def_vtable_indices->at(i) == initialized,
+                     "dump time vtable index is different from runtime index");
+            } else {
+              def_vtable_indices->at_put(i, initialized); //set vtable index
+            }
             initialized++;
           }
         }
@@ -365,7 +388,8 @@
   }
 
   // we need a new entry if there is no superclass
-  if (klass->super() == NULL) {
+  Klass* super = klass->super();
+  if (super == NULL) {
     return allocate_new;
   }
 
@@ -394,7 +418,15 @@
 
   Symbol* target_classname = target_klass->name();
   for(int i = 0; i < super_vtable_len; i++) {
-    Method* super_method = method_at(i);
+    Method* super_method;
+    if (is_preinitialized_vtable()) {
+      // If this is a shared class, the vtable is already in the final state (fully
+      // initialized). Need to look at the super's vtable.
+      klassVtable* superVtable = super->vtable();
+      super_method = superVtable->method_at(i);
+    } else {
+      super_method = method_at(i);
+    }
     // Check if method name matches
     if (super_method->name() == name && super_method->signature() == signature) {
 
@@ -458,7 +490,15 @@
          target_method()->set_vtable_index(i);
        } else {
          if (def_vtable_indices != NULL) {
-           def_vtable_indices->at_put(default_index, i);
+           if (is_preinitialized_vtable()) {
+             // At runtime initialize_vtable is rerun as part of link_class_impl()
+             // for a shared class loaded by the non-boot loader.
+             // The dumptime vtable index should be the same as the runtime index.
+             assert(def_vtable_indices->at(default_index) == i,
+                    "dump time vtable index is different from runtime index");
+           } else {
+             def_vtable_indices->at_put(default_index, i);
+           }
          }
          assert(super_method->is_default_method() || super_method->is_overpass()
                 || super_method->is_abstract(), "default override error");
@@ -523,24 +563,33 @@
 }
 
 void klassVtable::put_method_at(Method* m, int index) {
+  if (is_preinitialized_vtable()) {
+    // At runtime initialize_vtable is rerun as part of link_class_impl()
+    // for shared class loaded by the non-boot loader to obtain the loader
+    // constraints based on the runtime classloaders' context. The dumptime
+    // method at the vtable index should be the same as the runtime method.
+    assert(table()[index].method() == m,
+           "archived method is different from the runtime method");
+  } else {
 #ifndef PRODUCT
-  if (PrintVtables && Verbose) {
-    ResourceMark rm;
-    const char* sig = (m != NULL) ? m->name_and_sig_as_C_string() : "<NULL>";
-    tty->print("adding %s at index %d, flags: ", sig, index);
-    if (m != NULL) {
-      m->access_flags().print_on(tty);
-      if (m->is_default_method()) {
-        tty->print("default ");
+    if (PrintVtables && Verbose) {
+      ResourceMark rm;
+      const char* sig = (m != NULL) ? m->name_and_sig_as_C_string() : "<NULL>";
+      tty->print("adding %s at index %d, flags: ", sig, index);
+      if (m != NULL) {
+        m->access_flags().print_on(tty);
+        if (m->is_default_method()) {
+          tty->print("default ");
+        }
+        if (m->is_overpass()) {
+          tty->print("overpass");
+        }
       }
-      if (m->is_overpass()) {
-        tty->print("overpass");
-      }
+      tty->cr();
     }
-    tty->cr();
-  }
 #endif
-  table()[index].set(m);
+    table()[index].set(m);
+  }
 }
 
 // Find out if a method "m" with superclass "super", loader "classloader" and
@@ -971,7 +1020,15 @@
 void itableMethodEntry::initialize(Method* m) {
   if (m == NULL) return;
 
-  _method = m;
+  if (MetaspaceShared::is_in_shared_space((void*)&_method) &&
+     !MetaspaceShared::remapped_readwrite()) {
+    // At runtime initialize_itable is rerun as part of link_class_impl()
+    // for a shared class loaded by the non-boot loader.
+    // The dumptime itable method entry should be the same as the runtime entry.
+    assert(_method == m, "sanity");
+  } else {
+    _method = m;
+  }
 }
 
 klassItable::klassItable(instanceKlassHandle klass) {
@@ -1081,7 +1138,11 @@
         tty->cr();
       }
       if (!m->has_vtable_index()) {
-        assert(m->vtable_index() == Method::pending_itable_index, "set by initialize_vtable");
+        // A shared method could have an initialized itable_index that
+        // is < 0.
+        assert(m->vtable_index() == Method::pending_itable_index ||
+               m->is_shared(),
+               "set by initialize_vtable");
         m->set_itable_index(ime_num);
         // Progress to next itable entry
         ime_num++;
@@ -1277,7 +1338,6 @@
 }
 #endif // INCLUDE_JVMTI
 
-
 // Setup
 class InterfaceVisiterClosure : public StackObj {
  public:
diff --git a/hotspot/src/share/vm/oops/klassVtable.hpp b/hotspot/src/share/vm/oops/klassVtable.hpp
index e4b4c9f..244f3c0 100644
--- a/hotspot/src/share/vm/oops/klassVtable.hpp
+++ b/hotspot/src/share/vm/oops/klassVtable.hpp
@@ -142,6 +142,19 @@
       Array<Klass*>* local_interfaces);
   void verify_against(outputStream* st, klassVtable* vt, int index);
   inline InstanceKlass* ik() const;
+  // When loading a class from CDS archive at run time, and no class redefintion
+  // has happened, it is expected that the class's itable/vtables are
+  // laid out exactly the same way as they had been during dump time.
+  // Therefore, in klassVtable::initialize_[iv]table, we do not layout the
+  // tables again. Instead, we only rerun the process to create/check
+  // the class loader constraints. In non-product builds, we add asserts to
+  // guarantee that the table's layout would be the same as at dump time.
+  //
+  // If JVMTI redefines any class, the read-only shared memory are remapped
+  // as read-write. A shared class' vtable/itable are re-initialized and
+  // might have different layout due to class redefinition of the shared class
+  // or its super types.
+  bool is_preinitialized_vtable();
 };
 
 
diff --git a/hotspot/src/share/vm/oops/method.cpp b/hotspot/src/share/vm/oops/method.cpp
index ffc9e9c..172c612 100644
--- a/hotspot/src/share/vm/oops/method.cpp
+++ b/hotspot/src/share/vm/oops/method.cpp
@@ -36,6 +36,7 @@
 #include "memory/generation.hpp"
 #include "memory/heapInspection.hpp"
 #include "memory/metadataFactory.hpp"
+#include "memory/metaspaceShared.hpp"
 #include "memory/oopFactory.hpp"
 #include "oops/constMethod.hpp"
 #include "oops/methodData.hpp"
@@ -305,6 +306,33 @@
   unlink_method();
 }
 
+void Method::set_vtable_index(int index) {
+  if (is_shared() && !MetaspaceShared::remapped_readwrite()) {
+    // At runtime initialize_vtable is rerun as part of link_class_impl()
+    // for a shared class loaded by the non-boot loader to obtain the loader
+    // constraints based on the runtime classloaders' context.
+    return; // don't write into the shared class
+  } else {
+    _vtable_index = index;
+  }
+}
+
+void Method::set_itable_index(int index) {
+  if (is_shared() && !MetaspaceShared::remapped_readwrite()) {
+    // At runtime initialize_itable is rerun as part of link_class_impl()
+    // for a shared class loaded by the non-boot loader to obtain the loader
+    // constraints based on the runtime classloaders' context. The dumptime
+    // itable index should be the same as the runtime index.
+    assert(_vtable_index == itable_index_max - index,
+           "archived itable index is different from runtime index");
+    return; // don’t write into the shared class
+  } else {
+    _vtable_index = itable_index_max - index;
+  }
+  assert(valid_itable_index(), "");
+}
+
+
 
 bool Method::was_executed_more_than(int n) {
   // Invocation counter is reset when the Method* is compiled.
diff --git a/hotspot/src/share/vm/oops/method.hpp b/hotspot/src/share/vm/oops/method.hpp
index 56bd46a..2126033 100644
--- a/hotspot/src/share/vm/oops/method.hpp
+++ b/hotspot/src/share/vm/oops/method.hpp
@@ -471,12 +471,12 @@
   DEBUG_ONLY(bool valid_vtable_index() const     { return _vtable_index >= nonvirtual_vtable_index; })
   bool has_vtable_index() const                  { return _vtable_index >= 0; }
   int  vtable_index() const                      { return _vtable_index; }
-  void set_vtable_index(int index)               { _vtable_index = index; }
+  void set_vtable_index(int index);
   DEBUG_ONLY(bool valid_itable_index() const     { return _vtable_index <= pending_itable_index; })
   bool has_itable_index() const                  { return _vtable_index <= itable_index_max; }
   int  itable_index() const                      { assert(valid_itable_index(), "");
                                                    return itable_index_max - _vtable_index; }
-  void set_itable_index(int index)               { _vtable_index = itable_index_max - index; assert(valid_itable_index(), ""); }
+  void set_itable_index(int index);
 
   // interpreter entry
   address interpreter_entry() const              { return _i2i_entry; }
diff --git a/hotspot/src/share/vm/opto/c2compiler.cpp b/hotspot/src/share/vm/opto/c2compiler.cpp
index 87932d2..9d06646 100644
--- a/hotspot/src/share/vm/opto/c2compiler.cpp
+++ b/hotspot/src/share/vm/opto/c2compiler.cpp
@@ -49,6 +49,9 @@
 const char* C2Compiler::retry_no_escape_analysis() {
   return "retry without escape analysis";
 }
+const char* C2Compiler::retry_class_loading_during_parsing() {
+  return "retry class loading during parsing";
+}
 bool C2Compiler::init_c2_runtime() {
 
   // Check assumptions used while running ADLC
@@ -115,6 +118,10 @@
 
     // Check result and retry if appropriate.
     if (C.failure_reason() != NULL) {
+      if (C.failure_reason_is(retry_class_loading_during_parsing())) {
+        env->record_failure(C.failure_reason());
+        continue;  // retry
+      }
       if (C.failure_reason_is(retry_no_subsuming_loads())) {
         assert(subsume_loads, "must make progress");
         subsume_loads = false;
diff --git a/hotspot/src/share/vm/opto/c2compiler.hpp b/hotspot/src/share/vm/opto/c2compiler.hpp
index 635153d..c1449bc 100644
--- a/hotspot/src/share/vm/opto/c2compiler.hpp
+++ b/hotspot/src/share/vm/opto/c2compiler.hpp
@@ -49,6 +49,7 @@
   // sentinel value used to trigger backtracking in compile_method().
   static const char* retry_no_subsuming_loads();
   static const char* retry_no_escape_analysis();
+  static const char* retry_class_loading_during_parsing();
 
   // Print compilation timers and statistics
   void print_timers();
diff --git a/hotspot/src/share/vm/opto/callGenerator.cpp b/hotspot/src/share/vm/opto/callGenerator.cpp
index f715fd2..2d89751 100644
--- a/hotspot/src/share/vm/opto/callGenerator.cpp
+++ b/hotspot/src/share/vm/opto/callGenerator.cpp
@@ -658,7 +658,7 @@
                                            &exact_receiver);
 
   SafePointNode* slow_map = NULL;
-  JVMState* slow_jvms;
+  JVMState* slow_jvms = NULL;
   { PreserveJVMState pjvms(&kit);
     kit.set_control(slow_ctl);
     if (!kit.stopped()) {
@@ -829,17 +829,18 @@
           }
         }
         // Cast reference arguments to its type.
-        for (int i = 0; i < signature->count(); i++) {
+        for (int i = 0, j = 0; i < signature->count(); i++) {
           ciType* t = signature->type_at(i);
           if (t->is_klass()) {
-            Node* arg = kit.argument(receiver_skip + i);
+            Node* arg = kit.argument(receiver_skip + j);
             const TypeOopPtr* arg_type = arg->bottom_type()->isa_oopptr();
             const Type*       sig_type = TypeOopPtr::make_from_klass(t->as_klass());
             if (arg_type != NULL && !arg_type->higher_equal(sig_type)) {
               Node* cast_obj = gvn.transform(new (C) CheckCastPPNode(kit.control(), arg, sig_type));
-              kit.set_argument(receiver_skip + i, cast_obj);
+              kit.set_argument(receiver_skip + j, cast_obj);
             }
           }
+          j += t->size();  // long and double take two slots
         }
 
         // Try to get the most accurate receiver type
diff --git a/hotspot/src/share/vm/opto/cfgnode.cpp b/hotspot/src/share/vm/opto/cfgnode.cpp
index 85c6d51..de5eec8 100644
--- a/hotspot/src/share/vm/opto/cfgnode.cpp
+++ b/hotspot/src/share/vm/opto/cfgnode.cpp
@@ -973,7 +973,7 @@
 #ifdef ASSERT
   // The following logic has been moved into TypeOopPtr::filter.
   const Type* jt = t->join_speculative(_type);
-  if( jt->empty() ) {           // Emptied out???
+  if (jt->empty()) {           // Emptied out???
 
     // Check for evil case of 't' being a class and '_type' expecting an
     // interface.  This can happen because the bytecodes do not contain
@@ -984,14 +984,21 @@
     // be 'I' or 'j/l/O'.  Thus we'll pick 'j/l/O'.  If this then flows
     // into a Phi which "knows" it's an Interface type we'll have to
     // uplift the type.
-    if( !t->empty() && ttip && ttip->is_loaded() && ttip->klass()->is_interface() )
-      { assert(ft == _type, ""); } // Uplift to interface
-    else if( !t->empty() && ttkp && ttkp->is_loaded() && ttkp->klass()->is_interface() )
-      { assert(ft == _type, ""); } // Uplift to interface
-    // Otherwise it's something stupid like non-overlapping int ranges
-    // found on dying counted loops.
-    else
-      { assert(ft == Type::TOP, ""); } // Canonical empty value
+    if (!t->empty() && ttip && ttip->is_loaded() && ttip->klass()->is_interface()) {
+      assert(ft == _type, ""); // Uplift to interface
+    } else if (!t->empty() && ttkp && ttkp->is_loaded() && ttkp->klass()->is_interface()) {
+      assert(ft == _type, ""); // Uplift to interface
+    } else {
+      // We also have to handle 'evil cases' of interface- vs. class-arrays
+      Type::get_arrays_base_elements(jt, _type, NULL, &ttip);
+      if (!t->empty() && ttip != NULL && ttip->is_loaded() && ttip->klass()->is_interface()) {
+          assert(ft == _type, "");   // Uplift to array of interface
+      } else {
+        // Otherwise it's something stupid like non-overlapping int ranges
+        // found on dying counted loops.
+        assert(ft == Type::TOP, ""); // Canonical empty value
+      }
+    }
   }
 
   else {
diff --git a/hotspot/src/share/vm/opto/compile.cpp b/hotspot/src/share/vm/opto/compile.cpp
index b422215..dc88381 100644
--- a/hotspot/src/share/vm/opto/compile.cpp
+++ b/hotspot/src/share/vm/opto/compile.cpp
@@ -791,7 +791,9 @@
     }
     JVMState* jvms = build_start_state(start(), tf());
     if ((jvms = cg->generate(jvms)) == NULL) {
-      record_method_not_compilable("method parse failed");
+      if (!failure_reason_is(C2Compiler::retry_class_loading_during_parsing())) {
+        record_method_not_compilable("method parse failed");
+      }
       return;
     }
     GraphKit kit(jvms);
@@ -3712,7 +3714,7 @@
   MacroAssembler _masm(&cb);
   for (int i = 0; i < _constants.length(); i++) {
     Constant con = _constants.at(i);
-    address constant_addr;
+    address constant_addr = NULL;
     switch (con.type()) {
     case T_LONG:   constant_addr = _masm.long_constant(  con.get_jlong()  ); break;
     case T_FLOAT:  constant_addr = _masm.float_constant( con.get_jfloat() ); break;
diff --git a/hotspot/src/share/vm/opto/generateOptoStub.cpp b/hotspot/src/share/vm/opto/generateOptoStub.cpp
index ff501f2..57f8809 100644
--- a/hotspot/src/share/vm/opto/generateOptoStub.cpp
+++ b/hotspot/src/share/vm/opto/generateOptoStub.cpp
@@ -273,7 +273,7 @@
 
   //-----------------------------
   // If this is a normal subroutine return, issue the return and be done.
-  Node *ret;
+  Node *ret = NULL;
   switch( is_fancy_jump ) {
   case 0:                       // Make a return instruction
     // Return to caller, free any space for return address
diff --git a/hotspot/src/share/vm/opto/lcm.cpp b/hotspot/src/share/vm/opto/lcm.cpp
index 56cde6f..8f6844f 100644
--- a/hotspot/src/share/vm/opto/lcm.cpp
+++ b/hotspot/src/share/vm/opto/lcm.cpp
@@ -675,7 +675,7 @@
   block->insert_node(proj, node_cnt++);
 
   // Select the right register save policy.
-  const char * save_policy;
+  const char *save_policy = NULL;
   switch (op) {
     case Op_CallRuntime:
     case Op_CallLeaf:
diff --git a/hotspot/src/share/vm/opto/library_call.cpp b/hotspot/src/share/vm/opto/library_call.cpp
index 243cf74..f2a2937 100644
--- a/hotspot/src/share/vm/opto/library_call.cpp
+++ b/hotspot/src/share/vm/opto/library_call.cpp
@@ -1649,7 +1649,7 @@
 // public static double Math.log10(double)
 bool LibraryCallKit::inline_math(vmIntrinsics::ID id) {
   Node* arg = round_double_node(argument(0));
-  Node* n;
+  Node* n = NULL;
   switch (id) {
   case vmIntrinsics::_dabs:   n = new (C) AbsDNode(                arg);  break;
   case vmIntrinsics::_dsqrt:  n = new (C) SqrtDNode(C, control(),  arg);  break;
@@ -2390,7 +2390,7 @@
 // inline long       Long.reverseBytes(long)
 bool LibraryCallKit::inline_number_methods(vmIntrinsics::ID id) {
   Node* arg = argument(0);
-  Node* n;
+  Node* n = NULL;
   switch (id) {
   case vmIntrinsics::_numberOfLeadingZeros_i:   n = new (C) CountLeadingZerosINode( arg);  break;
   case vmIntrinsics::_numberOfLeadingZeros_l:   n = new (C) CountLeadingZerosLNode( arg);  break;
@@ -2985,7 +2985,7 @@
 
   // For now, we handle only those cases that actually exist: ints,
   // longs, and Object. Adding others should be straightforward.
-  Node* load_store;
+  Node* load_store = NULL;
   switch(type) {
   case T_INT:
     if (kind == LS_xadd) {
@@ -3905,7 +3905,7 @@
   Node* end               = is_copyOfRange? argument(2): argument(1);
   Node* array_type_mirror = is_copyOfRange? argument(3): argument(2);
 
-  Node* newcopy;
+  Node* newcopy = NULL;
 
   // Set the original stack and the reexecute bit for the interpreter to reexecute
   // the bytecode that invokes Arrays.copyOf if deoptimization happens.
@@ -4293,7 +4293,7 @@
 
 bool LibraryCallKit::inline_fp_conversions(vmIntrinsics::ID id) {
   Node* arg = argument(0);
-  Node* result;
+  Node* result = NULL;
 
   switch (id) {
   case vmIntrinsics::_floatToRawIntBits:    result = new (C) MoveF2INode(arg);  break;
@@ -6294,7 +6294,7 @@
 
 //------------------------------inline_aescrypt_Block-----------------------
 bool LibraryCallKit::inline_aescrypt_Block(vmIntrinsics::ID id) {
-  address stubAddr;
+  address stubAddr = NULL;
   const char *stubName;
   assert(UseAES, "need AES instruction support");
 
@@ -6360,8 +6360,8 @@
 
 //------------------------------inline_cipherBlockChaining_AESCrypt-----------------------
 bool LibraryCallKit::inline_cipherBlockChaining_AESCrypt(vmIntrinsics::ID id) {
-  address stubAddr;
-  const char *stubName;
+  address stubAddr = NULL;
+  const char *stubName = NULL;
 
   assert(UseAES, "need AES instruction support");
 
diff --git a/hotspot/src/share/vm/opto/loopTransform.cpp b/hotspot/src/share/vm/opto/loopTransform.cpp
index 171032d..a61c8a6 100644
--- a/hotspot/src/share/vm/opto/loopTransform.cpp
+++ b/hotspot/src/share/vm/opto/loopTransform.cpp
@@ -2836,7 +2836,7 @@
   // state of the loop.  It's safe in this case to replace it with the
   // result_mem.
   _igvn.replace_node(store->in(MemNode::Memory), result_mem);
-  _igvn.replace_node(exit, result_ctrl);
+  lazy_replace(exit, result_ctrl);
   _igvn.replace_node(store, result_mem);
   // Any uses the increment outside of the loop become the loop limit.
   _igvn.replace_node(head->incr(), head->limit());
diff --git a/hotspot/src/share/vm/opto/loopnode.cpp b/hotspot/src/share/vm/opto/loopnode.cpp
index 1e44b80..e653557 100644
--- a/hotspot/src/share/vm/opto/loopnode.cpp
+++ b/hotspot/src/share/vm/opto/loopnode.cpp
@@ -750,8 +750,8 @@
     set_loop(iff2, get_loop(iffalse));
 
     // Lazy update of 'get_ctrl' mechanism.
-    lazy_replace_proj( iffalse, iff2 );
-    lazy_replace_proj( iftrue,  ift2 );
+    lazy_replace(iffalse, iff2);
+    lazy_replace(iftrue,  ift2);
 
     // Swap names
     iffalse = iff2;
diff --git a/hotspot/src/share/vm/opto/loopnode.hpp b/hotspot/src/share/vm/opto/loopnode.hpp
index 93536c8..1294bff 100644
--- a/hotspot/src/share/vm/opto/loopnode.hpp
+++ b/hotspot/src/share/vm/opto/loopnode.hpp
@@ -660,13 +660,18 @@
   }
 
 private:
-  Node *get_ctrl_no_update( Node *i ) const {
+  Node *get_ctrl_no_update_helper(Node *i) const {
+    assert(has_ctrl(i), "should be control, not loop");
+    return (Node*)(((intptr_t)_nodes[i->_idx]) & ~1);
+  }
+
+  Node *get_ctrl_no_update(Node *i) const {
     assert( has_ctrl(i), "" );
-    Node *n = (Node*)(((intptr_t)_nodes[i->_idx]) & ~1);
+    Node *n = get_ctrl_no_update_helper(i);
     if (!n->in(0)) {
       // Skip dead CFG nodes
       do {
-        n = (Node*)(((intptr_t)_nodes[n->_idx]) & ~1);
+        n = get_ctrl_no_update_helper(n);
       } while (!n->in(0));
       n = find_non_split_ctrl(n);
     }
@@ -688,22 +693,15 @@
   // from old_node to new_node to support the lazy update.  Reference
   // replaces loop reference, since that is not needed for dead node.
 public:
-  void lazy_update( Node *old_node, Node *new_node ) {
-    assert( old_node != new_node, "no cycles please" );
-    //old_node->set_req( 1, new_node /*NO DU INFO*/ );
-    // Nodes always have DU info now, so re-use the side array slot
-    // for this node to provide the forwarding pointer.
-    _nodes.map( old_node->_idx, (Node*)((intptr_t)new_node + 1) );
+  void lazy_update(Node *old_node, Node *new_node) {
+    assert(old_node != new_node, "no cycles please");
+    // Re-use the side array slot for this node to provide the
+    // forwarding pointer.
+    _nodes.map(old_node->_idx, (Node*)((intptr_t)new_node + 1));
   }
-  void lazy_replace( Node *old_node, Node *new_node ) {
-    _igvn.replace_node( old_node, new_node );
-    lazy_update( old_node, new_node );
-  }
-  void lazy_replace_proj( Node *old_node, Node *new_node ) {
-    assert( old_node->req() == 1, "use this for Projs" );
-    _igvn.hash_delete(old_node); // Must hash-delete before hacking edges
-    old_node->add_req( NULL );
-    lazy_replace( old_node, new_node );
+  void lazy_replace(Node *old_node, Node *new_node) {
+    _igvn.replace_node(old_node, new_node);
+    lazy_update(old_node, new_node);
   }
 
 private:
diff --git a/hotspot/src/share/vm/opto/loopopts.cpp b/hotspot/src/share/vm/opto/loopopts.cpp
index 062daec..e19f35a 100644
--- a/hotspot/src/share/vm/opto/loopopts.cpp
+++ b/hotspot/src/share/vm/opto/loopopts.cpp
@@ -43,6 +43,14 @@
     return NULL;
   }
 
+  // Splitting range check CastIIs through a loop induction Phi can
+  // cause new Phis to be created that are left unrelated to the loop
+  // induction Phi and prevent optimizations (vectorization)
+  if (n->Opcode() == Op_CastII && n->as_CastII()->has_range_check() &&
+      region->is_CountedLoop() && n->in(1) == region->as_CountedLoop()->phi()) {
+    return NULL;
+  }
+
   int wins = 0;
   assert(!n->is_CFG(), "");
   assert(region->is_Region(), "");
diff --git a/hotspot/src/share/vm/opto/macro.cpp b/hotspot/src/share/vm/opto/macro.cpp
index 2d555c2..01b329c 100644
--- a/hotspot/src/share/vm/opto/macro.cpp
+++ b/hotspot/src/share/vm/opto/macro.cpp
@@ -693,10 +693,10 @@
   ciKlass* klass = NULL;
   ciInstanceKlass* iklass = NULL;
   int nfields = 0;
-  int array_base;
-  int element_size;
-  BasicType basic_elem_type;
-  ciType* elem_type;
+  int array_base = 0;
+  int element_size = 0;
+  BasicType basic_elem_type = T_ILLEGAL;
+  ciType* elem_type = NULL;
 
   Node* res = alloc->result_cast();
   assert(res == NULL || res->is_CheckCastPP(), "unexpected AllocateNode result");
@@ -1177,10 +1177,10 @@
   // We need a Region and corresponding Phi's to merge the slow-path and fast-path results.
   // they will not be used if "always_slow" is set
   enum { slow_result_path = 1, fast_result_path = 2 };
-  Node *result_region;
-  Node *result_phi_rawmem;
-  Node *result_phi_rawoop;
-  Node *result_phi_i_o;
+  Node *result_region = NULL;
+  Node *result_phi_rawmem = NULL;
+  Node *result_phi_rawoop = NULL;
+  Node *result_phi_i_o = NULL;
 
   // The initial slow comparison is a size check, the comparison
   // we want to do is a BoolTest::gt
diff --git a/hotspot/src/share/vm/opto/parse1.cpp b/hotspot/src/share/vm/opto/parse1.cpp
index 7a69729..8755784 100644
--- a/hotspot/src/share/vm/opto/parse1.cpp
+++ b/hotspot/src/share/vm/opto/parse1.cpp
@@ -27,6 +27,7 @@
 #include "interpreter/linkResolver.hpp"
 #include "oops/method.hpp"
 #include "opto/addnode.hpp"
+#include "opto/c2compiler.hpp"
 #include "opto/idealGraphPrinter.hpp"
 #include "opto/locknode.hpp"
 #include "opto/memnode.hpp"
@@ -105,7 +106,7 @@
 
   // Very similar to LoadNode::make, except we handle un-aligned longs and
   // doubles on Sparc.  Intel can handle them just fine directly.
-  Node *l;
+  Node *l = NULL;
   switch (bt) {                // Signature is flattened
   case T_INT:     l = new (C) LoadINode(ctl, mem, adr, TypeRawPtr::BOTTOM, TypeInt::INT,        MemNode::unordered); break;
   case T_FLOAT:   l = new (C) LoadFNode(ctl, mem, adr, TypeRawPtr::BOTTOM, Type::FLOAT,         MemNode::unordered); break;
@@ -988,7 +989,23 @@
   if (tf()->range()->cnt() > TypeFunc::Parms) {
     const Type* ret_type = tf()->range()->field_at(TypeFunc::Parms);
     Node*       ret_phi  = _gvn.transform( _exits.argument(0) );
-    assert(_exits.control()->is_top() || !_gvn.type(ret_phi)->empty(), "return value must be well defined");
+    if (!_exits.control()->is_top() && _gvn.type(ret_phi)->empty()) {
+      // In case of concurrent class loading, the type we set for the
+      // ret_phi in build_exits() may have been too optimistic and the
+      // ret_phi may be top now.
+      // Otherwise, we've encountered an error and have to mark the method as
+      // not compilable. Just using an assertion instead would be dangerous
+      // as this could lead to an infinite compile loop in non-debug builds.
+      {
+        MutexLockerEx ml(Compile_lock, Mutex::_no_safepoint_check_flag);
+        if (C->env()->system_dictionary_modification_counter_changed()) {
+          C->record_failure(C2Compiler::retry_class_loading_during_parsing());
+        } else {
+          C->record_method_not_compilable("Can't determine return type.");
+        }
+      }
+      return;
+    }
     if (ret_type->isa_int()) {
       BasicType ret_bt = method()->return_type()->basic_type();
       ret_phi = mask_int_value(ret_phi, ret_bt, &_gvn);
@@ -1897,7 +1914,7 @@
   // Now use a Phi here for merging
   assert(!nocreate, "Cannot build a phi for a block already parsed.");
   const JVMState* jvms = map->jvms();
-  const Type* t;
+  const Type* t = NULL;
   if (jvms->is_loc(idx)) {
     t = block()->local_type_at(idx - jvms->locoff());
   } else if (jvms->is_stk(idx)) {
@@ -2116,15 +2133,24 @@
     // here.
     Node* phi = _exits.argument(0);
     const TypeInstPtr *tr = phi->bottom_type()->isa_instptr();
-    if( tr && tr->klass()->is_loaded() &&
-        tr->klass()->is_interface() ) {
+    if (tr && tr->klass()->is_loaded() &&
+        tr->klass()->is_interface()) {
       const TypeInstPtr *tp = value->bottom_type()->isa_instptr();
       if (tp && tp->klass()->is_loaded() &&
           !tp->klass()->is_interface()) {
         // sharpen the type eagerly; this eases certain assert checking
         if (tp->higher_equal(TypeInstPtr::NOTNULL))
           tr = tr->join_speculative(TypeInstPtr::NOTNULL)->is_instptr();
-        value = _gvn.transform(new (C) CheckCastPPNode(0,value,tr));
+        value = _gvn.transform(new (C) CheckCastPPNode(0, value, tr));
+      }
+    } else {
+      // Also handle returns of oop-arrays to an arrays-of-interface return
+      const TypeInstPtr* phi_tip;
+      const TypeInstPtr* val_tip;
+      Type::get_arrays_base_elements(phi->bottom_type(), value->bottom_type(), &phi_tip, &val_tip);
+      if (phi_tip != NULL && phi_tip->is_loaded() && phi_tip->klass()->is_interface() &&
+          val_tip != NULL && val_tip->is_loaded() && !val_tip->klass()->is_interface()) {
+         value = _gvn.transform(new (C) CheckCastPPNode(0, value, phi->bottom_type()));
       }
     }
     phi->add_req(value);
diff --git a/hotspot/src/share/vm/opto/runtime.cpp b/hotspot/src/share/vm/opto/runtime.cpp
index 861f599..597580b 100644
--- a/hotspot/src/share/vm/opto/runtime.cpp
+++ b/hotspot/src/share/vm/opto/runtime.cpp
@@ -231,22 +231,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);
 
@@ -286,6 +281,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);
   }
@@ -364,6 +360,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);
@@ -380,6 +377,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);
@@ -397,6 +395,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);
@@ -415,6 +414,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);
@@ -432,6 +432,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);
diff --git a/hotspot/src/share/vm/opto/split_if.cpp b/hotspot/src/share/vm/opto/split_if.cpp
index 134c873..f7f5529 100644
--- a/hotspot/src/share/vm/opto/split_if.cpp
+++ b/hotspot/src/share/vm/opto/split_if.cpp
@@ -451,8 +451,8 @@
 
   // Replace both uses of 'new_iff' with Regions merging True/False
   // paths.  This makes 'new_iff' go dead.
-  Node *old_false, *old_true;
-  Node *new_false, *new_true;
+  Node *old_false = NULL, *old_true = NULL;
+  Node *new_false = NULL, *new_true = NULL;
   for (DUIterator_Last j2min, j2 = iff->last_outs(j2min); j2 >= j2min; --j2) {
     Node *ifp = iff->last_out(j2);
     assert( ifp->Opcode() == Op_IfFalse || ifp->Opcode() == Op_IfTrue, "" );
@@ -472,7 +472,7 @@
 
     // Replace in the graph with lazy-update mechanism
     new_iff->set_req(0, new_iff); // hook self so it does not go dead
-    lazy_replace_proj( ifp, ifpx );
+    lazy_replace(ifp, ifpx);
     new_iff->set_req(0, region);
 
     // Record bits for later xforms
diff --git a/hotspot/src/share/vm/opto/type.cpp b/hotspot/src/share/vm/opto/type.cpp
index e614bd4..685f417 100644
--- a/hotspot/src/share/vm/opto/type.cpp
+++ b/hotspot/src/share/vm/opto/type.cpp
@@ -149,6 +149,33 @@
   return bt;
 }
 
+// For two instance arrays of same dimension, return the base element types.
+// Otherwise or if the arrays have different dimensions, return NULL.
+void Type::get_arrays_base_elements(const Type *a1, const Type *a2,
+                                    const TypeInstPtr **e1, const TypeInstPtr **e2) {
+
+  if (e1) *e1 = NULL;
+  if (e2) *e2 = NULL;
+  const TypeAryPtr* a1tap = (a1 == NULL) ? NULL : a1->isa_aryptr();
+  const TypeAryPtr* a2tap = (a2 == NULL) ? NULL : a2->isa_aryptr();
+
+  if (a1tap != NULL && a2tap != NULL) {
+    // Handle multidimensional arrays
+    const TypePtr* a1tp = a1tap->elem()->make_ptr();
+    const TypePtr* a2tp = a2tap->elem()->make_ptr();
+    while (a1tp && a1tp->isa_aryptr() && a2tp && a2tp->isa_aryptr()) {
+      a1tap = a1tp->is_aryptr();
+      a2tap = a2tp->is_aryptr();
+      a1tp = a1tap->elem()->make_ptr();
+      a2tp = a2tap->elem()->make_ptr();
+    }
+    if (a1tp && a1tp->isa_instptr() && a2tp && a2tp->isa_instptr()) {
+      if (e1) *e1 = a1tp->is_instptr();
+      if (e2) *e2 = a2tp->is_instptr();
+    }
+  }
+}
+
 //---------------------------get_typeflow_type---------------------------------
 // Import a type produced by ciTypeFlow.
 const Type* Type::get_typeflow_type(ciType* type) {
@@ -1984,7 +2011,11 @@
 bool TypeAry::interface_vs_oop(const Type *t) const {
   const TypeAry* t_ary = t->is_ary();
   if (t_ary) {
-    return _elem->interface_vs_oop(t_ary->_elem);
+    const TypePtr* this_ptr = _elem->make_ptr(); // In case we have narrow_oops
+    const TypePtr*    t_ptr = t_ary->_elem->make_ptr();
+    if(this_ptr != NULL && t_ptr != NULL) {
+      return this_ptr->interface_vs_oop(t_ptr);
+    }
   }
   return false;
 }
@@ -2836,8 +2867,17 @@
     // be 'I' or 'j/l/O'.  Thus we'll pick 'j/l/O'.  If this then flows
     // into a Phi which "knows" it's an Interface type we'll have to
     // uplift the type.
-    if (!empty() && ktip != NULL && ktip->is_loaded() && ktip->klass()->is_interface())
-      return kills;             // Uplift to interface
+    if (!empty()) {
+      if (ktip != NULL && ktip->is_loaded() && ktip->klass()->is_interface()) {
+        return kills;           // Uplift to interface
+      }
+      // Also check for evil cases of 'this' being a class array
+      // and 'kills' expecting an array of interfaces.
+      Type::get_arrays_base_elements(ft, kills, NULL, &ktip);
+      if (ktip != NULL && ktip->is_loaded() && ktip->klass()->is_interface()) {
+        return kills;           // Uplift to array of interface
+      }
+    }
 
     return Type::TOP;           // Canonical empty value
   }
diff --git a/hotspot/src/share/vm/opto/type.hpp b/hotspot/src/share/vm/opto/type.hpp
index c587e14..4506c3a 100644
--- a/hotspot/src/share/vm/opto/type.hpp
+++ b/hotspot/src/share/vm/opto/type.hpp
@@ -367,6 +367,11 @@
     return _const_basic_type[type];
   }
 
+  // For two instance arrays of same dimension, return the base element types.
+  // Otherwise or if the arrays have different dimensions, return NULL.
+  static void get_arrays_base_elements(const Type *a1, const Type *a2,
+                                       const TypeInstPtr **e1, const TypeInstPtr **e2);
+
   // Mapping to the array element's basic type.
   BasicType array_element_basic_type() const;
 
diff --git a/hotspot/src/share/vm/prims/jvmtiEnter.xsl b/hotspot/src/share/vm/prims/jvmtiEnter.xsl
index e855d21..9a97213 100644
--- a/hotspot/src/share/vm/prims/jvmtiEnter.xsl
+++ b/hotspot/src/share/vm/prims/jvmtiEnter.xsl
@@ -631,8 +631,8 @@
   jint trace_flags = JvmtiTrace::trace_flags(</xsl:text>
       <xsl:value-of select="@num"/>
       <xsl:text>);
-  const char *func_name;
-  const char *curr_thread_name;
+  const char *func_name = NULL;
+  const char *curr_thread_name = NULL;
   if (trace_flags) {
     func_name = JvmtiTrace::function_name(</xsl:text>
       <xsl:value-of select="@num"/>
diff --git a/hotspot/src/share/vm/prims/jvmtiEnv.cpp b/hotspot/src/share/vm/prims/jvmtiEnv.cpp
index c9d53cf..0c92c88 100644
--- a/hotspot/src/share/vm/prims/jvmtiEnv.cpp
+++ b/hotspot/src/share/vm/prims/jvmtiEnv.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, 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
@@ -946,7 +946,7 @@
     return JVMTI_ERROR_INVALID_THREAD;
 
   Handle thread_obj(current_thread, thread_oop);
-  typeArrayHandle    name;
+  Handle name;
   ThreadPriority priority;
   Handle     thread_group;
   Handle context_class_loader;
@@ -954,7 +954,7 @@
 
   { MutexLocker mu(Threads_lock);
 
-    name = typeArrayHandle(current_thread, java_lang_Thread::name(thread_obj()));
+    name = Handle(current_thread, java_lang_Thread::name(thread_obj()));
     priority = java_lang_Thread::priority(thread_obj());
     thread_group = Handle(current_thread, java_lang_Thread::threadGroup(thread_obj()));
     is_daemon = java_lang_Thread::is_daemon(thread_obj());
@@ -965,7 +965,7 @@
   { const char *n;
 
     if (name() != NULL) {
-      n = UNICODE::as_utf8((jchar*) name->base(T_CHAR), name->length());
+      n = java_lang_String::as_utf8_string(name());
     } else {
       n = UNICODE::as_utf8(NULL, 0);
     }
@@ -3010,7 +3010,7 @@
     // in thread.cpp.
     JvmtiPendingMonitors::enter(rmonitor);
   } else {
-    int r;
+    int r = 0;
     Thread* thread = Thread::current();
 
     if (thread->is_Java_thread()) {
@@ -3073,7 +3073,7 @@
       err = JVMTI_ERROR_NOT_MONITOR_OWNER;
     }
   } else {
-    int r;
+    int r = 0;
     Thread* thread = Thread::current();
 
     if (thread->is_Java_thread()) {
@@ -3107,7 +3107,7 @@
 // rmonitor - pre-checked for validity
 jvmtiError
 JvmtiEnv::RawMonitorWait(JvmtiRawMonitor * rmonitor, jlong millis) {
-  int r;
+  int r = 0;
   Thread* thread = Thread::current();
 
   if (thread->is_Java_thread()) {
@@ -3166,7 +3166,7 @@
 // rmonitor - pre-checked for validity
 jvmtiError
 JvmtiEnv::RawMonitorNotify(JvmtiRawMonitor * rmonitor) {
-  int r;
+  int r = 0;
   Thread* thread = Thread::current();
 
   if (thread->is_Java_thread()) {
@@ -3197,7 +3197,7 @@
 // rmonitor - pre-checked for validity
 jvmtiError
 JvmtiEnv::RawMonitorNotifyAll(JvmtiRawMonitor * rmonitor) {
-  int r;
+  int r = 0;
   Thread* thread = Thread::current();
 
   if (thread->is_Java_thread()) {
diff --git a/hotspot/src/share/vm/prims/jvmtiEnvBase.cpp b/hotspot/src/share/vm/prims/jvmtiEnvBase.cpp
index 15edab2..fe2a381 100644
--- a/hotspot/src/share/vm/prims/jvmtiEnvBase.cpp
+++ b/hotspot/src/share/vm/prims/jvmtiEnvBase.cpp
@@ -511,7 +511,7 @@
 // mean much better out of memory handling
 unsigned char *
 JvmtiEnvBase::jvmtiMalloc(jlong size) {
-  unsigned char* mem;
+  unsigned char* mem = NULL;
   jvmtiError result = allocate(size, &mem);
   assert(result == JVMTI_ERROR_NONE, "Allocate failed");
   return mem;
@@ -1038,7 +1038,7 @@
     // implied else: entry_count == 0
   }
 
-  int nWant,nWait;
+  int nWant = 0, nWait = 0;
   if (mon != NULL) {
     // this object has a heavyweight monitor
     nWant = mon->contentions(); // # of threads contending for monitor
diff --git a/hotspot/src/share/vm/prims/jvmtiExport.cpp b/hotspot/src/share/vm/prims/jvmtiExport.cpp
index fca0b53..4586e9d 100644
--- a/hotspot/src/share/vm/prims/jvmtiExport.cpp
+++ b/hotspot/src/share/vm/prims/jvmtiExport.cpp
@@ -995,7 +995,9 @@
         // Before we call the JVMTI agent, we have to set the state in the
         // thread for which we are proxying.
         JavaThreadState prev_state = real_thread->thread_state();
-        assert(prev_state == _thread_blocked, "JavaThread should be at safepoint");
+        assert(((Thread *)real_thread)->is_ConcurrentGC_thread() ||
+               (real_thread->is_Java_thread() && prev_state == _thread_blocked),
+               "should be ConcurrentGCThread or JavaThread at safepoint");
         real_thread->set_thread_state(_thread_in_native);
 
         jvmtiExtensionEvent callback = env->ext_callbacks()->ClassUnload;
diff --git a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp
index aa2db58..7903b1d 100644
--- a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp
+++ b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, 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
@@ -332,7 +332,7 @@
       int new_name_and_type_ref_i = find_or_append_indirect_entry(scratch_cp, name_and_type_ref_i,
                                                           merge_cp_p, merge_cp_length_p, THREAD);
 
-      const char *entry_name;
+      const char *entry_name = NULL;
       switch (scratch_cp->tag_at(scratch_i).value()) {
       case JVM_CONSTANT_Fieldref:
         entry_name = "Fieldref";
@@ -3926,6 +3926,10 @@
   scratch_class->set_methods(_old_methods);     // To prevent potential GCing of the old methods,
                                           // and to be able to undo operation easily.
 
+  Array<int>* old_ordering = the_class->method_ordering();
+  the_class->set_method_ordering(scratch_class->method_ordering());
+  scratch_class->set_method_ordering(old_ordering);
+
   ConstantPool* old_constants = the_class->constants();
   the_class->set_constants(scratch_class->constants());
   scratch_class->set_constants(old_constants);  // See the previous comment.
diff --git a/hotspot/src/share/vm/prims/jvmtiTrace.cpp b/hotspot/src/share/vm/prims/jvmtiTrace.cpp
index 279e23a..c705ecf 100644
--- a/hotspot/src/share/vm/prims/jvmtiTrace.cpp
+++ b/hotspot/src/share/vm/prims/jvmtiTrace.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, 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
@@ -266,11 +266,11 @@
   if (threadObj == NULL) {
     return "NULL";
   }
-  typeArrayOop name = java_lang_Thread::name(threadObj);
+  oop name = java_lang_Thread::name(threadObj);
   if (name == NULL) {
     return "<NOT FILLED IN>";
   }
-  return UNICODE::as_utf8((jchar*) name->base(T_CHAR), name->length());
+  return java_lang_String::as_utf8_string(name);
 }
 
 
diff --git a/hotspot/src/share/vm/prims/unsafe.cpp b/hotspot/src/share/vm/prims/unsafe.cpp
index a1e9651..0846b20 100644
--- a/hotspot/src/share/vm/prims/unsafe.cpp
+++ b/hotspot/src/share/vm/prims/unsafe.cpp
@@ -864,7 +864,7 @@
 
 UNSAFE_ENTRY(jint, Unsafe_ArrayBaseOffset(JNIEnv *env, jobject unsafe, jclass acls))
   UnsafeWrapper("Unsafe_ArrayBaseOffset");
-  int base, scale;
+  int base = 0, scale = 0;
   getBaseAndScale(base, scale, acls, CHECK_0);
   return field_offset_from_byte_offset(base);
 UNSAFE_END
@@ -872,7 +872,7 @@
 
 UNSAFE_ENTRY(jint, Unsafe_ArrayIndexScale(JNIEnv *env, jobject unsafe, jclass acls))
   UnsafeWrapper("Unsafe_ArrayIndexScale");
-  int base, scale;
+  int base = 0, scale = 0;
   getBaseAndScale(base, scale, acls, 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
diff --git a/hotspot/src/share/vm/prims/whitebox.cpp b/hotspot/src/share/vm/prims/whitebox.cpp
index ef1da19..c3e0688 100644
--- a/hotspot/src/share/vm/prims/whitebox.cpp
+++ b/hotspot/src/share/vm/prims/whitebox.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2014, 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
@@ -25,6 +25,7 @@
 #include "precompiled.hpp"
 
 #include "memory/metadataFactory.hpp"
+#include "memory/metaspaceShared.hpp"
 #include "memory/universe.hpp"
 #include "oops/oop.inline.hpp"
 
@@ -914,6 +915,10 @@
   return (jlong) MetaspaceGC::capacity_until_GC();
 WB_END
 
+WB_ENTRY(jboolean, WB_IsSharedClass(JNIEnv* env, jobject wb, jclass clazz))
+  return (jboolean)MetaspaceShared::is_in_shared_space(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz)));
+WB_END
+
 WB_ENTRY(jboolean, WB_IsMonitorInflated(JNIEnv* env, jobject wb, jobject obj))
   oop obj_oop = JNIHandles::resolve(obj);
   return (jboolean) obj_oop->mark()->has_monitor();
@@ -1034,6 +1039,7 @@
   {CC"runMemoryUnitTests", CC"()V",                   (void*)&WB_RunMemoryUnitTests},
   {CC"readFromNoaccessArea",CC"()V",                  (void*)&WB_ReadFromNoaccessArea},
   {CC"stressVirtualSpaceResize",CC"(JJJ)I",           (void*)&WB_StressVirtualSpaceResize},
+  {CC"isSharedClass", CC"(Ljava/lang/Class;)Z",       (void*)&WB_IsSharedClass },
 #if INCLUDE_ALL_GCS
   {CC"g1InConcurrentMark", CC"()Z",                   (void*)&WB_G1InConcurrentMark},
   {CC"g1IsHumongous",      CC"(Ljava/lang/Object;)Z", (void*)&WB_G1IsHumongous     },
diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp
index 5e7c6d1..a21ce23 100644
--- a/hotspot/src/share/vm/runtime/arguments.cpp
+++ b/hotspot/src/share/vm/runtime/arguments.cpp
@@ -1675,9 +1675,8 @@
   FLAG_SET_DEFAULT(ParallelGCThreads,
                      Abstract_VM_Version::parallel_worker_threads());
   if (ParallelGCThreads == 0) {
-    FLAG_SET_DEFAULT(ParallelGCThreads,
-                     Abstract_VM_Version::parallel_worker_threads());
-  }
+    vm_exit_during_initialization("The flag -XX:+UseG1GC can not be combined with -XX:ParallelGCThreads=0", NULL);
+    }
 
 #if INCLUDE_ALL_GCS
   if (G1ConcRefinementThreads == 0) {
diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp
index 1e01b2e..c76ced4 100644
--- a/hotspot/src/share/vm/runtime/globals.hpp
+++ b/hotspot/src/share/vm/runtime/globals.hpp
@@ -2259,6 +2259,14 @@
   diagnostic(bool, VerifyDuringGC, false,                                   \
           "Verify memory system during GC (between phases)")                \
                                                                             \
+  diagnostic(ccstrlist, VerifySubSet, "",                                   \
+          "Memory sub-systems to verify when Verify*GC flag(s) "            \
+          "are enabled. One or more sub-systems can be specified "          \
+          "in a comma separated string. Sub-systems are: "                  \
+          "threads, heap, symbol_table, string_table, codecache, "          \
+          "dictionary, classloader_data_graph, metaspace, jni_handles, "    \
+          "c-heap, codecache_oops")                                         \
+                                                                            \
   diagnostic(bool, GCParallelVerificationEnabled, true,                     \
           "Enable parallel memory system verification")                     \
                                                                             \
diff --git a/hotspot/src/share/vm/runtime/os.cpp b/hotspot/src/share/vm/runtime/os.cpp
index e50f888..21764cb 100644
--- a/hotspot/src/share/vm/runtime/os.cpp
+++ b/hotspot/src/share/vm/runtime/os.cpp
@@ -325,6 +325,10 @@
   // We need to initialize large page support here because ergonomics takes some
   // decisions depending on large page support and the calculated large page size.
   large_page_init();
+
+  // VM version initialization identifies some characteristics of the
+  // the platform that are used during ergonomic decisions.
+  VM_Version::init_before_ergo();
 }
 
 void os::signal_init() {
diff --git a/hotspot/src/share/vm/runtime/safepoint.cpp b/hotspot/src/share/vm/runtime/safepoint.cpp
index cf64606..2f46a84 100644
--- a/hotspot/src/share/vm/runtime/safepoint.cpp
+++ b/hotspot/src/share/vm/runtime/safepoint.cpp
@@ -142,7 +142,7 @@
 
   // Save the starting time, so that it can be compared to see if this has taken
   // too long to complete.
-  jlong safepoint_limit_time;
+  jlong safepoint_limit_time = 0;
   timeout_error_printed = false;
 
   // PrintSafepointStatisticsTimeout can be specified separately. When
@@ -925,7 +925,7 @@
 
 
 void ThreadSafepointState::print_on(outputStream *st) const {
-  const char *s;
+  const char *s = NULL;
 
   switch(_type) {
     case _running                : s = "_running";              break;
diff --git a/hotspot/src/share/vm/runtime/thread.cpp b/hotspot/src/share/vm/runtime/thread.cpp
index 4866ec1..0dc86d9 100644
--- a/hotspot/src/share/vm/runtime/thread.cpp
+++ b/hotspot/src/share/vm/runtime/thread.cpp
@@ -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
@@ -2926,13 +2926,13 @@
   const char* name_str;
   oop thread_obj = threadObj();
   if (thread_obj != NULL) {
-    typeArrayOop name = java_lang_Thread::name(thread_obj);
+    oop name = java_lang_Thread::name(thread_obj);
     if (name != NULL) {
       if (buf == NULL) {
-        name_str = UNICODE::as_utf8((jchar*) name->base(T_CHAR), name->length());
+        name_str = java_lang_String::as_utf8_string(name);
       }
       else {
-        name_str = UNICODE::as_utf8((jchar*) name->base(T_CHAR), name->length(), buf, buflen);
+        name_str = java_lang_String::as_utf8_string(name, buf, buflen);
       }
     }
     else if (is_attaching_via_jni()) { // workaround for 6412693 - see 6404306
diff --git a/hotspot/src/share/vm/runtime/vm_version.hpp b/hotspot/src/share/vm/runtime/vm_version.hpp
index 07ff4ba..feabadf 100644
--- a/hotspot/src/share/vm/runtime/vm_version.hpp
+++ b/hotspot/src/share/vm/runtime/vm_version.hpp
@@ -54,6 +54,12 @@
                                                   unsigned int dem,
                                                   unsigned int switch_pt);
  public:
+  // Called as part of the runtime services initialization which is
+  // called from the management module initialization (via init_globals())
+  // after argument parsing and attaching of the main thread has
+  // occurred.  Examines a variety of the hardware capabilities of
+  // the platform to determine which features can be used to execute the
+  // program.
   static void initialize();
 
   // This allows for early initialization of VM_Version information
@@ -63,6 +69,11 @@
   // need to specialize this define VM_Version::early_initialize().
   static void early_initialize() { }
 
+  // Called to initialize VM variables needing initialization
+  // after command line parsing. Platforms that need to specialize
+  // this should define VM_Version::init_before_ergo().
+  static void init_before_ergo() {}
+
   // Name
   static const char* vm_name();
   // Vendor
diff --git a/hotspot/src/share/vm/services/diagnosticCommand.cpp b/hotspot/src/share/vm/services/diagnosticCommand.cpp
index b38da2e..f9551c9 100644
--- a/hotspot/src/share/vm/services/diagnosticCommand.cpp
+++ b/hotspot/src/share/vm/services/diagnosticCommand.cpp
@@ -437,6 +437,10 @@
   ("config.file",
    "set com.sun.management.config.file", "STRING", false),
 
+  _jmxremote_host
+  ("jmxremote.host",
+   "set com.sun.management.jmxremote.host", "STRING", false),
+
   _jmxremote_port
   ("jmxremote.port",
    "set com.sun.management.jmxremote.port", "STRING", false),
@@ -516,6 +520,7 @@
 
   {
     _dcmdparser.add_dcmd_option(&_config_file);
+    _dcmdparser.add_dcmd_option(&_jmxremote_host);
     _dcmdparser.add_dcmd_option(&_jmxremote_port);
     _dcmdparser.add_dcmd_option(&_jmxremote_rmi_port);
     _dcmdparser.add_dcmd_option(&_jmxremote_ssl);
@@ -586,6 +591,7 @@
     }
 
     PUT_OPTION(_config_file);
+    PUT_OPTION(_jmxremote_host);
     PUT_OPTION(_jmxremote_port);
     PUT_OPTION(_jmxremote_rmi_port);
     PUT_OPTION(_jmxremote_ssl);
diff --git a/hotspot/src/share/vm/services/diagnosticCommand.hpp b/hotspot/src/share/vm/services/diagnosticCommand.hpp
index 2ce4109..3fda342 100644
--- a/hotspot/src/share/vm/services/diagnosticCommand.hpp
+++ b/hotspot/src/share/vm/services/diagnosticCommand.hpp
@@ -280,6 +280,7 @@
   // com.sun.management is omitted
 
   DCmdArgument<char *> _config_file;
+  DCmdArgument<char *> _jmxremote_host;
   DCmdArgument<char *> _jmxremote_port;
   DCmdArgument<char *> _jmxremote_rmi_port;
   DCmdArgument<char *> _jmxremote_ssl;
diff --git a/hotspot/src/share/vm/services/heapDumper.cpp b/hotspot/src/share/vm/services/heapDumper.cpp
index 3b81e72..9086cfb 100644
--- a/hotspot/src/share/vm/services/heapDumper.cpp
+++ b/hotspot/src/share/vm/services/heapDumper.cpp
@@ -376,11 +376,11 @@
   };
 
   int _fd;              // file descriptor (-1 if dump file not open)
-  jlong _bytes_written; // number of byte written to dump file
+  julong _bytes_written; // number of byte written to dump file
 
   char* _buffer;    // internal buffer
-  int _size;
-  int _pos;
+  size_t _size;
+  size_t _pos;
 
   char* _error;   // error message when I/O fails
 
@@ -388,14 +388,14 @@
   int file_descriptor() const                   { return _fd; }
 
   char* buffer() const                          { return _buffer; }
-  int buffer_size() const                       { return _size; }
-  int position() const                          { return _pos; }
-  void set_position(int pos)                    { _pos = pos; }
+  size_t buffer_size() const                    { return _size; }
+  size_t position() const                       { return _pos; }
+  void set_position(size_t pos)                 { _pos = pos; }
 
   void set_error(const char* error)             { _error = (char*)os::strdup(error); }
 
   // all I/O go through this function
-  void write_internal(void* s, int len);
+  void write_internal(void* s, size_t len);
 
  public:
   DumpWriter(const char* path);
@@ -406,14 +406,14 @@
   void flush();
 
   // total number of bytes written to the disk
-  jlong bytes_written() const           { return _bytes_written; }
+  julong bytes_written() const          { return _bytes_written; }
 
   // adjust the number of bytes written to disk (used to keep the count
   // of the number of bytes written in case of rewrites)
-  void adjust_bytes_written(jlong n)     { _bytes_written += n; }
+  void adjust_bytes_written(jlong n)    { _bytes_written += n; }
 
   // number of (buffered) bytes as yet unwritten to the dump file
-  jlong bytes_unwritten() const          { return (jlong)position(); }
+  size_t bytes_unwritten() const        { return position(); }
 
   char* error() const                   { return _error; }
 
@@ -421,7 +421,7 @@
   void seek_to_offset(jlong pos);
 
   // writer functions
-  void write_raw(void* s, int len);
+  void write_raw(void* s, size_t len);
   void write_u1(u1 x)                   { write_raw((void*)&x, 1); }
   void write_u2(u2 x);
   void write_u4(u4 x);
@@ -474,29 +474,33 @@
 }
 
 // write directly to the file
-void DumpWriter::write_internal(void* s, int len) {
+void DumpWriter::write_internal(void* s, size_t len) {
   if (is_open()) {
-    int n = ::write(file_descriptor(), s, len);
-    if (n > 0) {
-      _bytes_written += n;
-    }
-    if (n != len) {
+    const char* pos = (char*)s;
+    ssize_t n = 0;
+    while (len > 0) {
+      uint tmp = (uint)MIN2(len, (size_t)UINT_MAX);
+      n = ::write(file_descriptor(), pos, tmp);
+
       if (n < 0) {
         set_error(strerror(errno));
-      } else {
-        set_error("file size limit");
+        ::close(file_descriptor());
+        set_file_descriptor(-1);
+        return;
       }
-      ::close(file_descriptor());
-      set_file_descriptor(-1);
+
+      _bytes_written += n;
+      pos += n;
+      len -= n;
     }
   }
 }
 
 // write raw bytes
-void DumpWriter::write_raw(void* s, int len) {
+void DumpWriter::write_raw(void* s, size_t len) {
   if (is_open()) {
-    // flush buffer to make toom
-    if ((position()+ len) >= buffer_size()) {
+    // flush buffer to make room
+    if ((position() + len) >= buffer_size()) {
       flush();
     }
 
@@ -519,13 +523,12 @@
   }
 }
 
-
 jlong DumpWriter::current_offset() {
   if (is_open()) {
     // the offset is the file offset plus whatever we have buffered
     jlong offset = os::current_file_offset(file_descriptor());
     assert(offset >= 0, "lseek failed");
-    return offset + (jlong)position();
+    return offset + position();
   } else {
     return (jlong)-1;
   }
@@ -774,7 +777,7 @@
   HandleMark hm;
   instanceKlassHandle ikh = instanceKlassHandle(Thread::current(), k);
 
-  int size = 0;
+  u4 size = 0;
 
   for (FieldStream fld(ikh, false, false); !fld.eos(); fld.next()) {
     if (!fld.access_flags().is_static()) {
@@ -799,7 +802,7 @@
       }
     }
   }
-  return (u4)size;
+  return size;
 }
 
 // dumps static fields of the given class
@@ -1031,8 +1034,7 @@
   }
 
   // If the byte ordering is big endian then we can copy most types directly
-  int length_in_bytes = array->length() * type2aelembytes(type);
-  assert(length_in_bytes > 0, "nothing to copy");
+  u4 length_in_bytes = (u4)array->length() * type2aelembytes(type);
 
   switch (type) {
     case T_INT : {
@@ -1285,22 +1287,18 @@
     }
   }
 
-  // create a HPROF_GC_INSTANCE record for each object
   if (o->is_instance()) {
+    // create a HPROF_GC_INSTANCE record for each object
     DumperSupport::dump_instance(writer(), o);
     mark_end_of_record();
-  } else {
+  } else if (o->is_objArray()) {
     // create a HPROF_GC_OBJ_ARRAY_DUMP record for each object array
-    if (o->is_objArray()) {
-      DumperSupport::dump_object_array(writer(), objArrayOop(o));
-      mark_end_of_record();
-    } else {
-      // create a HPROF_GC_PRIM_ARRAY_DUMP record for each type array
-      if (o->is_typeArray()) {
-        DumperSupport::dump_prim_array(writer(), typeArrayOop(o));
-        mark_end_of_record();
-      }
-    }
+    DumperSupport::dump_object_array(writer(), objArrayOop(o));
+    mark_end_of_record();
+  } else if (o->is_typeArray()) {
+    // create a HPROF_GC_PRIM_ARRAY_DUMP record for each type array
+    DumperSupport::dump_prim_array(writer(), typeArrayOop(o));
+    mark_end_of_record();
   }
 }
 
@@ -1448,11 +1446,11 @@
     assert(dump_start() >= 0, "no dump start recorded");
 
     // calculate the size of the dump record
-    jlong dump_end = writer()->current_offset();
-    jlong dump_len = (dump_end - dump_start() - 4);
+    julong dump_end = writer()->current_offset();
+    julong dump_len = (dump_end - dump_start() - 4);
 
     // record length must fit in a u4
-    if (dump_len > (jlong)(4L*(jlong)G)) {
+    if (dump_len > max_juint) {
       warning("record is too large");
     }
 
@@ -1461,7 +1459,7 @@
     writer()->write_u4((u4)dump_len);
 
     // adjust the total size written to keep the bytes written correct.
-    writer()->adjust_bytes_written(-((long) sizeof(u4)));
+    writer()->adjust_bytes_written(-((jlong) sizeof(u4)));
 
     // seek to dump end so we can continue
     writer()->seek_to_offset(dump_end);
@@ -1477,12 +1475,12 @@
   if (writer()->is_open()) {
     if (is_segmented_dump()) {
       // don't use current_offset that would be too expensive on a per record basis
-      jlong dump_end = writer()->bytes_written() + writer()->bytes_unwritten();
-      assert(dump_end == writer()->current_offset(), "checking");
-      jlong dump_len = (dump_end - dump_start() - 4);
-      assert(dump_len >= 0 && dump_len <= max_juint, "bad dump length");
+      julong dump_end = writer()->bytes_written() + writer()->bytes_unwritten();
+      assert(dump_end == (julong)writer()->current_offset(), "checking");
+      julong dump_len = (dump_end - dump_start() - 4);
+      assert(dump_len <= max_juint, "bad dump length");
 
-      if (dump_len > (jlong)HeapDumpSegmentSize) {
+      if (dump_len > HeapDumpSegmentSize) {
         write_current_dump_record_length();
         write_dump_header();
       }
@@ -1868,13 +1866,8 @@
   if (print_to_tty()) {
     timer()->stop();
     if (error() == NULL) {
-      char msg[256];
-      sprintf(msg, "Heap dump file created [%s bytes in %3.3f secs]",
-        JLONG_FORMAT, timer()->seconds());
-PRAGMA_DIAG_PUSH
-PRAGMA_FORMAT_NONLITERAL_IGNORED_INTERNAL
-      tty->print_cr(msg, writer.bytes_written());
-PRAGMA_DIAG_POP
+      tty->print_cr("Heap dump file created [" JULONG_FORMAT " bytes in %3.3f secs]",
+                    writer.bytes_written(), timer()->seconds());
     } else {
       tty->print_cr("Dump file is incomplete: %s", writer.error());
     }
diff --git a/hotspot/src/share/vm/services/threadService.hpp b/hotspot/src/share/vm/services/threadService.hpp
index f5c5121..46bc012 100644
--- a/hotspot/src/share/vm/services/threadService.hpp
+++ b/hotspot/src/share/vm/services/threadService.hpp
@@ -425,12 +425,12 @@
   }
 
   JavaThreadStatusChanger(JavaThread* java_thread,
-                          java_lang_Thread::ThreadStatus state) {
+                          java_lang_Thread::ThreadStatus state) : _old_state(java_lang_Thread::NEW) {
     save_old_state(java_thread);
     set_thread_status(state);
   }
 
-  JavaThreadStatusChanger(JavaThread* java_thread) {
+  JavaThreadStatusChanger(JavaThread* java_thread) : _old_state(java_lang_Thread::NEW) {
     save_old_state(java_thread);
   }
 
@@ -527,7 +527,7 @@
   // Current thread is the notifying thread which holds the monitor.
   static bool wait_reenter_begin(JavaThread *java_thread, ObjectMonitor *obj_m) {
     assert((java_thread != NULL), "Java thread should not be null here");
-    bool active  = false;
+    bool active = false;
     if (is_alive(java_thread) && ServiceUtil::visible_oop((oop)obj_m->object())) {
       active = contended_enter_begin(java_thread);
     }
@@ -542,7 +542,7 @@
   }
 
   JavaThreadBlockedOnMonitorEnterState(JavaThread *java_thread, ObjectMonitor *obj_m) :
-    JavaThreadStatusChanger(java_thread) {
+    _stat(NULL), _active(false), JavaThreadStatusChanger(java_thread) {
     assert((java_thread != NULL), "Java thread should not be null here");
     // Change thread status and collect contended enter stats for monitor contended
     // enter done for external java world objects and it is contended. All other cases
diff --git a/hotspot/test/TEST.groups b/hotspot/test/TEST.groups
index 9ec3c85..78d27c9 100644
--- a/hotspot/test/TEST.groups
+++ b/hotspot/test/TEST.groups
@@ -61,7 +61,6 @@
 # can be resolved in some cases by using tools from the compile-jdk.
 #
 needs_jdk = \
-  gc/TestG1ZeroPGCTJcmdThreadPrint.java \
   gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java \
   gc/metaspace/TestMetaspacePerfCounters.java \
   gc/metaspace/TestPerfCountersAndMemoryPools.java \
@@ -216,6 +215,7 @@
   runtime/NMT \
   gc/class_unloading/TestCMSClassUnloadingEnabledHWM.java \
   gc/class_unloading/TestG1ClassUnloadingHWM.java \
+  gc/ergonomics/TestDynamicNumberOfGCThreads.java \
   gc/g1/TestRegionAlignment.java \
   gc/g1/TestShrinkToOneRegion.java \
   gc/metaspace/G1AddMetaspaceDependency.java \
diff --git a/hotspot/test/compiler/jsr292/LongReferenceCastingTest.java b/hotspot/test/compiler/jsr292/LongReferenceCastingTest.java
new file mode 100644
index 0000000..218b096
--- /dev/null
+++ b/hotspot/test/compiler/jsr292/LongReferenceCastingTest.java
@@ -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.
+ *
+ */
+
+import java.lang.invoke.*;
+
+/**
+ * @test
+ * @bug 8148752
+ * @summary Test correct casting of MH arguments during inlining.
+ * @run main LongReferenceCastingTest
+ */
+public class LongReferenceCastingTest {
+    static final String MY_STRING = "myString";
+    static final MethodHandle MH;
+
+    static {
+        try {
+            MethodHandles.Lookup lookup = MethodHandles.lookup();
+            MethodType mt = MethodType.methodType(String.class, long.class, Object.class, String.class);
+            MH = lookup.findVirtual(LongReferenceCastingTest.class, "myMethod", mt);
+        } catch (Exception e) {
+            throw new Error(e);
+        }
+    }
+
+    public String myMethod(long l, Object o, String s) {
+        // The long argument occupies two stack slots, causing C2 to treat it as
+        // two arguments and casting the fist one two long and the second one to Object.
+        // As a result, Object o is casted to String and the o.toString() call is
+        // inlined as String::toString(). We fail at runtime because 'o' is not a String.
+        return o.toString();
+    }
+
+    public String toString() {
+        return MY_STRING;
+    }
+
+    public static void main(String[] args) throws Exception {
+        LongReferenceCastingTest test = new LongReferenceCastingTest();
+        try {
+            for (int i = 0; i < 20_000; ++i) {
+                if (!test.invoke().equals(MY_STRING)) {
+                    throw new RuntimeException("Invalid string");
+                }
+            }
+        } catch (Throwable t) {
+            throw new RuntimeException("Test failed", t);
+        }
+    }
+
+    public String invoke() throws Throwable {
+        return (String) MH.invokeExact(this, 0L, (Object)this, MY_STRING);
+    }
+}
diff --git a/hotspot/test/compiler/loopopts/TestArraysFillDeadControl.java b/hotspot/test/compiler/loopopts/TestArraysFillDeadControl.java
new file mode 100644
index 0000000..540ba42
--- /dev/null
+++ b/hotspot/test/compiler/loopopts/TestArraysFillDeadControl.java
@@ -0,0 +1,53 @@
+/*
+ * 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 8147645
+ * @summary Array.fill intrinsification code doesn't mark replaced control as dead
+ * @run main/othervm  -XX:-TieredCompilation -XX:CompileCommand=dontinline,TestArraysFillDeadControl::dont_inline TestArraysFillDeadControl
+ *
+ */
+
+import java.util.Arrays;
+
+public class TestArraysFillDeadControl {
+
+    static void dont_inline() {
+    }
+
+    static int i = 1;
+
+    public static void main(String[] args) {
+        for (int j = 0; j < 200000; j++) {
+            int[] a = new int[2];
+            int b = i;
+
+            Arrays.fill(a, 1);
+            Arrays.fill(a, 1+b);
+
+            dont_inline();
+        }
+    }
+}
diff --git a/hotspot/test/compiler/types/TestMeetIncompatibleInterfaceArrays.java b/hotspot/test/compiler/types/TestMeetIncompatibleInterfaceArrays.java
new file mode 100644
index 0000000..ccd90ef
--- /dev/null
+++ b/hotspot/test/compiler/types/TestMeetIncompatibleInterfaceArrays.java
@@ -0,0 +1,351 @@
+/*
+ * Copyright 2015 SAP AG.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8141551
+ * @summary C2 can not handle returns with inccompatible interface arrays
+ * @library /testlibrary /testlibrary/whitebox/
+ * @build sun.hotspot.WhiteBox
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ *                              sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm
+ *        -Xbootclasspath/a:.
+ *        -XX:+UnlockDiagnosticVMOptions
+ *        -XX:+WhiteBoxAPI
+ *        -Xbatch
+ *        -XX:CompileThreshold=1
+ *        -XX:-TieredCompilation
+ *        -XX:CICompilerCount=1
+ *        -XX:+PrintCompilation
+ *        -XX:+PrintInlining
+ *        -XX:CompileCommand=compileonly,MeetIncompatibleInterfaceArrays*.run
+ *        -XX:CompileCommand=dontinline,TestMeetIncompatibleInterfaceArrays$Helper.createI2*
+ *        -XX:CompileCommand=quiet
+ *        TestMeetIncompatibleInterfaceArrays 0
+ * @run main/othervm
+ *        -Xbootclasspath/a:.
+ *        -XX:+UnlockDiagnosticVMOptions
+ *        -XX:+WhiteBoxAPI
+ *        -Xbatch
+ *        -XX:CompileThreshold=1
+ *        -XX:-TieredCompilation
+ *        -XX:CICompilerCount=1
+ *        -XX:+PrintCompilation
+ *        -XX:+PrintInlining
+ *        -XX:CompileCommand=compileonly,MeetIncompatibleInterfaceArrays*.run
+ *        -XX:CompileCommand=inline,TestMeetIncompatibleInterfaceArrays$Helper.createI2*
+ *        -XX:CompileCommand=quiet
+ *        TestMeetIncompatibleInterfaceArrays 1
+ * @run main/othervm
+ *        -Xbootclasspath/a:.
+ *        -XX:+UnlockDiagnosticVMOptions
+ *        -XX:+WhiteBoxAPI
+ *        -Xbatch
+ *        -XX:CompileThreshold=1
+ *        -XX:Tier0InvokeNotifyFreqLog=0 -XX:Tier2InvokeNotifyFreqLog=0 -XX:Tier3InvokeNotifyFreqLog=0 -XX:Tier23InlineeNotifyFreqLog=0
+ *        -XX:Tier3InvocationThreshold=2 -XX:Tier3MinInvocationThreshold=2 -XX:Tier3CompileThreshold=2
+ *        -XX:Tier4InvocationThreshold=1 -XX:Tier4MinInvocationThreshold=1 -XX:Tier4CompileThreshold=1
+ *        -XX:+TieredCompilation
+ *        -XX:CICompilerCount=2
+ *        -XX:+PrintCompilation
+ *        -XX:+PrintInlining
+ *        -XX:CompileCommand=compileonly,MeetIncompatibleInterfaceArrays*.run
+ *        -XX:CompileCommand=compileonly,TestMeetIncompatibleInterfaceArrays$Helper.createI2*
+ *        -XX:CompileCommand=inline,TestMeetIncompatibleInterfaceArrays$Helper.createI2*
+ *        -XX:CompileCommand=quiet
+ *        TestMeetIncompatibleInterfaceArrays 2
+ *
+ * @author volker.simonis@gmail.com
+ */
+
+import java.io.FileOutputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import jdk.internal.org.objectweb.asm.ClassWriter;
+import jdk.internal.org.objectweb.asm.MethodVisitor;
+import static jdk.internal.org.objectweb.asm.Opcodes.*;
+import sun.hotspot.WhiteBox;
+
+public class TestMeetIncompatibleInterfaceArrays extends ClassLoader {
+
+    private static final WhiteBox WB = WhiteBox.getWhiteBox();
+
+    public static interface I1 { public String getName(); }
+    public static interface I2 { public String getName(); }
+    public static class I2C implements I2 { public String getName() { return "I2";} }
+    public static class I21C implements I2, I1 { public String getName() { return "I2 and I1";} }
+
+    public static class Helper {
+        public static I2 createI2Array0() {
+            return new I2C();
+        }
+        public static I2[] createI2Array1() {
+            return new I2C[] { new I2C() };
+        }
+        public static I2[][] createI2Array2() {
+            return new I2C[][] { new I2C[] { new I2C() } };
+        }
+        public static I2[][][] createI2Array3() {
+            return new I2C[][][] { new I2C[][] { new I2C[] { new I2C() } } };
+        }
+        public static I2[][][][] createI2Array4() {
+            return new I2C[][][][] { new I2C[][][] { new I2C[][] { new I2C[] { new I2C() } } } };
+        }
+        public static I2[][][][][] createI2Array5() {
+            return new I2C[][][][][] { new I2C[][][][] { new I2C[][][] { new I2C[][] { new I2C[] { new I2C() } } } } };
+        }
+        public static I2 createI21Array0() {
+            return new I21C();
+        }
+        public static I2[] createI21Array1() {
+            return new I21C[] { new I21C() };
+        }
+        public static I2[][] createI21Array2() {
+            return new I21C[][] { new I21C[] { new I21C() } };
+        }
+        public static I2[][][] createI21Array3() {
+            return new I21C[][][] { new I21C[][] { new I21C[] { new I21C() } } };
+        }
+        public static I2[][][][] createI21Array4() {
+            return new I21C[][][][] { new I21C[][][] { new I21C[][] { new I21C[] { new I21C() } } } };
+        }
+        public static I2[][][][][] createI21Array5() {
+            return new I21C[][][][][] { new I21C[][][][] { new I21C[][][] { new I21C[][] { new I21C[] { new I21C() } } } } };
+        }
+    }
+
+    // Location for the generated class files
+    public static final String PATH = System.getProperty("test.classes", ".") + java.io.File.separator;
+
+    /*
+     * With 'good == false' this helper method creates the following classes
+     * (using the nested 'Helper' class and the nested interfaces 'I1' and 'I2').
+     * For brevity I omit the enclosing class 'TestMeetIncompatibleInterfaceArrays' in the
+     * following examples:
+     *
+     * public class MeetIncompatibleInterfaceArrays0ASM {
+     *   public static I1 run() {
+     *     return Helper.createI2Array0(); // returns I2
+     *   }
+     *   public static void test() {
+     *     I1 i1 = run();
+     *     System.out.println(i1.getName());
+     *   }
+     * }
+     * public class MeetIncompatibleInterfaceArrays1ASM {
+     *   public static I1[] run() {
+     *     return Helper.createI2Array1(); // returns I2[]
+     *   }
+     *   public static void test() {
+     *     I1[] i1 = run();
+     *     System.out.println(i1[0].getName());
+     *   }
+     * }
+     * ...
+     * // MeetIncompatibleInterfaceArrays4ASM is special because it creates
+     * // an illegal class which will be rejected by the verifier.
+     * public class MeetIncompatibleInterfaceArrays4ASM {
+     *   public static I1[][][][] run() {
+     *     return Helper.createI2Array3(); // returns I1[][][] which gives a verifier error because return expects I1[][][][]
+     *   }
+     *   public static void test() {
+     *     I1[][][][][] i1 = run();
+     *     System.out.println(i1[0][0][0][0][0].getName());
+     *   }
+     * ...
+     * public class MeetIncompatibleInterfaceArrays5ASM {
+     *   public static I1[][][][][] run() {
+     *     return Helper.createI2Array5(); // returns I2[][][][][]
+     *   }
+     *   public static void test() {
+     *     I1[][][][][] i1 = run();
+     *     System.out.println(i1[0][0][0][0][0].getName());
+     *   }
+     * }
+     *
+     * Notice that this is not legal Java code. We would have to use a cast in "run()" to make it legal:
+     *
+     *   public static I1[] run() {
+     *     return (I1[])Helper.createI2Array1(); // returns I2[]
+     *   }
+     *
+     * But in pure bytecode, the "run()" methods are perfectly legal:
+     *
+     *   public static I1[] run();
+     *     Code:
+     *       0: invokestatic  #16  // Method Helper.createI2Array1:()[LI2;
+     *       3: areturn
+     *
+     * The "test()" method calls the "getName()" function from I1 on the objects returned by "run()".
+     * This will epectedly fail with an "IncompatibleClassChangeError" because the objects returned
+     * by "run()" (and by createI2Array()) are actually of type "I2C" and only implement "I2" but not "I1".
+     *
+     *
+     * With 'good == true' this helper method will create the following classes:
+     *
+     * public class MeetIncompatibleInterfaceArraysGood0ASM {
+     *   public static I1 run() {
+     *     return Helper.createI21Array0(); // returns I2
+     *   }
+     *   public static void test() {
+     *     I1 i1 = run();
+     *     System.out.println(i1.getName());
+     *   }
+     * }
+     *
+     * Calling "test()" on these objects will succeed and output "I2 and I1" because now the "run()"
+     * method calls "createI21Array()" which actually return an object (or an array of objects) of
+     * type "I21C" which implements both "I2" and "I1".
+     *
+     * Notice that at the bytecode level, the code for the "run()" and "test()" methods in
+     * "MeetIncompatibleInterfaceArraysASM" and "MeetIncompatibleInterfaceArraysGoodASM" look exactly
+     * the same. I.e. the verifier has no chance to verify if the I2 object returned by "createI1Array()"
+     * or "createI21Array()" implements "I1" or not. That's actually the reason why both versions of
+     * generated classes are legal from a verifier point of view.
+     *
+     */
+    static void generateTestClass(int dim, boolean good) throws Exception {
+        String baseClassName = "MeetIncompatibleInterfaceArrays";
+        if (good)
+            baseClassName += "Good";
+        String createName = "createI2" + (good ? "1" : "") + "Array";
+        String a = "";
+        for (int i = 0; i < dim; i++)
+            a += "[";
+        ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
+        cw.visit(V1_8, ACC_PUBLIC, baseClassName + dim + "ASM", null, "java/lang/Object", null);
+        MethodVisitor constr = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
+        constr.visitCode();
+        constr.visitVarInsn(ALOAD, 0);
+        constr.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
+        constr.visitInsn(RETURN);
+        constr.visitMaxs(0, 0);
+        constr.visitEnd();
+        MethodVisitor run = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "run",
+                "()" + a + "LTestMeetIncompatibleInterfaceArrays$I1;", null, null);
+        run.visitCode();
+        if (dim == 4) {
+            run.visitMethodInsn(INVOKESTATIC, "TestMeetIncompatibleInterfaceArrays$Helper", createName + 3,
+                    "()" + "[[[" + "LTestMeetIncompatibleInterfaceArrays$I2;", false);
+        } else {
+            run.visitMethodInsn(INVOKESTATIC, "TestMeetIncompatibleInterfaceArrays$Helper", createName + dim,
+                    "()" + a + "LTestMeetIncompatibleInterfaceArrays$I2;", false);
+        }
+        run.visitInsn(ARETURN);
+        run.visitMaxs(0, 0);
+        run.visitEnd();
+        MethodVisitor test = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "test", "()V", null, null);
+        test.visitCode();
+        test.visitMethodInsn(INVOKESTATIC, baseClassName + dim + "ASM", "run",
+                "()" + a + "LTestMeetIncompatibleInterfaceArrays$I1;", false);
+        test.visitVarInsn(ASTORE, 0);
+        if (dim > 0) {
+            test.visitVarInsn(ALOAD, 0);
+            for (int i = 1; i <= dim; i++) {
+                test.visitInsn(ICONST_0);
+                test.visitInsn(AALOAD);
+            }
+            test.visitVarInsn(ASTORE, 1);
+        }
+        test.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
+        test.visitVarInsn(ALOAD, dim > 0 ? 1 : 0);
+        test.visitMethodInsn(INVOKEINTERFACE, "TestMeetIncompatibleInterfaceArrays$I1", "getName",
+                "()Ljava/lang/String;", true);
+        test.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/Object;)V", false);
+        test.visitInsn(RETURN);
+        test.visitMaxs(0, 0);
+        test.visitEnd();
+
+        // Get the bytes of the class..
+        byte[] b = cw.toByteArray();
+        // ..and write them into a class file (for debugging)
+        FileOutputStream fos = new FileOutputStream(PATH + baseClassName + dim + "ASM.class");
+        fos.write(b);
+        fos.close();
+
+    }
+
+    public static String[][] tier = { { "interpreted", "C2 (tier 4) without inlining", "C2 (tier4) without inlining" },
+            { "interpreted", "C2 (tier 4) with inlining", "C2 (tier4) with inlining" },
+            { "interpreted", "C1 (tier 3) with inlining", "C2 (tier4) with inlining" } };
+
+    public static void main(String[] args) throws Exception {
+        final int pass = Integer.parseInt(args.length > 0 ? args[0] : "0");
+
+        // Load and initialize some classes required for compilation
+        Class.forName("TestMeetIncompatibleInterfaceArrays$I1");
+        Class.forName("TestMeetIncompatibleInterfaceArrays$I2");
+        Class.forName("TestMeetIncompatibleInterfaceArrays$Helper");
+
+        for (int g = 0; g < 2; g++) {
+            String baseClassName = "MeetIncompatibleInterfaceArrays";
+            boolean good = (g == 0) ? false : true;
+            if (good)
+                baseClassName += "Good";
+            for (int i = 0; i < 6; i++) {
+                System.out.println();
+                System.out.println("Creating " + baseClassName + i + "ASM.class");
+                System.out.println("========================================" + "=" + "=========");
+                // Create the "MeetIncompatibleInterfaceArrays<i>ASM" class
+                generateTestClass(i, good);
+                Class<?> c = null;
+                try {
+                    c = Class.forName(baseClassName + i + "ASM");
+                } catch (VerifyError ve) {
+                    if (i == 4) {
+                        System.out.println("OK - must be (" + ve.getMessage() + ").");
+                    } else {
+                        throw ve;
+                    }
+                    continue;
+                }
+                // Call MeetIncompatibleInterfaceArrays<i>ASM.test()
+                Method m = c.getMethod("test");
+                Method r = c.getMethod("run");
+                for (int j = 0; j < 3; j++) {
+                    System.out.println((j + 1) + ". invokation of " + baseClassName + i + "ASM.test() [should be "
+                            + tier[pass][j] + "]");
+                    try {
+                        m.invoke(null);
+                    } catch (InvocationTargetException ite) {
+                        if (good) {
+                            throw ite;
+                        } else {
+                            if (ite.getCause() instanceof IncompatibleClassChangeError) {
+                                System.out.println("  OK - catched InvocationTargetException("
+                                        + ite.getCause().getMessage() + ").");
+                            } else {
+                                throw ite;
+                            }
+                        }
+                    }
+                }
+                System.out.println("Method " + r + (WB.isMethodCompiled(r) ? " has" : " has not") + " been compiled.");
+                if (!WB.isMethodCompiled(r)) {
+                    throw new Exception("Method " + r + " must be compiled!");
+                }
+            }
+        }
+    }
+}
diff --git a/hotspot/test/gc/TestG1ZeroPGCTJcmdThreadPrint.java b/hotspot/test/gc/TestG1ZeroPGCTJcmdThreadPrint.java
deleted file mode 100644
index efe1301..0000000
--- a/hotspot/test/gc/TestG1ZeroPGCTJcmdThreadPrint.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/* @test TestG1ZeroPGCTJcmdThreadPrint
- * @key gc
- * @bug 8005875
- * @summary Use jcmd to generate a thread dump of a Java program being run with PGCT=0 to verify 8005875
- * @library /testlibrary
- * @run main/othervm -XX:+UseG1GC -XX:ParallelGCThreads=0 -XX:+IgnoreUnrecognizedVMOptions TestG1ZeroPGCTJcmdThreadPrint
- */
-
-import com.oracle.java.testlibrary.*;
-
-public class TestG1ZeroPGCTJcmdThreadPrint {
-  public static void main(String args[]) throws Exception {
-
-    // Grab the pid from the current java process
-    String pid = Integer.toString(ProcessTools.getProcessId());
-
-    // Create a ProcessBuilder
-    ProcessBuilder pb = new ProcessBuilder();
-
-    // Run jcmd <pid> Thread.print
-    pb.command(JDKToolFinder.getJDKTool("jcmd"), pid, "Thread.print");
-
-    OutputAnalyzer output = new OutputAnalyzer(pb.start());
-
-    // There shouldn't be a work gang for concurrent marking.
-    output.shouldNotContain("G1 Parallel Marking Threads");
-
-    // Make sure we didn't crash
-    output.shouldHaveExitValue(0);
-  }
-}
diff --git a/hotspot/test/gc/TestVerifySubSet.java b/hotspot/test/gc/TestVerifySubSet.java
new file mode 100644
index 0000000..8797983
--- /dev/null
+++ b/hotspot/test/gc/TestVerifySubSet.java
@@ -0,0 +1,91 @@
+/*
+ * 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 TestVerifySubSet.java
+ * @key gc
+ * @bug 8072725
+ * @summary Test VerifySubSet option
+ * @library /testlibrary
+ */
+
+import com.oracle.java.testlibrary.OutputAnalyzer;
+import com.oracle.java.testlibrary.ProcessTools;
+import java.util.ArrayList;
+import java.util.Collections;
+
+class RunSystemGC {
+    public static void main(String args[]) throws Exception {
+        System.gc();
+    }
+}
+
+public class TestVerifySubSet {
+    private static String[] getTestJavaOpts() {
+        String testVmOptsStr = System.getProperty("test.java.opts");
+        if (!testVmOptsStr.isEmpty()) {
+            return testVmOptsStr.split(" ");
+        } else {
+            return new String[] {};
+        }
+    }
+
+    private static OutputAnalyzer runTest(String subset) throws Exception {
+        ArrayList<String> vmOpts = new ArrayList();
+
+        Collections.addAll(vmOpts, getTestJavaOpts());
+        Collections.addAll(vmOpts, new String[] {"-XX:+UnlockDiagnosticVMOptions",
+                                                 "-XX:+VerifyBeforeGC",
+                                                 "-XX:+VerifyAfterGC",
+                                                 "-XX:VerifySubSet="+subset,
+                                                 RunSystemGC.class.getName()});
+        ProcessBuilder pb =
+            ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
+        OutputAnalyzer output = new OutputAnalyzer(pb.start());
+
+        System.out.println("Output:\n" + output.getOutput());
+        return output;
+    }
+
+    public static void main(String args[]) throws Exception {
+
+        OutputAnalyzer output;
+
+        output = runTest("heap, threads, codecache, metaspace");
+        output.shouldContain("Heap");
+        output.shouldContain("Threads");
+        output.shouldContain("CodeCache");
+        output.shouldContain("MetaspaceAux");
+        output.shouldNotContain("SymbolTable");
+        output.shouldNotContain("StringTable");
+        output.shouldNotContain("SystemDictionary");
+        output.shouldNotContain("CodeCache Oops");
+        output.shouldHaveExitValue(0);
+
+        output = runTest("hello, threads, codecache, metaspace");
+        output.shouldContain("memory sub-system is unknown, please correct it");
+        output.shouldNotContain("Threads");
+        output.shouldNotContain("CodeCache");
+        output.shouldNotContain("MetaspaceAux");
+        output.shouldHaveExitValue(1);
+    }
+}
diff --git a/hotspot/test/gc/ergonomics/TestDynamicNumberOfGCThreads.java b/hotspot/test/gc/ergonomics/TestDynamicNumberOfGCThreads.java
new file mode 100644
index 0000000..f4a6625
--- /dev/null
+++ b/hotspot/test/gc/ergonomics/TestDynamicNumberOfGCThreads.java
@@ -0,0 +1,79 @@
+/*
+ * 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 TestDynamicNumberOfGCThreads
+ * @bug 8017462
+ * @summary Ensure that UseDynamicNumberOfGCThreads runs
+ * @requires vm.gc=="null"
+ * @key gc
+ * @library /testlibrary
+ */
+
+import com.oracle.java.testlibrary.ProcessTools;
+import com.oracle.java.testlibrary.OutputAnalyzer;
+
+public class TestDynamicNumberOfGCThreads {
+  public static void main(String[] args) throws Exception {
+
+    testDynamicNumberOfGCThreads("UseConcMarkSweepGC");
+
+    testDynamicNumberOfGCThreads("UseG1GC");
+
+    testDynamicNumberOfGCThreads("UseParallelGC");
+  }
+
+  private static void verifyDynamicNumberOfGCThreads(OutputAnalyzer output) {
+    output.shouldHaveExitValue(0); // test should run succesfully
+    output.shouldContain("new_active_workers");
+  }
+
+  private static void testDynamicNumberOfGCThreads(String gcFlag) throws Exception {
+    // UseDynamicNumberOfGCThreads and TraceDynamicGCThreads enabled
+    String[] baseArgs = {"-XX:+" + gcFlag, "-Xmx10M", "-XX:+PrintGCDetails",  "-XX:+UseDynamicNumberOfGCThreads", "-XX:+TraceDynamicGCThreads", GCTest.class.getName()};
+
+    // Base test with gc and +UseDynamicNumberOfGCThreads:
+    ProcessBuilder pb_enabled = ProcessTools.createJavaProcessBuilder(baseArgs);
+    verifyDynamicNumberOfGCThreads(new OutputAnalyzer(pb_enabled.start()));
+
+    // Ensure it also works on uniprocessors or if user specifies -XX:ParallelGCThreads=1:
+    String[] extraArgs = {"-XX:+UnlockDiagnosticVMOptions", "-XX:+ForceDynamicNumberOfGCThreads", "-XX:ParallelGCThreads=1"};
+    String[] finalArgs = new String[baseArgs.length + extraArgs.length];
+    System.arraycopy(extraArgs, 0, finalArgs, 0,                extraArgs.length);
+    System.arraycopy(baseArgs,  0, finalArgs, extraArgs.length, baseArgs.length);
+    pb_enabled = ProcessTools.createJavaProcessBuilder(finalArgs);
+    verifyDynamicNumberOfGCThreads(new OutputAnalyzer(pb_enabled.start()));
+  }
+
+  static class GCTest {
+    private static byte[] garbage;
+    public static void main(String [] args) {
+      System.out.println("Creating garbage");
+      // create 128MB of garbage. This should result in at least one GC
+      for (int i = 0; i < 1024; i++) {
+        garbage = new byte[128 * 1024];
+      }
+      System.out.println("Done");
+    }
+  }
+}
diff --git a/hotspot/test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java b/hotspot/test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java
index 82990cf..2524e23 100644
--- a/hotspot/test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java
+++ b/hotspot/test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java
@@ -42,8 +42,8 @@
 
     public static void main(String args[]) throws Exception {
         OutputAnalyzer output;
-        long commitSize = 4 * 1024; // 4KB
-        long reserveSize = 1024 * 1024; // 1024KB
+        long commitSize = 128 * 1024; // 128KB
+        long reserveSize = 4 * 1024 * 1024; // 4096KB
         long addr;
 
         String pid = Integer.toString(ProcessTools.getProcessId());
@@ -62,11 +62,11 @@
                 "VM.native_memory", "detail" });
 
         output = new OutputAnalyzer(pb.start());
-        output.shouldContain("Test (reserved=1024KB, committed=0KB)");
+        output.shouldContain("Test (reserved=4096KB, committed=0KB)");
         if (has_nmt_detail) {
             output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*"
                     + Long.toHexString(addr + reserveSize)
-                    + "\\] reserved 1024KB for Test");
+                    + "\\] reserved 4096KB for Test");
         }
 
         long addrA = addr;
@@ -83,24 +83,24 @@
         wb.NMTCommitMemory(addrD, commitSize);
 
         output = new OutputAnalyzer(pb.start());
-        output.shouldContain("Test (reserved=1024KB, committed=16KB)");
+        output.shouldContain("Test (reserved=4096KB, committed=512KB)");
 
         if (has_nmt_detail) {
             output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*"
                     + Long.toHexString(addr + reserveSize)
-                    + "\\] reserved 1024KB for Test");
+                    + "\\] reserved 4096KB for Test");
         }
         // uncommit BC
         wb.NMTUncommitMemory(addrB, commitSize);
         wb.NMTUncommitMemory(addrC, commitSize);
 
         output = new OutputAnalyzer(pb.start());
-        output.shouldContain("Test (reserved=1024KB, committed=8KB)");
+        output.shouldContain("Test (reserved=4096KB, committed=256KB)");
 
         if (has_nmt_detail) {
             output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*"
                     + Long.toHexString(addr + reserveSize)
-                    + "\\] reserved 1024KB for Test");
+                    + "\\] reserved 4096KB for Test");
         }
 
         // commit EF
@@ -108,22 +108,22 @@
         wb.NMTCommitMemory(addrF, commitSize);
 
         output = new OutputAnalyzer(pb.start());
-        output.shouldContain("Test (reserved=1024KB, committed=16KB)");
+        output.shouldContain("Test (reserved=4096KB, committed=512KB)");
         if (has_nmt_detail) {
             output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*"
                     + Long.toHexString(addr + reserveSize)
-                    + "\\] reserved 1024KB for Test");
+                    + "\\] reserved 4096KB for Test");
         }
 
         // uncommit A
         wb.NMTUncommitMemory(addrA, commitSize);
 
         output = new OutputAnalyzer(pb.start());
-        output.shouldContain("Test (reserved=1024KB, committed=12KB)");
+        output.shouldContain("Test (reserved=4096KB, committed=384KB)");
         if (has_nmt_detail) {
             output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*"
                     + Long.toHexString(addr + reserveSize)
-                    + "\\] reserved 1024KB for Test");
+                    + "\\] reserved 4096KB for Test");
         }
 
         // commit ABC
@@ -132,11 +132,11 @@
         wb.NMTCommitMemory(addrC, commitSize);
 
         output = new OutputAnalyzer(pb.start());
-        output.shouldContain("Test (reserved=1024KB, committed=24KB)");
+        output.shouldContain("Test (reserved=4096KB, committed=768KB)");
         if (has_nmt_detail) {
             output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*"
                     + Long.toHexString(addr + reserveSize)
-                    + "\\] reserved 1024KB for Test");
+                    + "\\] reserved 4096KB for Test");
         }
 
         // uncommit ABCDEF
@@ -148,11 +148,11 @@
         wb.NMTUncommitMemory(addrF, commitSize);
 
         output = new OutputAnalyzer(pb.start());
-        output.shouldContain("Test (reserved=1024KB, committed=0KB)");
+        output.shouldContain("Test (reserved=4096KB, committed=0KB)");
         if (has_nmt_detail) {
             output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*"
                     + Long.toHexString(addr + reserveSize)
-                    + "\\] reserved 1024KB for Test");
+                    + "\\] reserved 4096KB for Test");
         }
 
         // release
@@ -160,6 +160,6 @@
         output = new OutputAnalyzer(pb.start());
         output.shouldNotContain("Test (reserved=");
         output.shouldNotMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*"
-                + Long.toHexString(addr + reserveSize) + "\\] reserved 1024KB for Test");
+                + Long.toHexString(addr + reserveSize) + "\\] reserved 4096KB for Test");
     }
 }
diff --git a/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java b/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java
index 99bb670..6b3d3e3 100644
--- a/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java
+++ b/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java
@@ -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
@@ -233,4 +233,6 @@
     return offset;
   }
 
+  // Class Data Sharing
+  public native boolean isSharedClass(Class<?> c);
 }
diff --git a/jaxp/.hgtags b/jaxp/.hgtags
index a76a68b..86dd005 100644
--- a/jaxp/.hgtags
+++ b/jaxp/.hgtags
@@ -386,6 +386,7 @@
 56f6ca79467d04eb95383102046836b6ac7d2811 jdk8u40-b27
 7e43d4e20a33b8b6bd06112e39d367b51de921a7 jdk8u40-b31
 8facbe662ec106f1aae271f5c59909e124938c40 jdk8u40-b32
+b02301aeab79b1ee7859aeeb994fa5ba31105734 jdk8u40-b33
 9286acc600a779acb8bcfab38e82d4f50704afe3 jdk8u45-b00
 9fded65e1d36e3388111955d50ebf8511dd0345e jdk8u45-b01
 62566a3dbe5982565ce3e468ee3980b7937a86cc jdk8u45-b02
@@ -561,6 +562,7 @@
 06cdf5dc679e0fef7c8e37c5c712b2c5891c1444 jdk8u75-b01
 26c297e9f11b78b55cdefd22849ae4fe55042a5b jdk8u75-b02
 2a292503c55704cb7f898fa195d76682c0ea6a72 jdk8u75-b03
+cb072b12f5dbe3a249d596078d98a34ec9364187 jdk8u101-b00
 cb072b12f5dbe3a249d596078d98a34ec9364187 jdk8u75-b04
 40ccc40d58450eb4518348f6b34885c5a711675a jdk8u75-b05
 e77acebebfdc2f84b1217be3a6a2eb4c205afda5 jdk8u75-b06
@@ -576,6 +578,7 @@
 6b0d1f04c4808aaab32771e0892ac83e66714ecb jdk8u91-b00
 817898d53814da42f567995c921f3ea90016dccc jdk8u91-b13
 f6bda5729ff86e9691cd51f04261c3942974cecc jdk8u91-b14
+8b0bf55a041ae5657b1ae9e74e68258e8d36dda4 jdk8u91-b15
 acbcb6682c9b3e66f9cc61a6a62e8cb5f24c75d3 jdk8u76-b00
 b3c914ad842d61818e0c5850409f77478b13acc6 jdk8u76-b01
 7711933ec18462ece8a1b9a9527ec873c520b1ab jdk8u76-b02
@@ -595,3 +598,39 @@
 ac887193179bae82fd1cdf4d8c463457163a6535 jdk8u92-b31
 edce55dd16423b70ebdb36a14b3e6c62d223637b jdk8u92-b32
 69550dfee4b1adb5c73175f0555dd69e7436ca8b jdk8u92-b33
+75757308d2785ab9dc36fddf022e6d3f6e9246a6 jdk8u92-b34
+cb072b12f5dbe3a249d596078d98a34ec9364187 jdk8u81-b00
+fb5e0a18ad7d49134616879d1a500b1356e12fd4 jdk8u101-b01
+c7aeb4e55b0f7de8c5bd2a6e41dc5c54c4239271 jdk8u101-b02
+c678c1a31a553ebe7a8fd3888acc282dbd975e3b jdk8u101-b03
+a6a032a5490f4000bdfb25a2f604b22bcdf95ecf jdk8u101-b04
+80f389596bfaa22d4d2282b8417b98a53241f2aa jdk8u101-b05
+03f2bf9410ef2aad8d8a5ab0432ae0dbdf8bfd62 jdk8u101-b06
+39e620ddf0bb8c6a6d6f0588c71d5f43d8bcc987 jdk8u101-b07
+20b4715976338d4307c2d70e205ce88f31fbd7e7 jdk8u101-b08
+97939d061a0e492c6c2b464df44373165ecc15d2 jdk8u101-b09
+0066fe71b1203e103f7e1a2354bd94f65fdf38fd jdk8u101-b10
+0878a0a5fdabeec872e878f4737d96edee8b1393 jdk8u101-b11
+ddcc10eeb9d3367eb4b3fa0cd4d118e6dbc8850e jdk8u101-b12
+8ee36eca2124f4ea14d0b7ef844d5d7070eb0dd1 jdk8u101-b13
+acbcb6682c9b3e66f9cc61a6a62e8cb5f24c75d3 jdk8u76-b00
+b3c914ad842d61818e0c5850409f77478b13acc6 jdk8u76-b01
+7711933ec18462ece8a1b9a9527ec873c520b1ab jdk8u76-b02
+11dd1c13f1bd75f58fc0b020c767f2c331abb2a7 jdk8u76-b03
+1cc1c3510fd8b9fa2a18bfad3984ca16069f013e jdk8u76-b04
+b96204430344538b19eea491a8cb4ad1ba711c39 jdk8u102-b00
+b96204430344538b19eea491a8cb4ad1ba711c39 jdk8u82-b00
+7ae23fadd851d39b3c4f1a88cdb5e087e174afd5 jdk8u102-b01
+760d26dbaa27603ee94a746e47f166e6470290c2 jdk8u102-b02
+9be3e75c8f466e69f21a0894731a3863d48bcf43 jdk8u102-b03
+58469c50677dfcf88b7b2f740ac71c7e1d1dd1d2 jdk8u102-b04
+f5cb21e3a36196f1c8c224d6b17d88dec37f7e49 jdk8u102-b05
+545ae88cd091d1e362537971b0c6f1b8d4327b9e jdk8u102-b06
+f563e46f3083e1c542a6bf3e11547d297c9da8fa jdk8u102-b07
+c9f8318eb6315719d79a3fa4791d73da42e73fe2 jdk8u102-b08
+8f5ebb91ab3a341a6f7db7ede8113a4f52a6ab26 jdk8u102-b09
+018c7ebb858c5cd3af8e9b11b03e4e05663250b4 jdk8u102-b10
+429621d25778abb1ab7a0ede8dc48d5606f76108 jdk8u102-b11
+fef62f7eb59982f2c92a3bb135c6ae4d6a466328 jdk8u102-b12
+e9de037c3b4c7691662d996c49b42f3e639e65ee jdk8u102-b13
+1f032000ff4b70c3adc02669b6324880199f8db8 jdk8u102-b14
diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/XalanConstants.java b/jaxp/src/com/sun/org/apache/xalan/internal/XalanConstants.java
index e35d775..d77dfb0 100644
--- a/jaxp/src/com/sun/org/apache/xalan/internal/XalanConstants.java
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/XalanConstants.java
@@ -81,6 +81,14 @@
      */
     public static final String JDK_GENERAL_ENTITY_SIZE_LIMIT =
             ORACLE_JAXP_PROPERTY_PREFIX + "maxGeneralEntitySizeLimit";
+
+    /**
+     * JDK node count limit in entities that limits the total number of nodes
+     * in all of entity references.
+     */
+    public static final String JDK_ENTITY_REPLACEMENT_LIMIT =
+            ORACLE_JAXP_PROPERTY_PREFIX + "entityReplacementLimit";
+
     /**
      * JDK maximum parameter entity size limit
      */
@@ -137,6 +145,13 @@
      * JDK maximum general entity size limit
      */
     public static final String SP_GENERAL_ENTITY_SIZE_LIMIT = "jdk.xml.maxGeneralEntitySizeLimit";
+
+    /**
+     * JDK node count limit in entities that limits the total number of nodes
+     * in all of entity references.
+     */
+    public static final String SP_ENTITY_REPLACEMENT_LIMIT = "jdk.xml.entityReplacementLimit";
+
     /**
      * JDK maximum parameter entity size limit
      */
diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_TW.java b/jaxp/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_TW.java
index 80e0a34..ee8a11b 100644
--- a/jaxp/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_TW.java
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_TW.java
@@ -1265,7 +1265,7 @@
       "\u627E\u4E0D\u5230\u5341\u9032\u4F4D\u683C\u5F0F\u7684\u5BA3\u544A: {0}"},
 
     { WG_OLD_XSLT_NS,
-     "\u907A\u6F0F\u6216\u4E0D\u6B63\u78BA\u7684 XSLT \u547D\u540D\u7A7A\u9593\u3002 "},
+     "\u907A\u6F0F\u6216\u4E0D\u6B63\u78BA\u7684 XSLT \u547D\u540D\u7A7A\u9593\u3002"},
 
     { WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED,
       "\u53EA\u5141\u8A31\u4E00\u500B\u9810\u8A2D\u7684 xsl:decimal-format \u5BA3\u544A\u3002"},
diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/utils/XMLSecurityManager.java b/jaxp/src/com/sun/org/apache/xalan/internal/utils/XMLSecurityManager.java
index 0701bb1..96bb46c 100644
--- a/jaxp/src/com/sun/org/apache/xalan/internal/utils/XMLSecurityManager.java
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/utils/XMLSecurityManager.java
@@ -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
@@ -26,6 +26,8 @@
 package com.sun.org.apache.xalan.internal.utils;
 
 import com.sun.org.apache.xalan.internal.XalanConstants;
+import java.util.concurrent.CopyOnWriteArrayList;
+import org.xml.sax.SAXException;
 
 
 /**
@@ -80,7 +82,9 @@
         MAX_ELEMENT_DEPTH_LIMIT("MaxElementDepthLimit", XalanConstants.JDK_MAX_ELEMENT_DEPTH,
                 XalanConstants.SP_MAX_ELEMENT_DEPTH, 0, 0),
         MAX_NAME_LIMIT("MaxXMLNameLimit", XalanConstants.JDK_XML_NAME_LIMIT,
-                XalanConstants.SP_XML_NAME_LIMIT, 1000, 1000);
+                XalanConstants.SP_XML_NAME_LIMIT, 1000, 1000),
+        ENTITY_REPLACEMENT_LIMIT("EntityReplacementLimit", XalanConstants.JDK_ENTITY_REPLACEMENT_LIMIT,
+                XalanConstants.SP_ENTITY_REPLACEMENT_LIMIT, 0, 3000000);
 
         final String key;
         final String apiProperty;
@@ -415,6 +419,23 @@
 
     }
 
+    // Array list to store printed warnings for each SAX parser used
+    private static final CopyOnWriteArrayList<String> printedWarnings = new CopyOnWriteArrayList<>();
+
+    /**
+     * Prints out warnings if a parser does not support the specified feature/property.
+     *
+     * @param parserClassName the name of the parser class
+     * @param propertyName the property name
+     * @param exception the exception thrown by the parser
+     */
+    public static void printWarning(String parserClassName, String propertyName, SAXException exception) {
+        String key = parserClassName+":"+propertyName;
+        if (printedWarnings.addIfAbsent(key)) {
+            System.err.println( "Warning: "+parserClassName+": "+exception.getMessage());
+        }
+    }
+
     /**
      * Read from system properties, or those in jaxp.properties
      *
diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/DOM.java b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/DOM.java
index bf6fbf1..25ce372 100644
--- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/DOM.java
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/DOM.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,9 +17,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id: DOM.java,v 1.2.4.1 2005/08/31 10:18:49 pvedula Exp $
- */
 
 package com.sun.org.apache.xalan.internal.xsltc;
 
@@ -102,4 +99,5 @@
     public int getDocument();
     public String getUnparsedEntityURI(String name);
     public Map<String, Integer> getElementsWithIDs();
+    public void release();
 }
diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyTemplates.java b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyTemplates.java
index 174a1d1..d7bc1ca 100644
--- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyTemplates.java
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyTemplates.java
@@ -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.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,9 +17,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id: ApplyTemplates.java,v 1.2.4.1 2005/09/12 09:59:21 pvedula Exp $
- */
 
 package com.sun.org.apache.xalan.internal.xsltc.compiler;
 
@@ -120,12 +117,10 @@
         final int current = methodGen.getLocalIndex("current");
 
         // check if sorting nodes is required
-        final Vector sortObjects = new Vector();
-        final Iterator<SyntaxTreeNode> children = elements();
-        while (children.hasNext()) {
-            final SyntaxTreeNode child = children.next();
+        final Vector<Sort> sortObjects = new Vector<>();
+        for (final SyntaxTreeNode child : getContents()) {
             if (child instanceof Sort) {
-                sortObjects.addElement(child);
+                sortObjects.addElement((Sort)child);
             }
         }
 
@@ -191,6 +186,13 @@
                                                     applyTemplatesSig);
         il.append(new INVOKEVIRTUAL(applyTemplates));
 
+        // unmap parameters to release temporary result trees
+        for (final SyntaxTreeNode child : getContents()) {
+            if (child instanceof WithParam) {
+                ((WithParam)child).releaseResultTree(classGen, methodGen);
+            }
+        }
+
         // Pop parameter frame
         if (stylesheet.hasLocalParams() || hasContents()) {
             il.append(classGen.loadTranslet());
diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/CallTemplate.java b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/CallTemplate.java
index caace08..2e2ca14 100644
--- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/CallTemplate.java
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/CallTemplate.java
@@ -1,6 +1,5 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Copyright 2001-2004 The Apache Software Foundation.
@@ -17,18 +16,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id: CallTemplate.java,v 1.2.4.1 2005/09/12 10:02:41 pvedula Exp $
- */
 
 package com.sun.org.apache.xalan.internal.xsltc.compiler;
 
-import com.sun.org.apache.bcel.internal.generic.ALOAD;
-import com.sun.org.apache.bcel.internal.generic.ASTORE;
 import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
 import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL;
 import com.sun.org.apache.bcel.internal.generic.InstructionList;
-import com.sun.org.apache.bcel.internal.generic.LocalVariableGen;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator;
@@ -56,7 +49,7 @@
      * this array can be either a WithParam or a Param if no WithParam
      * exists for a particular parameter.
      */
-    private Object[] _parameters = null;
+    private SyntaxTreeNode[] _parameters = null;
 
     /**
      * The corresponding template which this CallTemplate calls.
@@ -147,11 +140,10 @@
 
         // If calling a simply named template, push actual arguments
         if (_calleeTemplate != null) {
-            Vector calleeParams = _calleeTemplate.getParameters();
             int numParams = _parameters.length;
 
             for (int i = 0; i < numParams; i++) {
-                SyntaxTreeNode node = (SyntaxTreeNode)_parameters[i];
+                SyntaxTreeNode node = _parameters[i];
                 methodSig.append(OBJECT_SIG);   // append Object to signature
 
                 // Push 'null' if Param to indicate no actual parameter specified
@@ -170,6 +162,15 @@
                                                      methodName,
                                                      methodSig.toString())));
 
+        // release temporary result trees
+        if (_parameters != null) {
+            for (int i = 0; i < _parameters.length; i++) {
+                if (_parameters[i] instanceof WithParam) {
+                    ((WithParam)_parameters[i]).releaseResultTree(classGen, methodGen);
+                }
+            }
+        }
+
         // Do not need to call Translet.popParamFrame() if we are
         // calling a simple named template.
         if (_calleeTemplate == null && (stylesheet.hasLocalParams() || hasContents())) {
@@ -203,9 +204,9 @@
     private void buildParameterList() {
         // Put the parameters from the called template into the array first.
         // This is to ensure the order of the parameters.
-        Vector defaultParams = _calleeTemplate.getParameters();
+        Vector<Param> defaultParams = _calleeTemplate.getParameters();
         int numParams = defaultParams.size();
-        _parameters = new Object[numParams];
+        _parameters = new SyntaxTreeNode[numParams];
         for (int i = 0; i < numParams; i++) {
             _parameters[i] = defaultParams.elementAt(i);
         }
@@ -222,15 +223,15 @@
 
                 // Search for a Param with the same name
                 for (int k = 0; k < numParams; k++) {
-                    Object object = _parameters[k];
-                    if (object instanceof Param
-                        && ((Param)object).getName().equals(name)) {
+                    SyntaxTreeNode parm = _parameters[k];
+                    if (parm instanceof Param
+                        && ((Param)parm).getName().equals(name)) {
                         withParam.setDoParameterOptimization(true);
                         _parameters[k] = withParam;
                         break;
                     }
-                    else if (object instanceof WithParam
-                        && ((WithParam)object).getName().equals(name)) {
+                    else if (parm instanceof WithParam
+                        && ((WithParam)parm).getName().equals(name)) {
                         withParam.setDoParameterOptimization(true);
                         _parameters[k] = withParam;
                         break;
diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Parser.java b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Parser.java
index 2584f43..d15d90e 100644
--- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Parser.java
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Parser.java
@@ -489,18 +489,20 @@
             }
 
             final XMLReader reader = parser.getXMLReader();
+            String lastProperty = "";
             try {
                 XMLSecurityManager securityManager =
                         (XMLSecurityManager)_xsltc.getProperty(XalanConstants.SECURITY_MANAGER);
                 for (XMLSecurityManager.Limit limit : XMLSecurityManager.Limit.values()) {
-                    reader.setProperty(limit.apiProperty(), securityManager.getLimitValueAsString(limit));
+                    lastProperty = limit.apiProperty();
+                    reader.setProperty(lastProperty, securityManager.getLimitValueAsString(limit));
                 }
                 if (securityManager.printEntityCountInfo()) {
+                    lastProperty = XalanConstants.JDK_ENTITY_COUNT_INFO;
                     parser.setProperty(XalanConstants.JDK_ENTITY_COUNT_INFO, XalanConstants.JDK_YES);
                 }
             } catch (SAXException se) {
-                System.err.println("Warning:  " + reader.getClass().getName() + ": "
-                            + se.getMessage());
+                XMLSecurityManager.printWarning(reader.getClass().getName(), lastProperty, se);
             }
 
             return(parse(reader, input));
diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Sort.java b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Sort.java
index d8264a2..f7309e5 100644
--- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Sort.java
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Sort.java
@@ -1,6 +1,5 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Copyright 2001-2005 The Apache Software Foundation.
@@ -17,32 +16,22 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id: Sort.java,v 1.2.4.1 2005/09/12 11:08:12 pvedula Exp $
- */
 
 package com.sun.org.apache.xalan.internal.xsltc.compiler;
 
-import java.text.Collator;
 import java.util.ArrayList;
-import java.util.NoSuchElementException;
-import java.util.StringTokenizer;
 import java.util.Vector;
 
 import com.sun.org.apache.bcel.internal.classfile.Field;
-import com.sun.org.apache.bcel.internal.classfile.Method;
 import com.sun.org.apache.bcel.internal.generic.ALOAD;
 import com.sun.org.apache.bcel.internal.generic.ANEWARRAY;
 import com.sun.org.apache.bcel.internal.generic.ASTORE;
 import com.sun.org.apache.bcel.internal.generic.CHECKCAST;
 import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
 import com.sun.org.apache.bcel.internal.generic.GETFIELD;
-import com.sun.org.apache.bcel.internal.generic.ICONST;
 import com.sun.org.apache.bcel.internal.generic.ILOAD;
 import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE;
 import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL;
-import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC;
-import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL;
 import com.sun.org.apache.bcel.internal.generic.InstructionHandle;
 import com.sun.org.apache.bcel.internal.generic.InstructionList;
 import com.sun.org.apache.bcel.internal.generic.LocalVariableGen;
@@ -76,13 +65,10 @@
     private AttributeValue _order;
     private AttributeValue _caseOrder;
     private AttributeValue _dataType;
-    private String  _lang; // bug! see 26869
-
-    private String         _data = null;
-
+    private String         _lang; // bug! see 26869
 
     private String _className = null;
-    private ArrayList _closureVars = null;
+    private ArrayList<VariableRefBase> _closureVars = null;
     private boolean _needsSortRecordFactory = false;
 
     // -- Begin Closure interface --------------------
@@ -115,7 +101,7 @@
      */
     public void addVariable(VariableRefBase variableRef) {
         if (_closureVars == null) {
-            _closureVars = new ArrayList();
+            _closureVars = new ArrayList<>();
         }
 
         // Only one reference per variable
@@ -246,7 +232,7 @@
     public static void translateSortIterator(ClassGenerator classGen,
                                       MethodGenerator methodGen,
                                       Expression nodeSet,
-                                      Vector sortObjects)
+                                      Vector<Sort> sortObjects)
     {
         final ConstantPoolGen cpg = classGen.getConstantPool();
         final InstructionList il = methodGen.getInstructionList();
@@ -312,7 +298,7 @@
      * Compiles code that instantiates a NodeSortRecordFactory object which
      * will produce NodeSortRecord objects of a specific type.
      */
-    public static void compileSortRecordFactory(Vector sortObjects,
+    public static void compileSortRecordFactory(Vector<Sort> sortObjects,
         ClassGenerator classGen, MethodGenerator methodGen)
     {
         String sortRecordClass =
@@ -321,7 +307,7 @@
         boolean needsSortRecordFactory = false;
         final int nsorts = sortObjects.size();
         for (int i = 0; i < nsorts; i++) {
-            final Sort sort = (Sort) sortObjects.elementAt(i);
+            final Sort sort = sortObjects.elementAt(i);
             needsSortRecordFactory |= sort._needsSortRecordFactory;
         }
 
@@ -429,7 +415,7 @@
                     + "[" + STRING_SIG + ")V")));
 
         // Initialize closure variables in sortRecordFactory
-        final ArrayList dups = new ArrayList();
+        final ArrayList<VariableRefBase> dups = new ArrayList<>();
 
         for (int j = 0; j < nsorts; j++) {
             final Sort sort = (Sort) sortObjects.get(j);
@@ -437,7 +423,7 @@
                 sort._closureVars.size();
 
             for (int i = 0; i < length; i++) {
-                VariableRefBase varRef = (VariableRefBase) sort._closureVars.get(i);
+                VariableRefBase varRef = sort._closureVars.get(i);
 
                 // Discard duplicate variable references
                 if (dups.contains(varRef)) continue;
@@ -455,11 +441,11 @@
         }
     }
 
-    public static String compileSortRecordFactory(Vector sortObjects,
+    public static String compileSortRecordFactory(Vector<Sort> sortObjects,
         ClassGenerator classGen, MethodGenerator methodGen,
         String sortRecordClass)
     {
-        final XSLTC  xsltc = ((Sort)sortObjects.firstElement()).getXSLTC();
+        final XSLTC xsltc = (sortObjects.firstElement()).getXSLTC();
         final String className = xsltc.getHelperClassName();
 
         final NodeSortRecordFactGenerator sortRecordFactory =
@@ -474,15 +460,15 @@
 
         // Add a new instance variable for each var in closure
         final int nsorts = sortObjects.size();
-        final ArrayList dups = new ArrayList();
+        final ArrayList<VariableRefBase> dups = new ArrayList<>();
 
         for (int j = 0; j < nsorts; j++) {
-            final Sort sort = (Sort) sortObjects.get(j);
+            final Sort sort = sortObjects.get(j);
             final int length = (sort._closureVars == null) ? 0 :
                 sort._closureVars.size();
 
             for (int i = 0; i < length; i++) {
-                final VariableRefBase varRef = (VariableRefBase) sort._closureVars.get(i);
+                final VariableRefBase varRef = sort._closureVars.get(i);
 
                 // Discard duplicate variable references
                 if (dups.contains(varRef)) continue;
@@ -600,10 +586,10 @@
     /**
      * Create a new auxillary class extending NodeSortRecord.
      */
-    private static String compileSortRecord(Vector sortObjects,
+    private static String compileSortRecord(Vector<Sort> sortObjects,
                                             ClassGenerator classGen,
                                             MethodGenerator methodGen) {
-        final XSLTC  xsltc = ((Sort)sortObjects.firstElement()).getXSLTC();
+        final XSLTC  xsltc = sortObjects.firstElement().getXSLTC();
         final String className = xsltc.getHelperClassName();
 
         // This generates a new class for handling this specific sort
@@ -619,10 +605,10 @@
 
         // Add a new instance variable for each var in closure
         final int nsorts = sortObjects.size();
-        final ArrayList dups = new ArrayList();
+        final ArrayList<VariableRefBase> dups = new ArrayList<>();
 
         for (int j = 0; j < nsorts; j++) {
-            final Sort sort = (Sort) sortObjects.get(j);
+            final Sort sort = sortObjects.get(j);
 
             // Set the name of the inner class in this sort object
             sort.setInnerClassName(className);
@@ -644,8 +630,7 @@
             }
         }
 
-        MethodGenerator init = compileInit(sortObjects, sortRecord,
-                                         cpg, className);
+        MethodGenerator init = compileInit(sortRecord, cpg, className);
         MethodGenerator extract = compileExtract(sortObjects, sortRecord,
                                         cpg, className);
         sortRecord.addMethod(init);
@@ -660,8 +645,7 @@
      * collator in the super calls only when the stylesheet specifies a new
      * language in xsl:sort.
      */
-    private static MethodGenerator compileInit(Vector sortObjects,
-                                           NodeSortRecordGenerator sortRecord,
+    private static MethodGenerator compileInit(NodeSortRecordGenerator sortRecord,
                                            ConstantPoolGen cpg,
                                            String className)
     {
@@ -688,7 +672,7 @@
     /**
      * Compiles a method that overloads NodeSortRecord.extractValueFromDOM()
      */
-    private static MethodGenerator compileExtract(Vector sortObjects,
+    private static MethodGenerator compileExtract(Vector<Sort> sortObjects,
                                          NodeSortRecordGenerator sortRecord,
                                          ConstantPoolGen cpg,
                                          String className) {
@@ -730,7 +714,7 @@
         // Append all the cases for the switch statment
         for (int level = 0; level < levels; level++) {
             match[level] = level;
-            final Sort sort = (Sort)sortObjects.elementAt(level);
+            final Sort sort = sortObjects.elementAt(level);
             target[level] = il.append(NOP);
             sort.translateSelect(sortRecord, extractMethod);
             il.append(ARETURN);
diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/SyntaxTreeNode.java b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/SyntaxTreeNode.java
index e9020cf..1e8ad86 100644
--- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/SyntaxTreeNode.java
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/SyntaxTreeNode.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,9 +17,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id: SyntaxTreeNode.java,v 1.6 2006/06/06 22:34:33 spericas Exp $
- */
 
 package com.sun.org.apache.xalan.internal.xsltc.compiler;
 
@@ -519,9 +516,9 @@
         // references falling out-of-scope inside the for-each element.
         // (the cause of which being 'lazy' register allocation for references)
         for (int i = 0; i < n; i++) {
-            if( _contents.get(i) instanceof VariableBase) {
+            if ( _contents.get(i) instanceof VariableBase) {
                 final VariableBase var = (VariableBase)_contents.get(i);
-                var.unmapRegister(methodGen);
+                var.unmapRegister(classGen, methodGen);
             }
         }
     }
diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Template.java b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Template.java
index b4d8228..c683744 100644
--- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Template.java
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Template.java
@@ -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.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,9 +17,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id: Template.java,v 1.2.4.1 2005/09/12 11:30:11 pvedula Exp $
- */
 
 package com.sun.org.apache.xalan.internal.xsltc.compiler;
 
@@ -61,7 +58,7 @@
 
     // The list of parameters in this template. This is only used
     // for simple named templates.
-    private Vector  _parameters = new Vector();
+    private Vector<Param> _parameters = new Vector<>();
 
     public boolean hasParams() {
         return _parameters.size() > 0;
@@ -83,7 +80,7 @@
         _parameters.addElement(param);
     }
 
-    public Vector getParameters() {
+    public Vector<Param> getParameters() {
         return _parameters;
     }
 
diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/VariableBase.java b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/VariableBase.java
index 7ef4c1c..02e1a5f 100644
--- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/VariableBase.java
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/VariableBase.java
@@ -1,6 +1,5 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Copyright 2001-2004 The Apache Software Foundation.
@@ -17,18 +16,18 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id: VariableBase.java,v 1.5 2005/09/28 13:48:18 pvedula Exp $
- */
 
 package com.sun.org.apache.xalan.internal.xsltc.compiler;
 
 import java.util.Vector;
 
+import com.sun.org.apache.bcel.internal.generic.CHECKCAST;
 import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
 import com.sun.org.apache.bcel.internal.generic.Instruction;
 import com.sun.org.apache.bcel.internal.generic.InstructionList;
+import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE;
 import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL;
+import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL;
 import com.sun.org.apache.bcel.internal.generic.LocalVariableGen;
 import com.sun.org.apache.bcel.internal.generic.NEW;
 import com.sun.org.apache.bcel.internal.generic.PUSH;
@@ -36,6 +35,7 @@
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeSetType;
+import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ResultTreeType;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
 import com.sun.org.apache.xml.internal.utils.XML11Char;
@@ -49,21 +49,18 @@
  */
 class VariableBase extends TopLevelElement {
 
-    protected QName       _name;            // The name of the variable.
-    protected String      _escapedName;        // The escaped qname of the variable.
-    protected Type        _type;            // The type of this variable.
-    protected boolean     _isLocal;         // True if the variable is local.
-    protected LocalVariableGen _local;      // Reference to JVM variable
-    protected Instruction _loadInstruction; // Instruction to load JVM variable
+    protected QName       _name;             // The name of the variable.
+    protected String      _escapedName;      // The escaped qname of the variable.
+    protected Type        _type;             // The type of this variable.
+    protected boolean     _isLocal;          // True if the variable is local.
+    protected LocalVariableGen _local;       // Reference to JVM variable
+    protected Instruction _loadInstruction;  // Instruction to load JVM variable
     protected Instruction _storeInstruction; // Instruction to load JVM variable
-    protected Expression  _select;          // Reference to variable expression
-    protected String      select;           // Textual repr. of variable expr.
+    protected Expression  _select;           // Reference to variable expression
+    protected String      select;            // Textual repr. of variable expr.
 
     // References to this variable (when local)
-    protected Vector      _refs = new Vector(2);
-
-    // Dependencies to other variables/parameters (for globals only)
-    protected Vector      _dependencies = null;
+    protected Vector<VariableRefBase> _refs = new Vector<>(2);
 
     // Used to make sure parameter field is not added twice
     protected boolean    _ignore = false;
@@ -92,7 +89,7 @@
     public void copyReferences(VariableBase var) {
         final int size = _refs.size();
         for (int i = 0; i < size; i++) {
-            var.addReference((VariableRefBase) _refs.get(i));
+            var.addReference(_refs.get(i));
         }
     }
 
@@ -112,8 +109,24 @@
      * Remove the mapping of this variable to a register.
      * Called when we leave the AST scope of the variable's declaration
      */
-    public void unmapRegister(MethodGenerator methodGen) {
+    public void unmapRegister(ClassGenerator classGen, MethodGenerator methodGen) {
         if (_local != null) {
+            if (_type instanceof ResultTreeType) {
+                final ConstantPoolGen cpg = classGen.getConstantPool();
+                final InstructionList il = methodGen.getInstructionList();
+                if (classGen.getStylesheet().callsNodeset() && classGen.getDOMClass().equals(MULTI_DOM_CLASS)) {
+                    final int removeDA = cpg.addMethodref(MULTI_DOM_CLASS, "removeDOMAdapter", "(" + DOM_ADAPTER_SIG + ")V");
+                    il.append(methodGen.loadDOM());
+                    il.append(new CHECKCAST(cpg.addClass(MULTI_DOM_CLASS)));
+                    il.append(loadInstruction());
+                    il.append(new CHECKCAST(cpg.addClass(DOM_ADAPTER_CLASS)));
+                    il.append(new INVOKEVIRTUAL(removeDA));
+                }
+                final int release = cpg.addInterfaceMethodref(DOM_IMPL_CLASS, "release", "()V");
+                il.append(loadInstruction());
+                il.append(new INVOKEINTERFACE(release, 1));
+            }
+
             _local.setEnd(methodGen.getInstructionList().getEnd());
             methodGen.removeLocalVariable(_local);
             _refs = null;
@@ -126,7 +139,6 @@
      * the JVM stack.
      */
     public Instruction loadInstruction() {
-        final Instruction instr = _loadInstruction;
         if (_loadInstruction == null) {
             _loadInstruction = _type.LOAD(_local.getIndex());
         }
@@ -138,7 +150,6 @@
      * into this variable.
      */
     public Instruction storeInstruction() {
-        final Instruction instr = _storeInstruction;
         if (_storeInstruction == null) {
             _storeInstruction = _type.STORE(_local.getIndex());
         }
diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/WithParam.java b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/WithParam.java
index 3a87d59..fc2b202 100644
--- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/WithParam.java
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/WithParam.java
@@ -1,6 +1,5 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Copyright 2001-2004 The Apache Software Foundation.
@@ -17,15 +16,17 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id: WithParam.java,v 1.2.4.1 2005/09/12 11:38:01 pvedula Exp $
- */
 
 package com.sun.org.apache.xalan.internal.xsltc.compiler;
 
+import com.sun.org.apache.bcel.internal.generic.ALOAD;
+import com.sun.org.apache.bcel.internal.generic.ASTORE;
+import com.sun.org.apache.bcel.internal.generic.CHECKCAST;
 import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
+import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE;
 import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL;
 import com.sun.org.apache.bcel.internal.generic.InstructionList;
+import com.sun.org.apache.bcel.internal.generic.LocalVariableGen;
 import com.sun.org.apache.bcel.internal.generic.PUSH;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator;
 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
@@ -60,6 +61,11 @@
     private Expression _select;
 
     /**
+     * Reference to JVM variable holding temporary result tree.
+     */
+    private LocalVariableGen _domAdapter;
+
+    /**
      * %OPT% This is set to true when the WithParam is used in a CallTemplate
      * for a simple named template. If this is true, the parameters are
      * passed to the named template through method arguments rather than
@@ -164,8 +170,13 @@
             _select.startIterator(classGen, methodGen);
         }
         // If not, compile result tree from parameter body if present.
+        // Store result tree into local variable for releasing it later
         else if (hasContents()) {
+            final InstructionList il = methodGen.getInstructionList();
             compileResultTree(classGen, methodGen);
+            _domAdapter = methodGen.addLocalVariable2("@" + _escapedName, Type.ResultTree.toJCType(), il.getEnd());
+            il.append(DUP);
+            il.append(new ASTORE(_domAdapter.getIndex()));
         }
         // If neither are present then store empty string in parameter slot
         else {
@@ -208,4 +219,26 @@
                                                      ADD_PARAMETER_SIG)));
         il.append(POP); // cleanup stack
     }
+
+    /**
+     * Release the compiled result tree.
+     */
+    public void releaseResultTree(ClassGenerator classGen, MethodGenerator methodGen) {
+        if (_domAdapter != null) {
+            final ConstantPoolGen cpg = classGen.getConstantPool();
+            final InstructionList il = methodGen.getInstructionList();
+            if (classGen.getStylesheet().callsNodeset() && classGen.getDOMClass().equals(MULTI_DOM_CLASS)) {
+                final int removeDA = cpg.addMethodref(MULTI_DOM_CLASS, "removeDOMAdapter", "(" + DOM_ADAPTER_SIG + ")V");
+                il.append(methodGen.loadDOM());
+                il.append(new CHECKCAST(cpg.addClass(MULTI_DOM_CLASS)));
+                il.append(new ALOAD(_domAdapter.getIndex()));
+                il.append(new CHECKCAST(cpg.addClass(DOM_ADAPTER_CLASS)));
+                il.append(new INVOKEVIRTUAL(removeDA));
+            }
+            final int release = cpg.addInterfaceMethodref(DOM_IMPL_CLASS, "release", "()V");
+            il.append(new ALOAD(_domAdapter.getIndex()));
+            il.append(new INVOKEINTERFACE(release, 1));
+            _domAdapter = null;
+         }
+     }
 }
diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_zh_TW.java b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_zh_TW.java
index 2b73cd2..7cae67a 100644
--- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_zh_TW.java
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_zh_TW.java
@@ -682,7 +682,7 @@
          * documentation.
          */
         {ErrorMsg.COMPILE_USAGE_STR,
-        "\u6982\u8981\n   java com.sun.org.apache.xalan.internal.xsltc.cmdline.Compile [-o <output>]\n      [-d <directory>] [-j <jarfile>] [-p <package>]\n      [-n] [-x] [-u] [-v] [-h] { <stylesheet> | -i }\n\n\u9078\u9805\n   -o <output>    \u6307\u6D3E\u540D\u7A31 <output> \u81F3\u7522\u751F\u7684\n                  translet\u3002\u6839\u64DA\u9810\u8A2D\uFF0Ctranslet \u540D\u7A31\n                  \u884D\u751F\u81EA <stylesheet> \u540D\u7A31\u3002  \u82E5\u7DE8\u8B6F\n                  \u591A\u500B\u6A23\u5F0F\u8868\uFF0C\u5C07\u5FFD\u7565\u6B64\u9078\u9805\u3002\n   -d <directory> \u6307\u5B9A translet \u7684\u76EE\u7684\u5730\u76EE\u9304\n   -j <jarfile>   \u5C01\u88DD translet \u985E\u5225\u6210\u70BA jar \u6A94\u6848\uFF0C\n                  \u540D\u7A31\u6307\u5B9A\u70BA <jarfile>\n   -p <package>   \u6307\u5B9A\u6240\u6709\u7522\u751F\u7684 translet \u985E\u5225\u7684\u5957\u88DD\u7A0B\u5F0F\n                  \u540D\u7A31\u524D\u7F6E\u78BC\u3002\n   -n             \u555F\u7528\u6A23\u677F\u5167\u5D4C (\u9810\u8A2D\u884C\u70BA\u4E00\u822C\u800C\u8A00\n                  \u8F03\u4F73)\u3002\n   -x             \u958B\u555F\u984D\u5916\u7684\u9664\u932F\u8A0A\u606F\u8F38\u51FA\n   -u             \u89E3\u8B6F <stylesheet> \u5F15\u6578\u70BA URL\n   -i             \u5F37\u5236\u7DE8\u8B6F\u5668\u5F9E stdin \u8B80\u53D6\u6A23\u5F0F\u8868\n   -v             \u5217\u5370\u7DE8\u8B6F\u5668\u7248\u672C\n   -h             \u5217\u5370\u6B64\u7528\u6CD5\u6558\u8FF0\n"},
+        "\u6982\u8981\n   java com.sun.org.apache.xalan.internal.xsltc.cmdline.Compile [-o <output>]\n      [-d <directory>] [-j <jarfile>] [-p <package>]\n      [-n] [-x] [-u] [-v] [-h] { <stylesheet> | -i }\n\n\u9078\u9805\n   -o <output>    \u6307\u6D3E\u540D\u7A31 <output> \u81F3\u7522\u751F\u7684\n                  translet\u3002\u6839\u64DA\u9810\u8A2D\uFF0Ctranslet \u540D\u7A31\n                  \u884D\u751F\u81EA <stylesheet> \u540D\u7A31\u3002\u82E5\u7DE8\u8B6F\n                  \u591A\u500B\u6A23\u5F0F\u8868\uFF0C\u5C07\u5FFD\u7565\u6B64\u9078\u9805\u3002\n   -d <directory> \u6307\u5B9A translet \u7684\u76EE\u7684\u5730\u76EE\u9304\n   -j <jarfile>   \u5C01\u88DD translet \u985E\u5225\u6210\u70BA jar \u6A94\u6848\uFF0C\n                  \u540D\u7A31\u6307\u5B9A\u70BA <jarfile>\n   -p <package>   \u6307\u5B9A\u6240\u6709\u7522\u751F\u7684 translet \u985E\u5225\u7684\u5957\u88DD\u7A0B\u5F0F\n                  \u540D\u7A31\u524D\u7F6E\u78BC\u3002\n   -n             \u555F\u7528\u6A23\u677F\u5167\u5D4C (\u9810\u8A2D\u884C\u70BA\u4E00\u822C\u800C\u8A00\n                  \u8F03\u4F73)\u3002\n   -x             \u958B\u555F\u984D\u5916\u7684\u9664\u932F\u8A0A\u606F\u8F38\u51FA\n   -u             \u89E3\u8B6F <stylesheet> \u5F15\u6578\u70BA URL\n   -i             \u5F37\u5236\u7DE8\u8B6F\u5668\u5F9E stdin \u8B80\u53D6\u6A23\u5F0F\u8868\n   -v             \u5217\u5370\u7DE8\u8B6F\u5668\u7248\u672C\n   -h             \u5217\u5370\u6B64\u7528\u6CD5\u6558\u8FF0\n"},
 
         /*
          * Note to translators:  This message contains usage information for a
diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/dom/AdaptiveResultTreeImpl.java b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/dom/AdaptiveResultTreeImpl.java
index fc1b1d9..cb50cf5 100644
--- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/dom/AdaptiveResultTreeImpl.java
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/dom/AdaptiveResultTreeImpl.java
@@ -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.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,9 +17,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id: AdaptiveResultTreeImpl.java,v 1.2.4.1 2005/09/06 05:52:18 pvedula Exp $
- */
+
 package com.sun.org.apache.xalan.internal.xsltc.dom;
 
 import com.sun.org.apache.xalan.internal.xsltc.DOM;
@@ -1338,4 +1336,11 @@
         }
     }
 
+    public void release() {
+        if (_dom != null) {
+            _dom.release();
+            _dom = null;
+        }
+        super.release();
+    }
 }
diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/dom/DOMAdapter.java b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/dom/DOMAdapter.java
index a12d9e4..4f44ae1 100644
--- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/dom/DOMAdapter.java
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/dom/DOMAdapter.java
@@ -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.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,9 +17,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id: DOMAdapter.java,v 1.2.4.1 2005/09/06 06:07:28 pvedula Exp $
- */
 
 package com.sun.org.apache.xalan.internal.xsltc.dom;
 
@@ -56,8 +53,6 @@
     private short[] _NSmapping = null;
     private short[] _NSreverse = null;
 
-    private StripFilter _filter = null;
-
     private int _multiDOMMask;
 
     public DOMAdapter(DOM dom,
@@ -165,9 +160,7 @@
         }
     }
 
-    public void setFilter(StripFilter filter) {
-        _filter = filter;
-    }
+    public void setFilter(StripFilter filter) {}
 
     public DTMAxisIterator getTypedChildren(final int type) {
         final int[] reverse = getReverse();
@@ -464,4 +457,8 @@
     public Map<String, Integer> getElementsWithIDs() {
         return _dom.getElementsWithIDs();
     }
+
+    public void release() {
+        _dom.release();
+    }
 }
diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/dom/MultiDOM.java b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/dom/MultiDOM.java
index 66dfdc4..92eca91 100644
--- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/dom/MultiDOM.java
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/dom/MultiDOM.java
@@ -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.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -670,4 +670,51 @@
     public Map<String, Integer> getElementsWithIDs() {
         return _main.getElementsWithIDs();
     }
+
+    public void release() {
+        _main.release();
+    }
+
+    private boolean isMatchingAdapterEntry(DOM entry, DOMAdapter adapter) {
+        DOM dom = adapter.getDOMImpl();
+
+        return (entry == adapter) || (
+            /*
+             * Method addDOMAdapter overwrites for AdaptiveResultTreeImpl
+             * objects the usual entry with an adapter to the nested
+             * DOM, so we must check this here. See last 'if' statement
+             * of addDOMAdapter.
+             */
+            (dom instanceof AdaptiveResultTreeImpl) &&
+            (entry instanceof DOMAdapter) &&
+            (((AdaptiveResultTreeImpl)dom).getNestedDOM() == ((DOMAdapter)entry).getDOMImpl())
+        );
+    }
+
+    public void removeDOMAdapter(DOMAdapter adapter) {
+        _documents.remove(adapter.getDocumentURI(0));
+        DOM dom = adapter.getDOMImpl();
+
+        if (dom instanceof DTMDefaultBase) {
+            SuballocatedIntVector ids = ((DTMDefaultBase) dom).getDTMIDs();
+            int idsSize = ids.size();
+            for (int i = 0; i < idsSize; i++) {
+                _adapters[ids.elementAt(i) >>> DTMManager.IDENT_DTM_NODE_BITS] = null;
+            }
+        } else {
+            int id = dom.getDocument() >>> DTMManager.IDENT_DTM_NODE_BITS;
+            if ((id > 0) && (id < _adapters.length) && isMatchingAdapterEntry(_adapters[id], adapter)) {
+                _adapters[id] = null;
+            } else {
+                boolean found = false;
+                for (int i = 0; i < _adapters.length; i++) {
+                    if (isMatchingAdapterEntry(_adapters[id], adapter)) {
+                        _adapters[i] = null;
+                        found = true;
+                        break;
+                    }
+                }
+            }
+        }
+    }
 }
diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/dom/SAXImpl.java b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/dom/SAXImpl.java
index 77c56e5..2919b9b 100644
--- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/dom/SAXImpl.java
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/dom/SAXImpl.java
@@ -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.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,9 +17,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/*
- * $Id: SAXImpl.java,v 1.5 2005/09/28 13:48:37 pvedula Exp $
- */
 
 package com.sun.org.apache.xalan.internal.xsltc.dom;
 
@@ -82,7 +79,7 @@
 
     // Namespace prefix-to-uri mapping stuff
     private int       _uriCount     = 0;
-    private int       _prefixCount  = 0;
+    // private int       _prefixCount  = 0;
 
     // Stack used to keep track of what whitespace text nodes are protected
     // by xml:space="preserve" attributes and which nodes that are not.
@@ -90,11 +87,11 @@
     private int     _idx = 1;
     private boolean _preserve = false;
 
-    private static final String XML_STRING = "xml:";
+    // private static final String XML_STRING = "xml:";
     private static final String XML_PREFIX   = "xml";
     private static final String XMLSPACE_STRING = "xml:space";
     private static final String PRESERVE_STRING = "preserve";
-    private static final String XMLNS_PREFIX = "xmlns";
+    // private static final String XMLNS_PREFIX = "xmlns";
     private static final String XML_URI = "http://www.w3.org/XML/1998/namespace";
 
     private boolean _escaping = true;
@@ -123,7 +120,7 @@
     private BitArray  _dontEscape = null;
 
     // The URI to this document
-    private String    _documentURI = null;
+    // private String _documentURI = null;
     static private int _documentURIIndex = 0;
 
     // The owner Document when the input source is DOMSource.
@@ -143,8 +140,7 @@
     // Support for access/navigation through org.w3c.dom API
     private Node[] _nodes;
     private NodeList[] _nodeLists;
-    private final static String XML_LANG_ATTRIBUTE =
-        "http://www.w3.org/XML/1998/namespace:@lang";
+    // private final static String XML_LANG_ATTRIBUTE = "http://www.w3.org/XML/1998/namespace:@lang";
 
     /**
      * Define the origin of the document from which the tree was built
@@ -491,6 +487,7 @@
     /**
      * Sets up a translet-to-dom type mapping table
      */
+    /*
     private int[] setupMapping(String[] names, String[] uris, int[] types, int nNames) {
         // Padding with number of names, because they
         // may need to be added, i.e for RTFs. See copy03
@@ -502,6 +499,7 @@
         }
         return result;
     }
+    */
 
     /**
      * Returns the internal type associated with an expanded QName
@@ -1230,9 +1228,6 @@
      */
     public DTMAxisIterator getNamespaceAxisIterator(int axis, int ns)
     {
-
-        DTMAxisIterator iterator = null;
-
         if (ns == NO_TYPE) {
             return EMPTYITERATOR;
         }
@@ -1546,7 +1541,6 @@
      */
     public DTMAxisIterator getNthDescendant(int type, int n, boolean includeself)
     {
-        DTMAxisIterator source = (DTMAxisIterator) new TypedDescendantIterator(type);
         return new NthDescendantIterator(n);
     }
 
@@ -1882,4 +1876,7 @@
         }
     }
 
+    public void release() {
+        _dtmManager.release(this, true);
+    }
 }
diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/dom/SimpleResultTreeImpl.java b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/dom/SimpleResultTreeImpl.java
index 9d5d07b..3d71c6d 100644
--- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/dom/SimpleResultTreeImpl.java
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/dom/SimpleResultTreeImpl.java
@@ -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.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -1013,4 +1013,12 @@
     public void migrateTo(DTMManager manager)
     {
     }
+
+    public void release()
+    {
+        if (_documentID != 0) {
+            _dtmManager.release(this, true);
+            _documentID = 0;
+        }
+    }
 }
diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/Util.java b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/Util.java
index 4c6e029..bd3284d 100644
--- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/Util.java
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/Util.java
@@ -29,7 +29,6 @@
 
 import javax.xml.XMLConstants;
 import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 
 import javax.xml.stream.XMLEventReader;
@@ -39,7 +38,6 @@
 import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.sax.SAXSource;
-import javax.xml.transform.stax.StAXResult;
 import javax.xml.transform.stax.StAXSource;
 import javax.xml.transform.stream.StreamSource;
 
@@ -111,8 +109,8 @@
                                 reader.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING,
                                             xsltc.isSecureProcessing());
                            } catch (SAXNotRecognizedException e) {
-                                System.err.println("Warning:  " + reader.getClass().getName() + ": "
-                                        + e.getMessage());
+                                XMLSecurityManager.printWarning(reader.getClass().getName(),
+                                        XMLConstants.FEATURE_SECURE_PROCESSING, e);
                            }
                        } catch (Exception e ) {
                            try {
@@ -149,25 +147,27 @@
                         reader.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD,
                                    xsltc.getProperty(XMLConstants.ACCESS_EXTERNAL_DTD));
                     } catch (SAXNotRecognizedException e) {
-                        System.err.println("Warning:  " + reader.getClass().getName() + ": "
-                                + e.getMessage());
+                        XMLSecurityManager.printWarning(reader.getClass().getName(),
+                                XMLConstants.ACCESS_EXTERNAL_DTD, e);
                     }
 
+                    String lastProperty = "";
                     try {
                         XMLSecurityManager securityManager =
                                 (XMLSecurityManager)xsltc.getProperty(XalanConstants.SECURITY_MANAGER);
                         if (securityManager != null) {
                             for (XMLSecurityManager.Limit limit : XMLSecurityManager.Limit.values()) {
-                                reader.setProperty(limit.apiProperty(),
+                                lastProperty = limit.apiProperty();
+                                reader.setProperty(lastProperty,
                                         securityManager.getLimitValueAsString(limit));
                             }
                             if (securityManager.printEntityCountInfo()) {
+                                lastProperty = XalanConstants.JDK_ENTITY_COUNT_INFO;
                                 reader.setProperty(XalanConstants.JDK_ENTITY_COUNT_INFO, XalanConstants.JDK_YES);
                             }
                         }
                     } catch (SAXException se) {
-                        System.err.println("Warning:  " + reader.getClass().getName() + ": "
-                                    + se.getMessage());
+                        XMLSecurityManager.printWarning(reader.getClass().getName(), lastProperty, se);
                     }
                     xsltc.setXMLReader(reader);
                 }catch (SAXNotRecognizedException snre ) {
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/Constants.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/Constants.java
index 1f67a9f..c5355a0 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/Constants.java
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/Constants.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*
@@ -242,6 +242,14 @@
      */
     public static final String JDK_GENERAL_ENTITY_SIZE_LIMIT =
             ORACLE_JAXP_PROPERTY_PREFIX + "maxGeneralEntitySizeLimit";
+
+    /**
+     * JDK node count limit in entities that limits the total number of nodes
+     * in all of entity references.
+     */
+    public static final String JDK_ENTITY_REPLACEMENT_LIMIT =
+            ORACLE_JAXP_PROPERTY_PREFIX + "entityReplacementLimit";
+
     /**
      * JDK maximum parameter entity size limit
      */
@@ -295,6 +303,13 @@
      * JDK maximum general entity size limit
      */
     public static final String SP_GENERAL_ENTITY_SIZE_LIMIT = "jdk.xml.maxGeneralEntitySizeLimit";
+
+    /**
+     * JDK node count limit in entities that limits the total number of nodes
+     * in all of entity references.
+     */
+    public static final String SP_ENTITY_REPLACEMENT_LIMIT = "jdk.xml.entityReplacementLimit";
+
     /**
      * JDK maximum parameter entity size limit
      */
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11DTDScannerImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11DTDScannerImpl.java
index e3336e3..a4361b2 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11DTDScannerImpl.java
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11DTDScannerImpl.java
@@ -1,62 +1,21 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * The Apache Software License, Version 1.1
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
- * Copyright (c) 1999-2004 The Apache Software Foundation.
- * 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. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xerces" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 APACHE SOFTWARE FOUNDATION OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, International
- * Business Machines, Inc., http://www.apache.org.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
+ * 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 the License for the specific language governing permissions and
+ * limitations under the License.
  */
 
 package com.sun.org.apache.xerces.internal.impl;
@@ -97,19 +56,9 @@
 public class XML11DTDScannerImpl
     extends XMLDTDScannerImpl {
 
-    /** Array of 3 strings. */
-    private String[] fStrings = new String[3];
-
-    /** String. */
-    private XMLString fString = new XMLString();
-
     /** String buffer. */
     private XMLStringBuffer fStringBuffer = new XMLStringBuffer();
 
-    /** String buffer. */
-    private XMLStringBuffer fStringBuffer2 = new XMLStringBuffer();
-    private XMLStringBuffer fStringBuffer3 = new XMLStringBuffer();
-
     //
     // Constructors
     //
@@ -156,7 +105,7 @@
     protected boolean scanPubidLiteral(XMLString literal)
         throws IOException, XNIException
     {
-        int quote = fEntityScanner.scanChar();
+        int quote = fEntityScanner.scanChar(null);
         if (quote != '\'' && quote != '"') {
             reportFatalError("QuoteRequiredInPublicID", null);
             return false;
@@ -167,7 +116,7 @@
         boolean skipSpace = true;
         boolean dataok = true;
         while (true) {
-            int c = fEntityScanner.scanChar();
+            int c = fEntityScanner.scanChar(null);
             // REVISIT:  it could really only be \n or 0x20; all else is normalized, no?  - neilg
             if (c == ' ' || c == '\n' || c == '\r' || c == 0x85 || c == 0x2028) {
                 if (!skipSpace) {
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11DocumentScannerImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11DocumentScannerImpl.java
index 5276454..cea629a 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11DocumentScannerImpl.java
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11DocumentScannerImpl.java
@@ -1,74 +1,32 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * The Apache Software License, Version 1.1
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
- * Copyright (c) 1999-2004 The Apache Software Foundation.
- * 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. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xerces" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 APACHE SOFTWARE FOUNDATION OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 1999, International
- * Business Machines, Inc., http://www.apache.org.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
+ * 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 the License for the specific language governing permissions and
+ * limitations under the License.
  */
 
 package com.sun.org.apache.xerces.internal.impl;
 
-import java.io.IOException;
-
 import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
 import com.sun.org.apache.xerces.internal.util.XML11Char;
 import com.sun.org.apache.xerces.internal.util.XMLChar;
 import com.sun.org.apache.xerces.internal.util.XMLStringBuffer;
 import com.sun.org.apache.xerces.internal.xni.XMLString;
 import com.sun.org.apache.xerces.internal.xni.XNIException;
+import java.io.IOException;
 
 /**
  * This class is responsible for scanning XML document structure
@@ -135,7 +93,7 @@
             // happens when there is the character reference &#13;
             // but scanContent doesn't do entity expansions...
             // is this *really* necessary???  - NG
-            fEntityScanner.scanChar();
+            fEntityScanner.scanChar(null);
             content.append((char)c);
             c = -1;
         }
@@ -144,7 +102,7 @@
         } */
 
         if (c == ']') {
-            content.append((char)fEntityScanner.scanChar());
+            content.append((char)fEntityScanner.scanChar(null));
             // remember where we are in case we get an endEntity before we
             // could flush the buffer out - this happens when we're parsing an
             // entity which ends with a ]
@@ -153,12 +111,12 @@
             // We work on a single character basis to handle cases such as:
             // ']]]>' which we might otherwise miss.
             //
-            if (fEntityScanner.skipChar(']')) {
+            if (fEntityScanner.skipChar(']', null)) {
                 content.append(']');
-                while (fEntityScanner.skipChar(']')) {
+                while (fEntityScanner.skipChar(']', null)) {
                     content.append(']');
                 }
-                if (fEntityScanner.skipChar('>')) {
+                if (fEntityScanner.skipChar('>', null)) {
                     reportFatalError("CDEndInContent", null);
                 }
             }
@@ -185,6 +143,7 @@
      * @param checkEntities true if undeclared entities should be reported as VC violation,
      *                      false if undeclared entities should be reported as WFC violation.
      * @param eleName The name of element to which this attribute belongs.
+     * @param isNSURI The flag indicating whether the content is a namespace URI
      *
      * @return true if the non-normalized and normalized value are the same
      *
@@ -194,7 +153,7 @@
     protected boolean scanAttributeValue(XMLString value,
                                       XMLString nonNormalizedValue,
                                       String atName,
-                                      boolean checkEntities,String eleName)
+                                      boolean checkEntities,String eleName, boolean isNSURI)
         throws IOException, XNIException
     {
         // quote
@@ -203,10 +162,10 @@
             reportFatalError("OpenQuoteExpected", new Object[]{eleName,atName});
         }
 
-        fEntityScanner.scanChar();
+        fEntityScanner.scanChar(NameType.ATTRIBUTE);
         int entityDepth = fEntityDepth;
 
-        int c = fEntityScanner.scanLiteral(quote, value);
+        int c = fEntityScanner.scanLiteral(quote, value, isNSURI);
         if (DEBUG_ATTR_NORMALIZATION) {
             System.out.println("** scanLiteral -> \""
                                + value.toString() + "\"");
@@ -216,7 +175,7 @@
         if (c == quote && (fromIndex = isUnchangedByNormalization(value)) == -1) {
             /** Both the non-normalized and normalized attribute values are equal. **/
             nonNormalizedValue.setValues(value);
-            int cquote = fEntityScanner.scanChar();
+            int cquote = fEntityScanner.scanChar(NameType.ATTRIBUTE);
             if (cquote != quote) {
                 reportFatalError("CloseQuoteExpected", new Object[]{eleName,atName});
             }
@@ -239,11 +198,11 @@
                                        + fStringBuffer.toString() + "\"");
                 }
                 if (c == '&') {
-                    fEntityScanner.skipChar('&');
+                    fEntityScanner.skipChar('&', NameType.REFERENCE);
                     if (entityDepth == fEntityDepth) {
                         fStringBuffer2.append('&');
                     }
-                    if (fEntityScanner.skipChar('#')) {
+                    if (fEntityScanner.skipChar('#', NameType.REFERENCE)) {
                         if (entityDepth == fEntityDepth) {
                             fStringBuffer2.append('#');
                         }
@@ -257,59 +216,22 @@
                         }
                     }
                     else {
-                        String entityName = fEntityScanner.scanName();
+                        String entityName = fEntityScanner.scanName(NameType.REFERENCE);
                         if (entityName == null) {
                             reportFatalError("NameRequiredInReference", null);
                         }
                         else if (entityDepth == fEntityDepth) {
                             fStringBuffer2.append(entityName);
                         }
-                        if (!fEntityScanner.skipChar(';')) {
+                        if (!fEntityScanner.skipChar(';', NameType.REFERENCE)) {
                             reportFatalError("SemicolonRequiredInReference",
                                              new Object []{entityName});
                         }
                         else if (entityDepth == fEntityDepth) {
                             fStringBuffer2.append(';');
                         }
-                        if (entityName == fAmpSymbol) {
-                            fStringBuffer.append('&');
-                            if (DEBUG_ATTR_NORMALIZATION) {
-                                System.out.println("** value5: \""
-                                                   + fStringBuffer.toString()
-                                                   + "\"");
-                            }
-                        }
-                        else if (entityName == fAposSymbol) {
-                            fStringBuffer.append('\'');
-                            if (DEBUG_ATTR_NORMALIZATION) {
-                                System.out.println("** value7: \""
-                                                   + fStringBuffer.toString()
-                                                   + "\"");
-                            }
-                        }
-                        else if (entityName == fLtSymbol) {
-                            fStringBuffer.append('<');
-                            if (DEBUG_ATTR_NORMALIZATION) {
-                                System.out.println("** value9: \""
-                                                   + fStringBuffer.toString()
-                                                   + "\"");
-                            }
-                        }
-                        else if (entityName == fGtSymbol) {
-                            fStringBuffer.append('>');
-                            if (DEBUG_ATTR_NORMALIZATION) {
-                                System.out.println("** valueB: \""
-                                                   + fStringBuffer.toString()
-                                                   + "\"");
-                            }
-                        }
-                        else if (entityName == fQuotSymbol) {
-                            fStringBuffer.append('"');
-                            if (DEBUG_ATTR_NORMALIZATION) {
-                                System.out.println("** valueD: \""
-                                                   + fStringBuffer.toString()
-                                                   + "\"");
-                            }
+                        if (resolveCharacter(entityName, fStringBuffer)) {
+                            checkEntityLimit(false, fEntityScanner.fCurrentEntity.name, 1);
                         }
                         else {
                             if (fEntityManager.isExternalEntity(entityName)) {
@@ -340,13 +262,13 @@
                 else if (c == '<') {
                     reportFatalError("LessthanInAttValue",
                                      new Object[] { eleName, atName });
-                    fEntityScanner.scanChar();
+                    fEntityScanner.scanChar(null);
                     if (entityDepth == fEntityDepth) {
                         fStringBuffer2.append((char)c);
                     }
                 }
                 else if (c == '%' || c == ']') {
-                    fEntityScanner.scanChar();
+                    fEntityScanner.scanChar(null);
                     fStringBuffer.append((char)c);
                     if (entityDepth == fEntityDepth) {
                         fStringBuffer2.append((char)c);
@@ -360,7 +282,7 @@
                 // XML11EntityScanner.  Not sure why
                 // this check was originally necessary.  - NG
                 else if (c == '\n' || c == '\r' || c == 0x85 || c == 0x2028) {
-                    fEntityScanner.scanChar();
+                    fEntityScanner.scanChar(null);
                     fStringBuffer.append(' ');
                     if (entityDepth == fEntityDepth) {
                         fStringBuffer2.append('\n');
@@ -383,12 +305,12 @@
                 else if (c != -1 && isInvalidLiteral(c)) {
                     reportFatalError("InvalidCharInAttValue",
                                      new Object[] {eleName, atName, Integer.toString(c, 16)});
-                    fEntityScanner.scanChar();
+                    fEntityScanner.scanChar(null);
                     if (entityDepth == fEntityDepth) {
                         fStringBuffer2.append((char)c);
                     }
                 }
-                c = fEntityScanner.scanLiteral(quote, value);
+                c = fEntityScanner.scanLiteral(quote, value, isNSURI);
                 if (entityDepth == fEntityDepth) {
                     fStringBuffer2.append(value);
                 }
@@ -405,7 +327,7 @@
         nonNormalizedValue.setValues(fStringBuffer2);
 
         // quote
-        int cquote = fEntityScanner.scanChar();
+        int cquote = fEntityScanner.scanChar(null);
         if (cquote != quote) {
             reportFatalError("CloseQuoteExpected", new Object[]{eleName,atName});
         }
@@ -440,7 +362,7 @@
     protected boolean scanPubidLiteral(XMLString literal)
         throws IOException, XNIException
     {
-        int quote = fEntityScanner.scanChar();
+        int quote = fEntityScanner.scanChar(null);
         if (quote != '\'' && quote != '"') {
             reportFatalError("QuoteRequiredInPublicID", null);
             return false;
@@ -451,7 +373,7 @@
         boolean skipSpace = true;
         boolean dataok = true;
         while (true) {
-            int c = fEntityScanner.scanChar();
+            int c = fEntityScanner.scanChar(null);
             // REVISIT:  none of these except \n and 0x20 should make it past the entity scanner
             if (c == ' ' || c == '\n' || c == '\r' || c == 0x85 || c == 0x2028) {
                 if (!skipSpace) {
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11EntityScanner.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11EntityScanner.java
index 028f6a7..ac26f80 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11EntityScanner.java
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11EntityScanner.java
@@ -1,13 +1,13 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  */
-
 /*
- * Copyright 2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
@@ -20,14 +20,15 @@
 
 package com.sun.org.apache.xerces.internal.impl;
 
+import com.sun.org.apache.xerces.internal.impl.XMLScanner.NameType;
 import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
 import com.sun.org.apache.xerces.internal.util.XML11Char;
 import com.sun.org.apache.xerces.internal.util.XMLChar;
 import com.sun.org.apache.xerces.internal.util.XMLStringBuffer;
-import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
 import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager.Limit;
 import com.sun.org.apache.xerces.internal.xni.QName;
 import com.sun.org.apache.xerces.internal.xni.XMLString;
+import com.sun.xml.internal.stream.Entity;
 import java.io.IOException;
 
 /**
@@ -93,7 +94,7 @@
      * @throws IOException  Thrown if i/o error occurs.
      * @throws EOFException Thrown on end of file.
      */
-    public int scanChar() throws IOException {
+    protected int scanChar(NameType nt) throws IOException {
 
         // load more characters, if needed
         if (fCurrentEntity.position == fCurrentEntity.count) {
@@ -101,6 +102,7 @@
         }
 
         // scan character
+        int offset = fCurrentEntity.position;
         int c = fCurrentEntity.ch[fCurrentEntity.position++];
         boolean external = false;
         if (c == '\n' ||
@@ -111,6 +113,7 @@
                 invokeListeners(1);
                 fCurrentEntity.ch[0] = (char)c;
                 load(1, false, false);
+                offset = 0;
             }
             if (c == '\r' && external) {
                 int cc = fCurrentEntity.ch[fCurrentEntity.position++];
@@ -123,6 +126,9 @@
 
         // return character that was scanned
         fCurrentEntity.columnNumber++;
+        if (!detectingVersion) {
+            checkEntityLimit(nt, fCurrentEntity, offset, fCurrentEntity.position - offset);
+        }
         return c;
 
     } // scanChar():int
@@ -142,7 +148,7 @@
      * @see com.sun.org.apache.xerces.internal.util.SymbolTable
      * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11Name
      */
-    public String scanNmtoken() throws IOException {
+    protected String scanNmtoken() throws IOException {
         // load more characters, if needed
         if (fCurrentEntity.position == fCurrentEntity.count) {
             load(0, true, true);
@@ -249,6 +255,8 @@
      * <strong>Note:</strong> The string returned must be a symbol. The
      * SymbolTable can be used for this purpose.
      *
+     * @param nt The type of the name (element or attribute)
+     *
      * @throws IOException  Thrown if i/o error occurs.
      * @throws EOFException Thrown on end of file.
      *
@@ -256,7 +264,7 @@
      * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11Name
      * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11NameStart
      */
-    public String scanName() throws IOException {
+    protected String scanName(NameType nt) throws IOException {
         // load more characters, if needed
         if (fCurrentEntity.position == fCurrentEntity.count) {
             load(0, true, true);
@@ -311,23 +319,11 @@
             return null;
         }
 
+        int length = 0;
         do {
             ch = fCurrentEntity.ch[fCurrentEntity.position];
             if (XML11Char.isXML11Name(ch)) {
-                if (++fCurrentEntity.position == fCurrentEntity.count) {
-                    int length = fCurrentEntity.position - offset;
-                    invokeListeners(length);
-                    if (length == fCurrentEntity.ch.length) {
-                        // bad luck we have to resize our buffer
-                        char[] tmp = new char[fCurrentEntity.ch.length << 1];
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                         tmp, 0, length);
-                        fCurrentEntity.ch = tmp;
-                    }
-                    else {
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                         fCurrentEntity.ch, 0, length);
-                    }
+                if ((length = checkBeforeLoad(fCurrentEntity, offset, offset)) > 0) {
                     offset = 0;
                     if (load(length, false, false)) {
                         break;
@@ -335,20 +331,7 @@
                 }
             }
             else if (XML11Char.isXML11NameHighSurrogate(ch)) {
-                if (++fCurrentEntity.position == fCurrentEntity.count) {
-                    int length = fCurrentEntity.position - offset;
-                    invokeListeners(length);
-                    if (length == fCurrentEntity.ch.length) {
-                        // bad luck we have to resize our buffer
-                        char[] tmp = new char[fCurrentEntity.ch.length << 1];
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                         tmp, 0, length);
-                        fCurrentEntity.ch = tmp;
-                    }
-                    else {
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                         fCurrentEntity.ch, 0, length);
-                    }
+                if ((length = checkBeforeLoad(fCurrentEntity, offset, offset)) > 0) {
                     offset = 0;
                     if (load(length, false, false)) {
                         --fCurrentEntity.position;
@@ -362,20 +345,7 @@
                     --fCurrentEntity.position;
                     break;
                 }
-                if (++fCurrentEntity.position == fCurrentEntity.count) {
-                    int length = fCurrentEntity.position - offset;
-                    invokeListeners(length);
-                    if (length == fCurrentEntity.ch.length) {
-                        // bad luck we have to resize our buffer
-                        char[] tmp = new char[fCurrentEntity.ch.length << 1];
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                         tmp, 0, length);
-                        fCurrentEntity.ch = tmp;
-                    }
-                    else {
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                         fCurrentEntity.ch, 0, length);
-                    }
+                if ((length = checkBeforeLoad(fCurrentEntity, offset, offset)) > 0) {
                     offset = 0;
                     if (load(length, false, false)) {
                         break;
@@ -388,12 +358,14 @@
         }
         while (true);
 
-        int length = fCurrentEntity.position - offset;
+        length = fCurrentEntity.position - offset;
         fCurrentEntity.columnNumber += length;
 
         // return name
         String symbol = null;
         if (length > 0) {
+            checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, offset, length);
+            checkEntityLimit(nt, fCurrentEntity, offset, length);
             symbol = fSymbolTable.addSymbol(fCurrentEntity.ch, offset, length);
         }
         return symbol;
@@ -416,7 +388,7 @@
      * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11NCName
      * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11NCNameStart
      */
-    public String scanNCName() throws IOException {
+    protected String scanNCName() throws IOException {
 
         // load more characters, if needed
         if (fCurrentEntity.position == fCurrentEntity.count) {
@@ -572,6 +544,7 @@
      * this purpose.
      *
      * @param qname The qualified name structure to fill.
+     * @param nt The type of the name (element or attribute)
      *
      * @return Returns true if a qualified name appeared immediately on
      *         the input and was scanned, false otherwise.
@@ -583,7 +556,7 @@
      * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11Name
      * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11NameStart
      */
-    public boolean scanQName(QName qname) throws IOException {
+    protected boolean scanQName(QName qname, XMLScanner.NameType nt) throws IOException {
 
         // load more characters, if needed
         if (fCurrentEntity.position == fCurrentEntity.count) {
@@ -603,6 +576,7 @@
                     fCurrentEntity.columnNumber++;
                     String name = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 1);
                     qname.setValues(null, name, name, null);
+                    checkEntityLimit(nt, fCurrentEntity, 0, 1);
                     return true;
                 }
             }
@@ -633,6 +607,7 @@
                     fCurrentEntity.columnNumber += 2;
                     String name = fSymbolTable.addSymbol(fCurrentEntity.ch, 0, 2);
                     qname.setValues(null, name, name, null);
+                    checkEntityLimit(nt, fCurrentEntity, 0, 2);
                     return true;
                 }
             }
@@ -642,6 +617,7 @@
         }
 
         int index = -1;
+        int length = 0;
         boolean sawIncompleteSurrogatePair = false;
         do {
             ch = fCurrentEntity.ch[fCurrentEntity.position];
@@ -654,22 +630,7 @@
                     //check prefix before further read
                     checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, offset, index - offset);
                 }
-                if (++fCurrentEntity.position == fCurrentEntity.count) {
-                    int length = fCurrentEntity.position - offset;
-                    //check localpart before loading more data
-                    checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, offset, length - index - 1);
-                    invokeListeners(length);
-                    if (length == fCurrentEntity.ch.length) {
-                        // bad luck we have to resize our buffer
-                        char[] tmp = new char[fCurrentEntity.ch.length << 1];
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                         tmp, 0, length);
-                        fCurrentEntity.ch = tmp;
-                    }
-                    else {
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                         fCurrentEntity.ch, 0, length);
-                    }
+                if ((length = checkBeforeLoad(fCurrentEntity, offset, index)) > 0) {
                     if (index != -1) {
                         index = index - offset;
                     }
@@ -680,20 +641,7 @@
                 }
             }
             else if (XML11Char.isXML11NameHighSurrogate(ch)) {
-                if (++fCurrentEntity.position == fCurrentEntity.count) {
-                    int length = fCurrentEntity.position - offset;
-                    invokeListeners(length);
-                    if (length == fCurrentEntity.ch.length) {
-                        // bad luck we have to resize our buffer
-                        char[] tmp = new char[fCurrentEntity.ch.length << 1];
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                         tmp, 0, length);
-                        fCurrentEntity.ch = tmp;
-                    }
-                    else {
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                         fCurrentEntity.ch, 0, length);
-                    }
+                if ((length = checkBeforeLoad(fCurrentEntity, offset, index)) > 0) {
                     if (index != -1) {
                         index = index - offset;
                     }
@@ -712,20 +660,7 @@
                     --fCurrentEntity.position;
                     break;
                 }
-                if (++fCurrentEntity.position == fCurrentEntity.count) {
-                    int length = fCurrentEntity.position - offset;
-                    invokeListeners(length);
-                    if (length == fCurrentEntity.ch.length) {
-                        // bad luck we have to resize our buffer
-                        char[] tmp = new char[fCurrentEntity.ch.length << 1];
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                         tmp, 0, length);
-                        fCurrentEntity.ch = tmp;
-                    }
-                    else {
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                         fCurrentEntity.ch, 0, length);
-                    }
+                if ((length = checkBeforeLoad(fCurrentEntity, offset, index)) > 0) {
                     if (index != -1) {
                         index = index - offset;
                     }
@@ -741,7 +676,7 @@
         }
         while (true);
 
-        int length = fCurrentEntity.position - offset;
+        length = fCurrentEntity.position - offset;
         fCurrentEntity.columnNumber += length;
 
         if (length > 0) {
@@ -777,6 +712,7 @@
                 checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, offset, length);
             }
             qname.setValues(prefix, localpart, rawname, null);
+            checkEntityLimit(nt, fCurrentEntity, offset, length);
             return true;
         }
         return false;
@@ -809,7 +745,7 @@
      * @throws IOException  Thrown if i/o error occurs.
      * @throws EOFException Thrown on end of file.
      */
-    public int scanContent(XMLString content) throws IOException {
+    protected int scanContent(XMLString content) throws IOException {
 
         // load more characters, if needed
         if (fCurrentEntity.position == fCurrentEntity.count) {
@@ -827,6 +763,7 @@
         int offset = fCurrentEntity.position;
         int c = fCurrentEntity.ch[offset];
         int newlines = 0;
+        boolean counted = false;
         boolean external = fCurrentEntity.isExternal();
         if (c == '\n' || ((c == '\r' || c == 0x85 || c == 0x2028) && external)) {
             do {
@@ -836,11 +773,13 @@
                     fCurrentEntity.lineNumber++;
                     fCurrentEntity.columnNumber = 1;
                     if (fCurrentEntity.position == fCurrentEntity.count) {
+                        checkEntityLimit(null, fCurrentEntity, offset, newlines);
                         offset = 0;
                         fCurrentEntity.baseCharOffset += (fCurrentEntity.position - fCurrentEntity.startPosition);
                         fCurrentEntity.position = newlines;
                         fCurrentEntity.startPosition = newlines;
                         if (load(newlines, false, true)) {
+                            counted = true;
                             break;
                         }
                     }
@@ -859,11 +798,13 @@
                     fCurrentEntity.lineNumber++;
                     fCurrentEntity.columnNumber = 1;
                     if (fCurrentEntity.position == fCurrentEntity.count) {
+                        checkEntityLimit(null, fCurrentEntity, offset, newlines);
                         offset = 0;
                         fCurrentEntity.baseCharOffset += (fCurrentEntity.position - fCurrentEntity.startPosition);
                         fCurrentEntity.position = newlines;
                         fCurrentEntity.startPosition = newlines;
                         if (load(newlines, false, true)) {
+                            counted = true;
                             break;
                         }
                     }
@@ -878,6 +819,7 @@
             }
             int length = fCurrentEntity.position - offset;
             if (fCurrentEntity.position == fCurrentEntity.count - 1) {
+                checkEntityLimit(null, fCurrentEntity, offset, length);
                 content.setValues(fCurrentEntity.ch, offset, length);
                 return -1;
             }
@@ -905,8 +847,8 @@
         }
         int length = fCurrentEntity.position - offset;
         fCurrentEntity.columnNumber += length - newlines;
-        if (fCurrentEntity.isGE) {
-            checkLimit(Limit.TOTAL_ENTITY_SIZE_LIMIT, fCurrentEntity, offset, length);
+        if (!counted) {
+            checkEntityLimit(null, fCurrentEntity, offset, length);
         }
         content.setValues(fCurrentEntity.ch, offset, length);
 
@@ -946,6 +888,7 @@
      * @param quote   The quote character that signifies the end of the
      *                attribute value data.
      * @param content The content structure to fill.
+     * @param isNSURI a flag indicating whether the content is a Namespace URI
      *
      * @return Returns the next character on the input, if known. This
      *         value may be -1 but this does <em>note</em> designate
@@ -954,7 +897,7 @@
      * @throws IOException  Thrown if i/o error occurs.
      * @throws EOFException Thrown on end of file.
      */
-    public int scanLiteral(int quote, XMLString content)
+    protected int scanLiteral(int quote, XMLString content, boolean isNSURI)
         throws IOException {
         // load more characters, if needed
         if (fCurrentEntity.position == fCurrentEntity.count) {
@@ -1052,8 +995,10 @@
         }
         int length = fCurrentEntity.position - offset;
         fCurrentEntity.columnNumber += length - newlines;
-        if (fCurrentEntity.isGE) {
-            checkLimit(Limit.TOTAL_ENTITY_SIZE_LIMIT, fCurrentEntity, offset, length);
+
+        checkEntityLimit(null, fCurrentEntity, offset, length);
+        if (isNSURI) {
+            checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, offset, length);
         }
         content.setValues(fCurrentEntity.ch, offset, length);
 
@@ -1104,7 +1049,7 @@
      * @throws IOException  Thrown if i/o error occurs.
      * @throws EOFException Thrown on end of file.
      */
-    public boolean scanData(String delimiter, XMLStringBuffer buffer)
+    protected boolean scanData(String delimiter, XMLStringBuffer buffer)
         throws IOException {
 
         boolean done = false;
@@ -1136,6 +1081,7 @@
             if (fCurrentEntity.position >= fCurrentEntity.count - delimLen) {
                 // something must be wrong with the input:  e.g., file ends  an unterminated comment
                 int length = fCurrentEntity.count - fCurrentEntity.position;
+                checkEntityLimit(NameType.COMMENT, fCurrentEntity, fCurrentEntity.position, length);
                 buffer.append (fCurrentEntity.ch, fCurrentEntity.position, length);
                 fCurrentEntity.columnNumber += fCurrentEntity.count;
                 fCurrentEntity.baseCharOffset += (fCurrentEntity.position - fCurrentEntity.startPosition);
@@ -1200,6 +1146,7 @@
                 }
                 int length = fCurrentEntity.position - offset;
                 if (fCurrentEntity.position == fCurrentEntity.count - 1) {
+                    checkEntityLimit(NameType.COMMENT, fCurrentEntity, offset, length);
                     buffer.append(fCurrentEntity.ch, offset, length);
                     return true;
                 }
@@ -1238,6 +1185,7 @@
                         fCurrentEntity.position--;
                         int length = fCurrentEntity.position - offset;
                         fCurrentEntity.columnNumber += length - newlines;
+                        checkEntityLimit(NameType.COMMENT, fCurrentEntity, offset, length);
                         buffer.append(fCurrentEntity.ch, offset, length);
                         return true;
                     }
@@ -1275,6 +1223,7 @@
                         fCurrentEntity.position--;
                         int length = fCurrentEntity.position - offset;
                         fCurrentEntity.columnNumber += length - newlines;
+                        checkEntityLimit(NameType.COMMENT, fCurrentEntity, offset, length);
                         buffer.append(fCurrentEntity.ch, offset, length);
                         return true;
                     }
@@ -1282,6 +1231,7 @@
             }
             int length = fCurrentEntity.position - offset;
             fCurrentEntity.columnNumber += length - newlines;
+            checkEntityLimit(NameType.COMMENT, fCurrentEntity, offset, length);
             if (done) {
                 length -= delimLen;
             }
@@ -1306,7 +1256,7 @@
      * @throws IOException  Thrown if i/o error occurs.
      * @throws EOFException Thrown on end of file.
      */
-    public boolean skipChar(int c) throws IOException {
+    protected boolean skipChar(int c, NameType nt) throws IOException {
 
         // load more characters, if needed
         if (fCurrentEntity.position == fCurrentEntity.count) {
@@ -1314,6 +1264,7 @@
         }
 
         // skip character
+        int offset = fCurrentEntity.position;
         int cc = fCurrentEntity.ch[fCurrentEntity.position];
         if (cc == c) {
             fCurrentEntity.position++;
@@ -1324,12 +1275,14 @@
             else {
                 fCurrentEntity.columnNumber++;
             }
+            checkEntityLimit(nt, fCurrentEntity, offset, fCurrentEntity.position - offset);
             return true;
         }
         else if (c == '\n' && ((cc == 0x2028 || cc == 0x85) && fCurrentEntity.isExternal())) {
             fCurrentEntity.position++;
             fCurrentEntity.lineNumber++;
             fCurrentEntity.columnNumber = 1;
+            checkEntityLimit(nt, fCurrentEntity, offset, fCurrentEntity.position - offset);
             return true;
         }
         else if (c == '\n' && (cc == '\r' ) && fCurrentEntity.isExternal()) {
@@ -1345,6 +1298,7 @@
             }
             fCurrentEntity.lineNumber++;
             fCurrentEntity.columnNumber = 1;
+            checkEntityLimit(nt, fCurrentEntity, offset, fCurrentEntity.position - offset);
             return true;
         }
 
@@ -1367,7 +1321,7 @@
      * @see com.sun.org.apache.xerces.internal.util.XMLChar#isSpace
      * @see com.sun.org.apache.xerces.internal.util.XML11Char#isXML11Space
      */
-    public boolean skipSpaces() throws IOException {
+    protected boolean skipSpaces() throws IOException {
 
         // load more characters, if needed
         if (fCurrentEntity.position == fCurrentEntity.count) {
@@ -1387,7 +1341,7 @@
 
         // skip spaces
         int c = fCurrentEntity.ch[fCurrentEntity.position];
-
+        int offset = fCurrentEntity.position - 1;
         // External --  Match: S + 0x85 + 0x2028, and perform end of line normalization
         if (fCurrentEntity.isExternal()) {
             if (XML11Char.isXML11Space(c)) {
@@ -1423,6 +1377,11 @@
                     else {
                         fCurrentEntity.columnNumber++;
                     }
+
+                    //If this is a general entity, spaces within a start element should be counted
+                    checkEntityLimit(null, fCurrentEntity, offset, fCurrentEntity.position - offset);
+                    offset = fCurrentEntity.position;
+
                     // load more characters, if needed
                     if (!entityChanged)
                         fCurrentEntity.position++;
@@ -1462,6 +1421,11 @@
                 else {
                     fCurrentEntity.columnNumber++;
                 }
+
+                //If this is a general entity, spaces within a start element should be counted
+                checkEntityLimit(null, fCurrentEntity, offset, fCurrentEntity.position - offset);
+                offset = fCurrentEntity.position;
+
                 // load more characters, if needed
                 if (!entityChanged)
                     fCurrentEntity.position++;
@@ -1495,7 +1459,7 @@
      * @throws IOException  Thrown if i/o error occurs.
      * @throws EOFException Thrown on end of file.
      */
-    public boolean skipString(String s) throws IOException {
+    protected boolean skipString(String s) throws IOException {
 
         // load more characters, if needed
         if (fCurrentEntity.position == fCurrentEntity.count) {
@@ -1504,6 +1468,7 @@
 
         // skip string
         final int length = s.length();
+        final int beforeSkip = fCurrentEntity.position ;
         for (int i = 0; i < length; i++) {
             char c = fCurrentEntity.ch[fCurrentEntity.position++];
             if (c != s.charAt(i)) {
@@ -1523,6 +1488,9 @@
             }
         }
         fCurrentEntity.columnNumber += length;
+        if (!detectingVersion) {
+            checkEntityLimit(null, fCurrentEntity, beforeSkip, length);
+        }
         return true;
 
     } // skipString(String):boolean
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11NSDocumentScannerImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11NSDocumentScannerImpl.java
index a3dd4d1..ae7d7b8 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11NSDocumentScannerImpl.java
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11NSDocumentScannerImpl.java
@@ -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.
  */
 
 /*
@@ -136,7 +136,7 @@
         if (DEBUG_START_END_ELEMENT)
             System.out.println(">>> scanStartElementNS()");
                 // Note: namespace processing is on by default
-        fEntityScanner.scanQName(fElementQName);
+        fEntityScanner.scanQName(fElementQName, NameType.ATTRIBUTE);
         // REVISIT - [Q] Why do we need this local variable? -- mrglavas
         String rawname = fElementQName.rawname;
         if (fBindNamespaces) {
@@ -174,11 +174,11 @@
             // end tag?
             int c = fEntityScanner.peekChar();
             if (c == '>') {
-                fEntityScanner.scanChar();
+                fEntityScanner.scanChar(null);
                 break;
             } else if (c == '/') {
-                fEntityScanner.scanChar();
-                if (!fEntityScanner.skipChar('>')) {
+                fEntityScanner.scanChar(null);
+                if (!fEntityScanner.skipChar('>', null)) {
                     reportFatalError(
                         "ElementUnterminated",
                         new Object[] { rawname });
@@ -346,7 +346,7 @@
     protected void scanStartElementName ()
         throws IOException, XNIException {
         // Note: namespace processing is on by default
-        fEntityScanner.scanQName(fElementQName);
+        fEntityScanner.scanQName(fElementQName, NameType.ATTRIBUTE);
         // Must skip spaces here because the DTD scanner
         // would consume them at the end of the external subset.
         fSawSpace = fEntityScanner.skipSpaces();
@@ -396,11 +396,11 @@
             // end tag?
             int c = fEntityScanner.peekChar();
             if (c == '>') {
-                fEntityScanner.scanChar();
+                fEntityScanner.scanChar(null);
                 break;
             } else if (c == '/') {
-                fEntityScanner.scanChar();
-                if (!fEntityScanner.skipChar('>')) {
+                fEntityScanner.scanChar(null);
+                if (!fEntityScanner.skipChar('>', null)) {
                     reportFatalError(
                         "ElementUnterminated",
                         new Object[] { rawname });
@@ -572,11 +572,11 @@
             System.out.println(">>> scanAttribute()");
 
         // name
-        fEntityScanner.scanQName(fAttributeQName);
+        fEntityScanner.scanQName(fAttributeQName, NameType.ATTRIBUTE);
 
         // equals
         fEntityScanner.skipSpaces();
-        if (!fEntityScanner.skipChar('=')) {
+        if (!fEntityScanner.skipChar('=', NameType.ATTRIBUTE)) {
             reportFatalError(
                 "EqRequiredInAttribute",
                 new Object[] {
@@ -615,13 +615,20 @@
         //REVISIT: one more case needs to be included: external PE and standalone is no
         boolean isVC = fHasExternalDTD && !fStandalone;
 
-        // REVISIT: it seems that this function should not take attributes, and length
-        scanAttributeValue(
-            this.fTempString,
-            fTempString2,
-            fAttributeQName.rawname,
-            isVC,
-            fCurrentElement.rawname);
+        /**
+         * Determine whether this is a namespace declaration that will be subject
+         * to the name limit check in the scanAttributeValue operation.
+         * Namespace declaration format: xmlns="..." or xmlns:prefix="..."
+         * Note that prefix:xmlns="..." isn't a namespace.
+         */
+        String localpart = fAttributeQName.localpart;
+        String prefix = fAttributeQName.prefix != null
+                ? fAttributeQName.prefix : XMLSymbols.EMPTY_STRING;
+        boolean isNSDecl = fBindNamespaces & (prefix == XMLSymbols.PREFIX_XMLNS ||
+                    prefix == XMLSymbols.EMPTY_STRING && localpart == XMLSymbols.PREFIX_XMLNS);
+
+        scanAttributeValue(this.fTempString, fTempString2, fAttributeQName.rawname,
+            isVC, fCurrentElement.rawname, isNSDecl);
         String value = fTempString.toString();
         attributes.setValue(attrIndex, value);
         attributes.setNonNormalizedValue(attrIndex, fTempString2.toString());
@@ -629,17 +636,7 @@
 
         // record namespace declarations if any.
         if (fBindNamespaces) {
-
-            String localpart = fAttributeQName.localpart;
-            String prefix =
-                fAttributeQName.prefix != null
-                    ? fAttributeQName.prefix
-                    : XMLSymbols.EMPTY_STRING;
-            // when it's of form xmlns="..." or xmlns:prefix="...",
-            // it's a namespace declaration. but prefix:xmlns="..." isn't.
-            if (prefix == XMLSymbols.PREFIX_XMLNS
-                || prefix == XMLSymbols.EMPTY_STRING
-                && localpart == XMLSymbols.PREFIX_XMLNS) {
+            if (isNSDecl) {
                 if (value.length() > fXMLNameLimit) {
                     fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                             "MaxXMLNameLimit",
@@ -759,7 +756,7 @@
 
         // end
         fEntityScanner.skipSpaces();
-        if (!fEntityScanner.skipChar('>')) {
+        if (!fEntityScanner.skipChar('>', NameType.ELEMENTEND)) {
             reportFatalError(
                 "ETagUnterminated",
                 new Object[] { endElementName.rawname });
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java
index a54234b..135eb5e 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*
@@ -41,12 +41,8 @@
 import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDScanner;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
 import com.sun.org.apache.xerces.internal.xni.Augmentations;
-import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
-import com.sun.org.apache.xerces.internal.impl.XMLEntityHandler;
-import com.sun.org.apache.xerces.internal.impl.Constants;
 import com.sun.org.apache.xerces.internal.utils.XMLLimitAnalyzer;
 import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
-import com.sun.xml.internal.stream.Entity;
 
 /**
  * This class is responsible for scanning the declarations found
@@ -370,6 +366,7 @@
                 // we're done, set starting state for external subset
                 setScannerState(SCANNER_STATE_TEXT_DECL);
                 // we're done scanning DTD.
+                fLimitAnalyzer.reset(XMLSecurityManager.Limit.GENERAL_ENTITY_SIZE_LIMIT);
                 fLimitAnalyzer.reset(XMLSecurityManager.Limit.TOTAL_ENTITY_SIZE_LIMIT);
                 return false;
             }
@@ -760,7 +757,7 @@
                 fStringBuffer.clear();
                 fStringBuffer.append("xml");
                 while (isValidNameChar(fEntityScanner.peekChar())) {
-                    fStringBuffer.append((char)fEntityScanner.scanChar());
+                    fStringBuffer.append((char)fEntityScanner.scanChar(null));
                 }
                 String target =
                 fSymbolTable.addSymbol(fStringBuffer.ch,
@@ -860,7 +857,7 @@
         }
 
         // element name
-        String name = fEntityScanner.scanName();
+        String name = fEntityScanner.scanName(NameType.ELEMENTSTART);
         if (name == null) {
             reportFatalError("MSG_ELEMENT_TYPE_REQUIRED_IN_ELEMENTDECL",
             null);
@@ -893,7 +890,7 @@
             }
         }
         else {
-            if (!fEntityScanner.skipChar('(')) {
+            if (!fEntityScanner.skipChar('(', null)) {
                 reportFatalError("MSG_OPEN_PAREN_OR_ELEMENT_TYPE_REQUIRED_IN_CHILDREN",
                 new Object[]{name});
             }
@@ -923,7 +920,7 @@
         fReportEntity = false;
         skipSeparator(false, !scanningInternalSubset());
         // end
-        if (!fEntityScanner.skipChar('>')) {
+        if (!fEntityScanner.skipChar('>', null)) {
             reportFatalError("ElementDeclUnterminated", new Object[]{name});
         }
         fReportEntity = true;
@@ -960,7 +957,7 @@
             fDTDContentModelHandler.pcdata(null);
         }
         skipSeparator(false, !scanningInternalSubset());
-        while (fEntityScanner.skipChar('|')) {
+        while (fEntityScanner.skipChar('|', null)) {
             fStringBuffer.append('|');
             // call handler
             if (fDTDContentModelHandler != null) {
@@ -969,7 +966,7 @@
             }
             skipSeparator(false, !scanningInternalSubset());
 
-            childName = fEntityScanner.scanName();
+            childName = fEntityScanner.scanName(NameType.ENTITY);
             if (childName == null) {
                 reportFatalError("MSG_ELEMENT_TYPE_REQUIRED_IN_MIXED_CONTENT",
                 new Object[]{elName});
@@ -998,7 +995,7 @@
             reportFatalError("MixedContentUnterminated",
             new Object[]{elName});
         }
-        else if (fEntityScanner.skipChar(')')){
+        else if (fEntityScanner.skipChar(')', null)){
             fStringBuffer.append(')');
             // call handler
             if (fDTDContentModelHandler != null) {
@@ -1036,7 +1033,7 @@
         int currentOp = 0;
         int c;
         while (true) {
-            if (fEntityScanner.skipChar('(')) {
+            if (fEntityScanner.skipChar('(', null)) {
                 fMarkUpDepth++;
                 fStringBuffer.append('(');
                 // call handler
@@ -1050,7 +1047,7 @@
                 continue;
             }
             skipSeparator(false, !scanningInternalSubset());
-            String childName = fEntityScanner.scanName();
+            String childName = fEntityScanner.scanName(NameType.ELEMENTSTART);
             if (childName == null) {
                 reportFatalError("MSG_OPEN_PAREN_OR_ELEMENT_TYPE_REQUIRED_IN_CHILDREN",
                 new Object[]{elName});
@@ -1077,7 +1074,7 @@
                     }
                     fDTDContentModelHandler.occurrence(oc, null);
                 }
-                fEntityScanner.scanChar();
+                fEntityScanner.scanChar(null);
                 fStringBuffer.append((char)c);
             }
             while (true) {
@@ -1090,7 +1087,7 @@
                         fDTDContentModelHandler.separator(XMLDTDContentModelHandler.SEPARATOR_SEQUENCE,
                         null);
                     }
-                    fEntityScanner.scanChar();
+                    fEntityScanner.scanChar(null);
                     fStringBuffer.append(',');
                     break;
                 }
@@ -1101,7 +1098,7 @@
                         fDTDContentModelHandler.separator(XMLDTDContentModelHandler.SEPARATOR_CHOICE,
                         null);
                     }
-                    fEntityScanner.scanChar();
+                    fEntityScanner.scanChar(null);
                     fStringBuffer.append('|');
                     break;
                 }
@@ -1147,7 +1144,7 @@
                 }
                 else {
                     // no occurrence specified
-                    fEntityScanner.scanChar();
+                    fEntityScanner.scanChar(null);
                     fStringBuffer.append(')');
                 }
                 fMarkUpDepth--;
@@ -1179,7 +1176,7 @@
         }
 
         // element name
-        String elName = fEntityScanner.scanName();
+        String elName = fEntityScanner.scanName(NameType.ELEMENTSTART);
         if (elName == null) {
             reportFatalError("MSG_ELEMENT_TYPE_REQUIRED_IN_ATTLISTDECL",
             null);
@@ -1193,7 +1190,7 @@
         // spaces
         if (!skipSeparator(true, !scanningInternalSubset())) {
             // no space, is it the end yet?
-            if (fEntityScanner.skipChar('>')) {
+            if (fEntityScanner.skipChar('>', null)) {
                 // yes, stop here
                 // call handler
                 if (fDTDHandler != null) {
@@ -1209,8 +1206,8 @@
         }
 
         // definitions
-        while (!fEntityScanner.skipChar('>')) {
-            String name = fEntityScanner.scanName();
+        while (!fEntityScanner.skipChar('>', null)) {
+            String name = fEntityScanner.scanName(NameType.ATTRIBUTE);
             if (name == null) {
                 reportFatalError("AttNameRequiredInAttDef",
                 new Object[]{elName});
@@ -1346,7 +1343,7 @@
                 new Object[]{elName, atName});
             }
             // open paren
-            int c = fEntityScanner.scanChar();
+            int c = fEntityScanner.scanChar(null);
             if (c != '(') {
                 reportFatalError("MSG_OPEN_PAREN_REQUIRED_IN_NOTATIONTYPE",
                 new Object[]{elName, atName});
@@ -1354,7 +1351,7 @@
             fMarkUpDepth++;
             do {
                 skipSeparator(false, !scanningInternalSubset());
-                String aName = fEntityScanner.scanName();
+                String aName = fEntityScanner.scanName(NameType.ATTRIBUTE);
                 if (aName == null) {
                     reportFatalError("MSG_NAME_REQUIRED_IN_NOTATIONTYPE",
                     new Object[]{elName, atName});
@@ -1362,7 +1359,7 @@
                 ensureEnumerationSize(fEnumerationCount + 1);
                 fEnumeration[fEnumerationCount++] = aName;
                 skipSeparator(false, !scanningInternalSubset());
-                c = fEntityScanner.scanChar();
+                c = fEntityScanner.scanChar(null);
             } while (c == '|');
             if (c != ')') {
                 reportFatalError("NotationTypeUnterminated",
@@ -1373,7 +1370,7 @@
         else {              // Enumeration
             type = "ENUMERATION";
             // open paren
-            int c = fEntityScanner.scanChar();
+            int c = fEntityScanner.scanChar(null);
             if (c != '(') {
                 //                       "OPEN_PAREN_REQUIRED_BEFORE_ENUMERATION_IN_ATTRDECL",
                 reportFatalError("AttTypeRequiredInAttDef",
@@ -1390,7 +1387,7 @@
                 ensureEnumerationSize(fEnumerationCount + 1);
                 fEnumeration[fEnumerationCount++] = token;
                 skipSeparator(false, !scanningInternalSubset());
-                c = fEntityScanner.scanChar();
+                c = fEntityScanner.scanChar(null);
             } while (c == '|');
             if (c != ')') {
                 reportFatalError("EnumerationUnterminated",
@@ -1440,7 +1437,7 @@
             // AttValue
             boolean isVC = !fStandalone  &&  (fSeenExternalDTD || fSeenExternalPE) ;
             scanAttributeValue(defaultVal, nonNormalizedDefaultVal, atName,
-            fAttributes, 0, isVC, elName);
+            fAttributes, 0, isVC, elName, false);
         }
         return defaultType;
 
@@ -1468,7 +1465,7 @@
         boolean sawPERef = false;
         fReportEntity = false;
         if (fEntityScanner.skipSpaces()) {
-            if (!fEntityScanner.skipChar('%')) {
+            if (!fEntityScanner.skipChar('%', NameType.REFERENCE)) {
                 isPEDecl = false; // <!ENTITY x "x">
             }
             else if (skipSeparator(true, !scanningInternalSubset())) {
@@ -1489,7 +1486,7 @@
                 sawPERef = true;
             }
         }
-        else if (scanningInternalSubset() || !fEntityScanner.skipChar('%')) {
+        else if (scanningInternalSubset() || !fEntityScanner.skipChar('%', NameType.REFERENCE)) {
             // <!ENTITY[^ ]...> or <!ENTITY[^ %]...>
             reportFatalError("MSG_SPACE_REQUIRED_BEFORE_ENTITY_NAME_IN_ENTITYDECL",
             null);
@@ -1506,11 +1503,11 @@
         }
         if (sawPERef) {
             while (true) {
-                String peName = fEntityScanner.scanName();
+                String peName = fEntityScanner.scanName(NameType.REFERENCE);
                 if (peName == null) {
                     reportFatalError("NameRequiredInPEReference", null);
                 }
-                else if (!fEntityScanner.skipChar(';')) {
+                else if (!fEntityScanner.skipChar(';', NameType.REFERENCE)) {
                     reportFatalError("SemicolonRequiredInPEReference",
                     new Object[]{peName});
                 }
@@ -1518,20 +1515,20 @@
                     startPE(peName, false);
                 }
                 fEntityScanner.skipSpaces();
-                if (!fEntityScanner.skipChar('%'))
+                if (!fEntityScanner.skipChar('%', NameType.REFERENCE))
                     break;
                 if (!isPEDecl) {
                     if (skipSeparator(true, !scanningInternalSubset())) {
                         isPEDecl = true;
                         break;
                     }
-                    isPEDecl = fEntityScanner.skipChar('%');
+                    isPEDecl = fEntityScanner.skipChar('%', NameType.REFERENCE);
                 }
             }
         }
 
         // name
-        String name = fEntityScanner.scanName();
+        String name = fEntityScanner.scanName(NameType.ENTITY);
         if (name == null) {
             reportFatalError("MSG_ENTITY_NAME_REQUIRED_IN_ENTITYDECL", null);
         }
@@ -1566,7 +1563,7 @@
                 reportFatalError("MSG_SPACE_REQUIRED_BEFORE_NOTATION_NAME_IN_UNPARSED_ENTITYDECL",
                 new Object[]{name});
             }
-            notation = fEntityScanner.scanName();
+            notation = fEntityScanner.scanName(NameType.NOTATION);
             if (notation == null) {
                 reportFatalError("MSG_NOTATION_NAME_REQUIRED_FOR_UNPARSED_ENTITYDECL",
                 new Object[]{name});
@@ -1588,7 +1585,7 @@
         skipSeparator(false, !scanningInternalSubset());
 
         // end
-        if (!fEntityScanner.skipChar('>')) {
+        if (!fEntityScanner.skipChar('>', null)) {
             reportFatalError("EntityDeclUnterminated", new Object[]{name});
         }
         fMarkUpDepth--;
@@ -1643,7 +1640,7 @@
     protected final void scanEntityValue(String entityName, boolean isPEDecl, XMLString value,
     XMLString nonNormalizedValue)
     throws IOException, XNIException {
-        int quote = fEntityScanner.scanChar();
+        int quote = fEntityScanner.scanChar(null);
         if (quote != '\'' && quote != '"') {
             reportFatalError("OpenQuoteMissingInDecl", null);
         }
@@ -1658,23 +1655,24 @@
          }
         fLimitAnalyzer.startEntity(entityName);
 
-        if (fEntityScanner.scanLiteral(quote, fString) != quote) {
+        if (fEntityScanner.scanLiteral(quote, fString, false) != quote) {
             fStringBuffer.clear();
             fStringBuffer2.clear();
+            int offset;
             do {
-                checkEntityLimit(isPEDecl, entityName, fString.length + countChar);
                 countChar = 0;
+                offset = fStringBuffer.length;
                 fStringBuffer.append(fString);
                 fStringBuffer2.append(fString);
-                if (fEntityScanner.skipChar('&')) {
-                    if (fEntityScanner.skipChar('#')) {
+                if (fEntityScanner.skipChar('&', NameType.REFERENCE)) {
+                    if (fEntityScanner.skipChar('#', NameType.REFERENCE)) {
                         fStringBuffer2.append("&#");
                         scanCharReferenceValue(fStringBuffer, fStringBuffer2);
                     }
                     else {
                         fStringBuffer.append('&');
                         fStringBuffer2.append('&');
-                        String eName = fEntityScanner.scanName();
+                        String eName = fEntityScanner.scanName(NameType.REFERENCE);
                         if (eName == null) {
                             reportFatalError("NameRequiredInReference",
                             null);
@@ -1683,7 +1681,7 @@
                             fStringBuffer.append(eName);
                             fStringBuffer2.append(eName);
                         }
-                        if (!fEntityScanner.skipChar(';')) {
+                        if (!fEntityScanner.skipChar(';', NameType.REFERENCE)) {
                             reportFatalError("SemicolonRequiredInReference",
                             new Object[]{eName});
                         }
@@ -1693,15 +1691,15 @@
                         }
                     }
                 }
-                else if (fEntityScanner.skipChar('%')) {
+                else if (fEntityScanner.skipChar('%', NameType.REFERENCE)) {
                     while (true) {
                         fStringBuffer2.append('%');
-                        String peName = fEntityScanner.scanName();
+                        String peName = fEntityScanner.scanName(NameType.REFERENCE);
                         if (peName == null) {
                             reportFatalError("NameRequiredInPEReference",
                             null);
                         }
-                        else if (!fEntityScanner.skipChar(';')) {
+                        else if (!fEntityScanner.skipChar(';', NameType.REFERENCE)) {
                             reportFatalError("SemicolonRequiredInPEReference",
                             new Object[]{peName});
                         }
@@ -1718,20 +1716,20 @@
                         // REVISIT: This will make returning the non-
                         //          normalized value harder. -Ac
                         fEntityScanner.skipSpaces();
-                        if (!fEntityScanner.skipChar('%'))
+                        if (!fEntityScanner.skipChar('%', NameType.REFERENCE))
                             break;
                     }
                 }
                 else {
-                    countChar++;
                     int c = fEntityScanner.peekChar();
                     if (XMLChar.isHighSurrogate(c)) {
+                        countChar++;
                         scanSurrogates(fStringBuffer2);
                     }
                     else if (isInvalidLiteral(c)) {
                         reportFatalError("InvalidCharInLiteral",
                         new Object[]{Integer.toHexString(c)});
-                        fEntityScanner.scanChar();
+                        fEntityScanner.scanChar(null);
                     }
                     // if it's not the delimiting quote or if it is but from a
                     // different entity than the one this literal started from,
@@ -1739,10 +1737,12 @@
                     else if (c != quote || entityDepth != fEntityDepth) {
                         fStringBuffer.append((char)c);
                         fStringBuffer2.append((char)c);
-                        fEntityScanner.scanChar();
+                        fEntityScanner.scanChar(null);
                     }
                 }
-            } while (fEntityScanner.scanLiteral(quote, fString) != quote);
+                checkEntityLimit(isPEDecl, entityName, fStringBuffer.length - offset + countChar);
+            } while (fEntityScanner.scanLiteral(quote, fString, false) != quote);
+            checkEntityLimit(isPEDecl, entityName, fString.length);
             fStringBuffer.append(fString);
             fStringBuffer2.append(fString);
             literal = fStringBuffer;
@@ -1753,10 +1753,14 @@
         value.setValues(literal);
         nonNormalizedValue.setValues(literal2);
         if (fLimitAnalyzer != null) {
-            fLimitAnalyzer.endEntity(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT, entityName);
+            if (isPEDecl) {
+                fLimitAnalyzer.endEntity(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT, entityName);
+            } else {
+                fLimitAnalyzer.endEntity(XMLSecurityManager.Limit.GENERAL_ENTITY_SIZE_LIMIT, entityName);
+            }
         }
 
-        if (!fEntityScanner.skipChar(quote)) {
+        if (!fEntityScanner.skipChar(quote, null)) {
             reportFatalError("CloseQuoteMissingInDecl", null);
         }
     } // scanEntityValue(XMLString,XMLString):void
@@ -1781,7 +1785,7 @@
         }
 
         // notation name
-        String name = fEntityScanner.scanName();
+        String name = fEntityScanner.scanName(NameType.NOTATION);
         if (name == null) {
             reportFatalError("MSG_NOTATION_NAME_REQUIRED_IN_NOTATIONDECL",
             null);
@@ -1808,7 +1812,7 @@
         skipSeparator(false, !scanningInternalSubset());
 
         // end
-        if (!fEntityScanner.skipChar('>')) {
+        if (!fEntityScanner.skipChar('>', null)) {
             reportFatalError("NotationDeclUnterminated", new Object[]{name});
         }
         fMarkUpDepth--;
@@ -1856,7 +1860,7 @@
                 XMLErrorReporter.SEVERITY_ERROR);
             }
             // call handler
-            if (!fEntityScanner.skipChar('[')) {
+            if (!fEntityScanner.skipChar('[', null)) {
                 reportFatalError("MSG_MARKUP_NOT_RECOGNIZED_IN_DTD", null);
             }
 
@@ -1881,7 +1885,7 @@
                 fDTDHandler.startConditional(XMLDTDHandler.CONDITIONAL_IGNORE,
                 null);
             }
-            if (!fEntityScanner.skipChar('[')) {
+            if (!fEntityScanner.skipChar('[', null)) {
                 reportFatalError("MSG_MARKUP_NOT_RECOGNIZED_IN_DTD", null);
             }
             fReportEntity = true;
@@ -1890,7 +1894,7 @@
                 fIgnoreConditionalBuffer.clear();
             }
             while (true) {
-                if (fEntityScanner.skipChar('<')) {
+                if (fEntityScanner.skipChar('<', null)) {
                     if (fDTDHandler != null) {
                         fIgnoreConditionalBuffer.append('<');
                     }
@@ -1898,8 +1902,8 @@
                     // These tests are split so that we handle cases like
                     // '<<![' and '<!<![' which we might otherwise miss.
                     //
-                    if (fEntityScanner.skipChar('!')) {
-                        if(fEntityScanner.skipChar('[')) {
+                    if (fEntityScanner.skipChar('!', null)) {
+                        if(fEntityScanner.skipChar('[', null)) {
                             if (fDTDHandler != null) {
                                 fIgnoreConditionalBuffer.append("![");
                             }
@@ -1911,24 +1915,24 @@
                         }
                     }
                 }
-                else if (fEntityScanner.skipChar(']')) {
+                else if (fEntityScanner.skipChar(']', null)) {
                     if (fDTDHandler != null) {
                         fIgnoreConditionalBuffer.append(']');
                     }
                     //
                     // The same thing goes for ']<![' and '<]]>', etc.
                     //
-                    if (fEntityScanner.skipChar(']')) {
+                    if (fEntityScanner.skipChar(']', null)) {
                         if (fDTDHandler != null) {
                             fIgnoreConditionalBuffer.append(']');
                         }
-                        while (fEntityScanner.skipChar(']')) {
+                        while (fEntityScanner.skipChar(']', null)) {
                             /* empty loop body */
                             if (fDTDHandler != null) {
                                 fIgnoreConditionalBuffer.append(']');
                             }
                         }
-                        if (fEntityScanner.skipChar('>')) {
+                        if (fEntityScanner.skipChar('>', null)) {
                             if (fIncludeSectDepth-- == initialDepth) {
                                 fMarkUpDepth--;
                                 // call handler
@@ -1946,7 +1950,7 @@
                     }
                 }
                 else {
-                    int c = fEntityScanner.scanChar();
+                    int c = fEntityScanner.scanChar(null);
                     if (fScannerState == SCANNER_STATE_END_OF_INPUT) {
                         reportFatalError("IgnoreSectUnterminated", null);
                         return;
@@ -1983,16 +1987,16 @@
         //System.out.println("scanDecls"+fScannerState);
         while (again && fScannerState == SCANNER_STATE_MARKUP_DECL) {
             again = complete;
-            if (fEntityScanner.skipChar('<')) {
+            if (fEntityScanner.skipChar('<', null)) {
                 fMarkUpDepth++;
-                if (fEntityScanner.skipChar('?')) {
+                if (fEntityScanner.skipChar('?', null)) {
                     fStringBuffer.clear();
                     scanPI(fStringBuffer);
                     fMarkUpDepth--; // we're done with this decl
                 }
-                else if (fEntityScanner.skipChar('!')) {
-                    if (fEntityScanner.skipChar('-')) {
-                        if (!fEntityScanner.skipChar('-')) {
+                else if (fEntityScanner.skipChar('!', null)) {
+                    if (fEntityScanner.skipChar('-', null)) {
+                        if (!fEntityScanner.skipChar('-', null)) {
                             reportFatalError("MSG_MARKUP_NOT_RECOGNIZED_IN_DTD",
                             null);
                         } else {
@@ -2011,7 +2015,7 @@
                     else if (fEntityScanner.skipString("NOTATION")) {
                         scanNotationDecl();
                     }
-                    else if (fEntityScanner.skipChar('[') &&
+                    else if (fEntityScanner.skipChar('[', null) &&
                     !scanningInternalSubset()) {
                         scanConditionalSect(fPEDepth);
                     }
@@ -2026,10 +2030,10 @@
                     reportFatalError("MSG_MARKUP_NOT_RECOGNIZED_IN_DTD", null);
                 }
             }
-            else if (fIncludeSectDepth > 0 && fEntityScanner.skipChar(']')) {
+            else if (fIncludeSectDepth > 0 && fEntityScanner.skipChar(']', null)) {
                 // end of conditional section?
-                if (!fEntityScanner.skipChar(']')
-                || !fEntityScanner.skipChar('>')) {
+                if (!fEntityScanner.skipChar(']', null)
+                || !fEntityScanner.skipChar('>', null)) {
                     reportFatalError("IncludeSectUnterminated", null);
                 }
                 // call handler
@@ -2076,21 +2080,21 @@
     throws IOException, XNIException {
         int depth = fPEDepth;
         boolean sawSpace = fEntityScanner.skipSpaces();
-        if (!lookForPERefs || !fEntityScanner.skipChar('%')) {
+        if (!lookForPERefs || !fEntityScanner.skipChar('%', NameType.REFERENCE)) {
             return !spaceRequired || sawSpace || (depth != fPEDepth);
         }
         while (true) {
-            String name = fEntityScanner.scanName();
+            String name = fEntityScanner.scanName(NameType.ENTITY);
             if (name == null) {
                 reportFatalError("NameRequiredInPEReference", null);
             }
-            else if (!fEntityScanner.skipChar(';')) {
+            else if (!fEntityScanner.skipChar(';', NameType.REFERENCE)) {
                 reportFatalError("SemicolonRequiredInPEReference",
                 new Object[]{name});
             }
             startPE(name, false);
             fEntityScanner.skipSpaces();
-            if (!fEntityScanner.skipChar('%'))
+            if (!fEntityScanner.skipChar('%', NameType.REFERENCE))
                 return true;
         }
     }
@@ -2174,56 +2178,6 @@
         fSecurityManager = fEntityManager.fSecurityManager;
     }
 
-    /**
-     * Add the count of the content buffer and check if the accumulated
-     * value exceeds the limit
-     * @param isPEDecl a flag to indicate whether the entity is parameter
-     * @param entityName entity name
-     * @param buffer content buffer
-     */
-    private void checkEntityLimit(boolean isPEDecl, String entityName, XMLString buffer) {
-        checkEntityLimit(isPEDecl, entityName, buffer.length);
-    }
-
-    /**
-     * Add the count and check limit
-     * @param isPEDecl a flag to indicate whether the entity is parameter
-     * @param entityName entity name
-     * @param len length of the buffer
-     */
-    private void checkEntityLimit(boolean isPEDecl, String entityName, int len) {
-        if (fLimitAnalyzer == null) {
-            fLimitAnalyzer = fEntityManager.fLimitAnalyzer;
-        }
-        if (isPEDecl) {
-            fLimitAnalyzer.addValue(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT, "%" + entityName, len);
-            if (fSecurityManager.isOverLimit(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT, fLimitAnalyzer)) {
-                        fSecurityManager.debugPrint(fLimitAnalyzer);
-                reportFatalError("MaxEntitySizeLimit", new Object[]{"%" + entityName,
-                    fLimitAnalyzer.getValue(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT),
-                    fSecurityManager.getLimit(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT),
-                    fSecurityManager.getStateLiteral(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT)});
-            }
-        } else {
-            fLimitAnalyzer.addValue(XMLSecurityManager.Limit.GENERAL_ENTITY_SIZE_LIMIT, entityName, len);
-            if (fSecurityManager.isOverLimit(XMLSecurityManager.Limit.GENERAL_ENTITY_SIZE_LIMIT, fLimitAnalyzer)) {
-                        fSecurityManager.debugPrint(fLimitAnalyzer);
-                reportFatalError("MaxEntitySizeLimit", new Object[]{entityName,
-                    fLimitAnalyzer.getValue(XMLSecurityManager.Limit.GENERAL_ENTITY_SIZE_LIMIT),
-                    fSecurityManager.getLimit(XMLSecurityManager.Limit.GENERAL_ENTITY_SIZE_LIMIT),
-                    fSecurityManager.getStateLiteral(XMLSecurityManager.Limit.GENERAL_ENTITY_SIZE_LIMIT)});
-            }
-        }
-        if (fSecurityManager.isOverLimit(XMLSecurityManager.Limit.TOTAL_ENTITY_SIZE_LIMIT, fLimitAnalyzer)) {
-            fSecurityManager.debugPrint(fLimitAnalyzer);
-            reportFatalError("TotalEntitySizeLimit",
-                new Object[]{fLimitAnalyzer.getTotalValue(XMLSecurityManager.Limit.TOTAL_ENTITY_SIZE_LIMIT),
-                fSecurityManager.getLimit(XMLSecurityManager.Limit.TOTAL_ENTITY_SIZE_LIMIT),
-                fSecurityManager.getStateLiteral(XMLSecurityManager.Limit.TOTAL_ENTITY_SIZE_LIMIT)});
-        }
-
-    }
-
     public DTDGrammar getGrammar(){
         return nvGrammarInfo;
     }
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java
index e8a2d43..ef118f0 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*
@@ -21,21 +21,17 @@
 
 package com.sun.org.apache.xerces.internal.impl;
 
-import com.sun.xml.internal.stream.XMLBufferListener;
-import com.sun.xml.internal.stream.XMLEntityStorage;
-import com.sun.xml.internal.stream.XMLInputFactoryImpl;
-import com.sun.xml.internal.stream.dtd.DTDGrammarUtil;
-
-import java.io.EOFException;
-import java.io.IOException;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.events.XMLEvent;
 import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
 import com.sun.org.apache.xerces.internal.util.AugmentationsImpl;
 import com.sun.org.apache.xerces.internal.util.XMLAttributesIteratorImpl;
 import com.sun.org.apache.xerces.internal.util.XMLChar;
 import com.sun.org.apache.xerces.internal.util.XMLStringBuffer;
 import com.sun.org.apache.xerces.internal.util.XMLSymbols;
+import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager.Limit;
+import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager;
+import com.sun.org.apache.xerces.internal.xni.Augmentations;
 import com.sun.org.apache.xerces.internal.xni.QName;
 import com.sun.org.apache.xerces.internal.xni.XMLAttributes;
 import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
@@ -47,21 +43,16 @@
 import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentScanner;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
-import com.sun.org.apache.xerces.internal.xni.Augmentations;
-import com.sun.org.apache.xerces.internal.impl.Constants;
-import com.sun.org.apache.xerces.internal.impl.XMLEntityHandler;
-import com.sun.org.apache.xerces.internal.util.NamespaceSupport;
-import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
-import com.sun.org.apache.xerces.internal.utils.XMLLimitAnalyzer;
-import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
-import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager.Limit;
-import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager.State;
-import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager;
-import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
-import javax.xml.XMLConstants;
+import com.sun.xml.internal.stream.XMLBufferListener;
+import com.sun.xml.internal.stream.XMLEntityStorage;
+import com.sun.xml.internal.stream.dtd.DTDGrammarUtil;
+import java.io.EOFException;
+import java.io.IOException;
+import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamConstants;
 import javax.xml.stream.events.XMLEvent;
 
+
 /**
  *
  * This class is responsible for scanning the structure and content
@@ -211,12 +202,12 @@
                 null,
                 null,
                 null,
-                EXTERNAL_ACCESS_DEFAULT
+                null
     };
 
     private static final char [] cdata = {'[','C','D','A','T','A','['};
     static final char [] xmlDecl = {'<','?','x','m','l'};
-    private static final char [] endTag = {'<','/'};
+    // private static final char [] endTag = {'<','/'};
     // debugging
 
     /** Debug scanner state. */
@@ -460,6 +451,7 @@
                     //fDocumentHandler.startElement(getElementQName(),fAttributes,null);
                     break;
                 case XMLStreamConstants.CHARACTERS :
+                    fEntityScanner.checkNodeCount(fEntityScanner.fCurrentEntity);
                     fDocumentHandler.characters(getCharacterData(),null);
                     break;
                 case XMLStreamConstants.SPACE:
@@ -468,13 +460,15 @@
                     //fDocumentHandler.ignorableWhitespace(getCharacterData(), null);
                     break;
                 case XMLStreamConstants.ENTITY_REFERENCE :
+                    fEntityScanner.checkNodeCount(fEntityScanner.fCurrentEntity);
                     //entity reference callback are given in startEntity
                     break;
                 case XMLStreamConstants.PROCESSING_INSTRUCTION :
+                    fEntityScanner.checkNodeCount(fEntityScanner.fCurrentEntity);
                     fDocumentHandler.processingInstruction(getPITarget(),getPIData(),null);
                     break;
                 case XMLStreamConstants.COMMENT :
-                    //System.out.println(" in COMMENT of the XMLNSDocumentScannerImpl");
+                    fEntityScanner.checkNodeCount(fEntityScanner.fCurrentEntity);
                     fDocumentHandler.comment(getCharacterData(),null);
                     break;
                 case XMLStreamConstants.DTD :
@@ -483,6 +477,7 @@
                     //therefore we don't need to take care of anything here. So Just break;
                     break;
                 case XMLStreamConstants.CDATA:
+                    fEntityScanner.checkNodeCount(fEntityScanner.fCurrentEntity);
                     fDocumentHandler.startCDATA(null);
                     //xxx: check if CDATA values comes from getCharacterData() function
                     fDocumentHandler.characters(getCharacterData(),null);
@@ -1279,9 +1274,9 @@
             fElementQName = fElementStack.nextElement();
             // name
             if (fNamespaces) {
-                fEntityScanner.scanQName(fElementQName);
+                fEntityScanner.scanQName(fElementQName, NameType.ELEMENTSTART);
             } else {
-                String name = fEntityScanner.scanName();
+                String name = fEntityScanner.scanName(NameType.ELEMENTSTART);
                 fElementQName.setValues(null, name, name, null);
             }
 
@@ -1382,18 +1377,23 @@
         // end tag?
         final int c = fEntityScanner.peekChar();
         if (c == '>') {
-            fEntityScanner.scanChar();
+            fEntityScanner.scanChar(null);
             return true;
         } else if (c == '/') {
-            fEntityScanner.scanChar();
-            if (!fEntityScanner.skipChar('>')) {
+            fEntityScanner.scanChar(null);
+            if (!fEntityScanner.skipChar('>', NameType.ELEMENTEND)) {
                 reportFatalError("ElementUnterminated",
                         new Object[]{fElementQName.rawname});
             }
             fEmptyElement = true;
             return true;
         } else if (!isValidNameStartChar(c) || !sawSpace) {
-            reportFatalError("ElementUnterminated", new Object[]{fElementQName.rawname});
+            // Second chance. Check if this character is a high
+            // surrogate of a valid name start character.
+            if (!isValidNameStartHighSurrogate(c) || !sawSpace) {
+                reportFatalError("ElementUnterminated",
+                        new Object[]{fElementQName.rawname});
+            }
         }
 
         return false;
@@ -1519,15 +1519,15 @@
 
         // name
         if (fNamespaces) {
-            fEntityScanner.scanQName(fAttributeQName);
+            fEntityScanner.scanQName(fAttributeQName, NameType.ATTRIBUTENAME);
         } else {
-            String name = fEntityScanner.scanName();
+            String name = fEntityScanner.scanName(NameType.ATTRIBUTENAME);
             fAttributeQName.setValues(null, name, name, null);
         }
 
         // equals
         fEntityScanner.skipSpaces();
-        if (!fEntityScanner.skipChar('=')) {
+        if (!fEntityScanner.skipChar('=', NameType.ATTRIBUTE)) {
             reportFatalError("EqRequiredInAttribute",
                 new Object[] {fCurrentElement.rawname, fAttributeQName.rawname});
         }
@@ -1545,9 +1545,8 @@
         //can safely add the attribute later..
         XMLString tmpStr = getString();
 
-        scanAttributeValue(tmpStr, fTempString2,
-                fAttributeQName.rawname, attributes,
-                attIndex, isVC, fCurrentElement.rawname);
+        scanAttributeValue(tmpStr, fTempString2, fAttributeQName.rawname, attributes,
+                attIndex, isVC, fCurrentElement.rawname, false);
 
         // content
         int oldLen = attributes.getLength();
@@ -1595,13 +1594,13 @@
         if (c == '\r') {
             // happens when there is the character reference &#13;
             //xxx: We know the next chracter.. we should just skip it and add ']' directlry
-            fEntityScanner.scanChar();
+            fEntityScanner.scanChar(null);
             content.append((char)c);
             c = -1;
         } else if (c == ']') {
             //fStringBuffer.clear();
             //xxx: We know the next chracter.. we should just skip it and add ']' directlry
-            content.append((char)fEntityScanner.scanChar());
+            content.append((char)fEntityScanner.scanChar(null));
             // remember where we are in case we get an endEntity before we
             // could flush the buffer out - this happens when we're parsing an
             // entity which ends with a ]
@@ -1610,12 +1609,12 @@
             // We work on a single character basis to handle cases such as:
             // ']]]>' which we might otherwise miss.
             //
-            if (fEntityScanner.skipChar(']')) {
+            if (fEntityScanner.skipChar(']', null)) {
                 content.append(']');
-                while (fEntityScanner.skipChar(']')) {
+                while (fEntityScanner.skipChar(']', null)) {
                     content.append(']');
                 }
-                if (fEntityScanner.skipChar('>')) {
+                if (fEntityScanner.skipChar('>', null)) {
                     reportFatalError("CDEndInContent", null);
                 }
             }
@@ -1690,7 +1689,7 @@
                     } else {
                         reportFatalError("InvalidCharInCDSect",
                                 new Object[]{Integer.toString(c,16)});
-                                fEntityScanner.scanChar();
+                                fEntityScanner.scanChar(null);
                     }
                 }
                 //by this time we have also read surrogate contents if any...
@@ -1752,7 +1751,7 @@
 
         // end
         fEntityScanner.skipSpaces();
-        if (!fEntityScanner.skipChar('>')) {
+        if (!fEntityScanner.skipChar('>', NameType.ELEMENTEND)) {
             reportFatalError("ETagUnterminated",
                     new Object[]{rawname});
         }
@@ -1842,12 +1841,12 @@
      *                      notification.
      */
     protected void scanEntityReference(XMLStringBuffer content) throws IOException, XNIException {
-        String name = fEntityScanner.scanName();
+        String name = fEntityScanner.scanName(NameType.REFERENCE);
         if (name == null) {
             reportFatalError("NameRequiredInReference", null);
             return;
         }
-        if (!fEntityScanner.skipChar(';')) {
+        if (!fEntityScanner.skipChar(';', NameType.REFERENCE)) {
             reportFatalError("SemicolonRequiredInReference", new Object []{name});
         }
         if (fEntityStore.isUnparsedEntity(name)) {
@@ -1944,6 +1943,7 @@
      */
     private void handleCharacter(char c, String entity, XMLStringBuffer content) throws XNIException {
         foundBuiltInRefs = true;
+        checkEntityLimit(false, fEntityScanner.fCurrentEntity.name, 1);
         content.append(c);
         if (fDocumentHandler != null) {
             fSingleChar[0] = c;
@@ -2057,7 +2057,7 @@
      */
     String checkAccess(String systemId, String allowedProtocols) throws IOException {
         String baseSystemId = fEntityScanner.getBaseSystemId();
-        String expandedSystemId = fEntityManager.expandSystemId(systemId, baseSystemId,fStrictURI);
+        String expandedSystemId = XMLEntityManager.expandSystemId(systemId, baseSystemId, fStrictURI);
         return SecuritySupport.checkAccess(expandedSystemId, allowedProtocols, Constants.ACCESS_EXTERNAL_ALL);
     }
 
@@ -2593,8 +2593,6 @@
         //
         // Driver methods
         //
-        private boolean fContinueDispatching = true;
-        private boolean fScanningForMarkup = true;
 
         /**
          *  decides the appropriate state of the parser
@@ -2603,39 +2601,38 @@
             fMarkupDepth++;
             final int ch = fEntityScanner.peekChar();
 
-            switch(ch){
-                case '?' :{
-                    setScannerState(SCANNER_STATE_PI);
-                    fEntityScanner.skipChar(ch);
-                    break;
-                }
-                case '!' :{
-                    fEntityScanner.skipChar(ch);
-                    if (fEntityScanner.skipChar('-')) {
-                        if (!fEntityScanner.skipChar('-')) {
-                            reportFatalError("InvalidCommentStart",
+            if (isValidNameStartChar(ch) || isValidNameStartHighSurrogate(ch)) {
+                setScannerState(SCANNER_STATE_START_ELEMENT_TAG);
+            } else {
+                switch(ch){
+                    case '?' :{
+                        setScannerState(SCANNER_STATE_PI);
+                        fEntityScanner.skipChar(ch, null);
+                        break;
+                    }
+                    case '!' :{
+                        fEntityScanner.skipChar(ch, null);
+                        if (fEntityScanner.skipChar('-', null)) {
+                            if (!fEntityScanner.skipChar('-', NameType.COMMENT)) {
+                                reportFatalError("InvalidCommentStart",
+                                        null);
+                            }
+                            setScannerState(SCANNER_STATE_COMMENT);
+                        } else if (fEntityScanner.skipString(cdata)) {
+                            setScannerState(SCANNER_STATE_CDATA );
+                        } else if (!scanForDoctypeHook()) {
+                            reportFatalError("MarkupNotRecognizedInContent",
                                     null);
                         }
-                        setScannerState(SCANNER_STATE_COMMENT);
-                    } else if (fEntityScanner.skipString(cdata)) {
-                        setScannerState(SCANNER_STATE_CDATA );
-                    } else if (!scanForDoctypeHook()) {
-                        reportFatalError("MarkupNotRecognizedInContent",
-                                null);
+                        break;
                     }
-                    break;
-                }
-                case '/' :{
-                    setScannerState(SCANNER_STATE_END_ELEMENT_TAG);
-                    fEntityScanner.skipChar(ch);
-                    break;
-                }
-                default :{
-                    if (isValidNameStartChar(ch)) {
-                        setScannerState(SCANNER_STATE_START_ELEMENT_TAG);
-                    } else {
-                        reportFatalError("MarkupNotRecognizedInContent",
-                                null);
+                    case '/' :{
+                        setScannerState(SCANNER_STATE_END_ELEMENT_TAG);
+                        fEntityScanner.skipChar(ch, NameType.ELEMENTEND);
+                        break;
+                    }
+                    default :{
+                        reportFatalError("MarkupNotRecognizedInContent", null);
                     }
                 }
             }
@@ -2643,9 +2640,9 @@
         }//startOfMarkup
 
         private void startOfContent() throws IOException {
-            if (fEntityScanner.skipChar('<')) {
+            if (fEntityScanner.skipChar('<', null)) {
                 setScannerState(SCANNER_STATE_START_OF_MARKUP);
-            } else if (fEntityScanner.skipChar('&')) {
+            } else if (fEntityScanner.skipChar('&', NameType.REFERENCE)) {
                 setScannerState(SCANNER_STATE_REFERENCE) ; //XMLEvent.ENTITY_REFERENCE ); //SCANNER_STATE_REFERENCE
             } else {
                 //element content is there..
@@ -2718,10 +2715,10 @@
                     case SCANNER_STATE_CONTENT: {
                         final int ch = fEntityScanner.peekChar();
                         if (ch == '<') {
-                            fEntityScanner.scanChar();
+                            fEntityScanner.scanChar(null);
                             setScannerState(SCANNER_STATE_START_OF_MARKUP);
                         } else if (ch == '&') {
-                            fEntityScanner.scanChar();
+                            fEntityScanner.scanChar(NameType.REFERENCE);
                             setScannerState(SCANNER_STATE_REFERENCE) ; //XMLEvent.ENTITY_REFERENCE ); //SCANNER_STATE_REFERENCE
                             break;
                         } else {
@@ -2821,9 +2818,9 @@
                         if(DEBUG){
                             System.out.println("fTempString = " + fTempString);
                         }
-                        if(fEntityScanner.skipChar('<')){
+                        if(fEntityScanner.skipChar('<', null)){
                             //check if we have reached end of element
-                            if(fEntityScanner.skipChar('/')){
+                            if(fEntityScanner.skipChar('/', NameType.ELEMENTEND)){
                                 //increase the mark up depth
                                 fMarkupDepth++;
                                 fLastSectionWasCharacterData = false;
@@ -2873,7 +2870,7 @@
                             }
                             // happens when there is the character reference &#13;
                             //xxx: We know the next chracter.. we should just skip it and add ']' directlry
-                            fEntityScanner.scanChar();
+                            fEntityScanner.scanChar(null);
                             fUsebuffer = true;
                             fContentBuffer.append((char)c);
                             c = -1 ;
@@ -2881,7 +2878,7 @@
                             //fStringBuffer.clear();
                             //xxx: We know the next chracter.. we should just skip it and add ']' directlry
                             fUsebuffer = true;
-                            fContentBuffer.append((char)fEntityScanner.scanChar());
+                            fContentBuffer.append((char)fEntityScanner.scanChar(null));
                             // remember where we are in case we get an endEntity before we
                             // could flush the buffer out - this happens when we're parsing an
                             // entity which ends with a ]
@@ -2890,12 +2887,12 @@
                             // We work on a single character basis to handle cases such as:
                             // ']]]>' which we might otherwise miss.
                             //
-                            if (fEntityScanner.skipChar(']')) {
+                            if (fEntityScanner.skipChar(']', null)) {
                                 fContentBuffer.append(']');
-                                while (fEntityScanner.skipChar(']')) {
+                                while (fEntityScanner.skipChar(']', null)) {
                                     fContentBuffer.append(']');
                                 }
-                                if (fEntityScanner.skipChar('>')) {
+                                if (fEntityScanner.skipChar('>', null)) {
                                     reportFatalError("CDEndInContent", null);
                                 }
                             }
@@ -2908,12 +2905,12 @@
                             // we need not to grow the buffer only when isCoalesce() is not true;
 
                             if (c == '<') {
-                                fEntityScanner.scanChar();
+                                fEntityScanner.scanChar(null);
                                 setScannerState(SCANNER_STATE_START_OF_MARKUP);
                                 break;
                             }//xxx what should be the behavior if entity reference is present in the content ?
                             else if (c == '&') {
-                                fEntityScanner.scanChar();
+                                fEntityScanner.scanChar(NameType.REFERENCE);
                                 setScannerState(SCANNER_STATE_REFERENCE);
                                 break;
                             }///xxx since this part is also characters, it should be merged...
@@ -2926,7 +2923,7 @@
                                     reportFatalError("InvalidCharInContent",
                                             new Object[] {
                                         Integer.toString(c, 16)});
-                                        fEntityScanner.scanChar();
+                                        fEntityScanner.scanChar(null);
                                 }
                                 break;
                             }
@@ -3052,7 +3049,7 @@
                         }
                         fUsebuffer = true ;
                         //take care of character reference
-                        if (fEntityScanner.skipChar('#')) {
+                        if (fEntityScanner.skipChar('#', NameType.REFERENCE)) {
                             scanCharReferenceValue(fContentBuffer, null);
                             fMarkupDepth--;
                             if(!fIsCoalesce){
@@ -3103,11 +3100,11 @@
 
                                 if (fNamespaces) {
                                     while (isValidNCName(fEntityScanner.peekChar())) {
-                                        fStringBuffer.append((char)fEntityScanner.scanChar());
+                                        fStringBuffer.append((char)fEntityScanner.scanChar(null));
                                     }
                                 } else {
                                     while (isValidNameChar(fEntityScanner.peekChar())) {
-                                        fStringBuffer.append((char)fEntityScanner.scanChar());
+                                        fStringBuffer.append((char)fEntityScanner.scanChar(null));
                                     }
                                 }
                                 String target = fSymbolTable.addSymbol(fStringBuffer.ch, fStringBuffer.offset, fStringBuffer.length);
@@ -3254,7 +3251,7 @@
 
     protected XMLString getString(){
         if(fAttributeCacheUsedCount < initialCacheCount || fAttributeCacheUsedCount < attributeValueCache.size()){
-            return (XMLString)attributeValueCache.get(fAttributeCacheUsedCount++);
+            return attributeValueCache.get(fAttributeCacheUsedCount++);
         } else{
             XMLString str = new XMLString();
             fAttributeCacheUsedCount++;
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentScannerImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentScannerImpl.java
index 27689e7..4330492 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentScannerImpl.java
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentScannerImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*
@@ -31,7 +31,6 @@
 import com.sun.org.apache.xerces.internal.xni.Augmentations;
 import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
 import com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier;
-import com.sun.org.apache.xerces.internal.xni.XMLString;
 import com.sun.org.apache.xerces.internal.xni.XNIException;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
@@ -225,9 +224,6 @@
     /** A DTD Description. */
     private final XMLDTDDescription fDTDDescription = new XMLDTDDescription(null, null, null, null, null);
 
-    /** String. */
-    private XMLString fString = new XMLString();
-
     private static final char [] DOCTYPE = {'D','O','C','T','Y','P','E'};
     private static final char [] COMMENTSTRING = {'-','-'};
 
@@ -636,7 +632,7 @@
         }
 
         // root element name
-        fDoctypeName = fEntityScanner.scanName();
+        fDoctypeName = fEntityScanner.scanName(NameType.DOCTYPE);
         if (fDoctypeName == null) {
             reportFatalError("MSG_ROOT_ELEMENT_TYPE_REQUIRED", null);
         }
@@ -676,10 +672,10 @@
 
         // is there an internal subset?
         boolean internalSubset = true;
-        if (!fEntityScanner.skipChar('[')) {
+        if (!fEntityScanner.skipChar('[', null)) {
             internalSubset = false;
             fEntityScanner.skipSpaces();
-            if (!fEntityScanner.skipChar('>')) {
+            if (!fEntityScanner.skipChar('>', null)) {
                 reportFatalError("DoctypedeclUnterminated", new Object[]{fDoctypeName});
             }
             fMarkupDepth--;
@@ -758,7 +754,7 @@
                         fStringBuffer.clear();
                         fStringBuffer.append("xml");
                         while (XMLChar.isName(fEntityScanner.peekChar())) {
-                            fStringBuffer.append((char)fEntityScanner.scanChar());
+                            fStringBuffer.append((char)fEntityScanner.scanChar(null));
                         }
                         String target = fSymbolTable.addSymbol(fStringBuffer.ch, fStringBuffer.offset, fStringBuffer.length);
                         //this function should fill the data.. and set the fEvent object to this event.
@@ -836,9 +832,9 @@
                     switch (fScannerState) {
                         case SCANNER_STATE_PROLOG: {
                             fEntityScanner.skipSpaces();
-                            if (fEntityScanner.skipChar('<')) {
+                            if (fEntityScanner.skipChar('<', null)) {
                                 setScannerState(SCANNER_STATE_START_OF_MARKUP);
-                            } else if (fEntityScanner.skipChar('&')) {
+                            } else if (fEntityScanner.skipChar('&', NameType.REFERENCE)) {
                                 setScannerState(SCANNER_STATE_REFERENCE);
                             } else {
                                 setScannerState(SCANNER_STATE_CONTENT);
@@ -848,12 +844,15 @@
 
                         case SCANNER_STATE_START_OF_MARKUP: {
                             fMarkupDepth++;
-
-                            if (fEntityScanner.skipChar('?')) {
-                                setScannerState(SCANNER_STATE_PI);
-                            } else if (fEntityScanner.skipChar('!')) {
-                                if (fEntityScanner.skipChar('-')) {
-                                    if (!fEntityScanner.skipChar('-')) {
+                            if (isValidNameStartChar(fEntityScanner.peekChar()) ||
+                                    isValidNameStartHighSurrogate(fEntityScanner.peekChar())) {
+                                setScannerState(SCANNER_STATE_ROOT_ELEMENT);
+                                setDriver(fContentDriver);
+                                //from now onwards this would be handled by fContentDriver,in the same next() call
+                                return fContentDriver.next();
+                            } else if (fEntityScanner.skipChar('!', null)) {
+                                if (fEntityScanner.skipChar('-', null)) {
+                                    if (!fEntityScanner.skipChar('-', null)) {
                                         reportFatalError("InvalidCommentStart",
                                                 null);
                                     }
@@ -873,12 +872,8 @@
                                     reportFatalError("MarkupNotRecognizedInProlog",
                                             null);
                                 }
-                            } else if (XMLChar.isNameStart(fEntityScanner.peekChar())) {
-                                setScannerState(SCANNER_STATE_ROOT_ELEMENT);
-                                setDriver(fContentDriver);
-                                //from now onwards this would be handled by fContentDriver,in the same next() call
-                                return fContentDriver.next();
-
+                            } else if (fEntityScanner.skipChar('?', null)) {
+                                setScannerState(SCANNER_STATE_PI);
                             } else {
                                 reportFatalError("MarkupNotRecognizedInProlog",
                                         null);
@@ -997,7 +992,7 @@
 
                     case SCANNER_STATE_CONTENT: {
                         reportFatalError("ContentIllegalInProlog", null);
-                        fEntityScanner.scanChar();
+                        fEntityScanner.scanChar(null);
                     }
                     case SCANNER_STATE_REFERENCE: {
                         reportFatalError("ReferenceIllegalInProlog", null);
@@ -1111,12 +1106,12 @@
                             fReadingDTD=false;
                             if (!moreToScan) {
                                 // end doctype declaration
-                                if (!fEntityScanner.skipChar(']')) {
+                                if (!fEntityScanner.skipChar(']', null)) {
                                     reportFatalError("EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET",
                                             null);
                                 }
                                 fEntityScanner.skipSpaces();
-                                if (!fEntityScanner.skipChar('>')) {
+                                if (!fEntityScanner.skipChar('>', null)) {
                                     reportFatalError("DoctypedeclUnterminated", new Object[]{fDoctypeName});
                                 }
                                 fMarkupDepth--;
@@ -1380,7 +1375,7 @@
                             if(fScannerState == SCANNER_STATE_TERMINATED ){
                                 return XMLEvent.END_DOCUMENT ;
                             }
-                            if (fEntityScanner.skipChar('<')) {
+                            if (fEntityScanner.skipChar('<', null)) {
                                 setScannerState(SCANNER_STATE_START_OF_MARKUP);
                             } else {
                                 setScannerState(SCANNER_STATE_CONTENT);
@@ -1389,14 +1384,15 @@
                         }
                         case SCANNER_STATE_START_OF_MARKUP: {
                             fMarkupDepth++;
-                            if (fEntityScanner.skipChar('?')) {
+                            if (fEntityScanner.skipChar('?', null)) {
                                 setScannerState(SCANNER_STATE_PI);
-                            } else if (fEntityScanner.skipChar('!')) {
+                            } else if (fEntityScanner.skipChar('!', null)) {
                                 setScannerState(SCANNER_STATE_COMMENT);
-                            } else if (fEntityScanner.skipChar('/')) {
+                            } else if (fEntityScanner.skipChar('/', null)) {
                                 reportFatalError("MarkupNotRecognizedInMisc",
                                         null);
-                            } else if (XMLChar.isNameStart(fEntityScanner.peekChar())) {
+                            } else if (isValidNameStartChar(fEntityScanner.peekChar()) ||
+                                    isValidNameStartHighSurrogate(fEntityScanner.peekChar())) {
                                 reportFatalError("MarkupNotRecognizedInMisc",
                                         null);
                                 scanStartElement();
@@ -1435,7 +1431,7 @@
                         } else{
                             reportFatalError("ContentIllegalInTrailingMisc",
                                     null);
-                            fEntityScanner.scanChar();
+                            fEntityScanner.scanChar(null);
                             setScannerState(SCANNER_STATE_TRAILING_MISC);
                             return XMLEvent.CHARACTERS;
                         }
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java
index bf3adc2..570e2a6 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -368,7 +368,7 @@
     protected Map<String, Entity> fEntities = new HashMap<>();
 
     /** Entity stack. */
-    protected Stack fEntityStack = new Stack();
+    protected Stack<Entity> fEntityStack = new Stack<>();
 
     /** Current entity. */
     protected Entity.ScannedEntity fCurrentEntity = null;
@@ -631,10 +631,10 @@
                         final HTTPInputSource httpInputSource = (HTTPInputSource) xmlInputSource;
 
                         // set request properties
-                        Iterator propIter = httpInputSource.getHTTPRequestProperties();
+                        Iterator<Map.Entry<String, String>> propIter = httpInputSource.getHTTPRequestProperties();
                         while (propIter.hasNext()) {
-                            Map.Entry entry = (Map.Entry) propIter.next();
-                            urlConnection.setRequestProperty((String) entry.getKey(), (String) entry.getValue());
+                            Map.Entry<String, String> entry = propIter.next();
+                            urlConnection.setRequestProperty(entry.getKey(), entry.getValue());
                         }
 
                         // set preference for redirection
@@ -1053,7 +1053,6 @@
         String literalSystemId = resourceIdentifier.getLiteralSystemId();
         String baseSystemId = resourceIdentifier.getBaseSystemId();
         String expandedSystemId = resourceIdentifier.getExpandedSystemId();
-        String namespace = resourceIdentifier.getNamespace();
 
         // if no base systemId given, assume that it's relative
         // to the systemId of the current scanned entity
@@ -2008,14 +2007,6 @@
 
         // system id has to be a valid URI
         if (strict) {
-
-
-            // check if there is a system id before
-            // trying to expand it.
-            if (systemId == null) {
-                return null;
-            }
-
             try {
                 // if it's already an absolute one, return it
                 new URI(systemId);
@@ -2923,7 +2914,7 @@
                     if (!fCurrentEntity.xmlDeclChunkRead)
                     {
                         fCurrentEntity.xmlDeclChunkRead = true;
-                        len = fCurrentEntity.DEFAULT_XMLDECL_BUFFER_SIZE;
+                        len = Entity.ScannedEntity.DEFAULT_XMLDECL_BUFFER_SIZE;
                     }
                     return fInputStream.read(b, off, len);
                 }
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLEntityScanner.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLEntityScanner.java
index 1c0eca6..8b02b2e 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLEntityScanner.java
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLEntityScanner.java
@@ -1,13 +1,13 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  */
-
 /*
- * Copyright 2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
@@ -21,7 +21,7 @@
 package com.sun.org.apache.xerces.internal.impl;
 
 
-
+import com.sun.org.apache.xerces.internal.impl.XMLScanner.NameType;
 import com.sun.org.apache.xerces.internal.impl.io.ASCIIReader;
 import com.sun.org.apache.xerces.internal.impl.io.UCSReader;
 import com.sun.org.apache.xerces.internal.impl.io.UTF8Reader;
@@ -143,6 +143,10 @@
     // SAPJVM: Remember, that the XML version has explicitly been set,
     // so that XMLStreamReader.getVersion() can find that out.
     boolean xmlVersionSetExplicitly = false;
+
+    // indicates that the operation is for detecting XML version
+    boolean detectingVersion = false;
+
     //
     // Constructors
     //
@@ -529,10 +533,12 @@
      * <p>
      * <strong>Note:</strong> The character is consumed.
      *
+     * @param nt The type of the name (element or attribute)
+     *
      * @throws IOException  Thrown if i/o error occurs.
      * @throws EOFException Thrown on end of file.
      */
-    public int scanChar() throws IOException {
+    protected int scanChar(NameType nt) throws IOException {
         if (DEBUG_BUFFER) {
             System.out.print("(scanChar: ");
             print();
@@ -545,6 +551,7 @@
         }
 
         // scan character
+        int offset = fCurrentEntity.position;
         int c = fCurrentEntity.ch[fCurrentEntity.position++];
         if (c == '\n' ||
                 (c == '\r' && isExternal)) {
@@ -554,6 +561,7 @@
                 invokeListeners(1);
                 fCurrentEntity.ch[0] = (char)c;
                 load(1, false, false);
+                offset = 0;
             }
             if (c == '\r' && isExternal) {
                 if (fCurrentEntity.ch[fCurrentEntity.position++] != '\n') {
@@ -570,6 +578,9 @@
             System.out.println(" -> '"+(char)c+"'");
         }
         fCurrentEntity.columnNumber++;
+        if (!detectingVersion) {
+            checkEntityLimit(nt, fCurrentEntity, offset, fCurrentEntity.position - offset);
+        }
         return c;
 
     } // scanChar():int
@@ -589,7 +600,7 @@
      * @see com.sun.org.apache.xerces.internal.util.SymbolTable
      * @see com.sun.org.apache.xerces.internal.util.XMLChar#isName
      */
-    public String scanNmtoken() throws IOException {
+    protected String scanNmtoken() throws IOException {
         if (DEBUG_BUFFER) {
             System.out.print("(scanNmtoken: ");
             print();
@@ -661,6 +672,8 @@
      * <strong>Note:</strong> The string returned must be a symbol. The
      * SymbolTable can be used for this purpose.
      *
+     * @param nt The type of the name (element or attribute)
+     *
      * @throws IOException  Thrown if i/o error occurs.
      * @throws EOFException Thrown on end of file.
      *
@@ -668,7 +681,7 @@
      * @see com.sun.org.apache.xerces.internal.util.XMLChar#isName
      * @see com.sun.org.apache.xerces.internal.util.XMLChar#isNameStart
      */
-    public String scanName() throws IOException {
+    protected String scanName(NameType nt) throws IOException {
         if (DEBUG_BUFFER) {
             System.out.print("(scanName: ");
             print();
@@ -682,6 +695,7 @@
 
         // scan name
         int offset = fCurrentEntity.position;
+        int length;
         if (XMLChar.isNameStart(fCurrentEntity.ch[offset])) {
             if (++fCurrentEntity.position == fCurrentEntity.count) {
                 invokeListeners(1);
@@ -709,20 +723,7 @@
                     vc = XMLChar.isName(c);
                 }
                 if(!vc)break;
-                if (++fCurrentEntity.position == fCurrentEntity.count) {
-                    int length = fCurrentEntity.position - offset;
-                    invokeListeners(length);
-                    if (length == fCurrentEntity.fBufferSize) {
-                        // bad luck we have to resize our buffer
-                        char[] tmp = new char[fCurrentEntity.fBufferSize * 2];
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                tmp, 0, length);
-                        fCurrentEntity.ch = tmp;
-                        fCurrentEntity.fBufferSize *= 2;
-                    } else {
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                fCurrentEntity.ch, 0, length);
-                    }
+                if ((length = checkBeforeLoad(fCurrentEntity, offset, offset)) > 0) {
                     offset = 0;
                     if (load(length, false, false)) {
                         break;
@@ -730,12 +731,14 @@
                 }
             }
         }
-        int length = fCurrentEntity.position - offset;
+        length = fCurrentEntity.position - offset;
         fCurrentEntity.columnNumber += length;
 
         // return name
         String symbol;
         if (length > 0) {
+            checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, offset, length);
+            checkEntityLimit(nt, fCurrentEntity, offset, length);
             symbol = fSymbolTable.addSymbol(fCurrentEntity.ch, offset, length);
         } else
             symbol = null;
@@ -759,6 +762,7 @@
      * this purpose.
      *
      * @param qname The qualified name structure to fill.
+     * @param nt The type of the name (element or attribute)
      *
      * @return Returns true if a qualified name appeared immediately on
      *         the input and was scanned, false otherwise.
@@ -770,7 +774,7 @@
      * @see com.sun.org.apache.xerces.internal.util.XMLChar#isName
      * @see com.sun.org.apache.xerces.internal.util.XMLChar#isNameStart
      */
-    public boolean scanQName(QName qname) throws IOException {
+    protected boolean scanQName(QName qname, NameType nt) throws IOException {
         if (DEBUG_BUFFER) {
             System.out.print("(scanQName, "+qname+": ");
             print();
@@ -806,11 +810,13 @@
                         print();
                         System.out.println(" -> true");
                     }
+                    checkEntityLimit(nt, fCurrentEntity, 0, 1);
                     return true;
                 }
             }
             int index = -1;
             boolean vc = false;
+            int length;
             while ( true){
 
                 //XMLChar.isName(fCurrentEntity.ch[fCurrentEntity.position])) ;
@@ -829,22 +835,7 @@
                     //check prefix before further read
                     checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, offset, index - offset);
                 }
-                if (++fCurrentEntity.position == fCurrentEntity.count) {
-                    int length = fCurrentEntity.position - offset;
-                    //check localpart before loading more data
-                    checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, offset, length - index - 1);
-                    invokeListeners(length);
-                    if (length == fCurrentEntity.fBufferSize) {
-                        // bad luck we have to resize our buffer
-                        char[] tmp = new char[fCurrentEntity.fBufferSize * 2];
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                tmp, 0, length);
-                        fCurrentEntity.ch = tmp;
-                        fCurrentEntity.fBufferSize *= 2;
-                    } else {
-                        System.arraycopy(fCurrentEntity.ch, offset,
-                                fCurrentEntity.ch, 0, length);
-                    }
+                if ((length = checkBeforeLoad(fCurrentEntity, offset, index)) > 0) {
                     if (index != -1) {
                         index = index - offset;
                     }
@@ -854,7 +845,7 @@
                     }
                 }
             }
-            int length = fCurrentEntity.position - offset;
+            length = fCurrentEntity.position - offset;
             fCurrentEntity.columnNumber += length;
             if (length > 0) {
                 String prefix = null;
@@ -885,6 +876,7 @@
                     print();
                     System.out.println(" -> true");
                 }
+                checkEntityLimit(nt, fCurrentEntity, offset, length);
                 return true;
             }
         }
@@ -900,22 +892,104 @@
     } // scanQName(QName):boolean
 
     /**
+     * Checks whether the end of the entity buffer has been reached. If yes,
+     * checks against the limit and buffer size before loading more characters.
+     *
+     * @param entity the current entity
+     * @param offset the offset from which the current read was started
+     * @param nameOffset the offset from which the current name starts
+     * @return the length of characters scanned before the end of the buffer,
+     * zero if there is more to be read in the buffer
+     */
+    protected int checkBeforeLoad(Entity.ScannedEntity entity, int offset,
+            int nameOffset) throws IOException {
+        int length = 0;
+        if (++entity.position == entity.count) {
+            length = entity.position - offset;
+            int nameLength = length;
+            if (nameOffset != -1) {
+                nameOffset = nameOffset - offset;
+                nameLength = length - nameOffset;
+            } else {
+                nameOffset = offset;
+            }
+            //check limit before loading more data
+            checkLimit(Limit.MAX_NAME_LIMIT, entity, nameOffset, nameLength);
+            invokeListeners(length);
+            if (length == entity.ch.length) {
+                // bad luck we have to resize our buffer
+                char[] tmp = new char[entity.fBufferSize * 2];
+                System.arraycopy(entity.ch, offset, tmp, 0, length);
+                entity.ch = tmp;
+                entity.fBufferSize *= 2;
+            }
+            else {
+                System.arraycopy(entity.ch, offset, entity.ch, 0, length);
+            }
+        }
+        return length;
+    }
+
+    /**
+     * If the current entity is an Entity reference, check the accumulated size
+     * against the limit.
+     *
+     * @param nt type of name (element, attribute or entity)
+     * @param entity The current entity
+     * @param offset The index of the first byte
+     * @param length The length of the entity scanned
+     */
+    protected void checkEntityLimit(NameType nt, ScannedEntity entity, int offset, int length) {
+        if (entity == null || !entity.isGE) {
+            return;
+        }
+
+        if (nt != NameType.REFERENCE) {
+            checkLimit(Limit.GENERAL_ENTITY_SIZE_LIMIT, entity, offset, length);
+        }
+        if (nt == NameType.ELEMENTSTART || nt == NameType.ATTRIBUTENAME) {
+            checkNodeCount(entity);
+        }
+    }
+
+    /**
+     * If the current entity is an Entity reference, counts the total nodes in
+     * the entity and checks the accumulated value against the limit.
+     *
+     * @param entity The current entity
+     */
+    protected void checkNodeCount(ScannedEntity entity) {
+        if (entity != null && entity.isGE) {
+            checkLimit(Limit.ENTITY_REPLACEMENT_LIMIT, entity, 0, 1);
+        }
+    }
+
+    /**
      * Checks whether the value of the specified Limit exceeds its limit
      *
-     * @param limit The Limit to be checked.
-     * @param entity The current entity.
+     * @param limit The Limit to be checked
+     * @param entity The current entity
      * @param offset The index of the first byte
-     * @param length The length of the entity scanned.
+     * @param length The length of the entity scanned
      */
     protected void checkLimit(Limit limit, ScannedEntity entity, int offset, int length) {
-        fLimitAnalyzer.addValue(limit, null, length);
+        fLimitAnalyzer.addValue(limit, entity.name, length);
         if (fSecurityManager.isOverLimit(limit, fLimitAnalyzer)) {
             fSecurityManager.debugPrint(fLimitAnalyzer);
+            Object[] e = (limit == Limit.ENTITY_REPLACEMENT_LIMIT) ?
+                    new Object[]{fLimitAnalyzer.getValue(limit),
+                        fSecurityManager.getLimit(limit), fSecurityManager.getStateLiteral(limit)} :
+                    new Object[]{entity.name, fLimitAnalyzer.getValue(limit),
+                        fSecurityManager.getLimit(limit), fSecurityManager.getStateLiteral(limit)};
             fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN, limit.key(),
-                    new Object[]{new String(entity.ch, offset, length),
-                fLimitAnalyzer.getTotalValue(limit),
-                fSecurityManager.getLimit(limit),
-                fSecurityManager.getStateLiteral(limit)},
+                    e, XMLErrorReporter.SEVERITY_FATAL_ERROR);
+        }
+        if (fSecurityManager.isOverLimit(Limit.TOTAL_ENTITY_SIZE_LIMIT, fLimitAnalyzer)) {
+            fSecurityManager.debugPrint(fLimitAnalyzer);
+            fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN, "TotalEntitySizeLimit",
+                    new Object[]{fLimitAnalyzer.getTotalValue(Limit.TOTAL_ENTITY_SIZE_LIMIT),
+                fSecurityManager.getLimit(Limit.TOTAL_ENTITY_SIZE_LIMIT),
+                fSecurityManager.getStateLiteral(Limit.TOTAL_ENTITY_SIZE_LIMIT)},
                     XMLErrorReporter.SEVERITY_FATAL_ERROR);
         }
     }
@@ -942,7 +1016,7 @@
      * @throws IOException  Thrown if i/o error occurs.
      * @throws EOFException Thrown on end of file.
      */
-    public int scanContent(XMLString content) throws IOException {
+    protected int scanContent(XMLString content) throws IOException {
         if (DEBUG_BUFFER) {
             System.out.print("(scanContent: ");
             print();
@@ -963,6 +1037,7 @@
         int offset = fCurrentEntity.position;
         int c = fCurrentEntity.ch[offset];
         int newlines = 0;
+        boolean counted = false;
         if (c == '\n' || (c == '\r' && isExternal)) {
             if (DEBUG_BUFFER) {
                 System.out.print("[newline, "+offset+", "+fCurrentEntity.position+": ");
@@ -976,9 +1051,11 @@
                     fCurrentEntity.lineNumber++;
                     fCurrentEntity.columnNumber = 1;
                     if (fCurrentEntity.position == fCurrentEntity.count) {
+                        checkEntityLimit(null, fCurrentEntity, offset, newlines);
                         offset = 0;
                         fCurrentEntity.position = newlines;
                         if (load(newlines, false, true)) {
+                            counted = true;
                             break;
                         }
                     }
@@ -995,9 +1072,11 @@
                     fCurrentEntity.lineNumber++;
                     fCurrentEntity.columnNumber = 1;
                     if (fCurrentEntity.position == fCurrentEntity.count) {
+                        checkEntityLimit(null, fCurrentEntity, offset, newlines);
                         offset = 0;
                         fCurrentEntity.position = newlines;
                         if (load(newlines, false, true)) {
+                            counted = true;
                             break;
                         }
                     }
@@ -1011,6 +1090,7 @@
             }
             int length = fCurrentEntity.position - offset;
             if (fCurrentEntity.position == fCurrentEntity.count - 1) {
+                checkEntityLimit(null, fCurrentEntity, offset, length);
                 //CHANGED: dont replace the value.. append to the buffer. This gives control to the callee
                 //on buffering the data..
                 content.setValues(fCurrentEntity.ch, offset, length);
@@ -1038,8 +1118,8 @@
         }
         int length = fCurrentEntity.position - offset;
         fCurrentEntity.columnNumber += length - newlines;
-        if (fCurrentEntity.isGE) {
-            checkLimit(Limit.TOTAL_ENTITY_SIZE_LIMIT, fCurrentEntity, offset, length);
+        if (!counted) {
+            checkEntityLimit(null, fCurrentEntity, offset, length);
         }
 
         //CHANGED: dont replace the value.. append to the buffer. This gives control to the callee
@@ -1086,6 +1166,7 @@
      * @param quote   The quote character that signifies the end of the
      *                attribute value data.
      * @param content The content structure to fill.
+     * @param isNSURI a flag indicating whether the content is a Namespace URI
      *
      * @return Returns the next character on the input, if known. This
      *         value may be -1 but this does <em>note</em> designate
@@ -1094,7 +1175,7 @@
      * @throws IOException  Thrown if i/o error occurs.
      * @throws EOFException Thrown on end of file.
      */
-    public int scanLiteral(int quote, XMLString content)
+    protected int scanLiteral(int quote, XMLString content, boolean isNSURI)
     throws IOException {
         if (DEBUG_BUFFER) {
             System.out.print("(scanLiteral, '"+(char)quote+"': ");
@@ -1205,8 +1286,10 @@
         }
         int length = fCurrentEntity.position - offset;
         fCurrentEntity.columnNumber += length - newlines;
-        if (fCurrentEntity.isGE) {
-            checkLimit(Limit.TOTAL_ENTITY_SIZE_LIMIT, fCurrentEntity, offset, length);
+
+        checkEntityLimit(null, fCurrentEntity, offset, length);
+        if (isNSURI) {
+            checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, offset, length);
         }
         content.setValues(fCurrentEntity.ch, offset, length);
 
@@ -1273,7 +1356,7 @@
      * @throws IOException  Thrown if i/o error occurs.
      * @throws EOFException Thrown on end of file.
      */
-    public boolean scanData(String delimiter, XMLStringBuffer buffer)
+    protected boolean scanData(String delimiter, XMLStringBuffer buffer)
     throws IOException {
 
         boolean done = false;
@@ -1311,6 +1394,7 @@
             if (fCurrentEntity.position > fCurrentEntity.count - delimLen) {
                 // something must be wrong with the input:  e.g., file ends in an unterminated comment
                 int length = fCurrentEntity.count - fCurrentEntity.position;
+                checkEntityLimit(NameType.COMMENT, fCurrentEntity, fCurrentEntity.position, length);
                 buffer.append (fCurrentEntity.ch, fCurrentEntity.position, length);
                 fCurrentEntity.columnNumber += fCurrentEntity.count;
                 fCurrentEntity.baseCharOffset += (fCurrentEntity.position - fCurrentEntity.startPosition);
@@ -1373,6 +1457,7 @@
                 }
                 int length = fCurrentEntity.position - offset;
                 if (fCurrentEntity.position == fCurrentEntity.count - 1) {
+                    checkEntityLimit(NameType.COMMENT, fCurrentEntity, offset, length);
                     buffer.append(fCurrentEntity.ch, offset, length);
                     if (DEBUG_BUFFER) {
                         System.out.print("]newline, "+offset+", "+fCurrentEntity.position+": ");
@@ -1416,12 +1501,14 @@
                     fCurrentEntity.position--;
                     int length = fCurrentEntity.position - offset;
                     fCurrentEntity.columnNumber += length - newlines;
+                    checkEntityLimit(NameType.COMMENT, fCurrentEntity, offset, length);
                     buffer.append(fCurrentEntity.ch, offset, length);
                     return true;
                 }
             }
             int length = fCurrentEntity.position - offset;
             fCurrentEntity.columnNumber += length - newlines;
+            checkEntityLimit(NameType.COMMENT, fCurrentEntity, offset, length);
             if (done) {
                 length -= delimLen;
             }
@@ -1445,13 +1532,14 @@
      * the specified character.
      *
      * @param c The character to skip.
+     * @param nt The type of the name (element or attribute)
      *
      * @return Returns true if the character was skipped.
      *
      * @throws IOException  Thrown if i/o error occurs.
      * @throws EOFException Thrown on end of file.
      */
-    public boolean skipChar(int c) throws IOException {
+    protected boolean skipChar(int c, NameType nt) throws IOException {
         if (DEBUG_BUFFER) {
             System.out.print("(skipChar, '"+(char)c+"': ");
             print();
@@ -1464,6 +1552,7 @@
         }
 
         // skip character
+        int offset = fCurrentEntity.position;
         int cc = fCurrentEntity.ch[fCurrentEntity.position];
         if (cc == c) {
             fCurrentEntity.position++;
@@ -1478,6 +1567,7 @@
                 print();
                 System.out.println(" -> true");
             }
+            checkEntityLimit(nt, fCurrentEntity, offset, fCurrentEntity.position - offset);
             return true;
         } else if (c == '\n' && cc == '\r' && isExternal) {
             // handle newlines
@@ -1497,6 +1587,7 @@
                 print();
                 System.out.println(" -> true");
             }
+            checkEntityLimit(nt, fCurrentEntity, offset, fCurrentEntity.position - offset);
             return true;
         }
 
@@ -1526,7 +1617,7 @@
      *
      * @see com.sun.org.apache.xerces.internal.util.XMLChar#isSpace
      */
-    public boolean skipSpaces() throws IOException {
+    protected boolean skipSpaces() throws IOException {
         if (DEBUG_BUFFER) {
             System.out.print("(skipSpaces: ");
             print();
@@ -1550,6 +1641,7 @@
 
         // skip spaces
         int c = fCurrentEntity.ch[fCurrentEntity.position];
+        int offset = fCurrentEntity.position - 1;
         if (XMLChar.isSpace(c)) {
             do {
                 boolean entityChanged = false;
@@ -1579,6 +1671,11 @@
                 } else {
                     fCurrentEntity.columnNumber++;
                 }
+
+                //If this is a general entity, spaces within a start element should be counted
+                checkEntityLimit(null, fCurrentEntity, offset, fCurrentEntity.position - offset);
+                offset = fCurrentEntity.position;
+
                 // load more characters, if needed
                 if (!entityChanged){
                     fCurrentEntity.position++;
@@ -1620,7 +1717,7 @@
 
 
     /**
-     * @param legnth This function checks that following number of characters are available.
+     * @param length This function checks that following number of characters are available.
      * to the underlying buffer.
      * @return This function returns true if capacity asked is available.
      */
@@ -1629,9 +1726,9 @@
     }
 
     /**
-     * @param legnth This function checks that following number of characters are available.
+     * @param length This function checks that following number of characters are available.
      * to the underlying buffer.
-     * @param if the underlying function should change the entity
+     * @param changeEntity a flag to indicate that the underlying function should change the entity
      * @return This function returns true if capacity asked is available.
      *
      */
@@ -1694,7 +1791,7 @@
      * @throws IOException  Thrown if i/o error occurs.
      * @throws EOFException Thrown on end of file.
      */
-    public boolean skipString(String s) throws IOException {
+    protected boolean skipString(String s) throws IOException {
 
         final int length = s.length();
 
@@ -1714,6 +1811,9 @@
                 if(afterSkip-- == beforeSkip){
                     fCurrentEntity.position = fCurrentEntity.position + length ;
                     fCurrentEntity.columnNumber += length;
+                    if (!detectingVersion) {
+                        checkEntityLimit(null, fCurrentEntity, beforeSkip, length);
+                    }
                     return true;
                 }
             }
@@ -1722,7 +1822,7 @@
         return false;
     } // skipString(String):boolean
 
-    public boolean skipString(char [] s) throws IOException {
+    protected boolean skipString(char [] s) throws IOException {
 
         final int length = s.length;
         //first make sure that required capacity is avaible
@@ -1742,6 +1842,9 @@
             }
             fCurrentEntity.position = fCurrentEntity.position + length ;
             fCurrentEntity.columnNumber += length;
+            if (!detectingVersion) {
+                checkEntityLimit(null, fCurrentEntity, beforeSkip, length);
+            }
             return true;
 
         }
@@ -2139,7 +2242,7 @@
      *
      * @see com.sun.org.apache.xerces.internal.util.XMLChar#isSpace
      */
-    public final boolean skipDeclSpaces() throws IOException {
+    protected final boolean skipDeclSpaces() throws IOException {
         if (DEBUG_BUFFER) {
             System.out.print("(skipDeclSpaces: ");
             //XMLEntityManager.print(fCurrentEntity);
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java
index 7853357..264b908 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*
@@ -25,8 +25,6 @@
 import com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidatorFilter;
 import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
 import com.sun.org.apache.xerces.internal.util.XMLAttributesImpl;
-import com.sun.org.apache.xerces.internal.util.XMLAttributesIteratorImpl;
-import com.sun.org.apache.xerces.internal.util.XMLStringBuffer;
 import com.sun.org.apache.xerces.internal.util.XMLSymbols;
 import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
 import com.sun.org.apache.xerces.internal.xni.QName;
@@ -34,13 +32,9 @@
 import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
 import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
-import com.sun.org.apache.xerces.internal.xni.XMLAttributes;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource;
-import com.sun.org.apache.xerces.internal.util.XMLAttributesImpl;
 import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
 
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamConstants;
 import javax.xml.stream.events.XMLEvent;
 
 /**
@@ -196,9 +190,9 @@
             // There are two variables,fNamespaces and fBindNamespaces
             //StAX uses XMLNSDocumentScannerImpl so this distinction needs to be maintained
             if (fNamespaces) {
-                fEntityScanner.scanQName(fElementQName);
+                fEntityScanner.scanQName(fElementQName, NameType.ELEMENTSTART);
             } else {
-                String name = fEntityScanner.scanName();
+                String name = fEntityScanner.scanName(NameType.ELEMENTSTART);
                 fElementQName.setValues(null, name, name, null);
             }
 
@@ -411,11 +405,11 @@
         if (DEBUG_START_END_ELEMENT) System.out.println(this.getClass().toString() +">>> scanAttribute()");
 
         // name
-        fEntityScanner.scanQName(fAttributeQName);
+        fEntityScanner.scanQName(fAttributeQName, NameType.ATTRIBUTE);
 
         // equals
         fEntityScanner.skipSpaces();
-        if (!fEntityScanner.skipChar('=')) {
+        if (!fEntityScanner.skipChar('=', NameType.ATTRIBUTE)) {
             reportFatalError("EqRequiredInAttribute",
                     new Object[]{fCurrentElement.rawname,fAttributeQName.rawname});
         }
@@ -437,23 +431,28 @@
         //since scanAttributeValue doesn't use attIndex parameter therefore we
         //can safely add the attribute later..
         XMLString tmpStr = getString();
-        scanAttributeValue(tmpStr, fTempString2,
-                fAttributeQName.rawname, attributes,
-                attrIndex, isVC, fCurrentElement.rawname);
+
+        /**
+         * Determine whether this is a namespace declaration that will be subject
+         * to the name limit check in the scanAttributeValue operation.
+         * Namespace declaration format: xmlns="..." or xmlns:prefix="..."
+         * Note that prefix:xmlns="..." isn't a namespace.
+         */
+        String localpart = fAttributeQName.localpart;
+        String prefix = fAttributeQName.prefix != null
+                ? fAttributeQName.prefix : XMLSymbols.EMPTY_STRING;
+        boolean isNSDecl = fBindNamespaces & (prefix == XMLSymbols.PREFIX_XMLNS ||
+                    prefix == XMLSymbols.EMPTY_STRING && localpart == XMLSymbols.PREFIX_XMLNS);
+
+        scanAttributeValue(tmpStr, fTempString2, fAttributeQName.rawname, attributes,
+                attrIndex, isVC, fCurrentElement.rawname, isNSDecl);
 
         String value = null;
         //fTempString.toString();
 
         // record namespace declarations if any.
         if (fBindNamespaces) {
-
-            String localpart = fAttributeQName.localpart;
-            String prefix = fAttributeQName.prefix != null
-                    ? fAttributeQName.prefix : XMLSymbols.EMPTY_STRING;
-            // when it's of form xmlns="..." or xmlns:prefix="...",
-            // it's a namespace declaration. but prefix:xmlns="..." isn't.
-            if (prefix == XMLSymbols.PREFIX_XMLNS ||
-                    prefix == XMLSymbols.EMPTY_STRING && localpart == XMLSymbols.PREFIX_XMLNS) {
+            if (isNSDecl) {
                 //check the length of URI
                 if (tmpStr.length > fXMLNameLimit) {
                     fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java
index 0b8fb90..7645cce 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*
@@ -25,7 +25,6 @@
 import com.sun.xml.internal.stream.XMLEntityStorage;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.HashMap;
 import javax.xml.stream.events.XMLEvent;
 import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
 import com.sun.org.apache.xerces.internal.util.SymbolTable;
@@ -116,13 +115,37 @@
     /** Debug attribute normalization. */
     protected static final boolean DEBUG_ATTR_NORMALIZATION = false;
 
+    /**
+     * Type of names
+     */
+    public static enum NameType {
+        ATTRIBUTE("attribute"),
+        ATTRIBUTENAME("attribute name"),
+        COMMENT("comment"),
+        DOCTYPE("doctype"),
+        ELEMENTSTART("startelement"),
+        ELEMENTEND("endelement"),
+        ENTITY("entity"),
+        NOTATION("notation"),
+        PI("pi"),
+        REFERENCE("reference");
+
+        final String literal;
+        NameType(String literal) {
+            this.literal = literal;
+        }
+
+        String literal() {
+            return literal;
+        }
+    }
 
     //xxx: setting the default value as false, as we dont need to calculate this value
     //we should have a feature when set to true computes this value
     private boolean fNeedNonNormalizedValue = false;
 
-    protected ArrayList attributeValueCache = new ArrayList();
-    protected ArrayList stringBufferCache = new ArrayList();
+    protected ArrayList<XMLString> attributeValueCache = new ArrayList<>();
+    protected ArrayList<XMLStringBuffer> stringBufferCache = new ArrayList<>();
     protected int fStringBufferIndex = 0;
     protected boolean fAttributeCacheInitDone = false;
     protected int fAttributeCacheUsedCount = 0;
@@ -146,7 +169,7 @@
     protected boolean fNotifyCharRefs = false;
 
     /** Internal parser-settings feature */
-        protected boolean fParserSettings = true;
+    protected boolean fParserSettings = true;
 
     // properties
 
@@ -175,13 +198,13 @@
     /** event type */
     protected XMLEvent fEvent ;
 
-    /** Entity scanner, this alwasy works on last entity that was opened. */
+    /** Entity scanner, this always works on last entity that was opened. */
     protected XMLEntityScanner fEntityScanner = null;
 
     /** Entity depth. */
     protected int fEntityDepth;
 
-    /** Literal value of the last character refence scanned. */
+    /** Literal value of the last character reference scanned. */
     protected String fCharRefLiteral = null;
 
     /** Scanning attribute. */
@@ -549,10 +572,10 @@
         }
 
         // end
-        if (!fEntityScanner.skipChar('?')) {
+        if (!fEntityScanner.skipChar('?', null)) {
             reportFatalError("XMLDeclUnterminated", null);
         }
-        if (!fEntityScanner.skipChar('>')) {
+        if (!fEntityScanner.skipChar('>', null)) {
             reportFatalError("XMLDeclUnterminated", null);
 
         }
@@ -579,7 +602,7 @@
      * <strong>Note:</strong> This method uses fStringBuffer2, anything in it
      * at the time of calling is lost.
      */
-    public String scanPseudoAttribute(boolean scanningTextDecl,
+    protected String scanPseudoAttribute(boolean scanningTextDecl,
             XMLString value)
             throws IOException, XNIException {
 
@@ -590,7 +613,7 @@
             reportFatalError("PseudoAttrNameExpected", null);
         }
         fEntityScanner.skipSpaces();
-        if (!fEntityScanner.skipChar('=')) {
+        if (!fEntityScanner.skipChar('=', null)) {
             reportFatalError(scanningTextDecl ? "EqRequiredInTextDecl"
                     : "EqRequiredInXMLDecl", new Object[]{name});
         }
@@ -600,15 +623,15 @@
             reportFatalError(scanningTextDecl ? "QuoteRequiredInTextDecl"
                     : "QuoteRequiredInXMLDecl" , new Object[]{name});
         }
-        fEntityScanner.scanChar();
-        int c = fEntityScanner.scanLiteral(quote, value);
+        fEntityScanner.scanChar(NameType.ATTRIBUTE);
+        int c = fEntityScanner.scanLiteral(quote, value, false);
         if (c != quote) {
             fStringBuffer2.clear();
             do {
                 fStringBuffer2.append(value);
                 if (c != -1) {
                     if (c == '&' || c == '%' || c == '<' || c == ']') {
-                        fStringBuffer2.append((char)fEntityScanner.scanChar());
+                        fStringBuffer2.append((char)fEntityScanner.scanChar(NameType.ATTRIBUTE));
                     } else if (XMLChar.isHighSurrogate(c)) {
                         scanSurrogates(fStringBuffer2);
                     } else if (isInvalidLiteral(c)) {
@@ -616,15 +639,15 @@
                                 ? "InvalidCharInTextDecl" : "InvalidCharInXMLDecl";
                         reportFatalError(key,
                                 new Object[] {Integer.toString(c, 16)});
-                                fEntityScanner.scanChar();
+                                fEntityScanner.scanChar(null);
                     }
                 }
-                c = fEntityScanner.scanLiteral(quote, value);
+                c = fEntityScanner.scanLiteral(quote, value, false);
             } while (c != quote);
             fStringBuffer2.append(value);
             value.setValues(fStringBuffer2);
         }
-        if (!fEntityScanner.skipChar(quote)) {
+        if (!fEntityScanner.skipChar(quote, null)) {
             reportFatalError(scanningTextDecl ? "CloseQuoteMissingInTextDecl"
                     : "CloseQuoteMissingInXMLDecl",
                     new Object[]{name});
@@ -682,7 +705,7 @@
 
         // target
         fReportEntity = false;
-        String target = fEntityScanner.scanName();
+        String target = fEntityScanner.scanName(NameType.PI);
         if (target == null) {
             reportFatalError("PITargetRequired", null);
         }
@@ -747,7 +770,7 @@
                     } else if (isInvalidLiteral(c)) {
                         reportFatalError("InvalidCharInPI",
                                 new Object[]{Integer.toHexString(c)});
-                                fEntityScanner.scanChar();
+                                fEntityScanner.scanChar(null);
                     }
                 }
             } while (fEntityScanner.scanData("?>", data));
@@ -785,14 +808,14 @@
                 if (XMLChar.isHighSurrogate(c)) {
                     scanSurrogates(text);
                 }
-                if (isInvalidLiteral(c)) {
+                else if (isInvalidLiteral(c)) {
                     reportFatalError("InvalidCharInComment",
                             new Object[] { Integer.toHexString(c) });
-                            fEntityScanner.scanChar();
+                            fEntityScanner.scanChar(NameType.COMMENT);
                 }
             }
         }
-        if (!fEntityScanner.skipChar('>')) {
+        if (!fEntityScanner.skipChar('>', NameType.COMMENT)) {
             reportFatalError("DashDashInComment", null);
         }
 
@@ -813,15 +836,14 @@
      * @param checkEntities true if undeclared entities should be reported as VC violation,
      *                      false if undeclared entities should be reported as WFC violation.
      * @param eleName The name of element to which this attribute belongs.
+     * @param isNSURI a flag indicating whether the content is a Namespace URI
      *
      * <strong>Note:</strong> This method uses fStringBuffer2, anything in it
      * at the time of calling is lost.
      **/
-    protected void scanAttributeValue(XMLString value,
-            XMLString nonNormalizedValue,
-            String atName,
-            XMLAttributes attributes, int attrIndex,
-            boolean checkEntities, String eleName)
+    protected void scanAttributeValue(XMLString value, XMLString nonNormalizedValue,
+            String atName, XMLAttributes attributes, int attrIndex, boolean checkEntities,
+            String eleName, boolean isNSURI)
             throws IOException, XNIException {
         XMLStringBuffer stringBuffer = null;
         // quote
@@ -830,10 +852,10 @@
             reportFatalError("OpenQuoteExpected", new Object[]{eleName, atName});
         }
 
-        fEntityScanner.scanChar();
+        fEntityScanner.scanChar(NameType.ATTRIBUTE);
         int entityDepth = fEntityDepth;
 
-        int c = fEntityScanner.scanLiteral(quote, value);
+        int c = fEntityScanner.scanLiteral(quote, value, isNSURI);
         if (DEBUG_ATTR_NORMALIZATION) {
             System.out.println("** scanLiteral -> \""
                     + value.toString() + "\"");
@@ -859,11 +881,11 @@
                             + stringBuffer.toString() + "\"");
                 }
                 if (c == '&') {
-                    fEntityScanner.skipChar('&');
+                    fEntityScanner.skipChar('&', NameType.REFERENCE);
                     if (entityDepth == fEntityDepth && fNeedNonNormalizedValue ) {
                         fStringBuffer2.append('&');
                     }
-                    if (fEntityScanner.skipChar('#')) {
+                    if (fEntityScanner.skipChar('#', NameType.REFERENCE)) {
                         if (entityDepth == fEntityDepth && fNeedNonNormalizedValue ) {
                             fStringBuffer2.append('#');
                         }
@@ -881,53 +903,20 @@
                             }
                         }
                     } else {
-                        String entityName = fEntityScanner.scanName();
+                        String entityName = fEntityScanner.scanName(NameType.ENTITY);
                         if (entityName == null) {
                             reportFatalError("NameRequiredInReference", null);
                         } else if (entityDepth == fEntityDepth && fNeedNonNormalizedValue) {
                             fStringBuffer2.append(entityName);
                         }
-                        if (!fEntityScanner.skipChar(';')) {
+                        if (!fEntityScanner.skipChar(';', NameType.REFERENCE)) {
                             reportFatalError("SemicolonRequiredInReference",
                                     new Object []{entityName});
                         } else if (entityDepth == fEntityDepth && fNeedNonNormalizedValue) {
                             fStringBuffer2.append(';');
                         }
-                        if (entityName == fAmpSymbol) {
-                            stringBuffer.append('&');
-                            if (DEBUG_ATTR_NORMALIZATION) {
-                                System.out.println("** value5: \""
-                                        + stringBuffer.toString()
-                                        + "\"");
-                            }
-                        } else if (entityName == fAposSymbol) {
-                            stringBuffer.append('\'');
-                            if (DEBUG_ATTR_NORMALIZATION) {
-                                System.out.println("** value7: \""
-                                        + stringBuffer.toString()
-                                        + "\"");
-                            }
-                        } else if (entityName == fLtSymbol) {
-                            stringBuffer.append('<');
-                            if (DEBUG_ATTR_NORMALIZATION) {
-                                System.out.println("** value9: \""
-                                        + stringBuffer.toString()
-                                        + "\"");
-                            }
-                        } else if (entityName == fGtSymbol) {
-                            stringBuffer.append('>');
-                            if (DEBUG_ATTR_NORMALIZATION) {
-                                System.out.println("** valueB: \""
-                                        + stringBuffer.toString()
-                                        + "\"");
-                            }
-                        } else if (entityName == fQuotSymbol) {
-                            stringBuffer.append('"');
-                            if (DEBUG_ATTR_NORMALIZATION) {
-                                System.out.println("** valueD: \""
-                                        + stringBuffer.toString()
-                                        + "\"");
-                            }
+                        if (resolveCharacter(entityName, stringBuffer)) {
+                            checkEntityLimit(false, fEntityScanner.fCurrentEntity.name, 1);
                         } else {
                             if (fEntityStore.isExternalEntity(entityName)) {
                                 reportFatalError("ReferenceToExternalEntity",
@@ -954,12 +943,12 @@
                 } else if (c == '<') {
                     reportFatalError("LessthanInAttValue",
                             new Object[] { eleName, atName });
-                            fEntityScanner.scanChar();
+                            fEntityScanner.scanChar(null);
                             if (entityDepth == fEntityDepth && fNeedNonNormalizedValue) {
                                 fStringBuffer2.append((char)c);
                             }
                 } else if (c == '%' || c == ']') {
-                    fEntityScanner.scanChar();
+                    fEntityScanner.scanChar(null);
                     stringBuffer.append((char)c);
                     if (entityDepth == fEntityDepth && fNeedNonNormalizedValue) {
                         fStringBuffer2.append((char)c);
@@ -969,7 +958,7 @@
                                 + stringBuffer.toString() + "\"");
                     }
                 } else if (c == '\n' || c == '\r') {
-                    fEntityScanner.scanChar();
+                    fEntityScanner.scanChar(null);
                     stringBuffer.append(' ');
                     if (entityDepth == fEntityDepth && fNeedNonNormalizedValue) {
                         fStringBuffer2.append('\n');
@@ -990,12 +979,12 @@
                 } else if (c != -1 && isInvalidLiteral(c)) {
                     reportFatalError("InvalidCharInAttValue",
                             new Object[] {eleName, atName, Integer.toString(c, 16)});
-                            fEntityScanner.scanChar();
+                            fEntityScanner.scanChar(null);
                             if (entityDepth == fEntityDepth && fNeedNonNormalizedValue) {
                                 fStringBuffer2.append((char)c);
                             }
                 }
-                c = fEntityScanner.scanLiteral(quote, value);
+                c = fEntityScanner.scanLiteral(quote, value, isNSURI);
                 if (entityDepth == fEntityDepth && fNeedNonNormalizedValue) {
                     fStringBuffer2.append(value);
                 }
@@ -1016,7 +1005,7 @@
             nonNormalizedValue.setValues(fStringBuffer2);
 
         // quote
-        int cquote = fEntityScanner.scanChar();
+        int cquote = fEntityScanner.scanChar(NameType.ATTRIBUTE);
         if (cquote != quote) {
             reportFatalError("CloseQuoteExpected", new Object[]{eleName, atName});
         }
@@ -1024,6 +1013,39 @@
 
 
     /**
+     * Resolves character entity references.
+     * @param entityName the name of the entity
+     * @param stringBuffer the current XMLStringBuffer to append the character to.
+     * @return true if resolved, false otherwise
+     */
+    protected boolean resolveCharacter(String entityName, XMLStringBuffer stringBuffer) {
+        /**
+         * entityNames (symbols) are interned. The equals method would do the same,
+         * but I'm leaving it as comparisons by references are common in the impl
+         * and it made it explicit to others who read this code.
+         */
+        if (entityName == fAmpSymbol) {
+            stringBuffer.append('&');
+            return true;
+        } else if (entityName == fAposSymbol) {
+            stringBuffer.append('\'');
+            return true;
+        } else if (entityName == fLtSymbol) {
+            stringBuffer.append('<');
+            return true;
+        } else if (entityName == fGtSymbol) {
+            checkEntityLimit(false, fEntityScanner.fCurrentEntity.name, 1);
+            stringBuffer.append('>');
+            return true;
+        } else if (entityName == fQuotSymbol) {
+            checkEntityLimit(false, fEntityScanner.fCurrentEntity.name, 1);
+            stringBuffer.append('"');
+            return true;
+        }
+        return false;
+    }
+
+    /**
      * Scans External ID and return the public and system IDs.
      *
      * @param identifiers An array of size 2 to return the system id,
@@ -1066,25 +1088,25 @@
                 }
                 reportFatalError("QuoteRequiredInSystemID", null);
             }
-            fEntityScanner.scanChar();
+            fEntityScanner.scanChar(null);
             XMLString ident = fString;
-            if (fEntityScanner.scanLiteral(quote, ident) != quote) {
+            if (fEntityScanner.scanLiteral(quote, ident, false) != quote) {
                 fStringBuffer.clear();
                 do {
                     fStringBuffer.append(ident);
                     int c = fEntityScanner.peekChar();
                     if (XMLChar.isMarkup(c) || c == ']') {
-                        fStringBuffer.append((char)fEntityScanner.scanChar());
+                        fStringBuffer.append((char)fEntityScanner.scanChar(null));
                     } else if (c != -1 && isInvalidLiteral(c)) {
                         reportFatalError("InvalidCharInSystemID",
                             new Object[] {Integer.toString(c, 16)});
                     }
-                } while (fEntityScanner.scanLiteral(quote, ident) != quote);
+                } while (fEntityScanner.scanLiteral(quote, ident, false) != quote);
                 fStringBuffer.append(ident);
                 ident = fStringBuffer;
             }
             systemId = ident.toString();
-            if (!fEntityScanner.skipChar(quote)) {
+            if (!fEntityScanner.skipChar(quote, null)) {
                 reportFatalError("SystemIDUnterminated", null);
             }
         }
@@ -1116,7 +1138,7 @@
      */
     protected boolean scanPubidLiteral(XMLString literal)
     throws IOException, XNIException {
-        int quote = fEntityScanner.scanChar();
+        int quote = fEntityScanner.scanChar(null);
         if (quote != '\'' && quote != '"') {
             reportFatalError("QuoteRequiredInPublicID", null);
             return false;
@@ -1127,7 +1149,7 @@
         boolean skipSpace = true;
         boolean dataok = true;
         while (true) {
-            int c = fEntityScanner.scanChar();
+            int c = fEntityScanner.scanChar(null);
             if (c == ' ' || c == '\n' || c == '\r') {
                 if (!skipSpace) {
                     // take the first whitespace as a space and skip the others
@@ -1243,9 +1265,10 @@
      */
     protected int scanCharReferenceValue(XMLStringBuffer buf, XMLStringBuffer buf2)
     throws IOException, XNIException {
+        int initLen = buf.length;
         // scan hexadecimal value
         boolean hex = false;
-        if (fEntityScanner.skipChar('x')) {
+        if (fEntityScanner.skipChar('x', NameType.REFERENCE)) {
             if (buf2 != null) { buf2.append('x'); }
             hex = true;
             fStringBuffer3.clear();
@@ -1257,7 +1280,7 @@
                     (c >= 'A' && c <= 'F');
             if (digit) {
                 if (buf2 != null) { buf2.append((char)c); }
-                fEntityScanner.scanChar();
+                fEntityScanner.scanChar(NameType.REFERENCE);
                 fStringBuffer3.append((char)c);
 
                 do {
@@ -1267,7 +1290,7 @@
                             (c >= 'A' && c <= 'F');
                     if (digit) {
                         if (buf2 != null) { buf2.append((char)c); }
-                        fEntityScanner.scanChar();
+                        fEntityScanner.scanChar(NameType.REFERENCE);
                         fStringBuffer3.append((char)c);
                     }
                 } while (digit);
@@ -1285,7 +1308,7 @@
             digit = c >= '0' && c <= '9';
             if (digit) {
                 if (buf2 != null) { buf2.append((char)c); }
-                fEntityScanner.scanChar();
+                fEntityScanner.scanChar(NameType.REFERENCE);
                 fStringBuffer3.append((char)c);
 
                 do {
@@ -1293,7 +1316,7 @@
                     digit = c >= '0' && c <= '9';
                     if (digit) {
                         if (buf2 != null) { buf2.append((char)c); }
-                        fEntityScanner.scanChar();
+                        fEntityScanner.scanChar(NameType.REFERENCE);
                         fStringBuffer3.append((char)c);
                     }
                 } while (digit);
@@ -1303,7 +1326,7 @@
         }
 
         // end
-        if (!fEntityScanner.skipChar(';')) {
+        if (!fEntityScanner.skipChar(';', NameType.REFERENCE)) {
             reportFatalError("SemicolonRequiredInCharRef", null);
         }
         if (buf2 != null) { buf2.append(';'); }
@@ -1349,6 +1372,9 @@
             }
         }
 
+        if (fEntityScanner.fCurrentEntity.isGE) {
+            checkEntityLimit(false, fEntityScanner.fCurrentEntity.name, buf.length - initLen);
+        }
         return value;
     }
     // returns true if the given character is not
@@ -1386,6 +1412,14 @@
         return (XMLChar.isNameStart(value));
     } // isValidNameStartChar(int):  boolean
 
+    // returns true if the given character is
+    // a valid high surrogate for a nameStartChar
+    // with respect to the version of XML understood
+    // by this scanner.
+    protected boolean isValidNameStartHighSurrogate(int value) {
+        return false;
+    } // isValidNameStartHighSurrogate(int):  boolean
+
     protected boolean versionSupported(String version ) {
         return version.equals("1.0") || version.equals("1.1");
     } // version Supported
@@ -1402,14 +1436,14 @@
     protected boolean scanSurrogates(XMLStringBuffer buf)
     throws IOException, XNIException {
 
-        int high = fEntityScanner.scanChar();
+        int high = fEntityScanner.scanChar(null);
         int low = fEntityScanner.peekChar();
         if (!XMLChar.isLowSurrogate(low)) {
             reportFatalError("InvalidCharInContent",
                     new Object[] {Integer.toString(high, 16)});
                     return false;
         }
-        fEntityScanner.scanChar();
+        fEntityScanner.scanChar(null);
 
         // convert surrogates to supplemental character
         int c = XMLChar.supplemental((char)high, (char)low);
@@ -1463,7 +1497,7 @@
 
     XMLStringBuffer getStringBuffer(){
         if((fStringBufferIndex < initialCacheCount )|| (fStringBufferIndex < stringBufferCache.size())){
-            return (XMLStringBuffer)stringBufferCache.get(fStringBufferIndex++);
+            return stringBufferCache.get(fStringBufferIndex++);
         }else{
             XMLStringBuffer tmpObj = new XMLStringBuffer();
             fStringBufferIndex++;
@@ -1472,5 +1506,52 @@
         }
     }
 
+    /**
+     * Add the count of the content buffer and check if the accumulated
+     * value exceeds the limit
+     * @param isPEDecl a flag to indicate whether the entity is parameter
+     * @param entityName entity name
+     * @param buffer content buffer
+     */
+    void checkEntityLimit(boolean isPEDecl, String entityName, XMLString buffer) {
+        checkEntityLimit(isPEDecl, entityName, buffer.length);
+    }
 
+    /**
+     * Add the count and check limit
+     * @param isPEDecl a flag to indicate whether the entity is parameter
+     * @param entityName entity name
+     * @param len length of the buffer
+     */
+    void checkEntityLimit(boolean isPEDecl, String entityName, int len) {
+        if (fLimitAnalyzer == null) {
+            fLimitAnalyzer = fEntityManager.fLimitAnalyzer;
+        }
+        if (isPEDecl) {
+            fLimitAnalyzer.addValue(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT, "%" + entityName, len);
+            if (fSecurityManager.isOverLimit(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT, fLimitAnalyzer)) {
+                        fSecurityManager.debugPrint(fLimitAnalyzer);
+                reportFatalError("MaxEntitySizeLimit", new Object[]{"%" + entityName,
+                    fLimitAnalyzer.getValue(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT),
+                    fSecurityManager.getLimit(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT),
+                    fSecurityManager.getStateLiteral(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT)});
+            }
+        } else {
+            fLimitAnalyzer.addValue(XMLSecurityManager.Limit.GENERAL_ENTITY_SIZE_LIMIT, entityName, len);
+            if (fSecurityManager.isOverLimit(XMLSecurityManager.Limit.GENERAL_ENTITY_SIZE_LIMIT, fLimitAnalyzer)) {
+                        fSecurityManager.debugPrint(fLimitAnalyzer);
+                reportFatalError("MaxEntitySizeLimit", new Object[]{entityName,
+                    fLimitAnalyzer.getValue(XMLSecurityManager.Limit.GENERAL_ENTITY_SIZE_LIMIT),
+                    fSecurityManager.getLimit(XMLSecurityManager.Limit.GENERAL_ENTITY_SIZE_LIMIT),
+                    fSecurityManager.getStateLiteral(XMLSecurityManager.Limit.GENERAL_ENTITY_SIZE_LIMIT)});
+            }
+        }
+        if (fSecurityManager.isOverLimit(XMLSecurityManager.Limit.TOTAL_ENTITY_SIZE_LIMIT, fLimitAnalyzer)) {
+            fSecurityManager.debugPrint(fLimitAnalyzer);
+            reportFatalError("TotalEntitySizeLimit",
+                new Object[]{fLimitAnalyzer.getTotalValue(XMLSecurityManager.Limit.TOTAL_ENTITY_SIZE_LIMIT),
+                fSecurityManager.getLimit(XMLSecurityManager.Limit.TOTAL_ENTITY_SIZE_LIMIT),
+                fSecurityManager.getStateLiteral(XMLSecurityManager.Limit.TOTAL_ENTITY_SIZE_LIMIT)});
+        }
+    }
 } // class XMLScanner
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLVersionDetector.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLVersionDetector.java
index 437cc30..a7ab027 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLVersionDetector.java
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLVersionDetector.java
@@ -1,62 +1,21 @@
 /*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  */
 /*
- * The Apache Software License, Version 1.1
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
- * Copyright (c) 1999-2003 The Apache Software Foundation.
- * 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. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Xerces" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 APACHE SOFTWARE FOUNDATION OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 2003, International
- * Business Machines, Inc., http://www.apache.org.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
+ * 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 the License for the specific language governing permissions and
+ * limitations under the License.
  */
 
 package com.sun.org.apache.xerces.internal.impl;
@@ -192,40 +151,46 @@
         // in the XML declaration.
         fEntityManager.setScannerVersion(Constants.XML_VERSION_1_0);
         XMLEntityScanner scanner = fEntityManager.getEntityScanner();
+        scanner.detectingVersion = true;
         try {
             if (!scanner.skipString("<?xml")) {
                 // definitely not a well-formed 1.1 doc!
+                scanner.detectingVersion = false;
                 return Constants.XML_VERSION_1_0;
             }
             if (!scanner.skipDeclSpaces()) {
                 fixupCurrentEntity(fEntityManager, fExpectedVersionString, 5);
+                scanner.detectingVersion = false;
                 return Constants.XML_VERSION_1_0;
             }
             if (!scanner.skipString("version")) {
                 fixupCurrentEntity(fEntityManager, fExpectedVersionString, 6);
+                scanner.detectingVersion = false;
                 return Constants.XML_VERSION_1_0;
             }
             scanner.skipDeclSpaces();
             // Check if the next character is '='. If it is then consume it.
             if (scanner.peekChar() != '=') {
                 fixupCurrentEntity(fEntityManager, fExpectedVersionString, 13);
+                scanner.detectingVersion = false;
                 return Constants.XML_VERSION_1_0;
             }
-            scanner.scanChar();
+            scanner.scanChar(null);
             scanner.skipDeclSpaces();
-            int quoteChar = scanner.scanChar();
+            int quoteChar = scanner.scanChar(null);
             fExpectedVersionString[14] = (char) quoteChar;
             for (int versionPos = 0; versionPos < XML11_VERSION.length; versionPos++) {
-                fExpectedVersionString[15 + versionPos] = (char) scanner.scanChar();
+                fExpectedVersionString[15 + versionPos] = (char) scanner.scanChar(null);
             }
             // REVISIT:  should we check whether this equals quoteChar?
-            fExpectedVersionString[18] = (char) scanner.scanChar();
+            fExpectedVersionString[18] = (char) scanner.scanChar(null);
             fixupCurrentEntity(fEntityManager, fExpectedVersionString, 19);
             int matched = 0;
             for (; matched < XML11_VERSION.length; matched++) {
                 if (fExpectedVersionString[15 + matched] != XML11_VERSION[matched])
                     break;
             }
+            scanner.detectingVersion = false;
             if (matched == XML11_VERSION.length)
                 return Constants.XML_VERSION_1_1;
             return Constants.XML_VERSION_1_0;
@@ -237,10 +202,9 @@
                 "PrematureEOF",
                 null,
                 XMLErrorReporter.SEVERITY_FATAL_ERROR);
+            scanner.detectingVersion = false;
             return Constants.XML_VERSION_1_0;
-
         }
-
     }
 
     // This method prepends "length" chars from the char array,
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_zh_TW.properties b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_zh_TW.properties
index 675be50..2cb7ffe 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_zh_TW.properties
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/DatatypeMessages_zh_TW.properties
@@ -9,9 +9,9 @@
 FieldCannotBeNull=\u7121\u6CD5\u4F7F\u7528 ''null'' \u53C3\u6578\u547C\u53EB {0}
 UnknownField=\u4F7F\u7528\u4E0D\u660E\u7684\u6B04\u4F4D\u547C\u53EB {0}:{1}
 #There are two similar keys 'InvalidXMLGreogorianCalendarValue' . Suffix (year, month) has been added and are used as per the context.
-InvalidXGCValue-milli=\u5E74 = {0}\u3001\u6708 = {1}\uFF0C\u65E5 = {2}\uFF0C\u5C0F\u6642 = {3}\uFF0C\u5206\u9418\uFF0C = {4}\uFF0C\u79D2 = {5}\uFF0C\u5C0F\u6578\u79D2 = {6}\uFF0C\u6642\u5340\uFF0C = {7}\uFF0C\u4E0D\u662F XML \u516C\u66C6\u503C\u7684\u6709\u6548\u8868\u793A\u6CD5\u3002
+InvalidXGCValue-milli=\u5E74 = {0}\u3001\u6708 = {1}\u3001\u65E5 = {2}\u3001\u5C0F\u6642 = {3}\u3001\u5206\u9418 = {4}\u3001\u79D2 = {5}\u3001\u5C0F\u6578\u79D2 = {6}\u3001\u6642\u5340 = {7}\uFF0C\u4E0D\u662F XML \u516C\u66C6\u503C\u7684\u6709\u6548\u8868\u793A\u6CD5\u3002
 #There are two similar keys 'InvalidXMLGreogorianCalendarValue' . Suffix (year, month) has been added and are used as per the context.
-InvalidXGCValue-fractional=\u5E74 = {0}\u3001\u6708 = {1}\uFF0C\u65E5 = {2}\uFF0C\u5C0F\u6642 = {3}\uFF0C\u5206\u9418\uFF0C = {4}\uFF0C\u79D2 = {5}\uFF0C\u5C0F\u6578\u79D2 = {6}\uFF0C\u6642\u5340\uFF0C = {7}\uFF0C\u4E0D\u662F XML \u516C\u66C6\u503C\u7684\u6709\u6548\u8868\u793A\u6CD5\u3002
+InvalidXGCValue-fractional=\u5E74 = {0}\u3001\u6708 = {1}\u3001\u65E5 = {2}\u3001\u5C0F\u6642 = {3}\u3001\u5206\u9418 = {4}\u3001\u79D2 = {5}\u3001\u5C0F\u6578\u79D2 = {6}\u3001\u6642\u5340 = {7}\uFF0C\u4E0D\u662F XML \u516C\u66C6\u503C\u7684\u6709\u6548\u8868\u793A\u6CD5\u3002
 
 InvalidXGCFields=XMLGregorianCalendar \u8A2D\u5B9A\u4E86\u7121\u6548\u7684\u6B04\u4F4D\u96C6
 
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties
index e3cbc5f..c7a23c2 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties
@@ -297,7 +297,8 @@
         EntityExpansionLimit=JAXP00010001: The parser has encountered more than \"{0}\" entity expansions in this document; this is the limit imposed by the JDK.
         ElementAttributeLimit=JAXP00010002:  Element \"{0}\" has more than \"{1}\" attributes, \"{1}\" is the limit imposed by the JDK.
         MaxEntitySizeLimit=JAXP00010003: The length of entity \"{0}\" is \"{1}\" that exceeds the \"{2}\" limit set by \"{3}\".
-        TotalEntitySizeLimit=JAXP00010004: The accumulated size of entities is \"{1}\" that exceeded the \"{2}\" limit set by \"{3}\".
+        TotalEntitySizeLimit=JAXP00010004: The accumulated size of entities is \"{0}\" that exceeded the \"{1}\" limit set by \"{2}\".
         MaxXMLNameLimit=JAXP00010005: The length of entity \"{0}\" is \"{1}\" that exceeds the \"{2}\" limit set by \"{3}\".
         MaxElementDepthLimit=JAXP00010006: The element \"{0}\" has a depth of \"{1}\" that exceeds the limit \"{2}\" set by \"{3}\".
+        EntityReplacementLimit=JAXP00010007: The total number of nodes in entity references is \"{0}\" that is over the limit \"{1}\" set by \"{2}\".
 
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_de.properties b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_de.properties
index ce72953..91ff0dc 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_de.properties
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_de.properties
@@ -297,7 +297,8 @@
         EntityExpansionLimit=JAXP00010001: Der Parser hat mehr als {0} Entityerweiterungen in diesem Dokument gefunden. Dies ist der von JDK vorgeschriebene Grenzwert.
         ElementAttributeLimit=JAXP00010002: Element "{0}" hat mehr als {1} Attribute. "{1}" ist der von JDK vorgeschriebene Grenzwert.
         MaxEntitySizeLimit=JAXP00010003: Die L\u00E4nge von Entity "{0}" ist "{1}" und \u00FCberschreitet den Grenzwert "{2}", der von "{3}" festgelegt wurde.
-        TotalEntitySizeLimit=JAXP00010004: Die akkumulierte Gr\u00F6\u00DFe von Entitys ist "{1}" und \u00FCberschreitet den Grenzwert "{2}", der von "{3}" festgelegt wurde.
+        TotalEntitySizeLimit=JAXP00010004: Die akkumulierte Gr\u00F6\u00DFe von Entitys ist "{0}" und \u00FCberschreitet den Grenzwert "{1}", der von "{2}" festgelegt wurde.
         MaxXMLNameLimit=JAXP00010005: Die L\u00E4nge von Entity "{0}" ist "{1}" und \u00FCberschreitet den Grenzwert "{2}", der von "{3}" festgelegt wurde.
         MaxElementDepthLimit=JAXP00010006: Die Tiefe von Element "{0}" ist "{1}" und \u00FCberschreitet den Grenzwert "{2}", der von "{3}" festgelegt wurde.
+        EntityReplacementLimit=JAXP00010007: Die Gesamtanzahl von Knoten in Entityreferenzen betr\u00E4gt "{0}". Das liegt \u00FCber dem von "{2}" festgelegten Grenzwert "{1}".
 
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_es.properties b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_es.properties
index d784122..9c4d5b0 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_es.properties
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_es.properties
@@ -297,7 +297,8 @@
         EntityExpansionLimit=JAXP00010001: el analizador ha encontrado m\u00E1s de "{0}"ampliaciones de entidad en este documento; \u00E9ste es el l\u00EDmite impuesto por el JDK.
         ElementAttributeLimit=JAXP00010002: el elemento "{0}" tiene m\u00E1s de "{1}" atributos, "{1}" es el l\u00EDmite impuesto por el JDK.
         MaxEntitySizeLimit=JAXP00010003: la longitud de la entidad "{0}" es "{1}", que excede el l\u00EDmite de "{2}" que ha definido "{3}".
-        TotalEntitySizeLimit=JAXP00010004: el tama\u00F1o acumulado de las entidades es "{1}" y excede el l\u00EDmite de "{2}" definido por "{3}".
+        TotalEntitySizeLimit=JAXP00010004: el tama\u00F1o acumulado de las entidades es "{0}" y excede el l\u00EDmite de "{1}" definido por "{2}".
         MaxXMLNameLimit=JAXP00010005: la longitud de la entidad "{0}" es "{1}" y excede el l\u00EDmite de "{2}" definido por "{3}".
         MaxElementDepthLimit=JAXP00010006: El elemento "{0}" tiene una profundidad de "{1}" que excede el l\u00EDmite "{2}" definido por "{3}".
+        EntityReplacementLimit=JAXP00010007: El n\u00FAmero total de nodos en las referencias de entidad es de "{0}" que supera el l\u00EDmite de "{1}" definido por "{2}".
 
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_fr.properties b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_fr.properties
index c409487..300ff03 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_fr.properties
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_fr.properties
@@ -297,7 +297,8 @@
         EntityExpansionLimit=JAXP00010001 : L''analyseur a rencontr\u00E9 plus de "{0}" d\u00E9veloppements d''entit\u00E9 dans ce document. Il s''agit de la limite impos\u00E9e par le JDK.
         ElementAttributeLimit=JAXP00010002 : L''\u00E9l\u00E9ment "{0}" a plus de "{1}" attributs. "{1}" est la limite impos\u00E9e par le JDK.
         MaxEntitySizeLimit=JAXP00010003 : La longueur de l''entit\u00E9 "{0}" est de "{1}". Cette valeur d\u00E9passe la limite de "{2}" d\u00E9finie par "{3}".
-        TotalEntitySizeLimit=JAXP00010004 : La taille cumul\u00E9e des entit\u00E9s est "{1}" et d\u00E9passe la limite de "{2}" d\u00E9finie par "{3}".
+        TotalEntitySizeLimit=JAXP00010004 : La taille cumul\u00E9e des entit\u00E9s est "{0}" et d\u00E9passe la limite de "{1}" d\u00E9finie par "{2}".
         MaxXMLNameLimit=JAXP00010005 : La longueur de l''entit\u00E9 "{0}" est de "{1}". Cette valeur d\u00E9passe la limite de "{2}" d\u00E9finie par "{3}".
         MaxElementDepthLimit=JAXP00010006 : l''\u00E9l\u00E9ment "{0}" a une profondeur de "{1}" qui d\u00E9passe la limite de "{2}" d\u00E9finie par "{3}".
+        EntityReplacementLimit=JAXP00010007 : Le nombre total de noeuds dans les r\u00E9f\u00E9rences d''entit\u00E9 est "{0}", soit plus que la limite de "{1}" d\u00E9finie par "{2}".
 
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_it.properties b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_it.properties
index b2ed881..fbb95d3 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_it.properties
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_it.properties
@@ -297,7 +297,8 @@
         EntityExpansionLimit=JAXP00010001: il parser ha rilevato pi\u00F9 "{0}" espansioni di entit\u00E0 nel documento. Questo \u00E8 il limite imposto dal kit JDK.
         ElementAttributeLimit=JAXP00010002: l''elemento "{0}" contiene pi\u00F9 di "{1}" attributi. "{1}" \u00E8 il limite imposto dal kit JDK.
         MaxEntitySizeLimit=JAXP00010003: la lunghezza dell''entit\u00E0 "{0}" \u00E8 "{1}". Tale valore supera il limite "{2}" definito da "{3}".
-        TotalEntitySizeLimit=JAXP00010004: le dimensioni accumulate delle entit\u00E0 sono pari a "{1}". Tale valore supera il limite "{2}" definito da "{3}".
+        TotalEntitySizeLimit=JAXP00010004: le dimensioni accumulate delle entit\u00E0 sono pari a "{0}". Tale valore supera il limite "{1}" definito da "{2}".
         MaxXMLNameLimit=JAXP00010005: la lunghezza dell''entit\u00E0 "{0}" \u00E8 "{1}". Tale valore supera il limite "{2}" definito da "{3}".
         MaxElementDepthLimit=JAXP00010006: la profondit\u00E0 dell''elemento "{0}" \u00E8 "{1}". Tale valore supera il limite "{2}" definito da "{3}".
+        EntityReplacementLimit=JAXP00010007: il numero totale di nodi nei riferimenti entit\u00E0 \u00E8 "{0}". Tale valore supera il limite di "{1}" impostato da "{2}".
 
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_ja.properties b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_ja.properties
index aece337..e656dd8 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_ja.properties
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_ja.properties
@@ -297,7 +297,8 @@
         EntityExpansionLimit=JAXP00010001: \u30D1\u30FC\u30B5\u30FC\u306B\u3088\u3063\u3066\u3001\u3053\u306E\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u5185\u3067"{0}"\u3092\u8D85\u3048\u308B\u30A8\u30F3\u30C6\u30A3\u30C6\u30A3\u62E1\u5F35\u304C\u691C\u51FA\u3055\u308C\u307E\u3057\u305F\u3002\u3053\u308C\u306F\u3001JDK\u306B\u3088\u308B\u5236\u9650\u3067\u3059\u3002
         ElementAttributeLimit=JAXP00010002: \u8981\u7D20"{0}"\u306B"{1}"\u3092\u8D85\u3048\u308B\u5C5E\u6027\u304C\u5B58\u5728\u3057\u307E\u3059\u3002"{1}"\u306F\u3001JDK\u306B\u3088\u308B\u5236\u9650\u3067\u3059\u3002
         MaxEntitySizeLimit=JAXP00010003: \u30A8\u30F3\u30C6\u30A3\u30C6\u30A3"{0}"\u306E\u9577\u3055\u306F"{1}"\u3067\u3001"{3}"\u3067\u8A2D\u5B9A\u3055\u308C\u305F\u5236\u9650"{2}"\u3092\u8D85\u3048\u3066\u3044\u307E\u3059\u3002
-        TotalEntitySizeLimit=JAXP00010004: \u30A8\u30F3\u30C6\u30A3\u30C6\u30A3\u306E\u7D2F\u7A4D\u30B5\u30A4\u30BA"{1}"\u306F\u3001"{3}"\u3067\u8A2D\u5B9A\u3055\u308C\u305F\u5236\u9650"{2}"\u3092\u8D85\u3048\u307E\u3057\u305F\u3002
+        TotalEntitySizeLimit=JAXP00010004: \u30A8\u30F3\u30C6\u30A3\u30C6\u30A3\u306E\u7D2F\u7A4D\u30B5\u30A4\u30BA"{0}"\u306F\u3001"{2}"\u3067\u8A2D\u5B9A\u3055\u308C\u305F\u5236\u9650"{1}"\u3092\u8D85\u3048\u307E\u3057\u305F\u3002
         MaxXMLNameLimit=JAXP00010005: \u30A8\u30F3\u30C6\u30A3\u30C6\u30A3"{0}"\u306E\u9577\u3055\u306F"{1}"\u3067\u3001"{3}"\u3067\u8A2D\u5B9A\u3055\u308C\u305F\u5236\u9650"{2}"\u3092\u8D85\u3048\u3066\u3044\u307E\u3059\u3002
         MaxElementDepthLimit=JAXP00010006: \u8981\u7D20"{0}"\u306E\u6DF1\u3055\u306F"{1}"\u3067\u3001"{3}"\u3067\u8A2D\u5B9A\u3055\u308C\u305F\u5236\u9650"{2}"\u3092\u8D85\u3048\u3066\u3044\u307E\u3059\u3002
+        EntityReplacementLimit=JAXP00010007: \u30A8\u30F3\u30C6\u30A3\u30C6\u30A3\u53C2\u7167\u306E\u5408\u8A08\u30CE\u30FC\u30C9\u6570\u306F"{0}"\u3067\u3001"{2}"\u3067\u8A2D\u5B9A\u3055\u308C\u305F\u5236\u9650"{1}"\u3092\u8D85\u3048\u3066\u3044\u307E\u3059\u3002
 
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_ko.properties b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_ko.properties
index f992166..099855e 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_ko.properties
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_ko.properties
@@ -297,7 +297,8 @@
         EntityExpansionLimit=JAXP00010001: \uAD6C\uBB38 \uBD84\uC11D\uAE30\uAC00 \uC774 \uBB38\uC11C\uC5D0\uC11C "{0}"\uAC1C\uB97C \uCD08\uACFC\uD558\uB294 \uC5D4\uD2F0\uD2F0 \uD655\uC7A5\uC744 \uBC1C\uACAC\uD588\uC2B5\uB2C8\uB2E4. \uC774\uB294 JDK\uC5D0\uC11C \uC801\uC6A9\uD558\uB294 \uC81C\uD55C\uC785\uB2C8\uB2E4.
         ElementAttributeLimit=JAXP00010002:  "{0}" \uC694\uC18C\uC5D0 "{1}"\uAC1C\uB97C \uCD08\uACFC\uD558\uB294 \uC18D\uC131\uC774 \uC788\uC2B5\uB2C8\uB2E4. "{1}"\uC740(\uB294) JDK\uC5D0\uC11C \uC801\uC6A9\uD558\uB294 \uC81C\uD55C\uC785\uB2C8\uB2E4.
         MaxEntitySizeLimit=JAXP00010003: "{0}" \uC5D4\uD2F0\uD2F0\uC758 \uAE38\uC774\uAC00 "{3}"\uC5D0\uC11C \uC124\uC815\uB41C "{2}" \uC81C\uD55C\uC744 \uCD08\uACFC\uD558\uB294 "{1}"\uC785\uB2C8\uB2E4.
-        TotalEntitySizeLimit=JAXP00010004: \uC5D4\uD2F0\uD2F0\uC758 \uB204\uC801 \uD06C\uAE30\uAC00 "{3}"\uC5D0\uC11C \uC124\uC815\uD55C "{2}" \uC81C\uD55C\uC744 \uCD08\uACFC\uD558\uB294 "{1}"\uC785\uB2C8\uB2E4.
+        TotalEntitySizeLimit=JAXP00010004: \uC5D4\uD2F0\uD2F0\uC758 \uB204\uC801 \uD06C\uAE30\uAC00 "{2}"\uC5D0\uC11C \uC124\uC815\uD55C "{1}" \uC81C\uD55C\uC744 \uCD08\uACFC\uD558\uB294 "{0}"\uC785\uB2C8\uB2E4.
         MaxXMLNameLimit=JAXP00010005: "{0}" \uC5D4\uD2F0\uD2F0\uC758 \uAE38\uC774\uAC00 "{3}"\uC5D0\uC11C \uC124\uC815\uD55C "{2}" \uC81C\uD55C\uC744 \uCD08\uACFC\uD558\uB294 "{1}"\uC785\uB2C8\uB2E4.
         MaxElementDepthLimit=JAXP00010006: "{0}" \uC694\uC18C\uC758 \uAE4A\uC774\uAC00 "{3}"\uC5D0\uC11C \uC124\uC815\uB41C "{2}" \uC81C\uD55C\uC744 \uCD08\uACFC\uD558\uB294 "{1}"\uC785\uB2C8\uB2E4.
+        EntityReplacementLimit=JAXP00010007: \uC5D4\uD2F0\uD2F0 \uCC38\uC870\uC758 \uCD1D \uB178\uB4DC \uC218\uAC00 "{2}"\uC5D0\uC11C \uC124\uC815\uD55C "{1}" \uC81C\uD55C\uC744 \uCD08\uACFC\uD558\uB294 "{0}"\uC785\uB2C8\uB2E4.
 
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_pt_BR.properties b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_pt_BR.properties
index 473ca3e..1e00587 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_pt_BR.properties
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_pt_BR.properties
@@ -297,7 +297,8 @@
         EntityExpansionLimit=JAXP00010001: O parser detectou mais de "{0}" expans\u00F5es da entidade neste documento. Este \u00E9 o limite imposto pelo JDK.
         ElementAttributeLimit=JAXP00010002: o elemento "{0}" tem mais de "{1}" atributos. "{1}" \u00E9 o limite imposto pelo JDK.
         MaxEntitySizeLimit=JAXP00010003: o tamanho da entidade "{0}" \u00E9 "{1}", o que excede o limite de "{2}" definido por "{3}".
-        TotalEntitySizeLimit=JAXP00010004: o tamanho acumulado de entidades \u00E9 "{1}", o que excedeu o limite de "{2}" definido por "{3}".
+        TotalEntitySizeLimit=JAXP00010004: o tamanho acumulado de entidades \u00E9 "{0}", o que excedeu o limite de "{1}" definido por "{2}".
         MaxXMLNameLimit=JAXP00010005: o tamanho da entidade "{0}" \u00E9 "{1}", o que excede o limite de "{2}" definido por "{3}".
         MaxElementDepthLimit=JAXP00010006: o elemento "{0}" tem uma profundidade de "{1}" que excede o limite de "{2}" definido por "{3}".
+        EntityReplacementLimit=JAXP00010007: O n\u00FAmero total de n\u00F3s nas refer\u00EAncias da entidade \u00E9 de "{0}", o que est\u00E1 acima do limite de "{1}" definido por "{2}".
 
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_sv.properties b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_sv.properties
index 48fd780..add473e 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_sv.properties
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_sv.properties
@@ -297,7 +297,8 @@
         EntityExpansionLimit=JAXP00010001: Parsern har p\u00E5tr\u00E4ffat fler \u00E4n "{0}" enhetstill\u00E4gg i dokumentet - gr\u00E4nsv\u00E4rdet f\u00F6r JDK har uppn\u00E5tts.
         ElementAttributeLimit=JAXP00010002:  Elementet "{0}" har fler \u00E4n "{1}" attribut, "{1}" \u00E4r gr\u00E4nsv\u00E4rdet f\u00F6r JDK.
         MaxEntitySizeLimit=JAXP00010003: L\u00E4ngden p\u00E5 enheten "{0}" \u00E4r "{1}" som \u00F6verskriver gr\u00E4nsv\u00E4rdet p\u00E5 "{2}" som anges av "{3}".
-        TotalEntitySizeLimit=JAXP00010004: Den ackumulerade storleken f\u00F6r enheter \u00E4r "{1}", vilket \u00F6verskrider gr\u00E4nsv\u00E4rdet "{2}" som anges av "{3}".
+        TotalEntitySizeLimit=JAXP00010004: Den ackumulerade storleken f\u00F6r enheter \u00E4r "{0}", vilket \u00F6verskrider gr\u00E4nsv\u00E4rdet "{1}" som anges av "{2}".
         MaxXMLNameLimit=JAXP00010005: L\u00E4ngden p\u00E5 enheten "{0}" \u00E4r "{1}", vilket \u00F6verskrider gr\u00E4nsv\u00E4rdet "{2}" som anges av "{3}".
         MaxElementDepthLimit=JAXP00010006: Elementet "{0}" har djupet "{1}" vilket \u00E4r st\u00F6rre \u00E4n gr\u00E4nsen "{2}" som anges av "{3}".
+        EntityReplacementLimit=JAXP00010007: Det totala antalet noder i enhetsreferenser \u00E4r "{0}", vilket \u00E4r \u00F6ver gr\u00E4nsen "{1}" som har angetts av "{2}".
 
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_zh_CN.properties b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_zh_CN.properties
index 904174d..dc6bca0 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_zh_CN.properties
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_zh_CN.properties
@@ -297,7 +297,8 @@
         EntityExpansionLimit=JAXP00010001: \u89E3\u6790\u5668\u5728\u6B64\u6587\u6863\u4E2D\u9047\u5230\u591A\u4E2A "{0}" \u5B9E\u4F53\u6269\u5C55; \u8FD9\u662F JDK \u65BD\u52A0\u7684\u9650\u5236\u3002
         ElementAttributeLimit=JAXP00010002: \u5143\u7D20 "{0}" \u5177\u6709\u591A\u4E2A "{1}" \u5C5E\u6027, "{1}" \u662F JDK \u65BD\u52A0\u7684\u9650\u5236\u3002
         MaxEntitySizeLimit=JAXP00010003: \u5B9E\u4F53 "{0}" \u7684\u957F\u5EA6\u4E3A "{1}", \u8D85\u8FC7\u4E86 "{3}" \u8BBE\u7F6E\u7684 "{2}" \u9650\u5236\u3002
-        TotalEntitySizeLimit=JAXP00010004: \u5B9E\u4F53\u7684\u7D2F\u8BA1\u5927\u5C0F\u4E3A "{1}", \u8D85\u8FC7\u4E86 "{3}" \u8BBE\u7F6E\u7684 "{2}" \u9650\u5236\u3002
+        TotalEntitySizeLimit=JAXP00010004: \u5B9E\u4F53\u7684\u7D2F\u8BA1\u5927\u5C0F\u4E3A "{0}", \u8D85\u8FC7\u4E86 "{2}" \u8BBE\u7F6E\u7684 "{1}" \u9650\u5236\u3002
         MaxXMLNameLimit=JAXP00010005: \u5B9E\u4F53 "{0}" \u7684\u957F\u5EA6\u4E3A "{1}", \u8D85\u8FC7\u4E86 "{3}" \u8BBE\u7F6E\u7684 "{2}" \u9650\u5236\u3002
         MaxElementDepthLimit=JAXP00010006: \u5143\u7D20 "{0}" \u7684\u6DF1\u5EA6 "{1}" \u8D85\u8FC7\u4E86 "{3}" \u8BBE\u7F6E\u7684\u9650\u5236 "{2}"\u3002
+        EntityReplacementLimit=JAXP00010007: \u5B9E\u4F53\u5F15\u7528\u4E2D\u7684\u8282\u70B9\u603B\u6570\u4E3A "{0}", \u8D85\u8FC7\u4E86 "{2}" \u8BBE\u7F6E\u7684\u9650\u5236 "{1}"\u3002
 
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_zh_TW.properties b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_zh_TW.properties
index 11efb30..9d22569 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_zh_TW.properties
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages_zh_TW.properties
@@ -198,7 +198,7 @@
         MSG_SPACE_REQUIRED_BEFORE_NDATA_IN_UNPARSED_ENTITYDECL = \u5728\u5BE6\u9AD4 "{0}" \u7684\u5BA3\u544A\u4E2D\uFF0C"NDATA" \u4E4B\u524D\u9700\u8981\u7A7A\u683C\u3002
         MSG_NOTATION_NAME_REQUIRED_FOR_UNPARSED_ENTITYDECL = \u5728\u5BE6\u9AD4 "{0}" \u7684\u5BA3\u544A\u4E2D\uFF0C"NDATA" \u4E4B\u5F8C\u9700\u8981\u8868\u793A\u6CD5\u540D\u7A31\u3002
         EntityDeclUnterminated = \u5BE6\u9AD4 "{0}" \u7684\u5BA3\u544A\u7D50\u5C3E\u5FC5\u9808\u70BA ''>''\u3002
-	MSG_DUPLICATE_ENTITY_DEFINITION = \u5BE6\u9AD4 "{0}" \u5BA3\u544A\u8D85\u904E\u4E00\u6B21\u4EE5\u4E0A\u3002        
+	MSG_DUPLICATE_ENTITY_DEFINITION = \u5BE6\u9AD4 "{0}" \u5BA3\u544A\u8D85\u904E\u4E00\u6B21\u4EE5\u4E0A\u3002
 # 4.2.2 External Entities
         ExternalIDRequired = \u5916\u90E8\u5BE6\u9AD4\u5BA3\u544A\u7684\u958B\u982D\u5FC5\u9808\u70BA "SYSTEM" \u6216 "PUBLIC"\u3002
         MSG_SPACE_REQUIRED_BEFORE_PUBIDLITERAL_IN_EXTERNALID = "PUBLIC" \u8207\u516C\u7528 ID \u4E4B\u9593\u9700\u8981\u7A7A\u683C\u3002
@@ -254,7 +254,7 @@
         RootElementTypeMustMatchDoctypedecl = \u6587\u4EF6\u6839\u5143\u7D20 "{1}" \u5FC5\u9808\u914D\u5C0D DOCTYPE \u6839 "{0}"\u3002
         UndeclaredElementInContentSpec = \u5143\u7D20 "{0}" \u7684\u5167\u5BB9\u6A21\u578B\u53C3\u7167\u672A\u5BA3\u544A\u7684\u5143\u7D20 "{1}"\u3002
         UniqueNotationName = \u8868\u793A\u6CD5 "{0}" \u7684\u5BA3\u544A\u4E26\u975E\u552F\u4E00\u3002\u6307\u5B9A\u7684 Name \u4E0D\u80FD\u5728\u4E00\u500B\u4EE5\u4E0A\u7684\u8868\u793A\u6CD5\u5BA3\u544A\u4E2D\u5BA3\u544A\u3002
-        ENTITYFailedInitializeGrammar =  ENTITYDatatype \u9A57\u8B49\u7A0B\u5F0F: \u5931\u6557\u3002\u9700\u8981\u4F7F\u7528\u6709\u6548\u7684\u6587\u6CD5\u53C3\u7167\u4F86\u547C\u53EB\u8D77\u59CB\u65B9\u6CD5\u3002 \t
+        ENTITYFailedInitializeGrammar =  ENTITYDatatype \u9A57\u8B49\u7A0B\u5F0F: \u5931\u6557\u3002\u9700\u8981\u4F7F\u7528\u6709\u6548\u7684\u6587\u6CD5\u53C3\u7167\u4F86\u547C\u53EB\u8D77\u59CB\u65B9\u6CD5\u3002\t
         ENTITYNotUnparsed = ENTITY "{0}" \u4E26\u975E\u672A\u7D93\u5256\u6790\u3002
         ENTITYNotValid = ENTITY "{0}" \u7121\u6548\u3002
         EmptyList = \u985E\u578B ENTITIES\u3001IDREFS \u8207 NMTOKENS \u7684\u503C\u4E0D\u53EF\u70BA\u7A7A\u767D\u6E05\u55AE\u3002
@@ -277,7 +277,7 @@
         
 # Namespaces support
 # 4. Using Qualified Names
-        IllegalQName = \u5143\u7D20\u6216\u5C6C\u6027\u4E0D\u7B26\u5408 QName \u7522\u751F: QName::=(NCName':')?NCName\u3002 
+        IllegalQName = \u5143\u7D20\u6216\u5C6C\u6027\u4E0D\u7B26\u5408 QName \u7522\u751F: QName::=(NCName':')?NCName\u3002
         ElementXMLNSPrefix = \u5143\u7D20 "{0}" \u4E0D\u80FD\u4F7F\u7528 "xmlns" \u4F5C\u70BA\u524D\u7F6E\u78BC\u3002
         ElementPrefixUnbound = \u5143\u7D20 "{1}" \u7684\u524D\u7F6E\u78BC "{0}" \u672A\u9023\u7D50\u3002
         AttributePrefixUnbound = \u95DC\u806F\u5143\u7D20\u985E\u578B "{0}" \u4E4B\u5C6C\u6027 "{1}" \u7684\u524D\u7F6E\u78BC "{2}" \u672A\u9023\u7D50\u3002
@@ -297,7 +297,8 @@
         EntityExpansionLimit=JAXP00010001: \u5256\u6790\u5668\u5728\u6B64\u6587\u4EF6\u4E2D\u9047\u5230 "{0}" \u500B\u4EE5\u4E0A\u7684\u5BE6\u9AD4\u64F4\u5145; \u9019\u662F JDK \u6240\u898F\u5B9A\u7684\u9650\u5236\u3002
         ElementAttributeLimit=JAXP00010002: \u5143\u7D20 "{0}" \u5177\u6709\u8D85\u904E "{1}" \u500B\u4EE5\u4E0A\u7684\u5C6C\u6027\uFF0C"{1}" \u662F JDK \u6240\u898F\u5B9A\u7684\u9650\u5236\u3002
         MaxEntitySizeLimit=JAXP00010003: \u5BE6\u9AD4 "{0}" \u7684\u9577\u5EA6\u70BA "{1}"\uFF0C\u8D85\u904E "{3}" \u6240\u8A2D\u5B9A\u7684 "{2}" \u9650\u5236\u3002
-        TotalEntitySizeLimit=JAXP00010004: \u5BE6\u9AD4\u7684\u7D2F\u7A4D\u5927\u5C0F\u70BA "{1}"\uFF0C\u8D85\u904E "{3}" \u6240\u8A2D\u5B9A\u7684 "{2}" \u9650\u5236\u3002
+        TotalEntitySizeLimit=JAXP00010004: \u5BE6\u9AD4\u7684\u7D2F\u7A4D\u5927\u5C0F\u70BA "{0}"\uFF0C\u8D85\u904E "{2}" \u6240\u8A2D\u5B9A\u7684 "{1}" \u9650\u5236\u3002
         MaxXMLNameLimit=JAXP00010005: \u5BE6\u9AD4 "{0}" \u7684\u9577\u5EA6\u70BA "{1}"\uFF0C\u8D85\u904E "{3}" \u6240\u8A2D\u5B9A\u7684 "{2}" \u9650\u5236\u3002
-        MaxElementDepthLimit=JAXP00010006: \u5143\u7D20 "{0}" \u7684\u6DF1\u5EA6\u70BA "{1}"\uFF0C\u8D85\u904E "{3}" \u8A2D\u5B9A\u7684 "{2}" \u9650\u5236\u3002
+        MaxElementDepthLimit=JAXP00010006: \u5143\u7D20 "{0}" \u7684\u6DF1\u5EA6\u70BA "{1}"\uFF0C\u8D85\u904E "{3}" \u6240\u8A2D\u5B9A\u7684 "{2}" \u9650\u5236\u3002
+        EntityReplacementLimit=JAXP00010007: \u5BE6\u9AD4\u53C3\u7167\u4E2D\u7684\u7BC0\u9EDE\u7E3D\u6578\u70BA "{0}"\uFF0C\u8D85\u904E "{2}" \u6240\u8A2D\u5B9A\u7684 "{1}" \u9650\u5236\u3002
 
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_zh_TW.properties b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_zh_TW.properties
index 06d8a05..9f170b1 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_zh_TW.properties
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages_zh_TW.properties
@@ -188,7 +188,7 @@
         e-props-correct.5 = e-props-correct.5: '{'value constraint'}' \u4E0D\u53EF\u51FA\u73FE\u5728\u5143\u7D20 ''{0}'' \u4E0A\uFF0C\u56E0\u70BA\u5143\u7D20\u7684 '{'type definition'}' \u6216 '{'type definition'}' \u7684 '{'content type'}' \u70BA ID\uFF0C\u6216\u884D\u751F\u81EA ID\u3002
         e-props-correct.6 = e-props-correct.6: \u5075\u6E2C\u5230 ''{0}'' \u7684\u5FAA\u74B0\u66FF\u4EE3\u7FA4\u7D44\u3002
         fractionDigits-valid-restriction = fractionDigits-valid-restriction: \u5728 {2} \u7684\u5B9A\u7FA9\u4E2D\uFF0Cfacet ''fractionDigits'' \u7684\u503C ''{0}'' \u7121\u6548\uFF0C\u56E0\u70BA\u5B83\u5FC5\u9808\u5C0F\u65BC\u6216\u7B49\u65BC ''fractionDigits'' \u7684\u503C\uFF0C\u6B64\u503C\u4EE5\u5176\u4E2D\u4E00\u500B\u7956\u7CFB\u985E\u578B\u8A2D\u70BA ''{1}''\u3002
-        fractionDigits-totalDigits = fractionDigits-totalDigits: \u5728 {2} \u7684\u5B9A\u7FA9\u4E2D\uFF0C facet ''fractionDigits'' \u7684\u503C ''{0}'' \u7121\u6548\uFF0C\u56E0\u70BA\u503C\u5FC5\u9808\u5C0F\u65BC\u6216\u7B49\u65BC ''totalDigits'' \u7684\u503C\uFF0C\u4EA6\u5373 ''{1}''\u3002
+        fractionDigits-totalDigits = fractionDigits-totalDigits: \u5728 {2} \u7684\u5B9A\u7FA9\u4E2D\uFF0Cfacet ''fractionDigits'' \u7684\u503C ''{0}'' \u7121\u6548\uFF0C\u56E0\u70BA\u503C\u5FC5\u9808\u5C0F\u65BC\u6216\u7B49\u65BC ''totalDigits'' \u7684\u503C\uFF0C\u4EA6\u5373 ''{1}''\u3002
         length-minLength-maxLength.1.1 = length-minLength-maxLength.1.1: \u91DD\u5C0D\u985E\u578B {0}\uFF0Clength ''{1}'' \u7684\u503C\u5C0F\u65BC minLength ''{2}'' \u7684\u503C\u662F\u4E00\u9805\u932F\u8AA4\u3002
         length-minLength-maxLength.1.2.a = length-minLength-maxLength.1.2.a: \u91DD\u5C0D\u985E\u578B {0}\uFF0C\u82E5\u76EE\u524D\u9650\u5236\u5177\u6709 minLength facet \u4E14\u76EE\u524D\u7684\u9650\u5236\u6216\u57FA\u790E\u5177\u6709 length facet\uFF0C\u5247\u57FA\u790E\u6C92\u6709 minLength facet \u662F\u4E00\u9805\u932F\u8AA4\u3002
         length-minLength-maxLength.1.2.b = length-minLength-maxLength.1.2.b: \u91DD\u5C0D\u985E\u578B {0}\uFF0C\u76EE\u524D\u7684 minLength ''{1}'' \u4E0D\u7B49\u65BC\u57FA\u790E minLength ''{2}'' \u662F\u4E00\u9805\u932F\u8AA4\u3002
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java
index 92a3a83..5677971 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java
@@ -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.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -1172,7 +1172,7 @@
             if (max != SchemaSymbols.OCCURRENCE_UNBOUNDED) {
 
                 // maxOccurLimit is only check in secure mode
-                if (fSchemaHandler.fSecureProcessing != null) {
+                if (fSchemaHandler.fSecurityManager != null) {
                     String localName = element.getLocalName();
 
                 // The maxOccurs restriction no longer applies to elements
@@ -1191,8 +1191,8 @@
                     if (!optimize) {
                     //Revisit :: IMO this is not right place to check
                     // maxOccurNodeLimit.
-                    int maxOccurNodeLimit = fSchemaHandler.fSecureProcessing.getLimit(XMLSecurityManager.Limit.MAX_OCCUR_NODE_LIMIT);
-                    if (max > maxOccurNodeLimit && !fSchemaHandler.fSecureProcessing.isNoLimit(maxOccurNodeLimit)) {
+                    int maxOccurNodeLimit = fSchemaHandler.fSecurityManager.getLimit(XMLSecurityManager.Limit.MAX_OCCUR_NODE_LIMIT);
+                    if (max > maxOccurNodeLimit && !fSchemaHandler.fSecurityManager.isNoLimit(maxOccurNodeLimit)) {
                         reportSchemaFatalError("MaxOccurLimit", new Object[] {new Integer(maxOccurNodeLimit)}, element);
 
                         // reset max values in case processing continues on error
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java
index 825e792..e29554d 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -195,6 +195,7 @@
     /** Property identifier: entity resolver. */
     public static final String ENTITY_RESOLVER =
         Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_RESOLVER_PROPERTY;
+
     /** Property identifier: entity manager. */
     protected static final String ENTITY_MANAGER =
         Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_MANAGER_PROPERTY;
@@ -215,16 +216,13 @@
     protected static final String SECURITY_MANAGER =
         Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY;
 
-    private static final String SECURE_PROCESSING =
-        Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY;
-
     /** Property identifier: locale. */
     protected static final String LOCALE =
         Constants.XERCES_PROPERTY_PREFIX + Constants.LOCALE_PROPERTY;
 
-        /** Property identifier: Security property manager. */
+    /** Property identifier: Security property manager. */
     private static final String XML_SECURITY_PROPERTY_MANAGER =
-            Constants.XML_SECURITY_PROPERTY_MANAGER;
+        Constants.XML_SECURITY_PROPERTY_MANAGER;
 
     protected static final boolean DEBUG_NODE_POOL = false;
 
@@ -244,17 +242,12 @@
     // as unlikely as possible to cause collisions.
     public final static String REDEF_IDENTIFIER = "_fn3dktizrknc9pi";
 
-    //
-    //protected data that can be accessable by any traverser
+    //protected data that can be accessible by any traverser
 
     protected XSDeclarationPool fDeclPool = null;
 
-    /**
-     * <p>Security manager in effect.</p>
-     *
-     * <p>Protected to allow access by any traverser.</p>
-     */
-    protected XMLSecurityManager fSecureProcessing = null;
+    // the Security manager in effect.
+    protected XMLSecurityManager fSecurityManager = null;
 
     private String fAccessExternalSchema;
     private String fAccessExternalDTD;
@@ -267,27 +260,28 @@
     // XSDocumentInfoRegistry we can easily get the corresponding
     // XSDocumentInfo object.
     private boolean registryEmpty = true;
-    private Map<String, Element> fUnparsedAttributeRegistry = new HashMap();
-    private Map<String, Element> fUnparsedAttributeGroupRegistry =  new HashMap();
-    private Map<String, Element> fUnparsedElementRegistry =  new HashMap();
-    private Map<String, Element> fUnparsedGroupRegistry =  new HashMap();
-    private Map<String, Element> fUnparsedIdentityConstraintRegistry =  new HashMap();
-    private Map<String, Element> fUnparsedNotationRegistry =  new HashMap();
-    private Map<String, Element> fUnparsedTypeRegistry =  new HashMap();
+    private Map<String, Element> fUnparsedAttributeRegistry = new HashMap<>();
+    private Map<String, Element> fUnparsedAttributeGroupRegistry =  new HashMap<>();
+    private Map<String, Element> fUnparsedElementRegistry =  new HashMap<>();
+    private Map<String, Element> fUnparsedGroupRegistry =  new HashMap<>();
+    private Map<String, Element> fUnparsedIdentityConstraintRegistry =  new HashMap<>();
+    private Map<String, Element> fUnparsedNotationRegistry =  new HashMap<>();
+    private Map<String, Element> fUnparsedTypeRegistry =  new HashMap<>();
     // Compensation for the above maps to locate XSDocumentInfo,
     // Since we may take Schema Element directly, so can not get the
     // corresponding XSDocumentInfo object just using above maps.
-    private Map<String, XSDocumentInfo> fUnparsedAttributeRegistrySub =  new HashMap();
-    private Map<String, XSDocumentInfo> fUnparsedAttributeGroupRegistrySub =  new HashMap();
-    private Map<String, XSDocumentInfo> fUnparsedElementRegistrySub =  new HashMap();
-    private Map<String, XSDocumentInfo> fUnparsedGroupRegistrySub =  new HashMap();
-    private Map<String, XSDocumentInfo> fUnparsedIdentityConstraintRegistrySub =  new HashMap();
-    private Map<String, XSDocumentInfo> fUnparsedNotationRegistrySub =  new HashMap();
-    private Map<String, XSDocumentInfo> fUnparsedTypeRegistrySub =  new HashMap();
+    private Map<String, XSDocumentInfo> fUnparsedAttributeRegistrySub =  new HashMap<>();
+    private Map<String, XSDocumentInfo> fUnparsedAttributeGroupRegistrySub =  new HashMap<>();
+    private Map<String, XSDocumentInfo> fUnparsedElementRegistrySub =  new HashMap<>();
+    private Map<String, XSDocumentInfo> fUnparsedGroupRegistrySub =  new HashMap<>();
+    private Map<String, XSDocumentInfo> fUnparsedIdentityConstraintRegistrySub =  new HashMap<>();
+    private Map<String, XSDocumentInfo> fUnparsedNotationRegistrySub =  new HashMap<>();
+    private Map<String, XSDocumentInfo> fUnparsedTypeRegistrySub =  new HashMap<>();
 
     // Stores XSDocumentInfo (keyed by component name), to check for duplicate
     // components declared within the same xsd document
-    private Map fUnparsedRegistriesExt[] = new HashMap[] {
+    @SuppressWarnings("unchecked")
+    private Map<String, XSDocumentInfo> fUnparsedRegistriesExt[] = new HashMap[] {
         null,
         null, // ATTRIBUTE_TYPE
         null, // ATTRIBUTEGROUP_TYPE
@@ -301,17 +295,19 @@
     // this map is keyed on by XSDocumentInfo objects.  Its values
     // are Vectors containing the XSDocumentInfo objects <include>d,
     // <import>ed or <redefine>d by the key XSDocumentInfo.
-    private Map<XSDocumentInfo, Vector> fDependencyMap = new HashMap();
+    private Map<XSDocumentInfo, Vector<XSDocumentInfo>> fDependencyMap = new HashMap<>();
 
     // this map is keyed on by a target namespace.  Its values
     // are Vectors containing namespaces imported by schema documents
     // with the key target namespace.
-    // if an imprted schema has absent namespace, the value "null" is stored.
-    private Map<String, Vector> fImportMap = new HashMap();
+    // if an imported schema has absent namespace, the value "null" is stored.
+    private Map<String, Vector> fImportMap = new HashMap<> ();
+
     // all namespaces that imports other namespaces
     // if the importing schema has absent namespace, empty string is stored.
     // (because the key of a map can't be null.)
-    private Vector fAllTNSs = new Vector();
+    private Vector<String> fAllTNSs = new Vector<>();
+
     // stores instance document mappings between namespaces and schema hints
     private Map<String, XMLSchemaLoader.LocationArray> fLocationPairs = null;
 
@@ -334,7 +330,7 @@
         if(ele.getOwnerDocument() instanceof com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaDOM){
             documentURI = ((com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaDOM) ele.getOwnerDocument()).getDocumentURI();
         }
-        return documentURI != null ? documentURI : (String) fDoc2SystemId.get(ele);
+        return documentURI != null ? documentURI : fDoc2SystemId.get(ele);
     }
 
     // This vector stores strings which are combinations of the
@@ -342,11 +338,11 @@
     // schema document.  This combination is used so that the user's
     // EntityResolver can provide a consistent way of identifying a
     // schema document that is included in multiple other schemas.
-    private Map fTraversed = new HashMap();
+    private Map<XSDKey, Element> fTraversed = new HashMap<>();
 
     // this map contains a mapping from Schema Element to its systemId
     // this is useful to resolve a uri relative to the referring document
-    private Map fDoc2SystemId = new HashMap();
+    private Map<Element, String> fDoc2SystemId = new HashMap<>();
 
     // the primary XSDocumentInfo we were called to parse
     private XSDocumentInfo fRoot = null;
@@ -388,7 +384,15 @@
 
     // the XMLErrorReporter
     private XMLErrorReporter fErrorReporter;
-    private XMLEntityResolver fEntityResolver;
+
+    // the XMLErrorHandler
+    private XMLErrorHandler fErrorHandler;
+
+    // the Locale
+    private Locale fLocale;
+
+    // the XMLEntityManager
+    private XMLEntityResolver fEntityManager;
 
     // the XSAttributeChecker
     private XSAttributeChecker fAttributeChecker;
@@ -405,6 +409,9 @@
     // the Grammar Pool
     private XMLGrammarPool fGrammarPool;
 
+    // the security property manager
+    private XMLSecurityPropertyManager fSecurityPropertyMgr = null;
+
     //************ Traversers **********
     XSDAttributeGroupTraverser fAttributeGroupTraverser;
     XSDAttributeTraverser fAttributeTraverser;
@@ -639,7 +646,7 @@
         // for all grammars with <import>s
         for (int i = fAllTNSs.size() - 1; i >= 0; i--) {
             // get its target namespace
-            String tns = (String)fAllTNSs.elementAt(i);
+            String tns = fAllTNSs.elementAt(i);
             // get all namespaces it imports
             Vector ins = (Vector)fImportMap.get(tns);
             // get the grammar
@@ -697,12 +704,13 @@
         fAnnotationValidator.setFeature(VALIDATION, true);
         fAnnotationValidator.setFeature(XMLSCHEMA_VALIDATION, true);
         fAnnotationValidator.setProperty(XMLGRAMMAR_POOL, fGrammarBucketAdapter);
+        /** set security manager and XML Security Property Manager **/
+        fAnnotationValidator.setProperty(SECURITY_MANAGER, (fSecurityManager != null) ? fSecurityManager : new XMLSecurityManager(true));
+        fAnnotationValidator.setProperty(XML_SECURITY_PROPERTY_MANAGER, fSecurityPropertyMgr);
         /** Set error handler. **/
-        XMLErrorHandler errorHandler = fErrorReporter.getErrorHandler();
-        fAnnotationValidator.setProperty(ERROR_HANDLER, (errorHandler != null) ? errorHandler : new DefaultErrorHandler());
+        fAnnotationValidator.setProperty(ERROR_HANDLER, (fErrorHandler != null) ? fErrorHandler : new DefaultErrorHandler());
         /** Set locale. **/
-        Locale locale = fErrorReporter.getLocale();
-        fAnnotationValidator.setProperty(LOCALE, locale);
+        fAnnotationValidator.setProperty(LOCALE, fLocale);
     }
 
     /**
@@ -881,10 +889,10 @@
 
         // store the document and its location
         // REVISIT: don't expose the DOM tree
-        sg.addDocument(null, (String)fDoc2SystemId.get(currSchemaInfo.fSchemaElement));
+        sg.addDocument(null, fDoc2SystemId.get(currSchemaInfo.fSchemaElement));
 
         fDoc2XSDocumentMap.put(schemaRoot, currSchemaInfo);
-        Vector dependencies = new Vector();
+        Vector<XSDocumentInfo> dependencies = new Vector<>();
         Element rootNode = schemaRoot;
 
         Element newSchemaRoot = null;
@@ -1335,9 +1343,9 @@
             } // end for
 
             // now we're done with this one!
-                DOMUtil.setHidden(currDoc, fHiddenNodes);
+            DOMUtil.setHidden(currDoc, fHiddenNodes);
             // now add the schemas this guy depends on
-            Vector currSchemaDepends = (Vector)fDependencyMap.get(currSchemaDoc);
+            Vector<XSDocumentInfo> currSchemaDepends = fDependencyMap.get(currSchemaDoc);
             for (int i = 0; i < currSchemaDepends.size(); i++) {
                 schemasToProcess.push(currSchemaDepends.elementAt(i));
             }
@@ -1467,7 +1475,7 @@
             DOMUtil.setHidden(currDoc, fHiddenNodes);
 
             // now add the schemas this guy depends on
-            Vector currSchemaDepends = (Vector)fDependencyMap.get(currSchemaDoc);
+            Vector<XSDocumentInfo> currSchemaDepends = fDependencyMap.get(currSchemaDoc);
             for (int i = 0; i < currSchemaDepends.size(); i++) {
                 schemasToProcess.push(currSchemaDepends.elementAt(i));
             }
@@ -1916,7 +1924,7 @@
     }
 
     public String schemaDocument2SystemId(XSDocumentInfo schemaDoc) {
-        return (String)fDoc2SystemId.get(schemaDoc.fSchemaElement);
+        return fDoc2SystemId.get(schemaDoc.fSchemaElement);
     }
 
     // This method determines whether there is a group
@@ -2045,7 +2053,7 @@
         XMLInputSource schemaSource = null;
         try {
             Map<String, XMLSchemaLoader.LocationArray> pairs = usePairs ? fLocationPairs : Collections.emptyMap();
-            schemaSource = XMLSchemaLoader.resolveDocument(desc, pairs, fEntityResolver);
+            schemaSource = XMLSchemaLoader.resolveDocument(desc, pairs, fEntityManager);
         }
         catch (IOException ex) {
             if (mustResolve) {
@@ -2098,7 +2106,7 @@
         XMLInputSource schemaSource = null;
         try {
             Map<String, XMLSchemaLoader.LocationArray> pairs = usePairs ? fLocationPairs : Collections.emptyMap();
-            schemaSource = XMLSchemaLoader.resolveDocument(desc, pairs, fEntityResolver);
+            schemaSource = XMLSchemaLoader.resolveDocument(desc, pairs, fEntityManager);
         }
         catch (IOException ex) {
             if (mustResolve) {
@@ -2153,7 +2161,7 @@
                 if (referType != XSDDescription.CONTEXT_PREPARSE){
                     schemaId = XMLEntityManager.expandSystemId(schemaSource.getSystemId(), schemaSource.getBaseSystemId(), false);
                     key = new XSDKey(schemaId, referType, schemaNamespace);
-                    if((schemaElement = (Element)fTraversed.get(key)) != null) {
+                    if((schemaElement = fTraversed.get(key)) != null) {
                         fLastSchemaWasDuplicate = true;
                         return schemaElement;
                     }
@@ -2212,7 +2220,7 @@
                 if (referType != XSDDescription.CONTEXT_PREPARSE) {
                     schemaId = XMLEntityManager.expandSystemId(inputSource.getSystemId(), schemaSource.getBaseSystemId(), false);
                     key = new XSDKey(schemaId, referType, schemaNamespace);
-                    if ((schemaElement = (Element) fTraversed.get(key)) != null) {
+                    if ((schemaElement = fTraversed.get(key)) != null) {
                         fLastSchemaWasDuplicate = true;
                         return schemaElement;
                     }
@@ -2239,9 +2247,8 @@
                         namespacePrefixes = true;
                         // If this is a Xerces SAX parser set the security manager if there is one
                         if (parser instanceof SAXParser) {
-                            Object securityManager = fSchemaParser.getProperty(SECURITY_MANAGER);
-                            if (securityManager != null) {
-                                parser.setProperty(SECURITY_MANAGER, securityManager);
+                            if (fSecurityManager != null) {
+                                parser.setProperty(SECURITY_MANAGER, fSecurityManager);
                             }
                         }
                     }
@@ -2250,8 +2257,8 @@
                     try {
                         parser.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, fAccessExternalDTD);
                     } catch (SAXNotRecognizedException exc) {
-                        System.err.println("Warning: " + parser.getClass().getName() + ": " +
-                                exc.getMessage());
+                        XMLSecurityManager.printWarning(parser.getClass().getName(),
+                                XMLConstants.ACCESS_EXTERNAL_DTD, exc);
                     }
                 }
                 // If XML names and Namespace URIs are already internalized we
@@ -2348,7 +2355,7 @@
                     }
                     if (isDocument) {
                         key = new XSDKey(schemaId, referType, schemaNamespace);
-                        if ((schemaElement = (Element) fTraversed.get(key)) != null) {
+                        if ((schemaElement = fTraversed.get(key)) != null) {
                             fLastSchemaWasDuplicate = true;
                             return schemaElement;
                         }
@@ -2403,7 +2410,7 @@
                 }
                 if (isDocument) {
                     key = new XSDKey(schemaId, referType, schemaNamespace);
-                    if ((schemaElement = (Element) fTraversed.get(key)) != null) {
+                    if ((schemaElement = fTraversed.get(key)) != null) {
                         fLastSchemaWasDuplicate = true;
                         return schemaElement;
                     }
@@ -3503,40 +3510,21 @@
         // set symbol table
         fSymbolTable = (SymbolTable) componentManager.getProperty(SYMBOL_TABLE);
 
-        fSecureProcessing = null;
-        if( componentManager!=null ) {
-            fSecureProcessing = (XMLSecurityManager) componentManager.getProperty(SECURE_PROCESSING, null);
-        }
+        // set security manager
+        fSecurityManager = (XMLSecurityManager) componentManager.getProperty(SECURITY_MANAGER, null);
+
+        //set entity manager
+        fEntityManager = (XMLEntityResolver) componentManager.getProperty(ENTITY_MANAGER);
 
         //set entity resolver
-        fEntityResolver = (XMLEntityResolver) componentManager.getProperty(ENTITY_MANAGER);
         XMLEntityResolver er = (XMLEntityResolver)componentManager.getProperty(ENTITY_RESOLVER);
         if (er != null)
             fSchemaParser.setEntityResolver(er);
 
         // set error reporter
-        fErrorReporter =
-            (XMLErrorReporter) componentManager.getProperty(ERROR_REPORTER);
-        try {
-            XMLErrorHandler currErrorHandler = fErrorReporter.getErrorHandler();
-            // Setting a parser property can be much more expensive
-            // than checking its value.  Don't set the ERROR_HANDLER
-            // or LOCALE properties unless they've actually changed.
-            if (currErrorHandler != fSchemaParser.getProperty(ERROR_HANDLER)) {
-                fSchemaParser.setProperty(ERROR_HANDLER, (currErrorHandler != null) ? currErrorHandler : new DefaultErrorHandler());
-                if (fAnnotationValidator != null) {
-                    fAnnotationValidator.setProperty(ERROR_HANDLER, (currErrorHandler != null) ? currErrorHandler : new DefaultErrorHandler());
-                }
-            }
-            Locale currentLocale = fErrorReporter.getLocale();
-            if (currentLocale != fSchemaParser.getProperty(LOCALE)) {
-                fSchemaParser.setProperty(LOCALE, currentLocale);
-                if (fAnnotationValidator != null) {
-                    fAnnotationValidator.setProperty(LOCALE, currentLocale);
-                }
-            }
-        }
-        catch (XMLConfigurationException e) {}
+        fErrorReporter = (XMLErrorReporter) componentManager.getProperty(ERROR_REPORTER);
+        fErrorHandler = fErrorReporter.getErrorHandler();
+        fLocale = fErrorReporter.getLocale();
 
         fValidateAnnotations = componentManager.getFeature(VALIDATE_ANNOTATIONS, false);
         fHonourAllSchemaLocations = componentManager.getFeature(HONOUR_ALL_SCHEMALOCATIONS, false);
@@ -3544,56 +3532,66 @@
         fTolerateDuplicates = componentManager.getFeature(TOLERATE_DUPLICATES, false);
 
         try {
-            fSchemaParser.setFeature(
-                    CONTINUE_AFTER_FATAL_ERROR,
-                    fErrorReporter.getFeature(CONTINUE_AFTER_FATAL_ERROR));
-        } catch (XMLConfigurationException e) {
+            // Setting a parser property can be much more expensive
+            // than checking its value.  Don't set the ERROR_HANDLER
+            // or LOCALE properties unless they've actually changed.
+            if (fErrorHandler != fSchemaParser.getProperty(ERROR_HANDLER)) {
+                fSchemaParser.setProperty(ERROR_HANDLER, (fErrorHandler != null) ? fErrorHandler : new DefaultErrorHandler());
+                if (fAnnotationValidator != null) {
+                    fAnnotationValidator.setProperty(ERROR_HANDLER, (fErrorHandler != null) ? fErrorHandler : new DefaultErrorHandler());
+                }
+            }
+            if (fLocale != fSchemaParser.getProperty(LOCALE)) {
+                fSchemaParser.setProperty(LOCALE, fLocale);
+                if (fAnnotationValidator != null) {
+                    fAnnotationValidator.setProperty(LOCALE, fLocale);
+                }
+            }
         }
+        catch (XMLConfigurationException e) {}
+
+        try {
+            fSchemaParser.setFeature(CONTINUE_AFTER_FATAL_ERROR, fErrorReporter.getFeature(CONTINUE_AFTER_FATAL_ERROR));
+        } catch (XMLConfigurationException e) {}
 
         try {
             if (componentManager.getFeature(ALLOW_JAVA_ENCODINGS, false)) {
                 fSchemaParser.setFeature(ALLOW_JAVA_ENCODINGS, true);
             }
-        } catch (XMLConfigurationException e) {
-        }
+        } catch (XMLConfigurationException e) {}
+
         try {
             if (componentManager.getFeature(STANDARD_URI_CONFORMANT_FEATURE, false)) {
                 fSchemaParser.setFeature(STANDARD_URI_CONFORMANT_FEATURE, true);
             }
-        } catch (XMLConfigurationException e) {
-        }
+        } catch (XMLConfigurationException e) {}
 
         try {
-            fGrammarPool =
-                (XMLGrammarPool) componentManager.getProperty(XMLGRAMMAR_POOL);
+            fGrammarPool = (XMLGrammarPool) componentManager.getProperty(XMLGRAMMAR_POOL);
         } catch (XMLConfigurationException e) {
             fGrammarPool = null;
         }
+
         // security features
         try {
             if (componentManager.getFeature(DISALLOW_DOCTYPE, false)) {
                 fSchemaParser.setFeature(DISALLOW_DOCTYPE, true);
             }
-        } catch (XMLConfigurationException e) {
-        }
+        } catch (XMLConfigurationException e) {}
+
         try {
-            Object security = componentManager.getProperty(SECURITY_MANAGER, null);
-            if (security != null){
-                fSchemaParser.setProperty(SECURITY_MANAGER, security);
+            if (fSecurityManager != null) {
+                fSchemaParser.setProperty(SECURITY_MANAGER, fSecurityManager);
             }
-        } catch (XMLConfigurationException e) {
-        }
+        } catch (XMLConfigurationException e) {}
 
-        XMLSecurityPropertyManager securityPropertyMgr = (XMLSecurityPropertyManager)
-                componentManager.getProperty(XML_SECURITY_PROPERTY_MANAGER);
+        fSecurityPropertyMgr = (XMLSecurityPropertyManager) componentManager.getProperty(XML_SECURITY_PROPERTY_MANAGER);
+
         //Passing on the setting to the parser
-        fSchemaParser.setProperty(XML_SECURITY_PROPERTY_MANAGER, securityPropertyMgr);
+        fSchemaParser.setProperty(XML_SECURITY_PROPERTY_MANAGER, fSecurityPropertyMgr);
 
-        fAccessExternalDTD = securityPropertyMgr.getValue(
-                XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD);
-
-        fAccessExternalSchema = securityPropertyMgr.getValue(
-                XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA);
+        fAccessExternalDTD = fSecurityPropertyMgr.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD);
+        fAccessExternalSchema = fSecurityPropertyMgr.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA);
 
     } // reset(XMLComponentManager)
 
@@ -4052,7 +4050,7 @@
          so long as there's some include/import/redefine path amongst them.
          If they rver reverse this decision the code's right here though...  - neilg
          // now look in fDependencyMap to see if this is reachable
-          if(((Vector)fDependencyMap.get(currSchema)).contains(declDocInfo)) {
+          if((fDependencyMap.get(currSchema)).contains(declDocInfo)) {
           return declDocInfo;
           }
           // obviously the requesting doc didn't include, redefine or
@@ -4073,9 +4071,9 @@
         if (DOMUtil.isHidden(startSchema.fSchemaElement, fHiddenNodes)) {
             // make it visible
             DOMUtil.setVisible(startSchema.fSchemaElement, fHiddenNodes);
-            Vector dependingSchemas = (Vector)fDependencyMap.get(startSchema);
+            Vector<XSDocumentInfo> dependingSchemas = fDependencyMap.get(startSchema);
             for (int i = 0; i < dependingSchemas.size(); i++) {
-                setSchemasVisible((XSDocumentInfo)dependingSchemas.elementAt(i));
+                setSchemasVisible(dependingSchemas.elementAt(i));
             }
         }
         // if it's visible already than so must be its children
@@ -4108,7 +4106,7 @@
             ElementImpl ele = (ElementImpl)e;
             // get system id from document object
             Document doc = ele.getOwnerDocument();
-            String sid = (String)fDoc2SystemId.get(DOMUtil.getRoot(doc));
+            String sid = fDoc2SystemId.get(DOMUtil.getRoot(doc));
             // line/column numbers are stored in the element node
             int line = ele.getLineNumber();
             int column = ele.getColumnNumber();
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java
index fc652af..2a62405 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java
@@ -698,8 +698,8 @@
                                reader.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD,
                                        spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD));
                            } catch (SAXException exc) {
-                               System.err.println("Warning: " + reader.getClass().getName() + ": " +
-                                      exc.getMessage());
+                               XMLSecurityManager.printWarning(reader.getClass().getName(),
+                                       XMLConstants.ACCESS_EXTERNAL_DTD, exc);
                            }
                         }
                     } catch( Exception e ) {
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java
index bbcbcee..ac84e1e 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java
@@ -52,7 +52,6 @@
 import com.sun.org.apache.xerces.internal.util.ParserConfigurationSettings;
 import com.sun.org.apache.xerces.internal.util.PropertyState;
 import com.sun.org.apache.xerces.internal.util.SymbolTable;
-import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
 import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager;
 import com.sun.org.apache.xerces.internal.xni.XMLDTDContentModelHandler;
 import com.sun.org.apache.xerces.internal.xni.XMLDTDHandler;
@@ -167,45 +166,41 @@
     protected static final String USE_GRAMMAR_POOL_ONLY =
         Constants.XERCES_FEATURE_PREFIX + Constants.USE_GRAMMAR_POOL_ONLY_FEATURE;
 
-        // feature identifiers
+    // feature identifiers
 
-        /** Feature identifier: validation. */
-        protected static final String VALIDATION =
-                Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE;
+    /** Feature identifier: validation. */
+    protected static final String VALIDATION =
+        Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE;
 
-        /** Feature identifier: namespaces. */
-        protected static final String NAMESPACES =
-                Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE;
+    /** Feature identifier: namespaces. */
+    protected static final String NAMESPACES =
+        Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE;
 
-        /** Feature identifier: external general entities. */
-        protected static final String EXTERNAL_GENERAL_ENTITIES =
-                Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_GENERAL_ENTITIES_FEATURE;
+    /** Feature identifier: external general entities. */
+    protected static final String EXTERNAL_GENERAL_ENTITIES =
+        Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_GENERAL_ENTITIES_FEATURE;
 
-        /** Feature identifier: external parameter entities. */
-        protected static final String EXTERNAL_PARAMETER_ENTITIES =
-                Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_PARAMETER_ENTITIES_FEATURE;
-
-
+    /** Feature identifier: external parameter entities. */
+    protected static final String EXTERNAL_PARAMETER_ENTITIES =
+        Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_PARAMETER_ENTITIES_FEATURE;
 
     // property identifiers
 
+    /** Property identifier: xml string. */
+    protected static final String XML_STRING =
+        Constants.SAX_PROPERTY_PREFIX + Constants.XML_STRING_PROPERTY;
 
-        /** Property identifier: xml string. */
-        protected static final String XML_STRING =
-                Constants.SAX_PROPERTY_PREFIX + Constants.XML_STRING_PROPERTY;
+    /** Property identifier: symbol table. */
+    protected static final String SYMBOL_TABLE =
+        Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;
 
-        /** Property identifier: symbol table. */
-        protected static final String SYMBOL_TABLE =
-                Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;
+    /** Property identifier: error handler. */
+    protected static final String ERROR_HANDLER =
+        Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_HANDLER_PROPERTY;
 
-        /** Property identifier: error handler. */
-        protected static final String ERROR_HANDLER =
-                Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_HANDLER_PROPERTY;
-
-        /** Property identifier: entity resolver. */
-        protected static final String ENTITY_RESOLVER =
-                Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_RESOLVER_PROPERTY;
-
+    /** Property identifier: entity resolver. */
+    protected static final String ENTITY_RESOLVER =
+        Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_RESOLVER_PROPERTY;
 
     /** Property identifier: XML Schema validator. */
     protected static final String SCHEMA_VALIDATOR =
@@ -219,8 +214,6 @@
     protected static final String SCHEMA_NONS_LOCATION =
         Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_NONS_LOCATION;
 
-    // property identifiers
-
     /** Property identifier: error reporter. */
     protected static final String ERROR_REPORTER =
         Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY;
@@ -292,33 +285,33 @@
     // Data
     //
 
-        protected SymbolTable fSymbolTable;
+    protected SymbolTable fSymbolTable;
     protected XMLInputSource fInputSource;
     protected ValidationManager fValidationManager;
-        protected XMLVersionDetector fVersionDetector;
+    protected XMLVersionDetector fVersionDetector;
     protected XMLLocator fLocator;
-        protected Locale fLocale;
+    protected Locale fLocale;
 
-        /** XML 1.0 Components. */
-        protected ArrayList fComponents;
+    /** XML 1.0 Components. */
+    protected ArrayList<XMLComponent> fComponents;
 
-        /** XML 1.1. Components. */
-        protected ArrayList fXML11Components = null;
+    /** XML 1.1. Components. */
+    protected ArrayList<XMLComponent> fXML11Components = null;
 
-        /** Common components: XMLEntityManager, XMLErrorReporter, XMLSchemaValidator */
-        protected ArrayList fCommonComponents = null;
+    /** Common components: XMLEntityManager, XMLErrorReporter, XMLSchemaValidator */
+    protected ArrayList<XMLComponent> fCommonComponents = null;
 
-        /** The document handler. */
-        protected XMLDocumentHandler fDocumentHandler;
+    /** The document handler. */
+    protected XMLDocumentHandler fDocumentHandler;
 
-        /** The DTD handler. */
-        protected XMLDTDHandler fDTDHandler;
+    /** The DTD handler. */
+    protected XMLDTDHandler fDTDHandler;
 
-        /** The DTD content model handler. */
-        protected XMLDTDContentModelHandler fDTDContentModelHandler;
+    /** The DTD content model handler. */
+    protected XMLDTDContentModelHandler fDTDContentModelHandler;
 
-        /** Last component in the document pipeline */
-        protected XMLDocumentSource fLastComponent;
+    /** Last component in the document pipeline */
+    protected XMLDocumentSource fLastComponent;
 
     /**
      * True if a parse is in progress. This state is needed because
@@ -456,15 +449,15 @@
 
         // create a vector to hold all the components in use
         // XML 1.0 specialized components
-        fComponents = new ArrayList();
+        fComponents = new ArrayList<>();
         // XML 1.1 specialized components
-        fXML11Components = new ArrayList();
+        fXML11Components = new ArrayList<>();
         // Common components for XML 1.1. and XML 1.0
-        fCommonComponents = new ArrayList();
+        fCommonComponents = new ArrayList<>();
 
         // create table for features and properties
-        fFeatures = new HashMap();
-        fProperties = new HashMap();
+        fFeatures = new HashMap<>();
+        fProperties = new HashMap<>();
 
         // add default recognized features
         final String[] recognizedFeatures =
@@ -551,35 +544,35 @@
         }
 
         fEntityManager = new XMLEntityManager();
-                fProperties.put(ENTITY_MANAGER, fEntityManager);
+        fProperties.put(ENTITY_MANAGER, fEntityManager);
         addCommonComponent(fEntityManager);
 
         fErrorReporter = new XMLErrorReporter();
         fErrorReporter.setDocumentLocator(fEntityManager.getEntityScanner());
-                fProperties.put(ERROR_REPORTER, fErrorReporter);
+        fProperties.put(ERROR_REPORTER, fErrorReporter);
         addCommonComponent(fErrorReporter);
 
         fNamespaceScanner = new XMLNSDocumentScannerImpl();
-                fProperties.put(DOCUMENT_SCANNER, fNamespaceScanner);
+        fProperties.put(DOCUMENT_SCANNER, fNamespaceScanner);
         addComponent((XMLComponent) fNamespaceScanner);
 
         fDTDScanner = new XMLDTDScannerImpl();
-                fProperties.put(DTD_SCANNER, fDTDScanner);
+        fProperties.put(DTD_SCANNER, fDTDScanner);
         addComponent((XMLComponent) fDTDScanner);
 
         fDTDProcessor = new XMLDTDProcessor();
-                fProperties.put(DTD_PROCESSOR, fDTDProcessor);
+        fProperties.put(DTD_PROCESSOR, fDTDProcessor);
         addComponent((XMLComponent) fDTDProcessor);
 
         fDTDValidator = new XMLNSDTDValidator();
-                fProperties.put(DTD_VALIDATOR, fDTDValidator);
+        fProperties.put(DTD_VALIDATOR, fDTDValidator);
         addComponent(fDTDValidator);
 
         fDatatypeValidatorFactory = DTDDVFactory.getInstance();
-                fProperties.put(DATATYPE_VALIDATOR_FACTORY, fDatatypeValidatorFactory);
+        fProperties.put(DATATYPE_VALIDATOR_FACTORY, fDatatypeValidatorFactory);
 
         fValidationManager = new ValidationManager();
-                fProperties.put(VALIDATION_MANAGER, fValidationManager);
+        fProperties.put(VALIDATION_MANAGER, fValidationManager);
 
         fVersionDetector = new XMLVersionDetector();
 
@@ -907,20 +900,20 @@
                 // forward to every XML 1.0 component
                 int count = fComponents.size();
                 for (int i = 0; i < count; i++) {
-                        XMLComponent c = (XMLComponent) fComponents.get(i);
+                        XMLComponent c = fComponents.get(i);
                         c.setFeature(featureId, state);
                 }
                 // forward it to common components
                 count = fCommonComponents.size();
                 for (int i = 0; i < count; i++) {
-                        XMLComponent c = (XMLComponent) fCommonComponents.get(i);
+                        XMLComponent c = fCommonComponents.get(i);
                         c.setFeature(featureId, state);
                 }
 
                 // forward to every XML 1.1 component
                 count = fXML11Components.size();
                 for (int i = 0; i < count; i++) {
-                        XMLComponent c = (XMLComponent) fXML11Components.get(i);
+                        XMLComponent c = fXML11Components.get(i);
                         try{
                                 c.setFeature(featureId, state);
                         }
@@ -968,19 +961,19 @@
                 // forward to every XML 1.0 component
                 int count = fComponents.size();
                 for (int i = 0; i < count; i++) {
-                        XMLComponent c = (XMLComponent) fComponents.get(i);
+                        XMLComponent c = fComponents.get(i);
                         c.setProperty(propertyId, value);
                 }
                 // forward it to every common Component
                 count = fCommonComponents.size();
                 for (int i = 0; i < count; i++) {
-                        XMLComponent c = (XMLComponent) fCommonComponents.get(i);
+                        XMLComponent c = fCommonComponents.get(i);
                         c.setProperty(propertyId, value);
                 }
                 // forward it to every XML 1.1 component
                 count = fXML11Components.size();
                 for (int i = 0; i < count; i++) {
-                        XMLComponent c = (XMLComponent) fXML11Components.get(i);
+                        XMLComponent c = fXML11Components.get(i);
                         try{
                                 c.setProperty(propertyId, value);
                         }
@@ -1006,7 +999,7 @@
         protected void reset() throws XNIException {
                 int count = fComponents.size();
                 for (int i = 0; i < count; i++) {
-                        XMLComponent c = (XMLComponent) fComponents.get(i);
+                        XMLComponent c = fComponents.get(i);
                         c.reset(this);
                 }
 
@@ -1019,7 +1012,7 @@
                 // reset common components
                 int count = fCommonComponents.size();
                 for (int i = 0; i < count; i++) {
-                        XMLComponent c = (XMLComponent) fCommonComponents.get(i);
+                        XMLComponent c = fCommonComponents.get(i);
                         c.reset(this);
                 }
 
@@ -1033,7 +1026,7 @@
                 // reset every component
                 int count = fXML11Components.size();
                 for (int i = 0; i < count; i++) {
-                        XMLComponent c = (XMLComponent) fXML11Components.get(i);
+                        XMLComponent c = fXML11Components.get(i);
                         c.reset(this);
                 }
 
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/util/HTTPInputSource.java b/jaxp/src/com/sun/org/apache/xerces/internal/util/HTTPInputSource.java
index f4e29a3..bdd0750 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/util/HTTPInputSource.java
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/util/HTTPInputSource.java
@@ -51,7 +51,7 @@
     protected boolean fFollowRedirects = true;
 
     /** HTTP request properties. **/
-    protected Map fHTTPRequestProperties = new HashMap();
+    protected Map<String, String> fHTTPRequestProperties = new HashMap<>();
 
     //
     // Constructors
@@ -159,7 +159,7 @@
      * been set
      */
     public String getHTTPRequestProperty(String key) {
-        return (String) fHTTPRequestProperties.get(key);
+        return fHTTPRequestProperties.get(key);
     } // getHTTPRequestProperty(String):String
 
     /**
@@ -172,7 +172,7 @@
      * @return an iterator for the request properties this
      * input source contains
      */
-    public Iterator getHTTPRequestProperties() {
+    public Iterator<Map.Entry<String, String>> getHTTPRequestProperties() {
         return fHTTPRequestProperties.entrySet().iterator();
     } // getHTTPRequestProperties():Iterator
 
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/utils/XMLLimitAnalyzer.java b/jaxp/src/com/sun/org/apache/xerces/internal/utils/XMLLimitAnalyzer.java
index b2460d9..8dfe6c7 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/utils/XMLLimitAnalyzer.java
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/utils/XMLLimitAnalyzer.java
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
  *
  * The contents of this file are subject to the terms of either the GNU
  * General Public License Version 2 only ("GPL") or the Common Development
@@ -129,13 +129,15 @@
         if (index == Limit.ENTITY_EXPANSION_LIMIT.ordinal() ||
                 index == Limit.MAX_OCCUR_NODE_LIMIT.ordinal() ||
                 index == Limit.ELEMENT_ATTRIBUTE_LIMIT.ordinal() ||
-                index == Limit.TOTAL_ENTITY_SIZE_LIMIT.ordinal()
+                index == Limit.TOTAL_ENTITY_SIZE_LIMIT.ordinal() ||
+                index == Limit.ENTITY_REPLACEMENT_LIMIT.ordinal()
                 ) {
             totalValue[index] += value;
             return;
         }
         if (index == Limit.MAX_ELEMENT_DEPTH_LIMIT.ordinal() ||
                 index == Limit.MAX_NAME_LIMIT.ordinal()) {
+            values[index] = value;
             totalValue[index] = value;
             return;
         }
@@ -175,10 +177,13 @@
      * @return the value of the property
      */
     public int getValue(Limit limit) {
-        return values[limit.ordinal()];
+        return getValue(limit.ordinal());
     }
 
     public int getValue(int index) {
+        if (index == Limit.ENTITY_REPLACEMENT_LIMIT.ordinal()) {
+            return totalValue[index];
+        }
         return values[index];
     }
     /**
@@ -233,6 +238,11 @@
     public void reset(Limit limit) {
         if (limit.ordinal() == Limit.TOTAL_ENTITY_SIZE_LIMIT.ordinal()) {
             totalValue[limit.ordinal()] = 0;
+        } else if (limit.ordinal() == Limit.GENERAL_ENTITY_SIZE_LIMIT.ordinal()) {
+            names[limit.ordinal()] = null;
+            values[limit.ordinal()] = 0;
+            caches[limit.ordinal()] = null;
+            totalValue[limit.ordinal()] = 0;
         }
     }
 
diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/utils/XMLSecurityManager.java b/jaxp/src/com/sun/org/apache/xerces/internal/utils/XMLSecurityManager.java
index 7ae6df9..6f44177 100644
--- a/jaxp/src/com/sun/org/apache/xerces/internal/utils/XMLSecurityManager.java
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/utils/XMLSecurityManager.java
@@ -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,8 @@
 
 import com.sun.org.apache.xerces.internal.impl.Constants;
 import com.sun.org.apache.xerces.internal.util.SecurityManager;
+import java.util.concurrent.CopyOnWriteArrayList;
+import org.xml.sax.SAXException;
 
 /**
  * This class manages standard and implementation-specific limitations.
@@ -76,7 +78,9 @@
         MAX_ELEMENT_DEPTH_LIMIT("MaxElementDepthLimit",
                 Constants.JDK_MAX_ELEMENT_DEPTH, Constants.SP_MAX_ELEMENT_DEPTH, 0, 0),
         MAX_NAME_LIMIT("MaxXMLNameLimit",
-                Constants.JDK_XML_NAME_LIMIT, Constants.SP_XML_NAME_LIMIT, 1000, 1000);
+                Constants.JDK_XML_NAME_LIMIT, Constants.SP_XML_NAME_LIMIT, 1000, 1000),
+        ENTITY_REPLACEMENT_LIMIT("EntityReplacementLimit",
+                Constants.JDK_ENTITY_REPLACEMENT_LIMIT, Constants.SP_ENTITY_REPLACEMENT_LIMIT, 0, 3000000);
 
         final String key;
         final String apiProperty;
@@ -448,6 +452,7 @@
         if (index == Limit.ELEMENT_ATTRIBUTE_LIMIT.ordinal() ||
                 index == Limit.ENTITY_EXPANSION_LIMIT.ordinal() ||
                 index == Limit.TOTAL_ENTITY_SIZE_LIMIT.ordinal() ||
+                index == Limit.ENTITY_REPLACEMENT_LIMIT.ordinal() ||
                 index == Limit.MAX_ELEMENT_DEPTH_LIMIT.ordinal() ||
                 index == Limit.MAX_NAME_LIMIT.ordinal()
                 ) {
@@ -496,6 +501,23 @@
 
     }
 
+    // Array list to store printed warnings for each SAX parser used
+    private static final CopyOnWriteArrayList<String> printedWarnings = new CopyOnWriteArrayList<>();
+
+    /**
+     * Prints out warnings if a parser does not support the specified feature/property.
+     *
+     * @param parserClassName the name of the parser class
+     * @param propertyName the property name
+     * @param exception the exception thrown by the parser
+     */
+    public static void printWarning(String parserClassName, String propertyName, SAXException exception) {
+        String key = parserClassName+":"+propertyName;
+        if (printedWarnings.addIfAbsent(key)) {
+            System.err.println( "Warning: "+parserClassName+": "+exception.getMessage());
+        }
+    }
+
     /**
      * Read from system properties, or those in jaxp.properties
      *
diff --git a/jaxp/src/com/sun/org/apache/xml/internal/utils/XMLReaderManager.java b/jaxp/src/com/sun/org/apache/xml/internal/utils/XMLReaderManager.java
index a9c9aab..09cd04c 100644
--- a/jaxp/src/com/sun/org/apache/xml/internal/utils/XMLReaderManager.java
+++ b/jaxp/src/com/sun/org/apache/xml/internal/utils/XMLReaderManager.java
@@ -128,8 +128,8 @@
                     try {
                         reader.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, _secureProcessing);
                     } catch (SAXNotRecognizedException e) {
-                        System.err.println("Warning:  " + reader.getClass().getName() + ": "
-                                + e.getMessage());
+                        XMLSecurityManager.printWarning(reader.getClass().getName(),
+                                XMLConstants.FEATURE_SECURE_PROCESSING, e);
                     }
                 } catch (Exception e) {
                    try {
@@ -172,23 +172,25 @@
             //reader is cached, but this property might have been reset
             reader.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, _accessExternalDTD);
         } catch (SAXException se) {
-            System.err.println("Warning:  " + reader.getClass().getName() + ": "
-                        + se.getMessage());
+            XMLSecurityManager.printWarning(reader.getClass().getName(),
+                    XMLConstants.ACCESS_EXTERNAL_DTD, se);
         }
 
+        String lastProperty = "";
         try {
             if (_xmlSecurityManager != null) {
                 for (XMLSecurityManager.Limit limit : XMLSecurityManager.Limit.values()) {
-                    reader.setProperty(limit.apiProperty(),
+                    lastProperty = limit.apiProperty();
+                    reader.setProperty(lastProperty,
                             _xmlSecurityManager.getLimitValueAsString(limit));
                 }
                 if (_xmlSecurityManager.printEntityCountInfo()) {
+                    lastProperty = XalanConstants.JDK_ENTITY_COUNT_INFO;
                     reader.setProperty(XalanConstants.JDK_ENTITY_COUNT_INFO, XalanConstants.JDK_YES);
                 }
             }
         } catch (SAXException se) {
-            System.err.println("Warning:  " + reader.getClass().getName() + ": "
-                        + se.getMessage());
+            XMLSecurityManager.printWarning(reader.getClass().getName(), lastProperty, se);
         }
 
         return reader;
diff --git a/jaxp/src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_de.java b/jaxp/src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_de.java
index 1ddecd6..e7624ef 100644
--- a/jaxp/src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_de.java
+++ b/jaxp/src/com/sun/org/apache/xpath/internal/res/XPATHErrorResources_de.java
@@ -483,7 +483,7 @@
      "Fehler aufgetreten."},
 
   { ER_ILLEGAL_VARIABLE_REFERENCE,
-      "VariableReference au\u00DFerhalb des Kontextes oder ohne Definition f\u00FCr Variable angegeben. Name = {0}"},
+      "VariableReference au\u00DFerhalb des Kontexts oder ohne Definition f\u00FCr Variable angegeben. Name = {0}"},
 
   { ER_AXES_NOT_ALLOWED,
       "Nur \"child::\"- und \"attribute::\"-Achsen sind in Vergleichsmustern zul\u00E4ssig. Betreffende Achsen = {0}"},
@@ -855,7 +855,7 @@
       "Option \"-E\" nicht unterst\u00FCtzt f\u00FCr DTM-Parser"},
 
   { WG_ILLEGAL_VARIABLE_REFERENCE,
-      "VariableReference au\u00DFerhalb des Kontextes oder ohne Definition f\u00FCr Variable angegeben. Name = {0}"},
+      "VariableReference au\u00DFerhalb des Kontexts oder ohne Definition f\u00FCr Variable angegeben. Name = {0}"},
 
   { WG_UNSUPPORTED_ENCODING,
      "Nicht unterst\u00FCtzte Codierung: {0}"},
diff --git a/jaxp/src/com/sun/xml/internal/stream/writers/XMLStreamWriterImpl.java b/jaxp/src/com/sun/xml/internal/stream/writers/XMLStreamWriterImpl.java
index 8262111..f3b9b50 100644
--- a/jaxp/src/com/sun/xml/internal/stream/writers/XMLStreamWriterImpl.java
+++ b/jaxp/src/com/sun/xml/internal/stream/writers/XMLStreamWriterImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, 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
@@ -1346,6 +1346,15 @@
     }
 
     /**
+     * Writes character reference in hex format.
+     */
+    private void writeCharRef(int codePoint) throws IOException {
+        fWriter.write( "&#x" );
+        fWriter.write( Integer.toHexString(codePoint) );
+        fWriter.write( ';' );
+    }
+
+    /**
      * Writes XML content to underlying writer. Escapes characters unless
      * escaping character feature is turned off.
      */
@@ -1368,10 +1377,14 @@
             if (fEncoder != null && !fEncoder.canEncode(ch)){
                 fWriter.write(content, startWritePos, index - startWritePos );
 
-                // Escape this char as underlying encoder cannot handle it
-                fWriter.write( "&#x" );
-                fWriter.write(Integer.toHexString(ch));
-                fWriter.write( ';' );
+                // Check if current and next characters forms a surrogate pair
+                // and escape it to avoid generation of invalid xml content
+                if ( index != end - 1 && Character.isSurrogatePair(ch, content[index+1])) {
+                    writeCharRef(Character.toCodePoint(ch, content[index+1]));
+                    index++;
+                } else {
+                    writeCharRef(ch);
+                }
                 startWritePos = index + 1;
                 continue;
             }
@@ -1439,10 +1452,15 @@
             if (fEncoder != null && !fEncoder.canEncode(ch)){
                 fWriter.write(content, startWritePos, index - startWritePos );
 
-                // Escape this char as underlying encoder cannot handle it
-                fWriter.write( "&#x" );
-                fWriter.write(Integer.toHexString(ch));
-                fWriter.write( ';' );
+                // Check if current and next characters forms a surrogate pair
+                // and escape it to avoid generation of invalid xml content
+                if ( index != end - 1 && Character.isSurrogatePair(ch, content.charAt(index+1))) {
+                    writeCharRef(Character.toCodePoint(ch, content.charAt(index+1)));
+                    index++;
+                } else {
+                    writeCharRef(ch);
+                }
+
                 startWritePos = index + 1;
                 continue;
             }
diff --git a/jaxws/.hgtags b/jaxws/.hgtags
index 2cb6e94..f607b6b 100644
--- a/jaxws/.hgtags
+++ b/jaxws/.hgtags
@@ -384,6 +384,7 @@
 a5f2cdedb940511674e153dce8d3cbc3a0598c9e jdk8u40-b27
 a342e6841e8d3bbef44d4158c980be2ab903e10a jdk8u40-b31
 8960bce00f1abecad665291b0077d6e673c0ff64 jdk8u40-b32
+f9e72841a77fe0402da947500359f4d60ecc89df jdk8u40-b33
 667a4aee3720373f5c286a50f537afd0ff4b65ae jdk8u45-b00
 cb6added4913f4899bd1689e77be1fe4efcff4f1 jdk8u45-b01
 855a7b9302053546e4da94b67cc3b8956f5b4985 jdk8u45-b02
@@ -550,6 +551,7 @@
 d0161a6ecd3bf8c9953e979db8318177e4f2aa86 jdk8u75-b01
 57eb6af19a97a835b07c618d1c0aea50a0577337 jdk8u75-b02
 3412fd49bcbedcc4b0f6ae13a149e53ecde968ae jdk8u75-b03
+6580edbc4511d5a2281138c476700b8ab12165af jdk8u101-b00
 6580edbc4511d5a2281138c476700b8ab12165af jdk8u75-b04
 31337d5922975e1655764a7db158154d48866c13 jdk8u75-b05
 7fca20ec14beec302f7a4d446d1d8646a9a0b74f jdk8u75-b06
@@ -565,6 +567,7 @@
 f66ee2329cd21c3485de1b8e0588f55882a56e0d jdk8u91-b00
 be5935ee38f1bc5132cf318f7badb61af86e2396 jdk8u91-b13
 e71f424e2c966a495b1d47693317288f291a794a jdk8u91-b14
+4c0ed3f71a596277f3c28b3f841d5c4ee7a007e6 jdk8u91-b15
 6aba0f814a15966e47aeab61b466894b82c03c70 jdk8u76-b00
 60789eebd1fe440255fd3f504221dc8b5553b8c2 jdk8u76-b01
 8c7d476c446940edd913ba5a3ca36975febdac28 jdk8u76-b02
@@ -584,3 +587,39 @@
 38c6262b86559ff589f65f5bcc744b1763e20311 jdk8u92-b31
 b762186ac713fbb0fc759110a1c88bca4b4818cd jdk8u92-b32
 ff694a4e9cae136032855516e5f0cd7f1a0e6957 jdk8u92-b33
+283147c5fcc5027b39ca577250edaec4b4b87c0f jdk8u92-b34
+6580edbc4511d5a2281138c476700b8ab12165af jdk8u81-b00
+0bff22fbd91f48c37f7c5a4544929231b92bd9bf jdk8u101-b01
+31e437ae0354e628a675bc4eb6b9ca67af552fc2 jdk8u101-b02
+2a5ea5a78ae7332b3d13af5580418ca9d186cda7 jdk8u101-b03
+d3b054313ed2d29f9dbbdfd71a7ab3c4ad4eb5b6 jdk8u101-b04
+0a657e4d5ed57bf3216b96915633b661f6532be5 jdk8u101-b05
+8cef2df1e60991bfdd8b2d8a8bad9e3506c1a386 jdk8u101-b06
+96be6de53286422ccbfd1c4fdf36a0490af32edb jdk8u101-b07
+a6ed0b0e8707b7112c99294122d7f3b259707603 jdk8u101-b08
+a93b161995a80cf7b0e599cf2f91e755ab1c7098 jdk8u101-b09
+ea422e4481f6edfb77bb3a4cd74a73e463143ff3 jdk8u101-b10
+5f3dcb815b9715215d086ba0d48a59b23d01d0a4 jdk8u101-b11
+6a0347504d4c4171fcc24bc17749c0559518d862 jdk8u101-b12
+287f9e9d45cc05b902925346bb6f6ee34a5d5813 jdk8u101-b13
+6aba0f814a15966e47aeab61b466894b82c03c70 jdk8u76-b00
+60789eebd1fe440255fd3f504221dc8b5553b8c2 jdk8u76-b01
+8c7d476c446940edd913ba5a3ca36975febdac28 jdk8u76-b02
+4b728dce9390e63f60d9ea445c229430ed059174 jdk8u76-b03
+4dfb56754487262e72d2e76900ddb6db51974f2d jdk8u76-b04
+a0c077b39c7a331bda9764a173a2b02d0725f28f jdk8u102-b00
+a0c077b39c7a331bda9764a173a2b02d0725f28f jdk8u82-b00
+c0ad0fa38df0841eaaf81ab40e8b07b42372c5d5 jdk8u102-b01
+face9bd6bac2d43d4c423be4fe733689794c2f08 jdk8u102-b02
+4e12f131bb0dbe0478aecb7ebdfe24b10d3ece75 jdk8u102-b03
+5b1d73ea0eb68cef733eb9379ed71cfb008da72e jdk8u102-b04
+1f512419ae336ce17f1d16384e34669a81db27ae jdk8u102-b05
+c8f5925b8ec9491d95538d94803cf03b2d75d1b6 jdk8u102-b06
+d4bd96ee50976dc9e4cb308d8728e70ecb03a944 jdk8u102-b07
+ca64f5f827251b5c28046f79c3577fbc8991d3d7 jdk8u102-b08
+5b93dc7249127c6beae1a688b6cea204bac3fdd0 jdk8u102-b09
+7a11148c41b867305b153b6b82d75717accea119 jdk8u102-b10
+0305736a8580ad84733878623eda8f770ae04d60 jdk8u102-b11
+d02665ceefe5b12539bcd2bde95d4ada1a135cb0 jdk8u102-b12
+d84434eb3e4e991812a7b0c3c9e6bfdabae910d0 jdk8u102-b13
+81f2d81a48d74d2d4882c11330366517b73ee064 jdk8u102-b14
diff --git a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/model/CTypeRef.java b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/model/CTypeRef.java
index 62416b0..bcea98f 100644
--- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/model/CTypeRef.java
+++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/model/CTypeRef.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, 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
@@ -100,10 +100,15 @@
      */
     private static QName resolveSimpleTypeName(XSType declType) {
         QName name = BGMBuilder.getName(declType);
-        if (name != null && !XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(name.getNamespaceURI()))
-            return resolveSimpleTypeName(declType.getBaseType());
-        else
-            return name;
+        QName result = null;
+        if (name != null && !XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(name.getNamespaceURI())) {
+            result = resolveSimpleTypeName(declType.getBaseType());
+        } else {
+            if ( !"anySimpleType".equals(declType.getName()) ) {
+                result = name;
+            }
+        }
+        return result;
     }
 
     public CTypeRef(CNonElement type, QName elementName, QName typeName, boolean nillable, XmlString defaultValue) {
diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/StructureLoader.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/StructureLoader.java
index 0d4fa26..941944b 100644
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/StructureLoader.java
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/StructureLoader.java
@@ -231,22 +231,11 @@
     @Override
     public void childElement(UnmarshallingContext.State state, TagName arg) throws SAXException {
         ChildLoader child = childUnmarshallers.get(arg.uri,arg.local);
-        if(child==null) {
-            if ((beanInfo != null) && (beanInfo.getTypeNames() != null)) {
-                Iterator typeNamesIt = beanInfo.getTypeNames().iterator();
-                QName parentQName = null;
-                if ((typeNamesIt != null) && (typeNamesIt.hasNext()) && (catchAll == null)) {
-                    parentQName = (QName) typeNamesIt.next();
-                    String parentUri = parentQName.getNamespaceURI();
-                    child = childUnmarshallers.get(parentUri, arg.local);
-                }
-            }
-            if (child == null) {
-                child = catchAll;
-                if(child==null) {
-                    super.childElement(state,arg);
-                    return;
-                }
+        if (child == null) {
+            child = catchAll;
+            if (child==null) {
+                super.childElement(state,arg);
+                return;
             }
         }
 
diff --git a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/XmlSchemaGenerator.java b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/XmlSchemaGenerator.java
index 30c8080..a9cb5be 100644
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/XmlSchemaGenerator.java
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/XmlSchemaGenerator.java
@@ -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
@@ -110,6 +110,7 @@
 import com.sun.xml.internal.txw2.output.ResultFactory;
 import com.sun.xml.internal.txw2.output.XmlSerializer;
 import java.util.Collection;
+import java.util.HashSet;
 import org.xml.sax.SAXParseException;
 
 /**
@@ -436,7 +437,7 @@
 
         if(logger.isLoggable(Level.FINE)) {
             // debug logging to see what's going on.
-            logger.log(Level.FINE,"Wrigin XML Schema for "+toString(),new StackRecorder());
+            logger.log(Level.FINE,"Writing XML Schema for "+toString(),new StackRecorder());
         }
 
         // make it fool-proof
@@ -465,6 +466,8 @@
                     systemIds.put(n,output.getSystemId());
                 }
             }
+            //Clear the namespace specific set with already written classes
+            n.resetWritten();
         }
 
         // then write'em all
@@ -542,6 +545,11 @@
          */
         private boolean useMimeNs;
 
+        /**
+         * Container for already processed classes
+         */
+        private final Set<ClassInfo> written = new HashSet<ClassInfo>();
+
         public Namespace(String uri) {
             this.uri = uri;
             assert !XmlSchemaGenerator.this.namespaces.containsKey(uri);
@@ -549,6 +557,13 @@
         }
 
         /**
+         * Clear out the set of already processed classes for this namespace
+         */
+        void resetWritten() {
+            written.clear();
+        }
+
+        /**
          * Process the given PropertyInfo looking for references to namespaces that
          * are foreign to the given namespace.  Any foreign namespace references
          * found are added to the given namespaces dependency list and an &lt;import>
@@ -853,6 +868,10 @@
          * @param parent the writer of the parent element into which the type will be defined
          */
         private void writeClass(ClassInfo<T,C> c, TypeHost parent) {
+            if (written.contains(c)) { // to avoid cycles let's check if we haven't already processed the class
+                return;
+            }
+            written.add(c);
             // special handling for value properties
             if (containsValueProp(c)) {
                 if (c.getProperties().size() == 1) {
diff --git a/jdk/.hgtags b/jdk/.hgtags
index 9b69b6f..2a40448 100644
--- a/jdk/.hgtags
+++ b/jdk/.hgtags
@@ -389,6 +389,7 @@
 d4453d784fb6c52e4ed998b167588551e2fd43c5 jdk8u40-b27
 5a45234e0fc14ff943e13dc1f8966818acaeb4de jdk8u40-b31
 d8ac13c5eafe422d3425dc1aebebfcdf8ca67e2d jdk8u40-b32
+c7fbbf6133c339fb56f03241de28666774023d5d jdk8u40-b33
 1ecc234bd38950a2bc047aa253a5e803f0836a4e jdk8u45-b00
 e0c7864bbca3f76cde680722f2ae58dff2bff61d jdk8u45-b01
 9505c0392cddbfb905401e9fccc23262edc3254f jdk8u45-b02
@@ -543,11 +544,17 @@
 32c49f4a16599e376e4e46bb33c7bcc486e52ff3 jdk8u74-b02
 9c828e688240362b6f1b761b619cdaa070462c4e jdk8u74-b31
 6968ca30f8fdc9429fcd56187e16f46b215b474b jdk8u74-b32
+02e1209648050922a5a9f2789d9d359795f6f834 jdk8u77-b00
+f08584a0fde9344b0aa4766984266ca68b9a5018 jdk8u77-b01
+1a3e81c05703bb36def80a57681e1692c866f621 jdk8u77-b02
+c44179bce874a97e93ffd7b76a226af417e017a4 jdk8u77-b03
+8c3f4e540348daed7263bae092b0e5f212478b00 jdk8u77-b31
 1d4b343084874b1afa1cdd504b9b1e50bab7f121 jdk8u72-b31
 7cfd2c51c501df909833aa0fb6e40c50c61621ed jdk8u75-b00
 9e00a43602f87930c2318b2567002871ad9c59dd jdk8u75-b01
 9de301db625bb1b462aad3ebd8347118b94bb728 jdk8u75-b02
 dcacefa73649a2d821267b6bff1d70aa10a06801 jdk8u75-b03
+f6cc9dbb5db5883385c91bb71ca02081220aaf3d jdk8u101-b00
 de91f05824c5398cb2d2f666ff404aaa165498de jdk8u75-b04
 4138b3f27ffea524185a604c3f4f149c7e5ba780 jdk8u75-b05
 32f64c19b5fba8beeae5236ca6e480bd8e99698a jdk8u75-b06
@@ -564,6 +571,7 @@
 71f59a00df6c8f3bd5c6d6631a4988a431adab56 jdk8u91-b00
 7ade7a1ab10ff893f62cce9440b4a839aa19c250 jdk8u91-b13
 f8725698a870b6be82fad578e78a55910b259975 jdk8u91-b14
+29380f4d81bd92a6a7aa7a984ca4541ff3ac3a67 jdk8u91-b15
 39baa472e20c13c0eb1243eb5dce589e82f78143 jdk8u76-b00
 6ea3aea950d19d803475b3f4d704a2942e71b302 jdk8u76-b01
 4de4cffb5988cd68959ce4bbd14c6d4547078c91 jdk8u76-b02
@@ -583,3 +591,39 @@
 5875e297cfcf18304b4b062dc44fa9be312ad6e8 jdk8u92-b31
 ed69541ce48b38bf0830c762f353e4379ce43630 jdk8u92-b32
 739b1dc838cdf73c7e16bacb5ce4d1c4534c7d76 jdk8u92-b33
+1f29ae07173450d753189e5aa9d8bb46fb2f5982 jdk8u92-b34
+f6cc9dbb5db5883385c91bb71ca02081220aaf3d jdk8u81-b00
+00f8f39308687cde45f23282871c46cc6c2f10b3 jdk8u101-b01
+6042757c329b1b96fa6bc931e09306794f5c50c0 jdk8u101-b02
+25934d0d38fe10383ff22eb3f39bf5e8b9e73ac9 jdk8u101-b03
+ebc56c2e803597ef409a5296addc986b390d934d jdk8u101-b04
+c387bd2fb7db40467bd9aa803c8510a04ca32bae jdk8u101-b05
+a15cdf2e91e7c2d71510280b31ae11048fb2f31e jdk8u101-b06
+fdc0b30af431e17ffaed24ef5d545ae4cf7ddf6d jdk8u101-b07
+4dc4099e933a6f4584b51305b26b5798f042699b jdk8u101-b08
+5e7489ac05f0001e234e6d1c8730b465e74c9626 jdk8u101-b09
+9486707c119ab3940f7ea06c1af23a4f6367c77b jdk8u101-b10
+a9136f8d24d9ed01009df847176e0be67b354d15 jdk8u101-b11
+3eab3ce82c31d1332bc383a1a3201eaee220c001 jdk8u101-b12
+827b2350d7f8a96160aa820200a7bf6358b51450 jdk8u101-b13
+39baa472e20c13c0eb1243eb5dce589e82f78143 jdk8u76-b00
+6ea3aea950d19d803475b3f4d704a2942e71b302 jdk8u76-b01
+4de4cffb5988cd68959ce4bbd14c6d4547078c91 jdk8u76-b02
+8bef978e2374604f449b4d1d7f90cb26618540d7 jdk8u76-b03
+e057622070e5415c13b6d8511b97dce8bd2e398d jdk8u76-b04
+fa5a91b29658aa9eb7aff54ae34898c149ff7149 jdk8u102-b00
+fa5a91b29658aa9eb7aff54ae34898c149ff7149 jdk8u82-b00
+569e105bed3c517a47f0f1ebce0abcaf776a8e89 jdk8u102-b01
+5d5b55014d0da5bafb42366dc6d668ced4b8dec4 jdk8u102-b02
+abab8d5270997ad25e0699151eed48ce8db40787 jdk8u102-b03
+50809de3dcc24eb8cf86b8518cf0cc0423b61f4b jdk8u102-b04
+cdfb600c2dce889af220ebb6c4b0764066baa741 jdk8u102-b05
+59698da7972e97f4a18845b9c879f165b3c52e98 jdk8u102-b06
+725b400c93e0209c64f36f6191b8d1fd3ef9ed30 jdk8u102-b07
+c260a0aab5bff09f439914829b81f037715029bb jdk8u102-b08
+605340e782425b68342c1bc6485b747708de6101 jdk8u102-b09
+b64716a25e409798fcd7ed6143d55681ee4a4baa jdk8u102-b10
+e915a408ebf7ba05b36d1b714e166a1d9e5c7edd jdk8u102-b11
+8e12cb096db33b525ec010de5e857ef1cc985ddd jdk8u102-b12
+901ecf04370c7c03c61e22ab87a266c355baff54 jdk8u102-b13
+48c99b42383912886c005891c04b5f599adf6722 jdk8u102-b14
diff --git a/jdk/make/CopyIntoClasses.gmk b/jdk/make/CopyIntoClasses.gmk
index d46363c..10c4f94 100644
--- a/jdk/make/CopyIntoClasses.gmk
+++ b/jdk/make/CopyIntoClasses.gmk
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2013, 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
@@ -190,7 +190,11 @@
   SRC_SERVICES_FILES := $(filter-out %sun/java2d/cmm/kcms/META-INF/services/sun.java2d.cmm.CMMServiceProvider, $(SRC_SERVICES_FILES))
 else
   SRC_SERVICES_FILES := $(filter-out %sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine, $(SRC_SERVICES_FILES))
-  SRC_SERVICES_FILES := $(filter-out %sun/java2d/cmm/lcms/META-INF/services/sun.java2d.cmm.CMMServiceProvider, $(SRC_SERVICES_FILES))
+  ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH), linux-sparc)
+    SRC_SERVICES_FILES := $(filter-out %sun/java2d/cmm/kcms/META-INF/services/sun.java2d.cmm.CMMServiceProvider, $(SRC_SERVICES_FILES))
+  else
+    SRC_SERVICES_FILES := $(filter-out %sun/java2d/cmm/lcms/META-INF/services/sun.java2d.cmm.CMMServiceProvider, $(SRC_SERVICES_FILES))
+  endif
 endif
 
 # The number of services files are relatively few. If the increase in numbers, then
diff --git a/jdk/make/data/tzdata/VERSION b/jdk/make/data/tzdata/VERSION
index 55966f2..5aaf0c5 100644
--- a/jdk/make/data/tzdata/VERSION
+++ b/jdk/make/data/tzdata/VERSION
@@ -21,4 +21,4 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
-tzdata2016a
+tzdata2016d
diff --git a/jdk/make/data/tzdata/asia b/jdk/make/data/tzdata/asia
index 056a5f9..58b43e9 100644
--- a/jdk/make/data/tzdata/asia
+++ b/jdk/make/data/tzdata/asia
@@ -102,13 +102,9 @@
 Rule E-EurAsia	1996	max	-	Oct	lastSun	 0:00	0	-
 Rule RussiaAsia	1981	1984	-	Apr	1	 0:00	1:00	S
 Rule RussiaAsia	1981	1983	-	Oct	1	 0:00	0	-
-Rule RussiaAsia	1984	1991	-	Sep	lastSun	 2:00s	0	-
-Rule RussiaAsia	1985	1991	-	Mar	lastSun	 2:00s	1:00	S
-Rule RussiaAsia	1992	only	-	Mar	lastSat	23:00	1:00	S
-Rule RussiaAsia	1992	only	-	Sep	lastSat	23:00	0	-
-Rule RussiaAsia	1993	max	-	Mar	lastSun	 2:00s	1:00	S
-Rule RussiaAsia	1993	1995	-	Sep	lastSun	 2:00s	0	-
-Rule RussiaAsia	1996	max	-	Oct	lastSun	 2:00s	0	-
+Rule RussiaAsia	1984	1995	-	Sep	lastSun	 2:00s	0	-
+Rule RussiaAsia	1985	2011	-	Mar	lastSun	 2:00s	1:00	S
+Rule RussiaAsia	1996	2011	-	Oct	lastSun	 2:00s	0	-
 
 # Afghanistan
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
@@ -148,17 +144,26 @@
 			3:00	1:00	YERST	1991 Sep 23 # independence
 			3:00 RussiaAsia	AM%sT	1995 Sep 24  2:00s
 			4:00	-	AMT	1997
-			4:00 RussiaAsia	AM%sT	2012 Mar 25  2:00s
+			4:00 RussiaAsia	AM%sT	2012 Feb  9
 			4:00	-	AMT
 
 # Azerbaijan
+
 # From Rustam Aliyev of the Azerbaijan Internet Forum (2005-10-23):
 # According to the resolution of Cabinet of Ministers, 1997
 # From Paul Eggert (2015-09-17): It was Resolution No. 21 (1997-03-17).
 # http://code.az/files/daylight_res.pdf
+
+# From Steffen Thorsen (2016-03-17):
+# ... the Azerbaijani Cabinet of Ministers has cancelled switching to
+# daylight saving time....
+# http://www.azernews.az/azerbaijan/94137.html
+# http://vestnikkavkaza.net/news/Azerbaijani-Cabinet-of-Ministers-cancels-daylight-saving-time.html
+# http://en.apa.az/xeber_azerbaijan_abolishes_daylight_savings_ti_240862.html
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
-Rule	Azer	1997	max	-	Mar	lastSun	 4:00	1:00	S
-Rule	Azer	1997	max	-	Oct	lastSun	 5:00	0	-
+Rule	Azer	1997	2015	-	Mar	lastSun	 4:00	1:00	S
+Rule	Azer	1997	2015	-	Oct	lastSun	 5:00	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Baku	3:19:24 -	LMT	1924 May  2
 			3:00	-	BAKT	1957 Mar    # Baku Time
@@ -1581,23 +1586,6 @@
 
 # Kazakhstan
 
-# From Paul Eggert (1996-11-22):
-# Andrew Evtichov (1996-04-13) writes that Kazakhstan
-# stayed in sync with Moscow after 1990, and that Aqtobe (formerly Aktyubinsk)
-# and Aqtau (formerly Shevchenko) are the largest cities in their zones.
-# Guess that Aqtau and Aqtobe diverged in 1995, since that's the first time
-# IATA SSIM mentions a third time zone in Kazakhstan.
-
-# From Paul Eggert (2006-03-22):
-# German Iofis, ELSI, Almaty (2001-10-09) reports that Kazakhstan uses
-# RussiaAsia rules, instead of switching at 00:00 as the IATA has it.
-# Go with Shanks & Pottenger, who have them always using RussiaAsia rules.
-# Also go with the following claims of Shanks & Pottenger:
-#
-# - Kazakhstan did not observe DST in 1991.
-# - Qyzylorda switched from +5:00 to +6:00 on 1992-01-19 02:00.
-# - Oral switched from +5:00 to +4:00 in spring 1989.
-
 # From Kazakhstan Embassy's News Bulletin No. 11
 # <http://www.kazsociety.org.uk/news/2005/03/30.htm> (2005-03-21):
 # The Government of Kazakhstan passed a resolution March 15 abolishing
@@ -1614,61 +1602,232 @@
 # everything else....  I guess that would make Kazakhstan time zones
 # de jure UTC+5 and UTC+6 respectively.
 
+# From Stepan Golosunov (2016-03-27) ([*] means see later comments below):
+# Review of the linked documents from http://adilet.zan.kz/
+# produced the following data for post-1991 Kazakhstan:
+#
+# 0. Act of the Cabinet of Ministers of the USSR
+# from 1991-02-04 No. 20
+# http://pravo.gov.ru/proxy/ips/?docbody=&nd=102010545
+# removed the extra hour ("decree time") on the territory of the USSR
+# starting with the last Sunday of March 1991.
+# It also allowed (but not mandated) Kazakh SSR, Kirghiz SSR, Tajik SSR,
+# Turkmen SSR and Uzbek SSR to not have "summer" time.
+#
+# The 1992-01-13 act also refers to the act of the Cabinet of Ministers
+# of the Kazakh SSR from 1991-03-20 No. 170 "About the act of the Cabinet
+# of Ministers of the USSR from 1991-02-04 No. 20" but I didn't found its
+# text.
+#
+# According to Izvestia newspaper No. 68 (23334) from 1991-03-20
+# (page 6; available at http://libinfo.org/newsr/newsr2574.djvu via
+# http://libinfo.org/index.php?id=58564) on 1991-03-31 at 2:00 during
+# transition to "summer" time:
+# Republic of Georgia, Latvian SSR, Lithuanian SSR, SSR Moldova,
+# Estonian SSR; Komi ASSR; Kaliningrad oblast; Nenets autonomous okrug
+# were to move clocks 1 hour forward.
+# Kazakh SSR (excluding Uralsk oblast); Republic of Kyrgyzstan, Tajik
+# SSR; Andijan, Jizzakh, Namangan, Sirdarya, Tashkent, Fergana oblasts
+# of the Uzbek SSR were to move clocks 1 hour backwards.
+# Other territories were to not move clocks.
+# When the "summer" time would end on 1991-09-29, clocks were to be
+# moved 1 hour backwards on the territory of the USSR excluding
+# Kazakhstan, Kirghizia, Uzbekistan, Turkmenia, Tajikistan.
+#
+# Apparently there were last minute changes. Apparently Kazakh act No. 170
+# was one of such changes.
+#
+# https://ru.wikipedia.org/wiki/Декретное время
+# claims that Sovetskaya Rossiya newspaper on 1991-03-29 published that
+# Nenets autonomous okrug, Komi and Kazakhstan (excluding Uralsk oblast)
+# were to not move clocks and Uralsk oblast was to move clocks
+# forward; on 1991-09-29 Kazakhstan was to move clocks backwards.
+# (Probably there were changes even after that publication. There is an
+# article claiming that Kaliningrad oblast decided on 1991-03-29 to not
+# move clocks.)
+#
+# This implies that on 1991-03-31 Asia/Oral remained on +04/+05 while
+# the rest of Kazakhstan switched from +06/+07 to +05/06 or from +05/06
+# to +04/+05. It's unclear how Kzyl-Orda oblast moved into the fifth
+# time belt. (By switching from +04/+05 to +05/+06 on 1991-09-29?) ...
+#
+# 1. Act of the Cabinet of Ministers of the Republic of Kazakhstan
+# from 1992-01-13 No. 28
+# http://adilet.zan.kz/rus/docs/P920000028_
+# (text includes modification from the 1996 act)
+# introduced new rules for calculation of time, mirroring Russian
+# 1992-01-08 act.  It specified that time would be calculated
+# according to time belts plus extra hour ("decree time"), moved clocks
+# on the whole territory of Kazakhstan 1 hour forward on 1992-01-19 at
+# 2:00, specified DST rules.  It acknowledged that Kazakhstan was
+# located in the fourth and the fifth time belts and specified the
+# border between them to be located east of Kustanay and Aktyubinsk
+# oblasts (notably including Turgai and Kzyl-Orda oblasts into the fifth
+# time belt).
+#
+# This means switch on 1992-01-19 at 2:00 from +04/+05 to +05/+06 for
+# Asia/Aqtau, Asia/Aqtobe, Asia/Oral, Atyrau and Kustanay oblasts; from
+# +05/+06 to +06/+07 for Asia/Almaty and Asia/Qyzylorda (and Arkalyk) [*]....
+#
+# 2. Act of the Cabinet of Ministers of the Republic of Kazakhstan
+# from 1992-03-27 No. 284
+# http://adilet.zan.kz/rus/docs/P920000284_
+# cancels extra hour ("decree time") for Uralsk and Kzyl-Orda oblasts
+# since the last Sunday of March 1992, while keeping them in the fourth
+# and the fifth time belts respectively.
+#
+# 3. Order of the Prime Minister of the Republic of Kazakhstan
+# from 1994-09-23 No. 384
+# http://adilet.zan.kz/rus/docs/R940000384_
+# cancels the extra hour ("decree time") on the territory of Mangystau
+# oblast since the last Sunday of September 1994 (saying that time on
+# the territory would correspond to the third time belt as a
+# result)....
+#
+# 4. Act of the Government of the Republic of Kazakhstan
+# from 1996-05-08 No. 575
+# http://adilet.zan.kz/rus/docs/P960000575_
+# amends the 1992-01-13 act to end summer time in October instead
+# of September, mirroring identical Russian change from 1996-04-23 act.
+#
+# 5. Act of the Government of the Republic of Kazakhstan
+# from 1999-03-26 No. 305
+# http://adilet.zan.kz/rus/docs/P990000305_
+# cancels the extra hour ("decree time") for Atyrau oblast since the
+# last Sunday of March 1999 while retaining the oblast in the fourth
+# time belt.
+#
+# This means change from +05/+06 to +04/+05.
+#
+# There is no zone for Atyrau currently (listed under Asia/Aqtau in
+# zone1970.tab).[*]
+#
+# 6. Act of the Government of the Republic of Kazakhstan
+# from 2000-11-23 No. 1749
+# http://adilet.zan.kz/rus/archive/docs/P000001749_/23.11.2000
+# replaces the previous five documents.
+#
+# The only changes I noticed are in definition of the border between the
+# fourth and the fifth time belts.  They account for changes in spelling
+# and administrative division (splitting of Turgai oblast in 1997
+# probably changed time in territories incorporated into Kostanay oblast
+# (including Arkalyk) from +06/+07 to +05/+06) and move Kyzylorda oblast
+# from being in the fifth time belt and not using decree time into the
+# fourth time belt (no change in practice).[*]
+#
+# 7. Act of the Government of the Republic of Kazakhstan
+# from 2003-12-29 No. 1342
+# http://adilet.zan.kz/rus/docs/P030001342_
+# modified the 2000-11-23 act.  No relevant changes, apparently.
+#
+# 8. Act of the Government of the Republic of Kazakhstan
+# from 2004-07-20 No. 775
+# http://adilet.zan.kz/rus/archive/docs/P040000775_/20.07.2004
+# modified the 2000-11-23 act to move Kostanay and Kyzylorda oblasts into
+# the fifth time belt and add Aktobe oblast to the list of regions not
+# using extra hour ("decree time"), leaving Kazakhstan with only 2 time
+# zones (+04/+05 and +06/+07).  The changes were to be implemented
+# during DST transitions in 2004 and 2005 but the acts got radically
+# amended before implementation happened.
+#
+# 9. Act of the Government of the Republic of Kazakhstan
+# from 2004-09-15 No. 1059
+# http://adilet.zan.kz/rus/docs/P040001059_
+# modified the 2000-11-23 act to remove exceptions from the "decree time"
+# (leaving Kazakhstan in +05/+06 and +06/+07 zones), amended the
+# 2004-07-20 act to implement changes for Atyrau, West Kazakhstan,
+# Kostanay, Kyzylorda and Mangystau oblasts by not moving clocks
+# during the 2014 transition to "winter" time.
+#
+# This means transition from +04/+05 to +05/+06 for Atyrau oblast (no
+# zone currently), Asia/Oral, Asia/Aqtau and transition from +05/+06 to
+# +06/+07 for Kostanay oblast (Kostanay and Arkalyk, no zones currently)
+# and Asia/Qyzylorda on 2004-10-31 at 3:00....[*]
+#
+# 10. Act of the Government of the Republic of Kazakhstan
+# from 2005-03-15 No. 231
+# http://adilet.zan.kz/rus/docs/P050000231_
+# removes DST provisions from the 2000-11-23 act, removes most of the
+# (already implemented) provisions from the 2004-07-20 and 2004-09-15
+# acts, comes into effect 10 days after official publication.
+# The only practical effect seems to be the abolition of the summer
+# time.
+#
+# Unamended version of the act of the Government of the Russian Federation
+# No. 23 from 1992-01-08 [See 'europe' file for details].
+# Kazakh 1992-01-13 act appears to provide the same rules and 1992-03-27
+# act was to be enacted on the last Sunday of March 1992.
+
+# From Paul Eggert (2016-04-15):
+# The tables below should reflect Stepan Golosunov's remarks above,
+# except for the items marked "[*]" which I haven't gotten to yet.
+# It looks like we will need new zones Asia/Atyrau and Asia/Qostanay
+# to handle changes from 1992 through 2004 that we did not previously
+# know about.
+
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 #
 # Almaty (formerly Alma-Ata), representing most locations in Kazakhstan
+# This includes KZ-AKM, KZ-ALA, KZ-ALM, KZ-AST, KZ-BAY, KZ-VOS, KZ-ZHA,
+# KZ-KAR, KZ-SEV, KZ-PAV, and KZ-YUZ.
 Zone	Asia/Almaty	5:07:48 -	LMT	1924 May  2 # or Alma-Ata
-			5:00	-	ALMT	1930 Jun 21 # Alma-Ata Time
-			6:00 RussiaAsia ALM%sT	1991
-			6:00	-	ALMT	1992
-			6:00 RussiaAsia	ALM%sT	2005 Mar 15
-			6:00	-	ALMT
-# Qyzylorda (aka Kyzylorda, Kizilorda, Kzyl-Orda, etc.)
+			5:00	-	+05	1930 Jun 21
+			6:00 RussiaAsia +06/+07	1991 Mar 31  2:00s
+			5:00 RussiaAsia	+05/+06	1992 Jan 19  2:00s
+			6:00 RussiaAsia	+06/+07	2004 Oct 31  2:00s
+			6:00	-	+06
+# Qyzylorda (aka Kyzylorda, Kizilorda, Kzyl-Orda, etc.) (KZ-KZY)
 Zone	Asia/Qyzylorda	4:21:52 -	LMT	1924 May  2
-			4:00	-	KIZT	1930 Jun 21 # Kizilorda Time
-			5:00	-	KIZT	1981 Apr  1
-			5:00	1:00	KIZST	1981 Oct  1
-			6:00	-	KIZT	1982 Apr  1
-			5:00 RussiaAsia	KIZ%sT	1991
-			5:00	-	KIZT	1991 Dec 16 # independence
-			5:00	-	QYZT	1992 Jan 19  2:00
-			6:00 RussiaAsia	QYZ%sT	2005 Mar 15
-			6:00	-	QYZT
-# Aqtobe (aka Aktobe, formerly Aktyubinsk)
+			4:00	-	+04	1930 Jun 21
+			5:00	-	+05	1981 Apr  1
+			5:00	1:00	+06	1981 Oct  1
+			6:00	-	+06	1982 Apr  1
+			5:00 RussiaAsia	+05/+06	1991 Mar 31  2:00s
+			4:00 RussiaAsia	+04/+05	1991 Sep 29  2:00s
+			5:00 RussiaAsia	+05/+06	1992 Jan 19  2:00s
+			6:00 RussiaAsia	+06/+07	1992 Mar 29  2:00s
+			5:00 RussiaAsia	+05/+06	2004 Oct 31  2:00s
+			6:00	-	+06
+# Aqtobe (aka Aktobe, formerly Aktyubinsk) (KZ-AKT)
 Zone	Asia/Aqtobe	3:48:40	-	LMT	1924 May  2
-			4:00	-	AKTT	1930 Jun 21 # Aktyubinsk Time
-			5:00	-	AKTT	1981 Apr  1
-			5:00	1:00	AKTST	1981 Oct  1
-			6:00	-	AKTT	1982 Apr  1
-			5:00 RussiaAsia	AKT%sT	1991
-			5:00	-	AKTT	1991 Dec 16 # independence
-			5:00 RussiaAsia	AQT%sT	2005 Mar 15 # Aqtobe Time
-			5:00	-	AQTT
-# Mangghystau
+			4:00	-	+04	1930 Jun 21
+			5:00	-	+05	1981 Apr  1
+			5:00	1:00	+06	1981 Oct  1
+			6:00	-	+06	1982 Apr  1
+			5:00 RussiaAsia	+05/+06	1991 Mar 31  2:00s
+			4:00 RussiaAsia	+04/+05	1992 Jan 19  2:00s
+			5:00 RussiaAsia	+05/+06	2004 Oct 31  2:00s
+			5:00	-	+05
+# Qostanay (KZ-KUS)
+
+# Mangghystau (KZ-MAN)
 # Aqtau was not founded until 1963, but it represents an inhabited region,
 # so include time stamps before 1963.
 Zone	Asia/Aqtau	3:21:04	-	LMT	1924 May  2
-			4:00	-	FORT	1930 Jun 21 # Fort Shevchenko T
-			5:00	-	FORT	1963
-			5:00	-	SHET	1981 Oct  1 # Shevchenko Time
-			6:00	-	SHET	1982 Apr  1
-			5:00 RussiaAsia	SHE%sT	1991
-			5:00	-	SHET	1991 Dec 16 # independence
-			5:00 RussiaAsia	AQT%sT	1995 Mar lastSun  2:00 # Aqtau Time
-			4:00 RussiaAsia	AQT%sT	2005 Mar 15
-			5:00	-	AQTT
-# West Kazakhstan
+			4:00	-	+04	1930 Jun 21
+			5:00	-	+05	1963
+			5:00	-	+05	1981 Oct  1
+			6:00	-	+06	1982 Apr  1
+			5:00 RussiaAsia	+05/+06	1991 Mar 31  2:00s
+			4:00 RussiaAsia	+04/+05	1992 Jan 19  2:00s
+			5:00 RussiaAsia	+05/+06	1994 Sep 25  2:00s
+			4:00 RussiaAsia	+04/+05	2004 Oct 31  2:00s
+			5:00	-	+05
+
+# West Kazakhstan (KZ-ZAP)
+# From Paul Eggert (2016-03-18):
+# The 1989 transition is from USSR act No. 227 (1989-03-14).
 Zone	Asia/Oral	3:25:24	-	LMT	1924 May  2 # or Ural'sk
-			4:00	-	URAT	1930 Jun 21 # Ural'sk time
-			5:00	-	URAT	1981 Apr  1
-			5:00	1:00	URAST	1981 Oct  1
-			6:00	-	URAT	1982 Apr  1
-			5:00 RussiaAsia	URA%sT	1989 Mar 26  2:00
-			4:00 RussiaAsia	URA%sT	1991
-			4:00	-	URAT	1991 Dec 16 # independence
-			4:00 RussiaAsia	ORA%sT	2005 Mar 15 # Oral Time
-			5:00	-	ORAT
+			4:00	-	+04	1930 Jun 21
+			5:00	-	+05	1981 Apr  1
+			5:00	1:00	+06	1981 Oct  1
+			6:00	-	+06	1982 Apr  1
+			5:00 RussiaAsia	+05/+06	1989 Mar 26  2:00s
+			4:00 RussiaAsia	+04/+05	1992 Jan 19  2:00s
+			5:00 RussiaAsia	+05/+06	1992 Mar 29  2:00s
+			4:00 RussiaAsia	+04/+05	2004 Oct 31  2:00s
+			5:00	-	+05
 
 # Kyrgyzstan (Kirgizstan)
 # Transitions through 1991 are from Shanks & Pottenger.
@@ -2419,6 +2578,16 @@
 # http://www.timeanddate.com/time/change/gaza-strip/gaza
 # http://www.timeanddate.com/time/change/west-bank/hebron
 
+# From Hannah Kreitem (2016-03-09):
+# http://www.palestinecabinet.gov.ps/WebSite/ar/ViewDetails?ID=31728
+# [Google translation]: "The Council also decided to start daylight
+# saving in Palestine as of one o'clock on Saturday morning,
+# 2016-03-26, to provide the clock 60 minutes ahead."
+#
+# From Paul Eggert (2016-03-12):
+# Predict spring transitions on March's last Saturday at 01:00 from now on.
+# Leave fall predictions alone for now.
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule EgyptAsia	1957	only	-	May	10	0:00	1:00	S
 Rule EgyptAsia	1957	1958	-	Oct	 1	0:00	0	-
@@ -2447,7 +2616,8 @@
 Rule Palestine	2012	only	-	Sep	21	1:00	0	-
 Rule Palestine	2013	only	-	Sep	Fri>=21	0:00	0	-
 Rule Palestine	2014	max	-	Oct	Fri>=21	0:00	0	-
-Rule Palestine	2015	max	-	Mar	lastFri	24:00	1:00	S
+Rule Palestine	2015	only	-	Mar	lastFri	24:00	1:00	S
+Rule Palestine	2016	max	-	Mar	lastSat	1:00	1:00	S
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Gaza	2:17:52	-	LMT	1900 Oct
diff --git a/jdk/make/data/tzdata/australasia b/jdk/make/data/tzdata/australasia
index 09afef2..929124c 100644
--- a/jdk/make/data/tzdata/australasia
+++ b/jdk/make/data/tzdata/australasia
@@ -83,6 +83,14 @@
 # Hamilton is the largest, but there is also a Hamilton in Victoria,
 # so use Lindeman.
 #
+# From J William Piggott (2016-02-20):
+# There is no location named Holiday Islands in Queensland Australia; holiday
+# islands is a colloquial term used globally.  Hayman and Lindeman are at the
+# north and south extremes of the Whitsunday Islands archipelago, and
+# Hamilton is in between; it is reasonable to believe that this time zone
+# applies to all of the Whitsundays.
+# http://www.australia.gov.au/about-australia/australian-story/austn-islands
+#
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	AQ	1971	only	-	Oct	lastSun	2:00s	1:00	D
 Rule	AQ	1972	only	-	Feb	lastSun	2:00s	0	S
diff --git a/jdk/make/data/tzdata/europe b/jdk/make/data/tzdata/europe
index 2679921..00a9fff 100644
--- a/jdk/make/data/tzdata/europe
+++ b/jdk/make/data/tzdata/europe
@@ -623,16 +623,40 @@
 Rule	Russia	1981	1983	-	Oct	 1	 0:00	0	-
 # Act No. 967 of the Council of Ministers of the USSR (1984-09-13), repeated in
 # Act No. 227 of the Council of Ministers of the USSR (1989-03-14):
-Rule	Russia	1984	1991	-	Sep	lastSun	 2:00s	0	-
-Rule	Russia	1985	1991	-	Mar	lastSun	 2:00s	1:00	S
+Rule	Russia	1984	1995	-	Sep	lastSun	 2:00s	0	-
+Rule	Russia	1985	2010	-	Mar	lastSun	 2:00s	1:00	S
 #
-Rule	Russia	1992	only	-	Mar	lastSat	 23:00	1:00	S
-Rule	Russia	1992	only	-	Sep	lastSat	 23:00	0	-
-Rule	Russia	1993	2010	-	Mar	lastSun	 2:00s	1:00	S
-Rule	Russia	1993	1995	-	Sep	lastSun	 2:00s	0	-
 Rule	Russia	1996	2010	-	Oct	lastSun	 2:00s	0	-
 # As described below, Russia's 2014 change affects Zone data, not Rule data.
 
+# From Stepan Golosunov (2016-03-07):
+# Wikipedia and other sources refer to the Act of the Council of
+# Ministers of the USSR from 1988-01-04 No. 5 and the Act of the
+# Council of Ministers of the USSR from 1989-03-14 No. 227.
+#
+# I did not find full texts of these acts.  For the 1989 one we have
+# title at http://base.garant.ru/70754136/ :
+# "About change in calculation of time on the territories of
+# Lithuanian SSR, Latvian SSR and Estonian SSR, Astrakhan,
+# Kaliningrad, Kirov, Kuybyshev, Ulyanovsk and Uralsk oblasts".
+# And http://astrozet.net/files/Zones/DOC/RU/1980-925.txt appears to
+# contain quotes from both acts: Since last Sunday of March 1988 rules
+# of the second time belt are installed in Volgograd and Saratov
+# oblasts.  Since last Sunday of March 1989:
+# a) Lithuanian SSR, Latvian SSR, Estonian SSR, Kaliningrad oblast:
+# second time belt rules without extra hour (Moscow-1);
+# b) Astrakhan, Kirov, Kuybyshev, Ulyanovsk oblasts: second time belt
+# rules (Moscow time)
+# c) Uralsk oblast: third time belt rules (Moscow+1).
+
+# From Stepan Golosunov (2016-03-27):
+# Unamended version of the act of the
+# Government of the Russian Federation No. 23 from 08.01.1992
+# http://pravo.gov.ru/proxy/ips/?docbody=&nd=102014034&rdk=0
+# says that every year clocks were to be moved forward on last Sunday
+# of March at 2 hours and moved backwards on last Sunday of September
+# at 3 hours.  It was amended in 1996 to replace September with October.
+
 # From Alexander Krivenyshev (2011-06-14):
 # According to Kremlin press service, Russian President Dmitry Medvedev
 # signed a federal law "On calculation of time" on June 9, 2011.
@@ -1028,6 +1052,12 @@
 # startkart.no says Thule does not observe DST, but this is clearly an error,
 # so go with Shanks & Pottenger for Thule transitions until this year.
 # For 2007 on assume Thule will stay in sync with US DST rules.
+
+# From J William Piggott (2016-02-20):
+# "Greenland north of the community of Scoresbysund" is officially named
+# "National Park" by Executive Order:
+# http://naalakkersuisut.gl/~/media/Nanoq/Files/Attached%20Files/Engelske-tekster/Legislation/Executive%20Order%20National%20Park.rtf
+# It is their only National Park.
 #
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Thule	1991	1992	-	Mar	lastSun	2:00	1:00	D
@@ -1053,6 +1083,10 @@
 			-4:00	Thule	A%sT
 
 # Estonia
+#
+# From Paul Eggert (2016-03-18):
+# The 1989 transition is from USSR act No. 227 (1989-03-14).
+#
 # From Peter Ilieve (1994-10-15):
 # A relative in Tallinn confirms the accuracy of the data for 1989 onwards
 # [through 1994] and gives the legal authority for it,
@@ -1646,6 +1680,9 @@
 
 # Lithuania
 
+# From Paul Eggert (2016-03-18):
+# The 1989 transition is from USSR act No. 227 (1989-03-14).
+
 # From Paul Eggert (1996-11-22):
 # IATA SSIM (1992/1996) says Lithuania uses W-Eur rules, but since it is
 # known to be wrong about Estonia and Latvia, assume it's wrong here too.
@@ -1685,8 +1722,8 @@
 			1:00	-	CET	1940 Aug  3
 			3:00	-	MSK	1941 Jun 24
 			1:00	C-Eur	CE%sT	1944 Aug
-			3:00	Russia	MSK/MSD	1991 Mar 31  2:00s
-			2:00	1:00	EEST	1991 Sep 29  2:00s
+			3:00	Russia	MSK/MSD	1989 Mar 26  2:00s
+			2:00	Russia	EE%sT	1991 Sep 29  2:00s
 			2:00	C-Eur	EE%sT	1998
 			2:00	-	EET	1998 Mar 29  1:00u
 			1:00	EU	CE%sT	1999 Oct 31  1:00u
@@ -1751,6 +1788,16 @@
 
 # Moldova
 
+# From Stepan Golosunov (2016-03-07):
+# the act of the government of the Republic of Moldova Nr. 132 from 1990-05-04
+# http://lex.justice.md/viewdoc.php?action=view&view=doc&id=298782&lang=2
+# ... says that since 1990-05-06 on the territory of the Moldavian SSR
+# time would be calculated as the standard time of the second time belt
+# plus one hour of the "summer" time. To implement that clocks would be
+# adjusted one hour backwards at 1990-05-06 2:00. After that "summer"
+# time would be cancelled last Sunday of September at 3:00 and
+# reintroduced last Sunday of March at 2:00.
+
 # From Paul Eggert (2006-03-22):
 # A previous version of this database followed Shanks & Pottenger, who write
 # that Tiraspol switched to Moscow time on 1992-01-19 at 02:00.
@@ -1809,9 +1856,7 @@
 			2:00	Romania	EE%sT	1940 Aug 15
 			2:00	1:00	EEST	1941 Jul 17
 			1:00	C-Eur	CE%sT	1944 Aug 24
-			3:00	Russia	MSK/MSD	1990
-			3:00	-	MSK	1990 May 6
-			2:00	-	EET	1991
+			3:00	Russia	MSK/MSD	1990 May  6  2:00
 			2:00	Russia	EE%sT	1992
 			2:00	E-Eur	EE%sT	1997
 # See Romania commentary for the guessed 1997 transition to EU rules.
@@ -2289,16 +2334,32 @@
 # Europe/Kaliningrad covers...
 # 39	RU-KGD	Kaliningrad Oblast
 
+# From Paul Eggert (2016-03-18):
+# The 1989 transition is from USSR act No. 227 (1989-03-14).
+
+# From Stepan Golosunov (2016-03-07):
+# http://www.rgo.ru/ru/kaliningradskoe-oblastnoe-otdelenie/ob-otdelenii/publikacii/kak-nam-zhilos-bez-letnego-vremeni
+# confirms that the 1989 change to Moscow-1 was implemented.
+# (The article, though, is misattributed to 1990 while saying that
+# summer->winter transition would be done on the 24 of September. But
+# 1990-09-24 was Monday, while 1989-09-24 was Sunday as expected.)
+# ...
+# http://www.kaliningradka.ru/site_pc/cherez/index.php?ELEMENT_ID=40091
+# says that Kaliningrad switched to Moscow-1 on 1989-03-26, avoided
+# at the last moment switch to Moscow-1 on 1991-03-31, switched to
+# Moscow on 1991-11-03, switched to Moscow-1 on 1992-01-19.
+
 Zone Europe/Kaliningrad	 1:22:00 -	LMT	1893 Apr
 			 1:00	C-Eur	CE%sT	1945
 			 2:00	Poland	CE%sT	1946
-			 3:00	Russia	MSK/MSD	1991 Mar 31  2:00s
+			 3:00	Russia	MSK/MSD	1989 Mar 26  2:00s
 			 2:00	Russia	EE%sT	2011 Mar 27  2:00s
 			 3:00	-	FET	2014 Oct 26  2:00s
 			 2:00	-	EET
 
 
-# From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2001-08-25):
+# From Paul Eggert (2016-02-21), per Tim Parenti (2014-07-03) and
+# Oscar van Vlijmen (2001-08-25):
 # Europe/Moscow covers...
 # 01	RU-AD	Adygea, Republic of
 # 05	RU-DA	Dagestan, Republic of
@@ -2341,12 +2402,92 @@
 # 68	RU-TAM	Tambov Oblast
 # 69	RU-TVE	Tver Oblast
 # 71	RU-TUL	Tula Oblast
-# 73	RU-ULY	Ulyanovsk Oblast
 # 76	RU-YAR	Yaroslavl Oblast
 # 77	RU-MOW	Moscow
 # 78	RU-SPE	Saint Petersburg
 # 83	RU-NEN	Nenets Autonomous Okrug
 
+# From Stepan Golosunov (2016-03-07):
+# 11. Regions-violators, 1981-1982.
+# Wikipedia refers to
+# http://maps.monetonos.ru/maps/raznoe/Old_Maps/Old_Maps/Articles/022/3_1981.html
+# http://besp.narod.ru/nauka_1981_3.htm
+#
+# The second link provides two articles scanned from the Nauka i Zhizn
+# magazine No. 3, 1981 and a scan of the short article attributed to
+# the Trud newspaper from February 1982.  The first link provides the
+# same Nauka i Zhizn articles converted to the text form (but misses
+# time belt changes map).
+#
+# The second Nauka i Zhizn article says that in addition to
+# introduction of summer time on 1981-04-01 there are some time belt
+# border changes on 1981-10-01, mostly affecting Nenets Autonomous
+# Okrug, Krasnoyarsk Krai, Yakutia, Magadan Oblast and Chukotka
+# according to the provided map (colored one).  In addition to that
+# "time violators" (regions which were not using rules of the time
+# belts in which they were located) would not be moving off the DST on
+# 1981-10-01 to restore the decree time usage.  (Komi ASSR was
+# supposed to repeat that move in October 1982 to account for the 2
+# hour difference.)  Map depicting "time violators" before 1981-10-01
+# is also provided.
+#
+# The article from Trud says that 1981-10-01 changes caused problems
+# and some territories would be moved to pre-1981-10-01 time by not
+# moving to summer time on 1982-04-01.  Namely: Dagestan,
+# Kabardino-Balkar, Kalmyk, Komi, Mari, Mordovian, North Ossetian,
+# Tatar, Chechen-Ingush and Chuvash ASSR, Krasnodar and Stavropol
+# krais, Arkhangelsk, Vladimir, Vologda, Voronezh, Gorky, Ivanovo,
+# Kostroma, Lipetsk, Penza, Rostov, Ryazan, Tambov, Tyumen and
+# Yaroslavl oblasts, Nenets and Evenk autonomous okrugs, Khatangsky
+# district of Taymyr Autonomous Okrug.  As a result Evenk Autonomous
+# Okrug and Khatangsky district of Taymyr Autonomous Okrug would end
+# up on Moscow+4, Tyumen Oblast on Moscow+2 and the rest on Moscow
+# time.
+#
+# http://astrozet.net/files/Zones/DOC/RU/1980-925.txt
+# attributes the 1982 changes to the Act of the Council of Ministers
+# of the USSR No. 126 from 18.02.1982.  1980-925.txt also adds
+# Udmurtia to the list of affected territories and lists Khatangsky
+# district separately from Taymyr Autonomous Okurg.  Probably erroneously.
+#
+# The affected territories are currently listed under Europe/Moscow,
+# Asia/Yekaterinburg and Asia/Krasnoyarsk.
+#
+# 12. Udmurtia
+# The fact that Udmurtia is depicted as a violator in the Nauka i
+# Zhizn article hints at Izhevsk being on different time from
+# Kuybyshev before 1981-10-01. Udmurtia is not mentioned in the 1989 act.
+# http://astrozet.net/files/Zones/DOC/RU/1980-925.txt
+# implies Udmurtia was on Moscow time after 1982-04-01.
+# Wikipedia implies Udmurtia being on Moscow+1 until 1991.
+#
+# ...
+#
+# All Russian zones are supposed to have by default a -1 change at
+# 1991-03-31 2:00 (cancellation of the decree time in the USSR) and a +1
+# change at 1992-01-19 2:00 (restoration of the decree time in Russia).
+#
+# There were some exceptions, though.
+# Wikipedia says newspapers listed Astrakhan, Saratov, Kirov, Volgograd,
+# Izhevsk, Grozny, Kazan and Samara as such exceptions for the 1992
+# change. (Different newspapers providing different lists. And some
+# lists found in the internet are quite wild.)
+#
+# And apparently some exceptions were reverted in the last moment.
+# http://www.kaliningradka.ru/site_pc/cherez/index.php?ELEMENT_ID=40091
+# says that Kaliningrad decided not to be an exception 2 days before the
+# 1991-03-31 switch and one person at
+# http://izhevsk.ru/forum_light_message/50/682597-m8369040.html
+# says he remembers that Samara opted out of the 1992-01-19 exception
+# 2 days before the switch.
+#
+#
+# From Paul Eggert (2016-03-18):
+# Given the above, we appear to be missing some Zone entries for the
+# chaotic early 1980s in Russia.  It's not clear what these entries
+# should be.  For now, sweep this under the rug and just document the
+# time in Moscow.
+
 # From Vladimir Karpinsky (2014-07-08):
 # LMT in Moscow (before Jul 3, 1916) is 2:30:17, that was defined by Moscow
 # Observatory (coordinates: 55 deg. 45'29.70", 37 deg. 34'05.30")....
@@ -2420,47 +2561,102 @@
 			 3:00	-	MSK
 
 
-# From Tim Parenti (2014-07-03):
-# Europe/Volgograd covers...
+# From Paul Eggert (2016-03-18):
+# Europe/Astrakhan covers:
 # 30	RU-AST	Astrakhan Oblast
-# 34	RU-VGG	Volgograd Oblast
-# 43	RU-KIR	Kirov Oblast
-# 64	RU-SAR	Saratov Oblast
+#
+# The 1989 transition is from USSR act No. 227 (1989-03-14).
 
-# From Paul Eggert (2006-05-09):
-# Shanks & Pottenger say Kirov is still at +0400 but Wikipedia says +0300.
-# Perhaps it switched after the others?  But we have no data.
+# From Alexander Krivenyshev (2016-01-12):
+# On February 10, 2016 Astrakhan Oblast got approval by the Federation
+# Council to change its time zone to UTC+4 (from current UTC+3 Moscow time)....
+# This Federal Law shall enter into force on 27 March 2016 at 02:00.
+# From Matt Johnson (2016-03-09):
+# http://publication.pravo.gov.ru/Document/View/0001201602150056
+
+Zone Europe/Astrakhan	 3:12:12 -	LMT	1924 May
+			 3:00	-	+03	1930 Jun 21
+			 4:00	Russia	+04/+05	1989 Mar 26  2:00s
+			 3:00	Russia	+03/+04	1991 Mar 31  2:00s
+			 4:00	-	+04	1992 Mar 29  2:00s
+			 3:00	Russia	+03/+04	2011 Mar 27  2:00s
+			 4:00	-	+04	2014 Oct 26  2:00s
+			 3:00	-	+03	2016 Mar 27  2:00s
+			 4:00	-	+04
+
+# From Paul Eggert (2016-03-18):
+# Europe/Volgograd covers:
+# 34	RU-VGG	Volgograd Oblast
+# 64	RU-SAR	Saratov Oblast
+# The 1988 transition is from USSR act No. 5 (1988-01-04).
 
 Zone Europe/Volgograd	 2:57:40 -	LMT	1920 Jan  3
 			 3:00	-	TSAT	1925 Apr  6 # Tsaritsyn Time
 			 3:00	-	STAT	1930 Jun 21 # Stalingrad Time
 			 4:00	-	STAT	1961 Nov 11
-			 4:00	Russia	VOL%sT	1989 Mar 26  2:00s # Volgograd T
+			 4:00	Russia	VOL%sT	1988 Mar 27  2:00s # Volgograd T
 			 3:00	Russia	VOL%sT	1991 Mar 31  2:00s
 			 4:00	-	VOLT	1992 Mar 29  2:00s
 			 3:00	Russia	MSK/MSD	2011 Mar 27  2:00s
 			 4:00	-	MSK	2014 Oct 26  2:00s
 			 3:00	-	MSK
 
+# From Paul Eggert (2016-03-18):
+# Europe/Kirov covers:
+# 43	RU-KIR	Kirov Oblast
+# The 1989 transition is from USSR act No. 227 (1989-03-14).
+#
+Zone Europe/Kirov	 3:18:48 -	LMT	1919 Jul  1  2:00
+			 3:00	-	+03	1930 Jun 21
+			 4:00	Russia	+04/+05	1989 Mar 26  2:00s
+			 3:00	Russia	+03/+04	1991 Mar 31  2:00s
+			 4:00	-	+04	1992 Mar 29  2:00s
+			 3:00	Russia	+03/+04	2011 Mar 27  2:00s
+			 4:00	-	+04	2014 Oct 26  2:00s
+			 3:00	-	+03
 
 # From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2001-08-25):
 # Europe/Samara covers...
 # 18	RU-UD	Udmurt Republic
 # 63	RU-SAM	Samara Oblast
 
+# From Paul Eggert (2016-03-18):
 # Byalokoz 1919 says Samara was 3:20:20.
+# The 1989 transition is from USSR act No. 227 (1989-03-14).
 
 Zone Europe/Samara	 3:20:20 -	LMT	1919 Jul  1  2:00
-			 3:00	-	SAMT	1930 Jun 21
+			 3:00	-	SAMT	1930 Jun 21 # Samara Time
 			 4:00	-	SAMT	1935 Jan 27
 			 4:00	Russia	KUY%sT	1989 Mar 26  2:00s # Kuybyshev
 			 3:00	Russia	MSK/MSD	1991 Mar 31  2:00s
 			 2:00	Russia	EE%sT	1991 Sep 29  2:00s
-			 3:00	-	KUYT	1991 Oct 20  3:00
-			 4:00	Russia	SAM%sT	2010 Mar 28  2:00s # Samara Time
+			 3:00	-	SAMT	1991 Oct 20  3:00
+			 4:00	Russia	SAM%sT	2010 Mar 28  2:00s
 			 3:00	Russia	SAM%sT	2011 Mar 27  2:00s
 			 4:00	-	SAMT
 
+# From Paul Eggert (2016-03-18):
+# Europe/Ulyanovsk covers:
+# 73	RU-ULY	Ulyanovsk Oblast
+
+# The 1989 transition is from USSR act No. 227 (1989-03-14).
+
+# From Alexander Krivenyshev (2016-02-17):
+# Ulyanovsk ... on their way to change time zones by March 27, 2016 at 2am.
+# Ulyanovsk Oblast ... from MSK to MSK+1 (UTC+3 to UTC+4) ...
+# 920582-6 ... 02/17/2016 The State Duma passed the bill in the first reading.
+# From Matt Johnson (2016-03-09):
+# http://publication.pravo.gov.ru/Document/View/0001201603090051
+
+Zone Europe/Ulyanovsk	 3:13:36 -	LMT	1919 Jul  1  2:00
+			 3:00	-	+03	1930 Jun 21
+			 4:00	Russia	+04/+05	1989 Mar 26  2:00s
+			 3:00	Russia	+03/+04	1991 Mar 31  2:00s
+			 2:00	Russia	+02/+03	1992 Jan 19  2:00s
+			 3:00	Russia	+03/+04	2011 Mar 27  2:00s
+			 4:00	-	+04	2014 Oct 26  2:00s
+			 3:00	-	+03	2016 Mar 27  2:00s
+			 4:00	-	+04
 
 # From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2001-08-25):
 # Asia/Yekaterinburg covers...
@@ -2494,8 +2690,6 @@
 
 # From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2001-08-25):
 # Asia/Omsk covers...
-# 04	RU-AL	Altai Republic
-# 22	RU-ALT	Altai Krai
 # 55	RU-OMS	Omsk Oblast
 
 # Byalokoz 1919 says Omsk was 4:53:30.
@@ -2508,14 +2702,49 @@
 			 7:00	-	OMST	2014 Oct 26  2:00s
 			 6:00	-	OMST
 
+# From Paul Eggert (2016-02-22):
+# Asia/Barnaul covers:
+# 04	RU-AL	Altai Republic
+# 22	RU-ALT	Altai Krai
 
-# From Tim Parenti (2014-07-03):
-# Asia/Novosibirsk covers...
+# Data before 1991 are from Shanks & Pottenger.
+
+# From Stepan Golosunov (2016-03-07):
+# Letter of Bank of Russia from 1995-05-25
+# http://www.bestpravo.ru/rossijskoje/lj-akty/y3a.htm
+# suggests that Altai Republic transitioned to Moscow+3 on
+# 1995-05-28.
+#
+# http://regnum.ru/news/society/1957270.html
+# has some historical data for Altai Krai:
+# before 1957: west part on UTC+6, east on UTC+7
+# after 1957: UTC+7
+# since 1995: UTC+6
+# http://barnaul.rusplt.ru/index/pochemu_altajskij_kraj_okazalsja_v_neprivychnom_chasovom_pojase-17648.html
+# confirms that and provides more details including 1995-05-28 transition date.
+
+# From Alexander Krivenyshev (2016-02-17):
+# Altai Krai and Altai Republic on their way to change time zones
+# by March 27, 2016 at 2am....
+# Altai Republic / Gorno-Altaysk MSK+3 to MSK+4 (UTC+6 to UTC+7) ...
+# Altai Krai / Barnaul MSK+3 to MSK+4 (UTC+6 to UTC+7)
+# From Matt Johnson (2016-03-09):
+# http://publication.pravo.gov.ru/Document/View/0001201603090043
+# http://publication.pravo.gov.ru/Document/View/0001201603090038
+
+Zone Asia/Barnaul	 5:35:00 -	LMT	1919 Dec 10
+			 6:00	-	+06	1930 Jun 21
+			 7:00	Russia	+07/+08	1991 Mar 31  2:00s
+			 6:00	Russia	+06/+07	1992 Jan 19  2:00s
+			 7:00	Russia	+07/+08	1995 May 28
+			 6:00	Russia	+06/+07	2011 Mar 27  2:00s
+			 7:00	-	+07	2014 Oct 26  2:00s
+			 6:00	-	+06	2016 Mar 27  2:00s
+			 7:00	-	+07
+
+# From Paul Eggert (2016-03-18):
+# Asia/Novosibirsk covers:
 # 54	RU-NVS	Novosibirsk Oblast
-# 70	RU-TOM	Tomsk Oblast
-
-# From Paul Eggert (2006-08-19): I'm guessing about Tomsk here; it's
-# not clear when it switched from +7 to +6.
 
 Zone Asia/Novosibirsk	 5:31:40 -	LMT	1919 Dec 14  6:00
 			 6:00	-	NOVT	1930 Jun 21 # Novosibirsk Time
@@ -2526,6 +2755,55 @@
 			 7:00	-	NOVT	2014 Oct 26  2:00s
 			 6:00	-	NOVT
 
+# From Paul Eggert (2016-03-18):
+# Asia/Tomsk covers:
+# 70	RU-TOM	Tomsk Oblast
+
+# From Stepan Golosunov (2016-03-24):
+# Byalokoz listed Tomsk at 5:39:51.
+
+# From Stanislaw A. Kuzikowski (1994-06-29):
+# Tomsk is still 4 hours ahead of Moscow.
+
+# From Stepan Golosunov (2016-03-19):
+# http://pravo.gov.ru/proxy/ips/?docbody=&nd=102075743
+# (fifth time belt being UTC+5+1(decree time)
+# / UTC+5+1(decree time)+1(summer time)) ...
+# Note that time belts (numbered from 2 (Moscow) to 12 according to their
+# GMT/UTC offset and having too many exceptions like regions formally
+# belonging to one belt but using time from another) were replaced
+# with time zones in 2011 with different numberings (there was a
+# 2-hour gap between second and third zones in 2011-2014).
+
+# From Stepan Golosunov (2016-04-12):
+# http://asozd2.duma.gov.ru/main.nsf/(SpravkaNew)?OpenAgent&RN=1006865-6
+# This bill was approved in the first reading today.  It moves Tomsk oblast
+# from UTC+6 to UTC+7 and is supposed to come into effect on 2016-05-29 at
+# 2:00.  The bill needs to be approved in the second and the third readings by
+# the State Duma, approved by the Federation Council, signed by the President
+# and published to become a law.  Minor changes in the text are to be expected
+# before the second reading (references need to be updated to account for the
+# recent changes).
+#
+# Judging by the ultra-short one-day amendments period, recent similar laws,
+# the State Duma schedule and the Federation Council schedule
+# http://www.duma.gov.ru/legislative/planning/day-shedule/por_vesna_2016/
+# http://council.gov.ru/activity/meetings/schedule/63303
+# I speculate that the final text of the bill will be proposed tomorrow, the
+# bill will be approved in the second and the third readings on Friday,
+# approved by the Federation Council on 2016-04-20, signed by the President and
+# published as a law around 2016-04-26.
+
+Zone	Asia/Tomsk	 5:39:51 -	LMT	1919 Dec 22
+			 6:00	-	+06	1930 Jun 21
+			 7:00	Russia	+07/+08	1991 Mar 31  2:00s
+			 6:00	Russia	+06/+07	1992 Jan 19  2:00s
+			 7:00	Russia	+07/+08	2002 May  1  3:00
+			 6:00	Russia	+06/+07	2011 Mar 27  2:00s
+			 7:00	-	+07	2014 Oct 26  2:00s
+			 6:00	-	+06	2016 May 29  2:00s
+			 7:00	-	+07
+
 
 # From Tim Parenti (2014-07-03):
 # Asia/Novokuznetsk covers...
@@ -2549,9 +2827,6 @@
 #
 # Thus, when Russia will switch to DST on the night of March 28, 2010
 # Kemerovo region (Kemerovo oblast') will not change the clock.
-#
-# As a result, Kemerovo oblast' will be in the same time zone as
-# Novosibirsk, Omsk, Tomsk, Barnaul and Altai Republic.
 
 # From Tim Parenti (2014-07-02), per Alexander Krivenyshev (2014-07-02):
 # The Kemerovo region will remain at UTC+7 through the 2014-10-26 change, thus
@@ -2620,7 +2895,7 @@
 # [The] time zone in the Trans-Baikal Territory (Zabaykalsky Krai) -
 # Asia/Chita [is changing] from UTC+8 to UTC+9.  Effective date will
 # be March 27, 2016 at 2:00am....
-# http://publication.pravo.gov.ru/Document/View/000120151230010
+# http://publication.pravo.gov.ru/Document/View/0001201512300107
 
 Zone Asia/Chita	 7:33:52 -	LMT	1919 Dec 15
 			 8:00	-	YAKT	1930 Jun 21 # Yakutsk Time
@@ -2731,6 +3006,11 @@
 # ...with the exception of:
 # 65-11	****	Severo-Kurilsky District (North Kuril Islands)
 
+# From Matt Johnson (2016-02-22):
+# Asia/Sakhalin is moving (in entirety) from UTC+10 to UTC+11 ...
+# (2016-03-09):
+# http://publication.pravo.gov.ru/Document/View/0001201603090044
+
 # The Zone name should be Asia/Yuzhno-Sakhalinsk, but that's too long.
 Zone Asia/Sakhalin	 9:30:48 -	LMT	1905 Aug 23
 			 9:00	-	JCST	1937 Oct  1
@@ -2740,7 +3020,8 @@
 			11:00	Russia	SAK%sT	1997 Mar lastSun  2:00s
 			10:00	Russia	SAK%sT	2011 Mar 27  2:00s
 			11:00	-	SAKT	2014 Oct 26  2:00s
-			10:00	-	SAKT
+			10:00	-	SAKT	2016 Mar 27  2:00s
+			11:00	-	SAKT
 
 
 # From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2009-11-29):
@@ -2754,13 +3035,22 @@
 # until now by Asia/Magadan, will instead move to UTC+11.  These regions will
 # need their own zone.
 
+# From Alexander Krivenyshev (2016-03-27):
+# ... draft bill 948300-6 to change its time zone from UTC+10 to UTC+11 ...
+# will take ... effect ... on April 24, 2016 at 2 o'clock
+#
+# From Matt Johnson (2016-04-05):
+# ... signed by the President today ...
+# http://publication.pravo.gov.ru/Document/View/0001201604050038
+
 Zone Asia/Magadan	10:03:12 -	LMT	1924 May  2
 			10:00	-	MAGT	1930 Jun 21 # Magadan Time
 			11:00	Russia	MAG%sT	1991 Mar 31  2:00s
 			10:00	Russia	MAG%sT	1992 Jan 19  2:00s
 			11:00	Russia	MAG%sT	2011 Mar 27  2:00s
 			12:00	-	MAGT	2014 Oct 26  2:00s
-			10:00	-	MAGT
+			10:00	-	MAGT	2016 Apr 24  2:00s
+			11:00	-	MAGT
 
 
 # From Tim Parenti (2014-07-06):
diff --git a/jdk/make/data/tzdata/iso3166.tab b/jdk/make/data/tzdata/iso3166.tab
index 7fb3073..e47eefe 100644
--- a/jdk/make/data/tzdata/iso3166.tab
+++ b/jdk/make/data/tzdata/iso3166.tab
@@ -75,7 +75,7 @@
 BM	Bermuda
 BN	Brunei
 BO	Bolivia
-BQ	Caribbean Netherlands
+BQ	Caribbean NL
 BR	Brazil
 BS	Bahamas
 BT	Bhutan
@@ -186,7 +186,7 @@
 MC	Monaco
 MD	Moldova
 ME	Montenegro
-MF	St Martin (French part)
+MF	St Martin (French)
 MG	Madagascar
 MH	Marshall Islands
 MK	Macedonia
@@ -256,7 +256,7 @@
 SS	South Sudan
 ST	Sao Tome & Principe
 SV	El Salvador
-SX	St Maarten (Dutch part)
+SX	St Maarten (Dutch)
 SY	Syria
 SZ	Swaziland
 TC	Turks & Caicos Is
diff --git a/jdk/make/data/tzdata/leapseconds b/jdk/make/data/tzdata/leapseconds
index de698ea..a08fbc7 100644
--- a/jdk/make/data/tzdata/leapseconds
+++ b/jdk/make/data/tzdata/leapseconds
@@ -29,6 +29,7 @@
 # leap-seconds.list file available from most NIST time servers.
 # If the URL <ftp://time.nist.gov/pub/leap-seconds.list> does not work,
 # you should be able to pick up leap-seconds.list from a secondary NIST server.
+# See <http://tf.nist.gov/tf-cgi/servers.cgi> for a list of secondary servers.
 # For more about leap-seconds.list, please see
 # The NTP Timescale and Leap Seconds
 # http://www.eecis.udel.edu/~mills/leap.html
@@ -79,5 +80,5 @@
 Leap	2012	Jun	30	23:59:60	+	S
 Leap	2015	Jun	30	23:59:60	+	S
 
-#	Updated through IERS Bulletin C50
-#	File expires on:  28 June 2016
+#	Updated through IERS Bulletin C51
+#	File expires on:  28 December 2016
diff --git a/jdk/make/data/tzdata/northamerica b/jdk/make/data/tzdata/northamerica
index e56fd89..2124401 100644
--- a/jdk/make/data/tzdata/northamerica
+++ b/jdk/make/data/tzdata/northamerica
@@ -2498,13 +2498,22 @@
 			-6:00	-	CST	1981 Dec 23
 			-5:00	-	EST	1982 Dec  2
 			-6:00	Mexico	C%sT
-# Coahuila, Durango, Nuevo León, Tamaulipas (near US border)
+# Coahuila, Nuevo León, Tamaulipas (near US border)
+# This includes the following municipalities:
+#   in Coahuila: Ocampo, Acuña, Zaragoza, Jiménez, Piedras Negras, Nava,
+#     Guerrero, Hidalgo.
+#   in Nuevo León: Anáhuac, Los Aldama.
+#   in Tamaulipas: Nuevo Laredo, Guerrero, Mier, Miguel Alemán, Camargo,
+#     Gustavo Díaz Ordaz, Reynosa, Río Bravo, Valle Hermoso, Matamoros.
+# See: Inicia mañana Horario de Verano en zona fronteriza, El Universal,
+# 2016-03-12
+# http://www.eluniversal.com.mx/articulo/estados/2016/03/12/inicia-manana-horario-de-verano-en-zona-fronteriza
 Zone America/Matamoros	-6:40:00 -	LMT	1921 Dec 31 23:20:00
 			-6:00	-	CST	1988
 			-6:00	US	C%sT	1989
 			-6:00	Mexico	C%sT	2010
 			-6:00	US	C%sT
-# Coahuila, Durango, Nuevo León, Tamaulipas (away from US border)
+# Durango; Coahuila, Nuevo León, Tamaulipas (away from US border)
 Zone America/Monterrey	-6:41:16 -	LMT	1921 Dec 31 23:18:44
 			-6:00	-	CST	1988
 			-6:00	US	C%sT	1989
@@ -2520,6 +2529,9 @@
 			-6:00	-	CST	2002 Feb 20
 			-6:00	Mexico	C%sT
 # Chihuahua (near US border)
+# This includes the municipalities of Janos, Ascensión, Juárez, Guadalupe,
+# Práxedis G Guerrero, Coyame del Sotol, Ojinaga, and Manuel Benavides.
+# (See the 2016-03-12 El Universal source mentioned above.)
 Zone America/Ojinaga	-6:57:40 -	LMT	1922 Jan  1  0:02:20
 			-7:00	-	MST	1927 Jun 10 23:00
 			-6:00	-	CST	1930 Nov 15
@@ -2607,7 +2619,7 @@
 			-7:00	Mexico	M%sT	2010 Apr  4  2:00
 			-6:00	Mexico	C%sT
 
-# Baja California (near US border)
+# Baja California
 Zone America/Tijuana	-7:48:04 -	LMT	1922 Jan  1  0:11:56
 			-7:00	-	MST	1924
 			-8:00	-	PST	1927 Jun 10 23:00
@@ -3083,6 +3095,13 @@
 # http://radiovision2000haiti.net/public/haiti-avis-changement-dheure-dimanche/
 # http://www.canalplushaiti.net/?p=6714
 
+# From Steffen Thorsen (2016-03-12):
+# Jean Antoine, editor of www.haiti-reference.com informed us that Haiti
+# are not going on DST this year.  Several other resources confirm this: ...
+# http://www.radiotelevisioncaraibes.com/presse/heure_d_t_pas_de_changement_d_heure_pr_vu_pour_cet_ann_e.html
+# http://www.vantbefinfo.com/changement-dheure-pas-pour-haiti/
+# http://news.anmwe.com/haiti-lheure-nationale-ne-sera-ni-avancee-ni-reculee-cette-annee/
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Haiti	1983	only	-	May	8	0:00	1:00	D
 Rule	Haiti	1984	1987	-	Apr	lastSun	0:00	1:00	D
@@ -3093,8 +3112,8 @@
 Rule	Haiti	1988	1997	-	Oct	lastSun	1:00s	0	S
 Rule	Haiti	2005	2006	-	Apr	Sun>=1	0:00	1:00	D
 Rule	Haiti	2005	2006	-	Oct	lastSun	0:00	0	S
-Rule	Haiti	2012	max	-	Mar	Sun>=8	2:00	1:00	D
-Rule	Haiti	2012	max	-	Nov	Sun>=1	2:00	0	S
+Rule	Haiti	2012	2015	-	Mar	Sun>=8	2:00	1:00	D
+Rule	Haiti	2012	2015	-	Nov	Sun>=1	2:00	0	S
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone America/Port-au-Prince -4:49:20 -	LMT	1890
 			-4:49	-	PPMT	1917 Jan 24 12:00 # P-a-P MT
diff --git a/jdk/make/data/tzdata/southamerica b/jdk/make/data/tzdata/southamerica
index 0820186..b909089 100644
--- a/jdk/make/data/tzdata/southamerica
+++ b/jdk/make/data/tzdata/southamerica
@@ -1244,6 +1244,20 @@
 # From Paul Eggert (2015-03-03):
 # For now, assume that the extension will persist indefinitely.
 
+# From Juan Correa (2016-03-18):
+# The decree regarding DST has been published in today's Official Gazette:
+# http://www.diariooficial.interior.gob.cl/versiones-anteriores/do/20160318/
+# http://www.leychile.cl/Navegar?idNorma=1088502
+# It does consider the second Saturday of May and August as the dates
+# for the transition; and it lists DST dates until 2019, but I think
+# this scheme will stick.
+#
+# From Paul Eggert (2016-03-18):
+# For now, assume the pattern holds for the indefinite future.
+# The decree says transitions occur at 24:00; in practice this appears
+# to mean 24:00 mainland time, not 24:00 local time, so that Easter
+# Island is always two hours behind the mainland.
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Chile	1927	1931	-	Sep	 1	0:00	1:00	S
 Rule	Chile	1928	1932	-	Apr	 1	0:00	0	-
@@ -1275,8 +1289,10 @@
 Rule	Chile	2010	only	-	Apr	Sun>=1	3:00u	0	-
 Rule	Chile	2011	only	-	May	Sun>=2	3:00u	0	-
 Rule	Chile	2011	only	-	Aug	Sun>=16	4:00u	1:00	S
-Rule	Chile	2012	2015	-	Apr	Sun>=23	3:00u	0	-
+Rule	Chile	2012	2014	-	Apr	Sun>=23	3:00u	0	-
 Rule	Chile	2012	2014	-	Sep	Sun>=2	4:00u	1:00	S
+Rule	Chile	2016	max	-	May	Sun>=9	3:00u	0	-
+Rule	Chile	2016	max	-	Aug	Sun>=9	4:00u	1:00	S
 # IATA SSIM anomalies: (1992-02) says 1992-03-14;
 # (1996-09) says 1998-03-08.  Ignore these.
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
@@ -1293,13 +1309,11 @@
 			-4:00	1:00	CLST	1946 Sep  1 # central Chile
 			-4:00	-	CLT	1947 Apr  1
 			-5:00	-	CLT	1947 May 21 23:00
-			-4:00	Chile	CL%sT	2015 Apr 26  3:00u
-			-3:00	-	CLT
+			-4:00	Chile	CL%sT
 Zone Pacific/Easter	-7:17:28 -	LMT	1890
 			-7:17:28 -	EMT	1932 Sep    # Easter Mean Time
 			-7:00	Chile	EAS%sT	1982 Mar 14 3:00u # Easter Time
-			-6:00	Chile	EAS%sT	2015 Apr 26 3:00u
-			-5:00	-	EAST
+			-6:00	Chile	EAS%sT
 #
 # Salas y Gómez Island is uninhabited.
 # Other Chilean locations, including Juan Fernández Is, Desventuradas Is,
@@ -1321,8 +1335,7 @@
 Zone Antarctica/Palmer	0	-	zzz	1965
 			-4:00	Arg	AR%sT	1969 Oct  5
 			-3:00	Arg	AR%sT	1982 May
-			-4:00	Chile	CL%sT	2015 Apr 26 3:00u
-			-3:00	-	CLT
+			-4:00	Chile	CL%sT
 
 # Colombia
 
@@ -1765,9 +1778,25 @@
 # resolution publication)
 # http://www.globovision.com/news.php?nid=72208
 
+# From Alexander Krivenyshev (2016-04-15):
+# https://actualidad.rt.com/actualidad/204758-venezuela-modificar-huso-horario-sequia-elnino
+#
+# From Paul Eggert (2016-04-15):
+# Clocks advance 30 minutes on 2016-05-01 at 02:30. See:
+# Barboza AD. Huso horario en Venezuela volverá a 4 horas menos con
+# respecto al "Greenwich". Panorama 2016-04-15 12:20 -0430.
+# http://www.panorama.com.ve/ciudad/Huso-horario-en-Venezuela-volvera-a-4-horas-menos-con-respecto-al-Greenwich-20160415-0032.html
+#
+# "'Venezuela's new time-zone: hours without light, hours without water,
+# hours of presidential broadcasts, hours of lines," quipped comedian
+# Jean Mary Curro ...". See: Cawthorne A, Kai D. Venezuela scraps
+# half-hour time difference set by Chavez. Reuters 2016-04-15 14:50 -0400
+# http://www.reuters.com/article/us-venezuela-timezone-idUSKCN0XC2BE
+
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	America/Caracas	-4:27:44 -	LMT	1890
 			-4:27:40 -	CMT	1912 Feb 12 # Caracas Mean Time?
 			-4:30	-	VET	1965 Jan  1  0:00 # Venezuela T.
 			-4:00	-	VET	2007 Dec  9  3:00
-			-4:30	-	VET
+			-4:30	-	VET	2016 May  1  2:30
+			-4:00	-	VET
diff --git a/jdk/make/data/tzdata/zone.tab b/jdk/make/data/tzdata/zone.tab
index 51aaf77..5649691 100644
--- a/jdk/make/data/tzdata/zone.tab
+++ b/jdk/make/data/tzdata/zone.tab
@@ -53,22 +53,22 @@
 AL	+4120+01950	Europe/Tirane
 AM	+4011+04430	Asia/Yerevan
 AO	-0848+01314	Africa/Luanda
-AQ	-7750+16636	Antarctica/McMurdo	McMurdo, South Pole, Scott (New Zealand time)
-AQ	-6734-06808	Antarctica/Rothera	Rothera Station, Adelaide Island
-AQ	-6448-06406	Antarctica/Palmer	Palmer Station, Anvers Island
-AQ	-6736+06253	Antarctica/Mawson	Mawson Station, Holme Bay
-AQ	-6835+07758	Antarctica/Davis	Davis Station, Vestfold Hills
-AQ	-6617+11031	Antarctica/Casey	Casey Station, Bailey Peninsula
-AQ	-7824+10654	Antarctica/Vostok	Vostok Station, Lake Vostok
-AQ	-6640+14001	Antarctica/DumontDUrville	Dumont-d'Urville Station, Adelie Land
-AQ	-690022+0393524	Antarctica/Syowa	Syowa Station, E Ongul I
-AQ	-720041+0023206	Antarctica/Troll	Troll Station, Queen Maud Land
+AQ	-7750+16636	Antarctica/McMurdo	New Zealand time - McMurdo, South Pole
+AQ	-6617+11031	Antarctica/Casey	Casey
+AQ	-6835+07758	Antarctica/Davis	Davis
+AQ	-6640+14001	Antarctica/DumontDUrville	Dumont-d'Urville
+AQ	-6736+06253	Antarctica/Mawson	Mawson
+AQ	-6448-06406	Antarctica/Palmer	Palmer
+AQ	-6734-06808	Antarctica/Rothera	Rothera
+AQ	-690022+0393524	Antarctica/Syowa	Syowa
+AQ	-720041+0023206	Antarctica/Troll	Troll
+AQ	-7824+10654	Antarctica/Vostok	Vostok
 AR	-3436-05827	America/Argentina/Buenos_Aires	Buenos Aires (BA, CF)
-AR	-3124-06411	America/Argentina/Cordoba	most locations (CB, CC, CN, ER, FM, MN, SE, SF)
-AR	-2447-06525	America/Argentina/Salta	(SA, LP, NQ, RN)
+AR	-3124-06411	America/Argentina/Cordoba	Argentina (most areas: CB, CC, CN, ER, FM, MN, SE, SF)
+AR	-2447-06525	America/Argentina/Salta	Salta (SA, LP, NQ, RN)
 AR	-2411-06518	America/Argentina/Jujuy	Jujuy (JY)
 AR	-2649-06513	America/Argentina/Tucuman	Tucuman (TM)
-AR	-2828-06547	America/Argentina/Catamarca	Catamarca (CT), Chubut (CH)
+AR	-2828-06547	America/Argentina/Catamarca	Catamarca (CT); Chubut (CH)
 AR	-2926-06651	America/Argentina/La_Rioja	La Rioja (LR)
 AR	-3132-06831	America/Argentina/San_Juan	San Juan (SJ)
 AR	-3253-06849	America/Argentina/Mendoza	Mendoza (MZ)
@@ -79,17 +79,17 @@
 AT	+4813+01620	Europe/Vienna
 AU	-3133+15905	Australia/Lord_Howe	Lord Howe Island
 AU	-5430+15857	Antarctica/Macquarie	Macquarie Island
-AU	-4253+14719	Australia/Hobart	Tasmania - most locations
-AU	-3956+14352	Australia/Currie	Tasmania - King Island
+AU	-4253+14719	Australia/Hobart	Tasmania (most areas)
+AU	-3956+14352	Australia/Currie	Tasmania (King Island)
 AU	-3749+14458	Australia/Melbourne	Victoria
-AU	-3352+15113	Australia/Sydney	New South Wales - most locations
-AU	-3157+14127	Australia/Broken_Hill	New South Wales - Yancowinna
-AU	-2728+15302	Australia/Brisbane	Queensland - most locations
-AU	-2016+14900	Australia/Lindeman	Queensland - Holiday Islands
+AU	-3352+15113	Australia/Sydney	New South Wales (most areas)
+AU	-3157+14127	Australia/Broken_Hill	New South Wales (Yancowinna)
+AU	-2728+15302	Australia/Brisbane	Queensland (most areas)
+AU	-2016+14900	Australia/Lindeman	Queensland (Whitsunday Islands)
 AU	-3455+13835	Australia/Adelaide	South Australia
 AU	-1228+13050	Australia/Darwin	Northern Territory
-AU	-3157+11551	Australia/Perth	Western Australia - most locations
-AU	-3143+12852	Australia/Eucla	Western Australia - Eucla area
+AU	-3157+11551	Australia/Perth	Western Australia (most areas)
+AU	-3143+12852	Australia/Eucla	Western Australia (Eucla)
 AW	+1230-06958	America/Aruba
 AX	+6006+01957	Europe/Mariehamn
 AZ	+4023+04951	Asia/Baku
@@ -108,63 +108,63 @@
 BO	-1630-06809	America/La_Paz
 BQ	+120903-0681636	America/Kralendijk
 BR	-0351-03225	America/Noronha	Atlantic islands
-BR	-0127-04829	America/Belem	Amapa, E Para
-BR	-0343-03830	America/Fortaleza	NE Brazil (MA, PI, CE, RN, PB)
+BR	-0127-04829	America/Belem	Para (east); Amapa
+BR	-0343-03830	America/Fortaleza	Brazil (northeast: MA, PI, CE, RN, PB)
 BR	-0803-03454	America/Recife	Pernambuco
 BR	-0712-04812	America/Araguaina	Tocantins
 BR	-0940-03543	America/Maceio	Alagoas, Sergipe
 BR	-1259-03831	America/Bahia	Bahia
-BR	-2332-04637	America/Sao_Paulo	S & SE Brazil (GO, DF, MG, ES, RJ, SP, PR, SC, RS)
+BR	-2332-04637	America/Sao_Paulo	Brazil (southeast: GO, DF, MG, ES, RJ, SP, PR, SC, RS)
 BR	-2027-05437	America/Campo_Grande	Mato Grosso do Sul
 BR	-1535-05605	America/Cuiaba	Mato Grosso
-BR	-0226-05452	America/Santarem	W Para
+BR	-0226-05452	America/Santarem	Para (west)
 BR	-0846-06354	America/Porto_Velho	Rondonia
 BR	+0249-06040	America/Boa_Vista	Roraima
-BR	-0308-06001	America/Manaus	E Amazonas
-BR	-0640-06952	America/Eirunepe	W Amazonas
+BR	-0308-06001	America/Manaus	Amazonas (east)
+BR	-0640-06952	America/Eirunepe	Amazonas (west)
 BR	-0958-06748	America/Rio_Branco	Acre
 BS	+2505-07721	America/Nassau
 BT	+2728+08939	Asia/Thimphu
 BW	-2439+02555	Africa/Gaborone
 BY	+5354+02734	Europe/Minsk
 BZ	+1730-08812	America/Belize
-CA	+4734-05243	America/St_Johns	Newfoundland Time, including SE Labrador
-CA	+4439-06336	America/Halifax	Atlantic Time - Nova Scotia (peninsula), PEI
-CA	+4612-05957	America/Glace_Bay	Atlantic Time - Nova Scotia (Cape Breton)
-CA	+4606-06447	America/Moncton	Atlantic Time - New Brunswick
-CA	+5320-06025	America/Goose_Bay	Atlantic Time - Labrador - most locations
-CA	+5125-05707	America/Blanc-Sablon	Atlantic Standard Time - Quebec - Lower North Shore
-CA	+4339-07923	America/Toronto	Eastern Time - Ontario & Quebec - most locations
-CA	+4901-08816	America/Nipigon	Eastern Time - Ontario & Quebec - places that did not observe DST 1967-1973
-CA	+4823-08915	America/Thunder_Bay	Eastern Time - Thunder Bay, Ontario
-CA	+6344-06828	America/Iqaluit	Eastern Time - east Nunavut - most locations
-CA	+6608-06544	America/Pangnirtung	Eastern Time - Pangnirtung, Nunavut
-CA	+744144-0944945	America/Resolute	Central Time - Resolute, Nunavut
-CA	+484531-0913718	America/Atikokan	Eastern Standard Time - Atikokan, Ontario and Southampton I, Nunavut
-CA	+624900-0920459	America/Rankin_Inlet	Central Time - central Nunavut
-CA	+4953-09709	America/Winnipeg	Central Time - Manitoba & west Ontario
-CA	+4843-09434	America/Rainy_River	Central Time - Rainy River & Fort Frances, Ontario
-CA	+5024-10439	America/Regina	Central Standard Time - Saskatchewan - most locations
-CA	+5017-10750	America/Swift_Current	Central Standard Time - Saskatchewan - midwest
-CA	+5333-11328	America/Edmonton	Mountain Time - Alberta, east British Columbia & west Saskatchewan
-CA	+690650-1050310	America/Cambridge_Bay	Mountain Time - west Nunavut
-CA	+6227-11421	America/Yellowknife	Mountain Time - central Northwest Territories
-CA	+682059-1334300	America/Inuvik	Mountain Time - west Northwest Territories
-CA	+4906-11631	America/Creston	Mountain Standard Time - Creston, British Columbia
-CA	+5946-12014	America/Dawson_Creek	Mountain Standard Time - Dawson Creek & Fort Saint John, British Columbia
-CA	+5848-12242	America/Fort_Nelson	Mountain Standard Time - Fort Nelson, British Columbia
-CA	+4916-12307	America/Vancouver	Pacific Time - west British Columbia
-CA	+6043-13503	America/Whitehorse	Pacific Time - south Yukon
-CA	+6404-13925	America/Dawson	Pacific Time - north Yukon
+CA	+4734-05243	America/St_Johns	Newfoundland; Labrador (southeast)
+CA	+4439-06336	America/Halifax	Atlantic - NS (most areas); PE
+CA	+4612-05957	America/Glace_Bay	Atlantic - NS (Cape Breton)
+CA	+4606-06447	America/Moncton	Atlantic - New Brunswick
+CA	+5320-06025	America/Goose_Bay	Atlantic - Labrador (most areas)
+CA	+5125-05707	America/Blanc-Sablon	AST - QC (Lower North Shore)
+CA	+4339-07923	America/Toronto	Eastern - ON, QC (most areas)
+CA	+4901-08816	America/Nipigon	Eastern - ON, QC (no DST 1967-73)
+CA	+4823-08915	America/Thunder_Bay	Eastern - ON (Thunder Bay)
+CA	+6344-06828	America/Iqaluit	Eastern - NU (most east areas)
+CA	+6608-06544	America/Pangnirtung	Eastern - NU (Pangnirtung)
+CA	+484531-0913718	America/Atikokan	EST - ON (Atikokan); NU (Coral H)
+CA	+4953-09709	America/Winnipeg	Central - ON (west); Manitoba
+CA	+4843-09434	America/Rainy_River	Central - ON (Rainy R, Ft Frances)
+CA	+744144-0944945	America/Resolute	Central - NU (Resolute)
+CA	+624900-0920459	America/Rankin_Inlet	Central - NU (central)
+CA	+5024-10439	America/Regina	CST - SK (most areas)
+CA	+5017-10750	America/Swift_Current	CST - SK (midwest)
+CA	+5333-11328	America/Edmonton	Mountain - AB; BC (E); SK (W)
+CA	+690650-1050310	America/Cambridge_Bay	Mountain - NU (west)
+CA	+6227-11421	America/Yellowknife	Mountain - NT (central)
+CA	+682059-1334300	America/Inuvik	Mountain - NT (west)
+CA	+4906-11631	America/Creston	MST - BC (Creston)
+CA	+5946-12014	America/Dawson_Creek	MST - BC (Dawson Cr, Ft St John)
+CA	+5848-12242	America/Fort_Nelson	MST - BC (Ft Nelson)
+CA	+4916-12307	America/Vancouver	Pacific - BC (most areas)
+CA	+6043-13503	America/Whitehorse	Pacific - Yukon (south)
+CA	+6404-13925	America/Dawson	Pacific - Yukon (north)
 CC	-1210+09655	Indian/Cocos
-CD	-0418+01518	Africa/Kinshasa	west Dem. Rep. of Congo
-CD	-1140+02728	Africa/Lubumbashi	east Dem. Rep. of Congo
+CD	-0418+01518	Africa/Kinshasa	Dem. Rep. of Congo (west)
+CD	-1140+02728	Africa/Lubumbashi	Dem. Rep. of Congo (east)
 CF	+0422+01835	Africa/Bangui
 CG	-0416+01517	Africa/Brazzaville
 CH	+4723+00832	Europe/Zurich
 CI	+0519-00402	Africa/Abidjan
 CK	-2114-15946	Pacific/Rarotonga
-CL	-3327-07040	America/Santiago	most locations
+CL	-3327-07040	America/Santiago	Chile (most areas)
 CL	-2709-10926	Pacific/Easter	Easter Island
 CM	+0403+00942	Africa/Douala
 CN	+3114+12128	Asia/Shanghai	Beijing Time
@@ -177,28 +177,28 @@
 CX	-1025+10543	Indian/Christmas
 CY	+3510+03322	Asia/Nicosia
 CZ	+5005+01426	Europe/Prague
-DE	+5230+01322	Europe/Berlin	most locations
+DE	+5230+01322	Europe/Berlin	Germany (most areas)
 DE	+4742+00841	Europe/Busingen	Busingen
 DJ	+1136+04309	Africa/Djibouti
 DK	+5540+01235	Europe/Copenhagen
 DM	+1518-06124	America/Dominica
 DO	+1828-06954	America/Santo_Domingo
 DZ	+3647+00303	Africa/Algiers
-EC	-0210-07950	America/Guayaquil	mainland
+EC	-0210-07950	America/Guayaquil	Ecuador (mainland)
 EC	-0054-08936	Pacific/Galapagos	Galapagos Islands
 EE	+5925+02445	Europe/Tallinn
 EG	+3003+03115	Africa/Cairo
 EH	+2709-01312	Africa/El_Aaiun
 ER	+1520+03853	Africa/Asmara
-ES	+4024-00341	Europe/Madrid	mainland
-ES	+3553-00519	Africa/Ceuta	Ceuta & Melilla
+ES	+4024-00341	Europe/Madrid	Spain (mainland)
+ES	+3553-00519	Africa/Ceuta	Ceuta, Melilla
 ES	+2806-01524	Atlantic/Canary	Canary Islands
 ET	+0902+03842	Africa/Addis_Ababa
 FI	+6010+02458	Europe/Helsinki
 FJ	-1808+17825	Pacific/Fiji
 FK	-5142-05751	Atlantic/Stanley
-FM	+0725+15147	Pacific/Chuuk	Chuuk (Truk) and Yap
-FM	+0658+15813	Pacific/Pohnpei	Pohnpei (Ponape)
+FM	+0725+15147	Pacific/Chuuk	Chuuk/Truk, Yap
+FM	+0658+15813	Pacific/Pohnpei	Pohnpei/Ponape
 FM	+0519+16259	Pacific/Kosrae	Kosrae
 FO	+6201-00646	Atlantic/Faroe
 FR	+4852+00220	Europe/Paris
@@ -210,10 +210,10 @@
 GG	+4927-00232	Europe/Guernsey
 GH	+0533-00013	Africa/Accra
 GI	+3608-00521	Europe/Gibraltar
-GL	+6411-05144	America/Godthab	most locations
-GL	+7646-01840	America/Danmarkshavn	east coast, north of Scoresbysund
-GL	+7029-02158	America/Scoresbysund	Scoresbysund / Ittoqqortoormiit
-GL	+7634-06847	America/Thule	Thule / Pituffik
+GL	+6411-05144	America/Godthab	Greenland (most areas)
+GL	+7646-01840	America/Danmarkshavn	National Park (east coast)
+GL	+7029-02158	America/Scoresbysund	Scoresbysund/Ittoqqortoormiit
+GL	+7634-06847	America/Thule	Thule/Pituffik
 GM	+1328-01639	Africa/Banjul
 GN	+0931-01343	Africa/Conakry
 GP	+1614-06132	America/Guadeloupe
@@ -229,10 +229,10 @@
 HR	+4548+01558	Europe/Zagreb
 HT	+1832-07220	America/Port-au-Prince
 HU	+4730+01905	Europe/Budapest
-ID	-0610+10648	Asia/Jakarta	Java & Sumatra
-ID	-0002+10920	Asia/Pontianak	west & central Borneo
-ID	-0507+11924	Asia/Makassar	east & south Borneo, Sulawesi (Celebes), Bali, Nusa Tengarra, west Timor
-ID	-0232+14042	Asia/Jayapura	west New Guinea (Irian Jaya) & Malukus (Moluccas)
+ID	-0610+10648	Asia/Jakarta	Java, Sumatra
+ID	-0002+10920	Asia/Pontianak	Borneo (west, central)
+ID	-0507+11924	Asia/Makassar	Borneo (east, south); Sulawesi/Celebes, Bali, Nusa Tengarra; Timor (west)
+ID	-0232+14042	Asia/Jayapura	New Guinea (West Papua / Irian Jaya); Malukus/Moluccas
 IE	+5320-00615	Europe/Dublin
 IL	+314650+0351326	Asia/Jerusalem
 IM	+5409-00428	Europe/Isle_of_Man
@@ -258,10 +258,10 @@
 KR	+3733+12658	Asia/Seoul
 KW	+2920+04759	Asia/Kuwait
 KY	+1918-08123	America/Cayman
-KZ	+4315+07657	Asia/Almaty	most locations
-KZ	+4448+06528	Asia/Qyzylorda	Qyzylorda (Kyzylorda, Kzyl-Orda)
-KZ	+5017+05710	Asia/Aqtobe	Aqtobe (Aktobe)
-KZ	+4431+05016	Asia/Aqtau	Atyrau (Atirau, Gur'yev), Mangghystau (Mankistau)
+KZ	+4315+07657	Asia/Almaty	Kazakhstan (most areas)
+KZ	+4448+06528	Asia/Qyzylorda	Qyzylorda/Kyzylorda/Kzyl-Orda
+KZ	+5017+05710	Asia/Aqtobe	Aqtobe/Aktobe
+KZ	+4431+05016	Asia/Aqtau	Atyrau/Atirau/Gur'yev, Mangghystau/Mankistau
 KZ	+5113+05121	Asia/Oral	West Kazakhstan
 LA	+1758+10236	Asia/Vientiane
 LB	+3353+03530	Asia/Beirut
@@ -280,12 +280,12 @@
 ME	+4226+01916	Europe/Podgorica
 MF	+1804-06305	America/Marigot
 MG	-1855+04731	Indian/Antananarivo
-MH	+0709+17112	Pacific/Majuro	most locations
+MH	+0709+17112	Pacific/Majuro	Marshall Islands (most areas)
 MH	+0905+16720	Pacific/Kwajalein	Kwajalein
 MK	+4159+02126	Europe/Skopje
 ML	+1239-00800	Africa/Bamako
 MM	+1647+09610	Asia/Rangoon
-MN	+4755+10653	Asia/Ulaanbaatar	most locations
+MN	+4755+10653	Asia/Ulaanbaatar	Mongolia (most areas)
 MN	+4801+09139	Asia/Hovd	Bayan-Olgiy, Govi-Altai, Hovd, Uvs, Zavkhan
 MN	+4804+11430	Asia/Choibalsan	Dornod, Sukhbaatar
 MO	+2214+11335	Asia/Macau
@@ -297,19 +297,19 @@
 MU	-2010+05730	Indian/Mauritius
 MV	+0410+07330	Indian/Maldives
 MW	-1547+03500	Africa/Blantyre
-MX	+1924-09909	America/Mexico_City	Central Time - most locations
+MX	+1924-09909	America/Mexico_City	Central Time
 MX	+2105-08646	America/Cancun	Eastern Standard Time - Quintana Roo
 MX	+2058-08937	America/Merida	Central Time - Campeche, Yucatan
-MX	+2540-10019	America/Monterrey	Mexican Central Time - Coahuila, Durango, Nuevo Leon, Tamaulipas away from US border
-MX	+2550-09730	America/Matamoros	US Central Time - Coahuila, Durango, Nuevo Leon, Tamaulipas near US border
-MX	+2313-10625	America/Mazatlan	Mountain Time - S Baja, Nayarit, Sinaloa
-MX	+2838-10605	America/Chihuahua	Mexican Mountain Time - Chihuahua away from US border
-MX	+2934-10425	America/Ojinaga	US Mountain Time - Chihuahua near US border
+MX	+2540-10019	America/Monterrey	Central Time - Durango; Coahuila, Nuevo Leon, Tamaulipas (most areas)
+MX	+2550-09730	America/Matamoros	Central Time US - Coahuila, Nuevo Leon, Tamaulipas (US border)
+MX	+2313-10625	America/Mazatlan	Mountain Time - Baja California Sur, Nayarit, Sinaloa
+MX	+2838-10605	America/Chihuahua	Mountain Time - Chihuahua (most areas)
+MX	+2934-10425	America/Ojinaga	Mountain Time US - Chihuahua (US border)
 MX	+2904-11058	America/Hermosillo	Mountain Standard Time - Sonora
-MX	+3232-11701	America/Tijuana	US Pacific Time - Baja California state
-MX	+2048-10515	America/Bahia_Banderas	Mexican Central Time - Bahia de Banderas
-MY	+0310+10142	Asia/Kuala_Lumpur	peninsular Malaysia
-MY	+0133+11020	Asia/Kuching	Sabah & Sarawak
+MX	+3232-11701	America/Tijuana	Pacific Time US - Baja California
+MX	+2048-10515	America/Bahia_Banderas	Central Time - Bahia de Banderas
+MY	+0310+10142	Asia/Kuala_Lumpur	Malaysia (peninsula)
+MY	+0133+11020	Asia/Kuching	Sabah, Sarawak
 MZ	-2558+03235	Africa/Maputo
 NA	-2234+01706	Africa/Windhoek
 NC	-2216+16627	Pacific/Noumea
@@ -322,7 +322,7 @@
 NP	+2743+08519	Asia/Kathmandu
 NR	-0031+16655	Pacific/Nauru
 NU	-1901-16955	Pacific/Niue
-NZ	-3652+17446	Pacific/Auckland	most locations
+NZ	-3652+17446	Pacific/Auckland	New Zealand (most areas)
 NZ	-4357-17633	Pacific/Chatham	Chatham Islands
 OM	+2336+05835	Asia/Muscat
 PA	+0858-07932	America/Panama
@@ -330,7 +330,7 @@
 PF	-1732-14934	Pacific/Tahiti	Society Islands
 PF	-0900-13930	Pacific/Marquesas	Marquesas Islands
 PF	-2308-13457	Pacific/Gambier	Gambier Islands
-PG	-0930+14710	Pacific/Port_Moresby	most locations
+PG	-0930+14710	Pacific/Port_Moresby	Papua New Guinea (most areas)
 PG	-0613+15534	Pacific/Bougainville	Bougainville
 PH	+1435+12100	Asia/Manila
 PK	+2452+06703	Asia/Karachi
@@ -340,7 +340,7 @@
 PR	+182806-0660622	America/Puerto_Rico
 PS	+3130+03428	Asia/Gaza	Gaza Strip
 PS	+313200+0350542	Asia/Hebron	West Bank
-PT	+3843-00908	Europe/Lisbon	mainland
+PT	+3843-00908	Europe/Lisbon	Portugal (mainland)
 PT	+3238-01654	Atlantic/Madeira	Madeira Islands
 PT	+3744-02540	Atlantic/Azores	Azores
 PW	+0720+13429	Pacific/Palau
@@ -349,27 +349,32 @@
 RE	-2052+05528	Indian/Reunion
 RO	+4426+02606	Europe/Bucharest
 RS	+4450+02030	Europe/Belgrade
-RU	+5443+02030	Europe/Kaliningrad	Moscow-01 - Kaliningrad
-RU	+554521+0373704	Europe/Moscow	Moscow+00 - west Russia
-RU	+4457+03406	Europe/Simferopol	Moscow+00 - Crimea
-RU	+4844+04425	Europe/Volgograd	Moscow+00 - Caspian Sea
-RU	+5312+05009	Europe/Samara	Moscow+00 (Moscow+01 after 2014-10-26) - Samara, Udmurtia
-RU	+5651+06036	Asia/Yekaterinburg	Moscow+02 - Urals
-RU	+5500+07324	Asia/Omsk	Moscow+03 - west Siberia
-RU	+5502+08255	Asia/Novosibirsk	Moscow+03 - Novosibirsk
-RU	+5345+08707	Asia/Novokuznetsk	Moscow+03 (Moscow+04 after 2014-10-26) - Kemerovo
-RU	+5601+09250	Asia/Krasnoyarsk	Moscow+04 - Yenisei River
-RU	+5216+10420	Asia/Irkutsk	Moscow+05 - Lake Baikal
-RU	+5203+11328	Asia/Chita	Moscow+06 (Moscow+05 after 2014-10-26) - Zabaykalsky
-RU	+6200+12940	Asia/Yakutsk	Moscow+06 - Lena River
-RU	+623923+1353314	Asia/Khandyga	Moscow+06 - Tomponsky, Ust-Maysky
-RU	+4310+13156	Asia/Vladivostok	Moscow+07 - Amur River
-RU	+4658+14242	Asia/Sakhalin	Moscow+07 - Sakhalin Island
-RU	+643337+1431336	Asia/Ust-Nera	Moscow+07 - Oymyakonsky
-RU	+5934+15048	Asia/Magadan	Moscow+08 (Moscow+07 after 2014-10-26) - Magadan
-RU	+6728+15343	Asia/Srednekolymsk	Moscow+08 - E Sakha, N Kuril Is
-RU	+5301+15839	Asia/Kamchatka	Moscow+08 (Moscow+09 after 2014-10-26) - Kamchatka
-RU	+6445+17729	Asia/Anadyr	Moscow+08 (Moscow+09 after 2014-10-26) - Bering Sea
+RU	+5443+02030	Europe/Kaliningrad	MSK-01 - Kaliningrad
+RU	+554521+0373704	Europe/Moscow	MSK+00 - Moscow area
+RU	+4457+03406	Europe/Simferopol	MSK+00 - Crimea
+RU	+4844+04425	Europe/Volgograd	MSK+00 - Volgograd, Saratov
+RU	+5836+04939	Europe/Kirov	MSK+00 - Kirov
+RU	+4621+04803	Europe/Astrakhan	MSK+01 - Astrakhan
+RU	+5312+05009	Europe/Samara	MSK+01 - Samara, Udmurtia
+RU	+5420+04824	Europe/Ulyanovsk	MSK+01 - Ulyanovsk
+RU	+5651+06036	Asia/Yekaterinburg	MSK+02 - Urals
+RU	+5500+07324	Asia/Omsk	MSK+03 - Omsk
+RU	+5502+08255	Asia/Novosibirsk	MSK+03 - Novosibirsk
+RU	+5322+08345	Asia/Barnaul	MSK+04 - Altai
+RU	+5630+08458	Asia/Tomsk	MSK+04 - Tomsk
+RU	+5345+08707	Asia/Novokuznetsk	MSK+04 - Kemerovo
+RU	+5601+09250	Asia/Krasnoyarsk	MSK+04 - Krasnoyarsk area
+RU	+5216+10420	Asia/Irkutsk	MSK+05 - Irkutsk, Buryatia
+RU	+5203+11328	Asia/Chita	MSK+06 - Zabaykalsky
+RU	+6200+12940	Asia/Yakutsk	MSK+06 - Lena River
+RU	+623923+1353314	Asia/Khandyga	MSK+06 - Tomponsky, Ust-Maysky
+RU	+4310+13156	Asia/Vladivostok	MSK+07 - Amur River
+RU	+643337+1431336	Asia/Ust-Nera	MSK+07 - Oymyakonsky
+RU	+5934+15048	Asia/Magadan	MSK+08 - Magadan
+RU	+4658+14242	Asia/Sakhalin	MSK+08 - Sakhalin Island
+RU	+6728+15343	Asia/Srednekolymsk	MSK+08 - Sakha (E); North Kuril Is
+RU	+5301+15839	Asia/Kamchatka	MSK+09 - Kamchatka
+RU	+6445+17729	Asia/Anadyr	MSK+09 - Bering Sea
 RW	-0157+03004	Africa/Kigali
 SA	+2438+04643	Asia/Riyadh
 SB	-0932+16012	Pacific/Guadalcanal
@@ -408,45 +413,45 @@
 TV	-0831+17913	Pacific/Funafuti
 TW	+2503+12130	Asia/Taipei
 TZ	-0648+03917	Africa/Dar_es_Salaam
-UA	+5026+03031	Europe/Kiev	most locations
+UA	+5026+03031	Europe/Kiev	Ukraine (most areas)
 UA	+4837+02218	Europe/Uzhgorod	Ruthenia
-UA	+4750+03510	Europe/Zaporozhye	Zaporozh'ye, E Lugansk / Zaporizhia, E Luhansk
+UA	+4750+03510	Europe/Zaporozhye	Zaporozh'ye/Zaporizhia; Lugansk/Luhansk (east)
 UG	+0019+03225	Africa/Kampala
 UM	+1645-16931	Pacific/Johnston	Johnston Atoll
 UM	+2813-17722	Pacific/Midway	Midway Islands
 UM	+1917+16637	Pacific/Wake	Wake Island
-US	+404251-0740023	America/New_York	Eastern Time
-US	+421953-0830245	America/Detroit	Eastern Time - Michigan - most locations
-US	+381515-0854534	America/Kentucky/Louisville	Eastern Time - Kentucky - Louisville area
-US	+364947-0845057	America/Kentucky/Monticello	Eastern Time - Kentucky - Wayne County
-US	+394606-0860929	America/Indiana/Indianapolis	Eastern Time - Indiana - most locations
-US	+384038-0873143	America/Indiana/Vincennes	Eastern Time - Indiana - Daviess, Dubois, Knox & Martin Counties
-US	+410305-0863611	America/Indiana/Winamac	Eastern Time - Indiana - Pulaski County
-US	+382232-0862041	America/Indiana/Marengo	Eastern Time - Indiana - Crawford County
-US	+382931-0871643	America/Indiana/Petersburg	Eastern Time - Indiana - Pike County
-US	+384452-0850402	America/Indiana/Vevay	Eastern Time - Indiana - Switzerland County
-US	+415100-0873900	America/Chicago	Central Time
-US	+375711-0864541	America/Indiana/Tell_City	Central Time - Indiana - Perry County
-US	+411745-0863730	America/Indiana/Knox	Central Time - Indiana - Starke County
-US	+450628-0873651	America/Menominee	Central Time - Michigan - Dickinson, Gogebic, Iron & Menominee Counties
-US	+470659-1011757	America/North_Dakota/Center	Central Time - North Dakota - Oliver County
-US	+465042-1012439	America/North_Dakota/New_Salem	Central Time - North Dakota - Morton County (except Mandan area)
-US	+471551-1014640	America/North_Dakota/Beulah	Central Time - North Dakota - Mercer County
-US	+394421-1045903	America/Denver	Mountain Time
-US	+433649-1161209	America/Boise	Mountain Time - south Idaho & east Oregon
-US	+332654-1120424	America/Phoenix	Mountain Standard Time - Arizona (except Navajo)
-US	+340308-1181434	America/Los_Angeles	Pacific Time
-US	+611305-1495401	America/Anchorage	Alaska Time
-US	+581807-1342511	America/Juneau	Alaska Time - Alaska panhandle
-US	+571035-1351807	America/Sitka	Alaska Time - southeast Alaska panhandle
-US	+550737-1313435	America/Metlakatla	Alaska Time - Annette Island
-US	+593249-1394338	America/Yakutat	Alaska Time - Alaska panhandle neck
-US	+643004-1652423	America/Nome	Alaska Time - west Alaska
+US	+404251-0740023	America/New_York	Eastern (most areas)
+US	+421953-0830245	America/Detroit	Eastern - MI (most areas)
+US	+381515-0854534	America/Kentucky/Louisville	Eastern - KY (Louisville area)
+US	+364947-0845057	America/Kentucky/Monticello	Eastern - KY (Wayne)
+US	+394606-0860929	America/Indiana/Indianapolis	Eastern - IN (most areas)
+US	+384038-0873143	America/Indiana/Vincennes	Eastern - IN (Da, Du, K, Mn)
+US	+410305-0863611	America/Indiana/Winamac	Eastern - IN (Pulaski)
+US	+382232-0862041	America/Indiana/Marengo	Eastern - IN (Crawford)
+US	+382931-0871643	America/Indiana/Petersburg	Eastern - IN (Pike)
+US	+384452-0850402	America/Indiana/Vevay	Eastern - IN (Switzerland)
+US	+415100-0873900	America/Chicago	Central (most areas)
+US	+375711-0864541	America/Indiana/Tell_City	Central - IN (Perry)
+US	+411745-0863730	America/Indiana/Knox	Central - IN (Starke)
+US	+450628-0873651	America/Menominee	Central - MI (Wisconsin border)
+US	+470659-1011757	America/North_Dakota/Center	Central - ND (Oliver)
+US	+465042-1012439	America/North_Dakota/New_Salem	Central - ND (Morton rural)
+US	+471551-1014640	America/North_Dakota/Beulah	Central - ND (Mercer)
+US	+394421-1045903	America/Denver	Mountain (most areas)
+US	+433649-1161209	America/Boise	Mountain - ID (south); OR (east)
+US	+332654-1120424	America/Phoenix	MST - Arizona (except Navajo)
+US	+340308-1181434	America/Los_Angeles	Pacific
+US	+611305-1495401	America/Anchorage	Alaska (most areas)
+US	+581807-1342511	America/Juneau	Alaska - Juneau area
+US	+571035-1351807	America/Sitka	Alaska - Sitka area
+US	+550737-1313435	America/Metlakatla	Alaska - Annette Island
+US	+593249-1394338	America/Yakutat	Alaska - Yakutat
+US	+643004-1652423	America/Nome	Alaska (west)
 US	+515248-1763929	America/Adak	Aleutian Islands
 US	+211825-1575130	Pacific/Honolulu	Hawaii
 UY	-3453-05611	America/Montevideo
-UZ	+3940+06648	Asia/Samarkand	west Uzbekistan
-UZ	+4120+06918	Asia/Tashkent	east Uzbekistan
+UZ	+3940+06648	Asia/Samarkand	Uzbekistan (west)
+UZ	+4120+06918	Asia/Tashkent	Uzbekistan (east)
 VA	+415408+0122711	Europe/Vatican
 VC	+1309-06114	America/St_Vincent
 VE	+1030-06656	America/Caracas
diff --git a/jdk/make/src/classes/build/tools/cldrconverter/ResourceBundleGenerator.java b/jdk/make/src/classes/build/tools/cldrconverter/ResourceBundleGenerator.java
index b905f75..d5eecf2 100644
--- a/jdk/make/src/classes/build/tools/cldrconverter/ResourceBundleGenerator.java
+++ b/jdk/make/src/classes/build/tools/cldrconverter/ResourceBundleGenerator.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, 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
@@ -30,11 +30,37 @@
 import java.io.PrintWriter;
 import java.util.Formatter;
 import java.util.HashSet;
+import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Set;
 import java.util.SortedSet;
 
 class ResourceBundleGenerator implements BundleGenerator {
+    // preferred timezones - keeping compatibility with JDK1.1 3 letter abbreviations
+    private static final String[] preferredTZIDs = {
+        "America/Los_Angeles",
+        "America/Denver",
+        "America/Phoenix",
+        "America/Chicago",
+        "America/New_York",
+        "America/Indianapolis",
+        "Pacific/Honolulu",
+        "America/Anchorage",
+        "America/Halifax",
+        "America/Sitka",
+        "America/St_Johns",
+        "Europe/Paris",
+        // Although CLDR does not support abbreviated zones, handle "GMT" as a
+        // special case here, as it is specified in the javadoc.
+        "GMT",
+        "Africa/Casablanca",
+        "Asia/Jerusalem",
+        "Asia/Tokyo",
+        "Europe/Bucharest",
+        "Asia/Shanghai",
+        "UTC",
+    };
+
     @Override
     public void generateBundle(String packageName, String baseName, String localeID, boolean useJava,
                                Map<String, ?> map, BundleType type) throws IOException {
@@ -89,6 +115,19 @@
             for (String key : metaKeys) {
                 map.remove(key);
             }
+
+            // Make it preferred ordered
+            LinkedHashMap<String, Object> newMap = new LinkedHashMap<>();
+            for (String preferred : preferredTZIDs) {
+                if (map.containsKey(preferred)) {
+                    newMap.put(preferred, map.remove(preferred));
+                } else if (("GMT".equals(preferred) || "UTC".equals(preferred)) &&
+                           metaKeys.contains(CLDRConverter.METAZONE_ID_PREFIX+preferred)) {
+                    newMap.put(preferred, preferred);
+                }
+            }
+            newMap.putAll(map);
+            map = newMap;
         }
 
         try (PrintWriter out = new PrintWriter(file, encoding)) {
diff --git a/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_ko.properties b/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_ko.properties
index 530caa6..51de7a1 100644
--- a/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_ko.properties
+++ b/jdk/src/share/classes/com/sun/accessibility/internal/resources/accessibility_ko.properties
@@ -15,13 +15,13 @@
 #
 alert=\uACBD\uBCF4
 awtcomponent=AWT \uAD6C\uC131 \uC694\uC18C
-checkbox=\uCCB4\uD06C \uBC15\uC2A4
+checkbox=\uCCB4\uD06C\uBC15\uC2A4
 colorchooser=\uC0C9\uC0C1 \uC120\uD0DD\uAE30
 columnheader=\uC5F4 \uBA38\uB9AC\uAE00
 combobox=\uCF64\uBCF4 \uC0C1\uC790
 canvas=\uCE94\uBC84\uC2A4
-desktopicon=\uBC14\uD0D5 \uD654\uBA74 \uC544\uC774\uCF58
-desktoppane=\uBC14\uD0D5 \uD654\uBA74 \uCC3D
+desktopicon=\uBC14\uD0D5\uD654\uBA74 \uC544\uC774\uCF58
+desktoppane=\uBC14\uD0D5\uD654\uBA74 \uCC3D
 dialog=\uB300\uD654\uC0C1\uC790
 directorypane=\uB514\uB809\uD1A0\uB9AC \uCC3D
 glasspane=\uAE00\uB798\uC2A4 \uCC3D
diff --git a/jdk/src/share/classes/com/sun/crypto/provider/AESCipher.java b/jdk/src/share/classes/com/sun/crypto/provider/AESCipher.java
index 32cb3e3..9d11f00 100644
--- a/jdk/src/share/classes/com/sun/crypto/provider/AESCipher.java
+++ b/jdk/src/share/classes/com/sun/crypto/provider/AESCipher.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2013, 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
@@ -172,6 +172,11 @@
      */
     private final int fixedKeySize; // in bytes, -1 if no restriction
 
+    /*
+     * needed to enforce ISE thrown when updateAAD is called after update for GCM mode.
+     */
+    private boolean updateCalled;
+
     /**
      * Creates an instance of AES cipher with default ECB mode and
      * PKCS5Padding.
@@ -304,6 +309,7 @@
     protected void engineInit(int opmode, Key key, SecureRandom random)
         throws InvalidKeyException {
         checkKeySize(key, fixedKeySize);
+        updateCalled = false;
         core.init(opmode, key, random);
     }
 
@@ -336,6 +342,7 @@
                               SecureRandom random)
         throws InvalidKeyException, InvalidAlgorithmParameterException {
         checkKeySize(key, fixedKeySize);
+        updateCalled = false;
         core.init(opmode, key, params, random);
     }
 
@@ -344,6 +351,7 @@
                               SecureRandom random)
         throws InvalidKeyException, InvalidAlgorithmParameterException {
         checkKeySize(key, fixedKeySize);
+        updateCalled = false;
         core.init(opmode, key, params, random);
     }
 
@@ -368,6 +376,7 @@
      */
     protected byte[] engineUpdate(byte[] input, int inputOffset,
                                   int inputLen) {
+        updateCalled = true;
         return core.update(input, inputOffset, inputLen);
     }
 
@@ -397,6 +406,7 @@
     protected int engineUpdate(byte[] input, int inputOffset, int inputLen,
                                byte[] output, int outputOffset)
         throws ShortBufferException {
+        updateCalled = true;
         return core.update(input, inputOffset, inputLen, output,
                            outputOffset);
     }
@@ -433,7 +443,9 @@
      */
     protected byte[] engineDoFinal(byte[] input, int inputOffset, int inputLen)
         throws IllegalBlockSizeException, BadPaddingException {
-        return core.doFinal(input, inputOffset, inputLen);
+        byte[] out = core.doFinal(input, inputOffset, inputLen);
+        updateCalled = false;
+        return out;
     }
 
     /**
@@ -476,8 +488,10 @@
                                 byte[] output, int outputOffset)
         throws IllegalBlockSizeException, ShortBufferException,
                BadPaddingException {
-        return core.doFinal(input, inputOffset, inputLen, output,
-                            outputOffset);
+        int outLen = core.doFinal(input, inputOffset, inputLen, output,
+                                  outputOffset);
+        updateCalled = false;
+        return outLen;
     }
 
     /**
@@ -574,6 +588,9 @@
      */
     @Override
     protected void engineUpdateAAD(byte[] src, int offset, int len) {
+        if (core.getMode() == CipherCore.GCM_MODE && updateCalled) {
+            throw new IllegalStateException("AAD must be supplied before encryption/decryption starts");
+        }
         core.updateAAD(src, offset, len);
     }
 
@@ -606,6 +623,9 @@
      */
     @Override
     protected void engineUpdateAAD(ByteBuffer src) {
+        if (core.getMode() == CipherCore.GCM_MODE && updateCalled) {
+            throw new IllegalStateException("AAD must be supplied before encryption/decryption starts");
+        }
         if (src != null) {
             int aadLen = src.limit() - src.position();
             if (aadLen != 0) {
diff --git a/jdk/src/share/classes/com/sun/crypto/provider/CipherCore.java b/jdk/src/share/classes/com/sun/crypto/provider/CipherCore.java
index 408da30..79f66cd 100644
--- a/jdk/src/share/classes/com/sun/crypto/provider/CipherCore.java
+++ b/jdk/src/share/classes/com/sun/crypto/provider/CipherCore.java
@@ -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
@@ -124,7 +124,7 @@
     private static final int PCBC_MODE = 4;
     private static final int CTR_MODE = 5;
     private static final int CTS_MODE = 6;
-    private static final int GCM_MODE = 7;
+    static final int GCM_MODE = 7;
 
     /*
      * variables used for performing the GCM (key+iv) uniqueness check.
@@ -196,7 +196,7 @@
             cipher = new CounterMode(rawImpl);
             unitBytes = 1;
             padding = null;
-        }  else if (modeUpperCase.startsWith("GCM")) {
+        }  else if (modeUpperCase.equals("GCM")) {
             // can only be used for block ciphers w/ 128-bit block size
             if (blockSize != 16) {
                 throw new NoSuchAlgorithmException
@@ -223,6 +223,15 @@
         }
     }
 
+    /**
+     * Returns the mode of this cipher.
+     *
+     * @return the parsed cipher mode
+     */
+    int getMode() {
+        return cipherMode;
+    }
+
     private static int getNumOfUnit(String mode, int offset, int blockSize)
         throws NoSuchAlgorithmException {
         int result = blockSize; // use blockSize as default value
diff --git a/jdk/src/share/classes/com/sun/crypto/provider/GaloisCounterMode.java b/jdk/src/share/classes/com/sun/crypto/provider/GaloisCounterMode.java
index df98d93..e4edbf0 100644
--- a/jdk/src/share/classes/com/sun/crypto/provider/GaloisCounterMode.java
+++ b/jdk/src/share/classes/com/sun/crypto/provider/GaloisCounterMode.java
@@ -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
@@ -49,6 +49,16 @@
     static int DEFAULT_TAG_LEN = AES_BLOCK_SIZE;
     static int DEFAULT_IV_LEN = 12; // in bytes
 
+    // In NIST SP 800-38D, GCM input size is limited to be no longer
+    // than (2^36 - 32) bytes. Otherwise, the counter will wrap
+    // around and lead to a leak of plaintext.
+    // However, given the current GCM spec requirement that recovered
+    // text can only be returned after successful tag verification,
+    // we are bound by limiting the data size to the size limit of
+    // java byte array, e.g. Integer.MAX_VALUE, since all data
+    // can only be returned by the doFinal(...) call.
+    private static final int MAX_BUF_SIZE = Integer.MAX_VALUE;
+
     // buffer for AAD data; if null, meaning update has been called
     private ByteArrayOutputStream aadBuffer = new ByteArrayOutputStream();
     private int sizeOfAAD = 0;
@@ -89,9 +99,13 @@
         }
     }
 
-    // ivLen in bits
-    private static byte[] getLengthBlock(int ivLen) {
+    private static byte[] getLengthBlock(int ivLenInBytes) {
+        long ivLen = ((long)ivLenInBytes) << 3;
         byte[] out = new byte[AES_BLOCK_SIZE];
+        out[8] = (byte)(ivLen >>> 56);
+        out[9] = (byte)(ivLen >>> 48);
+        out[10] = (byte)(ivLen >>> 40);
+        out[11] = (byte)(ivLen >>> 32);
         out[12] = (byte)(ivLen >>> 24);
         out[13] = (byte)(ivLen >>> 16);
         out[14] = (byte)(ivLen >>> 8);
@@ -99,13 +113,22 @@
         return out;
     }
 
-    // aLen and cLen both in bits
-    private static byte[] getLengthBlock(int aLen, int cLen) {
+    private static byte[] getLengthBlock(int aLenInBytes, int cLenInBytes) {
+        long aLen = ((long)aLenInBytes) << 3;
+        long cLen = ((long)cLenInBytes) << 3;
         byte[] out = new byte[AES_BLOCK_SIZE];
+        out[0] = (byte)(aLen >>> 56);
+        out[1] = (byte)(aLen >>> 48);
+        out[2] = (byte)(aLen >>> 40);
+        out[3] = (byte)(aLen >>> 32);
         out[4] = (byte)(aLen >>> 24);
         out[5] = (byte)(aLen >>> 16);
         out[6] = (byte)(aLen >>> 8);
         out[7] = (byte)aLen;
+        out[8] = (byte)(cLen >>> 56);
+        out[9] = (byte)(cLen >>> 48);
+        out[10] = (byte)(cLen >>> 40);
+        out[11] = (byte)(cLen >>> 32);
         out[12] = (byte)(cLen >>> 24);
         out[13] = (byte)(cLen >>> 16);
         out[14] = (byte)(cLen >>> 8);
@@ -142,13 +165,20 @@
             } else {
                 g.update(iv);
             }
-            byte[] lengthBlock = getLengthBlock(iv.length*8);
+            byte[] lengthBlock = getLengthBlock(iv.length);
             g.update(lengthBlock);
             j0 = g.digest();
         }
         return j0;
     }
 
+    private static void checkDataLength(int processed, int len) {
+        if (processed > MAX_BUF_SIZE - len) {
+            throw new ProviderException("SunJCE provider only supports " +
+                "input size up to " + MAX_BUF_SIZE + " bytes");
+        }
+    }
+
     GaloisCounterMode(SymmetricCipher embeddedCipher) {
         super(embeddedCipher);
         aadBuffer = new ByteArrayOutputStream();
@@ -319,20 +349,22 @@
 
     // Feed the AAD data to GHASH, pad if necessary
     void processAAD() {
-        if (aadBuffer != null && aadBuffer.size() > 0) {
-            byte[] aad = aadBuffer.toByteArray();
-            sizeOfAAD = aad.length;
-            aadBuffer = null;
+        if (aadBuffer != null) {
+            if (aadBuffer.size() > 0) {
+                byte[] aad = aadBuffer.toByteArray();
+                sizeOfAAD = aad.length;
 
-            int lastLen = aad.length % AES_BLOCK_SIZE;
-            if (lastLen != 0) {
-                ghashAllToS.update(aad, 0, aad.length - lastLen);
-                byte[] padded = expandToOneBlock(aad, aad.length - lastLen,
-                                                 lastLen);
-                ghashAllToS.update(padded);
-            } else {
-                ghashAllToS.update(aad);
+                int lastLen = aad.length % AES_BLOCK_SIZE;
+                if (lastLen != 0) {
+                    ghashAllToS.update(aad, 0, aad.length - lastLen);
+                    byte[] padded = expandToOneBlock(aad, aad.length - lastLen,
+                                                     lastLen);
+                    ghashAllToS.update(padded);
+                } else {
+                    ghashAllToS.update(aad);
+                }
             }
+            aadBuffer = null;
         }
     }
 
@@ -386,6 +418,8 @@
      * @param outOfs the offset in <code>out</code>
      */
     int encrypt(byte[] in, int inOfs, int len, byte[] out, int outOfs) {
+        checkDataLength(processed, len);
+
         processAAD();
         if (len > 0) {
             gctrPAndC.update(in, inOfs, len, out, outOfs);
@@ -410,17 +444,23 @@
      */
     int encryptFinal(byte[] in, int inOfs, int len, byte[] out, int outOfs)
         throws IllegalBlockSizeException, ShortBufferException {
+        if (len > MAX_BUF_SIZE - tagLenBytes) {
+            throw new ShortBufferException
+                ("Can't fit both data and tag into one buffer");
+        }
         if (out.length - outOfs < (len + tagLenBytes)) {
             throw new ShortBufferException("Output buffer too small");
         }
 
+        checkDataLength(processed, len);
+
         processAAD();
         if (len > 0) {
             doLastBlock(in, inOfs, len, out, outOfs, true);
         }
 
         byte[] lengthBlock =
-            getLengthBlock(sizeOfAAD*8, processed*8);
+            getLengthBlock(sizeOfAAD, processed);
         ghashAllToS.update(lengthBlock);
         byte[] s = ghashAllToS.digest();
         byte[] sOut = new byte[s.length];
@@ -454,6 +494,8 @@
      * @param outOfs the offset in <code>out</code>
      */
     int decrypt(byte[] in, int inOfs, int len, byte[] out, int outOfs) {
+        checkDataLength(ibuffer.size(), len);
+
         processAAD();
 
         if (len > 0) {
@@ -488,10 +530,21 @@
         if (len < tagLenBytes) {
             throw new AEADBadTagException("Input too short - need tag");
         }
+        // do this check here can also catch the potential integer overflow
+        // scenario for the subsequent output buffer capacity check.
+        checkDataLength(ibuffer.size(), (len - tagLenBytes));
+
         if (out.length - outOfs < ((ibuffer.size() + len) - tagLenBytes)) {
             throw new ShortBufferException("Output buffer too small");
         }
+
         processAAD();
+
+        // get the trailing tag bytes from 'in'
+        byte[] tag = new byte[tagLenBytes];
+        System.arraycopy(in, inOfs + len - tagLenBytes, tag, 0, tagLenBytes);
+        len -= tagLenBytes;
+
         if (len != 0) {
             ibuffer.write(in, inOfs, len);
         }
@@ -502,17 +555,12 @@
         len = in.length;
         ibuffer.reset();
 
-        byte[] tag = new byte[tagLenBytes];
-        // get the trailing tag bytes from 'in'
-        System.arraycopy(in, len - tagLenBytes, tag, 0, tagLenBytes);
-        len -= tagLenBytes;
-
         if (len > 0) {
             doLastBlock(in, inOfs, len, out, outOfs, false);
         }
 
         byte[] lengthBlock =
-            getLengthBlock(sizeOfAAD*8, processed*8);
+            getLengthBlock(sizeOfAAD, processed);
         ghashAllToS.update(lengthBlock);
 
         byte[] s = ghashAllToS.digest();
diff --git a/jdk/src/share/classes/com/sun/jmx/remote/security/JMXSubjectDomainCombiner.java b/jdk/src/share/classes/com/sun/jmx/remote/security/JMXSubjectDomainCombiner.java
index 4961ac6..141a332 100644
--- a/jdk/src/share/classes/com/sun/jmx/remote/security/JMXSubjectDomainCombiner.java
+++ b/jdk/src/share/classes/com/sun/jmx/remote/security/JMXSubjectDomainCombiner.java
@@ -81,7 +81,7 @@
      * A ProtectionDomain with a null CodeSource and an empty permission set.
      */
     private static final ProtectionDomain pdNoPerms =
-        new ProtectionDomain(nullCodeSource, new Permissions());
+        new ProtectionDomain(nullCodeSource, new Permissions(), null, null);
 
     /**
      * Get the current AccessControlContext combined with the supplied subject.
diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/LdapCtx.java b/jdk/src/share/classes/com/sun/jndi/ldap/LdapCtx.java
index e5821ad..79630f5 100644
--- a/jdk/src/share/classes/com/sun/jndi/ldap/LdapCtx.java
+++ b/jdk/src/share/classes/com/sun/jndi/ldap/LdapCtx.java
@@ -2975,7 +2975,8 @@
             r = new LdapReferralException(resolvedName, resolvedObj, remainName,
                 msg, envprops, fullDN, handleReferrals, reqCtls);
             // only one set of URLs is present
-            r.setReferralInfo(res.referrals.elementAt(0), false);
+            r.setReferralInfo(res.referrals == null ? null :
+                    res.referrals.elementAt(0), false);
 
             if (hopCount > 1) {
                 r.setHopCount(hopCount);
@@ -3044,7 +3045,7 @@
              *     assume name resolution has not yet completed.
              */
             if (((res.entries == null) || (res.entries.isEmpty())) &&
-                (res.referrals.size() == 1)) {
+                ((res.referrals != null) && (res.referrals.size() == 1))) {
 
                 r.setReferralInfo(res.referrals, false);
 
diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/LdapReferralContext.java b/jdk/src/share/classes/com/sun/jndi/ldap/LdapReferralContext.java
index 0a09e0f..0b82340 100644
--- a/jdk/src/share/classes/com/sun/jndi/ldap/LdapReferralContext.java
+++ b/jdk/src/share/classes/com/sun/jndi/ldap/LdapReferralContext.java
@@ -92,7 +92,12 @@
             try {
                 referral = refEx.getNextReferral();
                 if (referral == null) {
-                    throw (NamingException)(previousEx.fillInStackTrace());
+                    if (previousEx != null) {
+                        throw (NamingException)(previousEx.fillInStackTrace());
+                    } else {
+                        throw new NamingException(
+                            "Illegal encoding: referral is empty");
+                    }
                 }
 
             } catch (LdapReferralException e) {
diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/LdapReferralException.java b/jdk/src/share/classes/com/sun/jndi/ldap/LdapReferralException.java
index 53783ad..1058d9d 100644
--- a/jdk/src/share/classes/com/sun/jndi/ldap/LdapReferralException.java
+++ b/jdk/src/share/classes/com/sun/jndi/ldap/LdapReferralException.java
@@ -217,13 +217,15 @@
             System.out.println("LdapReferralException.setReferralInfo");
 
         this.referrals = referrals;
-        if (referrals != null) {
-            referralCount = referrals.size();
-        }
+        referralCount = (referrals == null) ? 0 : referrals.size();
 
         if (debug) {
-            for (int i = 0; i < referralCount; i++) {
-                System.out.println("  [" + i + "] " + referrals.elementAt(i));
+            if (referrals != null) {
+                for (int i = 0; i < referralCount; i++) {
+                    System.out.println("  [" + i + "] " + referrals.elementAt(i));
+                }
+            } else {
+                System.out.println("setReferralInfo : referrals == null");
             }
         }
     }
diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java b/jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java
index 9b1ff67..8464e5a 100644
--- a/jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java
@@ -669,6 +669,40 @@
             actions.add(new PrivilegedAction<InputStream>() {
                 public InputStream run() {
                     if (System.getProperties().getProperty("os.name")
+                            .startsWith("Linux")) {
+
+                        File[] systemSoundFontsDir = new File[] {
+                            /* Arch, Fedora, Mageia */
+                            new File("/usr/share/soundfonts/"),
+                            new File("/usr/local/share/soundfonts/"),
+                            /* Debian, Gentoo, OpenSUSE, Ubuntu */
+                            new File("/usr/share/sounds/sf2/"),
+                            new File("/usr/local/share/sounds/sf2/"),
+                        };
+
+                        /*
+                         * Look for a default.sf2
+                         */
+                        for (File systemSoundFontDir : systemSoundFontsDir) {
+                            if (systemSoundFontDir.exists()) {
+                                File defaultSoundFont = new File(systemSoundFontDir, "default.sf2");
+                                if (defaultSoundFont.exists()) {
+                                    try {
+                                        return new FileInputStream(defaultSoundFont);
+                                    } catch (IOException e) {
+                                        // continue with lookup
+                                    }
+                                }
+                            }
+                        }
+                    }
+                    return null;
+                }
+            });
+
+            actions.add(new PrivilegedAction<InputStream>() {
+                public InputStream run() {
+                    if (System.getProperties().getProperty("os.name")
                             .startsWith("Windows")) {
                         File gm_dls = new File(System.getenv("SystemRoot")
                                 + "\\system32\\drivers\\gm.dls");
diff --git a/jdk/src/share/classes/com/sun/tools/hat/internal/parser/HprofReader.java b/jdk/src/share/classes/com/sun/tools/hat/internal/parser/HprofReader.java
index 33cdb3a..a5b20bd 100644
--- a/jdk/src/share/classes/com/sun/tools/hat/internal/parser/HprofReader.java
+++ b/jdk/src/share/classes/com/sun/tools/hat/internal/parser/HprofReader.java
@@ -354,7 +354,14 @@
     }
 
     private void skipBytes(long length) throws IOException {
-        in.skipBytes((int)length);
+        while (length > 0) {
+            long skipped = in.skip(length);
+            length -= skipped;
+            if (skipped == 0) {
+                // EOF or other problem, throw exception
+                throw new EOFException("Couldn't skip enough bytes");
+            }
+        }
     }
 
     private int readVersionHeader() throws IOException {
@@ -486,12 +493,12 @@
                     break;
                 }
                 case HPROF_GC_OBJ_ARRAY_DUMP: {
-                    int bytesRead = readArray(false);
+                    long bytesRead = readArray(false);
                     bytesLeft -= bytesRead;
                     break;
                 }
                 case HPROF_GC_PRIM_ARRAY_DUMP: {
-                    int bytesRead = readArray(true);
+                    long bytesRead = readArray(true);
                     bytesLeft -= bytesRead;
                     break;
                 }
@@ -743,12 +750,12 @@
     // Handle a HPROF_GC_OBJ_ARRAY_DUMP or HPROF_GC_PRIM_ARRAY_DUMP
     // Return number of bytes read
     //
-    private int readArray(boolean isPrimitive) throws IOException {
+    private long readArray(boolean isPrimitive) throws IOException {
         long start = in.position();
         long id = readID();
         StackTrace stackTrace = getStackTraceFromSerial(in.readInt());
         int num = in.readInt();
-        int bytesRead = identifierSize + 8;
+        long bytesRead = identifierSize + 8;
         long elementClassID;
         if (isPrimitive) {
             elementClassID = in.readByte();
@@ -810,14 +817,14 @@
             }
         }
         if (primitiveSignature != 0x00) {
-            int size = elSize * num;
+            long size = elSize * (long)num;
             bytesRead += size;
             JavaValueArray va = new JavaValueArray(primitiveSignature, start);
             skipBytes(size);
             snapshot.addHeapObject(id, va);
             snapshot.setSiteTrace(va, stackTrace);
         } else {
-            int sz = num * identifierSize;
+            long sz = (long)num * identifierSize;
             bytesRead += sz;
             JavaObjectArray arr = new JavaObjectArray(elementClassID, start);
             skipBytes(sz);
diff --git a/jdk/src/share/classes/com/sun/tools/jdi/ArrayTypeImpl.java b/jdk/src/share/classes/com/sun/tools/jdi/ArrayTypeImpl.java
index 0c83e4d..3449a45 100644
--- a/jdk/src/share/classes/com/sun/tools/jdi/ArrayTypeImpl.java
+++ b/jdk/src/share/classes/com/sun/tools/jdi/ArrayTypeImpl.java
@@ -200,4 +200,9 @@
      * Defined always to be true for arrays
      */
     public boolean isFinal() { return true; }
+
+    /*
+     * Defined always to be false for arrays
+     */
+    public boolean isStatic() { return false; }
 }
diff --git a/jdk/src/share/classes/java/lang/AbstractStringBuilder.java b/jdk/src/share/classes/java/lang/AbstractStringBuilder.java
index 3cde60d..4c31e23 100644
--- a/jdk/src/share/classes/java/lang/AbstractStringBuilder.java
+++ b/jdk/src/share/classes/java/lang/AbstractStringBuilder.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, 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
@@ -112,29 +112,56 @@
     }
 
     /**
-     * This method has the same contract as ensureCapacity, but is
-     * never synchronized.
+     * For positive values of {@code minimumCapacity}, this method
+     * behaves like {@code ensureCapacity}, however it is never
+     * synchronized.
+     * If {@code minimumCapacity} is non positive due to numeric
+     * overflow, this method throws {@code OutOfMemoryError}.
      */
     private void ensureCapacityInternal(int minimumCapacity) {
         // overflow-conscious code
-        if (minimumCapacity - value.length > 0)
-            expandCapacity(minimumCapacity);
+        if (minimumCapacity - value.length > 0) {
+            value = Arrays.copyOf(value,
+                    newCapacity(minimumCapacity));
+        }
     }
 
     /**
-     * This implements the expansion semantics of ensureCapacity with no
-     * size check or synchronization.
+     * The maximum size of array to allocate (unless necessary).
+     * Some VMs reserve some header words in an array.
+     * Attempts to allocate larger arrays may result in
+     * OutOfMemoryError: Requested array size exceeds VM limit
      */
-    void expandCapacity(int minimumCapacity) {
-        int newCapacity = value.length * 2 + 2;
-        if (newCapacity - minimumCapacity < 0)
-            newCapacity = minimumCapacity;
-        if (newCapacity < 0) {
-            if (minimumCapacity < 0) // overflow
-                throw new OutOfMemoryError();
-            newCapacity = Integer.MAX_VALUE;
+    private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
+
+    /**
+     * Returns a capacity at least as large as the given minimum capacity.
+     * Returns the current capacity increased by the same amount + 2 if
+     * that suffices.
+     * Will not return a capacity greater than {@code MAX_ARRAY_SIZE}
+     * unless the given minimum capacity is greater than that.
+     *
+     * @param  minCapacity the desired minimum capacity
+     * @throws OutOfMemoryError if minCapacity is less than zero or
+     *         greater than Integer.MAX_VALUE
+     */
+    private int newCapacity(int minCapacity) {
+        // overflow-conscious code
+        int newCapacity = (value.length << 1) + 2;
+        if (newCapacity - minCapacity < 0) {
+            newCapacity = minCapacity;
         }
-        value = Arrays.copyOf(value, newCapacity);
+        return (newCapacity <= 0 || MAX_ARRAY_SIZE - newCapacity < 0)
+            ? hugeCapacity(minCapacity)
+            : newCapacity;
+    }
+
+    private int hugeCapacity(int minCapacity) {
+        if (Integer.MAX_VALUE - minCapacity < 0) { // overflow
+            throw new OutOfMemoryError();
+        }
+        return (minCapacity > MAX_ARRAY_SIZE)
+            ? minCapacity : MAX_ARRAY_SIZE;
     }
 
     /**
diff --git a/jdk/src/share/classes/java/lang/StringBuffer.java b/jdk/src/share/classes/java/lang/StringBuffer.java
index 9bc8f3b..1638f30 100644
--- a/jdk/src/share/classes/java/lang/StringBuffer.java
+++ b/jdk/src/share/classes/java/lang/StringBuffer.java
@@ -171,9 +171,7 @@
 
     @Override
     public synchronized void ensureCapacity(int minimumCapacity) {
-        if (minimumCapacity > value.length) {
-            expandCapacity(minimumCapacity);
-        }
+        super.ensureCapacity(minimumCapacity);
     }
 
     /**
diff --git a/jdk/src/share/classes/java/lang/Thread.java b/jdk/src/share/classes/java/lang/Thread.java
index 274801c..7c8e83e 100644
--- a/jdk/src/share/classes/java/lang/Thread.java
+++ b/jdk/src/share/classes/java/lang/Thread.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 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
@@ -145,7 +145,7 @@
         registerNatives();
     }
 
-    private volatile char  name[];
+    private volatile String name;
     private int            priority;
     private Thread         threadQ;
     private long           eetop;
@@ -366,7 +366,7 @@
             throw new NullPointerException("name cannot be null");
         }
 
-        this.name = name.toCharArray();
+        this.name = name;
 
         Thread parent = currentThread();
         SecurityManager security = System.getSecurityManager();
@@ -1119,7 +1119,11 @@
      */
     public final synchronized void setName(String name) {
         checkAccess();
-        this.name = name.toCharArray();
+        if (name == null) {
+            throw new NullPointerException("name cannot be null");
+        }
+
+        this.name = name;
         if (threadStatus != 0) {
             setNativeName(name);
         }
@@ -1132,7 +1136,7 @@
      * @see     #setName(String)
      */
     public final String getName() {
-        return new String(name, true);
+        return name;
     }
 
     /**
diff --git a/jdk/src/share/classes/java/lang/invoke/DirectMethodHandle.java b/jdk/src/share/classes/java/lang/invoke/DirectMethodHandle.java
index cabd071..df3c2be 100644
--- a/jdk/src/share/classes/java/lang/invoke/DirectMethodHandle.java
+++ b/jdk/src/share/classes/java/lang/invoke/DirectMethodHandle.java
@@ -158,7 +158,7 @@
     private static LambdaForm preparedLambdaForm(MemberName m) {
         assert(m.isInvocable()) : m;  // call preparedFieldLambdaForm instead
         MethodType mtype = m.getInvocationType().basicType();
-        assert(!m.isMethodHandleInvoke() || "invokeBasic".equals(m.getName())) : m;
+        assert(!m.isMethodHandleInvoke()) : m;
         int which;
         switch (m.getReferenceKind()) {
         case REF_invokeVirtual:    which = LF_INVVIRTUAL;    break;
diff --git a/jdk/src/share/classes/java/lang/invoke/LambdaForm.java b/jdk/src/share/classes/java/lang/invoke/LambdaForm.java
index 09a742f..9420d3b 100644
--- a/jdk/src/share/classes/java/lang/invoke/LambdaForm.java
+++ b/jdk/src/share/classes/java/lang/invoke/LambdaForm.java
@@ -1034,7 +1034,7 @@
             this.member = member;
             this.resolvedHandle = resolvedHandle;
              // The following assert is almost always correct, but will fail for corner cases, such as PrivateInvokeTest.
-             //assert(!isInvokeBasic());
+             //assert(!isInvokeBasic(member));
         }
         NamedFunction(MethodType basicInvokerType) {
             assert(basicInvokerType == basicInvokerType.basicType()) : basicInvokerType;
@@ -1045,13 +1045,13 @@
                 // necessary to pass BigArityTest
                 this.member = Invokers.invokeBasicMethod(basicInvokerType);
             }
-            assert(isInvokeBasic());
+            assert(isInvokeBasic(member));
         }
 
-        private boolean isInvokeBasic() {
+        private static boolean isInvokeBasic(MemberName member) {
             return member != null &&
-                   member.isMethodHandleInvoke() &&
-                   "invokeBasic".equals(member.getName());
+                   member.getDeclaringClass() == MethodHandle.class &&
+                  "invokeBasic".equals(member.getName());
         }
 
         // The next 3 constructors are used to break circular dependencies on MH.invokeStatic, etc.
@@ -1191,7 +1191,7 @@
             assert(mh.type().basicType() == MethodType.genericMethodType(arity).changeReturnType(rtype))
                     : Arrays.asList(mh, rtype, arity);
             MemberName member = mh.internalMemberName();
-            if (member != null && member.getName().equals("invokeBasic") && member.isMethodHandleInvoke()) {
+            if (isInvokeBasic(member)) {
                 assert(arity > 0);
                 assert(a[0] instanceof MethodHandle);
                 MethodHandle mh2 = (MethodHandle) a[0];
diff --git a/jdk/src/share/classes/java/lang/invoke/MemberName.java b/jdk/src/share/classes/java/lang/invoke/MemberName.java
index bcc08e7..b2fc757 100644
--- a/jdk/src/share/classes/java/lang/invoke/MemberName.java
+++ b/jdk/src/share/classes/java/lang/invoke/MemberName.java
@@ -341,7 +341,6 @@
     }
 
     /** Utility method to query if this member is a method handle invocation (invoke or invokeExact).
-     *  Also returns true for the non-public MH.invokeBasic.
      */
     public boolean isMethodHandleInvoke() {
         final int bits = MH_INVOKE_MODS &~ Modifier.PUBLIC;
@@ -356,7 +355,6 @@
         switch (name) {
         case "invoke":
         case "invokeExact":
-        case "invokeBasic":  // internal sig-poly method
             return true;
         default:
             return false;
diff --git a/jdk/src/share/classes/java/lang/invoke/MethodHandles.java b/jdk/src/share/classes/java/lang/invoke/MethodHandles.java
index 8511890..dfd8628 100644
--- a/jdk/src/share/classes/java/lang/invoke/MethodHandles.java
+++ b/jdk/src/share/classes/java/lang/invoke/MethodHandles.java
@@ -28,6 +28,7 @@
 import java.lang.reflect.*;
 import java.util.BitSet;
 import java.util.List;
+import java.util.ArrayList;
 import java.util.Arrays;
 
 import sun.invoke.util.ValueConversions;
@@ -864,8 +865,6 @@
                 return invoker(type);
             if ("invokeExact".equals(name))
                 return exactInvoker(type);
-            if ("invokeBasic".equals(name))
-                return basicInvoker(type);
             assert(!MemberName.isMethodHandleInvokeName(name));
             return null;
         }
@@ -2447,6 +2446,7 @@
      */
     public static
     MethodHandle dropArguments(MethodHandle target, int pos, List<Class<?>> valueTypes) {
+        valueTypes = copyTypes(valueTypes);
         MethodType oldType = target.type();  // get NPE
         int dropped = dropArgumentChecks(oldType, pos, valueTypes);
         MethodType newType = oldType.insertParameterTypes(pos, valueTypes);
@@ -2461,6 +2461,11 @@
         return result;
     }
 
+    private static List<Class<?>> copyTypes(List<Class<?>> types) {
+        Object[] a = types.toArray();
+        return Arrays.asList(Arrays.copyOf(a, a.length, Class[].class));
+    }
+
     private static int dropArgumentChecks(MethodType oldType, int pos, List<Class<?>> valueTypes) {
         int dropped = valueTypes.size();
         MethodType.checkSlotCount(dropped);
@@ -2842,7 +2847,7 @@
         int filterValues = filterType.parameterCount();
         if (filterValues == 0
                 ? (rtype != void.class)
-                : (rtype != filterType.parameterType(0)))
+                : (rtype != filterType.parameterType(0) || filterValues != 1))
             throw newIllegalArgumentException("target and filter types do not match", targetType, filterType);
     }
 
diff --git a/jdk/src/share/classes/java/net/URLConnection.java b/jdk/src/share/classes/java/net/URLConnection.java
index dd66ed2..7f7f43d 100644
--- a/jdk/src/share/classes/java/net/URLConnection.java
+++ b/jdk/src/share/classes/java/net/URLConnection.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -1515,7 +1515,7 @@
         }
 
         if (c1 == 0xFF && c2 == 0xD8 && c3 == 0xFF) {
-            if (c4 == 0xE0) {
+            if (c4 == 0xE0 || c4 == 0xEE) {
                 return "image/jpeg";
             }
 
@@ -1530,10 +1530,6 @@
                  c11 == 0)) {
                 return "image/jpeg";
             }
-
-            if (c4 == 0xEE) {
-                return "image/jpg";
-            }
         }
 
         if (c1 == 0xD0 && c2 == 0xCF && c3 == 0x11 && c4 == 0xE0 &&
diff --git a/jdk/src/share/classes/java/net/URLPermission.java b/jdk/src/share/classes/java/net/URLPermission.java
index 78373e1..e188c81 100644
--- a/jdk/src/share/classes/java/net/URLPermission.java
+++ b/jdk/src/share/classes/java/net/URLPermission.java
@@ -170,7 +170,8 @@
         parseURI(getName());
         int colon = actions.indexOf(':');
         if (actions.lastIndexOf(':') != colon) {
-            throw new IllegalArgumentException("invalid actions string");
+            throw new IllegalArgumentException(
+                "Invalid actions string: \"" + actions + "\"");
         }
 
         String methods, headers;
@@ -371,7 +372,8 @@
                     l.add(s);
                 b = new StringBuilder();
             } else if (c == ' ' || c == '\t') {
-                throw new IllegalArgumentException("white space not allowed");
+                throw new IllegalArgumentException(
+                    "White space not allowed in methods: \"" + methods + "\"");
             } else {
                 if (c >= 'a' && c <= 'z') {
                     c += 'A' - 'a';
@@ -398,7 +400,8 @@
                 }
                 b.append(c);
             } else if (c == ' ' || c == '\t') {
-                throw new IllegalArgumentException("white space not allowed");
+                throw new IllegalArgumentException(
+                    "White space not allowed in headers: \"" + headers + "\"");
             } else if (c == '-') {
                     capitalizeNext = true;
                 b.append(c);
@@ -423,14 +426,16 @@
         int len = url.length();
         int delim = url.indexOf(':');
         if (delim == -1 || delim + 1 == len) {
-            throw new IllegalArgumentException("invalid URL string");
+            throw new IllegalArgumentException(
+                "Invalid URL string: \"" + url + "\"");
         }
         scheme = url.substring(0, delim).toLowerCase();
         this.ssp = url.substring(delim + 1);
 
         if (!ssp.startsWith("//")) {
             if (!ssp.equals("*")) {
-                throw new IllegalArgumentException("invalid URL string");
+                throw new IllegalArgumentException(
+                    "Invalid URL string: \"" + url + "\"");
             }
             this.authority = new Authority(scheme, "*");
             return;
diff --git a/jdk/src/share/classes/java/security/ProtectionDomain.java b/jdk/src/share/classes/java/security/ProtectionDomain.java
index b177849..ffd2def 100644
--- a/jdk/src/share/classes/java/security/ProtectionDomain.java
+++ b/jdk/src/share/classes/java/security/ProtectionDomain.java
@@ -475,6 +475,11 @@
                         }
                     };
                 }
+
+                @Override
+                public boolean getStaticPermissionsField(ProtectionDomain pd) {
+                    return pd.staticPermissions;
+                }
             });
     }
 }
diff --git a/jdk/src/share/classes/java/text/DateFormatSymbols.java b/jdk/src/share/classes/java/text/DateFormatSymbols.java
index c1f951d..4fcde4e 100644
--- a/jdk/src/share/classes/java/text/DateFormatSymbols.java
+++ b/jdk/src/share/classes/java/text/DateFormatSymbols.java
@@ -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
@@ -47,7 +47,6 @@
 import java.util.Locale;
 import java.util.Objects;
 import java.util.ResourceBundle;
-import java.util.TimeZone;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import sun.util.locale.provider.LocaleProviderAdapter;
@@ -147,6 +146,12 @@
     }
 
     /**
+     * Constructs an uninitialized DateFormatSymbols.
+     */
+    private DateFormatSymbols(boolean flag) {
+    }
+
+    /**
      * Era strings. For example: "AD" and "BC".  An array of 2 strings,
      * indexed by <code>Calendar.BC</code> and <code>Calendar.AD</code>.
      * @serial
@@ -677,54 +682,80 @@
      */
     transient volatile int cachedHashCode = 0;
 
-    private void initializeData(Locale desiredLocale) {
-        locale = desiredLocale;
-
-        // Copy values of a cached instance if any.
+    /**
+     * Initializes this DateFormatSymbols with the locale data. This method uses
+     * a cached DateFormatSymbols instance for the given locale if available. If
+     * there's no cached one, this method creates an uninitialized instance and
+     * populates its fields from the resource bundle for the locale, and caches
+     * the instance. Note: zoneStrings isn't initialized in this method.
+     */
+    private void initializeData(Locale locale) {
         SoftReference<DateFormatSymbols> ref = cachedInstances.get(locale);
         DateFormatSymbols dfs;
-        if (ref != null && (dfs = ref.get()) != null) {
-            copyMembers(dfs, this);
-            return;
-        }
+        if (ref == null || (dfs = ref.get()) == null) {
+            if (ref != null) {
+                // Remove the empty SoftReference
+                cachedInstances.remove(locale, ref);
+            }
+            dfs = new DateFormatSymbols(false);
 
-        // Initialize the fields from the ResourceBundle for locale.
-        LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatSymbolsProvider.class, locale);
-        // Avoid any potential recursions
-        if (!(adapter instanceof ResourceBundleBasedAdapter)) {
-            adapter = LocaleProviderAdapter.getResourceBundleBased();
-        }
-        ResourceBundle resource = ((ResourceBundleBasedAdapter)adapter).getLocaleData().getDateFormatData(locale);
+            // Initialize the fields from the ResourceBundle for locale.
+            LocaleProviderAdapter adapter
+                = LocaleProviderAdapter.getAdapter(DateFormatSymbolsProvider.class, locale);
+            // Avoid any potential recursions
+            if (!(adapter instanceof ResourceBundleBasedAdapter)) {
+                adapter = LocaleProviderAdapter.getResourceBundleBased();
+            }
+            ResourceBundle resource
+                = ((ResourceBundleBasedAdapter)adapter).getLocaleData().getDateFormatData(locale);
 
-        // JRE and CLDR use different keys
-        // JRE: Eras, short.Eras and narrow.Eras
-        // CLDR: long.Eras, Eras and narrow.Eras
-        if (resource.containsKey("Eras")) {
-            eras = resource.getStringArray("Eras");
-        } else if (resource.containsKey("long.Eras")) {
-            eras = resource.getStringArray("long.Eras");
-        } else if (resource.containsKey("short.Eras")) {
-            eras = resource.getStringArray("short.Eras");
-        }
-        months = resource.getStringArray("MonthNames");
-        shortMonths = resource.getStringArray("MonthAbbreviations");
-        ampms = resource.getStringArray("AmPmMarkers");
-        localPatternChars = resource.getString("DateTimePatternChars");
+            dfs.locale = locale;
+            // JRE and CLDR use different keys
+            // JRE: Eras, short.Eras and narrow.Eras
+            // CLDR: long.Eras, Eras and narrow.Eras
+            if (resource.containsKey("Eras")) {
+                dfs.eras = resource.getStringArray("Eras");
+            } else if (resource.containsKey("long.Eras")) {
+                dfs.eras = resource.getStringArray("long.Eras");
+            } else if (resource.containsKey("short.Eras")) {
+                dfs.eras = resource.getStringArray("short.Eras");
+            }
+            dfs.months = resource.getStringArray("MonthNames");
+            dfs.shortMonths = resource.getStringArray("MonthAbbreviations");
+            dfs.ampms = resource.getStringArray("AmPmMarkers");
+            dfs.localPatternChars = resource.getString("DateTimePatternChars");
 
-        // Day of week names are stored in a 1-based array.
-        weekdays = toOneBasedArray(resource.getStringArray("DayNames"));
-        shortWeekdays = toOneBasedArray(resource.getStringArray("DayAbbreviations"));
+            // Day of week names are stored in a 1-based array.
+            dfs.weekdays = toOneBasedArray(resource.getStringArray("DayNames"));
+            dfs.shortWeekdays = toOneBasedArray(resource.getStringArray("DayAbbreviations"));
 
-        // Put a clone in the cache
-        ref = new SoftReference<>((DateFormatSymbols)this.clone());
-        SoftReference<DateFormatSymbols> x = cachedInstances.putIfAbsent(locale, ref);
-        if (x != null) {
-            DateFormatSymbols y = x.get();
-            if (y == null) {
-                // Replace the empty SoftReference with ref.
-                cachedInstances.put(locale, ref);
+            // Put dfs in the cache
+            ref = new SoftReference<>(dfs);
+            SoftReference<DateFormatSymbols> x = cachedInstances.putIfAbsent(locale, ref);
+            if (x != null) {
+                DateFormatSymbols y = x.get();
+                if (y == null) {
+                    // Replace the empty SoftReference with ref.
+                    cachedInstances.replace(locale, x, ref);
+                } else {
+                    ref = x;
+                    dfs = y;
+                }
+            }
+            // If the bundle's locale isn't the target locale, put another cache
+            // entry for the bundle's locale.
+            Locale bundleLocale = resource.getLocale();
+            if (!bundleLocale.equals(locale)) {
+                SoftReference<DateFormatSymbols> z
+                    = cachedInstances.putIfAbsent(bundleLocale, ref);
+                if (z != null && z.get() == null) {
+                    cachedInstances.replace(bundleLocale, z, ref);
+                }
             }
         }
+
+        // Copy the field values from dfs to this instance.
+        copyMembers(dfs, this);
     }
 
     private static String[] toOneBasedArray(String[] src) {
@@ -806,12 +837,14 @@
 
     /**
      * Clones all the data members from the source DateFormatSymbols to
-     * the target DateFormatSymbols. This is only for subclasses.
+     * the target DateFormatSymbols.
+     *
      * @param src the source DateFormatSymbols.
      * @param dst the target DateFormatSymbols.
      */
     private void copyMembers(DateFormatSymbols src, DateFormatSymbols dst)
     {
+        dst.locale = src.locale;
         dst.eras = Arrays.copyOf(src.eras, src.eras.length);
         dst.months = Arrays.copyOf(src.months, src.months.length);
         dst.shortMonths = Arrays.copyOf(src.shortMonths, src.shortMonths.length);
diff --git a/jdk/src/share/classes/java/util/Hashtable.java b/jdk/src/share/classes/java/util/Hashtable.java
index 6ee87cb..c7e9251 100644
--- a/jdk/src/share/classes/java/util/Hashtable.java
+++ b/jdk/src/share/classes/java/util/Hashtable.java
@@ -1132,10 +1132,10 @@
         Entry<Object, Object> entryStack = null;
 
         synchronized (this) {
-            // Write out the length, threshold, loadfactor
+            // Write out the threshold and loadFactor
             s.defaultWriteObject();
 
-            // Write out length, count of elements
+            // Write out the length and count of elements
             s.writeInt(table.length);
             s.writeInt(count);
 
@@ -1165,22 +1165,33 @@
     private void readObject(java.io.ObjectInputStream s)
          throws IOException, ClassNotFoundException
     {
-        // Read in the length, threshold, and loadfactor
+        // Read in the threshold and loadFactor
         s.defaultReadObject();
 
+        // Validate loadFactor (ignore threshold - it will be re-computed)
+        if (loadFactor <= 0 || Float.isNaN(loadFactor))
+            throw new StreamCorruptedException("Illegal Load: " + loadFactor);
+
         // Read the original length of the array and number of elements
         int origlength = s.readInt();
         int elements = s.readInt();
 
-        // Compute new size with a bit of room 5% to grow but
-        // no larger than the original size.  Make the length
+        // Validate # of elements
+        if (elements < 0)
+            throw new StreamCorruptedException("Illegal # of Elements: " + elements);
+
+        // Clamp original length to be more than elements / loadFactor
+        // (this is the invariant enforced with auto-growth)
+        origlength = Math.max(origlength, (int)(elements / loadFactor) + 1);
+
+        // Compute new length with a bit of room 5% + 3 to grow but
+        // no larger than the clamped original length.  Make the length
         // odd if it's large enough, this helps distribute the entries.
         // Guard against the length ending up zero, that's not valid.
-        int length = (int)(elements * loadFactor) + (elements / 20) + 3;
+        int length = (int)((elements + elements / 20) / loadFactor) + 3;
         if (length > elements && (length & 1) == 0)
             length--;
-        if (origlength > 0 && length > origlength)
-            length = origlength;
+        length = Math.min(length, origlength);
         table = new Entry<?,?>[length];
         threshold = (int)Math.min(length * loadFactor, MAX_ARRAY_SIZE + 1);
         count = 0;
@@ -1191,7 +1202,7 @@
                 K key = (K)s.readObject();
             @SuppressWarnings("unchecked")
                 V value = (V)s.readObject();
-            // synch could be eliminated for performance
+            // sync is eliminated for performance
             reconstitutionPut(table, key, value);
         }
     }
@@ -1203,9 +1214,9 @@
      *
      * <p>This differs from the regular put method in several ways. No
      * checking for rehashing is necessary since the number of elements
-     * initially in the table is known. The modCount is not incremented
-     * because we are creating a new instance. Also, no return value
-     * is needed.
+     * initially in the table is known. The modCount is not incremented and
+     * there's no synchronization because we are creating a new instance.
+     * Also, no return value is needed.
      */
     private void reconstitutionPut(Entry<?,?>[] tab, K key, V value)
         throws StreamCorruptedException
diff --git a/jdk/src/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java b/jdk/src/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java
index 62512ac..15c4c9c 100644
--- a/jdk/src/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java
+++ b/jdk/src/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java
@@ -485,19 +485,25 @@
      * @return {@code true} if this queue changed as a result of the call
      */
     public boolean remove(Object o) {
-        if (o == null) return false;
-        Node<E> pred = null;
-        for (Node<E> p = first(); p != null; p = succ(p)) {
-            E item = p.item;
-            if (item != null &&
-                o.equals(item) &&
-                p.casItem(item, null)) {
-                Node<E> next = succ(p);
-                if (pred != null && next != null)
+        if (o != null) {
+            Node<E> next, pred = null;
+            for (Node<E> p = first(); p != null; pred = p, p = next) {
+                boolean removed = false;
+                E item = p.item;
+                if (item != null) {
+                    if (!o.equals(item)) {
+                        next = succ(p);
+                        continue;
+                    }
+                    removed = p.casItem(item, null);
+                }
+
+                next = succ(p);
+                if (pred != null && next != null) // unlink
                     pred.casNext(p, next);
-                return true;
+                if (removed)
+                    return true;
             }
-            pred = p;
         }
         return false;
     }
diff --git a/jdk/src/share/classes/java/util/logging/Logger.java b/jdk/src/share/classes/java/util/logging/Logger.java
index 4629320..61bbe4e 100644
--- a/jdk/src/share/classes/java/util/logging/Logger.java
+++ b/jdk/src/share/classes/java/util/logging/Logger.java
@@ -800,6 +800,7 @@
      * @param   level   One of the message level identifiers, e.g., SEVERE
      * @param   msgSupplier   A function, which when called, produces the
      *                        desired log message
+     * @since 1.8
      */
     public void log(Level level, Supplier<String> msgSupplier) {
         if (!isLoggable(level)) {
diff --git a/jdk/src/share/classes/javax/crypto/JceSecurity.java b/jdk/src/share/classes/javax/crypto/JceSecurity.java
index fb7052d..29823e7 100644
--- a/jdk/src/share/classes/javax/crypto/JceSecurity.java
+++ b/jdk/src/share/classes/javax/crypto/JceSecurity.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, 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
@@ -64,8 +64,7 @@
     private final static Map<Provider, Object> verifyingProviders =
             new IdentityHashMap<>();
 
-    // Set the default value. May be changed in the static initializer.
-    private static boolean isRestricted = true;
+    private static final boolean isRestricted;
 
     /*
      * Don't let anyone instantiate this.
diff --git a/jdk/src/share/classes/javax/security/auth/SubjectDomainCombiner.java b/jdk/src/share/classes/javax/security/auth/SubjectDomainCombiner.java
index da75d68..89812d2 100644
--- a/jdk/src/share/classes/javax/security/auth/SubjectDomainCombiner.java
+++ b/jdk/src/share/classes/javax/security/auth/SubjectDomainCombiner.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, 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
@@ -37,6 +37,8 @@
 import java.util.Set;
 import java.util.WeakHashMap;
 import java.lang.ref.WeakReference;
+import sun.misc.SharedSecrets;
+import sun.misc.JavaSecurityProtectionDomainAccess;
 
 /**
  * A {@code SubjectDomainCombiner} updates ProtectionDomains
@@ -65,6 +67,9 @@
     private static final boolean allowCaching =
                                         (useJavaxPolicy && cachePolicy());
 
+    private static final JavaSecurityProtectionDomainAccess pdAccess =
+        SharedSecrets.getJavaSecurityProtectionDomainAccess();
+
     /**
      * Associate the provided {@code Subject} with this
      * {@code SubjectDomainCombiner}.
@@ -239,10 +244,16 @@
                 subjectPd = cachedPDs.getValue(pd);
 
                 if (subjectPd == null) {
-                    subjectPd = new ProtectionDomain(pd.getCodeSource(),
+                    if (pdAccess.getStaticPermissionsField(pd)) {
+                        // Need to keep static ProtectionDomain objects static
+                        subjectPd = new ProtectionDomain(pd.getCodeSource(),
+                                                pd.getPermissions());
+                    } else {
+                        subjectPd = new ProtectionDomain(pd.getCodeSource(),
                                                 pd.getPermissions(),
                                                 pd.getClassLoader(),
                                                 principals);
+                    }
                     cachedPDs.putValue(pd, subjectPd);
                 } else {
                     allNew = false;
@@ -341,60 +352,63 @@
                 ProtectionDomain subjectPd = cachedPDs.getValue(pd);
 
                 if (subjectPd == null) {
+                    if (pdAccess.getStaticPermissionsField(pd)) {
+                        // keep static ProtectionDomain objects static
+                        subjectPd = new ProtectionDomain(pd.getCodeSource(),
+                                                pd.getPermissions());
+                    } else {
+                        // XXX
+                        // we must first add the original permissions.
+                        // that way when we later add the new JAAS permissions,
+                        // any unresolved JAAS-related permissions will
+                        // automatically get resolved.
 
-                    // XXX
-                    // we must first add the original permissions.
-                    // that way when we later add the new JAAS permissions,
-                    // any unresolved JAAS-related permissions will
-                    // automatically get resolved.
-
-                    // get the original perms
-                    Permissions perms = new Permissions();
-                    PermissionCollection coll = pd.getPermissions();
-                    java.util.Enumeration<Permission> e;
-                    if (coll != null) {
-                        synchronized (coll) {
-                            e = coll.elements();
-                            while (e.hasMoreElements()) {
-                                Permission newPerm =
+                        // get the original perms
+                        Permissions perms = new Permissions();
+                        PermissionCollection coll = pd.getPermissions();
+                        java.util.Enumeration<Permission> e;
+                        if (coll != null) {
+                            synchronized (coll) {
+                                e = coll.elements();
+                                while (e.hasMoreElements()) {
+                                    Permission newPerm =
                                         e.nextElement();
-                                 perms.add(newPerm);
+                                    perms.add(newPerm);
+                                }
                             }
                         }
-                    }
 
-                    // get perms from the policy
+                        // get perms from the policy
+                        final java.security.CodeSource finalCs = pd.getCodeSource();
+                        final Subject finalS = subject;
+                        PermissionCollection newPerms =
+                            java.security.AccessController.doPrivileged
+                            (new PrivilegedAction<PermissionCollection>() {
+                            @SuppressWarnings("deprecation")
+                            public PermissionCollection run() {
+                                return
+                                    javax.security.auth.Policy.getPolicy().getPermissions
+                                    (finalS, finalCs);
+                            }
+                        });
 
-                    final java.security.CodeSource finalCs = pd.getCodeSource();
-                    final Subject finalS = subject;
-                    PermissionCollection newPerms =
-                        java.security.AccessController.doPrivileged
-                        (new PrivilegedAction<PermissionCollection>() {
-                        @SuppressWarnings("deprecation")
-                        public PermissionCollection run() {
-                          return
-                          javax.security.auth.Policy.getPolicy().getPermissions
-                                (finalS, finalCs);
-                        }
-                    });
-
-                    // add the newly granted perms,
-                    // avoiding duplicates
-                    synchronized (newPerms) {
-                        e = newPerms.elements();
-                        while (e.hasMoreElements()) {
-                            Permission newPerm = e.nextElement();
-                            if (!perms.implies(newPerm)) {
-                                perms.add(newPerm);
-                                if (debug != null)
-                                    debug.println (
-                                        "Adding perm " + newPerm + "\n");
+                        // add the newly granted perms,
+                        // avoiding duplicates
+                        synchronized (newPerms) {
+                            e = newPerms.elements();
+                            while (e.hasMoreElements()) {
+                                Permission newPerm = e.nextElement();
+                                if (!perms.implies(newPerm)) {
+                                    perms.add(newPerm);
+                                    if (debug != null)
+                                        debug.println (
+                                            "Adding perm " + newPerm + "\n");
+                                }
                             }
                         }
+                        subjectPd = new ProtectionDomain
+                            (finalCs, perms, pd.getClassLoader(), principals);
                     }
-                    subjectPd = new ProtectionDomain
-                        (finalCs, perms, pd.getClassLoader(), principals);
-
                     if (allowCaching)
                         cachedPDs.putValue(pd, subjectPd);
                 }
diff --git a/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMURIDereferencer.java b/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMURIDereferencer.java
index bf4e28b..209de66 100644
--- a/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMURIDereferencer.java
+++ b/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMURIDereferencer.java
@@ -21,7 +21,7 @@
  * under the License.
  */
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * $Id: DOMURIDereferencer.java 1231033 2012-01-13 12:12:12Z coheigea $
@@ -111,7 +111,8 @@
         try {
             ResourceResolver apacheResolver =
                 ResourceResolver.getInstance(uriAttr, baseURI, secVal);
-            XMLSignatureInput in = apacheResolver.resolve(uriAttr, baseURI);
+            XMLSignatureInput in = apacheResolver.resolve(uriAttr,
+                                                          baseURI, secVal);
             if (in.isOctetStream()) {
                 return new ApacheOctetStreamData(in);
             } else {
diff --git a/jdk/src/share/classes/sun/awt/datatransfer/DataTransferer.java b/jdk/src/share/classes/sun/awt/datatransfer/DataTransferer.java
index 79c2792..a5bd0f5 100644
--- a/jdk/src/share/classes/sun/awt/datatransfer/DataTransferer.java
+++ b/jdk/src/share/classes/sun/awt/datatransfer/DataTransferer.java
@@ -2898,13 +2898,7 @@
                     return comp;
                 }
             } else {
-                // First, prefer application types.
-                comp = compareIndices(primaryTypes, primaryType1, primaryType2,
-                                      UNKNOWN_OBJECT_LOSES);
-                if (comp != 0) {
-                    return comp;
-                }
-
+                // First, prefer text types
                 if (flavor1.isFlavorTextType()) {
                     return 1;
                 }
@@ -2913,6 +2907,13 @@
                     return -1;
                 }
 
+                // Next, prefer application types.
+                comp = compareIndices(primaryTypes, primaryType1, primaryType2,
+                        UNKNOWN_OBJECT_LOSES);
+                if (comp != 0) {
+                    return comp;
+                }
+
                 // Next, look for application/x-java-* types. Prefer unknown
                 // MIME types because if the user provides his own data flavor,
                 // it will likely be the most descriptive one.
diff --git a/jdk/src/share/classes/sun/invoke/anon/AnonymousClassLoader.java b/jdk/src/share/classes/sun/invoke/anon/AnonymousClassLoader.java
deleted file mode 100644
index 32624b4..0000000
--- a/jdk/src/share/classes/sun/invoke/anon/AnonymousClassLoader.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.invoke.anon;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import sun.misc.IOUtils;
-
-/**
- * Anonymous class loader.  Will load any valid classfile, producing
- * a {@link Class} metaobject, without installing that class in the
- * system dictionary.  Therefore, {@link Class#forName(String)} will never
- * produce a reference to an anonymous class.
- * <p>
- * The access permissions of the anonymous class are borrowed from
- * a <em>host class</em>.  The new class behaves as if it were an
- * inner class of the host class.  It can access the host's private
- * members, if the creator of the class loader has permission to
- * do so (or to create accessible reflective objects).
- * <p>
- * When the anonymous class is loaded, elements of its constant pool
- * can be patched to new values.  This provides a hook to pre-resolve
- * named classes in the constant pool to other classes, including
- * anonymous ones.  Also, string constants can be pre-resolved to
- * any reference.  (The verifier treats non-string, non-class reference
- * constants as plain objects.)
- *  <p>
- * Why include the patching function?  It makes some use cases much easier.
- * Second, the constant pool needed some internal patching anyway,
- * to anonymize the loaded class itself.  Finally, if you are going
- * to use this seriously, you'll want to build anonymous classes
- * on top of pre-existing anonymous classes, and that requires patching.
- *
- * <p>%%% TO-DO:
- * <ul>
- * <li>needs better documentation</li>
- * <li>needs more security work (for safe delegation)</li>
- * <li>needs a clearer story about error processing</li>
- * <li>patch member references also (use ';' as delimiter char)</li>
- * <li>patch method references to (conforming) method handles</li>
- * </ul>
- *
- * @author jrose
- * @author Remi Forax
- * @see <a href="http://blogs.sun.com/jrose/entry/anonymous_classes_in_the_vm">
- *      http://blogs.sun.com/jrose/entry/anonymous_classes_in_the_vm</a>
- */
-
-public class AnonymousClassLoader {
-    final Class<?> hostClass;
-
-    // Privileged constructor.
-    private AnonymousClassLoader(Class<?> hostClass) {
-        this.hostClass = hostClass;
-    }
-
-    public static AnonymousClassLoader make(sun.misc.Unsafe unsafe, Class<?> hostClass) {
-        if (unsafe == null)  throw new NullPointerException();
-        return new AnonymousClassLoader(hostClass);
-    }
-
-    public Class<?> loadClass(byte[] classFile) {
-        if (defineAnonymousClass == null) {
-            // no JVM support; try to fake an approximation
-            try {
-                return fakeLoadClass(new ConstantPoolParser(classFile).createPatch());
-            } catch (InvalidConstantPoolFormatException ee) {
-                throw new IllegalArgumentException(ee);
-            }
-        }
-        return loadClass(classFile, null);
-    }
-
-    public Class<?> loadClass(ConstantPoolPatch classPatch) {
-        if (defineAnonymousClass == null) {
-            // no JVM support; try to fake an approximation
-            return fakeLoadClass(classPatch);
-        }
-        Object[] patches = classPatch.patchArray;
-        // Convert class names (this late in the game)
-        // to use slash '/' instead of dot '.'.
-        // Java likes dots, but the JVM likes slashes.
-        for (int i = 0; i < patches.length; i++) {
-            Object value = patches[i];
-            if (value != null) {
-                byte tag = classPatch.getTag(i);
-                switch (tag) {
-                case ConstantPoolVisitor.CONSTANT_Class:
-                    if (value instanceof String) {
-                        if (patches == classPatch.patchArray)
-                            patches = patches.clone();
-                        patches[i] = ((String)value).replace('.', '/');
-                    }
-                    break;
-                case ConstantPoolVisitor.CONSTANT_Fieldref:
-                case ConstantPoolVisitor.CONSTANT_Methodref:
-                case ConstantPoolVisitor.CONSTANT_InterfaceMethodref:
-                case ConstantPoolVisitor.CONSTANT_NameAndType:
-                    // When/if the JVM supports these patches,
-                    // we'll probably need to reformat them also.
-                    // Meanwhile, let the class loader create the error.
-                    break;
-                }
-            }
-        }
-        return loadClass(classPatch.outer.classFile, classPatch.patchArray);
-    }
-
-    private Class<?> loadClass(byte[] classFile, Object[] patchArray) {
-        try {
-            return (Class<?>)
-                defineAnonymousClass.invoke(unsafe,
-                                            hostClass, classFile, patchArray);
-        } catch (Exception ex) {
-            throwReflectedException(ex);
-            throw new RuntimeException("error loading into "+hostClass, ex);
-        }
-    }
-
-    private static void throwReflectedException(Exception ex) {
-        if (ex instanceof InvocationTargetException) {
-            Throwable tex = ((InvocationTargetException)ex).getTargetException();
-            if (tex instanceof Error)
-                throw (Error) tex;
-            ex = (Exception) tex;
-        }
-        if (ex instanceof RuntimeException) {
-            throw (RuntimeException) ex;
-        }
-    }
-
-    private Class<?> fakeLoadClass(ConstantPoolPatch classPatch) {
-        // Implementation:
-        // 1. Make up a new name nobody has used yet.
-        // 2. Inspect the tail-header of the class to find the this_class index.
-        // 3. Patch the CONSTANT_Class for this_class to the new name.
-        // 4. Add other CP entries required by (e.g.) string patches.
-        // 5. Flatten Class constants down to their names, making sure that
-        //    the host class loader can pick them up again accurately.
-        // 6. Generate the edited class file bytes.
-        //
-        // Potential limitations:
-        // * The class won't be truly anonymous, and may interfere with others.
-        // * Flattened class constants might not work, because of loader issues.
-        // * Pseudo-string constants will not flatten down to real strings.
-        // * Method handles will (of course) fail to flatten to linkage strings.
-        if (true)  throw new UnsupportedOperationException("NYI");
-        Object[] cpArray;
-        try {
-            cpArray = classPatch.getOriginalCP();
-        } catch (InvalidConstantPoolFormatException ex) {
-            throw new RuntimeException(ex);
-        }
-        int thisClassIndex = classPatch.getParser().getThisClassIndex();
-        String thisClassName = (String) cpArray[thisClassIndex];
-        synchronized (AnonymousClassLoader.class) {
-            thisClassName = thisClassName+"\\|"+(++fakeNameCounter);
-        }
-        classPatch.putUTF8(thisClassIndex, thisClassName);
-        byte[] classFile = null;
-        return unsafe.defineClass(null, classFile, 0, classFile.length,
-                                  hostClass.getClassLoader(),
-                                  hostClass.getProtectionDomain());
-    }
-    private static int fakeNameCounter = 99999;
-
-    // ignore two warnings on this line:
-    private static sun.misc.Unsafe unsafe = sun.misc.Unsafe.getUnsafe();
-    // preceding line requires that this class be on the boot class path
-
-    static private final Method defineAnonymousClass;
-    static {
-        Method dac = null;
-        Class<? extends sun.misc.Unsafe> unsafeClass = unsafe.getClass();
-        try {
-            dac = unsafeClass.getMethod("defineAnonymousClass",
-                                        Class.class,
-                                        byte[].class,
-                                        Object[].class);
-        } catch (Exception ee) {
-            dac = null;
-        }
-        defineAnonymousClass = dac;
-    }
-
-    private static void noJVMSupport() {
-        throw new UnsupportedOperationException("no JVM support for anonymous classes");
-    }
-
-
-    private static native Class<?> loadClassInternal(Class<?> hostClass,
-                                                     byte[] classFile,
-                                                     Object[] patchArray);
-
-    public static byte[] readClassFile(Class<?> templateClass) throws IOException {
-        String templateName = templateClass.getName();
-        int lastDot = templateName.lastIndexOf('.');
-        java.net.URL url = templateClass.getResource(templateName.substring(lastDot+1)+".class");
-        java.net.URLConnection connection = url.openConnection();
-        int contentLength = connection.getContentLength();
-        if (contentLength < 0)
-            throw new IOException("invalid content length "+contentLength);
-
-        return IOUtils.readFully(connection.getInputStream(), contentLength, true);
-    }
-}
diff --git a/jdk/src/share/classes/sun/invoke/anon/ConstantPoolParser.java b/jdk/src/share/classes/sun/invoke/anon/ConstantPoolParser.java
deleted file mode 100644
index 441ba95..0000000
--- a/jdk/src/share/classes/sun/invoke/anon/ConstantPoolParser.java
+++ /dev/null
@@ -1,368 +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.
- */
-
-package sun.invoke.anon;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.BufferUnderflowException;
-import java.nio.ByteBuffer;
-
-import static sun.invoke.anon.ConstantPoolVisitor.*;
-
-/** A constant pool parser.
- */
-public class ConstantPoolParser {
-    final byte[] classFile;
-    final byte[] tags;
-    final char[] firstHeader;  // maghi, maglo, minor, major, cplen
-
-    // these are filled in on first parse:
-    int endOffset;
-    char[] secondHeader;       // flags, this_class, super_class, intlen
-
-    // used to decode UTF8 array
-    private char[] charArray = new char[80];
-
-    /** Creates a constant pool parser.
-     * @param classFile an array of bytes containing a class.
-     * @throws InvalidConstantPoolFormatException if the header of the class has errors.
-     */
-    public ConstantPoolParser(byte[] classFile) throws InvalidConstantPoolFormatException {
-        this.classFile = classFile;
-        this.firstHeader = parseHeader(classFile);
-        this.tags = new byte[firstHeader[4]];
-    }
-
-    /** Create a constant pool parser by loading the bytecodes of the
-     *  class taken as argument.
-     *
-     * @param templateClass the class to parse.
-     *
-     * @throws IOException raised if an I/O occurs when loading
-     *  the bytecode of the template class.
-     * @throws InvalidConstantPoolFormatException if the header of the class has errors.
-     *
-     * @see #ConstantPoolParser(byte[])
-     * @see AnonymousClassLoader#readClassFile(Class)
-     */
-    public ConstantPoolParser(Class<?> templateClass) throws IOException, InvalidConstantPoolFormatException {
-        this(AnonymousClassLoader.readClassFile(templateClass));
-    }
-
-    /** Creates an empty patch to patch the class file
-     *  used by the current parser.
-     * @return a new class patch.
-     */
-    public ConstantPoolPatch createPatch() {
-        return new ConstantPoolPatch(this);
-    }
-
-    /** Report the tag of the indicated CP entry.
-     * @param index
-     * @return one of {@link ConstantPoolVisitor#CONSTANT_Utf8}, etc.
-     */
-    public byte getTag(int index) {
-        getEndOffset();  // trigger an exception if we haven't parsed yet
-        return tags[index];
-    }
-
-    /** Report the length of the constant pool. */
-    public int getLength() {
-        return firstHeader[4];
-    }
-
-    /** Report the offset, within the class file, of the start of the constant pool. */
-    public int getStartOffset() {
-        return firstHeader.length * 2;
-    }
-
-    /** Report the offset, within the class file, of the end of the constant pool. */
-    public int getEndOffset() {
-        if (endOffset == 0)
-            throw new IllegalStateException("class file has not yet been parsed");
-        return endOffset;
-    }
-
-    /** Report the CP index of this class's own name. */
-    public int getThisClassIndex() {
-        getEndOffset();   // provoke exception if not yet parsed
-        return secondHeader[1];
-    }
-
-    /** Report the total size of the class file. */
-    public int getTailLength() {
-        return classFile.length - getEndOffset();
-    }
-
-    /** Write the head (header plus constant pool)
-     *  of the class file to the indicated stream.
-     */
-    public void writeHead(OutputStream out) throws IOException {
-        out.write(classFile, 0, getEndOffset());
-    }
-
-    /** Write the head (header plus constant pool)
-     *  of the class file to the indicated stream,
-     *  incorporating the non-null entries of the given array
-     *  as patches.
-     */
-    void writePatchedHead(OutputStream out, Object[] patchArray) {
-        // this will be useful to partially emulate the class loader on old JVMs
-        throw new UnsupportedOperationException("Not yet implemented");
-    }
-
-    /** Write the tail (everything after the constant pool)
-     *  of the class file to the indicated stream.
-     */
-    public void writeTail(OutputStream out) throws IOException {
-        out.write(classFile, getEndOffset(), getTailLength());
-    }
-
-    private static char[] parseHeader(byte[] classFile) throws InvalidConstantPoolFormatException {
-        char[] result = new char[5];
-        ByteBuffer buffer = ByteBuffer.wrap(classFile);
-        for (int i = 0; i < result.length; i++)
-            result[i] = (char) getUnsignedShort(buffer);
-        int magic = result[0] << 16 | result[1] << 0;
-        if (magic != 0xCAFEBABE)
-            throw new InvalidConstantPoolFormatException("invalid magic number "+magic);
-        // skip major, minor version
-        int len = result[4];
-        if (len < 1)
-            throw new InvalidConstantPoolFormatException("constant pool length < 1");
-        return result;
-    }
-
-    /** Parse the constant pool of the class
-     *  calling a method visit* each time a constant pool entry is parsed.
-     *
-     *  The order of the calls to visit* is not guaranteed to be the same
-     *  than the order of the constant pool entry in the bytecode array.
-     *
-     * @param visitor
-     * @throws InvalidConstantPoolFormatException
-     */
-    public void parse(ConstantPoolVisitor visitor) throws InvalidConstantPoolFormatException {
-        ByteBuffer buffer = ByteBuffer.wrap(classFile);
-        buffer.position(getStartOffset()); //skip header
-
-        Object[] values = new Object[getLength()];
-        try {
-            parseConstantPool(buffer, values, visitor);
-        } catch(BufferUnderflowException e) {
-            throw new InvalidConstantPoolFormatException(e);
-        }
-        if (endOffset == 0) {
-            endOffset = buffer.position();
-            secondHeader = new char[4];
-            for (int i = 0; i < secondHeader.length; i++) {
-                secondHeader[i] = (char) getUnsignedShort(buffer);
-            }
-        }
-        resolveConstantPool(values, visitor);
-    }
-
-    private char[] getCharArray(int utfLength) {
-        if (utfLength <= charArray.length)
-            return charArray;
-        return charArray = new char[utfLength];
-    }
-
-    private void parseConstantPool(ByteBuffer buffer, Object[] values, ConstantPoolVisitor visitor) throws InvalidConstantPoolFormatException {
-        for (int i = 1; i < tags.length; ) {
-            byte tag = (byte) getUnsignedByte(buffer);
-            assert(tags[i] == 0 || tags[i] == tag);
-            tags[i] = tag;
-            switch (tag) {
-                case CONSTANT_Utf8:
-                    int utfLen = getUnsignedShort(buffer);
-                    String value = getUTF8(buffer, utfLen, getCharArray(utfLen));
-                    visitor.visitUTF8(i, CONSTANT_Utf8, value);
-                    tags[i] = tag;
-                    values[i++] = value;
-                    break;
-                case CONSTANT_Integer:
-                    visitor.visitConstantValue(i, tag, buffer.getInt());
-                    i++;
-                    break;
-                case CONSTANT_Float:
-                    visitor.visitConstantValue(i, tag, buffer.getFloat());
-                    i++;
-                    break;
-                case CONSTANT_Long:
-                    visitor.visitConstantValue(i, tag, buffer.getLong());
-                    i+=2;
-                    break;
-                case CONSTANT_Double:
-                    visitor.visitConstantValue(i, tag, buffer.getDouble());
-                    i+=2;
-                    break;
-
-                case CONSTANT_Class:    // fall through:
-                case CONSTANT_String:
-                    tags[i] = tag;
-                    values[i++] = new int[] { getUnsignedShort(buffer) };
-                    break;
-
-                case CONSTANT_Fieldref:           // fall through:
-                case CONSTANT_Methodref:          // fall through:
-                case CONSTANT_InterfaceMethodref: // fall through:
-                case CONSTANT_NameAndType:
-                    tags[i] = tag;
-                    values[i++] = new int[] { getUnsignedShort(buffer), getUnsignedShort(buffer) };
-                    break;
-                default:
-                    throw new AssertionError("invalid constant "+tag);
-            }
-        }
-    }
-
-    private void resolveConstantPool(Object[] values, ConstantPoolVisitor visitor) {
-        // clean out the int[] values, which are temporary
-        for (int beg = 1, end = values.length-1, beg2, end2;
-             beg <= end;
-             beg = beg2, end = end2) {
-             beg2 = end; end2 = beg-1;
-             //System.out.println("CP resolve pass: "+beg+".."+end);
-             for (int i = beg; i <= end; i++) {
-                  Object value = values[i];
-                  if (!(value instanceof int[]))
-                      continue;
-                  int[] array = (int[]) value;
-                  byte tag = tags[i];
-                  switch (tag) {
-                      case CONSTANT_String:
-                          String stringBody = (String) values[array[0]];
-                          visitor.visitConstantString(i, tag, stringBody, array[0]);
-                          values[i] = null;
-                          break;
-                      case CONSTANT_Class: {
-                          String className = (String) values[array[0]];
-                          // use the external form favored by Class.forName:
-                          className = className.replace('/', '.');
-                          visitor.visitConstantString(i, tag, className, array[0]);
-                          values[i] = className;
-                          break;
-                      }
-                      case CONSTANT_NameAndType: {
-                          String memberName = (String) values[array[0]];
-                          String signature  = (String) values[array[1]];
-                          visitor.visitDescriptor(i, tag, memberName, signature,
-                                                  array[0], array[1]);
-                          values[i] = new String[] {memberName, signature};
-                          break;
-                      }
-                      case CONSTANT_Fieldref:           // fall through:
-                      case CONSTANT_Methodref:          // fall through:
-                      case CONSTANT_InterfaceMethodref: {
-                              Object className   = values[array[0]];
-                              Object nameAndType = values[array[1]];
-                              if (!(className instanceof String) ||
-                                  !(nameAndType instanceof String[])) {
-                                   // one more pass is needed
-                                   if (beg2 > i)  beg2 = i;
-                                   if (end2 < i)  end2 = i;
-                                   continue;
-                              }
-                              String[] nameAndTypeArray = (String[]) nameAndType;
-                              visitor.visitMemberRef(i, tag,
-                                  (String)className,
-                                  nameAndTypeArray[0],
-                                  nameAndTypeArray[1],
-                                  array[0], array[1]);
-                              values[i] = null;
-                          }
-                          break;
-                      default:
-                          continue;
-                }
-            }
-        }
-    }
-
-    private static int getUnsignedByte(ByteBuffer buffer) {
-        return buffer.get() & 0xFF;
-    }
-
-    private static int getUnsignedShort(ByteBuffer buffer) {
-        int b1 = getUnsignedByte(buffer);
-        int b2 = getUnsignedByte(buffer);
-        return (b1 << 8) + (b2 << 0);
-    }
-
-    private static String getUTF8(ByteBuffer buffer, int utfLen, char[] charArray) throws InvalidConstantPoolFormatException {
-      int utfLimit = buffer.position() + utfLen;
-      int index = 0;
-      while (buffer.position() < utfLimit) {
-          int c = buffer.get() & 0xff;
-          if (c > 127) {
-              buffer.position(buffer.position() - 1);
-              return getUTF8Extended(buffer, utfLimit, charArray, index);
-          }
-          charArray[index++] = (char)c;
-      }
-      return new String(charArray, 0, index);
-    }
-
-    private static String getUTF8Extended(ByteBuffer buffer, int utfLimit, char[] charArray, int index) throws InvalidConstantPoolFormatException {
-        int c, c2, c3;
-        while (buffer.position() < utfLimit) {
-            c = buffer.get() & 0xff;
-            switch (c >> 4) {
-                case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
-                    /* 0xxxxxxx*/
-                    charArray[index++] = (char)c;
-                    break;
-                case 12: case 13:
-                    /* 110x xxxx   10xx xxxx*/
-                    c2 = buffer.get();
-                    if ((c2 & 0xC0) != 0x80)
-                        throw new InvalidConstantPoolFormatException(
-                            "malformed input around byte " + buffer.position());
-                     charArray[index++] = (char)(((c  & 0x1F) << 6) |
-                                                  (c2 & 0x3F));
-                    break;
-                case 14:
-                    /* 1110 xxxx  10xx xxxx  10xx xxxx */
-                    c2 = buffer.get();
-                    c3 = buffer.get();
-                    if (((c2 & 0xC0) != 0x80) || ((c3 & 0xC0) != 0x80))
-                       throw new InvalidConstantPoolFormatException(
-                          "malformed input around byte " + (buffer.position()));
-                    charArray[index++] = (char)(((c  & 0x0F) << 12) |
-                                                ((c2 & 0x3F) << 6)  |
-                                                ((c3 & 0x3F) << 0));
-                    break;
-                default:
-                    /* 10xx xxxx,  1111 xxxx */
-                    throw new InvalidConstantPoolFormatException(
-                        "malformed input around byte " + buffer.position());
-            }
-        }
-        // The number of chars produced may be less than utflen
-        return new String(charArray, 0, index);
-    }
-}
diff --git a/jdk/src/share/classes/sun/invoke/anon/ConstantPoolPatch.java b/jdk/src/share/classes/sun/invoke/anon/ConstantPoolPatch.java
deleted file mode 100644
index d83c2a6..0000000
--- a/jdk/src/share/classes/sun/invoke/anon/ConstantPoolPatch.java
+++ /dev/null
@@ -1,503 +0,0 @@
-/*
- * Copyright (c) 2008, 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.invoke.anon;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.IdentityHashMap;
-import java.util.Map;
-
-import static sun.invoke.anon.ConstantPoolVisitor.*;
-
-/** A class and its patched constant pool.
- *
- *  This class allow to modify (patch) a constant pool
- *  by changing the value of its entry.
- *  Entry are referenced using index that can be get
- *  by parsing the constant pool using
- *  {@link ConstantPoolParser#parse(ConstantPoolVisitor)}.
- *
- * @see ConstantPoolVisitor
- * @see ConstantPoolParser#createPatch()
- */
-public class ConstantPoolPatch {
-    final ConstantPoolParser outer;
-    final Object[] patchArray;
-
-    ConstantPoolPatch(ConstantPoolParser outer) {
-        this.outer      = outer;
-        this.patchArray = new Object[outer.getLength()];
-    }
-
-    /** Create a {@link ConstantPoolParser} and
-     *  a {@link ConstantPoolPatch} in one step.
-     *  Equivalent to {@code new ConstantPoolParser(classFile).createPatch()}.
-     *
-     * @param classFile an array of bytes containing a class.
-     * @see #ConstantPoolParser(Class)
-     */
-    public ConstantPoolPatch(byte[] classFile) throws InvalidConstantPoolFormatException {
-        this(new ConstantPoolParser(classFile));
-    }
-
-    /** Create a {@link ConstantPoolParser} and
-     *  a {@link ConstantPoolPatch} in one step.
-     *  Equivalent to {@code new ConstantPoolParser(templateClass).createPatch()}.
-     *
-     * @param templateClass the class to parse.
-     * @see #ConstantPoolParser(Class)
-     */
-    public ConstantPoolPatch(Class<?> templateClass) throws IOException, InvalidConstantPoolFormatException {
-        this(new ConstantPoolParser(templateClass));
-    }
-
-
-    /** Creates a patch from an existing patch.
-     *  All changes are copied from that patch.
-     * @param patch a patch
-     *
-     * @see ConstantPoolParser#createPatch()
-     */
-    public ConstantPoolPatch(ConstantPoolPatch patch) {
-        outer      = patch.outer;
-        patchArray = patch.patchArray.clone();
-    }
-
-    /** Which parser built this patch? */
-    public ConstantPoolParser getParser() {
-        return outer;
-    }
-
-    /** Report the tag at the given index in the constant pool. */
-    public byte getTag(int index) {
-        return outer.getTag(index);
-    }
-
-    /** Report the current patch at the given index of the constant pool.
-     *  Null means no patch will be made.
-     *  To observe the unpatched entry at the given index, use
-     *  {@link #getParser()}{@code .}@link ConstantPoolParser#parse(ConstantPoolVisitor)}
-     */
-    public Object getPatch(int index) {
-        Object value = patchArray[index];
-        if (value == null)  return null;
-        switch (getTag(index)) {
-        case CONSTANT_Fieldref:
-        case CONSTANT_Methodref:
-        case CONSTANT_InterfaceMethodref:
-            if (value instanceof String)
-                value = stripSemis(2, (String) value);
-            break;
-        case CONSTANT_NameAndType:
-            if (value instanceof String)
-                value = stripSemis(1, (String) value);
-            break;
-        }
-        return value;
-    }
-
-    /** Clear all patches. */
-    public void clear() {
-        Arrays.fill(patchArray, null);
-    }
-
-    /** Clear one patch. */
-    public void clear(int index) {
-        patchArray[index] = null;
-    }
-
-    /** Produce the patches as an array. */
-    public Object[] getPatches() {
-        return patchArray.clone();
-    }
-
-    /** Produce the original constant pool as an array. */
-    public Object[] getOriginalCP() throws InvalidConstantPoolFormatException {
-        return getOriginalCP(0, patchArray.length, -1);
-    }
-
-    /** Walk the constant pool, applying patches using the given map.
-     *
-     * @param utf8Map Utf8 strings to modify, if encountered
-     * @param classMap Classes (or their names) to modify, if encountered
-     * @param valueMap Constant values to modify, if encountered
-     * @param deleteUsedEntries if true, delete map entries that are used
-     */
-    public void putPatches(final Map<String,String> utf8Map,
-                           final Map<String,Object> classMap,
-                           final Map<Object,Object> valueMap,
-                           boolean deleteUsedEntries) throws InvalidConstantPoolFormatException {
-        final HashSet<String> usedUtf8Keys;
-        final HashSet<String> usedClassKeys;
-        final HashSet<Object> usedValueKeys;
-        if (deleteUsedEntries) {
-            usedUtf8Keys  = (utf8Map  == null) ? null : new HashSet<String>();
-            usedClassKeys = (classMap == null) ? null : new HashSet<String>();
-            usedValueKeys = (valueMap == null) ? null : new HashSet<Object>();
-        } else {
-            usedUtf8Keys = null;
-            usedClassKeys = null;
-            usedValueKeys = null;
-        }
-
-        outer.parse(new ConstantPoolVisitor() {
-
-            @Override
-            public void visitUTF8(int index, byte tag, String utf8) {
-                putUTF8(index, utf8Map.get(utf8));
-                if (usedUtf8Keys != null)  usedUtf8Keys.add(utf8);
-            }
-
-            @Override
-            public void visitConstantValue(int index, byte tag, Object value) {
-                putConstantValue(index, tag, valueMap.get(value));
-                if (usedValueKeys != null)  usedValueKeys.add(value);
-            }
-
-            @Override
-            public void visitConstantString(int index, byte tag, String name, int nameIndex) {
-                if (tag == CONSTANT_Class) {
-                    putConstantValue(index, tag, classMap.get(name));
-                    if (usedClassKeys != null)  usedClassKeys.add(name);
-                } else {
-                    assert(tag == CONSTANT_String);
-                    visitConstantValue(index, tag, name);
-                }
-            }
-        });
-        if (usedUtf8Keys != null)   utf8Map.keySet().removeAll(usedUtf8Keys);
-        if (usedClassKeys != null)  classMap.keySet().removeAll(usedClassKeys);
-        if (usedValueKeys != null)  valueMap.keySet().removeAll(usedValueKeys);
-    }
-
-    Object[] getOriginalCP(final int startIndex,
-                           final int endIndex,
-                           final int tagMask) throws InvalidConstantPoolFormatException {
-        final Object[] cpArray = new Object[endIndex - startIndex];
-        outer.parse(new ConstantPoolVisitor() {
-
-            void show(int index, byte tag, Object value) {
-                if (index < startIndex || index >= endIndex)  return;
-                if (((1 << tag) & tagMask) == 0)  return;
-                cpArray[index - startIndex] = value;
-            }
-
-            @Override
-            public void visitUTF8(int index, byte tag, String utf8) {
-                show(index, tag, utf8);
-            }
-
-            @Override
-            public void visitConstantValue(int index, byte tag, Object value) {
-                assert(tag != CONSTANT_String);
-                show(index, tag, value);
-            }
-
-            @Override
-            public void visitConstantString(int index, byte tag,
-                                            String value, int j) {
-                show(index, tag, value);
-            }
-
-            @Override
-            public void visitMemberRef(int index, byte tag,
-                    String className, String memberName,
-                    String signature,
-                    int j, int k) {
-                show(index, tag, new String[]{ className, memberName, signature });
-            }
-
-            @Override
-            public void visitDescriptor(int index, byte tag,
-                    String memberName, String signature,
-                    int j, int k) {
-                show(index, tag, new String[]{ memberName, signature });
-            }
-        });
-        return cpArray;
-    }
-
-    /** Write the head (header plus constant pool)
-     *  of the patched class file to the indicated stream.
-     */
-    void writeHead(OutputStream out) throws IOException {
-        outer.writePatchedHead(out, patchArray);
-    }
-
-    /** Write the tail (everything after the constant pool)
-     *  of the patched class file to the indicated stream.
-     */
-    void writeTail(OutputStream out) throws IOException {
-        outer.writeTail(out);
-    }
-
-    private void checkConstantTag(byte tag, Object value) {
-        if (value == null)
-            throw new IllegalArgumentException(
-                    "invalid null constant value");
-        if (classForTag(tag) != value.getClass())
-            throw new IllegalArgumentException(
-                    "invalid constant value"
-                    + (tag == CONSTANT_None ? ""
-                        : " for tag "+tagName(tag))
-                    + " of class "+value.getClass());
-    }
-
-    private void checkTag(int index, byte putTag) {
-        byte tag = outer.tags[index];
-        if (tag != putTag)
-            throw new IllegalArgumentException(
-                "invalid put operation"
-                + " for " + tagName(putTag)
-                + " at index " + index + " found " + tagName(tag));
-    }
-
-    private void checkTagMask(int index, int tagBitMask) {
-        byte tag = outer.tags[index];
-        int tagBit = ((tag & 0x1F) == tag) ? (1 << tag) : 0;
-        if ((tagBit & tagBitMask) == 0)
-            throw new IllegalArgumentException(
-                "invalid put operation"
-                + " at index " + index + " found " + tagName(tag));
-    }
-
-    private static void checkMemberName(String memberName) {
-        if (memberName.indexOf(';') >= 0)
-            throw new IllegalArgumentException("memberName " + memberName + " contains a ';'");
-    }
-
-    /** Set the entry of the constant pool indexed by index to
-     *  a new string.
-     *
-     * @param index an index to a constant pool entry containing a
-     *        {@link ConstantPoolVisitor#CONSTANT_Utf8} value.
-     * @param utf8 a string
-     *
-     * @see ConstantPoolVisitor#visitUTF8(int, byte, String)
-     */
-    public void putUTF8(int index, String utf8) {
-        if (utf8 == null) { clear(index); return; }
-        checkTag(index, CONSTANT_Utf8);
-        patchArray[index] = utf8;
-    }
-
-    /** Set the entry of the constant pool indexed by index to
-     *  a new value, depending on its dynamic type.
-     *
-     * @param index an index to a constant pool entry containing a
-     *        one of the following structures:
-     *        {@link ConstantPoolVisitor#CONSTANT_Integer},
-     *        {@link ConstantPoolVisitor#CONSTANT_Float},
-     *        {@link ConstantPoolVisitor#CONSTANT_Long},
-     *        {@link ConstantPoolVisitor#CONSTANT_Double},
-     *        {@link ConstantPoolVisitor#CONSTANT_String}, or
-     *        {@link ConstantPoolVisitor#CONSTANT_Class}
-     * @param value a boxed int, float, long or double; or a string or class object
-     * @throws IllegalArgumentException if the type of the constant does not
-     *         match the constant pool entry type,
-     *         as reported by {@link #getTag(int)}
-     *
-     * @see #putConstantValue(int, byte, Object)
-     * @see ConstantPoolVisitor#visitConstantValue(int, byte, Object)
-     * @see ConstantPoolVisitor#visitConstantString(int, byte, String, int)
-     */
-    public void putConstantValue(int index, Object value) {
-        if (value == null) { clear(index); return; }
-        byte tag = tagForConstant(value.getClass());
-        checkConstantTag(tag, value);
-        checkTag(index, tag);
-        patchArray[index] = value;
-    }
-
-    /** Set the entry of the constant pool indexed by index to
-     *  a new value.
-     *
-     * @param index an index to a constant pool entry matching the given tag
-     * @param tag one of the following values:
-     *        {@link ConstantPoolVisitor#CONSTANT_Integer},
-     *        {@link ConstantPoolVisitor#CONSTANT_Float},
-     *        {@link ConstantPoolVisitor#CONSTANT_Long},
-     *        {@link ConstantPoolVisitor#CONSTANT_Double},
-     *        {@link ConstantPoolVisitor#CONSTANT_String}, or
-     *        {@link ConstantPoolVisitor#CONSTANT_Class}
-     * @param value a boxed number, string, or class object
-     * @throws IllegalArgumentException if the type of the constant does not
-     *         match the constant pool entry type, or if a class name contains
-     *         '/' or ';'
-     *
-     * @see #putConstantValue(int, Object)
-     * @see ConstantPoolVisitor#visitConstantValue(int, byte, Object)
-     * @see ConstantPoolVisitor#visitConstantString(int, byte, String, int)
-     */
-    public void putConstantValue(int index, byte tag, Object value) {
-        if (value == null) { clear(index); return; }
-        checkTag(index, tag);
-        if (tag == CONSTANT_Class && value instanceof String) {
-            checkClassName((String) value);
-        } else if (tag == CONSTANT_String) {
-            // the JVM accepts any object as a patch for a string
-        } else {
-            // make sure the incoming value is the right type
-            checkConstantTag(tag, value);
-        }
-        checkTag(index, tag);
-        patchArray[index] = value;
-    }
-
-    /** Set the entry of the constant pool indexed by index to
-     *  a new {@link ConstantPoolVisitor#CONSTANT_NameAndType} value.
-     *
-     * @param index an index to a constant pool entry containing a
-     *        {@link ConstantPoolVisitor#CONSTANT_NameAndType} value.
-     * @param memberName a memberName
-     * @param signature a signature
-     * @throws IllegalArgumentException if memberName contains the character ';'
-     *
-     * @see ConstantPoolVisitor#visitDescriptor(int, byte, String, String, int, int)
-     */
-    public void putDescriptor(int index, String memberName, String signature) {
-        checkTag(index, CONSTANT_NameAndType);
-        checkMemberName(memberName);
-        patchArray[index] = addSemis(memberName, signature);
-    }
-
-    /** Set the entry of the constant pool indexed by index to
-     *  a new {@link ConstantPoolVisitor#CONSTANT_Fieldref},
-     *  {@link ConstantPoolVisitor#CONSTANT_Methodref}, or
-     *  {@link ConstantPoolVisitor#CONSTANT_InterfaceMethodref} value.
-     *
-     * @param index an index to a constant pool entry containing a member reference
-     * @param className a class name
-     * @param memberName a field or method name
-     * @param signature a field or method signature
-     * @throws IllegalArgumentException if memberName contains the character ';'
-     *             or signature is not a correct signature
-     *
-     * @see ConstantPoolVisitor#visitMemberRef(int, byte, String, String, String, int, int)
-     */
-    public void putMemberRef(int index, byte tag,
-                    String className, String memberName, String signature) {
-        checkTagMask(tag, CONSTANT_MemberRef_MASK);
-        checkTag(index, tag);
-        checkClassName(className);
-        checkMemberName(memberName);
-        if (signature.startsWith("(") == (tag == CONSTANT_Fieldref))
-            throw new IllegalArgumentException("bad signature: "+signature);
-        patchArray[index] = addSemis(className, memberName, signature);
-    }
-
-    static private final int CONSTANT_MemberRef_MASK =
-              CONSTANT_Fieldref
-            | CONSTANT_Methodref
-            | CONSTANT_InterfaceMethodref;
-
-    private static final Map<Class<?>, Byte> CONSTANT_VALUE_CLASS_TAG
-        = new IdentityHashMap<Class<?>, Byte>();
-    private static final Class<?>[] CONSTANT_VALUE_CLASS = new Class<?>[16];
-    static {
-        Object[][] values = {
-            {Integer.class, CONSTANT_Integer},
-            {Long.class, CONSTANT_Long},
-            {Float.class, CONSTANT_Float},
-            {Double.class, CONSTANT_Double},
-            {String.class, CONSTANT_String},
-            {Class.class, CONSTANT_Class}
-        };
-        for (Object[] value : values) {
-            Class<?> cls = (Class<?>)value[0];
-            Byte     tag = (Byte) value[1];
-            CONSTANT_VALUE_CLASS_TAG.put(cls, tag);
-            CONSTANT_VALUE_CLASS[(byte)tag] = cls;
-        }
-    }
-
-    static Class<?> classForTag(byte tag) {
-        if ((tag & 0xFF) >= CONSTANT_VALUE_CLASS.length)
-            return null;
-        return CONSTANT_VALUE_CLASS[tag];
-    }
-
-    static byte tagForConstant(Class<?> cls) {
-        Byte tag = CONSTANT_VALUE_CLASS_TAG.get(cls);
-        return (tag == null) ? CONSTANT_None : (byte)tag;
-    }
-
-    private static void checkClassName(String className) {
-        if (className.indexOf('/') >= 0 || className.indexOf(';') >= 0)
-            throw new IllegalArgumentException("invalid class name " + className);
-    }
-
-    static String addSemis(String name, String... names) {
-        StringBuilder buf = new StringBuilder(name.length() * 5);
-        buf.append(name);
-        for (String name2 : names) {
-            buf.append(';').append(name2);
-        }
-        String res = buf.toString();
-        assert(stripSemis(names.length, res)[0].equals(name));
-        assert(stripSemis(names.length, res)[1].equals(names[0]));
-        assert(names.length == 1 ||
-               stripSemis(names.length, res)[2].equals(names[1]));
-        return res;
-    }
-
-    static String[] stripSemis(int count, String string) {
-        String[] res = new String[count+1];
-        int pos = 0;
-        for (int i = 0; i < count; i++) {
-            int pos2 = string.indexOf(';', pos);
-            if (pos2 < 0)  pos2 = string.length();  // yuck
-            res[i] = string.substring(pos, pos2);
-            pos = pos2;
-        }
-        res[count] = string.substring(pos);
-        return res;
-    }
-
-    public String toString() {
-        StringBuilder buf = new StringBuilder(this.getClass().getName());
-        buf.append("{");
-        Object[] origCP = null;
-        for (int i = 0; i < patchArray.length; i++) {
-            if (patchArray[i] == null)  continue;
-            if (origCP != null) {
-                buf.append(", ");
-            } else {
-                try {
-                    origCP = getOriginalCP();
-                } catch (InvalidConstantPoolFormatException ee) {
-                    origCP = new Object[0];
-                }
-            }
-            Object orig = (i < origCP.length) ? origCP[i] : "?";
-            buf.append(orig).append("=").append(patchArray[i]);
-        }
-        buf.append("}");
-        return buf.toString();
-    }
-}
diff --git a/jdk/src/share/classes/sun/invoke/anon/ConstantPoolVisitor.java b/jdk/src/share/classes/sun/invoke/anon/ConstantPoolVisitor.java
deleted file mode 100644
index dfec8b4..0000000
--- a/jdk/src/share/classes/sun/invoke/anon/ConstantPoolVisitor.java
+++ /dev/null
@@ -1,192 +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.
- */
-
-package sun.invoke.anon;
-
-/**
- * A visitor called by {@link ConstantPoolParser#parse(ConstantPoolVisitor)}
- * when a constant pool entry is parsed.
- * <p>
- * A visit* method is called when a constant pool entry is parsed.
- * The first argument is always the constant pool index.
- * The second argument is always the constant pool tag,
- * even for methods like {@link #visitUTF8(int, byte, String)} which only apply to one tag.
- * String arguments refer to Utf8 or NameAndType entries declared elsewhere,
- * and are always accompanied by the indexes of those entries.
- * <p>
- * The order of the calls to the visit* methods is not necessarily related
- * to the order of the entries in the constant pool.
- * If one entry has a reference to another entry, the latter (lower-level)
- * entry will be visited first.
- * <p>
- * The following table shows the relation between constant pool entry
- * types and the corresponding visit* methods:
- *
- * <table border=1 cellpadding=5 summary="constant pool visitor methods">
- * <tr><th>Tag(s)</th><th>Method</th></tr>
- * <tr>
- *   <td>{@link #CONSTANT_Utf8}</td>
- *   <td>{@link #visitUTF8(int, byte, String)}</td>
- * </tr><tr>
- *   <td>{@link #CONSTANT_Integer}, {@link #CONSTANT_Float},
- *       {@link #CONSTANT_Long}, {@link #CONSTANT_Double}</td>
- *   <td>{@link #visitConstantValue(int, byte, Object)}</td>
- * </tr><tr>
- *   <td>{@link #CONSTANT_String}, {@link #CONSTANT_Class}</td>
- *   <td>{@link #visitConstantString(int, byte, String, int)}</td>
- * </tr><tr>
- *   <td>{@link #CONSTANT_NameAndType}</td>
- *   <td>{@link #visitDescriptor(int, byte, String, String, int, int)}</td>
- * </tr><tr>
- *   <td>{@link #CONSTANT_Fieldref},
- *       {@link #CONSTANT_Methodref},
- *       {@link #CONSTANT_InterfaceMethodref}</td>
- *   <td>{@link #visitMemberRef(int, byte, String, String, String, int, int)}</td>
- * </tr>
- * </table>
- *
- * @see ConstantPoolPatch
- * @author Remi Forax
- * @author jrose
- */
-public class ConstantPoolVisitor {
-  /** Called each time an UTF8 constant pool entry is found.
-   * @param index the constant pool index
-   * @param tag always {@link #CONSTANT_Utf8}
-   * @param utf8 string encoded in modified UTF-8 format passed as a {@code String}
-   *
-   * @see ConstantPoolPatch#putUTF8(int, String)
-   */
-  public void visitUTF8(int index, byte tag, String utf8) {
-    // do nothing
-  }
-
-  /** Called for each constant pool entry that encodes an integer,
-   *  a float, a long, or a double.
-   *  Constant strings and classes are not managed by this method but
-   *  by {@link #visitConstantString(int, byte, String, int)}.
-   *
-   * @param index the constant pool index
-   * @param tag one of {@link #CONSTANT_Integer},
-   *            {@link #CONSTANT_Float},
-   *            {@link #CONSTANT_Long},
-   *            or {@link #CONSTANT_Double}
-   * @param value encoded value
-   *
-   * @see ConstantPoolPatch#putConstantValue(int, Object)
-   */
-  public void visitConstantValue(int index, byte tag, Object value) {
-    // do nothing
-  }
-
-  /** Called for each constant pool entry that encodes a string or a class.
-   * @param index the constant pool index
-   * @param tag one of {@link #CONSTANT_String},
-   *            {@link #CONSTANT_Class},
-   * @param name string body or class name (using dot separator)
-   * @param nameIndex the index of the Utf8 string for the name
-   *
-   * @see ConstantPoolPatch#putConstantValue(int, byte, Object)
-   */
-  public void visitConstantString(int index, byte tag,
-                                  String name, int nameIndex) {
-    // do nothing
-  }
-
-  /** Called for each constant pool entry that encodes a name and type.
-   * @param index the constant pool index
-   * @param tag always {@link #CONSTANT_NameAndType}
-   * @param memberName a field or method name
-   * @param signature the member signature
-   * @param memberNameIndex index of the Utf8 string for the member name
-   * @param signatureIndex index of the Utf8 string for the signature
-   *
-   * @see ConstantPoolPatch#putDescriptor(int, String, String)
-   */
-  public void visitDescriptor(int index, byte tag,
-                              String memberName, String signature,
-                              int memberNameIndex, int signatureIndex) {
-    // do nothing
-  }
-
-  /** Called for each constant pool entry that encodes a field or method.
-   * @param index the constant pool index
-   * @param tag one of {@link #CONSTANT_Fieldref},
-   *            or {@link #CONSTANT_Methodref},
-   *            or {@link #CONSTANT_InterfaceMethodref}
-   * @param className the class name (using dot separator)
-   * @param memberName name of the field or method
-   * @param signature the field or method signature
-   * @param classNameIndex index of the Utf8 string for the class name
-   * @param descriptorIndex index of the NameAndType descriptor constant
-   *
-   * @see ConstantPoolPatch#putMemberRef(int, byte, String, String, String)
-   */
-  public void visitMemberRef(int index, byte tag,
-                             String className, String memberName, String signature,
-                             int classNameIndex, int descriptorIndex) {
-    // do nothing
-  }
-
-    public static final byte
-      CONSTANT_None = 0,
-      CONSTANT_Utf8 = 1,
-      //CONSTANT_Unicode = 2,               /* unused */
-      CONSTANT_Integer = 3,
-      CONSTANT_Float = 4,
-      CONSTANT_Long = 5,
-      CONSTANT_Double = 6,
-      CONSTANT_Class = 7,
-      CONSTANT_String = 8,
-      CONSTANT_Fieldref = 9,
-      CONSTANT_Methodref = 10,
-      CONSTANT_InterfaceMethodref = 11,
-      CONSTANT_NameAndType = 12;
-
-    private static String[] TAG_NAMES = {
-        "Empty",
-        "Utf8",
-        null, //"Unicode",
-        "Integer",
-        "Float",
-        "Long",
-        "Double",
-        "Class",
-        "String",
-        "Fieldref",
-        "Methodref",
-        "InterfaceMethodref",
-        "NameAndType"
-    };
-
-    public static String tagName(byte tag) {
-        String name = null;
-        if ((tag & 0xFF) < TAG_NAMES.length)
-            name = TAG_NAMES[tag];
-        if (name == null)
-            name = "Unknown#"+(tag&0xFF);
-        return name;
-    }
-}
diff --git a/jdk/src/share/classes/sun/launcher/resources/launcher_zh_TW.properties b/jdk/src/share/classes/sun/launcher/resources/launcher_zh_TW.properties
index dc3bcfb..949c138 100644
--- a/jdk/src/share/classes/sun/launcher/resources/launcher_zh_TW.properties
+++ b/jdk/src/share/classes/sun/launcher/resources/launcher_zh_TW.properties
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2007, 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,7 +44,7 @@
 
 java.launcher.cls.error1=\u932F\u8AA4: \u627E\u4E0D\u5230\u6216\u7121\u6CD5\u8F09\u5165\u4E3B\u8981\u985E\u5225 {0}
 java.launcher.cls.error2=\u932F\u8AA4: \u4E3B\u8981\u65B9\u6CD5\u4E0D\u662F\u985E\u5225 {1} \u4E2D\u7684 {0}\uFF0C\u8ACB\u5B9A\u7FA9\u4E3B\u8981\u65B9\u6CD5\u70BA:\n   public static void main(String[] args)
-java.launcher.cls.error3=\u932F\u8AA4: \u4E3B\u8981\u65B9\u6CD5\u5FC5\u9808\u50B3\u56DE\u985E\u5225 {0} \u4E2D void \u985E\u578B\u7684\u503C\uFF0C \n\u8ACB\u5B9A\u7FA9\u4E3B\u8981\u65B9\u6CD5\u70BA:\n   public static void main(String[] args)
+java.launcher.cls.error3=\u932F\u8AA4: \u4E3B\u8981\u65B9\u6CD5\u5FC5\u9808\u50B3\u56DE\u985E\u5225 {0} \u4E2D void \u985E\u578B\u7684\u503C\uFF0C\n\u8ACB\u5B9A\u7FA9\u4E3B\u8981\u65B9\u6CD5\u70BA:\n   public static void main(String[] args)
 java.launcher.cls.error4=\u932F\u8AA4: \u5728\u985E\u5225 {0} \u4E2D\u627E\u4E0D\u5230\u4E3B\u8981\u65B9\u6CD5\uFF0C\u8ACB\u5B9A\u7FA9\u4E3B\u8981\u65B9\u6CD5\u70BA:\n   public static void main(String[] args)\n\u6216\u8005 JavaFX \u61C9\u7528\u7A0B\u5F0F\u985E\u5225\u5FC5\u9808\u64F4\u5145 {1}
 java.launcher.cls.error5=\u932F\u8AA4: \u907A\u6F0F\u57F7\u884C\u6B64\u61C9\u7528\u7A0B\u5F0F\u6240\u9700\u7684 JavaFX \u7A0B\u5F0F\u5BE6\u969B\u57F7\u884C\u5143\u4EF6
 java.launcher.jar.error1=\u932F\u8AA4: \u5617\u8A66\u958B\u555F\u6A94\u6848 {0} \u6642\u767C\u751F\u672A\u9810\u671F\u7684\u932F\u8AA4
diff --git a/jdk/src/share/classes/sun/management/jmxremote/ConnectorBootstrap.java b/jdk/src/share/classes/sun/management/jmxremote/ConnectorBootstrap.java
index 3ff602b..56287ed 100644
--- a/jdk/src/share/classes/sun/management/jmxremote/ConnectorBootstrap.java
+++ b/jdk/src/share/classes/sun/management/jmxremote/ConnectorBootstrap.java
@@ -30,9 +30,12 @@
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.Serializable;
 import java.lang.management.ManagementFactory;
 import java.net.InetAddress;
 import java.net.MalformedURLException;
+import java.net.Socket;
+import java.net.ServerSocket;
 import java.net.UnknownHostException;
 import java.rmi.NoSuchObjectException;
 import java.rmi.Remote;
@@ -40,6 +43,7 @@
 import java.rmi.registry.Registry;
 import java.rmi.server.RMIClientSocketFactory;
 import java.rmi.server.RMIServerSocketFactory;
+import java.rmi.server.RMISocketFactory;
 import java.rmi.server.RemoteObject;
 import java.rmi.server.UnicastRemoteObject;
 import java.security.KeyStore;
@@ -59,6 +63,8 @@
 import javax.management.remote.rmi.RMIConnectorServer;
 import javax.net.ssl.KeyManagerFactory;
 import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.SSLSocketFactory;
 import javax.net.ssl.TrustManagerFactory;
 import javax.rmi.ssl.SslRMIClientSocketFactory;
 import javax.rmi.ssl.SslRMIServerSocketFactory;
@@ -107,6 +113,8 @@
 
         public static final String PORT =
                 "com.sun.management.jmxremote.port";
+        public static final String HOST =
+                "com.sun.management.jmxremote.host";
         public static final String RMI_PORT =
                 "com.sun.management.jmxremote.rmi.port";
         public static final String CONFIG_FILE_NAME =
@@ -424,10 +432,14 @@
             checkAccessFile(accessFileName);
         }
 
+        final String bindAddress =
+                props.getProperty(PropertyNames.HOST);
+
         if (log.debugOn()) {
             log.debug("startRemoteConnectorServer",
                     Agent.getText("jmxremote.ConnectorBootstrap.starting") +
                     "\n\t" + PropertyNames.PORT + "=" + port +
+                    (bindAddress == null ? "" : "\n\t" + PropertyNames.HOST + "=" + bindAddress) +
                     "\n\t" + PropertyNames.RMI_PORT + "=" + rmiPort +
                     "\n\t" + PropertyNames.USE_SSL + "=" + useSsl +
                     "\n\t" + PropertyNames.USE_REGISTRY_SSL + "=" + useRegistrySsl +
@@ -458,7 +470,7 @@
                     sslConfigFileName, enabledCipherSuitesList,
                     enabledProtocolsList, sslNeedClientAuth,
                     useAuthentication, loginConfigName,
-                    passwordFileName, accessFileName);
+                    passwordFileName, accessFileName, bindAddress);
             cs = data.jmxConnectorServer;
             url = data.jmxRemoteURL;
             log.config("startRemoteConnectorServer",
@@ -631,12 +643,13 @@
             String sslConfigFileName,
             String[] enabledCipherSuites,
             String[] enabledProtocols,
-            boolean sslNeedClientAuth) {
+            boolean sslNeedClientAuth,
+            String bindAddress) {
         if (sslConfigFileName == null) {
-            return new SslRMIServerSocketFactory(
+            return new HostAwareSslSocketFactory(
                     enabledCipherSuites,
                     enabledProtocols,
-                    sslNeedClientAuth);
+                    sslNeedClientAuth, bindAddress);
         } else {
             checkRestrictedFile(sslConfigFileName);
             try {
@@ -690,11 +703,11 @@
                 SSLContext ctx = SSLContext.getInstance("SSL");
                 ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
 
-                return new SslRMIServerSocketFactory(
+                return new HostAwareSslSocketFactory(
                         ctx,
                         enabledCipherSuites,
                         enabledProtocols,
-                        sslNeedClientAuth);
+                        sslNeedClientAuth, bindAddress);
             } catch (Exception e) {
                 throw new AgentConfigurationError(AGENT_EXCEPTION, e, e.toString());
             }
@@ -714,7 +727,8 @@
             boolean useAuthentication,
             String loginConfigName,
             String passwordFileName,
-            String accessFileName)
+            String accessFileName,
+            String bindAddress)
             throws IOException, MalformedURLException {
 
         /* Make sure we use non-guessable RMI object IDs.  Otherwise
@@ -722,7 +736,7 @@
          * IDs.  */
         System.setProperty("java.rmi.server.randomIDs", "true");
 
-        JMXServiceURL url = new JMXServiceURL("rmi", null, rmiPort);
+        JMXServiceURL url = new JMXServiceURL("rmi", bindAddress, rmiPort);
 
         Map<String, Object> env = new HashMap<>();
 
@@ -733,6 +747,8 @@
             String[].class.getName(), String.class.getName()
         });
 
+        boolean useSocketFactory = bindAddress != null && !useSsl;
+
         if (useAuthentication) {
             if (loginConfigName != null) {
                 env.put("jmx.remote.x.login.config", loginConfigName);
@@ -757,7 +773,7 @@
             csf = new SslRMIClientSocketFactory();
             ssf = createSslRMIServerSocketFactory(
                     sslConfigFileName, enabledCipherSuites,
-                    enabledProtocols, sslNeedClientAuth);
+                    enabledProtocols, sslNeedClientAuth, bindAddress);
         }
 
         if (useSsl) {
@@ -767,6 +783,12 @@
                     ssf);
         }
 
+        if (useSocketFactory) {
+            ssf = new HostAwareSocketFactory(bindAddress);
+            env.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE,
+                    ssf);
+        }
+
         JMXConnectorServer connServer = null;
         try {
             connServer =
@@ -786,6 +808,10 @@
             registry =
                     new SingleEntryRegistry(port, csf, ssf,
                     "jmxrmi", exporter.firstExported);
+        } else if (useSocketFactory) {
+            registry =
+                    new SingleEntryRegistry(port, csf, ssf,
+                    "jmxrmi", exporter.firstExported);
         } else {
             registry =
                     new SingleEntryRegistry(port,
@@ -819,4 +845,172 @@
     private static final ClassLogger log =
         new ClassLogger(ConnectorBootstrap.class.getPackage().getName(),
                         "ConnectorBootstrap");
+
+    private static class HostAwareSocketFactory implements RMIServerSocketFactory {
+
+        private final String bindAddress;
+
+        private HostAwareSocketFactory(String bindAddress) {
+             this.bindAddress = bindAddress;
+        }
+
+        @Override
+        public ServerSocket createServerSocket(int port) throws IOException {
+            if (bindAddress == null) {
+                return new ServerSocket(port);
+            } else {
+                try {
+                    InetAddress addr = InetAddress.getByName(bindAddress);
+                    return new ServerSocket(port, 0, addr);
+                } catch (UnknownHostException e) {
+                    return new ServerSocket(port);
+                }
+            }
+        }
+    }
+
+    private static class HostAwareSslSocketFactory extends SslRMIServerSocketFactory {
+
+        private final String bindAddress;
+        private final String[] enabledCipherSuites;
+        private final String[] enabledProtocols;
+        private final boolean needClientAuth;
+        private final SSLContext context;
+
+        private HostAwareSslSocketFactory(String[] enabledCipherSuites,
+                                          String[] enabledProtocols,
+                                          boolean sslNeedClientAuth,
+                                          String bindAddress) throws IllegalArgumentException {
+            this(null, enabledCipherSuites, enabledProtocols, sslNeedClientAuth, bindAddress);
+        }
+
+        private HostAwareSslSocketFactory(SSLContext ctx,
+                                          String[] enabledCipherSuites,
+                                          String[] enabledProtocols,
+                                          boolean sslNeedClientAuth,
+                                          String bindAddress) throws IllegalArgumentException {
+            this.context = ctx;
+            this.bindAddress = bindAddress;
+            this.enabledProtocols = enabledProtocols;
+            this.enabledCipherSuites = enabledCipherSuites;
+            this.needClientAuth = sslNeedClientAuth;
+            checkValues(ctx, enabledCipherSuites, enabledProtocols);
+        }
+
+        @Override
+        public ServerSocket createServerSocket(int port) throws IOException {
+            if (bindAddress != null) {
+                try {
+                    InetAddress addr = InetAddress.getByName(bindAddress);
+                    return new SslServerSocket(port, 0, addr, context,
+                                               enabledCipherSuites, enabledProtocols, needClientAuth);
+                } catch (UnknownHostException e) {
+                    return new SslServerSocket(port, context,
+                                               enabledCipherSuites, enabledProtocols, needClientAuth);
+                }
+            } else {
+                return new SslServerSocket(port, context,
+                                           enabledCipherSuites, enabledProtocols, needClientAuth);
+            }
+        }
+
+        private static void checkValues(SSLContext context,
+                                        String[] enabledCipherSuites,
+                                        String[] enabledProtocols) throws IllegalArgumentException {
+            // Force the initialization of the default at construction time,
+            // rather than delaying it to the first time createServerSocket()
+            // is called.
+            //
+            final SSLSocketFactory sslSocketFactory =
+                    context == null ?
+                        (SSLSocketFactory)SSLSocketFactory.getDefault() : context.getSocketFactory();
+            SSLSocket sslSocket = null;
+            if (enabledCipherSuites != null || enabledProtocols != null) {
+                try {
+                    sslSocket = (SSLSocket) sslSocketFactory.createSocket();
+                } catch (Exception e) {
+                    final String msg = "Unable to check if the cipher suites " +
+                            "and protocols to enable are supported";
+                    throw (IllegalArgumentException)
+                    new IllegalArgumentException(msg).initCause(e);
+                }
+            }
+
+            // Check if all the cipher suites and protocol versions to enable
+            // are supported by the underlying SSL/TLS implementation and if
+            // true create lists from arrays.
+            //
+            if (enabledCipherSuites != null) {
+                sslSocket.setEnabledCipherSuites(enabledCipherSuites);
+            }
+            if (enabledProtocols != null) {
+                sslSocket.setEnabledProtocols(enabledProtocols);
+            }
+        }
+    }
+
+    private static class SslServerSocket extends ServerSocket {
+
+        private static SSLSocketFactory defaultSSLSocketFactory;
+        private final String[] enabledCipherSuites;
+        private final String[] enabledProtocols;
+        private final boolean needClientAuth;
+        private final SSLContext context;
+
+        private SslServerSocket(int port,
+                                SSLContext ctx,
+                                String[] enabledCipherSuites,
+                                String[] enabledProtocols,
+                                boolean needClientAuth) throws IOException {
+            super(port);
+            this.enabledProtocols = enabledProtocols;
+            this.enabledCipherSuites = enabledCipherSuites;
+            this.needClientAuth = needClientAuth;
+            this.context = ctx;
+        }
+
+        private SslServerSocket(int port,
+                                int backlog,
+                                InetAddress bindAddr,
+                                SSLContext ctx,
+                                String[] enabledCipherSuites,
+                                String[] enabledProtocols,
+                                boolean needClientAuth) throws IOException {
+            super(port, backlog, bindAddr);
+            this.enabledProtocols = enabledProtocols;
+            this.enabledCipherSuites = enabledCipherSuites;
+            this.needClientAuth = needClientAuth;
+            this.context = ctx;
+        }
+
+        @Override
+        public Socket accept() throws IOException {
+            final SSLSocketFactory sslSocketFactory =
+                    context == null ?
+                        getDefaultSSLSocketFactory() : context.getSocketFactory();
+            Socket socket = super.accept();
+            SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket(
+                    socket, socket.getInetAddress().getHostName(),
+                    socket.getPort(), true);
+            sslSocket.setUseClientMode(false);
+            if (enabledCipherSuites != null) {
+                sslSocket.setEnabledCipherSuites(enabledCipherSuites);
+            }
+            if (enabledProtocols != null) {
+                sslSocket.setEnabledProtocols(enabledProtocols);
+            }
+            sslSocket.setNeedClientAuth(needClientAuth);
+            return sslSocket;
+        }
+
+        private static synchronized SSLSocketFactory getDefaultSSLSocketFactory() {
+            if (defaultSSLSocketFactory == null) {
+                defaultSSLSocketFactory = (SSLSocketFactory)SSLSocketFactory.getDefault();
+                return defaultSSLSocketFactory;
+            } else {
+                return defaultSSLSocketFactory;
+            }
+        }
+
+    }
 }
diff --git a/jdk/src/share/classes/sun/management/resources/agent_zh_TW.properties b/jdk/src/share/classes/sun/management/resources/agent_zh_TW.properties
index e75cb6d..5b2208b 100644
--- a/jdk/src/share/classes/sun/management/resources/agent_zh_TW.properties
+++ b/jdk/src/share/classes/sun/management/resources/agent_zh_TW.properties
@@ -1,6 +1,6 @@
 #
 #
-# Copyright (c) 2004, 2013, 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
@@ -31,10 +31,10 @@
 agent.err.exception                = \u4EE3\u7406\u7A0B\u5F0F\u767C\u751F\u7570\u5E38 
 agent.err.warning		   = \u8B66\u544A
 
-agent.err.configfile.notfound      = \u627E\u4E0D\u5230\u914D\u7F6E\u6A94\u6848
-agent.err.configfile.failed        = \u7121\u6CD5\u8B80\u53D6\u914D\u7F6E\u6A94\u6848
-agent.err.configfile.closed.failed = \u7121\u6CD5\u95DC\u9589\u914D\u7F6E\u6A94\u6848
-agent.err.configfile.access.denied = \u5B58\u53D6\u914D\u7F6E\u6A94\u6848\u906D\u5230\u62D2\u7D55
+agent.err.configfile.notfound      = \u627E\u4E0D\u5230\u7D44\u614B\u6A94\u6848
+agent.err.configfile.failed        = \u7121\u6CD5\u8B80\u53D6\u7D44\u614B\u6A94\u6848
+agent.err.configfile.closed.failed = \u7121\u6CD5\u95DC\u9589\u7D44\u614B\u6A94\u6848
+agent.err.configfile.access.denied = \u5B58\u53D6\u7D44\u614B\u6A94\u6848\u906D\u5230\u62D2\u7D55
 
 agent.err.exportaddress.failed	   = \u5C07 JMX \u9023\u63A5\u5668\u4F4D\u5740\u532F\u51FA\u81F3\u8A2D\u5099\u7DE9\u885D\u5340\u5931\u6557
 
diff --git a/jdk/src/share/classes/sun/misc/JavaSecurityProtectionDomainAccess.java b/jdk/src/share/classes/sun/misc/JavaSecurityProtectionDomainAccess.java
index 95560ff..3567f35 100644
--- a/jdk/src/share/classes/sun/misc/JavaSecurityProtectionDomainAccess.java
+++ b/jdk/src/share/classes/sun/misc/JavaSecurityProtectionDomainAccess.java
@@ -36,4 +36,9 @@
      * Returns the ProtectionDomainCache.
      */
     ProtectionDomainCache getProtectionDomainCache();
+
+    /**
+     * Returns the staticPermissions field of the specified object
+     */
+    boolean getStaticPermissionsField(ProtectionDomain pd);
 }
diff --git a/jdk/src/share/classes/sun/nio/ch/Util.java b/jdk/src/share/classes/sun/nio/ch/Util.java
index dca91d6..3c61f83 100644
--- a/jdk/src/share/classes/sun/nio/ch/Util.java
+++ b/jdk/src/share/classes/sun/nio/ch/Util.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, 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
@@ -47,6 +47,9 @@
     // The number of temp buffers in our pool
     private static final int TEMP_BUF_POOL_SIZE = IOUtil.IOV_MAX;
 
+    // The max size allowed for a cached temp buffer, in bytes
+    private static final long MAX_CACHED_BUFFER_SIZE = getMaxCachedBufferSize();
+
     // Per-thread cache of temporary direct buffers
     private static ThreadLocal<BufferCache> bufferCache =
         new ThreadLocal<BufferCache>()
@@ -58,6 +61,52 @@
     };
 
     /**
+     * Returns the max size allowed for a cached temp buffers, in
+     * bytes. It defaults to Long.MAX_VALUE. It can be set with the
+     * jdk.nio.maxCachedBufferSize property. Even though
+     * ByteBuffer.capacity() returns an int, we're using a long here
+     * for potential future-proofing.
+     */
+    private static long getMaxCachedBufferSize() {
+        String s = java.security.AccessController.doPrivileged(
+            new PrivilegedAction<String>() {
+                @Override
+                public String run() {
+                    return System.getProperty("jdk.nio.maxCachedBufferSize");
+                }
+            });
+        if (s != null) {
+            try {
+                long m = Long.parseLong(s);
+                if (m >= 0) {
+                    return m;
+                } else {
+                    // if it's negative, ignore the system property
+                }
+            } catch (NumberFormatException e) {
+                // if the string is not well formed, ignore the system property
+            }
+        }
+        return Long.MAX_VALUE;
+    }
+
+    /**
+     * Returns true if a buffer of this size is too large to be
+     * added to the buffer cache, false otherwise.
+     */
+    private static boolean isBufferTooLarge(int size) {
+        return size > MAX_CACHED_BUFFER_SIZE;
+    }
+
+    /**
+     * Returns true if the buffer is too large to be added to the
+     * buffer cache, false otherwise.
+     */
+    private static boolean isBufferTooLarge(ByteBuffer buf) {
+        return isBufferTooLarge(buf.capacity());
+    }
+
+    /**
      * A simple cache of direct buffers.
      */
     private static class BufferCache {
@@ -83,6 +132,9 @@
          * size (or null if no suitable buffer is found).
          */
         ByteBuffer get(int size) {
+            // Don't call this if the buffer would be too large.
+            assert !isBufferTooLarge(size);
+
             if (count == 0)
                 return null;  // cache is empty
 
@@ -120,6 +172,9 @@
         }
 
         boolean offerFirst(ByteBuffer buf) {
+            // Don't call this if the buffer is too large.
+            assert !isBufferTooLarge(buf);
+
             if (count >= TEMP_BUF_POOL_SIZE) {
                 return false;
             } else {
@@ -131,6 +186,9 @@
         }
 
         boolean offerLast(ByteBuffer buf) {
+            // Don't call this if the buffer is too large.
+            assert !isBufferTooLarge(buf);
+
             if (count >= TEMP_BUF_POOL_SIZE) {
                 return false;
             } else {
@@ -159,6 +217,15 @@
      * Returns a temporary buffer of at least the given size
      */
     public static ByteBuffer getTemporaryDirectBuffer(int size) {
+        // If a buffer of this size is too large for the cache, there
+        // should not be a buffer in the cache that is at least as
+        // large. So we'll just create a new one. Also, we don't have
+        // to remove the buffer from the cache (as this method does
+        // below) given that we won't put the new buffer in the cache.
+        if (isBufferTooLarge(size)) {
+            return ByteBuffer.allocateDirect(size);
+        }
+
         BufferCache cache = bufferCache.get();
         ByteBuffer buf = cache.get(size);
         if (buf != null) {
@@ -188,6 +255,13 @@
      * likely to be returned by a subsequent call to getTemporaryDirectBuffer.
      */
     static void offerFirstTemporaryDirectBuffer(ByteBuffer buf) {
+        // If the buffer is too large for the cache we don't have to
+        // check the cache. We'll just free it.
+        if (isBufferTooLarge(buf)) {
+            free(buf);
+            return;
+        }
+
         assert buf != null;
         BufferCache cache = bufferCache.get();
         if (!cache.offerFirst(buf)) {
@@ -203,6 +277,13 @@
      * cache in same order that they were obtained.
      */
     static void offerLastTemporaryDirectBuffer(ByteBuffer buf) {
+        // If the buffer is too large for the cache we don't have to
+        // check the cache. We'll just free it.
+        if (isBufferTooLarge(buf)) {
+            free(buf);
+            return;
+        }
+
         assert buf != null;
         BufferCache cache = bufferCache.get();
         if (!cache.offerLast(buf)) {
diff --git a/jdk/src/share/classes/sun/rmi/server/resources/rmid_zh_TW.properties b/jdk/src/share/classes/sun/rmi/server/resources/rmid_zh_TW.properties
index 2905dc4..1a32abc 100644
--- a/jdk/src/share/classes/sun/rmi/server/resources/rmid_zh_TW.properties
+++ b/jdk/src/share/classes/sun/rmi/server/resources/rmid_zh_TW.properties
@@ -1,6 +1,6 @@
 #
 #
-# 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
@@ -71,7 +71,7 @@
 # "Activation.main", "sun.rmi.activation.execPolicy", "ExecPermission" and 
 # "ExecOptionPermission" should not be translated, since they refer to
 # class/permission names.
-rmid.exec.perms.inadequate=Activation.main: \u8B66\u544A: sun.rmi.activation.execPolicy \u7CFB\u7D71\n\u5C6C\u6027\u672A\u6307\u5B9A\uFF0C\u4E26\u4E14\u672A\u6388\u4E88 ExecPermissions/ExecOptionPermissions; \n\u5F8C\u7E8C\u7684\u555F\u52D5\u5617\u8A66\u53EF\u80FD\u6703\u56E0\u70BA\u672A\u6210\u529F\u7684\nExecPermission/ExecOptionPermission \u6B0A\u9650\u6AA2\u67E5\u800C\u5931\u6557\u3002\u5982\u9700\n\u95DC\u65BC\u5982\u4F55\u914D\u7F6E rmid \u5B89\u5168\u7684\u8AAA\u660E\u6587\u4EF6\uFF0C\u8ACB\u53C3\u8003:\n\nhttp://java.sun.com/j2se/1.4/docs/tooldocs/solaris/rmid.html\nhttp://java.sun.com/j2se/1.4/docs/tooldocs/win32/rmid.html\n
+rmid.exec.perms.inadequate=Activation.main: \u8B66\u544A: sun.rmi.activation.execPolicy \u7CFB\u7D71\n\u5C6C\u6027\u672A\u6307\u5B9A\uFF0C\u4E26\u4E14\u672A\u6388\u4E88 ExecPermissions/ExecOptionPermissions; \n\u5F8C\u7E8C\u7684\u555F\u52D5\u5617\u8A66\u53EF\u80FD\u6703\u56E0\u70BA\u672A\u6210\u529F\u7684\nExecPermission/ExecOptionPermission \u6B0A\u9650\u6AA2\u67E5\u800C\u5931\u6557\u3002\u5982\u9700\n\u95DC\u65BC\u5982\u4F55\u8A2D\u5B9A rmid \u5B89\u5168\u7684\u8AAA\u660E\u6587\u4EF6\uFF0C\u8ACB\u53C3\u8003:\n\nhttp://java.sun.com/j2se/1.4/docs/tooldocs/solaris/rmid.html\nhttp://java.sun.com/j2se/1.4/docs/tooldocs/win32/rmid.html\n
 
 # "rmid", "-port", "-log", "-stop", "-C" and "-J" should not be translated,
 # because they are syntax
diff --git a/jdk/src/share/classes/sun/rmi/transport/DGCAckHandler.java b/jdk/src/share/classes/sun/rmi/transport/DGCAckHandler.java
index 7f70440..18e9ec0 100644
--- a/jdk/src/share/classes/sun/rmi/transport/DGCAckHandler.java
+++ b/jdk/src/share/classes/sun/rmi/transport/DGCAckHandler.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2012, 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
@@ -118,6 +118,9 @@
         if (objList != null && task == null) {
             task = scheduler.schedule(new Runnable() {
                 public void run() {
+                    if (id != null) {
+                        idTable.remove(id);
+                    }
                     release();
                 }
             }, dgcAckTimeout, TimeUnit.MILLISECONDS);
diff --git a/jdk/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java b/jdk/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java
index ca4d2d3..25fc78c 100644
--- a/jdk/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java
+++ b/jdk/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java
@@ -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
@@ -383,19 +383,19 @@
 
             // decode secret key
             } else {
-                SecretKeyFactory sKeyFactory =
-                    SecretKeyFactory.getInstance(keyAlgo);
                 byte[] keyBytes = in.getOctetString();
                 SecretKeySpec secretKeySpec =
                     new SecretKeySpec(keyBytes, keyAlgo);
 
                 // Special handling required for PBE: needs a PBEKeySpec
                 if (keyAlgo.startsWith("PBE")) {
+                    SecretKeyFactory sKeyFactory =
+                        SecretKeyFactory.getInstance(keyAlgo);
                     KeySpec pbeKeySpec =
                         sKeyFactory.getKeySpec(secretKeySpec, PBEKeySpec.class);
                     key = sKeyFactory.generateSecret(pbeKeySpec);
                 } else {
-                    key = sKeyFactory.generateSecret(secretKeySpec);
+                    key = secretKeySpec;
                 }
 
                 if (debug != null) {
diff --git a/jdk/src/share/classes/sun/security/provider/certpath/AdaptableX509CertSelector.java b/jdk/src/share/classes/sun/security/provider/certpath/AdaptableX509CertSelector.java
index db36c0e..0ad5387 100644
--- a/jdk/src/share/classes/sun/security/provider/certpath/AdaptableX509CertSelector.java
+++ b/jdk/src/share/classes/sun/security/provider/certpath/AdaptableX509CertSelector.java
@@ -36,9 +36,7 @@
 
 import sun.security.util.Debug;
 import sun.security.util.DerInputStream;
-import sun.security.util.DerOutputStream;
 import sun.security.x509.SerialNumber;
-import sun.security.x509.KeyIdentifier;
 import sun.security.x509.AuthorityKeyIdentifierExtension;
 
 /**
@@ -131,13 +129,7 @@
         serial = null;
 
         if (ext != null) {
-            KeyIdentifier akid = (KeyIdentifier)ext.get(
-                AuthorityKeyIdentifierExtension.KEY_ID);
-            if (akid != null) {
-                DerOutputStream derout = new DerOutputStream();
-                derout.putOctetString(akid.getIdentifier());
-                ski = derout.toByteArray();
-            }
+            ski = ext.getEncodedKeyIdentifier();
             SerialNumber asn = (SerialNumber)ext.get(
                 AuthorityKeyIdentifierExtension.SERIAL_NUMBER);
             if (asn != null) {
diff --git a/jdk/src/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java b/jdk/src/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java
index 7b1076e..086e73f 100644
--- a/jdk/src/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java
+++ b/jdk/src/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java
@@ -33,7 +33,6 @@
 import java.util.*;
 
 import sun.security.util.Debug;
-import sun.security.util.DerOutputStream;
 import static sun.security.x509.PKIXExtensions.*;
 import sun.security.x509.*;
 
@@ -608,12 +607,9 @@
             AuthorityKeyIdentifierExtension akidext =
                                             crlImpl.getAuthKeyIdExtension();
             if (akidext != null) {
-                KeyIdentifier akid = (KeyIdentifier)akidext.get(
-                        AuthorityKeyIdentifierExtension.KEY_ID);
-                if (akid != null) {
-                    DerOutputStream derout = new DerOutputStream();
-                    derout.putOctetString(akid.getIdentifier());
-                    certSel.setSubjectKeyIdentifier(derout.toByteArray());
+                byte[] kid = akidext.getEncodedKeyIdentifier();
+                if (kid != null) {
+                    certSel.setSubjectKeyIdentifier(kid);
                 }
 
                 SerialNumber asn = (SerialNumber)akidext.get(
diff --git a/jdk/src/share/classes/sun/security/provider/certpath/ForwardBuilder.java b/jdk/src/share/classes/sun/security/provider/certpath/ForwardBuilder.java
index 7f30d3b..3c86d62 100644
--- a/jdk/src/share/classes/sun/security/provider/certpath/ForwardBuilder.java
+++ b/jdk/src/share/classes/sun/security/provider/certpath/ForwardBuilder.java
@@ -46,9 +46,10 @@
 import sun.security.util.Debug;
 import sun.security.x509.AccessDescription;
 import sun.security.x509.AuthorityInfoAccessExtension;
+import sun.security.x509.AuthorityKeyIdentifierExtension;
 import static sun.security.x509.PKIXExtensions.*;
 import sun.security.x509.X500Name;
-import sun.security.x509.AuthorityKeyIdentifierExtension;
+import sun.security.x509.X509CertImpl;
 
 /**
  * This class represents a forward builder, which is able to retrieve
@@ -69,7 +70,6 @@
     private AdaptableX509CertSelector caSelector;
     private X509CertSelector caTargetSelector;
     TrustAnchor trustAnchor;
-    private Comparator<X509Certificate> comparator;
     private boolean searchAllCertStores = true;
 
     /**
@@ -93,7 +93,6 @@
                 trustedSubjectDNs.add(anchor.getCA());
             }
         }
-        comparator = new PKIXCertComparator(trustedSubjectDNs);
         this.searchAllCertStores = searchAllCertStores;
     }
 
@@ -122,6 +121,8 @@
          * As each cert is added, it is sorted based on the PKIXCertComparator
          * algorithm.
          */
+        Comparator<X509Certificate> comparator =
+            new PKIXCertComparator(trustedSubjectDNs, currState.cert);
         Set<X509Certificate> certs = new TreeSet<>(comparator);
 
         /*
@@ -265,14 +266,6 @@
                 (caSelector, currentState.subjectNamesTraversed);
 
             /*
-             * Facilitate certification path construction with authority
-             * key identifier and subject key identifier.
-             */
-            AuthorityKeyIdentifierExtension akidext =
-                    currentState.cert.getAuthorityKeyIdentifierExtension();
-            caSelector.setSkiAndSerialNumber(akidext);
-
-            /*
              * check the validity period
              */
             caSelector.setValidityPeriod(currentState.cert.getNotBefore(),
@@ -404,41 +397,68 @@
      *
      * Preference order for current cert:
      *
-     * 1) Issuer matches a trusted subject
+     * 1) The key identifier of an AKID extension (if present) in the
+     *    previous certificate matches the key identifier in the SKID extension
+     *
+     * 2) Issuer matches a trusted subject
      *    Issuer: ou=D,ou=C,o=B,c=A
      *
-     * 2) Issuer is a descendant of a trusted subject (in order of
+     * 3) Issuer is a descendant of a trusted subject (in order of
      *    number of links to the trusted subject)
      *    a) Issuer: ou=E,ou=D,ou=C,o=B,c=A        [links=1]
      *    b) Issuer: ou=F,ou=E,ou=D,ou=C,ou=B,c=A  [links=2]
      *
-     * 3) Issuer is an ancestor of a trusted subject (in order of number of
+     * 4) Issuer is an ancestor of a trusted subject (in order of number of
      *    links to the trusted subject)
      *    a) Issuer: ou=C,o=B,c=A [links=1]
      *    b) Issuer: o=B,c=A      [links=2]
      *
-     * 4) Issuer is in the same namespace as a trusted subject (in order of
+     * 5) Issuer is in the same namespace as a trusted subject (in order of
      *    number of links to the trusted subject)
      *    a) Issuer: ou=G,ou=C,o=B,c=A  [links=2]
      *    b) Issuer: ou=H,o=B,c=A       [links=3]
      *
-     * 5) Issuer is an ancestor of certificate subject (in order of number
+     * 6) Issuer is an ancestor of certificate subject (in order of number
      *    of links to the certificate subject)
      *    a) Issuer:  ou=K,o=J,c=A
      *       Subject: ou=L,ou=K,o=J,c=A
      *    b) Issuer:  o=J,c=A
      *       Subject: ou=L,ou=K,0=J,c=A
      *
-     * 6) Any other certificates
+     * 7) Any other certificates
      */
     static class PKIXCertComparator implements Comparator<X509Certificate> {
 
-        final static String METHOD_NME = "PKIXCertComparator.compare()";
+        static final String METHOD_NME = "PKIXCertComparator.compare()";
 
         private final Set<X500Principal> trustedSubjectDNs;
+        private final X509CertSelector certSkidSelector;
 
-        PKIXCertComparator(Set<X500Principal> trustedSubjectDNs) {
+        PKIXCertComparator(Set<X500Principal> trustedSubjectDNs,
+                           X509CertImpl previousCert) throws IOException {
             this.trustedSubjectDNs = trustedSubjectDNs;
+            this.certSkidSelector = getSelector(previousCert);
+        }
+
+        /**
+         * Returns an X509CertSelector for matching on the authority key
+         * identifier, or null if not applicable.
+         */
+        private X509CertSelector getSelector(X509CertImpl previousCert)
+            throws IOException {
+            if (previousCert != null) {
+                AuthorityKeyIdentifierExtension akidExt =
+                    previousCert.getAuthorityKeyIdentifierExtension();
+                if (akidExt != null) {
+                    byte[] skid = akidExt.getEncodedKeyIdentifier();
+                    if (skid != null) {
+                        X509CertSelector selector = new X509CertSelector();
+                        selector.setSubjectKeyIdentifier(skid);
+                        return selector;
+                    }
+                }
+            }
+            return null;
         }
 
         /**
@@ -462,6 +482,16 @@
             // if certs are the same, return 0
             if (oCert1.equals(oCert2)) return 0;
 
+            // If akid/skid match then it is preferable
+            if (certSkidSelector != null) {
+                if (certSkidSelector.match(oCert1)) {
+                    return -1;
+                }
+                if (certSkidSelector.match(oCert2)) {
+                    return 1;
+                }
+            }
+
             X500Principal cIssuer1 = oCert1.getIssuerX500Principal();
             X500Principal cIssuer2 = oCert2.getIssuerX500Principal();
             X500Name cIssuer1Name = X500Name.asX500Name(cIssuer1);
diff --git a/jdk/src/share/classes/sun/security/ssl/HandshakeMessage.java b/jdk/src/share/classes/sun/security/ssl/HandshakeMessage.java
index e921ea0..8ecaf78 100644
--- a/jdk/src/share/classes/sun/security/ssl/HandshakeMessage.java
+++ b/jdk/src/share/classes/sun/security/ssl/HandshakeMessage.java
@@ -812,8 +812,9 @@
             if (!localSupportedSignAlgs.contains(
                     preferableSignatureAlgorithm)) {
                 throw new SSLHandshakeException(
-                        "Unsupported SignatureAndHashAlgorithm in " +
-                        "ServerKeyExchange message");
+                    "Unsupported SignatureAndHashAlgorithm in " +
+                    "ServerKeyExchange message: " +
+                    preferableSignatureAlgorithm);
             }
         } else {
             this.preferableSignatureAlgorithm = null;
@@ -846,7 +847,8 @@
                         sig = RSASignature.getInstance();
                         break;
                     default:
-                        throw new SSLKeyException("neither an RSA or a DSA key");
+                        throw new SSLKeyException(
+                            "neither an RSA or a DSA key: " + algorithm);
                 }
         }
 
@@ -1096,7 +1098,8 @@
                     preferableSignatureAlgorithm)) {
                 throw new SSLHandshakeException(
                         "Unsupported SignatureAndHashAlgorithm in " +
-                        "ServerKeyExchange message");
+                        "ServerKeyExchange message: " +
+                        preferableSignatureAlgorithm);
             }
         }
 
@@ -1136,7 +1139,8 @@
                 case "RSA":
                     return RSASignature.getInstance();
                 default:
-                    throw new NoSuchAlgorithmException("neither an RSA or a EC key");
+                    throw new NoSuchAlgorithmException(
+                        "neither an RSA or a EC key : " + keyAlgorithm);
             }
     }
 
@@ -1343,7 +1347,8 @@
             algorithmsLen = input.getInt16();
             if (algorithmsLen < 2) {
                 throw new SSLProtocolException(
-                        "Invalid supported_signature_algorithms field");
+                    "Invalid supported_signature_algorithms field: " +
+                    algorithmsLen);
             }
 
             algorithms = new ArrayList<SignatureAndHashAlgorithm>();
@@ -1362,7 +1367,8 @@
 
             if (remains != 0) {
                 throw new SSLProtocolException(
-                        "Invalid supported_signature_algorithms field");
+                    "Invalid supported_signature_algorithms field. remains: " +
+                    remains);
             }
         } else {
             algorithms = new ArrayList<SignatureAndHashAlgorithm>();
@@ -1379,7 +1385,8 @@
         }
 
         if (len != 0) {
-            throw new SSLProtocolException("Bad CertificateRequest DN length");
+            throw new SSLProtocolException(
+                "Bad CertificateRequest DN length: " + len);
         }
 
         authorities = v.toArray(new DistinguishedName[v.size()]);
@@ -1609,8 +1616,8 @@
             if (!localSupportedSignAlgs.contains(
                     preferableSignatureAlgorithm)) {
                 throw new SSLHandshakeException(
-                        "Unsupported SignatureAndHashAlgorithm in " +
-                        "CertificateVerify message");
+                    "Unsupported SignatureAndHashAlgorithm in " +
+                    "CertificateVerify message: " + preferableSignatureAlgorithm);
             }
         }
 
@@ -1977,7 +1984,8 @@
                 SecretKey prfKey = kg.generateKey();
                 if ("RAW".equals(prfKey.getFormat()) == false) {
                     throw new ProviderException(
-                        "Invalid PRF output, format must be RAW");
+                        "Invalid PRF output, format must be RAW. " +
+                        "Format received: " + prfKey.getFormat());
                 }
                 byte[] finished = prfKey.getEncoded();
                 return finished;
diff --git a/jdk/src/share/classes/sun/security/ssl/RSAClientKeyExchange.java b/jdk/src/share/classes/sun/security/ssl/RSAClientKeyExchange.java
index 038cf2a..783146c 100644
--- a/jdk/src/share/classes/sun/security/ssl/RSAClientKeyExchange.java
+++ b/jdk/src/share/classes/sun/security/ssl/RSAClientKeyExchange.java
@@ -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
@@ -67,7 +67,8 @@
             ProtocolVersion maxVersion,
             SecureRandom generator, PublicKey publicKey) throws IOException {
         if (publicKey.getAlgorithm().equals("RSA") == false) {
-            throw new SSLKeyException("Public key not of type RSA");
+            throw new SSLKeyException("Public key not of type RSA: " +
+                publicKey.getAlgorithm());
         }
         this.protocolVersion = protocolVersion;
 
@@ -98,7 +99,8 @@
             int messageSize, PrivateKey privateKey) throws IOException {
 
         if (privateKey.getAlgorithm().equals("RSA") == false) {
-            throw new SSLKeyException("Private key not of type RSA");
+            throw new SSLKeyException("Private key not of type RSA: " +
+                 privateKey.getAlgorithm());
         }
 
         if (currentVersion.v >= ProtocolVersion.TLS10.v) {
@@ -113,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 {
@@ -132,17 +155,14 @@
                                 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);
             }
         } catch (InvalidKeyException ibk) {
             // the message is too big to process with RSA
-            throw new SSLProtocolException(
-                "Unable to process PreMasterSecret, may be too big");
+            throw new SSLException(
+                "Unable to process PreMasterSecret", ibk);
         } catch (Exception e) {
             // unlikely to happen, otherwise, must be a provider exception
             if (debug != null && Debug.isOn("handshake")) {
diff --git a/jdk/src/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java b/jdk/src/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java
index c9b31cd..256bdf2 100644
--- a/jdk/src/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java
+++ b/jdk/src/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java
@@ -413,12 +413,16 @@
                     "SHA1withECDSA",        --p);
 
             if (Security.getProvider("SunMSCAPI") == null) {
+                supports(HashAlgorithm.SHA224,      SignatureAlgorithm.DSA,
+                        "SHA224withDSA",        --p);
                 supports(HashAlgorithm.SHA224,      SignatureAlgorithm.RSA,
                         "SHA224withRSA",        --p);
                 supports(HashAlgorithm.SHA224,      SignatureAlgorithm.ECDSA,
                         "SHA224withECDSA",      --p);
             }
 
+            supports(HashAlgorithm.SHA256,      SignatureAlgorithm.DSA,
+                    "SHA256withDSA",        --p);
             supports(HashAlgorithm.SHA256,      SignatureAlgorithm.RSA,
                     "SHA256withRSA",        --p);
             supports(HashAlgorithm.SHA256,      SignatureAlgorithm.ECDSA,
diff --git a/jdk/src/share/classes/sun/security/tools/jarsigner/Resources_ja.java b/jdk/src/share/classes/sun/security/tools/jarsigner/Resources_ja.java
index 7588a64..b471210 100644
--- a/jdk/src/share/classes/sun/security/tools/jarsigner/Resources_ja.java
+++ b/jdk/src/share/classes/sun/security/tools/jarsigner/Resources_ja.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2014, 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
@@ -88,6 +88,8 @@
                 "[-tsacert <alias>]          \u30BF\u30A4\u30E0\u30B9\u30BF\u30F3\u30D7\u5C40\u306E\u516C\u958B\u9375\u8A3C\u660E\u66F8"},
         {".tsapolicyid.tsapolicyid.for.Timestamping.Authority",
                 "[-tsapolicyid <oid>]        \u30BF\u30A4\u30E0\u30B9\u30BF\u30F3\u30D7\u5C40\u306ETSAPolicyID"},
+        {".tsadigestalg.algorithm.of.digest.data.in.timestamping.request",
+                "[-tsadigestalg <algorithm>] \u30BF\u30A4\u30E0\u30B9\u30BF\u30F3\u30D7\u30FB\u30EA\u30AF\u30A8\u30B9\u30C8\u306E\u30C0\u30A4\u30B8\u30A7\u30B9\u30C8\u30FB\u30C7\u30FC\u30BF\u306E\u30A2\u30EB\u30B4\u30EA\u30BA\u30E0"},
         {".altsigner.class.class.name.of.an.alternative.signing.mechanism",
                 "[-altsigner <class>]        \u4EE3\u66FF\u7F72\u540D\u30E1\u30AB\u30CB\u30BA\u30E0\u306E\u30AF\u30E9\u30B9\u540D"},
         {".altsignerpath.pathlist.location.of.an.alternative.signing.mechanism",
diff --git a/jdk/src/share/classes/sun/security/tools/jarsigner/Resources_zh_CN.java b/jdk/src/share/classes/sun/security/tools/jarsigner/Resources_zh_CN.java
index bdec2e2..76f88c1 100644
--- a/jdk/src/share/classes/sun/security/tools/jarsigner/Resources_zh_CN.java
+++ b/jdk/src/share/classes/sun/security/tools/jarsigner/Resources_zh_CN.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2014, 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
@@ -88,6 +88,8 @@
                 "[-tsacert <\u522B\u540D>]           \u65F6\u95F4\u6233\u9881\u53D1\u673A\u6784\u7684\u516C\u5171\u5BC6\u94A5\u8BC1\u4E66"},
         {".tsapolicyid.tsapolicyid.for.Timestamping.Authority",
                 "[-tsapolicyid <oid>]        \u65F6\u95F4\u6233\u9881\u53D1\u673A\u6784\u7684 TSAPolicyID"},
+        {".tsadigestalg.algorithm.of.digest.data.in.timestamping.request",
+                "[-tsadigestalg <\u7B97\u6CD5>]      \u65F6\u95F4\u6233\u8BF7\u6C42\u4E2D\u7684\u6458\u8981\u6570\u636E\u7684\u7B97\u6CD5"},
         {".altsigner.class.class.name.of.an.alternative.signing.mechanism",
                 "[-altsigner <\u7C7B>]           \u66FF\u4EE3\u7684\u7B7E\u540D\u673A\u5236\u7684\u7C7B\u540D"},
         {".altsignerpath.pathlist.location.of.an.alternative.signing.mechanism",
diff --git a/jdk/src/share/classes/sun/security/tools/keytool/Resources_zh_TW.java b/jdk/src/share/classes/sun/security/tools/keytool/Resources_zh_TW.java
index 1f0bb68..2e37101 100644
--- a/jdk/src/share/classes/sun/security/tools/keytool/Resources_zh_TW.java
+++ b/jdk/src/share/classes/sun/security/tools/keytool/Resources_zh_TW.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2014, 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
@@ -381,9 +381,9 @@
                 "\u6C92\u6709\u4F86\u81EA SSL \u4F3A\u670D\u5668\u7684\u6191\u8B49"},
 
         {".The.integrity.of.the.information.stored.in.your.keystore.",
-            "* \u5C1A\u672A\u9A57\u8B49\u5132\u5B58\u65BC\u91D1\u9470\u5132\u5B58\u5EAB\u4E2D\u8CC7\u8A0A  *\n* \u7684\u5B8C\u6574\u6027\uFF01\u82E5\u8981\u9A57\u8B49\u5176\u5B8C\u6574\u6027\uFF0C*\n* \u60A8\u5FC5\u9808\u63D0\u4F9B\u60A8\u7684\u91D1\u9470\u5132\u5B58\u5EAB\u5BC6\u78BC\u3002                  *"},
+            "* \u5C1A\u672A\u9A57\u8B49\u5132\u5B58\u65BC\u91D1\u9470\u5132\u5B58\u5EAB\u4E2D\u8CC7\u8A0A  *\n* \u7684\u5B8C\u6574\u6027\uFF01\u82E5\u8981\u9A57\u8B49\u5176\u5B8C\u6574\u6027\uFF0C    *\n* \u60A8\u5FC5\u9808\u63D0\u4F9B\u60A8\u7684\u91D1\u9470\u5132\u5B58\u5EAB\u5BC6\u78BC\u3002  *"},
         {".The.integrity.of.the.information.stored.in.the.srckeystore.",
-            "* \u5C1A\u672A\u9A57\u8B49\u5132\u5B58\u65BC srckeystore \u4E2D\u8CC7\u8A0A*\n* \u7684\u5B8C\u6574\u6027\uFF01\u82E5\u8981\u9A57\u8B49\u5176\u5B8C\u6574\u6027\uFF0C\u60A8\u5FC5\u9808 *\n* \u63D0\u4F9B srckeystore \u5BC6\u78BC\u3002          *"},
+            "* \u5C1A\u672A\u9A57\u8B49\u5132\u5B58\u65BC srckeystore \u4E2D\u8CC7\u8A0A  *\n* \u7684\u5B8C\u6574\u6027\uFF01\u82E5\u8981\u9A57\u8B49\u5176\u5B8C\u6574\u6027\uFF0C\u60A8\u5FC5\u9808 *\n* \u63D0\u4F9B srckeystore \u5BC6\u78BC\u3002            *"},
 
         {"Certificate.reply.does.not.contain.public.key.for.alias.",
                 "\u6191\u8B49\u56DE\u8986\u4E26\u672A\u5305\u542B <{0}> \u7684\u516C\u958B\u91D1\u9470"},
diff --git a/jdk/src/share/classes/sun/security/tools/policytool/Resources_zh_TW.java b/jdk/src/share/classes/sun/security/tools/policytool/Resources_zh_TW.java
index a0c60ca..e96ad87 100644
--- a/jdk/src/share/classes/sun/security/tools/policytool/Resources_zh_TW.java
+++ b/jdk/src/share/classes/sun/security/tools/policytool/Resources_zh_TW.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, 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
@@ -35,7 +35,7 @@
     private static final Object[][] contents = {
         {"NEWLINE", "\n"},
         {"Warning.A.public.key.for.alias.signers.i.does.not.exist.Make.sure.a.KeyStore.is.properly.configured.",
-                "\u8B66\u544A: \u5225\u540D {0} \u7684\u516C\u958B\u91D1\u9470\u4E0D\u5B58\u5728\u3002\u8ACB\u78BA\u5B9A\u91D1\u9470\u5132\u5B58\u5EAB\u914D\u7F6E\u6B63\u78BA\u3002"},
+                "\u8B66\u544A: \u5225\u540D {0} \u7684\u516C\u958B\u91D1\u9470\u4E0D\u5B58\u5728\u3002\u8ACB\u78BA\u5B9A\u91D1\u9470\u5132\u5B58\u5EAB\u8A2D\u5B9A\u6B63\u78BA\u3002"},
         {"Warning.Class.not.found.class", "\u8B66\u544A: \u627E\u4E0D\u5230\u985E\u5225 {0}"},
         {"Warning.Invalid.argument.s.for.constructor.arg",
                 "\u8B66\u544A: \u7121\u6548\u7684\u5EFA\u69CB\u5B50\u5F15\u6578: {0}"},
diff --git a/jdk/src/share/classes/sun/security/util/Resources_zh_TW.java b/jdk/src/share/classes/sun/security/util/Resources_zh_TW.java
index a1de718..d83082a 100644
--- a/jdk/src/share/classes/sun/security/util/Resources_zh_TW.java
+++ b/jdk/src/share/classes/sun/security/util/Resources_zh_TW.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, 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
@@ -83,7 +83,7 @@
         // javax.security.auth.login.LoginContext
         {"Invalid.null.input.name", "\u7121\u6548\u7A7A\u503C\u8F38\u5165: \u540D\u7A31"},
         {"No.LoginModules.configured.for.name",
-         "\u7121\u91DD\u5C0D {0} \u914D\u7F6E\u7684 LoginModules"},
+         "\u7121\u91DD\u5C0D {0} \u8A2D\u5B9A\u7684 LoginModules"},
         {"invalid.null.Subject.provided", "\u63D0\u4F9B\u7121\u6548\u7A7A\u503C\u4E3B\u984C"},
         {"invalid.null.CallbackHandler.provided",
                 "\u63D0\u4F9B\u7121\u6548\u7A7A\u503C CallbackHandler"},
diff --git a/jdk/src/share/classes/sun/security/x509/AuthorityKeyIdentifierExtension.java b/jdk/src/share/classes/sun/security/x509/AuthorityKeyIdentifierExtension.java
index afd7c99..9e76a3a 100644
--- a/jdk/src/share/classes/sun/security/x509/AuthorityKeyIdentifierExtension.java
+++ b/jdk/src/share/classes/sun/security/x509/AuthorityKeyIdentifierExtension.java
@@ -307,4 +307,16 @@
     public String getName() {
         return (NAME);
     }
+
+    /**
+     * Return the encoded key identifier, or null if not specified.
+     */
+    public byte[] getEncodedKeyIdentifier() throws IOException {
+        if (id != null) {
+            DerOutputStream derOut = new DerOutputStream();
+            id.encode(derOut);
+            return derOut.toByteArray();
+        }
+        return null;
+    }
 }
diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames.java
index 9befaec..5722da9 100644
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames.java
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames.java
@@ -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
@@ -310,6 +310,7 @@
             {"Europe/Bucharest", EET},
             {"Asia/Shanghai", CTT},
             {"CTT", CTT},
+            {"UTC", UTC},
             /* Don't change the order of the above zones
              * to keep compatibility with the previous version.
              */
@@ -1032,7 +1033,6 @@
             {"US/Pacific", PST},
             {"US/Pacific-New", PST},
             {"US/Samoa", SAMOA},
-            {"UTC", UTC},
             {"VST", ICT},
             {"W-SU", MSK},
             {"WET", WET},
diff --git a/jdk/src/share/classes/sun/util/resources/de/TimeZoneNames_de.java b/jdk/src/share/classes/sun/util/resources/de/TimeZoneNames_de.java
index d32357c..8fa22f9 100644
--- a/jdk/src/share/classes/sun/util/resources/de/TimeZoneNames_de.java
+++ b/jdk/src/share/classes/sun/util/resources/de/TimeZoneNames_de.java
@@ -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
@@ -311,6 +311,7 @@
             {"Europe/Bucharest", EET},
             {"Asia/Shanghai", CTT},
             {"CTT", CTT},
+            {"UTC", UTC},
             /* Don't change the order of the above zones
              * to keep compatibility with the previous version.
              */
@@ -1033,7 +1034,6 @@
             {"US/Pacific", PST},
             {"US/Pacific-New", PST},
             {"US/Samoa", SAMOA},
-            {"UTC", UTC},
             {"VST", ICT},
             {"W-SU", MSK},
             {"WET", WET},
diff --git a/jdk/src/share/classes/sun/util/resources/es/TimeZoneNames_es.java b/jdk/src/share/classes/sun/util/resources/es/TimeZoneNames_es.java
index 40ad3fa..c20c02e 100644
--- a/jdk/src/share/classes/sun/util/resources/es/TimeZoneNames_es.java
+++ b/jdk/src/share/classes/sun/util/resources/es/TimeZoneNames_es.java
@@ -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
@@ -311,6 +311,7 @@
             {"Europe/Bucharest", EET},
             {"Asia/Shanghai", CTT},
             {"CTT", CTT},
+            {"UTC", UTC},
             /* Don't change the order of the above zones
              * to keep compatibility with the previous version.
              */
@@ -1033,7 +1034,6 @@
             {"US/Pacific", PST},
             {"US/Pacific-New", PST},
             {"US/Samoa", SAMOA},
-            {"UTC", UTC},
             {"VST", ICT},
             {"W-SU", MSK},
             {"WET", WET},
diff --git a/jdk/src/share/classes/sun/util/resources/fr/TimeZoneNames_fr.java b/jdk/src/share/classes/sun/util/resources/fr/TimeZoneNames_fr.java
index 010d56b..3d81200 100644
--- a/jdk/src/share/classes/sun/util/resources/fr/TimeZoneNames_fr.java
+++ b/jdk/src/share/classes/sun/util/resources/fr/TimeZoneNames_fr.java
@@ -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
@@ -311,6 +311,7 @@
             {"Europe/Bucharest", EET},
             {"Asia/Shanghai", CTT},
             {"CTT", CTT},
+            {"UTC", UTC},
             /* Don't change the order of the above zones
              * to keep compatibility with the previous version.
              */
@@ -1033,7 +1034,6 @@
             {"US/Pacific", PST},
             {"US/Pacific-New", PST},
             {"US/Samoa", SAMOA},
-            {"UTC", UTC},
             {"VST", ICT},
             {"W-SU", MSK},
             {"WET", WET},
diff --git a/jdk/src/share/classes/sun/util/resources/it/TimeZoneNames_it.java b/jdk/src/share/classes/sun/util/resources/it/TimeZoneNames_it.java
index e2e2e7b..33350c4 100644
--- a/jdk/src/share/classes/sun/util/resources/it/TimeZoneNames_it.java
+++ b/jdk/src/share/classes/sun/util/resources/it/TimeZoneNames_it.java
@@ -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
@@ -311,6 +311,7 @@
             {"Europe/Bucharest", EET},
             {"Asia/Shanghai", CTT},
             {"CTT", CTT},
+            {"UTC", UTC},
             /* Don't change the order of the above zones
              * to keep compatibility with the previous version.
              */
@@ -1033,7 +1034,6 @@
             {"US/Pacific", PST},
             {"US/Pacific-New", PST},
             {"US/Samoa", SAMOA},
-            {"UTC", UTC},
             {"VST", ICT},
             {"W-SU", MSK},
             {"WET", WET},
diff --git a/jdk/src/share/classes/sun/util/resources/ja/TimeZoneNames_ja.java b/jdk/src/share/classes/sun/util/resources/ja/TimeZoneNames_ja.java
index d7a33f2..57a3fb7 100644
--- a/jdk/src/share/classes/sun/util/resources/ja/TimeZoneNames_ja.java
+++ b/jdk/src/share/classes/sun/util/resources/ja/TimeZoneNames_ja.java
@@ -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
@@ -311,6 +311,7 @@
             {"Europe/Bucharest", EET},
             {"Asia/Shanghai", CTT},
             {"CTT", CTT},
+            {"UTC", UTC},
             /* Don't change the order of the above zones
              * to keep compatibility with the previous version.
              */
@@ -1033,7 +1034,6 @@
             {"US/Pacific", PST},
             {"US/Pacific-New", PST},
             {"US/Samoa", SAMOA},
-            {"UTC", UTC},
             {"VST", ICT},
             {"W-SU", MSK},
             {"WET", WET},
diff --git a/jdk/src/share/classes/sun/util/resources/ko/TimeZoneNames_ko.java b/jdk/src/share/classes/sun/util/resources/ko/TimeZoneNames_ko.java
index b84d4df..d17154b 100644
--- a/jdk/src/share/classes/sun/util/resources/ko/TimeZoneNames_ko.java
+++ b/jdk/src/share/classes/sun/util/resources/ko/TimeZoneNames_ko.java
@@ -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
@@ -311,6 +311,7 @@
             {"Europe/Bucharest", EET},
             {"Asia/Shanghai", CTT},
             {"CTT", CTT},
+            {"UTC", UTC},
             /* Don't change the order of the above zones
              * to keep compatibility with the previous version.
              */
@@ -1033,7 +1034,6 @@
             {"US/Pacific", PST},
             {"US/Pacific-New", PST},
             {"US/Samoa", SAMOA},
-            {"UTC", UTC},
             {"VST", ICT},
             {"W-SU", MSK},
             {"WET", WET},
diff --git a/jdk/src/share/classes/sun/util/resources/pt/TimeZoneNames_pt_BR.java b/jdk/src/share/classes/sun/util/resources/pt/TimeZoneNames_pt_BR.java
index 5601d959..32747fe 100644
--- a/jdk/src/share/classes/sun/util/resources/pt/TimeZoneNames_pt_BR.java
+++ b/jdk/src/share/classes/sun/util/resources/pt/TimeZoneNames_pt_BR.java
@@ -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
@@ -311,6 +311,7 @@
             {"Europe/Bucharest", EET},
             {"Asia/Shanghai", CTT},
             {"CTT", CTT},
+            {"UTC", UTC},
             /* Don't change the order of the above zones
              * to keep compatibility with the previous version.
              */
@@ -1033,7 +1034,6 @@
             {"US/Pacific", PST},
             {"US/Pacific-New", PST},
             {"US/Samoa", SAMOA},
-            {"UTC", UTC},
             {"VST", ICT},
             {"W-SU", MSK},
             {"WET", WET},
diff --git a/jdk/src/share/classes/sun/util/resources/sv/TimeZoneNames_sv.java b/jdk/src/share/classes/sun/util/resources/sv/TimeZoneNames_sv.java
index bdae906..8705bfe 100644
--- a/jdk/src/share/classes/sun/util/resources/sv/TimeZoneNames_sv.java
+++ b/jdk/src/share/classes/sun/util/resources/sv/TimeZoneNames_sv.java
@@ -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
@@ -311,6 +311,7 @@
             {"Europe/Bucharest", EET},
             {"Asia/Shanghai", CTT},
             {"CTT", CTT},
+            {"UTC", UTC},
             /* Don't change the order of the above zones
              * to keep compatibility with the previous version.
              */
@@ -1033,7 +1034,6 @@
             {"US/Pacific", PST},
             {"US/Pacific-New", PST},
             {"US/Samoa", SAMOA},
-            {"UTC", UTC},
             {"VST", ICT},
             {"W-SU", MSK},
             {"WET", WET},
diff --git a/jdk/src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_CN.java b/jdk/src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_CN.java
index 534261f..d5e5215 100644
--- a/jdk/src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_CN.java
+++ b/jdk/src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_CN.java
@@ -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
@@ -311,6 +311,7 @@
             {"Europe/Bucharest", EET},
             {"Asia/Shanghai", CTT},
             {"CTT", CTT},
+            {"UTC", UTC},
             /* Don't change the order of the above zones
              * to keep compatibility with the previous version.
              */
@@ -1033,7 +1034,6 @@
             {"US/Pacific", PST},
             {"US/Pacific-New", PST},
             {"US/Samoa", SAMOA},
-            {"UTC", UTC},
             {"VST", ICT},
             {"W-SU", MSK},
             {"WET", WET},
diff --git a/jdk/src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_TW.java b/jdk/src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_TW.java
index ca5558b..4dc212b 100644
--- a/jdk/src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_TW.java
+++ b/jdk/src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_TW.java
@@ -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
@@ -311,6 +311,7 @@
             {"Europe/Bucharest", EET},
             {"Asia/Shanghai", CTT},
             {"CTT", CTT},
+            {"UTC", UTC},
             /* Don't change the order of the above zones
              * to keep compatibility with the previous version.
              */
@@ -1035,7 +1036,6 @@
             {"US/Pacific", PST},
             {"US/Pacific-New", PST},
             {"US/Samoa", SAMOA},
-            {"UTC", UTC},
             {"VST", ICT},
             {"W-SU", MSK},
             {"WET", WET},
diff --git a/jdk/src/share/lib/management/management.properties b/jdk/src/share/lib/management/management.properties
index db08b78..70efa2e 100644
--- a/jdk/src/share/lib/management/management.properties
+++ b/jdk/src/share/lib/management/management.properties
@@ -316,3 +316,16 @@
 
 # For a non-default password file location use the following line
 # com.sun.management.jmxremote.access.file=filepath
+#
+
+# ################ Management agent listen interface #########################
+#
+# com.sun.management.jmxremote.host=<host-or-interface-name>
+#      Specifies the local interface on which the JMX RMI agent will bind.
+#      This is useful when running on machines which have several
+#      interfaces defined. It makes it possible to listen to a specific
+#      subnet accessible through that interface.
+#
+#      The format of the value for that property is any string accepted
+#      by java.net.InetAddress.getByName(String).
+#
diff --git a/jdk/src/solaris/classes/java/lang/UNIXProcess.java b/jdk/src/solaris/classes/java/lang/UNIXProcess.java
index cc3b596..1793a8f 100644
--- a/jdk/src/solaris/classes/java/lang/UNIXProcess.java
+++ b/jdk/src/solaris/classes/java/lang/UNIXProcess.java
@@ -225,9 +225,8 @@
             ThreadGroup systemThreadGroup = tg;
 
             ThreadFactory threadFactory = grimReaper -> {
-                // Our thread stack requirement is quite modest.
-                Thread t = new Thread(systemThreadGroup, grimReaper,
-                                      "process reaper", 32768);
+                long stackSize = Boolean.getBoolean("jdk.lang.processReaperUseDefaultStackSize") ? 0 : 32768;
+                Thread t = new Thread(systemThreadGroup, grimReaper,"process reaper", stackSize);
                 t.setDaemon(true);
                 // A small attempt (probably futile) to avoid priority inversion
                 t.setPriority(Thread.MAX_PRIORITY);
diff --git a/jdk/src/solaris/classes/sun/awt/X11/XBaseWindow.java b/jdk/src/solaris/classes/sun/awt/X11/XBaseWindow.java
index 25e8852..297e2dd 100644
--- a/jdk/src/solaris/classes/sun/awt/X11/XBaseWindow.java
+++ b/jdk/src/solaris/classes/sun/awt/X11/XBaseWindow.java
@@ -79,7 +79,6 @@
 
     static enum InitialiseState {
         INITIALISING,
-        NOT_INITIALISED,
         INITIALISED,
         FAILED_INITIALISATION
     };
@@ -122,7 +121,6 @@
      */
     void instantPreInit(XCreateWindowParams params) {
         state_lock = new StateLock();
-        initialising = InitialiseState.NOT_INITIALISED;
     }
 
     /**
@@ -131,7 +129,6 @@
      */
     void preInit(XCreateWindowParams params) {
         state_lock = new StateLock();
-        initialising = InitialiseState.NOT_INITIALISED;
         embedded = Boolean.TRUE.equals(params.get(EMBEDDED));
         visible = Boolean.TRUE.equals(params.get(VISIBLE));
 
@@ -223,7 +220,6 @@
                       return false;
                   }
                   return true;
-              case NOT_INITIALISED:
               case FAILED_INITIALISATION:
                   return false;
               default:
@@ -673,7 +669,7 @@
         XToolkit.awtLock();
         try {
             XAtom xa = XAtom.get(XAtom.XA_WM_CLASS);
-            xa.setProperty8(getWindow(), cl[0] + '\0' + cl[1]);
+            xa.setProperty8(getWindow(), cl[0] + '\0' + cl[1] + '\0');
         } finally {
             XToolkit.awtUnlock();
         }
diff --git a/jdk/src/solaris/native/java/net/net_util_md.c b/jdk/src/solaris/native/java/net/net_util_md.c
index 693b4b0..c31d294 100644
--- a/jdk/src/solaris/native/java/net/net_util_md.c
+++ b/jdk/src/solaris/native/java/net/net_util_md.c
@@ -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
@@ -68,13 +68,6 @@
 
 #include "java_net_SocketOptions.h"
 
-/* needed from libsocket on Solaris 8 */
-
-getaddrinfo_f getaddrinfo_ptr = NULL;
-freeaddrinfo_f freeaddrinfo_ptr = NULL;
-gai_strerror_f gai_strerror_ptr = NULL;
-getnameinfo_f getnameinfo_ptr = NULL;
-
 /*
  * EXCLBIND socket options only on Solaris
  */
@@ -434,8 +427,7 @@
     int size;
     char *buf;
     const char *format = "%s: %s";
-    const char *error_string =
-        (gai_strerror_ptr == NULL) ? NULL : (*gai_strerror_ptr)(gai_error);
+    const char *error_string = gai_strerror(gai_error);
     if (error_string == NULL)
         error_string = "unknown error";
 
diff --git a/jdk/src/solaris/native/java/net/net_util_md.h b/jdk/src/solaris/native/java/net/net_util_md.h
index 68c10d6..58be690 100644
--- a/jdk/src/solaris/native/java/net/net_util_md.h
+++ b/jdk/src/solaris/native/java/net/net_util_md.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, 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
@@ -134,22 +134,6 @@
 #endif /* SO_FLOW_SLA */
 #endif /* __solaris__ */
 
-/* needed from libsocket on Solaris 8 */
-
-typedef int (*getaddrinfo_f)(const char *nodename, const char *servname,
-    const struct addrinfo *hints, struct addrinfo **res);
-
-typedef void (*freeaddrinfo_f)(struct addrinfo *);
-
-typedef const char * (*gai_strerror_f)(int ecode);
-
-typedef int (*getnameinfo_f)(const struct sockaddr *, size_t,
-    char *, size_t, char *, size_t, int);
-
-extern getaddrinfo_f getaddrinfo_ptr;
-extern freeaddrinfo_f freeaddrinfo_ptr;
-extern getnameinfo_f getnameinfo_ptr;
-
 void ThrowUnknownHostExceptionWithGaiError(JNIEnv *env,
                                            const char* hostname,
                                            int gai_error);
diff --git a/jdk/src/windows/classes/com/sun/java/accessibility/AccessBridge.java b/jdk/src/windows/classes/com/sun/java/accessibility/AccessBridge.java
index e21429e..3b176da 100644
--- a/jdk/src/windows/classes/com/sun/java/accessibility/AccessBridge.java
+++ b/jdk/src/windows/classes/com/sun/java/accessibility/AccessBridge.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, 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
@@ -1501,7 +1501,9 @@
                     s.indexOf(AccessibleState.MANAGES_DESCENDANTS.toDisplayString(Locale.US)) == -1) {
                     // Indicate whether this component manages its own
                     // children
-                    AccessibleRole role = ac.getAccessibleRole();
+                    AccessibleRole role = InvocationUtils.invokeAndWait(() -> {
+                                return ac.getAccessibleRole();
+                        }, ac);
                     if (role == AccessibleRole.LIST ||
                         role == AccessibleRole.TABLE ||
                         role == AccessibleRole.TREE) {
@@ -1759,7 +1761,9 @@
      */
     private AccessibleComponent getAccessibleComponentFromContext(AccessibleContext ac) {
         if (ac != null) {
-            AccessibleComponent acmp = ac.getAccessibleComponent();
+            AccessibleComponent acmp = InvocationUtils.invokeAndWait(() -> {
+                    return ac.getAccessibleComponent();
+                }, ac);
             if (acmp != null) {
                 debugString("Returning AccessibleComponent Context");
                 return acmp;
diff --git a/jdk/src/windows/classes/sun/awt/windows/fontconfig.properties b/jdk/src/windows/classes/sun/awt/windows/fontconfig.properties
index 65a239a..6e488ee 100644
--- a/jdk/src/windows/classes/sun/awt/windows/fontconfig.properties
+++ b/jdk/src/windows/classes/sun/awt/windows/fontconfig.properties
@@ -242,7 +242,7 @@
 
 # Exclusion Ranges
 
-exclusion.alphabetic=0700-1e9f,1f00-20ab,20ad-f8ff
+exclusion.alphabetic=0700-1e9f,1f00-2017,2020-20ab,20ad-f8ff
 exclusion.chinese-gb18030=0390-03d6,2200-22ef,2701-27be
 exclusion.hebrew=0041-005a,0060-007a,007f-00ff,20ac-20ac
 
diff --git a/jdk/src/windows/classes/sun/nio/ch/PipeImpl.java b/jdk/src/windows/classes/sun/nio/ch/PipeImpl.java
index b86580d..d1052cf 100644
--- a/jdk/src/windows/classes/sun/nio/ch/PipeImpl.java
+++ b/jdk/src/windows/classes/sun/nio/ch/PipeImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2013, 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
@@ -37,6 +37,7 @@
 import java.security.AccessController;
 import java.security.PrivilegedExceptionAction;
 import java.security.PrivilegedActionException;
+import java.security.SecureRandom;
 import java.util.Random;
 
 
@@ -47,24 +48,16 @@
 class PipeImpl
     extends Pipe
 {
+    // Number of bytes in the secret handshake.
+    private static final int NUM_SECRET_BYTES = 16;
+
+    // Random object for handshake values
+    private static final Random RANDOM_NUMBER_GENERATOR = new SecureRandom();
 
     // Source and sink channels
     private SourceChannel source;
     private SinkChannel sink;
 
-    // Random object for handshake values
-    private static final Random rnd;
-
-    static {
-        byte[] someBytes = new byte[8];
-        boolean resultOK = IOUtil.randomBytes(someBytes);
-        if (resultOK) {
-            rnd = new Random(ByteBuffer.wrap(someBytes).getLong());
-        } else {
-            rnd = new Random();
-        }
-    }
-
     private class Initializer
         implements PrivilegedExceptionAction<Void>
     {
@@ -112,6 +105,10 @@
                 SocketChannel sc2 = null;
 
                 try {
+                    // Create secret with a backing array.
+                    ByteBuffer secret = ByteBuffer.allocate(NUM_SECRET_BYTES);
+                    ByteBuffer bb = ByteBuffer.allocate(NUM_SECRET_BYTES);
+
                     // Loopback address
                     InetAddress lb = InetAddress.getByName("127.0.0.1");
                     assert(lb.isLoopbackAddress());
@@ -128,18 +125,22 @@
                         // Establish connection (assume connections are eagerly
                         // accepted)
                         sc1 = SocketChannel.open(sa);
-                        ByteBuffer bb = ByteBuffer.allocate(8);
-                        long secret = rnd.nextLong();
-                        bb.putLong(secret).flip();
-                        sc1.write(bb);
+                        RANDOM_NUMBER_GENERATOR.nextBytes(secret.array());
+                        do {
+                            sc1.write(secret);
+                        } while (secret.hasRemaining());
+                        secret.rewind();
 
                         // Get a connection and verify it is legitimate
                         sc2 = ssc.accept();
-                        bb.clear();
-                        sc2.read(bb);
+                        do {
+                            sc2.read(bb);
+                        } while (bb.hasRemaining());
                         bb.rewind();
-                        if (bb.getLong() == secret)
+
+                        if (bb.equals(secret))
                             break;
+
                         sc2.close();
                         sc1.close();
                     }
diff --git a/jdk/src/windows/native/java/net/NetworkInterface_winXP.c b/jdk/src/windows/native/java/net/NetworkInterface_winXP.c
index 7e3e79d..4042d16 100644
--- a/jdk/src/windows/native/java/net/NetworkInterface_winXP.c
+++ b/jdk/src/windows/native/java/net/NetworkInterface_winXP.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -28,6 +28,7 @@
 #include <winsock2.h>           /* needed for htonl */
 #include <iprtrmib.h>
 #include <assert.h>
+#include <limits.h>
 
 #include "java_net_NetworkInterface.h"
 #include "jni_util.h"
@@ -70,7 +71,7 @@
 
 #endif
 
-static int bufsize = 1024;
+static int bufsize = 4096;
 
 /*
  * return an array of IP_ADAPTER_ADDRESSES containing one element
@@ -94,7 +95,12 @@
     ret = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, adapterInfo, &len);
 
     if (ret == ERROR_BUFFER_OVERFLOW) {
-        IP_ADAPTER_ADDRESSES * newAdapterInfo = (IP_ADAPTER_ADDRESSES *) realloc (adapterInfo, len);
+        IP_ADAPTER_ADDRESSES * newAdapterInfo = NULL;
+        if (len  < (ULONG_MAX - bufsize)) {
+            len = len + bufsize;
+        }
+        newAdapterInfo =
+                (IP_ADAPTER_ADDRESSES *) realloc (adapterInfo, len);
         if (newAdapterInfo == NULL) {
             free(adapterInfo);
             JNU_ThrowByName(env, "java/lang/OutOfMemoryError", "Native heap allocation failure");
@@ -103,7 +109,6 @@
 
         adapterInfo = newAdapterInfo;
 
-        bufsize = len;
         ret = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, adapterInfo, &len);
     }
 
@@ -137,7 +142,12 @@
     flags |= GAA_FLAG_INCLUDE_PREFIX;
     val = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, adapterInfo, &len);
     if (val == ERROR_BUFFER_OVERFLOW) {
-        IP_ADAPTER_ADDRESSES * newAdapterInfo = (IP_ADAPTER_ADDRESSES *) realloc (adapterInfo, len);
+        IP_ADAPTER_ADDRESSES * newAdapterInfo = NULL;
+        if (len  < (ULONG_MAX - bufsize)) {
+            len = len + bufsize;
+        }
+        newAdapterInfo =
+                (IP_ADAPTER_ADDRESSES *) realloc (adapterInfo, len);
         if (newAdapterInfo == NULL) {
             free(adapterInfo);
             JNU_ThrowByName(env, "java/lang/OutOfMemoryError", "Native heap allocation failure");
@@ -146,7 +156,6 @@
 
         adapterInfo = newAdapterInfo;
 
-        bufsize = len;
         val = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, adapterInfo, &len);
     }
 
diff --git a/jdk/src/windows/native/sun/font/lcdglyph.c b/jdk/src/windows/native/sun/font/lcdglyph.c
index 05f4aae..d940e8c 100644
--- a/jdk/src/windows/native/sun/font/lcdglyph.c
+++ b/jdk/src/windows/native/sun/font/lcdglyph.c
@@ -157,6 +157,9 @@
     if (hBitmap != 0) { \
         DeleteObject(hBitmap); \
     } \
+    if (tmpBitmap != 0) { \
+        DeleteObject(tmpBitmap); \
+    } \
     if (dibImage != NULL) { \
         free(dibImage); \
     } \
@@ -196,6 +199,7 @@
     int bmWidth, bmHeight;
     int x, y;
     HBITMAP hBitmap = NULL, hOrigBM;
+    HBITMAP tmpBitmap = NULL;
     int gamma, orient;
 
     HWND hWnd = NULL;
@@ -250,6 +254,12 @@
     }
     oldFont = SelectObject(hMemoryDC, hFont);
 
+    tmpBitmap = CreateCompatibleBitmap(hDesktopDC, 1, 1);
+    if (tmpBitmap == NULL) {
+        FREE_AND_RETURN;
+    }
+    hOrigBM = (HBITMAP)SelectObject(hMemoryDC, tmpBitmap);
+
     memset(&textMetric, 0, sizeof(TEXTMETRIC));
     err = GetTextMetrics(hMemoryDC, &textMetric);
     if (err == 0) {
@@ -334,7 +344,7 @@
     if (hBitmap == NULL) {
         FREE_AND_RETURN;
     }
-    hOrigBM = (HBITMAP)SelectObject(hMemoryDC, hBitmap);
+    SelectObject(hMemoryDC, hBitmap);
 
     /* Fill in black */
     rect.left = 0;
@@ -478,6 +488,7 @@
     ReleaseDC(hWnd, hDesktopDC);
     DeleteObject(hMemoryDC);
     DeleteObject(hBitmap);
+    DeleteObject(tmpBitmap);
 
     return ptr_to_jlong(glyphInfo);
 }
diff --git a/jdk/src/windows/native/sun/windows/awt_Font.cpp b/jdk/src/windows/native/sun/windows/awt_Font.cpp
index a3d5965..76bdd84 100644
--- a/jdk/src/windows/native/sun/windows/awt_Font.cpp
+++ b/jdk/src/windows/native/sun/windows/awt_Font.cpp
@@ -256,7 +256,7 @@
 
     AwtFont* awtFont = NULL;
     jobjectArray compFont = NULL;
-    int cfnum;
+    int cfnum = 0;
 
     try {
         if (env->EnsureLocalCapacity(3) < 0)
@@ -264,7 +264,9 @@
 
         if (IsMultiFont(env, font)) {
             compFont = GetComponentFonts(env, font);
-            cfnum = env->GetArrayLength(compFont);
+            if (compFont != NULL) {
+                cfnum = env->GetArrayLength(compFont);
+            }
         } else {
             compFont = NULL;
             cfnum = 0;
@@ -614,7 +616,9 @@
 
     if (IsMultiFont(env, font)) {
         array = GetComponentFonts(env, font);
-        num = env->GetArrayLength(array);
+        if (array != NULL) {
+            num = env->GetArrayLength(array);
+        }
     } else {
         array = NULL;
         num = 0;
@@ -672,14 +676,16 @@
 
     if (IsMultiFont(env, font)) {
         jobject peer = env->CallObjectMethod(font, AwtFont::peerMID);
-        array =  (jobjectArray)(env->CallObjectMethod(
-        peer, AwtFont::makeConvertedMultiFontStringMID, str));
-        DASSERT(!safe_ExceptionOccurred(env));
+        if (peer != NULL) {
+            array = (jobjectArray)(env->CallObjectMethod(
+            peer, AwtFont::makeConvertedMultiFontStringMID, str));
+            DASSERT(!safe_ExceptionOccurred(env));
 
-        if (array != NULL) {
-            arrayLength = env->GetArrayLength(array);
+            if (array != NULL) {
+                arrayLength = env->GetArrayLength(array);
+            }
+            env->DeleteLocalRef(peer);
         }
-        env->DeleteLocalRef(peer);
     } else {
         array = NULL;
         arrayLength = 0;
diff --git a/jdk/src/windows/native/sun/windows/awt_Font.h b/jdk/src/windows/native/sun/windows/awt_Font.h
index 83df5e7..3f4d8e6 100644
--- a/jdk/src/windows/native/sun/windows/awt_Font.h
+++ b/jdk/src/windows/native/sun/windows/awt_Font.h
@@ -230,11 +230,14 @@
     INLINE static jobjectArray GetComponentFonts(JNIEnv *env,
                                                      jobject font) {
       jobject platformFont = env->CallObjectMethod(font, AwtFont::peerMID);
-      jobjectArray result =
-          (jobjectArray)(env->GetObjectField(platformFont,
-                                             AwtFont::componentFontsID));
-      env->DeleteLocalRef(platformFont);
-      return result;
+      if (platformFont != NULL) {
+          jobjectArray result =
+              (jobjectArray)(env->GetObjectField(platformFont,
+                                                 AwtFont::componentFontsID));
+          env->DeleteLocalRef(platformFont);
+          return result;
+      }
+      return NULL;
     }
 
    /*
diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt
index 25ada7c..c726b04 100644
--- a/jdk/test/ProblemList.txt
+++ b/jdk/test/ProblemList.txt
@@ -273,3 +273,13 @@
 java/util/concurrent/locks/ReentrantLock/CancelledLockLoops.java generic-all
 
 ############################################################################
+
+# svc_tools
+
+# 8031482
+sun/tools/jcmd/TestJcmdSanity.java				windows-all
+
+# 6456333
+sun/tools/jps/TestJpsJarRelative.java				generic-all
+
+############################################################################
diff --git a/jdk/test/TEST.ROOT b/jdk/test/TEST.ROOT
index 26377b7..7a285b0 100644
--- a/jdk/test/TEST.ROOT
+++ b/jdk/test/TEST.ROOT
@@ -1,8 +1,15 @@
 # This file identifies the root of the test-suite hierarchy.
 # It also contains test-suite configuration information.
 
-# The list of keywords supported in the entire test suite
-keys=2d dnd i18n
+# The list of keywords supported in the entire test suite.  The
+# "intermittent" keyword marks tests known to fail intermittently.
+# The "randomness" keyword marks tests using randomness with test
+# cases differing from run to run. (A test using a fixed random seed
+# would not count as "randomness" by this definition.) Extra care
+# should be taken to handle test failures of intermittent or
+# randomness tests.
+
+keys=2d dnd i18n intermittent randomness
 
 # Tests that must run in othervm mode
 othervm.dirs=java/awt java/beans java/rmi javax/accessibility javax/imageio javax/sound javax/print javax/management com/sun/awt sun/awt sun/java2d sun/pisces sun/rmi
@@ -10,5 +17,8 @@
 # Tests that cannot run concurrently
 exclusiveAccess.dirs=java/rmi/Naming java/util/Currency java/util/prefs sun/management/jmxremote sun/tools/jstatd sun/security/mscapi javax/rmi
 
+# Allow querying of sun.arch.data.model in @requires clauses
+requires.properties=sun.arch.data.model 
+
 # Group definitions
 groups=TEST.groups [closed/TEST.groups]
diff --git a/jdk/test/TEST.groups b/jdk/test/TEST.groups
index a17b16a..886566f 100644
--- a/jdk/test/TEST.groups
+++ b/jdk/test/TEST.groups
@@ -352,7 +352,8 @@
   javax/xml/bind/jxc \
   javax/xml/ws/8033113 \
   javax/xml/ws/clientjar/TestWsImport.java \
-  javax/xml/ws/ebcdic
+  javax/xml/ws/ebcdic \
+  javax/xml/bind/xjc/8145039/JaxbMarshallTest.java
 
 # JRE adds further tests to compact3
 #
diff --git a/jdk/test/com/sun/crypto/provider/CICO/CICOChainingTest.java b/jdk/test/com/sun/crypto/provider/CICO/CICOChainingTest.java
new file mode 100644
index 0000000..5e0d3c5
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/CICO/CICOChainingTest.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PipedInputStream;
+import java.io.PipedOutputStream;
+import java.util.Arrays;
+import javax.crypto.CipherInputStream;
+import javax.crypto.CipherOutputStream;
+
+/*
+ * @test
+ * @bug 8048604
+ * @summary This test verifies the assertion "The chaining feature of
+ *  Filter streams should be supported." for feature "CipherInputStream &
+ *  CipherOutputStream"
+ * @run main CICOChainingTest
+ */
+public class CICOChainingTest {
+    /**
+     * Plain text length.
+     */
+    private static final int PLAIN_TEXT_LENGTH = 200;
+
+    public static void main(String argv[]) throws Exception {
+        CICOChainingTest test = new CICOChainingTest();
+        test.chainTest(true);
+        test.chainTest(false);
+    }
+
+    /**
+     * Chain CipherInputStream/CipherOutputStream with other stream, encrypt
+     * the text and decrypt it, recovered text is supposed to be same as
+     * original text.
+     * @param useInt true if read byte by byte false if read with buffer.
+     * @throws IOException any I/O operation failed.
+     */
+    public void chainTest(boolean useInt) throws IOException {
+        byte[] plainText = TestUtilities.generateBytes(PLAIN_TEXT_LENGTH);
+        byte[] recoveredText = new byte[plainText.length];
+        // Do initialization
+        try (MyNullCipherInputStream ciInput1 = new MyNullCipherInputStream(
+                new ByteArrayInputStream(plainText));
+                PipedOutputStream piOut = new PipedOutputStream();
+                MyNullCipherInputStream ciInput2 = new MyNullCipherInputStream(
+                        new PipedInputStream(piOut));
+                MyNullCipherOutputStream ciOut = new MyNullCipherOutputStream(
+                        piOut);) {
+            if (useInt) {
+                int buffer = ciInput1.read();
+                while (buffer != -1) {
+                    piOut.write(buffer);
+                    buffer = ciInput1.read();
+                }
+            } else {
+                byte[] buffer = new byte[20];
+                int len = ciInput1.read(buffer);
+                while (len != -1) {
+                    ciOut.write(buffer, 0, len);
+                    len = ciInput1.read(buffer);
+                }
+            }
+            ciOut.flush();
+            piOut.flush();
+            // Get the output
+            ciInput2.read(recoveredText);
+            if (ciInput2.available() > 0) {
+                throw new RuntimeException("Expected no data from ciInput2, but"
+                        + " ciInput2.available() = " + ciInput2.available());
+            }
+        }
+        // Verify output is same to input.
+        if (!Arrays.equals(plainText, recoveredText)) {
+            throw new RuntimeException("plainText:" + new String(plainText)
+                    + " recoveredText:" + new String(recoveredText)
+                    + " Test failed due to result compare fail");
+        }
+    }
+}
+
+class MyNullCipherInputStream extends CipherInputStream {
+
+    public MyNullCipherInputStream(InputStream is) {
+        super(is);
+    }
+}
+
+class MyNullCipherOutputStream extends CipherOutputStream {
+
+    public MyNullCipherOutputStream(OutputStream os) {
+        super(os);
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/CICO/CICODESFuncTest.java b/jdk/test/com/sun/crypto/provider/CICO/CICODESFuncTest.java
new file mode 100644
index 0000000..3164294
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/CICO/CICODESFuncTest.java
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+import static java.lang.System.out;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import java.security.NoSuchAlgorithmException;
+import java.security.Provider;
+import java.security.Security;
+import java.security.spec.AlgorithmParameterSpec;
+import java.util.Arrays;
+import javax.crypto.CipherInputStream;
+import javax.crypto.CipherOutputStream;
+import javax.crypto.SecretKey;
+import javax.crypto.Cipher;
+import javax.crypto.KeyGenerator;
+import javax.crypto.spec.IvParameterSpec;
+
+/*
+ * @test
+ * @bug 8048604
+ * @summary to verify cipherInputStream and cipherInputStream cipher function
+ * @run main CICODESFuncTest
+ */
+public class CICODESFuncTest {
+    /**
+     * Algorithms name.
+     */
+    private static final String[] ALGORITHMS = { "DES", "DESede", "Blowfish" };
+    private static final String[] MODES = { "ECB", "CBC", "CFB", "CFB24",
+            "CFB32", "CFB40", "CFB72", "OFB", "OFB20", "OFB48", "OFB56",
+            "OFB64", "PCBC" };
+    /**
+     * Padding mode.
+     */
+    private static final String[] PADDINGS = { "noPadding", "pkcs5padding" };
+    /**
+     * Plain text length.
+     */
+    private static final int TEXT_LENGTH = 80;
+    /**
+     * Initialization vector length.
+     */
+    private static final int IV_LENGTH = 8;
+
+    public static void main(String[] args) throws Exception {
+        Provider provider = Security.getProvider("SunJCE");
+        if (provider == null) {
+            throw new RuntimeException("SunJCE provider does not exist.");
+        }
+        for (String algorithm : ALGORITHMS) {
+            for (String mode : MODES) {
+                // We only test noPadding and pkcs5padding for CFB72, OFB20, ECB
+                // PCBC and CBC. Otherwise test noPadding only.
+                int padKinds = 1;
+                if (mode.equalsIgnoreCase("CFB72")
+                        || mode.equalsIgnoreCase("OFB20")
+                        || mode.equalsIgnoreCase("ECB")
+                        || mode.equalsIgnoreCase("PCBC")
+                        || mode.equalsIgnoreCase("CBC")) {
+                    padKinds = PADDINGS.length;
+                }
+                // PKCS5padding is meaningful only for ECB, CBC, PCBC
+                for (int k = 0; k < padKinds; k++) {
+                    for (ReadModel readMode : ReadModel.values()) {
+                        runTest(provider, algorithm, mode, PADDINGS[k], readMode);
+                    }
+                }
+            }
+        }
+    }
+
+    private static void runTest(Provider p, String algo, String mo, String pad,
+            ReadModel whichRead) throws GeneralSecurityException, IOException {
+        // Do initialization
+        byte[] plainText = TestUtilities.generateBytes(TEXT_LENGTH);
+        byte[] iv = TestUtilities.generateBytes(IV_LENGTH);
+        AlgorithmParameterSpec aps = new IvParameterSpec(iv);
+        try {
+            KeyGenerator kg = KeyGenerator.getInstance(algo, p);
+            out.println(algo + "/" + mo + "/" + pad + "/" + whichRead);
+            SecretKey key = kg.generateKey();
+            Cipher ci1 = Cipher.getInstance(algo + "/" + mo + "/" + pad, p);
+            if ("CFB72".equalsIgnoreCase(mo) || "OFB20".equalsIgnoreCase(mo)) {
+                throw new RuntimeException(
+                        "NoSuchAlgorithmException not throw when mode"
+                                + " is CFB72 or OFB20");
+            }
+            Cipher ci2 = Cipher.getInstance(algo + "/" + mo + "/" + pad, p);
+            if ("ECB".equalsIgnoreCase(mo)) {
+                ci1.init(Cipher.ENCRYPT_MODE, key);
+                ci2.init(Cipher.DECRYPT_MODE, key);
+            } else {
+                ci1.init(Cipher.ENCRYPT_MODE, key, aps);
+                ci2.init(Cipher.DECRYPT_MODE, key, aps);
+            }
+            ByteArrayOutputStream baOutput = new ByteArrayOutputStream();
+            try (CipherInputStream cInput
+                    = new CipherInputStream(
+                            new ByteArrayInputStream(plainText), ci1);
+                    CipherOutputStream ciOutput
+                        = new CipherOutputStream(baOutput, ci2);) {
+                // Read from the input and write to the output using 2 types
+                // of buffering : byte[] and int
+                whichRead.read(cInput, ciOutput, ci1, plainText.length);
+            }
+            // Verify input and output are same.
+            if (!Arrays.equals(plainText, baOutput.toByteArray())) {
+                throw new RuntimeException("Test failed due to compare fail ");
+            }
+        } catch (NoSuchAlgorithmException nsaEx) {
+            if ("CFB72".equalsIgnoreCase(mo) || "OFB20".equalsIgnoreCase(mo)) {
+                out.println("NoSuchAlgorithmException is expected for CFB72 and OFB20");
+            } else {
+                throw new RuntimeException("Unexpected exception testing: "
+                        + algo + "/" + mo + "/" + pad + "/" + whichRead, nsaEx);
+            }
+        }
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/CICO/CICOSkipTest.java b/jdk/test/com/sun/crypto/provider/CICO/CICOSkipTest.java
new file mode 100644
index 0000000..0641845
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/CICO/CICOSkipTest.java
@@ -0,0 +1,270 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+
+import static java.lang.System.out;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.Provider;
+import java.security.Security;
+import java.security.spec.AlgorithmParameterSpec;
+import java.security.spec.InvalidKeySpecException;
+import javax.crypto.Cipher;
+import javax.crypto.CipherInputStream;
+import javax.crypto.KeyGenerator;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.SecretKey;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.PBEKeySpec;
+import javax.crypto.spec.PBEParameterSpec;
+
+/*
+ * @test
+ * @bug 8048604
+ * @summary This test verifies the assertion "The skip feature of Filter
+ *    streams should be supported." for feature
+ *    CipherInputStream and CipherOutputStream
+ */
+public class CICOSkipTest {
+    /**
+     * Block length.
+     */
+    private static final int BLOCK = 50;
+
+    /**
+     * Saving bytes length.
+     */
+    private static final int SAVE = 45;
+
+    /**
+     * Plain text length.
+     */
+    private static final int PLAIN_TEXT_LENGTH = 800;
+
+    /**
+     * Skip reading byte size. This should be same to BLOCK - SAVE
+     */
+    private static final int DISCARD = BLOCK - SAVE;
+
+    private static final String[] ALGOS = {"DES", "DESede", "Blowfish"};
+    private static final String[] MODES = {"ECB", "CBC", "CFB", "CFB32",
+        "OFB", "OFB64", "PCBC"};
+    private static final String[] PADDINGS = {"NoPadding", "Pkcs5Padding"};
+    private static final String[] PBE_ALGOS = {"PBEWithMD5AndDES",
+        "PBEWithMD5AndDES/CBC/PKCS5Padding"};
+
+    public static void main(String[] args) throws Exception {
+        // how many kinds of padding mode such as PKCS5padding and NoPadding
+        for (String algo : ALGOS) {
+            for (String mode : MODES) {
+                int padKinds = 1;
+                if (mode.equalsIgnoreCase("ECB")
+                        || mode.equalsIgnoreCase("PCBC")
+                        || mode.equalsIgnoreCase("CBC")) {
+                    padKinds = PADDINGS.length;
+                }
+                // PKCS5padding is meaningful only for ECB, CBC, PCBC
+                for (int k = 0; k < padKinds; k++) {
+                    String info = algo + "/" + mode + "/" + PADDINGS[k];
+                    try {
+                        CipherGenerator cg = new CipherGenerator(algo, mode,
+                                PADDINGS[k]);
+                        for (ReadMethod model : ReadMethod.values()) {
+                            runTest(cg.getPair(), info, model);
+                        }
+                    } catch (LengthLimitException exp) {
+                        // skip this if this key length is larger than what's
+                        // configured in the jce jurisdiction policy files
+                        out.println(exp.getMessage() + " is expected.");
+                    }
+                }
+            }
+        }
+        for (String pbeAlgo : PBE_ALGOS) {
+            for (ReadMethod model : ReadMethod.values()) {
+                System.out.println("Testing Algorithm : " + pbeAlgo
+                        + " ReadMethod : " + model);
+                runTest(new CipherGenerator(pbeAlgo).getPair(), pbeAlgo, model);
+            }
+        }
+    }
+
+    private static void runTest(Cipher[] pair, String info, ReadMethod whichRead)
+            throws IOException {
+        byte[] plainText = TestUtilities.generateBytes(PLAIN_TEXT_LENGTH);
+        out.println("Testing: " + info + "/" + whichRead);
+        try (ByteArrayInputStream baInput = new ByteArrayInputStream(plainText);
+                CipherInputStream ciInput1 = new CipherInputStream(baInput,
+                        pair[0]);
+                CipherInputStream ciInput2 = new CipherInputStream(ciInput1,
+                        pair[1]);) {
+            // Skip 5 bytes after read 45 bytes and repeat until finish
+            // (Read from the input and write to the output using 2 types
+            // of buffering : byte[] and int)
+            // So output has size:
+            // (OVERALL/BLOCK)* SAVE = (800 / 50) * 45 = 720 bytes
+            int numOfBlocks = plainText.length / BLOCK;
+
+            // Output buffer.
+            byte[] outputText = new byte[numOfBlocks * SAVE];
+            int index = 0;
+            for (int i = 0; i < numOfBlocks; i++) {
+                index = whichRead.readByte(ciInput2, outputText, SAVE, index);
+                // If available is more than expected discard byte size. Skip
+                // discard bytes, otherwise try to read discard bytes by read.
+                if (ciInput2.available() >= DISCARD) {
+                    ciInput2.skip(DISCARD);
+                } else {
+                    for (int k = 0; k < DISCARD; k++) {
+                        ciInput2.read();
+                    }
+                }
+            }
+            // Verify output is same as input
+            if (!TestUtilities
+                    .equalsBlockPartial(plainText, outputText, BLOCK, SAVE)) {
+                throw new RuntimeException("Test failed with compare fail");
+            }
+        }
+    }
+}
+
+class CipherGenerator {
+    /**
+     * Initialization vector  length.
+     */
+    private static final int IV_LENGTH = 8;
+
+    private static final String PASSWD = "Sesame!(@#$%^&*)";
+
+    private final Cipher[] pair = new Cipher[2];
+
+    // For DES/DESede ciphers
+    CipherGenerator(String algo, String mo, String pad)
+            throws NoSuchAlgorithmException,
+            InvalidAlgorithmParameterException, InvalidKeyException,
+            NoSuchPaddingException, SecurityException, LengthLimitException {
+        // Do initialization
+        KeyGenerator kg = KeyGenerator.getInstance(algo);
+        SecretKey key = kg.generateKey();
+        if (key.getEncoded().length * 8 > Cipher.getMaxAllowedKeyLength(algo)) {
+            // skip this if this key length is larger than what's
+            // configured in the jce jurisdiction policy files
+            throw new LengthLimitException(
+                    "Skip this test if key length is larger than what's"
+                    + "configured in the jce jurisdiction policy files");
+        }
+        AlgorithmParameterSpec aps = null;
+        if (!mo.equalsIgnoreCase("ECB")) {
+            byte[] iv = TestUtilities.generateBytes(IV_LENGTH);
+            aps = new IvParameterSpec(iv);
+        }
+        initCiphers(algo + "/" + mo + "/" + pad, key, aps);
+    }
+
+    // For PBE ciphers
+    CipherGenerator(String algo) throws NoSuchAlgorithmException,
+            InvalidAlgorithmParameterException, InvalidKeyException,
+            NoSuchPaddingException, InvalidKeySpecException {
+        // Do initialization
+        byte[] salt = TestUtilities.generateBytes(IV_LENGTH);
+        int iterCnt = 6;
+        SecretKeyFactory skf = SecretKeyFactory.getInstance(algo.split("/")[0]);
+        SecretKey key = skf
+                .generateSecret(new PBEKeySpec(PASSWD.toCharArray()));
+        AlgorithmParameterSpec aps = new PBEParameterSpec(salt, iterCnt);
+        initCiphers(algo, key, aps);
+    }
+
+    private void initCiphers(String algo, SecretKey key,
+            AlgorithmParameterSpec aps) throws NoSuchAlgorithmException,
+            NoSuchPaddingException, InvalidKeyException,
+            InvalidAlgorithmParameterException {
+        Provider provider = Security.getProvider("SunJCE");
+        if (provider == null) {
+            throw new RuntimeException("SunJCE provider does not exist.");
+        }
+        Cipher ci1 = Cipher.getInstance(algo, provider);
+        ci1.init(Cipher.ENCRYPT_MODE, key, aps);
+        pair[0] = ci1;
+        Cipher ci2 = Cipher.getInstance(algo, provider);
+        ci2.init(Cipher.DECRYPT_MODE, key, aps);
+        pair[1] = ci2;
+    }
+
+    Cipher[] getPair() {
+        return pair;
+    }
+}
+
+enum ReadMethod {
+    // read one byte at a time for save times
+    READ_ONE_BYTE {
+        @Override
+        int readByte(CipherInputStream ciIn2, byte[] outputText, int save,
+                int index) throws IOException {
+            for (int j = 0; j < save; j++, index++) {
+                int buffer0 = ciIn2.read();
+                if (buffer0 != -1) {
+                    outputText[index] = (byte) buffer0;
+                } else {
+                    break;
+                }
+            }
+            return index;
+        }
+    },
+    // read a chunk of save bytes if possible
+    READ_BLOCK {
+        @Override
+        int readByte(CipherInputStream ciIn2, byte[] outputText, int save,
+                int index) throws IOException {
+            int len1 = ciIn2.read(outputText, index, save);
+            out.println("Init: index=" + index + ",len=" + len1);
+            // read more until save bytes
+            index += len1;
+            int len2 = 0;
+            while (len1 != save && len2 != -1) {
+                len2 = ciIn2.read(outputText, index, save - len1);
+                out.println("Cont: index=" + index + ",len=" + len2);
+                len1 += len2;
+                index += len2;
+            }
+            return index;
+        }
+    };
+
+    abstract int readByte(CipherInputStream ciIn2, byte[] outputText, int save,
+            int index) throws IOException;
+};
+
+class LengthLimitException extends Exception {
+
+    public LengthLimitException(String string) {
+        super(string);
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/AESPBEWrapper.java b/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/AESPBEWrapper.java
new file mode 100644
index 0000000..e6e5c2f
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/AESPBEWrapper.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+
+import java.security.AlgorithmParameters;
+import java.security.GeneralSecurityException;
+import java.security.Provider;
+import java.security.Security;
+import javax.crypto.SecretKey;
+import javax.crypto.Cipher;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.PBEKeySpec;
+
+/**
+ * Wrapper class to test a given AES-based PBE algorithm.
+ */
+public class AESPBEWrapper extends AbstractPBEWrapper {
+    /**
+     * the algorithm parameters.
+     */
+    private AlgorithmParameters pbeParams;
+
+    /**
+     * the encryption key.
+     */
+    private final SecretKey key;
+
+    /**
+     * The Wrapper constructor. Instantiate Cipher using the given AES-based PBE
+     * algorithm.
+     *
+     * @param algo AES-based PBE algorithm.
+     * @param passwd password phrase.
+     * @throws GeneralSecurityException all security exceptions are thrown.
+     */
+    public AESPBEWrapper(PBEAlgorithm algo, String passwd)
+            throws GeneralSecurityException {
+        // salt and iteration count will be generated during encryption
+        super(algo, passwd, 0);
+
+        // Generate secret key. We expect no mode and padding specified.
+        SecretKeyFactory skf = SecretKeyFactory.getInstance(algo.baseAlgo);
+        key = skf.generateSecret(new PBEKeySpec(passwd.toCharArray()));
+    }
+
+    /**
+     * Initiate the Cipher object using given "mode".
+     * @return a cipher object.
+     * @throws GeneralSecurityException all security exceptions are thrown.
+     */
+    @Override
+    protected Cipher initCipher(int mode) throws GeneralSecurityException {
+        Provider provider = Security.getProvider("SunJCE");
+        if (provider == null) {
+            throw new RuntimeException("SunJCE provider does not exist.");
+        }
+        // get Cipher instance
+        Cipher ci = Cipher.getInstance(transformation, provider);
+        if (Cipher.ENCRYPT_MODE == mode) {
+            ci.init(Cipher.ENCRYPT_MODE, key);
+            pbeParams = ci.getParameters();
+        } else {
+            ci.init(Cipher.DECRYPT_MODE, key, pbeParams);
+        }
+        return ci;
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/AbstractPBEWrapper.java b/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/AbstractPBEWrapper.java
new file mode 100644
index 0000000..d155a14
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/AbstractPBEWrapper.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+import java.security.GeneralSecurityException;
+import javax.crypto.Cipher;
+
+/**
+ * PBEWrapper is an abstract class for all concrete PBE Cipher wrappers.
+ */
+public abstract class AbstractPBEWrapper {
+    /**
+     * Iteration count.
+     */
+    public static final int DEFAULT_ITERATION = 1000;
+
+    public static final String PBKDF2 = "PBKDF2";
+    public static final String AES = "AES";
+    public static final String DEFAULT = "default";
+
+    /**
+     * transformation the name of the transformation, e.g.,
+     * DES/CBC/PKCS5Padding
+     */
+    protected final String transformation;
+
+    /**
+     * the standard name of the requested secret-key algorithm.
+     */
+    protected final String baseAlgo;
+
+    /**
+     * The contents of salt are copied to protect against subsequent
+     * modification.
+     */
+    protected final byte[] salt;
+
+    /**
+     * Password.
+     */
+    protected final String password;
+
+    /**
+     * PBEWrapper creator.
+     *
+     * @param algo PBE algorithm to test
+     * @param passwd a password phrase
+     * @return PBEWrapper in accordance to requested algo.
+     * @throws GeneralSecurityException all exceptions are thrown.
+     */
+    public static AbstractPBEWrapper createWrapper(PBEAlgorithm algo, String passwd)
+            throws GeneralSecurityException {
+        switch (algo.type) {
+            case PBKDF2:
+                return new PBKDF2Wrapper(algo, passwd);
+            case AES:
+                return new AESPBEWrapper(algo, passwd);
+            default:
+                return new DefaultPBEWrapper(algo, passwd);
+        }
+    }
+
+    /**
+     * PBEWrapper constructor.
+     *
+     * @param algo algorithm to wrap
+     * @param password password phrase
+     * @param saltSize salt size (defined in subclasses)
+     */
+    protected AbstractPBEWrapper(PBEAlgorithm algo, String password, int saltSize) {
+        this.transformation = algo.getTransformation();
+        this.baseAlgo = algo.baseAlgo;
+        this.salt = TestUtilities.generateBytes(saltSize);
+        this.password = password;
+    }
+
+    /**
+     * Initialize Cipher object for the operation requested in the mode parameter.
+     *
+     * @param mode encryption or decryption
+     * @return a cipher initialize by mode.
+     * @throws GeneralSecurityException all security exceptions are thrown.
+     */
+    protected abstract Cipher initCipher(int mode) throws GeneralSecurityException;
+}
diff --git a/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/CICOPBEFuncTest.java b/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/CICOPBEFuncTest.java
new file mode 100644
index 0000000..0e4b376
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/CICOPBEFuncTest.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2007, 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 8048604
+ * @summary This test verifies the assertion "The encrypt/decrypt
+ *  mechanism of cipher should perform correctly." for feature
+ *  "CipherInputStream & CipherOutputStream".
+ * @library ../
+ * @run main CICOPBEFuncTest
+ */
+
+import java.util.Arrays;
+import javax.crypto.Cipher;
+
+public class CICOPBEFuncTest {
+
+    public static void main(String[] args) throws Exception {
+        for (PBEAlgorithm algorithm : PBEAlgorithm.values()) {
+            // int buffertin test
+            String algo = algorithm.baseAlgo.toUpperCase();
+            if (!algo.contains("TRIPLEDES") && !algo.contains("AES_256")
+                    || Cipher.getMaxAllowedKeyLength(algo) > 128) {
+                // skip this if this key length is larger than what's
+                // configured in the jce jurisdiction policy files
+                System.out.println("Testing " + algorithm.getTransformation());
+                for (String type : Arrays.asList(CICO_PBE_Test.INT_BYTE_BUFFER,
+                        CICO_PBE_Test.BYTE_ARR_BUFFER)) {
+                    new CICO_PBE_RW_Test(algorithm)
+                        .proceedTest(type);
+                    new CICO_PBE_SKIP_Test(algorithm)
+                        .proceedTest(type);
+                }
+            }
+        }
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/CICO_PBE_RW_Test.java b/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/CICO_PBE_RW_Test.java
new file mode 100644
index 0000000..da149f0
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/CICO_PBE_RW_Test.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+
+import javax.crypto.CipherOutputStream;
+
+/**
+ * CICO PBE Read/Write functional test.
+ *
+ * Verifies for the given PBE algorithm if the encrypt/decrypt mechanism is
+ * performed correctly for CipherInputStream and CipherOutputStream.
+ *
+ * Test scenario:
+ * 1. initializes plain text with random generated data.
+ * 2. for the given PBE algorithm instantiates encrypt and decrypt Ciphers.
+ * 3. instantiates CipherInputStream with the encrypt Cipher.
+ * 4. instantiates CipherOutputStream with the decrypt Cipher.
+ * 5. performs reading from the CipherInputStream (encryption data) and writing
+ *    to the CipherOutputStream (decryption). As a result the output of the
+ *    CipherOutputStream should be the same as an original plain text.
+ * 6. compares if the original plain text is the same as the output of the
+ *    CipherOutputStream.
+ *
+ * The test implements 2 test cases in accordance with buffering type:
+ * 1. byte array buffering
+ * 2. int buffering
+ */
+public class CICO_PBE_RW_Test extends CICO_PBE_Test {
+
+    public CICO_PBE_RW_Test(PBEAlgorithm pbeAlgo)
+            throws GeneralSecurityException {
+        super(pbeAlgo);
+    }
+
+    /**
+     * The CICO PBE RW test specific part of the super.doTest(). Implements the
+     * scenario in accordance to the class description.
+     * @param type byteArrayBuffering or intByteBuffering
+     * @throws IOException  any I/O operation failed.
+     * @throws GeneralSecurityException any security error.
+     */
+    @Override
+    public void proceedTest(String type) throws IOException,
+            GeneralSecurityException {
+        ByteArrayOutputStream baOutput = new ByteArrayOutputStream();
+        try (CipherOutputStream ciOutput = new CipherOutputStream(baOutput,
+                getDecryptCipher())) {
+            if (type.equals(CICO_PBE_Test.BYTE_ARR_BUFFER)) {
+                proceedTestUsingByteArrayBuffer(ciOutput);
+            } else {
+                proceedTestUsingIntBuffer(ciOutput);
+            }
+            ciOutput.flush();
+        }
+        // Compare input and output
+        if (!TestUtilities.equalsBlock(plainText, baOutput.toByteArray(), TEXT_SIZE)) {
+            throw new RuntimeException("outputText not same with expectedText"
+                    + " when test " + type);
+        }
+    }
+
+    /**
+     * Implements byte array buffering type test case of the CICO PBE RW test.
+     * @param ciOutput  output stream for data written.
+     * @throws java.io.IOException any I/O operation failed.
+     */
+    public void proceedTestUsingByteArrayBuffer(
+            CipherOutputStream ciOutput) throws IOException {
+        byte[] buffer = new byte[TEXT_SIZE];
+        int len = getCiInput().read(buffer);
+        while (len != -1) {
+            ciOutput.write(buffer, 0, len);
+            len = getCiInput().read(buffer);
+        }
+    }
+
+    /**
+     * Implements int buffering type test case.
+     * @param ciOutput output stream for data written.
+     * @throws java.io.IOException any I/O operation failed.
+     */
+    public void proceedTestUsingIntBuffer(CipherOutputStream ciOutput)
+            throws IOException {
+        int buffer = getCiInput().read();
+        while (buffer != -1) {
+            ciOutput.write(buffer);
+            buffer = getCiInput().read();
+        }
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/CICO_PBE_SKIP_Test.java b/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/CICO_PBE_SKIP_Test.java
new file mode 100644
index 0000000..62ebd83
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/CICO_PBE_SKIP_Test.java
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import javax.crypto.CipherInputStream;
+
+/**
+ * CICO PBE SKIP functional test.
+ *
+ * Verifies for the given PBE algorithm if the encrypt/decrypt mechanism is
+ * performed correctly for CipherInputStream when skip() method is used.
+ *
+ * Test scenario:
+ * 1. initializes plain text with random generated data with length TEXT_SIZE.
+ * 2. for the given PBE algorithm instantiates encrypt and decrypt Ciphers.
+ * 3. instantiates CipherInputStream 1 with the encrypt Cipher.
+ * 4. instantiates CipherInputStream 2 with the CipherInputStream 1 and decrypt
+ *    Cipher.
+ * 5. the plain text is divided on TEXT_SIZE/BLOCK blocks. Reading from
+ *    CipherInputStream 2 one block at time. The last BLOCK - SAVE bytes are
+ *    skipping for each block. Therefor the plain text data go through
+ *    CipherInputStream 1 (encrypting) and CipherInputStream 2 (decrypting).
+ *    As a result the output should equal to the original text except DISCARD
+ *    byte for each block are skipped.
+ * 6. get the standard output.
+ * 7. compares the expected standard output with the output of the
+ *    CipherInputStream 2. If it is the same the test passed. Otherwise it
+ *    failed. Any uncaught exceptions should be considered as an error.
+ * The test implements 2 test cases in accordance with a buffering type:
+ * 1. byte array buffering
+ * 2. int buffering
+ */
+public class CICO_PBE_SKIP_Test extends CICO_PBE_Test {
+    /**
+     * Block size.
+     */
+    private static final int BLOCK = 50;
+
+    /**
+     * Valid reading byte size.
+     */
+    private static final int SAVE = 45;
+
+    /**
+     * Skip reading byte size. This should be same to BLOCK - SAVE
+     */
+    private static final int DISCARD = BLOCK - SAVE;
+
+    /**
+     * Number of blocks.
+     */
+    private static final int NUMBER_OF_BLOCKS = TEXT_SIZE / BLOCK;
+
+    private final byte[] outputText;
+    /**
+     * CICO PBE Skip test constructor
+     *
+     * @param pbeAlgo the PBE algorithm to test.
+     * @throws java.security.GeneralSecurityException
+     */
+    public CICO_PBE_SKIP_Test(PBEAlgorithm pbeAlgo)
+            throws GeneralSecurityException {
+        super(pbeAlgo);
+        outputText = new byte[NUMBER_OF_BLOCKS * SAVE];
+    }
+
+    /**
+     * Implements byte array buffering type test case of the CICO SKIP test.
+     *
+     * @param blockNum block number to read.
+     */
+    private void proceedSkipTestUsingByteArrayBufferingType(
+            CipherInputStream ciIn2, int blockNum) throws IOException {
+        int index = blockNum * SAVE;
+        int len1 = ciIn2.read(outputText, index, SAVE);
+        // read more until SAVE bytes
+        index += len1;
+        int len2 = 0;
+        int totalRead = len1;
+        while (len1 != SAVE && len2 != -1) {
+            len2 = ciIn2.read(outputText, index, SAVE - len1);
+            len1 += len2;
+            index += len2;
+            totalRead += len2;
+        }
+        if (totalRead != SAVE) {
+            throw new RuntimeException("Read bytes number " + totalRead
+                    + " does not equal to given number " + SAVE);
+        }
+    }
+
+    /**
+     * Implements int buffering type test case of the CICO SKIP test.
+     *
+     * @param blockNum block number to read.
+     */
+    private void proceedSkipTestUsingIntBufferingType(CipherInputStream ciIn2,
+            int blockNum) throws IOException {
+        int index = blockNum * SAVE;
+        int totalRead = 0;
+        for (int j = 0; j < SAVE; j++, index++) {
+            int buffer0 = ciIn2.read();
+            if (buffer0 != -1) {
+                outputText[index] = (byte) buffer0;
+                totalRead++;
+            } else {
+                break;
+            }
+        }
+        if (totalRead != SAVE) {
+            throw new RuntimeException("Read bytes number " + totalRead
+                    + " does not equal to given number " + SAVE);
+        }
+    }
+
+    /**
+     * The CICO PBE SKIP test specific part of the super.doTest(). Implements
+     * the scenario in accordance to the class description.
+     * @throws java.io.IOException any I/O failed.
+     */
+    @Override
+    public void proceedTest(String type) throws IOException {
+        System.out.println("Test type: " + type);
+        // init second input stream with decrypt Cipher
+        try (CipherInputStream ciIn2 = new CipherInputStream(getCiInput(),
+                getDecryptCipher())) {
+            for (int i = 0; i < NUMBER_OF_BLOCKS; i++) {
+                if (type.equals(CICO_PBE_Test.BYTE_ARR_BUFFER)) {
+                    proceedSkipTestUsingByteArrayBufferingType(ciIn2, i);
+                } else {
+                    proceedSkipTestUsingIntBufferingType(ciIn2, i);
+                }
+                if (ciIn2.available() >= DISCARD) {
+                    ciIn2.skip(DISCARD);
+                } else {
+                    for (int k = 0; k < DISCARD; k++) {
+                        ciIn2.read();
+                    }
+                }
+            }
+        }
+        if (!TestUtilities.equalsBlockPartial(plainText, outputText, BLOCK, SAVE)) {
+            throw new RuntimeException("outputText not same with expectedText"
+                    + " when test " + type);
+        }
+    }
+
+}
diff --git a/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/CICO_PBE_Test.java b/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/CICO_PBE_Test.java
new file mode 100644
index 0000000..9879bf4
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/CICO_PBE_Test.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import javax.crypto.Cipher;
+import javax.crypto.CipherInputStream;
+
+/**
+ * This is an abstract class for CipherInputStream/CipherOutputStream PBE
+ * functional tests.
+ */
+public abstract class CICO_PBE_Test {
+    /**
+     * Sample string for byte buffer.
+     */
+    public static final String BYTE_ARR_BUFFER = "byteArrayBuffering";
+
+    /**
+     * Sample string for int buffer.
+     */
+    public static final String INT_BYTE_BUFFER = "intByteBuffering";
+    public static final String PASS_PHRASE = "Some password phrase!";
+
+    /**
+     * Text string size.
+     */
+    public static final int TEXT_SIZE = 800;
+
+    protected final byte[] plainText;
+    private final Cipher encryptCipher, decryptCipher;
+
+    /**
+     * An CipherInputStream for reading cipher and plain text.
+     */
+    private final CipherInputStream ciInput;
+
+    /**
+     * Constructor by algorithm.
+     * @param pbeAlgo PBE algorithm to test.
+     * @throws GeneralSecurityException if any security error.
+     */
+    public CICO_PBE_Test(PBEAlgorithm pbeAlgo) throws GeneralSecurityException {
+        // Do initialization of the plainText
+        plainText = TestUtilities.generateBytes(TEXT_SIZE);
+        // Do initialization of the ciphers
+        AbstractPBEWrapper pbeWrap = AbstractPBEWrapper.createWrapper(pbeAlgo, PASS_PHRASE);
+        encryptCipher = pbeWrap.initCipher(Cipher.ENCRYPT_MODE);
+        decryptCipher = pbeWrap.initCipher(Cipher.DECRYPT_MODE);
+        // init cipher input stream
+        ciInput = new CipherInputStream(new ByteArrayInputStream(plainText),
+                encryptCipher);
+    }
+
+    protected byte[] getPlainText() {
+        return plainText;
+    }
+
+    /**
+     * The body of the test. Should be defined in subclasses.
+     * @param type byteArrayBuffering or intByteBuffering
+     * @throws IOException I/O operation failed.
+     * @throws GeneralSecurityException all exceptions thrown.
+     */
+    protected abstract void proceedTest(String type)
+            throws IOException, GeneralSecurityException;
+
+    protected Cipher getEncryptCipher() {
+        return encryptCipher;
+    }
+
+    public CipherInputStream getCiInput() {
+        return ciInput;
+    }
+
+    public Cipher getDecryptCipher() {
+        return decryptCipher;
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/CipherNCFuncTest.java b/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/CipherNCFuncTest.java
new file mode 100644
index 0000000..73952eb
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/CipherNCFuncTest.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2001, 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 8048604
+ * @library ../ /lib/testlibrary
+ * @summary This test verifies the assertion "There should be no transformation
+ *  on the plaintext/ciphertext in encryption/decryption mechanism" for
+ *  feature "NullCipher".
+ */
+import javax.crypto.BadPaddingException;
+import javax.crypto.Cipher;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.NullCipher;
+import javax.crypto.ShortBufferException;
+import jdk.testlibrary.RandomFactory;
+
+public class CipherNCFuncTest {
+    public static void main(String[] args) throws ShortBufferException,
+            IllegalBlockSizeException, BadPaddingException {
+        byte[] plainText = new byte[801];
+        // Initialization
+        RandomFactory.getRandom().nextBytes(plainText);
+        Cipher ci = new NullCipher();
+        // Encryption
+        byte[] cipherText = new byte[ci.getOutputSize(plainText.length)];
+        int offset = ci.update(plainText, 0, plainText.length, cipherText, 0);
+        ci.doFinal(cipherText, offset);
+        // Decryption
+        byte[] recoveredText = new byte[ci.getOutputSize(cipherText.length)];
+        int len = ci.doFinal(cipherText, 0, cipherText.length, recoveredText);
+        // Comparison
+        if (len != plainText.length ||
+                !TestUtilities.equalsBlock(plainText, cipherText, len) ||
+                !TestUtilities.equalsBlock(plainText, recoveredText, len)) {
+            throw new RuntimeException(
+                "Test failed because plainText not equal to cipherText and revoveredText");
+        }
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/DefaultPBEWrapper.java b/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/DefaultPBEWrapper.java
new file mode 100644
index 0000000..f68fd85
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/DefaultPBEWrapper.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+import java.security.GeneralSecurityException;
+import java.security.Provider;
+import java.security.Security;
+import javax.crypto.SecretKey;
+import javax.crypto.Cipher;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.PBEKeySpec;
+import javax.crypto.spec.PBEParameterSpec;
+
+/**
+ * Default wrapper for a password based encryption Cipher.
+ */
+
+public class DefaultPBEWrapper extends AbstractPBEWrapper {
+    /**
+     * Define default SALT size as 8.
+     */
+    private static final int PBE_SALT_SIZE = 8;
+
+    /**
+     * Default PBE wrapper constructor.
+     *
+     * @param algo PGE algorithm to wrap.
+     * @param passwd password phrase
+     */
+    public DefaultPBEWrapper(PBEAlgorithm algo, String passwd) {
+        super(algo, passwd, PBE_SALT_SIZE);
+    }
+
+    /**
+     * Instantiate Cipher for the PBE algorithm.
+     *
+     * @param mode Cipher mode: encrypt or decrypt.
+     * @return Cipher in accordance to the PBE algorithm
+     * @throws java.security.GeneralSecurityException
+     */
+    @Override
+    protected Cipher initCipher(int mode) throws  GeneralSecurityException {
+        Provider provider = Security.getProvider("SunJCE");
+        if (provider == null) {
+            throw new RuntimeException("SunJCE provider does not exist.");
+        }
+        SecretKey key = SecretKeyFactory.getInstance(baseAlgo)
+                .generateSecret(new PBEKeySpec(password.toCharArray()));
+        Cipher ci = Cipher.getInstance(transformation, provider);
+        ci.init(mode, key, new PBEParameterSpec(salt, DEFAULT_ITERATION));
+        return ci;
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/PBEAlgorithm.java b/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/PBEAlgorithm.java
new file mode 100644
index 0000000..98ef4f2
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/PBEAlgorithm.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+
+import java.util.StringJoiner;
+
+public enum PBEAlgorithm {
+    MD5_DES("PBEWithMD5ANDdes", "", "", AbstractPBEWrapper.DEFAULT),
+    MD5_DES_CBC_PKCS5("PBEWithMD5AndDES", "CBC", "PKCS5Padding",
+            AbstractPBEWrapper.DEFAULT),
+    MD5_TRIPLEDES("PBEWithMD5ANDtripledes", "", "", AbstractPBEWrapper.DEFAULT),
+    MD5_TRIPLEDES_CBC_PKCS5("PBEWithMD5AndTRIPLEDES", "CBC", "PKCS5Padding",
+            AbstractPBEWrapper.DEFAULT),
+    SHA1_DESEDE("PBEwithSHA1AndDESede", "", "", AbstractPBEWrapper.DEFAULT),
+    SHA1_DESEDE_CBC_PKCS5("PBEwithSHA1AndDESede", "CBC", "PKCS5Padding",
+            AbstractPBEWrapper.DEFAULT),
+    SHA1_RC2_40("PBEwithSHA1AndRC2_40", "", "", AbstractPBEWrapper.DEFAULT),
+    SHA1_RC2_40_PKCS5("PBEwithSHA1Andrc2_40", "CBC", "PKCS5Padding",
+            AbstractPBEWrapper.DEFAULT),
+    SHA1_RC2_128("PBEWithSHA1AndRC2_128", "", "", AbstractPBEWrapper.DEFAULT),
+    SHA1_RC2_128_PKCS5("PBEWithSHA1andRC2_128", "CBC", "PKCS5Padding",
+            AbstractPBEWrapper.DEFAULT),
+    SHA1_RC4_40("PBEWithSHA1AndRC4_40", "", "", AbstractPBEWrapper.DEFAULT),
+    SHA1_RC4_40_ECB_NOPADDING("PBEWithsha1AndRC4_40", "ECB", "NoPadding",
+            AbstractPBEWrapper.DEFAULT),
+    SHA1_RC4_128("PBEWithSHA1AndRC4_128", "", "", AbstractPBEWrapper.DEFAULT),
+    SHA1_RC4_128_ECB_NOPADDING("pbeWithSHA1AndRC4_128", "ECB", "NoPadding",
+            AbstractPBEWrapper.DEFAULT),
+    HMAC_SHA1_AES_128("PBEWithHmacSHA1AndAES_128", "", "", AbstractPBEWrapper.AES),
+    HMAC_SHA224_AES_128("PBEWithHmacSHA224AndAES_128", "", "", AbstractPBEWrapper.AES),
+    HMAC_SHA256_AES_128("PBEWithHmacSHA256AndAES_128", "", "", AbstractPBEWrapper.AES),
+    HMAC_SHA384_AES_128("PBEWithHmacSHA384AndAES_128", "", "", AbstractPBEWrapper.AES),
+    HMAC_SHA512_AES_128("PBEWithHmacSHA512AndAES_128", "", "", AbstractPBEWrapper.AES),
+    HMAC_SHA1_AES_256("PBEWithHmacSHA1AndAES_256", "", "", AbstractPBEWrapper.AES),
+    HMAC_SHA224_AES_256("PBEWithHmacSHA224AndAES_256", "", "", AbstractPBEWrapper.AES),
+    HMAC_SHA256_AES_256("PBEWithHmacSHA256AndAES_256", "", "", AbstractPBEWrapper.AES),
+    HMAC_SHA384_AES_256("PBEWithHmacSHA384AndAES_256", "", "", AbstractPBEWrapper.AES),
+    HMAC_SHA512_AES_256("PBEWithHmacSHA512AndAES_256", "", "", AbstractPBEWrapper.AES),
+    PBKDF_HMAC_SHA1("PBKDF2WithHmacSHA1", "", "", AbstractPBEWrapper.PBKDF2),
+    PBKDF_HMAC_SHA224("PBKDF2WithHmacSHA224", "", "", AbstractPBEWrapper.PBKDF2),
+    PBKDF_HMAC_SHA256("PBKDF2WithHmacSHA256", "", "", AbstractPBEWrapper.PBKDF2),
+    PBKDF_HMAC_SHA384("PBKDF2WithHmacSHA384", "", "", AbstractPBEWrapper.PBKDF2),
+    PBKDF_HMAC_SHA512("PBKDF2WithHmacSHA512", "", "", AbstractPBEWrapper.PBKDF2);
+    final String baseAlgo;
+    final String mode;
+    final String padding;
+    final String type;
+
+    PBEAlgorithm(String alg, String mode, String padding, String type) {
+        this.baseAlgo = alg;
+        this.mode = mode;
+        this.padding = padding;
+        this.type = type;
+    }
+
+    public String getTransformation() {
+        StringJoiner sj = new StringJoiner("/");
+        sj.add(baseAlgo);
+        if (!mode.equals("")) {
+            sj.add(this.mode);
+        }
+        if (!padding.equals("")) {
+            sj.add(this.padding);
+        }
+        return sj.toString();
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/PBKDF2Wrapper.java b/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/PBKDF2Wrapper.java
new file mode 100644
index 0000000..fb2d0ac
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/PBKDF2Wrapper.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+
+import java.security.GeneralSecurityException;
+import java.security.Provider;
+import java.security.Security;
+import javax.crypto.Cipher;
+import javax.crypto.SecretKey;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.PBEKeySpec;
+import javax.crypto.spec.SecretKeySpec;
+
+/**
+ * Wrapper class to test a given SecretKeyFactory.PBKDF2 algorithm.
+ */
+public class PBKDF2Wrapper extends AbstractPBEWrapper {
+    /**
+     * Default salt size.
+     */
+    public static final int PBKDF2_SALT_SIZE = 64;
+
+    /**
+     * Default key length.
+     */
+    public static final int PKDF2_DEFAULT_KEY_LEN = 128;
+
+    /**
+     * Default transformation.
+     */
+    public static final String CIPHER_TRANSFORMATION = "AES/CBC/PKCS5Padding";
+
+    /**
+     * Algorithm name.
+     */
+    public static final String KEY_ALGORITHM = "AES";
+
+    /**
+     * Initialization vector length.
+     */
+    private static final int IV_LENGTH = 16;
+
+    /**
+     * The buffer with the IV.
+     */
+    private final byte[] iv;
+
+    /**
+     * PBKDF2Wrapper constructor. Instantiate Cipher using
+     * "AES/CBC/PKCS5Padding" transformation. Generate a secret key using PKDF2
+     * algorithms given in the "algo" parameter.
+     *
+     * @param algo AES-based PBE algorithm.
+     * @param passwd password phrase.
+     * @throws GeneralSecurityException all security exceptions are thrown.
+     */
+    public PBKDF2Wrapper(PBEAlgorithm algo, String passwd)
+            throws GeneralSecurityException {
+        super(algo, passwd, PBKDF2_SALT_SIZE);
+        iv = TestUtilities.generateBytes(IV_LENGTH);
+    }
+
+    /**
+     * Initiate the Cipher object for PBKDF2 algorithm using given "mode".
+     *
+     * @param mode Cipher mode: encrypt or decrypt
+     * @return Cipher object for PBKDF2 algorithm
+     * @throws GeneralSecurityException all security exceptions are thrown.
+     */
+    @Override
+    protected Cipher initCipher(int mode) throws GeneralSecurityException {
+        Provider provider = Security.getProvider("SunJCE");
+        if (provider == null) {
+            throw new RuntimeException("SunJCE provider does not exist.");
+        }
+        // Generate secret key
+        PBEKeySpec pbeKeySpec = new PBEKeySpec(password.toCharArray(),
+                salt, DEFAULT_ITERATION, PKDF2_DEFAULT_KEY_LEN);
+        SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(baseAlgo);
+        SecretKey key = keyFactory.generateSecret(pbeKeySpec);
+
+        // get Cipher instance
+        Cipher cipher = Cipher.getInstance(CIPHER_TRANSFORMATION, provider);
+        cipher.init(mode,
+                new SecretKeySpec(key.getEncoded(),KEY_ALGORITHM),
+                new IvParameterSpec(iv));
+        return cipher;
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/CICO/ReadModel.java b/jdk/test/com/sun/crypto/provider/CICO/ReadModel.java
new file mode 100644
index 0000000..d1cfb71
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/CICO/ReadModel.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+import java.io.IOException;
+
+import javax.crypto.Cipher;
+import javax.crypto.CipherInputStream;
+import javax.crypto.CipherOutputStream;
+
+/**
+ * ReadModel provides different way to test
+ * CipherInputStream.read()/read(byte[])/read(byte[], int, int) and
+ * CipherOutputStream.write(int)/write(byte[], int, int)/read(byte[]) API
+ */
+enum ReadModel {
+    READ_BYTE {
+        @Override
+        public void read(CipherInputStream cInput, CipherOutputStream ciOutput,
+                Cipher ciIn, int inputLen) throws IOException {
+            int buffer0 = cInput.read();
+            while (buffer0 != -1) {
+                ciOutput.write(buffer0);
+                buffer0 = cInput.read();
+            }
+        }
+    },
+    READ_BUFFER {
+        @Override
+        public void read(CipherInputStream cInput, CipherOutputStream ciOutput,
+                Cipher ciIn, int inputLen) throws IOException {
+            byte[] buffer1 = new byte[20];
+            int len1;
+            while ((len1 = cInput.read(buffer1)) != -1) {
+                ciOutput.write(buffer1, 0, len1);
+            }
+
+        }
+    },
+    READ_BUFFER_OFFSET {
+        @Override
+        public void read(CipherInputStream cInput, CipherOutputStream ciOutput,
+                Cipher ciIn, int inputLen) throws IOException {
+            byte[] buffer2 = new byte[ciIn.getOutputSize(inputLen)];
+            int offset2 = 0;
+            int len2 = 0;
+            while (len2 != -1) {
+                len2 = cInput.read(buffer2, offset2, buffer2.length - offset2);
+                offset2 += len2;
+            }
+            ciOutput.write(buffer2);
+
+        }
+    };
+
+    abstract public void read(CipherInputStream cInput,
+            CipherOutputStream ciOutput, Cipher ciIn, int inputLen)
+            throws IOException;
+}
diff --git a/jdk/test/com/sun/crypto/provider/CICO/TestUtilities.java b/jdk/test/com/sun/crypto/provider/CICO/TestUtilities.java
new file mode 100644
index 0000000..a1160f7
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/CICO/TestUtilities.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+
+/*
+ * utility class
+ */
+
+public class TestUtilities {
+    public static boolean equalsBlock(byte[] b1, byte[] b2, int len) {
+        for (int i = 0; i < len; i++) {
+            if (b1[i] != b2[i]) {
+                System.err.println("b1[" + i + "] : " + b1[i]
+                        + " b2[" + i + "] : " + b2[i]);
+                return false;
+            }
+        }
+        return true;
+    }
+
+    public static boolean equals(byte[] b1, byte[] b2) {
+        if (b2.length != b1.length) {
+            System.err.println("b1.length = " + b1.length
+                    + " b2.length = " + b2.length );
+            return false;
+        }
+        return equalsBlock(b1, b2, b1.length);
+    }
+
+    /**
+     * Verify b1's partial part is same as b2. compares b1 and b2 by chopping up
+     * b1 into blocks of b1BKSize and b2 into blocks of b2BKSize, and then
+     * compare the first b2BKSize bytes of each block, return true if they equal
+     * , otherwise return false.
+     * @param b1 byte array to be compared.
+     * @param b2 saved byte array.
+     * @param b1BKSize b1's block size.
+     * @param b2BKSize b2's block size.
+     * @return true is same. false otherwise.
+     */
+    public static boolean equalsBlockPartial(byte[] b1, byte[] b2, int b1BKSize,
+            int b2BKSize) {
+        int numOfBlock = b1.length / b1BKSize;
+        for (int b = 0; b < numOfBlock; b++) {
+            for (int i = 0; i < b2BKSize; i++) {
+                int j1 = b * b1BKSize + i;
+                int j2 = b * b2BKSize + i;
+                if (b1[j1] != b2[j2]) {
+                    System.err.println("Compare failed at b1[" + j1 + "]:" +
+                            b1[j1] + " b2[" + j2 + "]:" + b2[j2]);
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+
+    /**
+     * Generate a byte block by given length. The content of byte block
+     * is determined by the index.
+     * @param length length of byte array
+     * @return a byte array
+     */
+    public static byte[] generateBytes(int length) {
+        byte[] bytes = new byte[length];
+        for (int i = 0; i < length; i++) {
+            bytes[i] = (byte) (i & 0xff);
+        }
+        return bytes;
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/Cipher/AEAD/Encrypt.java b/jdk/test/com/sun/crypto/provider/Cipher/AEAD/Encrypt.java
new file mode 100644
index 0000000..d96cb00
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Cipher/AEAD/Encrypt.java
@@ -0,0 +1,753 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+
+import java.nio.ByteBuffer;
+import java.security.AlgorithmParameters;
+import java.security.Provider;
+import java.security.Security;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import javax.crypto.SecretKey;
+import javax.crypto.Cipher;
+import javax.crypto.KeyGenerator;
+
+/*
+ * @test
+ * @bug 8048596
+ * @summary AEAD encryption/decryption test
+ */
+
+/*
+ * The test does the following:
+ *   - create an input text and additional data
+ *   - generate a secret key
+ *   - instantiate a cipher according to the GCM transformation
+ *   - generate an outputText using a single-part encryption/decryption
+ *     in AEAD mode
+ *   - perform 16 different combinations of multiple-part encryption/decryption
+ *     operation in AEAD mode (in encryption mode new Cipher object is created
+ *     and initialized with the same secret key and parameters)
+ *   - check that all 17 results are equal
+ *
+ * Combinations:
+ *
+ * combination #1
+ *   updateAAD(byte[] src)
+ *   update(byte[], int, int)
+ *   doFinal(byte[], int, int)
+ *
+ * combination #2
+ *   updateAAD(byte[] src)
+ *   update(byte[], int, int)
+ *   doFinal(byte[], int, int, byte[], int)
+ *
+ * combination #3
+ *   updateAAD(byte[] src)
+ *   update(byte[], int, int, byte[], int)
+ *   doFinal(byte[], int, int)
+ *
+ * combination #4
+ *   updateAAD(byte[] src)
+ *   update(byte[], int, int, byte[], int)
+ *   doFinal(byte[], int, int, byte[], int)
+ *
+ * combination #5 - #8 are similar to #1 -#4,
+ * but with updateAAD(byte[] src, int offset, int len)
+ *
+ * combination #9 - #12 are similar to #1 - #4,
+ * but with updateAAD(ByteBuffer src)
+ *
+ * combination #13 - #16 are similar to #9 - #12 but with directly allocated
+ * ByteBuffer and update(ByteBuffer input, ByteBuffer output)
+ *
+ */
+public class Encrypt {
+
+    private static final String ALGORITHMS[] = { "AES", "Rijndael" };
+    private static final int KEY_STRENGTHS[] = { 128, 192, 256 };
+    private static final int TEXT_LENGTHS[] = { 0, 256, 1024 };
+    private static final int AAD_LENGTHS[] = { 0, 8, 128, 256, 1024 };
+    private static final int ARRAY_OFFSET = 8;
+
+    private final String transformation;
+    private final Provider provider;
+    private final SecretKey key;
+    private final int textLength;
+    private final int AADLength;
+
+    /**
+     * @param provider Security provider
+     * @param algorithm Security algorithm to test
+     * @param mode The mode (GCM is only expected)
+     * @param padding Algorithm padding
+     * @param keyStrength key length
+     * @param textLength Plain text length
+     * @param AADLength Additional data length
+     */
+    public Encrypt(Provider provider, String algorithm, String mode,
+            String padding, int keyStrength, int textLength, int AADLength)
+            throws Exception {
+
+        // init a secret Key
+        KeyGenerator kg = KeyGenerator.getInstance(algorithm, provider);
+        kg.init(keyStrength);
+        key = kg.generateKey();
+
+        this.provider = provider;
+        this.transformation = algorithm + "/" + mode + "/" + padding;
+        this.textLength = textLength;
+        this.AADLength = AADLength;
+    }
+
+    public static void main(String[] args) throws Exception {
+        Provider p = Security.getProvider("SunJCE");
+        for (String alg : ALGORITHMS) {
+            for (int keyStrength : KEY_STRENGTHS) {
+                if (keyStrength > Cipher.getMaxAllowedKeyLength(alg)) {
+                    // skip this if this key length is larger than what's
+                    // configured in the JCE jurisdiction policy files
+                    continue;
+                }
+                for (int textLength : TEXT_LENGTHS) {
+                    for (int AADLength : AAD_LENGTHS) {
+                        Encrypt test = new Encrypt(p, alg,
+                                "GCM", "NoPadding", keyStrength, textLength,
+                                AADLength);
+                        Cipher cipher = test.createCipher(Cipher.ENCRYPT_MODE,
+                                null);
+                        AlgorithmParameters params = cipher.getParameters();
+                        test.doTest(params);
+                        System.out.println("Test " + alg + ":"
+                                + keyStrength + ":" + textLength + ":"
+                                + AADLength + " passed");
+                    }
+                }
+            }
+        }
+    }
+
+    public void doTest(AlgorithmParameters params) throws Exception {
+        System.out.println("Test transformation = " + transformation
+                + ", textLength = " + textLength
+                + ", AADLength = " + AADLength);
+        byte[] input = Helper.generateBytes(textLength);
+        byte[] AAD = Helper.generateBytes(AADLength);
+        byte[] result = execute(Cipher.ENCRYPT_MODE, AAD, input, params);
+        result = execute(Cipher.DECRYPT_MODE, AAD, result, params);
+        if (!Arrays.equals(input, result)) {
+            throw new RuntimeException("Test failed");
+        }
+        System.out.println("Test passed");
+    }
+
+    /**
+     * Create a Cipher object for the requested encryption/decryption mode.
+     *
+     * @param mode encryption or decryption mode
+     * @return Cipher object initiated to perform requested mode operation
+     */
+    private Cipher createCipher(int mode, AlgorithmParameters params)
+            throws Exception {
+        Cipher ci;
+        if (Cipher.ENCRYPT_MODE == mode) {
+            // create a new Cipher object for encryption
+            ci = Cipher.getInstance(transformation, provider);
+
+            // initiate it with the saved parameters
+            if (params != null) {
+                ci.init(Cipher.ENCRYPT_MODE, key, params);
+            } else {
+                // initiate the cipher without parameters
+                ci.init(Cipher.ENCRYPT_MODE, key);
+            }
+        } else {
+            // it is expected that parameters already generated
+            // before decryption
+            ci = Cipher.getInstance(transformation, provider);
+            ci.init(Cipher.DECRYPT_MODE, key, params);
+        }
+
+        return ci;
+    }
+
+    /**
+     * Test AEAD combinations
+     *
+     * @param mode decryption or encryption
+     * @param AAD additional data for AEAD operations
+     * @param inputText plain text to decrypt/encrypt
+     * @return output text after encrypt/decrypt
+     */
+    public byte[] execute(int mode, byte[] AAD, byte[] inputText,
+            AlgorithmParameters params) throws Exception {
+
+        Cipher cipher = createCipher(mode, params);
+
+        // results of each combination will be saved in the outputTexts
+        List<byte[]> outputTexts = new ArrayList<>();
+
+        // generate a standard outputText using a single-part en/de-cryption
+        cipher.updateAAD(AAD);
+        byte[] output = cipher.doFinal(inputText);
+
+        // execute multiple-part encryption/decryption combinations
+        combination_1(outputTexts, mode, AAD, inputText, params);
+        combination_2(outputTexts, mode, AAD, inputText, params);
+        combination_3(outputTexts, mode, AAD, inputText, params);
+        combination_4(outputTexts, mode, AAD, inputText, params);
+        combination_5(outputTexts, mode, AAD, inputText, params);
+        combination_6(outputTexts, mode, AAD, inputText, params);
+        combination_7(outputTexts, mode, AAD, inputText, params);
+        combination_8(outputTexts, mode, AAD, inputText, params);
+        combination_9(outputTexts, mode, AAD, inputText, params);
+        combination_10(outputTexts, mode, AAD, inputText, params);
+        combination_11(outputTexts, mode, AAD, inputText, params);
+        combination_12(outputTexts, mode, AAD, inputText, params);
+        combination_13(outputTexts, mode, AAD, inputText, params);
+        combination_14(outputTexts, mode, AAD, inputText, params);
+        combination_15(outputTexts, mode, AAD, inputText, params);
+        combination_16(outputTexts, mode, AAD, inputText, params);
+
+        for (int k = 0; k < outputTexts.size(); k++) {
+            if (!Arrays.equals(output, outputTexts.get(k))) {
+                throw new RuntimeException("Combination #" + k + " failed");
+            }
+        }
+        return output;
+    }
+
+    /*
+     * Execute multiple-part encryption/decryption combination #1:
+     *   updateAAD(byte[] src)
+     *   update(byte[], int, int)
+     *   doFinal(byte[], int, int)
+     */
+    private void combination_1(List<byte[]> results, int mode, byte[] AAD,
+            byte[] plainText, AlgorithmParameters params) throws Exception {
+        Cipher c = createCipher(mode, params);
+        c.updateAAD(AAD);
+        byte[] part11 = c.update(plainText, 0, plainText.length);
+        int part11_length = part11 == null ? 0 : part11.length;
+        byte[] part12 = c.doFinal();
+        byte[] outputText1 = new byte[part11_length + part12.length];
+        if (part11 != null) {
+            System.arraycopy(part11, 0, outputText1, 0, part11_length);
+        }
+        System.arraycopy(part12, 0, outputText1, part11_length, part12.length);
+        results.add(outputText1);
+    }
+
+    /*
+     * Execute multiple-part encryption/decryption combination #2:
+     *   updateAAD(byte[] src)
+     *   update(byte[], int, int)
+     *   doFinal(byte[], int, int, byte[], int)
+     */
+    private void combination_2(List<byte[]> results, int mode, byte[] AAD,
+            byte[] plainText, AlgorithmParameters params) throws Exception {
+        Cipher c = createCipher(mode, params);
+        c.updateAAD(AAD);
+        int t = 0;
+        int offset = 0;
+        if (plainText.length > ARRAY_OFFSET) {
+            t = plainText.length - ARRAY_OFFSET;
+            offset = ARRAY_OFFSET;
+        }
+        byte[] part21 = c.update(plainText, 0, t);
+        byte[] part22 = new byte[c.getOutputSize(plainText.length)];
+        int len2 = c.doFinal(plainText, t, offset, part22, 0);
+        int part21Length = part21 != null ? part21.length : 0;
+        byte[] outputText2 = new byte[part21Length + len2];
+        if (part21 != null) {
+            System.arraycopy(part21, 0, outputText2, 0, part21Length);
+        }
+        System.arraycopy(part22, 0, outputText2, part21Length, len2);
+        results.add(outputText2);
+    }
+
+    /*
+     * Execute multiple-part encryption/decryption combination #3
+     *   updateAAD(byte[] src)
+     *   update(byte[], int, int, byte[], int)
+     *   doFinal(byte[], int, int)
+     */
+    private void combination_3(List<byte[]> results, int mode, byte[] AAD,
+            byte[] plainText, AlgorithmParameters params) throws Exception {
+        Cipher ci = createCipher(mode, params);
+        ci.updateAAD(AAD);
+        byte[] part31 = new byte[ci.getOutputSize(plainText.length)];
+        int offset = plainText.length > ARRAY_OFFSET ? ARRAY_OFFSET : 0;
+        int len = ci.update(plainText, 0, plainText.length - offset, part31, 0);
+        byte[] part32 = ci.doFinal(plainText, plainText.length - offset,
+                offset);
+        byte[] outputText3 = new byte[len + part32.length];
+        System.arraycopy(part31, 0, outputText3, 0, len);
+        System.arraycopy(part32, 0, outputText3, len, part32.length);
+        results.add(outputText3);
+    }
+
+    /*
+     * Execute multiple-part encryption/decryption combination #4:
+     *   updateAAD(byte[] src)
+     *   update(byte[], int, int, byte[], int)
+     *   doFinal(byte[], int, int, byte[], int)
+     */
+    private void combination_4(List<byte[]> results, int mode, byte[] AAD,
+            byte[] plainText, AlgorithmParameters params) throws Exception {
+        Cipher ci = createCipher(mode, params);
+        ci.updateAAD(AAD);
+        byte[] part41 = new byte[ci.getOutputSize(plainText.length)];
+        int offset = plainText.length > ARRAY_OFFSET ? ARRAY_OFFSET : 0;
+        int len = ci.update(plainText, 0, plainText.length - offset, part41, 0);
+        int rest4 = ci.doFinal(plainText, plainText.length - offset, offset,
+                part41, len);
+        byte[] outputText4 = new byte[len + rest4];
+        System.arraycopy(part41, 0, outputText4, 0, outputText4.length);
+        results.add(outputText4);
+    }
+
+    /*
+     * Execute multiple-part encryption/decryption combination #5:
+     *   updateAAD(byte[] src, int offset, int len)
+     *   update(byte[], int, int)
+     *   doFinal(byte[], int, int)
+     */
+    private void combination_5(List<byte[]> results, int mode, byte[] AAD,
+            byte[] plainText, AlgorithmParameters params) throws Exception {
+        Cipher c = createCipher(mode, params);
+        c.updateAAD(AAD, 0, AAD.length);
+        byte[] part51 = c.update(plainText, 0, plainText.length);
+        byte[] part52 = c.doFinal();
+        int part51Length = part51 != null ? part51.length : 0;
+        byte[] outputText5 = new byte[part51Length + part52.length];
+        if (part51 != null) {
+            System.arraycopy(part51, 0, outputText5, 0, part51Length);
+        }
+        System.arraycopy(part52, 0, outputText5, part51Length, part52.length);
+        results.add(outputText5);
+    }
+
+    /*
+     * Execute multiple-part encryption/decryption combination #6:
+     *   updateAAD(byte[] src, int offset, int len)
+     *   updateAAD(byte[] src, int offset, int len)
+     *   update(byte[], int, int) doFinal(byte[], int, int, byte[], int)
+     */
+    private void combination_6(List<byte[]> results, int mode, byte[] AAD,
+            byte[] plainText, AlgorithmParameters params) throws Exception {
+        Cipher c = createCipher(mode, params);
+        c.updateAAD(AAD, 0, AAD.length / 2);
+        c.updateAAD(AAD, AAD.length / 2, AAD.length - AAD.length / 2);
+        int t = 0;
+        int offset = 0;
+        if (plainText.length > ARRAY_OFFSET) {
+            t = plainText.length - ARRAY_OFFSET;
+            offset = ARRAY_OFFSET;
+        }
+        byte[] part61 = c.update(plainText, 0, t);
+        byte[] part62 = new byte[c.getOutputSize(plainText.length)];
+        int len = c.doFinal(plainText, t, offset, part62, 0);
+        int part61Length = part61 != null ? part61.length : 0;
+        byte[] outputText6 = new byte[part61Length + len];
+        if (part61 != null) {
+            System.arraycopy(part61, 0, outputText6, 0, part61Length);
+        }
+        System.arraycopy(part62, 0, outputText6, part61Length, len);
+        results.add(outputText6);
+    }
+
+    /*
+     * Execute multiple-part encryption/decryption combination #7
+     *   updateAAD(byte[] src, int offset, int len)
+     *   updateAAD(byte[] src, src.length, 0)
+     *   update(byte[], int, int, byte[], int) doFinal(byte[],int, int)
+     */
+    private void combination_7(List<byte[]> results, int mode, byte[] AAD,
+            byte[] plainText, AlgorithmParameters params) throws Exception {
+        Cipher ci = createCipher(mode, params);
+        ci.updateAAD(AAD, 0, AAD.length);
+        ci.updateAAD(AAD, AAD.length, 0);
+        byte[] part71 = new byte[ci.getOutputSize(plainText.length)];
+        int offset = plainText.length > ARRAY_OFFSET ? ARRAY_OFFSET : 0;
+        int len = ci.update(plainText, 0, plainText.length - offset, part71, 0);
+        byte[] part72 = ci.doFinal(plainText, plainText.length - offset, offset);
+        byte[] outputText7 = new byte[len + part72.length];
+        System.arraycopy(part71, 0, outputText7, 0, len);
+        System.arraycopy(part72, 0, outputText7, len, part72.length);
+        results.add(outputText7);
+    }
+
+    /*
+     * Execute multiple-part encryption/decryption combination #8:
+     *   updateAAD(byte[] src, 0, 0)
+     *   updateAAD(byte[] src, 0, src.length)
+     *   update(byte[], int, int, byte[], int)
+     *   doFinal(byte[], int, int, byte[], int)
+     */
+    private void combination_8(List<byte[]> results, int mode, byte[] AAD,
+            byte[] plainText, AlgorithmParameters params) throws Exception {
+        Cipher ci = createCipher(mode, params);
+        ci.updateAAD(AAD, 0, 0);
+        ci.updateAAD(AAD, 0, AAD.length);
+        byte[] part81 = new byte[ci.getOutputSize(plainText.length)];
+        int offset = plainText.length > ARRAY_OFFSET ? ARRAY_OFFSET : 0;
+        int len = ci.update(plainText, 0, plainText.length - offset, part81, 0);
+        int rest = ci.doFinal(plainText, plainText.length - offset, offset,
+                part81, len);
+        byte[] outputText8 = new byte[len + rest];
+        System.arraycopy(part81, 0, outputText8, 0, outputText8.length);
+        results.add(outputText8);
+    }
+
+    /*
+     * Execute multiple-part encryption/decryption combination #9:
+     *   updateAAD(ByteBuffer src)
+     *   update(byte[], int, int) doFinal(byte[], int, int)
+     */
+    private void combination_9(List<byte[]> results, int mode, byte[] AAD,
+            byte[] plainText, AlgorithmParameters params) throws Exception {
+
+        // prepare ByteBuffer to test
+        ByteBuffer buf = ByteBuffer.allocate(AAD.length);
+        buf.put(AAD);
+        buf.position(0);
+        buf.limit(AAD.length);
+
+        // Get Cipher object and do the combination
+        Cipher c = createCipher(mode, params);
+        c.updateAAD(buf);
+        byte[] part91 = c.update(plainText, 0, plainText.length);
+        int part91_length = part91 == null ? 0 : part91.length;
+        byte[] part92 = c.doFinal();
+        byte[] outputText9 = new byte[part91_length + part92.length];
+
+        // form result of the combination
+        if (part91 != null) {
+            System.arraycopy(part91, 0, outputText9, 0, part91_length);
+        }
+        System.arraycopy(part92, 0, outputText9, part91_length, part92.length);
+        results.add(outputText9);
+    }
+
+    /*
+     * Execute multiple-part encryption/decryption combination #10:
+     *   updateAAD(ByteBuffer src)
+     *   updateAAD(ByteBuffer src) update(byte[], int, int)
+     *   doFinal(byte[], int, int, byte[], int)
+     */
+    private void combination_10(List<byte[]> results, int mode, byte[] AAD,
+            byte[] plainText, AlgorithmParameters params) throws Exception {
+
+        // prepare ByteBuffer to test
+        ByteBuffer buf = ByteBuffer.allocate(AAD.length);
+        buf.put(AAD);
+        buf.position(0);
+        buf.limit(AAD.length / 2);
+
+        // get a Cipher object and do the combination
+        Cipher c = createCipher(mode, params);
+
+        // process the first half of AAD data
+        c.updateAAD(buf);
+
+        // process the rest of AAD data
+        buf.limit(AAD.length);
+        c.updateAAD(buf);
+
+        // prapare variables for the combination
+        int t = 0;
+        int offset = 0;
+        if (plainText.length > ARRAY_OFFSET) {
+            t = plainText.length - ARRAY_OFFSET;
+            offset = ARRAY_OFFSET;
+        }
+
+        // encrypt the text
+        byte[] part10_1 = c.update(plainText, 0, t);
+        int part10_1_Length = part10_1 != null ? part10_1.length : 0;
+        byte[] part10_2 = new byte[c.getOutputSize(plainText.length)];
+        int len2 = c.doFinal(plainText, t, offset, part10_2, 0);
+
+        // form the combination's result
+        byte[] outputText10 = new byte[part10_1_Length + len2];
+        if (part10_1 != null) {
+            System.arraycopy(part10_1, 0, outputText10, 0, part10_1_Length);
+        }
+        System.arraycopy(part10_2, 0, outputText10, part10_1_Length, len2);
+        results.add(outputText10);
+    }
+
+    /*
+     * Execute multiple-part encryption/decryption combination #11
+     *   updateAAD(ByteBuffer src1)
+     *   updateAAD(ByteBuffer src2)
+     *   update(byte[],int, int, byte[], int)
+     *   doFinal(byte[], int, int)
+     */
+    private void combination_11(List<byte[]> results, int mode, byte[] AAD,
+            byte[] plainText, AlgorithmParameters params) throws Exception {
+
+        // prepare ByteBuffer1 to test
+        ByteBuffer buf1 = ByteBuffer.allocate(AAD.length / 2);
+        buf1.put(AAD, 0, AAD.length / 2);
+        buf1.position(0);
+        buf1.limit(AAD.length / 2);
+
+        // get a Cipher object and do combination
+        Cipher ci = createCipher(mode, params);
+
+        // process the first half of AAD data
+        ci.updateAAD(buf1);
+
+        // prepare ByteBuffer2 to test
+        ByteBuffer buf2 = ByteBuffer.allocate(AAD.length - AAD.length / 2);
+        buf2.put(AAD, AAD.length / 2, AAD.length - AAD.length / 2);
+        buf2.position(0);
+        buf2.limit(AAD.length - AAD.length / 2);
+
+        // process the rest of AAD data
+        ci.updateAAD(buf2);
+
+        // encrypt plain text
+        byte[] part11_1 = new byte[ci.getOutputSize(plainText.length)];
+        int offset = plainText.length > ARRAY_OFFSET ? ARRAY_OFFSET : 0;
+        int len_11 = ci.update(plainText, 0, plainText.length - offset,
+                part11_1, 0);
+        byte[] part11_2 = ci.doFinal(plainText, plainText.length - offset,
+                offset);
+        byte[] outputText11 = new byte[len_11 + part11_2.length];
+        System.arraycopy(part11_1, 0, outputText11, 0, len_11);
+        System.arraycopy(part11_2, 0, outputText11, len_11, part11_2.length);
+        results.add(outputText11);
+    }
+
+    /*
+     * Execute multiple-part encryption/decryption combination #12:
+     *   updateAAD(ByteBuffer src)
+     *   updateAAD(ByteBuffer emptyByteBuffer)
+     *   update(byte[], int, int, byte[], int)
+     *   doFinal(byte[], int, int, byte[], int)
+     */
+    private void combination_12(List<byte[]> results, int mode, byte[] AAD,
+            byte[] plainText, AlgorithmParameters params) throws Exception {
+
+        // prepare ByteBuffer to test
+        ByteBuffer buf = ByteBuffer.allocate(AAD.length);
+        buf.put(AAD);
+        buf.position(0);
+        buf.limit(AAD.length);
+        Cipher ci = createCipher(mode, params);
+        ci.updateAAD(buf);
+
+        // prepare an empty ByteBuffer
+        ByteBuffer emptyBuf = ByteBuffer.allocate(0);
+        emptyBuf.put(new byte[0]);
+        ci.updateAAD(emptyBuf);
+        byte[] part12_1 = new byte[ci.getOutputSize(plainText.length)];
+        int offset = plainText.length > ARRAY_OFFSET ? ARRAY_OFFSET : 0;
+        int len12 = ci.update(plainText, 0, plainText.length - offset,
+                part12_1, 0);
+        int rest12 = ci.doFinal(plainText, plainText.length - offset, offset,
+                part12_1, len12);
+        byte[] outputText12 = new byte[len12 + rest12];
+        System.arraycopy(part12_1, 0, outputText12, 0, outputText12.length);
+        results.add(outputText12);
+    }
+
+    /*
+     * Execute multiple-part encryption/decryption combination #13:
+     *   updateAAD(ByteBuffer src), where src is directly allocated
+     *   update(ByteBuffer input, ByteBuffer out)
+     *   doFinal(ByteBuffer input, ByteBuffer out)
+     */
+    private void combination_13(List<byte[]> results, int mode, byte[] AAD,
+            byte[] plainText, AlgorithmParameters params) throws Exception {
+        Cipher c = createCipher(mode, params);
+
+        // prepare ByteBuffer to test
+        ByteBuffer buf = ByteBuffer.allocateDirect(AAD.length);
+        buf.put(AAD);
+        buf.position(0);
+        buf.limit(AAD.length);
+        c.updateAAD(buf);
+
+        // prepare buffers to encrypt/decrypt
+        ByteBuffer in = ByteBuffer.allocateDirect(plainText.length);
+        in.put(plainText);
+        in.position(0);
+        in.limit(plainText.length);
+        ByteBuffer output = ByteBuffer.allocateDirect(
+                c.getOutputSize(in.limit()));
+        output.position(0);
+        output.limit(c.getOutputSize(in.limit()));
+
+        // process input text
+        c.update(in, output);
+        c.doFinal(in, output);
+        int resultSize = output.position();
+        byte[] result13 = new byte[resultSize];
+        output.position(0);
+        output.limit(resultSize);
+        output.get(result13, 0, resultSize);
+        results.add(result13);
+    }
+
+    /*
+     * Execute multiple-part encryption/decryption combination #14:
+     *   updateAAD(ByteBuffer src) updateAAD(ByteBuffer src),
+     *       where src is directly allocated
+     *   update(ByteBuffer input, ByteBuffer out)
+     *   doFinal(ByteBuffer input, ByteBuffer out)
+     */
+    private void combination_14(List<byte[]> results, int mode, byte[] AAD,
+            byte[] plainText, AlgorithmParameters params) throws Exception {
+        Cipher c = createCipher(mode, params);
+        // prepare ByteBuffer to test
+        ByteBuffer buf = ByteBuffer.allocateDirect(AAD.length);
+        buf.put(AAD);
+
+        // process the first half of AAD data
+        buf.position(0);
+        buf.limit(AAD.length / 2);
+        c.updateAAD(buf);
+
+        // process the rest of AAD data
+        buf.limit(AAD.length);
+        c.updateAAD(buf);
+
+        // prepare buffers to encrypt/decrypt
+        ByteBuffer in = ByteBuffer.allocate(plainText.length);
+        in.put(plainText);
+        in.position(0);
+        in.limit(plainText.length);
+        ByteBuffer out = ByteBuffer.allocate(c.getOutputSize(in.limit()));
+        out.position(0);
+        out.limit(c.getOutputSize(in.limit()));
+
+        // process input text
+        c.update(in, out);
+        c.doFinal(in, out);
+        int resultSize = out.position();
+        byte[] result14 = new byte[resultSize];
+        out.position(0);
+        out.limit(resultSize);
+        out.get(result14, 0, resultSize);
+        results.add(result14);
+    }
+
+    /*
+     * Execute multiple-part encryption/decryption combination #15
+     *   updateAAD(ByteBuffer src1), where src1 is directly allocated
+     *   updateAAD(ByteBuffer src2), where src2 is directly allocated
+     *   doFinal(ByteBuffer input, ByteBuffer out)
+     */
+    private void combination_15(List<byte[]> results, int mode, byte[] AAD,
+            byte[] plainText, AlgorithmParameters params) throws Exception {
+        Cipher c = createCipher(mode, params);
+
+        // prepare ByteBuffer1 to test
+        ByteBuffer buf1 = ByteBuffer.allocateDirect(AAD.length / 2);
+        buf1.put(AAD, 0, AAD.length / 2);
+        buf1.position(0);
+        buf1.limit(AAD.length / 2);
+
+        // process the first half of AAD data
+        c.updateAAD(buf1);
+
+        // prepare ByteBuffer2 to test
+        ByteBuffer buf2 = ByteBuffer.allocateDirect(
+                AAD.length - AAD.length / 2);
+        buf2.put(AAD, AAD.length / 2, AAD.length - AAD.length / 2);
+        buf2.position(0);
+        buf2.limit(AAD.length - AAD.length / 2);
+
+        // process the rest of AAD data
+        c.updateAAD(buf2);
+
+        // prepare buffers to encrypt/decrypt
+        ByteBuffer in = ByteBuffer.allocateDirect(plainText.length);
+        in.put(plainText);
+        in.position(0);
+        in.limit(plainText.length);
+        ByteBuffer output = ByteBuffer.allocateDirect(
+                c.getOutputSize(in.limit()));
+        output.position(0);
+        output.limit(c.getOutputSize(in.limit()));
+
+        // process input text
+        c.doFinal(in, output);
+        int resultSize = output.position();
+        byte[] result15 = new byte[resultSize];
+        output.position(0);
+        output.limit(resultSize);
+        output.get(result15, 0, resultSize);
+        results.add(result15);
+    }
+
+    /*
+     * Execute multiple-part encryption/decryption combination #16:
+     *   updateAAD(ByteBuffer src)
+     *   updateAAD(ByteBuffer emptyByteBuffer)
+     *   update(ByteBuffer input, ByteBuffer out)
+     *   doFinal(EmptyByteBuffer, ByteBuffer out)
+     */
+    private void combination_16(List<byte[]> results, int mode, byte[] AAD,
+            byte[] plainText, AlgorithmParameters params) throws Exception {
+        Cipher c = createCipher(mode, params);
+
+        // prepare ByteBuffer to test
+        ByteBuffer buf = ByteBuffer.allocateDirect(AAD.length);
+        buf.put(AAD);
+        buf.position(0);
+        buf.limit(AAD.length);
+        c.updateAAD(buf);
+
+        // prepare empty ByteBuffer
+        ByteBuffer emptyBuf = ByteBuffer.allocateDirect(0);
+        emptyBuf.put(new byte[0]);
+        c.updateAAD(emptyBuf);
+
+        // prepare buffers to encrypt/decrypt
+        ByteBuffer in = ByteBuffer.allocateDirect(plainText.length);
+        in.put(plainText);
+        in.position(0);
+        in.limit(plainText.length);
+        ByteBuffer output = ByteBuffer.allocateDirect(
+                c.getOutputSize(in.limit()));
+        output.position(0);
+        output.limit(c.getOutputSize(in.limit()));
+
+        // process input text with an empty buffer
+        c.update(in, output);
+        ByteBuffer emptyBuf2 = ByteBuffer.allocate(0);
+        emptyBuf2.put(new byte[0]);
+        c.doFinal(emptyBuf2, output);
+        int resultSize = output.position();
+        byte[] result16 = new byte[resultSize];
+        output.position(0);
+        output.limit(resultSize);
+        output.get(result16, 0, resultSize);
+        results.add(result16);
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/Cipher/AEAD/GCMParameterSpecTest.java b/jdk/test/com/sun/crypto/provider/Cipher/AEAD/GCMParameterSpecTest.java
new file mode 100644
index 0000000..7250c4d
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Cipher/AEAD/GCMParameterSpecTest.java
@@ -0,0 +1,218 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.util.Arrays;
+import javax.crypto.SecretKey;
+import javax.crypto.Cipher;
+import javax.crypto.KeyGenerator;
+import javax.crypto.spec.GCMParameterSpec;
+
+/*
+ * @test
+ * @bug 8048596
+ * @summary Check if GCMParameterSpec works as expected
+ */
+public class GCMParameterSpecTest {
+
+    private static final int[] IV_LENGTHS = { 96, 8, 1024 };
+    private static final int[] KEY_LENGTHS = { 128, 192, 256 };
+    private static final int[] DATA_LENGTHS = { 0, 128, 1024 };
+    private static final int[] AAD_LENGTHS = { 0, 128, 1024 };
+    private static final int[] TAG_LENGTHS = { 128, 120, 112, 104, 96 };
+    private static final int[] OFFSETS = { 0, 2, 5, 99 };
+    private static final String TRANSFORMATION = "AES/GCM/NoPadding";
+    private static final String TEMPLATE = "Test:\n  tag = %d\n"
+            + "  IV length = %d\n  data length = %d\n"
+            + "  AAD length = %d\n  offset = %d\n  keylength = %d\n";
+
+    private final byte[] IV;
+    private final byte[] IVO;
+    private final byte[] data;
+    private final byte[] AAD;
+    private final SecretKey key;
+    private final int tagLength;
+    private final int IVlength;
+    private final int offset;
+
+    /**
+     * Initialize IV, IV with offset, plain text, AAD and SecretKey
+     *
+     * @param keyLength length of a secret key
+     * @param tagLength tag length
+     * @param IVlength IV length
+     * @param offset offset in a buffer for IV
+     * @param textLength plain text length
+     * @param AADLength AAD length
+     */
+    public GCMParameterSpecTest(int keyLength, int tagLength, int IVlength,
+            int offset, int textLength, int AADLength)
+            throws NoSuchAlgorithmException, NoSuchProviderException {
+        this.tagLength = tagLength; // save tag length
+        this.IVlength = IVlength; // save IV length
+        this.offset = offset; // save IV offset
+
+        // prepare IV
+        IV = Helper.generateBytes(IVlength);
+
+        // prepare IV with offset
+        IVO = new byte[this.IVlength + this.offset];
+        System.arraycopy(IV, 0, IVO, offset, this.IVlength);
+
+        // prepare data
+        data = Helper.generateBytes(textLength);
+
+        // prepare AAD
+        AAD = Helper.generateBytes(AADLength);
+
+        // init a secret key
+        KeyGenerator kg = KeyGenerator.getInstance("AES", "SunJCE");
+        kg.init(keyLength);
+        key = kg.generateKey();
+    }
+
+    /*
+     * Run the test for each key length, tag length, IV length, plain text
+     * length, AAD length and offset.
+     */
+    public static void main(String[] args) throws Exception {
+        boolean success = true;
+        for (int k : KEY_LENGTHS) {
+            if (k > Cipher.getMaxAllowedKeyLength(TRANSFORMATION)) {
+                // skip this if this key length is larger than what's
+                // allowed in the jce jurisdiction policy files
+                continue;
+            }
+            for (int t : TAG_LENGTHS) {
+                for (int n : IV_LENGTHS) {
+                    for (int p : DATA_LENGTHS) {
+                        for (int a : AAD_LENGTHS) {
+                            for (int o : OFFSETS) {
+                                System.out.printf(TEMPLATE, t, n, p, a, o, k);
+                                success &= new GCMParameterSpecTest(
+                                        k, t, n, o, p, a).doTest();
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        if (!success) {
+            throw new RuntimeException("At least one test case failed");
+        }
+    }
+
+    /*
+     * Run the test:
+     *   - check if result of encryption of plain text is the same
+     *     when parameters constructed with different GCMParameterSpec
+     *     constructors are used
+     *   - check if GCMParameterSpec.getTLen() is equal to actual tag length
+     *   - check if ciphertext has the same length as plaintext
+     */
+    private boolean doTest() throws Exception {
+        GCMParameterSpec spec1 = new GCMParameterSpec(tagLength, IV);
+        GCMParameterSpec spec2 = new GCMParameterSpec(tagLength, IVO, offset,
+                IVlength);
+        byte[] cipherText1 = getCipherTextBySpec(spec1);
+        if (cipherText1 == null) {
+            return false;
+        }
+        byte[] cipherText2 = getCipherTextBySpec(spec2);
+        if (cipherText2 == null) {
+            return false;
+        }
+        if (!Arrays.equals(cipherText1, cipherText2)) {
+            System.out.println("Cipher texts are different");
+            return false;
+        }
+        if (spec1.getTLen() != spec2.getTLen()) {
+            System.out.println("Tag lengths are not equal");
+            return false;
+        }
+        byte[] recoveredText1 = recoverCipherText(cipherText1, spec2);
+        if (recoveredText1 == null) {
+            return false;
+        }
+        byte[] recoveredText2 = recoverCipherText(cipherText2, spec1);
+        if (recoveredText2 == null) {
+            return false;
+        }
+        if (!Arrays.equals(recoveredText1, recoveredText2)) {
+            System.out.println("Recovered texts are different");
+            return false;
+        }
+        if (!Arrays.equals(recoveredText1, data)) {
+            System.out.println("Recovered and original texts are not equal");
+            return false;
+        }
+
+        return true;
+    }
+
+    /*
+     * Encrypt a plain text, and check if GCMParameterSpec.getIV()
+     * is equal to Cipher.getIV()
+     */
+    private byte[] getCipherTextBySpec(GCMParameterSpec spec) throws Exception {
+        // init a cipher
+        Cipher cipher = createCipher(Cipher.ENCRYPT_MODE, spec);
+        cipher.updateAAD(AAD);
+        byte[] cipherText = cipher.doFinal(data);
+
+        // check IVs
+        if (!Arrays.equals(cipher.getIV(), spec.getIV())) {
+            System.out.println("IV in parameters is incorrect");
+            return null;
+        }
+        if (spec.getTLen() != (cipherText.length - data.length) * 8) {
+            System.out.println("Tag length is incorrect");
+            return null;
+        }
+        return cipherText;
+    }
+
+    private byte[] recoverCipherText(byte[] cipherText, GCMParameterSpec spec)
+            throws Exception {
+        // init a cipher
+        Cipher cipher = createCipher(Cipher.DECRYPT_MODE, spec);
+
+        // check IVs
+        if (!Arrays.equals(cipher.getIV(), spec.getIV())) {
+            System.out.println("IV in parameters is incorrect");
+            return null;
+        }
+
+        cipher.updateAAD(AAD);
+        return cipher.doFinal(cipherText);
+    }
+
+    private Cipher createCipher(int mode, GCMParameterSpec spec)
+            throws Exception {
+        Cipher cipher = Cipher.getInstance(TRANSFORMATION, "SunJCE");
+        cipher.init(mode, key, spec);
+        return cipher;
+    }
+}
diff --git a/hotspot/test/gc/8000311/Test8000311.java b/jdk/test/com/sun/crypto/provider/Cipher/AEAD/Helper.java
similarity index 65%
copy from hotspot/test/gc/8000311/Test8000311.java
copy to jdk/test/com/sun/crypto/provider/Cipher/AEAD/Helper.java
index 2c33191..dad216b 100644
--- a/hotspot/test/gc/8000311/Test8000311.java
+++ b/jdk/test/com/sun/crypto/provider/Cipher/AEAD/Helper.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -21,22 +21,13 @@
  * questions.
  */
 
-/**
- * @test Test8000311
- * @key gc
- * @bug 8000311
- * @summary G1: ParallelGCThreads==0 broken
- * @run main/othervm -XX:+UseG1GC -XX:ParallelGCThreads=0 -XX:+ResizePLAB -XX:+ExplicitGCInvokesConcurrent Test8000311
- * @author filipp.zhinkin@oracle.com
- */
+public class Helper {
 
-import java.util.*;
-
-public class Test8000311 {
-  public static void main(String args[]) {
-    for(int i = 0; i<100; i++) {
-      byte[] garbage = new byte[1000];
-      System.gc();
+    public static byte[] generateBytes(int length) {
+        byte[] bytes = new byte[length];
+        for (int i = 0; i < length; i++) {
+            bytes[i] = (byte) (i % 256);
+        }
+        return bytes;
     }
-  }
 }
diff --git a/jdk/test/com/sun/crypto/provider/Cipher/AEAD/KeyWrapper.java b/jdk/test/com/sun/crypto/provider/Cipher/AEAD/KeyWrapper.java
new file mode 100644
index 0000000..21f1dee
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Cipher/AEAD/KeyWrapper.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+
+import java.security.AlgorithmParameters;
+import java.security.Key;
+import java.util.Arrays;
+import javax.crypto.SecretKey;
+import javax.crypto.Cipher;
+import javax.crypto.KeyGenerator;
+
+/*
+ * @test
+ * @bug 8048596
+ * @summary Check if a key wrapper works properly with GCM mode
+ */
+public class KeyWrapper {
+
+    static final String AES = "AES";
+    static final String TRANSFORMATION = "AES/GCM/NoPadding";
+    static final String PROVIDER = "SunJCE";
+    static final int KEY_LENGTH = 128;
+
+    public static void main(String argv[]) throws Exception {
+        doTest(PROVIDER, TRANSFORMATION);
+    }
+
+    private static void doTest(String provider, String algo) throws Exception {
+        SecretKey key;
+        SecretKey keyToWrap;
+
+        // init a secret Key
+        KeyGenerator kg = KeyGenerator.getInstance(AES, PROVIDER);
+        kg.init(KEY_LENGTH);
+        key = kg.generateKey();
+        keyToWrap = kg.generateKey();
+
+        // initialization
+        Cipher cipher = Cipher.getInstance(algo, provider);
+        cipher.init(Cipher.WRAP_MODE, key);
+        AlgorithmParameters params = cipher.getParameters();
+
+        // wrap the key
+        byte[] keyWrapper = cipher.wrap(keyToWrap);
+        try {
+            // check if we can't wrap it again with the same key/IV
+            keyWrapper = cipher.wrap(keyToWrap);
+            throw new RuntimeException(
+                    "FAILED: expected IllegalStateException hasn't "
+                            + "been thrown ");
+        } catch (IllegalStateException ise) {
+            System.out.println(ise.getMessage());
+            System.out.println("Expected exception");
+        }
+
+        // unwrap the key
+        cipher.init(Cipher.UNWRAP_MODE, key, params);
+        cipher.unwrap(keyWrapper, algo, Cipher.SECRET_KEY);
+
+        // check if we can unwrap second time
+        Key unwrapKey = cipher.unwrap(keyWrapper, algo, Cipher.SECRET_KEY);
+
+        if (!Arrays.equals(keyToWrap.getEncoded(), unwrapKey.getEncoded())) {
+            throw new RuntimeException(
+                    "FAILED: original and unwrapped keys are not equal");
+        }
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/Cipher/AEAD/ReadWriteSkip.java b/jdk/test/com/sun/crypto/provider/Cipher/AEAD/ReadWriteSkip.java
new file mode 100644
index 0000000..f6bd380
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Cipher/AEAD/ReadWriteSkip.java
@@ -0,0 +1,317 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import java.security.NoSuchAlgorithmException;
+import java.util.Arrays;
+import javax.crypto.Cipher;
+import javax.crypto.CipherInputStream;
+import javax.crypto.CipherOutputStream;
+import javax.crypto.KeyGenerator;
+import javax.crypto.SecretKey;
+
+/*
+ * @test
+ * @bug 8048596
+ * @summary Test CICO AEAD read/write/skip operations
+ */
+public class ReadWriteSkip {
+
+    static enum BufferType {
+        BYTE_ARRAY_BUFFERING, INT_BYTE_BUFFERING
+    }
+
+    static final int KEY_LENGTHS[] = {128, 192, 256};
+    static final int TXT_LENGTHS[] = {800, 0};
+    static final int AAD_LENGTHS[] = {0, 100};
+    static final int BLOCK = 50;
+    static final int SAVE = 45;
+    static final int DISCARD = BLOCK - SAVE;
+    static final String PROVIDER = "SunJCE";
+    static final String AES = "AES";
+    static final String GCM = "GCM";
+    static final String PADDING = "NoPadding";
+    static final String TRANSFORM = AES + "/" + GCM + "/" + PADDING;
+
+    final SecretKey key;
+    final byte[] plaintext;
+    final byte[] AAD;
+    final int textLength;;
+    final int keyLength;
+    Cipher encryptCipher;
+    Cipher decryptCipher;
+    CipherInputStream ciInput;
+
+    public static void main(String[] args) throws Exception {
+        boolean success = true;
+        for (int keyLength : KEY_LENGTHS) {
+            if (keyLength > Cipher.getMaxAllowedKeyLength(TRANSFORM)) {
+                // skip this if this key length is larger than what's
+                // configured in the jce jurisdiction policy files
+                continue;
+            }
+            for (int textLength : TXT_LENGTHS) {
+                for (int AADLength : AAD_LENGTHS) {
+                    System.out.println("Key length = " + keyLength
+                            + ", text length = " + textLength
+                            + ", AAD length = " + AADLength);
+                    try {
+                        run(keyLength, textLength, AADLength);
+                        System.out.println("Test case passed");
+                    } catch (Exception e) {
+                        System.out.println("Test case failed: " + e);
+                        success = false;
+                    }
+                }
+            }
+        }
+
+        if (!success) {
+            throw new RuntimeException("At least one test case failed");
+        }
+
+        System.out.println("Test passed");
+    }
+
+    ReadWriteSkip(int keyLength, int textLength, int AADLength)
+            throws Exception {
+        this.keyLength = keyLength;
+        this.textLength = textLength;
+
+        // init AAD
+        this.AAD = Helper.generateBytes(AADLength);
+
+        // init a secret Key
+        KeyGenerator kg = KeyGenerator.getInstance(AES, PROVIDER);
+        kg.init(this.keyLength);
+        this.key = kg.generateKey();
+
+        this.plaintext = Helper.generateBytes(textLength);
+    }
+
+    final void doTest(BufferType type) throws Exception {
+        // init ciphers
+        encryptCipher = createCipher(Cipher.ENCRYPT_MODE);
+        decryptCipher = createCipher(Cipher.DECRYPT_MODE);
+
+        // init cipher input stream
+        ciInput = new CipherInputStream(new ByteArrayInputStream(plaintext),
+                encryptCipher);
+
+        runTest(type);
+    }
+
+    void runTest(BufferType type) throws Exception {}
+
+    private Cipher createCipher(int mode) throws GeneralSecurityException {
+        Cipher cipher = Cipher.getInstance(TRANSFORM, PROVIDER);
+        if (mode == Cipher.ENCRYPT_MODE) {
+            cipher.init(Cipher.ENCRYPT_MODE, key);
+        } else {
+            if (encryptCipher != null) {
+                cipher.init(Cipher.DECRYPT_MODE, key,
+                        encryptCipher.getParameters());
+            } else {
+                throw new RuntimeException("Can't create a cipher");
+            }
+        }
+        cipher.updateAAD(AAD);
+        return cipher;
+    }
+
+    /*
+     * Run test cases
+     */
+    static void run(int keyLength, int textLength, int AADLength)
+            throws Exception {
+        new ReadWriteTest(keyLength, textLength, AADLength)
+                .doTest(BufferType.BYTE_ARRAY_BUFFERING);
+        new ReadWriteTest(keyLength, textLength, AADLength)
+                .doTest(BufferType.INT_BYTE_BUFFERING);
+        new SkipTest(keyLength, textLength, AADLength)
+                .doTest(BufferType.BYTE_ARRAY_BUFFERING);
+        new SkipTest(keyLength, textLength, AADLength)
+                .doTest(BufferType.INT_BYTE_BUFFERING);
+    }
+
+    static void check(byte[] first, byte[] second) {
+        if (!Arrays.equals(first, second)) {
+            throw new RuntimeException("Arrays are not equal");
+        }
+    }
+
+    /*
+     * CICO AEAD read/write functional test.
+     *
+     * Check if encrypt/decrypt operations work correctly.
+     *
+     * Test scenario:
+     *   - initializes plain text
+     *   - for given AEAD algorithm instantiates encrypt and decrypt Ciphers
+     *   - instantiates CipherInputStream with the encrypt Cipher
+     *   - instantiates CipherOutputStream with the decrypt Cipher
+     *   - performs reading from the CipherInputStream (encryption data)
+     *     and writing to the CipherOutputStream (decryption). As a result,
+     *     output of the CipherOutputStream should be equal
+     *     with original plain text
+     *   - check if the original plain text is equal to output
+     *     of the CipherOutputStream
+     *   - if it is equal the test passes, otherwise it fails
+     */
+    static class ReadWriteTest extends ReadWriteSkip {
+
+        public ReadWriteTest(int keyLength, int textLength, int AADLength)
+                throws Exception {
+            super(keyLength, textLength, AADLength);
+        }
+
+        @Override
+        public void runTest(BufferType bufType) throws IOException,
+                GeneralSecurityException {
+
+            ByteArrayOutputStream baOutput = new ByteArrayOutputStream();
+            try (CipherOutputStream ciOutput = new CipherOutputStream(baOutput,
+                    decryptCipher)) {
+                if (bufType == BufferType.BYTE_ARRAY_BUFFERING) {
+                    doByteTest(ciOutput);
+                } else {
+                    doIntTest(ciOutput);
+                }
+            }
+
+            check(plaintext, baOutput.toByteArray());
+        }
+
+        /*
+         * Implements byte array buffering type test case
+         */
+        public void doByteTest(CipherOutputStream out) throws IOException {
+            byte[] buffer = Helper.generateBytes(textLength + 1);
+            int len = ciInput.read(buffer);
+            while (len != -1) {
+                out.write(buffer, 0, len);
+                len = ciInput.read(buffer);
+            }
+        }
+
+        /*
+         * Implements integer buffering type test case
+         */
+        public void doIntTest(CipherOutputStream out) throws IOException {
+            int buffer = ciInput.read();
+            while (buffer != -1) {
+                out.write(buffer);
+                buffer = ciInput.read();
+            }
+        }
+    }
+
+    /*
+     * CICO AEAD SKIP functional test.
+     *
+     * Checks if the encrypt/decrypt operations work correctly
+     * when skip() method is used.
+     *
+     * Test scenario:
+     *   - initializes a plain text
+     *   - initializes ciphers
+     *   - initializes cipher streams
+     *   - split plain text to TEXT_SIZE/BLOCK blocks
+     *   - read from CipherInputStream2 one block at time
+     *   - the last DISCARD = BLOCK - SAVE bytes are skipping for each block
+     *   - therefore, plain text data go through CipherInputStream1 (encrypting)
+     *     and CipherInputStream2 (decrypting)
+     *   - as a result, output should equal to the original text
+     *     except DISCART byte for each block
+     *   - check result buffers
+     */
+    static class SkipTest extends ReadWriteSkip {
+
+        private final int numberOfBlocks;
+        private final byte[] outputText;
+
+        public SkipTest(int keyLength, int textLength, int AADLength)
+                throws Exception {
+            super(keyLength, textLength, AADLength);
+            numberOfBlocks = this.textLength / BLOCK;
+            outputText = new byte[numberOfBlocks * SAVE];
+        }
+
+        private void doByteTest(int blockNum, CipherInputStream cis)
+                throws IOException {
+            int index = blockNum * SAVE;
+            int len = cis.read(outputText, index, SAVE);
+            index += len;
+            int read = 0;
+            while (len != SAVE && read != -1) {
+                read = cis.read(outputText, index, SAVE - len);
+                len += read;
+                index += read;
+            }
+        }
+
+        private void doIntTest(int blockNum, CipherInputStream cis)
+                throws IOException {
+            int i = blockNum * SAVE;
+            for (int j = 0; j < SAVE && i < outputText.length; j++, i++) {
+                int b = cis.read();
+                if (b != -1) {
+                    outputText[i] = (byte) b;
+                }
+            }
+        }
+
+        @Override
+        public void runTest(BufferType type) throws IOException,
+                NoSuchAlgorithmException {
+            try (CipherInputStream cis = new CipherInputStream(ciInput,
+                    decryptCipher)) {
+                for (int i = 0; i < numberOfBlocks; i++) {
+                    if (type == BufferType.BYTE_ARRAY_BUFFERING) {
+                        doByteTest(i, cis);
+                    } else {
+                        doIntTest(i, cis);
+                    }
+                    if (cis.available() >= DISCARD) {
+                        cis.skip(DISCARD);
+                    } else {
+                        for (int k = 0; k < DISCARD; k++) {
+                            cis.read();
+                        }
+                    }
+                }
+            }
+
+            byte[] expectedText = new byte[numberOfBlocks * SAVE];
+            for (int m = 0; m < numberOfBlocks; m++) {
+                for (int n = 0; n < SAVE; n++) {
+                    expectedText[m * SAVE + n] = plaintext[m * BLOCK + n];
+                }
+            }
+            check(expectedText, outputText);
+        }
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/Cipher/AEAD/SameBuffer.java b/jdk/test/com/sun/crypto/provider/Cipher/AEAD/SameBuffer.java
new file mode 100644
index 0000000..30afb8e
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Cipher/AEAD/SameBuffer.java
@@ -0,0 +1,423 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+
+import java.nio.ByteBuffer;
+import java.security.AlgorithmParameters;
+import java.security.Provider;
+import java.security.Security;
+import javax.crypto.SecretKey;
+import javax.crypto.Cipher;
+import javax.crypto.KeyGenerator;
+import javax.crypto.spec.GCMParameterSpec;
+
+/*
+ * @test
+ * @bug 8048596
+ * @summary Check if AEAD operations work correctly when buffers used
+ *          for storing plain text and cipher text are overlapped or the same
+ */
+public class SameBuffer {
+
+    private static final String PROVIDER = "SunJCE";
+    private static final String AES = "AES";
+    private static final String GCM = "GCM";
+    private static final String PADDING = "NoPadding";
+    private static final int OFFSET = 2;
+    private static final int OFFSETS = 4;
+    private static final int KEY_LENGTHS[] = { 128, 192, 256 };
+    private static final int TEXT_LENGTHS[] = { 0, 1024 };
+    private static final int AAD_LENGTHS[] = { 0, 1024 };
+
+    private final Provider provider;
+    private final SecretKey key;
+    private final String transformation;
+    private final int textLength;
+    private final int AADLength;
+
+    /**
+     * Constructor of the test
+     *
+     * @param provider security provider
+     * @param keyStrength key length
+     * @param textLength length of data
+     * @param AADLength AAD length
+     */
+    public SameBuffer(Provider provider, String algorithm, String mode,
+            String padding, int keyStrength, int textLength, int AADLength)
+            throws Exception {
+
+        // init a secret key
+        KeyGenerator kg = KeyGenerator.getInstance(algorithm, provider);
+        kg.init(keyStrength);
+        key = kg.generateKey();
+
+        this.transformation = algorithm + "/" + mode + "/" + padding;
+        this.provider = provider;
+        this.textLength = textLength;
+        this.AADLength = AADLength;
+    }
+
+    public static void main(String[] args) throws Exception {
+        Provider p = Security.getProvider(PROVIDER);
+        for (int keyLength : KEY_LENGTHS) {
+            for (int textLength : TEXT_LENGTHS) {
+                for (int AADLength : AAD_LENGTHS) {
+                    for (int i = 0; i < OFFSETS; i++) {
+                        // try different offsets
+                        int offset = i * OFFSET;
+                        runTest(p, AES, GCM, PADDING, keyLength, textLength,
+                                AADLength, offset);
+                    }
+                }
+            }
+        }
+    }
+
+    /*
+     * Run single test case with given parameters
+     */
+    static void runTest(Provider p, String algo, String mode,
+            String padding, int keyLength, int textLength, int AADLength,
+            int offset) throws Exception {
+        System.out.println("Testing " + keyLength + " key length; "
+                + textLength + " text lenght; " + AADLength + " AAD length; "
+                + offset + " offset");
+        if (keyLength > Cipher.getMaxAllowedKeyLength(algo)) {
+            // skip this if this key length is larger than what's
+            // configured in the jce jurisdiction policy files
+            return;
+        }
+        SameBuffer test = new SameBuffer(p, algo, mode,
+                padding, keyLength, textLength, AADLength);
+
+        /*
+         * There are four test cases:
+         *   1. AAD and text are placed in separated byte arrays
+         *   2. AAD and text are placed in the same byte array
+         *   3. AAD and text are placed in separated byte buffers
+         *   4. AAD and text are placed in the same byte buffer
+         */
+        Cipher ci = test.createCipher(Cipher.ENCRYPT_MODE, null);
+        AlgorithmParameters params = ci.getParameters();
+        test.doTestWithSeparateArrays(offset, params);
+        test.doTestWithSameArrays(offset, params);
+        test.doTestWithSeparatedBuffer(offset, params);
+        test.doTestWithSameBuffer(offset, params);
+    }
+
+    /*
+     * Run the test in case when AAD and text are placed in separated byte
+     * arrays.
+     */
+    private void doTestWithSeparateArrays(int offset,
+            AlgorithmParameters params) throws Exception {
+        // prepare buffers to test
+        Cipher c = createCipher(Cipher.ENCRYPT_MODE, params);
+        int outputLength = c.getOutputSize(textLength);
+        int outputBufSize = outputLength + offset * 2;
+
+        byte[] inputText = Helper.generateBytes(outputBufSize);
+        byte[] AAD = Helper.generateBytes(AADLength);
+
+        // do the test
+        runGCMWithSeparateArray(Cipher.ENCRYPT_MODE, AAD, inputText, offset * 2,
+                textLength, offset, params);
+        int tagLength = c.getParameters()
+                .getParameterSpec(GCMParameterSpec.class).getTLen() / 8;
+        runGCMWithSeparateArray(Cipher.DECRYPT_MODE, AAD, inputText, offset,
+                textLength + tagLength, offset, params);
+    }
+
+    /**
+     * Run the test in case when AAD and text are placed in the same byte
+     * array.
+     */
+    private void doTestWithSameArrays(int offset, AlgorithmParameters params)
+            throws Exception {
+        // prepare buffers to test
+        Cipher c = createCipher(Cipher.ENCRYPT_MODE, params);
+        int outputLength = c.getOutputSize(textLength);
+        int outputBufSize = AADLength + outputLength + offset * 2;
+
+        byte[] AAD_and_text = Helper.generateBytes(outputBufSize);
+
+        // do the test
+        runGCMWithSameArray(Cipher.ENCRYPT_MODE, AAD_and_text, AADLength + offset,
+                textLength, params);
+        int tagLength = c.getParameters()
+                .getParameterSpec(GCMParameterSpec.class).getTLen() / 8;
+        runGCMWithSameArray(Cipher.DECRYPT_MODE, AAD_and_text, AADLength + offset,
+                textLength + tagLength, params);
+    }
+
+    /*
+     * Run the test in case when AAD and text are placed in separated ByteBuffer
+     */
+    private void doTestWithSeparatedBuffer(int offset,
+            AlgorithmParameters params) throws Exception {
+        // prepare AAD byte buffers to test
+        byte[] AAD = Helper.generateBytes(AADLength);
+        ByteBuffer AAD_Buf = ByteBuffer.allocate(AADLength);
+        AAD_Buf.put(AAD, 0, AAD.length);
+        AAD_Buf.flip();
+
+        // prepare text byte buffer to encrypt/decrypt
+        Cipher c = createCipher(Cipher.ENCRYPT_MODE, params);
+        int outputLength = c.getOutputSize(textLength);
+        int outputBufSize = outputLength + offset;
+        byte[] inputText = Helper.generateBytes(outputBufSize);
+        ByteBuffer plainTextBB = ByteBuffer.allocateDirect(inputText.length);
+        plainTextBB.put(inputText);
+        plainTextBB.position(offset);
+        plainTextBB.limit(offset + textLength);
+
+        // do test
+        runGCMWithSeparateBuffers(Cipher.ENCRYPT_MODE, AAD_Buf, plainTextBB, offset,
+                textLength, params);
+        int tagLength = c.getParameters()
+                .getParameterSpec(GCMParameterSpec.class).getTLen() / 8;
+        plainTextBB.position(offset);
+        plainTextBB.limit(offset + textLength + tagLength);
+        runGCMWithSeparateBuffers(Cipher.DECRYPT_MODE, AAD_Buf, plainTextBB, offset,
+                textLength + tagLength, params);
+    }
+
+    /*
+     * Run the test in case when AAD and text are placed in the same ByteBuffer
+     */
+    private void doTestWithSameBuffer(int offset, AlgorithmParameters params)
+            throws Exception {
+        // calculate output length
+        Cipher c = createCipher(Cipher.ENCRYPT_MODE, params);
+        int outputLength = c.getOutputSize(textLength);
+
+        // prepare byte buffer contained AAD and plain text
+        int bufSize = AADLength + offset + outputLength;
+        byte[] AAD_and_Text = Helper.generateBytes(bufSize);
+        ByteBuffer AAD_and_Text_Buf = ByteBuffer.allocate(bufSize);
+        AAD_and_Text_Buf.put(AAD_and_Text, 0, AAD_and_Text.length);
+
+        // do test
+        runGCMWithSameBuffer(Cipher.ENCRYPT_MODE, AAD_and_Text_Buf, offset,
+                textLength, params);
+        int tagLength = c.getParameters()
+                .getParameterSpec(GCMParameterSpec.class).getTLen() / 8;
+        AAD_and_Text_Buf.limit(AADLength + offset + textLength + tagLength);
+        runGCMWithSameBuffer(Cipher.DECRYPT_MODE, AAD_and_Text_Buf, offset,
+                textLength + tagLength, params);
+
+    }
+
+    /*
+     * Execute GCM encryption/decryption of a text placed in a byte array.
+     * AAD is placed in the separated byte array.
+     * Data are processed twice:
+     *   - in a separately allocated buffer
+     *   - in the text buffer
+     * Check if two results are equal
+     */
+    private void runGCMWithSeparateArray(int mode, byte[] AAD, byte[] text,
+            int txtOffset, int lenght, int offset, AlgorithmParameters params)
+            throws Exception {
+        // first, generate the cipher text at an allocated buffer
+        Cipher cipher = createCipher(mode, params);
+        cipher.updateAAD(AAD);
+        byte[] outputText = cipher.doFinal(text, txtOffset, lenght);
+
+        // new cipher for encrypt operation
+        Cipher anotherCipher = createCipher(mode, params);
+        anotherCipher.updateAAD(AAD);
+
+        // next, generate cipher text again at the same buffer of plain text
+        int myoff = offset;
+        int off = anotherCipher.update(text, txtOffset, lenght, text, myoff);
+        anotherCipher.doFinal(text, myoff + off);
+
+        // check if two resutls are equal
+        if (!isEqual(text, myoff, outputText, 0, outputText.length)) {
+            throw new RuntimeException("Two results not equal, mode:" + mode);
+        }
+    }
+
+    /*
+     * Execute GCM encrption/decryption of a text. The AAD and text to process
+     * are placed in the same byte array. Data are processed twice:
+     *   - in a separetly allocated buffer
+     *   - in a buffer that shares content of the AAD_and_Text_BA
+     * Check if two results are equal
+     */
+    private void runGCMWithSameArray(int mode, byte[] array, int txtOffset,
+            int length, AlgorithmParameters params) throws Exception {
+        // first, generate cipher text at an allocated buffer
+        Cipher cipher = createCipher(mode, params);
+        cipher.updateAAD(array, 0, AADLength);
+        byte[] outputText = cipher.doFinal(array, txtOffset, length);
+
+        // new cipher for encrypt operation
+        Cipher anotherCipher = createCipher(mode, params);
+        anotherCipher.updateAAD(array, 0, AADLength);
+
+        // next, generate cipher text again at the same buffer of plain text
+        int off = anotherCipher.update(array, txtOffset, length,
+                array, txtOffset);
+        anotherCipher.doFinal(array, txtOffset + off);
+
+        // check if two results are equal or not
+        if (!isEqual(array, txtOffset, outputText, 0,
+                outputText.length)) {
+            throw new RuntimeException(
+                    "Two results are not equal, mode:" + mode);
+        }
+    }
+
+    /*
+     * Execute GCM encryption/decryption of textBB. AAD and text to process are
+     * placed in different byte buffers. Data are processed twice:
+     *  - in a separately allocated buffer
+     *  - in a buffer that shares content of the textBB
+     * Check if results are equal
+     */
+    private void runGCMWithSeparateBuffers(int mode, ByteBuffer buffer,
+            ByteBuffer textBB, int txtOffset, int dataLength,
+            AlgorithmParameters params) throws Exception {
+        // take offset into account
+        textBB.position(txtOffset);
+        textBB.mark();
+
+        // first, generate the cipher text at an allocated buffer
+        Cipher cipher = createCipher(mode, params);
+        cipher.updateAAD(buffer);
+        buffer.flip();
+        ByteBuffer outBB = ByteBuffer.allocateDirect(
+                cipher.getOutputSize(dataLength));
+
+        cipher.doFinal(textBB, outBB);// get cipher text in outBB
+        outBB.flip();
+
+        // restore positions
+        textBB.reset();
+
+        // next, generate cipher text again in a buffer that shares content
+        Cipher anotherCipher = createCipher(mode, params);
+        anotherCipher.updateAAD(buffer);
+        buffer.flip();
+        ByteBuffer buf2 = textBB.duplicate(); // buf2 shares textBuf context
+        buf2.limit(txtOffset + anotherCipher.getOutputSize(dataLength));
+        int dataProcessed2 = anotherCipher.doFinal(textBB, buf2);
+        buf2.position(txtOffset);
+        buf2.limit(txtOffset + dataProcessed2);
+
+        if (!buf2.equals(outBB)) {
+            throw new RuntimeException(
+                    "Two results are not equal, mode:" + mode);
+        }
+    }
+
+    /*
+     * Execute GCM encryption/decryption of text. AAD and a text to process are
+     * placed in the same buffer. Data is processed twice:
+     *   - in a separately allocated buffer
+     *   - in a buffer that shares content of the AAD_and_Text_BB
+     */
+    private void runGCMWithSameBuffer(int mode, ByteBuffer buffer,
+            int txtOffset, int length, AlgorithmParameters params)
+            throws Exception {
+
+        // allocate a separate buffer
+        Cipher cipher = createCipher(mode, params);
+        ByteBuffer outBB = ByteBuffer.allocateDirect(
+                cipher.getOutputSize(length));
+
+        // first, generate the cipher text at an allocated buffer
+        buffer.flip();
+        buffer.limit(AADLength);
+        cipher.updateAAD(buffer);
+        buffer.limit(AADLength + txtOffset + length);
+        buffer.position(AADLength + txtOffset);
+        cipher.doFinal(buffer, outBB);
+        outBB.flip(); // cipher text in outBB
+
+        // next, generate cipherText again in the same buffer
+        Cipher anotherCipher = createCipher(mode, params);
+        buffer.flip();
+        buffer.limit(AADLength);
+        anotherCipher.updateAAD(buffer);
+        buffer.limit(AADLength + txtOffset + length);
+        buffer.position(AADLength + txtOffset);
+
+        // share textBuf context
+        ByteBuffer buf2 = buffer.duplicate();
+        buf2.limit(AADLength + txtOffset + anotherCipher.getOutputSize(length));
+        int dataProcessed2 = anotherCipher.doFinal(buffer, buf2);
+        buf2.position(AADLength + txtOffset);
+        buf2.limit(AADLength + txtOffset + dataProcessed2);
+
+        if (!buf2.equals(outBB)) {
+            throw new RuntimeException(
+                    "Two results are not equal, mode:" + mode);
+        }
+    }
+
+    private boolean isEqual(byte[] A, int offsetA, byte[] B, int offsetB,
+            int bytesToCompare) {
+        System.out.println("offsetA: " + offsetA + " offsetB: " + offsetA
+                + " bytesToCompare: " + bytesToCompare);
+        for (int i = 0; i < bytesToCompare; i++) {
+            int setA = i + offsetA;
+            int setB = i + offsetB;
+            if (setA > A.length - 1 || setB > B.length - 1
+                    || A[setA] != B[setB]) {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    /*
+     * Creates a Cipher object for testing: for encryption it creates new Cipher
+     * based on previously saved parameters (it is prohibited to use the same
+     * Cipher twice for encription during GCM mode), or returns initiated
+     * existing Cipher.
+     */
+    private Cipher createCipher(int mode, AlgorithmParameters params)
+            throws Exception {
+        Cipher cipher = Cipher.getInstance(transformation, provider);
+        if (Cipher.ENCRYPT_MODE == mode) {
+            // initiate it with the saved parameters
+            if (params != null) {
+                cipher.init(Cipher.ENCRYPT_MODE, key, params);
+            } else {
+                // intiate the cipher and save parameters
+                cipher.init(Cipher.ENCRYPT_MODE, key);
+            }
+        } else if (cipher != null) {
+            cipher.init(Cipher.DECRYPT_MODE, key, params);
+        } else {
+            throw new RuntimeException("Can't create cipher");
+        }
+
+        return cipher;
+    }
+
+}
diff --git a/jdk/test/com/sun/crypto/provider/Cipher/AEAD/SealedObjectTest.java b/jdk/test/com/sun/crypto/provider/Cipher/AEAD/SealedObjectTest.java
new file mode 100644
index 0000000..6f5e820
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Cipher/AEAD/SealedObjectTest.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+
+import java.security.AlgorithmParameters;
+import java.util.Arrays;
+import javax.crypto.SecretKey;
+import javax.crypto.Cipher;
+import javax.crypto.KeyGenerator;
+import javax.crypto.SealedObject;
+
+/*
+ * @test
+ * @bug 8048596
+ * @summary Check if the seal/unseal feature works properly in AEAD/GCM mode.
+ */
+public class SealedObjectTest {
+
+    private static final String AES = "AES";
+    private static final String TRANSFORMATION = "AES/GCM/NoPadding";
+    private static final String PROVIDER = "SunJCE";
+    private static final int KEY_LENGTH = 128;
+
+    public static void main(String[] args) throws Exception {
+        doTest();
+    }
+
+    /*
+     * Run the test:
+     * - init a cipher with AES/GCM/NoPadding transformation
+     * - seal an object
+     * - check if we can't seal it again with the same key/IV
+     * - unseal the object using different methods of SealedObject class
+     * - check if the original and sealed objects are equal
+     */
+    static void doTest() throws Exception {
+        // init a secret Key
+        KeyGenerator kg = KeyGenerator.getInstance(AES, PROVIDER);
+        kg.init(KEY_LENGTH);
+        SecretKey key = kg.generateKey();
+
+        // initialization
+        Cipher cipher = Cipher.getInstance(TRANSFORMATION, PROVIDER);
+        cipher.init(Cipher.ENCRYPT_MODE, key);
+        AlgorithmParameters params = cipher.getParameters();
+
+        // seal an object
+        SealedObject so = new SealedObject(key, cipher);
+        try {
+            // check if we can't seal it again with the same key/IV
+            so = new SealedObject(key, cipher);
+            throw new RuntimeException(
+                    "FAILED: expected IllegalStateException hasn't "
+                            + "been thrown");
+        } catch (IllegalStateException ise) {
+            System.out.println("Expected exception when seal it again with"
+                    + " the same key/IV: " + ise);
+        }
+
+        // unseal the object using getObject(Cipher) and compare
+        cipher.init(Cipher.DECRYPT_MODE, key, params);
+        SecretKey unsealedKey = (SecretKey) so.getObject(cipher);
+        assertKeysSame(unsealedKey, key, "SealedObject.getObject(Cipher)");
+
+        // unseal the object using getObject(Key) and compare
+        unsealedKey = (SecretKey) so.getObject(key);
+        assertKeysSame(unsealedKey, key, "SealedObject.getObject(Key)");
+
+        // unseal the object using getObject(Key, String) and compare
+        unsealedKey = (SecretKey) so.getObject(key, PROVIDER);
+
+        assertKeysSame(unsealedKey, key,
+                "SealedObject.getObject(Key, String)");
+    }
+
+    /**
+     * Compare two SecretKey objects.
+     *
+     * @param key1 first key
+     * @param key2 second key
+     * @param meth method that was used for unsealing the SecretKey object
+     * @return true if key1 and key2 are the same, false otherwise.
+     */
+    static void assertKeysSame(SecretKey key1, SecretKey key2, String meth) {
+        if (!Arrays.equals(key1.getEncoded(), key2.getEncoded())) {
+            throw new RuntimeException(
+                    "FAILED: original and unsealed objects aren't the same for "
+                            + meth);
+        }
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/Cipher/AEAD/WrongAAD.java b/jdk/test/com/sun/crypto/provider/Cipher/AEAD/WrongAAD.java
new file mode 100644
index 0000000..157a8bb
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Cipher/AEAD/WrongAAD.java
@@ -0,0 +1,174 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.security.AlgorithmParameters;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.util.Arrays;
+import javax.crypto.CipherInputStream;
+import javax.crypto.CipherOutputStream;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.SecretKey;
+import javax.crypto.Cipher;
+import javax.crypto.KeyGenerator;
+
+/*
+ * @test
+ * @bug 8048596
+ * @summary Check if wrong or empty AAD is rejected
+ */
+public class WrongAAD {
+
+    private static final String PROVIDER = "SunJCE";
+    private static final String TRANSFORMATION = "AES/GCM/NoPadding";
+    private static final int TEXT_SIZE = 800;
+    private static final int KEY_SIZE = 128;
+    private static final int AAD_SIZE = 128;
+
+    private final SecretKey key;
+    private final byte[] plainText;
+    private final Cipher encryptCipher;
+
+    public WrongAAD() throws Exception {
+        // init a secret key
+        KeyGenerator kg = KeyGenerator.getInstance("AES", PROVIDER);
+        kg.init(KEY_SIZE);
+        key = kg.generateKey();
+
+        // generate a plain text
+        plainText = Helper.generateBytes(TEXT_SIZE);
+
+        // init AADs
+        byte[] AAD = Helper.generateBytes(AAD_SIZE);
+
+        // init a cipher
+        encryptCipher = createCipher(Cipher.ENCRYPT_MODE, null);
+        encryptCipher.updateAAD(AAD);
+    }
+
+    public static void main(String[] args) throws Exception {
+        WrongAAD test = new WrongAAD();
+        test.decryptWithEmptyAAD();
+        test.decryptWithWrongAAD();
+    }
+
+    /*
+     * Attempt to decrypt a cipher text using Cipher object
+     * initialized without AAD used for encryption.
+     */
+    private void decryptWithEmptyAAD() throws Exception {
+        System.out.println("decryptWithEmptyAAD() started");
+        // initialize it with empty AAD to get exception during decryption
+        Cipher decryptCipher = createCipher(Cipher.DECRYPT_MODE,
+                encryptCipher.getParameters());
+        try (ByteArrayOutputStream baOutput = new ByteArrayOutputStream();
+                CipherOutputStream ciOutput = new CipherOutputStream(baOutput,
+                        decryptCipher)) {
+            if (decrypt(ciOutput, baOutput)) {
+                throw new RuntimeException(
+                        "Decryption has been perfomed successfully in"
+                                + " spite of the decrypt Cipher has NOT been"
+                                + " initialized with AAD");
+            }
+        }
+        System.out.println("decryptWithEmptyAAD() passed");
+    }
+
+    /*
+     * Attempt to decrypt the cipher text using Cipher object
+     * initialized with some fake AAD.
+     */
+    private void decryptWithWrongAAD() throws Exception {
+        System.out.println("decrypt with wrong AAD");
+
+        // initialize it with wrong AAD to get an exception during decryption
+        Cipher decryptCipher = createCipher(Cipher.DECRYPT_MODE,
+                encryptCipher.getParameters());
+        byte[] someAAD = Helper.generateBytes(AAD_SIZE + 1);
+        decryptCipher.updateAAD(someAAD);
+
+        // init output stream
+        try (ByteArrayOutputStream baOutput = new ByteArrayOutputStream();
+                CipherOutputStream ciOutput = new CipherOutputStream(baOutput,
+                        decryptCipher);) {
+            if (decrypt(ciOutput, baOutput)) {
+                throw new RuntimeException(
+                        "A decryption has been perfomed successfully in"
+                                + " spite of the decrypt Cipher has been"
+                                + " initialized with fake AAD");
+            }
+        }
+
+        System.out.println("Passed");
+    }
+
+    private boolean decrypt(CipherOutputStream ciOutput,
+            ByteArrayOutputStream baOutput) throws IOException {
+        try (ByteArrayInputStream baInput = new ByteArrayInputStream(plainText);
+                CipherInputStream ciInput = new CipherInputStream(baInput,
+                        encryptCipher)) {
+            byte[] buffer = new byte[TEXT_SIZE];
+            int len = ciInput.read(buffer);
+
+            while (len != -1) {
+                ciOutput.write(buffer, 0, len);
+                len = ciInput.read(buffer);
+            }
+            ciOutput.flush();
+            byte[] recoveredText = baOutput.toByteArray();
+            System.out.println("recoveredText: " + new String(recoveredText));
+
+            /*
+             * See bug 8012900, AEADBadTagException is swalloed by CI/CO streams
+             * If recovered text is empty, than decryption failed
+             */
+            if (recoveredText.length == 0) {
+                return false;
+            }
+            return Arrays.equals(plainText, recoveredText);
+        } catch (IllegalStateException e) {
+            System.out.println("Expected IllegalStateException: "
+                    + e.getMessage());
+            e.printStackTrace(System.out);
+            return false;
+        }
+    }
+
+    private Cipher createCipher(int mode, AlgorithmParameters params)
+            throws NoSuchAlgorithmException, NoSuchProviderException,
+            NoSuchPaddingException, InvalidKeyException,
+            InvalidAlgorithmParameterException {
+        Cipher cipher = Cipher.getInstance(TRANSFORMATION, PROVIDER);
+        if (params != null) {
+            cipher.init(mode, key, params);
+        } else {
+            cipher.init(mode, key);
+        }
+        return cipher;
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/Cipher/AES/CICO.java b/jdk/test/com/sun/crypto/provider/Cipher/AES/CICO.java
new file mode 100644
index 0000000..811724b
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Cipher/AES/CICO.java
@@ -0,0 +1,186 @@
+/*
+ * 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.
+ *
+ * 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.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.spec.AlgorithmParameterSpec;
+import java.util.Random;
+import javax.crypto.Cipher;
+import javax.crypto.CipherInputStream;
+import javax.crypto.CipherOutputStream;
+import javax.crypto.KeyGenerator;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.IvParameterSpec;
+
+/**
+ * @test
+ * @bug 8043836
+ * @summary Test AES ciphers with different modes and padding schemes (ECB mode
+ *          doesn't use IV). The test tries 3 different read methods of
+ *          CipherInputStream.
+ */
+public class CICO {
+    private static final String ALGORITHM = "aEs";
+    private static final String[] MODES = { "PCBC", "ECb", "cbC", "cFB",
+        "cFB24", "cFB32", "Cfb40", "CFB72", "OfB", "OfB20", "OfB48",
+        "OfB56", "OFB64", "OFB112", "CFB112", "pCbC" };
+    private static final String[] PADDING = { "noPadding", "pkcs5padding" };
+    private static final String PROVIDER = "SunJCE";
+    private static final int NREADS = 3;
+    private static final int KEY_LENGTH = 128;
+
+    private final byte[] plainText = new byte[1600000];
+
+
+    public static void main(String argv[]) throws Exception {
+        CICO test = new CICO();
+        for (String mode : MODES) {
+            for (String pad : PADDING) {
+                for (int m = 0; m < NREADS; m++) {
+                    test.runTest(ALGORITHM, mode, pad, m);
+                }
+            }
+        }
+    }
+
+    public void runTest(String algo, String mo, String pad, int whichRead) throws Exception {
+        Cipher ci1 = null;
+        Cipher ci2 = null;
+        byte[] iv = null;
+        AlgorithmParameterSpec aps = null;
+        SecretKey key = null;
+
+        try {
+            // Do initialization
+            Random rdm = new Random();
+            rdm.nextBytes(plainText);
+            KeyGenerator kg = KeyGenerator.getInstance(algo, PROVIDER);
+            if (!kg.getAlgorithm().equals(algo)) {
+                throw new RuntimeException("Unexpected algorithm <"
+                        + kg.getAlgorithm() + ">, expected value is <" + algo
+                        + ">");
+            }
+
+            kg.init(KEY_LENGTH);
+            key = kg.generateKey();
+
+            ci1 = Cipher.getInstance(algo + "/" + mo + "/" + pad, PROVIDER);
+
+            if (mo.equalsIgnoreCase("ECB")) {
+                ci1.init(Cipher.ENCRYPT_MODE, key);
+            } else {
+                ci1.init(Cipher.ENCRYPT_MODE, key, aps);
+            }
+
+            if (!mo.equalsIgnoreCase("ECB")) {
+                iv = ci1.getIV();
+                aps = new IvParameterSpec(iv);
+            } else {
+                aps = null;
+            }
+
+            ci2 = Cipher.getInstance(algo + "/" + mo + "/" + pad, PROVIDER);
+            if (mo.equalsIgnoreCase("ECB")) {
+                ci2.init(Cipher.DECRYPT_MODE, key);
+            } else {
+                ci2.init(Cipher.DECRYPT_MODE, key, aps);
+            }
+
+            ByteArrayInputStream baInput = new ByteArrayInputStream(plainText);
+            ByteArrayOutputStream baOutput = new ByteArrayOutputStream();
+            try (CipherInputStream ciInput = new CipherInputStream(baInput, ci1);
+                    CipherOutputStream ciOutput = new CipherOutputStream(
+                            baOutput, ci2)) {
+                // According to specification, CipherInputStream does not support the
+                // mark and reset methods
+                if (ciInput.markSupported()) {
+                    throw new RuntimeException(
+                            "CipherInputStream unexpectedly supports the mark and reset methods");
+                }
+
+                // Read from the input and write to the output using 2 types
+                // of buffering : byte[] and int
+                switch (whichRead) {
+                case 0:
+                    int buffer0 = ciInput.read();
+                    while (buffer0 != -1) {
+                        ciOutput.write(buffer0);
+                        buffer0 = ciInput.read();
+                    }
+                    break;
+                case 1:
+                    byte[] buffer1 = new byte[20];
+                    int len1 = ciInput.read(buffer1);
+                    while (len1 != -1) {
+                        ciOutput.write(buffer1, 0, len1);
+                        len1 = ciInput.read(buffer1);
+                    }
+                    break;
+                case NREADS - 1:
+                    byte[] buffer2 = new byte[ci1
+                                              .getOutputSize(plainText.length)];
+                    int offset2 = 0;
+                    int len2 = 0;
+                    while (len2 != -1) {
+                        len2 = ciInput.read(buffer2, offset2, buffer2.length
+                                - offset2);
+                        offset2 += len2;
+                    }
+                    ciOutput.write(buffer2, 0, buffer2.length);
+                    break;
+                }
+            }
+
+            // Get the output
+            byte[] recoveredText = new byte[baOutput.size()];
+            recoveredText = baOutput.toByteArray();
+            if (!java.util.Arrays.equals(plainText, recoveredText)) {
+                throw new RuntimeException(
+                        "Original text is not equal with recovered text, with "
+                                + algo + "/" + mo + "/" + pad + "/" + whichRead);
+            }
+
+            // Compare input and output
+
+        } catch (NoSuchAlgorithmException e) {
+            //OFB20 is for negative testing
+            if (!mo.equalsIgnoreCase("OFB20")) {
+                System.out.println("Unexpected NoSuchAlgorithmException with "
+                        + algo + "/" + mo + "/" + pad + "/" + whichRead);
+                throw new RuntimeException("Test failed!");
+            }
+        } catch (IOException | NoSuchProviderException | NoSuchPaddingException
+                | InvalidKeyException | InvalidAlgorithmParameterException e) {
+            System.out.println("Unexpected Exception with "
+                    + algo + "/" + mo + "/" + pad + "/" + whichRead);
+            System.out.println("Test failed!");
+            throw e;
+        }
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/Cipher/AES/CTR.java b/jdk/test/com/sun/crypto/provider/Cipher/AES/CTR.java
new file mode 100644
index 0000000..808f3e2
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Cipher/AES/CTR.java
@@ -0,0 +1,145 @@
+/*
+ * 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.
+ *
+ * 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.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.spec.AlgorithmParameterSpec;
+import java.util.Arrays;
+import java.util.Random;
+import javax.crypto.BadPaddingException;
+import javax.crypto.Cipher;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.KeyGenerator;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.SecretKey;
+import javax.crypto.ShortBufferException;
+import javax.crypto.spec.IvParameterSpec;
+
+
+/**
+ * @test
+ * @bug 8043836
+ * @summary Test AES ciphers with 4 different modes with NoPadding. Check if
+ *          data before encryption and after decryption is the same.
+ */
+
+public class CTR {
+
+    private static final String ALGORITHM = "AES";
+
+    private static final String PROVIDER = "SunJCE";
+
+    private static final String[] MODES = {"CTR","CFB24","OFB32","GCM"};
+
+    private static final String PADDING = "NoPadding";
+
+
+    private static final int KEY_LENGTH = 128;
+
+    public static void main(String argv[]) throws Exception {
+        CTR test = new CTR();
+        for (String mode : MODES) {
+            test.runTest(ALGORITHM, mode, PADDING);
+        }
+    }
+
+
+    public void runTest(String algo, String mo, String pad) throws Exception {
+        Cipher ci = null;
+        byte[] iv = null;
+        AlgorithmParameterSpec aps = null;
+        SecretKey key = null;
+
+        try {
+            Random rdm = new Random();
+            byte[] plainText;
+
+            ci = Cipher.getInstance(algo + "/" + mo + "/" + pad, PROVIDER);
+            KeyGenerator kg = KeyGenerator.getInstance(algo, PROVIDER);
+            kg.init(KEY_LENGTH);
+            key = kg.generateKey();
+
+            for (int i = 0; i < 15; i++) {
+                plainText = new byte[1600 + i + 1];
+                rdm.nextBytes(plainText);
+
+                if (!mo.equalsIgnoreCase("GCM")) {
+                    ci.init(Cipher.ENCRYPT_MODE, key, aps);
+                } else {
+                    ci.init(Cipher.ENCRYPT_MODE, key);
+                }
+
+                byte[] cipherText = new byte[ci.getOutputSize(plainText.length)];
+                int offset = ci.update(plainText, 0, plainText.length,
+                        cipherText, 0);
+
+                ci.doFinal(cipherText, offset);
+
+                if (!mo.equalsIgnoreCase("ECB")) {
+                    iv = ci.getIV();
+                    aps = new IvParameterSpec(iv);
+                } else {
+                    aps = null;
+                }
+
+                if (!mo.equalsIgnoreCase("GCM")) {
+                    ci.init(Cipher.DECRYPT_MODE, key, aps);
+                } else {
+                    ci.init(Cipher.DECRYPT_MODE, key, ci.getParameters());
+                }
+
+                byte[] recoveredText = new byte[ci.getOutputSize(cipherText.length)];
+                int len = ci.doFinal(cipherText, 0, cipherText.length,
+                        recoveredText);
+                byte[] tmp = new byte[len];
+
+                for (int j = 0; j < len; j++) {
+                    tmp[j] = recoveredText[j];
+                }
+                Arrays.toString(plainText);
+                if (!java.util.Arrays.equals(plainText, tmp)) {
+                    System.out.println("Original: ");
+                    dumpBytes(plainText);
+                    System.out.println("Recovered: ");
+                    dumpBytes(tmp);
+                    throw new RuntimeException("Original text is not equal with recovered text, with mode:" + mo);
+                }
+            }
+        } catch (NoSuchAlgorithmException | NoSuchProviderException | NoSuchPaddingException
+                | InvalidKeyException | InvalidAlgorithmParameterException
+                | ShortBufferException | IllegalBlockSizeException
+                | BadPaddingException e) {
+            System.out.println("Test failed!");
+            throw e;
+        }
+    }
+
+    private void dumpBytes(byte[] bytes){
+        for (byte b : bytes){
+            System.out.print(Integer.toHexString(b));
+        }
+        System.out.println();
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/Cipher/AES/Padding.java b/jdk/test/com/sun/crypto/provider/Cipher/AES/Padding.java
new file mode 100644
index 0000000..6023ec7
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Cipher/AES/Padding.java
@@ -0,0 +1,151 @@
+/*
+ * 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.
+ *
+ * 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.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.spec.AlgorithmParameterSpec;
+import java.util.Random;
+import javax.crypto.BadPaddingException;
+import javax.crypto.Cipher;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.KeyGenerator;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.SecretKey;
+import javax.crypto.ShortBufferException;
+import javax.crypto.spec.IvParameterSpec;
+
+/**
+ * @test
+ * @bug 8043836
+ * @summary Test AES ciphers with different modes and padding schemes (ECB mode
+ *          doesn't use IV). The test tries 3 different read methods of
+ *          CipherInputStream.
+ */
+public class Padding {
+
+    private static final String ALGORITHM = "AES";
+    private static final String PROVIDER = "SunJCE";
+    private static final String[] MODES = { "ECb", "CbC", "PCBC", "OFB",
+        "OFB150", "cFB", "CFB7", "cFB8", "cFB16", "cFB24", "cFB32",
+        "Cfb40", "cfB48", "cfB56", "cfB64", "cfB72", "cfB80", "cfB88",
+        "cfB96", "cfb104", "cfB112", "cfB120", "OFB8", "OFB16", "OFB24",
+        "OFB32", "OFB40", "OFB48", "OFB56", "OFB64", "OFB72", "OFB80",
+        "OFB88", "OFB96", "OFB104", "OFB112", "OFB120", "GCM" };
+    private static final String PADDING = "PKCS5Padding";
+    private static final int KEY_LENGTH = 128;
+
+    public static void main(String argv[]) throws Exception {
+        Padding test = new Padding();
+        for (String mode : MODES) {
+            test.runTest(ALGORITHM, mode, PADDING);
+        }
+    }
+
+    public void runTest(String algo, String mo, String pad) throws Exception {
+        Cipher ci = null;
+        byte[] iv = null;
+        AlgorithmParameterSpec aps = null;
+        SecretKey key = null;
+        try {
+            Random rdm = new Random();
+            byte[] plainText;
+
+            ci = Cipher.getInstance(algo + "/" + mo + "/" + pad, PROVIDER);
+            KeyGenerator kg = KeyGenerator.getInstance(algo, PROVIDER);
+            kg.init(KEY_LENGTH);
+            key = kg.generateKey();
+
+            for (int i = 0; i < 15; i++) {
+                plainText = new byte[1600 + i + 1];
+                rdm.nextBytes(plainText);
+
+                if (!mo.equalsIgnoreCase("GCM")) {
+                    ci.init(Cipher.ENCRYPT_MODE, key, aps);
+                } else {
+                    ci.init(Cipher.ENCRYPT_MODE, key);
+                }
+
+                byte[] cipherText = new byte[ci.getOutputSize(plainText.length)];
+                int offset = ci.update(plainText, 0, plainText.length,
+                        cipherText, 0);
+                ci.doFinal(cipherText, offset);
+
+                if (!mo.equalsIgnoreCase("ECB")) {
+                    iv = ci.getIV();
+                    aps = new IvParameterSpec(iv);
+                } else {
+                    aps = null;
+                }
+
+                if (!mo.equalsIgnoreCase("GCM")) {
+                    ci.init(Cipher.DECRYPT_MODE, key, aps);
+                } else {
+                    ci.init(Cipher.DECRYPT_MODE, key, ci.getParameters());
+                }
+
+                byte[] recoveredText = new byte[ci.getOutputSize(cipherText.length)];
+                int len = ci.doFinal(cipherText, 0, cipherText.length,
+                        recoveredText);
+                byte[] tmp = new byte[len];
+
+                for (int j = 0; j < len; j++) {
+                    tmp[j] = recoveredText[j];
+                }
+
+                if (!java.util.Arrays.equals(plainText, tmp)) {
+                    System.out.println("Original: ");
+                    dumpBytes(plainText);
+                    System.out.println("Recovered: ");
+                    dumpBytes(tmp);
+                    throw new RuntimeException(
+                            "Original text is not equal with recovered text, with mode:"
+                                    + mo);
+                }
+            }
+        } catch (NoSuchAlgorithmException e) {
+            //CFB7 and OFB150 are for negative testing
+            if (!mo.equalsIgnoreCase("CFB7") && !mo.equalsIgnoreCase("OFB150")) {
+                System.out
+                .println("Unexpected NoSuchAlgorithmException with mode: "
+                        + mo);
+                throw new RuntimeException("Test failed!");
+            }
+        } catch ( NoSuchProviderException | NoSuchPaddingException
+                | InvalidKeyException | InvalidAlgorithmParameterException
+                | ShortBufferException | IllegalBlockSizeException
+                | BadPaddingException e) {
+            System.out.println("Test failed!");
+            throw e;
+        }
+    }
+
+    private void dumpBytes(byte[] bytes) {
+        for (byte b : bytes) {
+            System.out.print(Integer.toHexString(b));
+        }
+
+        System.out.println();
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/Cipher/AES/TestAESCipher.java b/jdk/test/com/sun/crypto/provider/Cipher/AES/TestAESCipher.java
new file mode 100644
index 0000000..190b586
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Cipher/AES/TestAESCipher.java
@@ -0,0 +1,156 @@
+/*
+ * 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.
+ *
+ * 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.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.spec.AlgorithmParameterSpec;
+import java.util.Random;
+import javax.crypto.BadPaddingException;
+import javax.crypto.Cipher;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.KeyGenerator;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.SecretKey;
+import javax.crypto.ShortBufferException;
+import javax.crypto.spec.IvParameterSpec;
+
+/**
+ * @test
+ * @bug 8043836
+ * @summary Test AES ciphers with different modes and padding schemes (ECB mode
+ *          doesn't use IV).
+ * @author Liwen Wang
+ * @author Parag Salvi
+ */
+public class TestAESCipher {
+
+    private static final String ALGORITHM = "AES";
+    private static final String PROVIDER = "SunJCE";
+    private static final String[] MODES = { "ECb", "CbC", "CTR", "PCBC", "OFB",
+        "OFB150", "cFB", "CFB7", "cFB8", "cFB16", "cFB24", "cFB32",
+        "Cfb40", "cfB48", "cfB56", "cfB64", "cfB72", "cfB80", "cfB88",
+        "cfB96", "cfb104", "cfB112", "cfB120", "OFB8", "OFB16", "OFB24",
+        "OFB32", "OFB40", "OFB48", "OFB56", "OFB64", "OFB72", "OFB80",
+        "OFB88", "OFB96", "OFB104", "OFB112", "OFB120", "GCM" };
+    private static final String[] PADDING = { "NoPadding", "PKCS5Padding" };
+    private static final int KEY_LENGTH = 128;
+
+    public static void main(String argv[]) throws Exception {
+        TestAESCipher test = new TestAESCipher();
+        for (String mode : MODES) {
+            int padKinds = 1;
+            if (mode.equalsIgnoreCase("ECB") || mode.equalsIgnoreCase("PCBC")
+                    || mode.equalsIgnoreCase("CBC")) {
+                padKinds = PADDING.length;
+            }
+
+            for (int k = 0; k < padKinds; k++) {
+                test.runTest(ALGORITHM, mode, PADDING[k]);
+            }
+        }
+    }
+
+    public void runTest(String algo, String mo, String pad) throws Exception {
+        Cipher ci = null;
+        byte[] iv = null;
+        AlgorithmParameterSpec aps = null;
+        SecretKey key = null;
+        try {
+            // Initialization
+            Random rdm = new Random();
+            byte[] plainText = new byte[128];
+            rdm.nextBytes(plainText);
+
+            ci = Cipher.getInstance(algo + "/" + mo + "/" + pad, PROVIDER);
+            KeyGenerator kg = KeyGenerator.getInstance(algo, PROVIDER);
+            kg.init(KEY_LENGTH);
+            key = kg.generateKey();
+
+            // encrypt
+            if (!mo.equalsIgnoreCase("GCM")) {
+                ci.init(Cipher.ENCRYPT_MODE, key, aps);
+            } else {
+                ci.init(Cipher.ENCRYPT_MODE, key);
+            }
+
+            byte[] cipherText = new byte[ci.getOutputSize(plainText.length)];
+            int offset = ci.update(plainText, 0, plainText.length, cipherText,
+                    0);
+            ci.doFinal(cipherText, offset);
+
+            if (!mo.equalsIgnoreCase("ECB")) {
+                iv = ci.getIV();
+                aps = new IvParameterSpec(iv);
+            } else {
+                aps = null;
+            }
+
+            if (!mo.equalsIgnoreCase("GCM")) {
+                ci.init(Cipher.DECRYPT_MODE, key, aps);
+            } else {
+                ci.init(Cipher.DECRYPT_MODE, key, ci.getParameters());
+            }
+
+            byte[] recoveredText = new byte[ci.getOutputSize(cipherText.length)];
+            int len = ci.doFinal(cipherText, 0, cipherText.length,
+                    recoveredText);
+            byte[] tmp = new byte[len];
+            System.arraycopy(recoveredText, 0, tmp, 0, len);
+
+            // Comparison
+            if (!java.util.Arrays.equals(plainText, tmp)) {
+                System.out.println("Original: ");
+                dumpBytes(plainText);
+                System.out.println("Recovered: ");
+                dumpBytes(tmp);
+                throw new RuntimeException(
+                        "Original text is not equal with recovered text, with mode:"
+                                + mo);
+            }
+
+        } catch (NoSuchAlgorithmException e) {
+            //CFB7 and OFB150 are for negative testing
+            if (!mo.equalsIgnoreCase("CFB7") && !mo.equalsIgnoreCase("OFB150")) {
+                System.out.println("Unexpected NoSuchAlgorithmException with mode: "
+                        + mo);
+                throw new RuntimeException("Test failed!");
+            }
+        }  catch ( NoSuchProviderException | NoSuchPaddingException
+                | InvalidKeyException | InvalidAlgorithmParameterException
+                | ShortBufferException | IllegalBlockSizeException
+                | BadPaddingException e) {
+            System.out.println("Test failed!");
+            throw e;
+        }
+    }
+
+    private void dumpBytes(byte[] bytes) {
+        for (byte b : bytes) {
+            System.out.print(Integer.toHexString(b));
+        }
+
+        System.out.println();
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/Cipher/AES/TestNonexpanding.java b/jdk/test/com/sun/crypto/provider/Cipher/AES/TestNonexpanding.java
new file mode 100644
index 0000000..200d38b
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Cipher/AES/TestNonexpanding.java
@@ -0,0 +1,115 @@
+/*
+ * 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.
+ *
+ * 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.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.spec.InvalidParameterSpecException;
+import java.util.Random;
+import javax.crypto.BadPaddingException;
+import javax.crypto.Cipher;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.KeyGenerator;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.SecretKey;
+import javax.crypto.ShortBufferException;
+import javax.crypto.spec.GCMParameterSpec;
+
+/**
+ * @test
+ * @bug 8043836
+ * @summary Test AES encryption with no padding. Expect the original data length
+ *          is the same as the encrypted data.
+ */
+public class TestNonexpanding {
+
+    private static final String ALGORITHM = "AES";
+    private static final String PROVIDER = "SunJCE";
+    private static final String[] MODES = { "ECb", "CbC", "OFB", "OFB150",
+        "cFB", "CFB7", "cFB8", "cFB16", "cFB24", "cFB32", "Cfb40", "cfB48",
+        "cfB56", "cfB64", "cfB72", "cfB80", "cfB88", "cfB96", "cfb104",
+        "cfB112", "cfB120", "GCM" };
+    private static final String PADDING = "NoPadding";
+    private static final int KEY_LENGTH = 128;
+
+    public static void main(String argv[]) throws Exception {
+        TestNonexpanding test = new TestNonexpanding();
+        for (String mode : MODES) {
+            test.runTest(ALGORITHM, mode, PADDING);
+        }
+    }
+
+    public void runTest(String algo, String mo, String pad) throws Exception {
+        Cipher ci = null;
+        SecretKey key = null;
+        try {
+            // Initialization
+            Random rdm = new Random();
+            byte[] plainText = new byte[128];
+            rdm.nextBytes(plainText);
+
+            ci = Cipher.getInstance(algo + "/" + mo + "/" + pad, PROVIDER);
+
+            KeyGenerator kg = KeyGenerator.getInstance(algo, PROVIDER);
+            kg.init(KEY_LENGTH);
+            key = kg.generateKey();
+
+            // encrypt
+            ci.init(Cipher.ENCRYPT_MODE, key);
+            byte[] cipherText = new byte[ci.getOutputSize(plainText.length)];
+            int offset = ci.update(plainText, 0, plainText.length, cipherText,
+                    0);
+            ci.doFinal(cipherText, offset);
+
+            // Comparison
+            if (!(plainText.length == cipherText.length)) {
+                // The result of encryption in GCM is a combination of an
+                // authentication tag and cipher text.
+                if (mo.equalsIgnoreCase("GCM")) {
+                    GCMParameterSpec spec = ci.getParameters().getParameterSpec(GCMParameterSpec.class);
+                    int cipherTextLength = cipherText.length - spec.getTLen()
+                            / 8;
+                    if (plainText.length == cipherTextLength) {
+                        return;
+                    }
+                }
+                System.out.println("Original length: " + plainText.length);
+                System.out.println("Cipher text length: " + cipherText.length);
+                throw new RuntimeException("Test failed!");
+            }
+        } catch (NoSuchAlgorithmException e) {
+            //CFB7 and OFB150 are for negative testing
+            if (!mo.equalsIgnoreCase("CFB7") && !mo.equalsIgnoreCase("OFB150")) {
+                System.out.println("Unexpected NoSuchAlgorithmException with mode: "
+                        + mo);
+                throw new RuntimeException("Test failed!");
+            }
+        } catch ( NoSuchProviderException | NoSuchPaddingException
+                | InvalidKeyException | InvalidParameterSpecException
+                | ShortBufferException | IllegalBlockSizeException
+                | BadPaddingException e) {
+            System.out.println("Test failed!");
+            throw e;
+        }
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/Cipher/AES/TestSameBuffer.java b/jdk/test/com/sun/crypto/provider/Cipher/AES/TestSameBuffer.java
new file mode 100644
index 0000000..bbba223
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Cipher/AES/TestSameBuffer.java
@@ -0,0 +1,138 @@
+/*
+ * 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.
+ *
+ * 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.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.spec.AlgorithmParameterSpec;
+import java.util.Random;
+import javax.crypto.BadPaddingException;
+import javax.crypto.Cipher;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.KeyGenerator;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.SecretKey;
+import javax.crypto.ShortBufferException;
+import javax.crypto.spec.IvParameterSpec;
+
+/**
+ * @test
+ * @bug 8043836
+ * @summary Test AES ciphers with different modes and padding schemes (ECB mode
+ *          doesn't use IV). The test tries 3 different read methods of
+ *          CipherInputStream.
+ */
+public class TestSameBuffer {
+
+    private static final String ALGORITHM = "Rijndael";
+    private static final String PROVIDER = "SunJCE";
+    private static final String[] MODES = { "ECb", "CbC", "OFB", "CFB150",
+        "cFB", "CFB7", " cFB8", "cFB16", "cFB24", "cFB32", "Cfb40",
+        "cfB48", " cfB56", "cfB64", "cfB72", "cfB80", "cfB88", "cfB96",
+        "cfb104", "cfB112", "cfB120" };
+    private static final String PADDING = "NoPadding";
+    private static final int KEY_LENGTH = 128;
+
+    public static void main(String argv[]) throws Exception {
+        TestSameBuffer test = new TestSameBuffer();
+        for (String mode : MODES) {
+            test.runTest(ALGORITHM, mode, PADDING);
+        }
+    }
+
+    public void runTest(String algo, String mo, String pad) throws Exception {
+        Cipher ci = null;
+        byte[] iv = null;
+        AlgorithmParameterSpec aps = null;
+        SecretKey key = null;
+        try {
+            // Initialization
+            Random rdm = new Random();
+            byte[] plainText = new byte[128];
+            rdm.nextBytes(plainText);
+
+            // keep the plain text
+            byte[] tmpText = new byte[plainText.length];
+            for (int i = 0; i < plainText.length; i++) {
+                tmpText[i] = plainText[i];
+            }
+
+            ci = Cipher.getInstance(algo + "/" + mo + "/" + pad, PROVIDER);
+
+            KeyGenerator kg = KeyGenerator.getInstance(algo, PROVIDER);
+            kg.init(KEY_LENGTH);
+            key = kg.generateKey();
+
+            // encrypt
+            ci.init(Cipher.ENCRYPT_MODE, key);
+            int offset = ci
+                    .update(plainText, 0, plainText.length, plainText, 0);
+            ci.doFinal(plainText, offset);
+
+            if (!mo.equalsIgnoreCase("ECB")) {
+                iv = ci.getIV();
+                aps = new IvParameterSpec(iv);
+            } else {
+                aps = null;
+            }
+
+            ci.init(Cipher.DECRYPT_MODE, key, aps);
+            byte[] recoveredText = new byte[ci.getOutputSize(plainText.length)];
+            ci.doFinal(plainText, 0, plainText.length, recoveredText);
+
+            // Comparison
+            if (!java.util.Arrays.equals(tmpText, recoveredText)) {
+                System.out.println("Original: ");
+                dumpBytes(plainText);
+                System.out.println("Recovered: ");
+                dumpBytes(recoveredText);
+                throw new RuntimeException(
+                        "Original text is not equal with recovered text, with mode:"
+                                + mo);
+            }
+
+        } catch (NoSuchAlgorithmException e) {
+            //CFB7 and CFB150 are for negative testing
+            if (!mo.equalsIgnoreCase("CFB7") && !mo.equalsIgnoreCase("CFB150")) {
+                System.out.println("Unexpected NoSuchAlgorithmException with mode: "
+                        + mo);
+                throw new RuntimeException("Test failed!");
+            }
+        }  catch (NoSuchProviderException | NoSuchPaddingException
+                | InvalidKeyException | InvalidAlgorithmParameterException
+                | ShortBufferException | IllegalBlockSizeException
+                | BadPaddingException e) {
+            System.out.println("Test failed!");
+            throw e;
+        }
+    }
+
+    private void dumpBytes(byte[] bytes) {
+        for (byte b : bytes) {
+            System.out.print(Integer.toHexString(b));
+        }
+
+        System.out.println();
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/Cipher/DES/TestUtility.java b/jdk/test/com/sun/crypto/provider/Cipher/DES/TestUtility.java
index 61efd62..ffa0a5b 100644
--- a/jdk/test/com/sun/crypto/provider/Cipher/DES/TestUtility.java
+++ b/jdk/test/com/sun/crypto/provider/Cipher/DES/TestUtility.java
@@ -27,39 +27,52 @@
 
 public class TestUtility {
 
-    private static final String digits = "0123456789abcdef";
+    private static final String DIGITS = "0123456789abcdef";
 
-    public TestUtility() {
+    private TestUtility() {
 
     }
 
     public static String hexDump(byte[] bytes) {
 
-        StringBuffer buf = new StringBuffer (bytes.length * 2);
-        int  i;
+        StringBuilder buf = new StringBuilder(bytes.length * 2);
+        int i;
 
-        buf.append ("    ");                    // four spaces
+        buf.append("    "); // four spaces
         for (i = 0; i < bytes.length; i++) {
-            buf.append (digits.charAt ((bytes[i] >> 4) & 0x0f));
-            buf.append (digits.charAt (bytes[i] & 0x0f));
-            if (((i + 1) % 32) == 0) {
-                if ((i +  1) != bytes.length)
-                    buf.append ("\n    ");      // line after four words
-            } else if (((i + 1) % 4) == 0)
-                buf.append (' ');               // space between words
+            buf.append(DIGITS.charAt(bytes[i] >> 4 & 0x0f));
+            buf.append(DIGITS.charAt(bytes[i] & 0x0f));
+            if ((i + 1) % 32 == 0) {
+                if (i + 1 != bytes.length) {
+                    buf.append("\n    "); // line after four words
+                }
+            } else if ((i + 1) % 4 == 0) {
+                buf.append(' '); // space between words
+            }
         }
-        return buf.toString ();
+        return buf.toString();
     }
 
+    public static String hexDump(byte[] bytes, int index) {
+        StringBuilder buf = new StringBuilder(bytes.length * 2);
+        int i;
+
+        buf.append("    "); // four spaces
+        buf.append(DIGITS.charAt(bytes[index] >> 4 & 0x0f));
+        buf.append(DIGITS.charAt(bytes[index] & 0x0f));
+        return buf.toString();
+    }
 
     public static boolean equalsBlock(byte[] b1, byte[] b2) {
 
-        if (b1.length != b2.length)
+        if (b1.length != b2.length) {
             return false;
+        }
 
-        for (int i=0; i<b1.length; i++) {
-            if (b1[i] != b2[i])
+        for (int i = 0; i < b1.length; i++) {
+            if (b1[i] != b2[i]) {
                 return false;
+            }
         }
 
         return true;
@@ -67,9 +80,10 @@
 
     public static boolean equalsBlock(byte[] b1, byte[] b2, int len) {
 
-        for (int i=0; i<len; i++) {
-            if (b1[i] != b2[i])
+        for (int i = 0; i < len; i++) {
+            if (b1[i] != b2[i]) {
                 return false;
+            }
         }
 
         return true;
diff --git a/jdk/test/com/sun/crypto/provider/Cipher/DES/TextPKCS5PaddingTest.java b/jdk/test/com/sun/crypto/provider/Cipher/DES/TextPKCS5PaddingTest.java
new file mode 100644
index 0000000..0afb280
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Cipher/DES/TextPKCS5PaddingTest.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2001, 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 8048604
+ * @summary This test checks boundary conditions for testing
+ *          ShortBufferException.
+ */
+import static java.lang.System.out;
+
+import java.security.AlgorithmParameters;
+import java.security.Provider;
+import java.security.Security;
+import javax.crypto.BadPaddingException;
+import javax.crypto.Cipher;
+import javax.crypto.KeyGenerator;
+import javax.crypto.SecretKey;
+
+public class TextPKCS5PaddingTest {
+    /**
+     * Test plain text.
+     */
+    private static final byte[] PLAIN_TEXT = {
+        0b10001, 0b10001, 0b10001, 0b10001,
+        0b10001, 0b10001, 0b11,    0b11
+    };
+
+    public static void main(String[] args) throws Exception {
+        Provider provider = Security.getProvider("SunJCE");
+        if (provider == null) {
+            throw new RuntimeException("SunJCE provider not exist");
+        }
+        // generate no-padding cipher with secret key
+        Cipher c = Cipher.getInstance("DES/CBC/NoPadding", provider);
+        KeyGenerator kgen = KeyGenerator.getInstance("DES", provider);
+        SecretKey skey = kgen.generateKey();
+        // this is the improperly padded plaintext
+
+        c.init(Cipher.ENCRYPT_MODE, skey);
+        // encrypt plaintext
+        byte[] cipher = c.doFinal(PLAIN_TEXT);
+        AlgorithmParameters params = c.getParameters();
+        // generate cipher that enforces PKCS5 padding
+        c = Cipher.getInstance("DES/CBC/PKCS5Padding", provider);
+        c.init(Cipher.DECRYPT_MODE, skey, params);
+        try {
+            c.doFinal(cipher);
+            throw new RuntimeException(
+                    "ERROR: Expected BadPaddingException not thrown");
+        } catch (BadPaddingException expected) {
+            out.println("Expected BadPaddingException thrown");
+        }
+
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/Cipher/JCE/Bugs/4686632/Empty.java b/jdk/test/com/sun/crypto/provider/Cipher/JCE/Bugs/4686632/Empty.java
new file mode 100644
index 0000000..4a774ae
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Cipher/JCE/Bugs/4686632/Empty.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+
+import java.lang.String;
+import javax.crypto.SecretKey;
+import javax.crypto.Cipher;
+import javax.crypto.spec.SecretKeySpec;
+
+import static java.lang.System.out;
+
+/*
+ * @test
+ * @bug 4686632 8048610
+ * @summary  To verify Cipher.init will throw InvalidKeyException with
+ *  Non-empty message when create SecretKeySpec with invalid DES key
+ * @author Kevin Liu
+ */
+public class Empty {
+    public static void main(String[] args) throws Exception {
+        try {
+            byte master[] = {
+                    0, 1, 2, 3, 4
+            };
+            SecretKey key = new SecretKeySpec(master, "DES");
+            Cipher cipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
+            cipher.init(Cipher.ENCRYPT_MODE, key);
+            throw new RuntimeException("InvalidKeyException not thrown");
+        } catch (java.security.InvalidKeyException ike) {
+            ike.printStackTrace();
+            if (ike.getMessage() != null) {
+                out.println("Status -- Passed");
+            } else {
+                throw new RuntimeException("Error message is not expected when"
+                        + " InvalidKeyException is thrown");
+            }
+
+        }
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/Cipher/KeyWrap/TestCipherKeyWrapperTest.java b/jdk/test/com/sun/crypto/provider/Cipher/KeyWrap/TestCipherKeyWrapperTest.java
new file mode 100644
index 0000000..363d21d
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Cipher/KeyWrap/TestCipherKeyWrapperTest.java
@@ -0,0 +1,316 @@
+/*
+ * 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.
+ */
+
+import static java.lang.System.out;
+
+import java.lang.Integer;
+import java.lang.String;
+import java.lang.System;
+import java.security.AlgorithmParameters;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.KeyPair;
+import java.security.NoSuchAlgorithmException;
+import java.security.KeyPairGenerator;
+import java.security.Provider;
+import java.security.Security;
+import java.security.spec.AlgorithmParameterSpec;
+import java.security.spec.InvalidKeySpecException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Random;
+
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.SecretKey;
+import javax.crypto.Cipher;
+import javax.crypto.KeyGenerator;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.PBEKeySpec;
+import javax.crypto.spec.PBEParameterSpec;
+
+/*
+ * @test
+ * @bug 8048599
+ * @summary  Tests for key wrap and unwrap operations
+ */
+
+public class TestCipherKeyWrapperTest {
+    private static final String SUN_JCE = "SunJCE";
+    // Blowfish Variable key length: 32 bits to 448 bits
+    private static final int BLOWFISH_MIN_KEYSIZE = 32;
+    private static final int BLOWFISH_MAX_KEYSIZE = 448;
+    private static final int LINIMITED_KEYSIZE = 128;
+    private static final String NOPADDING = "NoPaDDing";
+    private static final String[] PBE_ALGORITHM_AR = { "pbeWithMD5ANDdes",
+            "PBEWithMD5AndDES/CBC/PKCS5Padding", "PBEWithMD5AndTripleDES",
+            "PBEWithMD5AndTripleDES/CBC/PKCS5Padding", "PBEwithSHA1AndDESede",
+            "PBEwithSHA1AndDESede/CBC/PKCS5Padding", "PBEwithSHA1AndRC2_40",
+            "PBEwithSHA1Andrc2_40/CBC/PKCS5Padding", "PBEWithSHA1AndRC2_128",
+            "PBEWithSHA1andRC2_128/CBC/PKCS5Padding", "PBEWithSHA1AndRC4_40",
+            "PBEWithsha1AndRC4_40/ECB/NoPadding", "PBEWithSHA1AndRC4_128",
+            "pbeWithSHA1AndRC4_128/ECB/NoPadding", "PBEWithHmacSHA1AndAES_128",
+            "PBEWithHmacSHA224AndAES_128", "PBEWithHmacSHA256AndAES_128",
+            "PBEWithHmacSHA384AndAES_128", "PBEWithHmacSHA512AndAES_128",
+            "PBEWithHmacSHA1AndAES_256", "PBEWithHmacSHA224AndAES_256",
+            "PBEWithHmacSHA256AndAES_256", "PBEWithHmacSHA384AndAES_256",
+            "PBEWithHmacSHA512AndAES_256" };
+    private static final String[] MODEL_AR = { "ECb", "pCbC", "cbC", "cFB",
+            "cFB24", "cFB40", "OfB48", "OFB64" };
+    private static final String[] PADDING_AR = { NOPADDING, "PKCS5Padding" };
+
+    private enum AlgorithmWrapper {
+        AESWrap("AES", "AESWrap", -1),
+        AESWrap_128("AES", "AESWrap_128", 128),
+        AESWrap_192("AES", "AESWrap_192", 192),
+        AESWrap_256("AES", "AESWrap_256", 256),
+        DESedeWrap("desede", "DESedeWrap", -1),
+        NegtiveWrap("AES", "DESedeWrap", -1);
+
+        private final String algorithm;
+        private final String wrapper;
+        private final int keySize;
+
+        private AlgorithmWrapper(String algorithm, String wrapper, int kSize) {
+            this.algorithm = algorithm;
+            this.wrapper = wrapper;
+            this.keySize = kSize;
+        }
+
+        public String getAlgorithm() {
+            return algorithm;
+        }
+
+        public String getWrapper() {
+            return wrapper;
+        }
+
+        public int getKeySize() {
+            return keySize;
+        }
+
+    };
+
+    public static void main(String[] args) throws Exception {
+
+        TestCipherKeyWrapperTest test = new TestCipherKeyWrapperTest();
+        // AESWrap and DESedeWrap test
+        for (AlgorithmWrapper algoWrapper : AlgorithmWrapper.values()) {
+            String algo = algoWrapper.getAlgorithm();
+            String wrapper = algoWrapper.getWrapper();
+            try {
+                int keySize = algoWrapper.getKeySize();
+                // only run the tests on longer key lengths if unlimited
+                // version of JCE jurisdiction policy files are installed
+                if (!(Cipher.getMaxAllowedKeyLength(algo) == Integer.MAX_VALUE)
+                        && keySize > LINIMITED_KEYSIZE) {
+                    out.println(algo + " will not run if unlimited version of"
+                            + " JCE jurisdiction policy files are installed");
+                    continue;
+                }
+                test.wrapperAesDESedeKeyTest(algo, wrapper, keySize);
+                if (algoWrapper == AlgorithmWrapper.NegtiveWrap) {
+                    throw new RuntimeException("Expected not throw when algo"
+                            + " and wrapAlgo are not match:" + algo);
+                }
+            } catch (InvalidKeyException e) {
+                if (algoWrapper == AlgorithmWrapper.NegtiveWrap) {
+                    out.println("Expepted exception when algo"
+                            + " and wrapAlgo are not match:" + algo);
+                } else {
+                    throw e;
+                }
+            }
+        }
+        test.wrapperBlowfishKeyTest();
+        // PBE and public wrapper test.
+        String[] publicPrivateAlgos = new String[] { "DiffieHellman", "DSA",
+                "RSA" };
+        Provider provider = Security.getProvider(SUN_JCE);
+        if (provider == null) {
+            throw new RuntimeException("SUN_JCE provider not exist");
+        }
+
+        test.wrapperPBEKeyTest(provider);
+        // Public and private key wrap test
+        test.wrapperPublicPriviteKeyTest(provider, publicPrivateAlgos);
+    }
+
+    private void wrapperAesDESedeKeyTest(String algo, String wrapAlgo,
+            int keySize) throws InvalidKeyException, NoSuchAlgorithmException,
+            NoSuchPaddingException, IllegalBlockSizeException,
+            InvalidAlgorithmParameterException {
+        // Initialization
+        KeyGenerator kg = KeyGenerator.getInstance(algo);
+        if (keySize != -1) {
+            kg.init(keySize);
+        }
+        SecretKey key = kg.generateKey();
+        wrapTest(algo, wrapAlgo, key, key, Cipher.SECRET_KEY, false);
+    }
+
+    private void wrapperBlowfishKeyTest() throws InvalidKeyException,
+            NoSuchAlgorithmException, NoSuchPaddingException,
+            IllegalBlockSizeException, InvalidAlgorithmParameterException {
+        // how many kinds of padding mode
+        int padKinds;
+        // Keysize should be multiple of 8 bytes.
+        int KeyCutter = 8;
+        int kSize = BLOWFISH_MIN_KEYSIZE;
+        String algorithm = "Blowfish";
+        int maxAllowKeyLength = Cipher.getMaxAllowedKeyLength(algorithm);
+        boolean unLimitPolicy = maxAllowKeyLength == Integer.MAX_VALUE;
+        SecretKey key = null;
+        while (kSize <= BLOWFISH_MAX_KEYSIZE) {
+            for (String mode : MODEL_AR) {
+                // PKCS5padding is meaningful only for ECB, CBC, PCBC
+                if (mode.equalsIgnoreCase(MODEL_AR[0])
+                        || mode.equalsIgnoreCase(MODEL_AR[1])
+                        || mode.equalsIgnoreCase(MODEL_AR[2])) {
+                    padKinds = PADDING_AR.length;
+                } else {
+                    padKinds = 1;
+                }
+                // Initialization
+                KeyGenerator kg = KeyGenerator.getInstance(algorithm);
+                for (int k = 0; k < padKinds; k++) {
+                    String transformation = algorithm + "/" + mode + "/"
+                            + PADDING_AR[k];
+                    if (NOPADDING.equals(PADDING_AR[k]) && kSize % 64 != 0) {
+                        out.println(transformation
+                                + " will not run if input length not multiple"
+                                + " of 8 bytes when padding is " + NOPADDING);
+                        continue;
+                    }
+                    kg.init(kSize);
+                    key = kg.generateKey();
+                    // only run the tests on longer key lengths if unlimited
+                    // version of JCE jurisdiction policy files are installed
+                    if (!unLimitPolicy && kSize > LINIMITED_KEYSIZE) {
+                        out.println("keyStrength > 128 within " + algorithm
+                                + " will not run under global policy");
+                    } else {
+                        wrapTest(transformation, transformation, key, key,
+                                Cipher.SECRET_KEY, false);
+                    }
+                }
+            }
+            if (kSize <= LINIMITED_KEYSIZE) {
+                KeyCutter = 8;
+            } else {
+                KeyCutter = 48;
+            }
+            kSize += KeyCutter;
+        }
+    }
+
+    private void wrapperPBEKeyTest(Provider p) throws InvalidKeySpecException,
+            InvalidKeyException, NoSuchPaddingException,
+            IllegalBlockSizeException, InvalidAlgorithmParameterException,
+            NoSuchAlgorithmException {
+        for (String alg : PBE_ALGORITHM_AR) {
+            String baseAlgo = alg.split("/")[0].toUpperCase();
+            // only run the tests on longer key lengths if unlimited version
+            // of JCE jurisdiction policy files are installed
+
+            if (Cipher.getMaxAllowedKeyLength(alg) < Integer.MAX_VALUE
+                    && (baseAlgo.endsWith("TRIPLEDES") || alg
+                            .endsWith("AES_256"))) {
+                out.println("keyStrength > 128 within " + alg
+                        + " will not run under global policy");
+                continue;
+            }
+            SecretKeyFactory skf = SecretKeyFactory.getInstance(baseAlgo, p);
+            SecretKey key = skf.generateSecret(new PBEKeySpec("Secret Lover"
+                    .toCharArray()));
+            wrapTest(alg, alg, key, key, Cipher.SECRET_KEY, true);
+        }
+    }
+
+    private void wrapperPublicPriviteKeyTest(Provider p, String[] algorithms)
+            throws NoSuchAlgorithmException, InvalidKeyException,
+            NoSuchPaddingException, IllegalBlockSizeException,
+            InvalidAlgorithmParameterException {
+        for (String algo : algorithms) {
+            // Key pair generated
+            System.out.println("Generate key pair (algorithm: " + algo
+                    + ", provider: " + p.getName() + ")");
+            KeyPairGenerator kpg = KeyPairGenerator.getInstance(algo);
+            kpg.initialize(512);
+            KeyPair kp = kpg.genKeyPair();
+            // key generated
+            String algoWrap = "DES";
+            KeyGenerator kg = KeyGenerator.getInstance(algoWrap, p);
+            Key key = kg.generateKey();
+            wrapTest(algo, algoWrap, key, kp.getPrivate(), Cipher.PRIVATE_KEY,
+                    false);
+            wrapTest(algo, algoWrap, key, kp.getPublic(), Cipher.PUBLIC_KEY,
+                    false);
+        }
+    }
+
+    private void wrapTest(String transformation, String wrapAlgo, Key initKey,
+            Key wrapKey, int keyType, boolean isPBE)
+            throws NoSuchAlgorithmException, NoSuchPaddingException,
+            InvalidKeyException, IllegalBlockSizeException,
+            InvalidAlgorithmParameterException {
+        String algo = transformation.split("/")[0];
+        boolean isAESBlowfish = algo.indexOf("AES") != -1
+                || algo.indexOf("Blowfish") != -1;
+        AlgorithmParameters aps = null;
+        AlgorithmParameterSpec pbeParams = null;
+        if (isPBE) {
+            byte[] salt = new byte[8];
+            int iterCnt = 1000;
+            new Random().nextBytes(salt);
+            pbeParams = new PBEParameterSpec(salt, iterCnt);
+        }
+        // Wrap & UnWrap operation
+        Cipher wrapCI = Cipher.getInstance(wrapAlgo);
+        if (isPBE && !isAESBlowfish) {
+            wrapCI.init(Cipher.WRAP_MODE, initKey, pbeParams);
+        } else if (isAESBlowfish) {
+            wrapCI.init(Cipher.WRAP_MODE, initKey);
+            aps = wrapCI.getParameters();
+        } else {
+            wrapCI.init(Cipher.WRAP_MODE, initKey);
+        }
+        out.println("keysize : " + wrapKey.getEncoded().length);
+        byte[] keyWrapper = wrapCI.wrap(wrapKey);
+        if (isPBE && !isAESBlowfish) {
+            wrapCI.init(Cipher.UNWRAP_MODE, initKey, pbeParams);
+        } else if (isAESBlowfish) {
+            wrapCI.init(Cipher.UNWRAP_MODE, initKey, aps);
+        } else {
+            wrapCI.init(Cipher.UNWRAP_MODE, initKey);
+        }
+        Key unwrappedKey = wrapCI.unwrap(keyWrapper, algo, keyType);
+        // Comparison
+        if (!Arrays.equals(wrapKey.getEncoded(), unwrappedKey.getEncoded())) {
+            throw new RuntimeException("Comparation failed testing "
+                    + transformation + ":" + wrapAlgo + ":" + keyType);
+        }
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESameBuffer/AESPBEWrapper.java b/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESameBuffer/AESPBEWrapper.java
new file mode 100644
index 0000000..16dd69a
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESameBuffer/AESPBEWrapper.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2012, 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.
+ *
+ * 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.PrintStream;
+import java.security.AlgorithmParameters;
+import java.security.InvalidKeyException;
+import java.security.Provider;
+import javax.crypto.Cipher;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.PBEKeySpec;
+
+/**
+ * Wrapper class to test a given AES-based PBE algorithm.
+ *
+ * @author Alexander Fomin
+ */
+public class AESPBEWrapper extends PBEWrapper {
+
+    private AlgorithmParameters pbeParams;
+
+    /**
+     * Constructor. Instantiate Cipher using the given AES-based PBE algorithms.
+     *
+     * @param p security Provider
+     * @param algo PKDF2 algorithm
+     * @param passwd password phrase
+     * @param out print stream
+     * @throws Exception all exceptions are thrown
+     */
+    public AESPBEWrapper(Provider p, String algo, String passwd,
+            PrintStream out) throws Exception {
+        super(algo,
+                SecretKeyFactory.getInstance(algo, p).generateSecret(
+                        new PBEKeySpec(passwd.toCharArray())),
+                Cipher.getInstance(algo, p), out);
+    }
+
+    /**
+     * Perform encryption/decryption operation (depending on the specified
+     * edMode) on the same byte buffer. Compare result with the result at an
+     * allocated buffer. If both results are equal - return true, otherwise
+     * return false.
+     *
+     * @param edMode specified mode
+     * @param inputText text to decrypt
+     * @param offset offset in the text
+     * @param len input length
+     * @return ture - test passed; false - test failed
+     */
+    @Override
+    public boolean execute(int edMode, byte[] inputText, int offset, int len) {
+        try {
+            // init Cipher
+            if (Cipher.ENCRYPT_MODE == edMode) {
+                ci.init(Cipher.ENCRYPT_MODE, this.key);
+                pbeParams = ci.getParameters();
+            } else {
+                ci.init(Cipher.DECRYPT_MODE, this.key, pbeParams);
+            }
+
+            // First, generate the cipherText at an allocated buffer
+            byte[] outputText = ci.doFinal(inputText, offset, len);
+
+            // Second, generate cipherText again at the same buffer of plainText
+            int myoff = offset / 2;
+            int off = ci.update(inputText, offset, len, inputText, myoff);
+            ci.doFinal(inputText, myoff + off);
+
+            if (this.algo.endsWith("AES_256")) {
+                out.print("Expected exception uncaught, "
+                        + "keyStrength > 128 within " + this.algo);
+
+                return false;
+            }
+
+            // Compare to see whether the two results are the same or not
+            return equalsBlock(inputText, myoff, outputText, 0,
+                    outputText.length);
+        } catch (Exception ex) {
+            if ((ex instanceof InvalidKeyException)
+                    && this.algo.endsWith("AES_256")) {
+                out.println("Expected InvalidKeyException exception: "
+                        + ex.getMessage());
+
+                return true;
+            }
+
+            out.println("Catch unexpected exception within " + algo);
+            ex.printStackTrace(out);
+
+            return false;
+        }
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESameBuffer/PBECipherWrapper.java b/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESameBuffer/PBECipherWrapper.java
new file mode 100644
index 0000000..e4a8509
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESameBuffer/PBECipherWrapper.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2012, 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.
+ *
+ * 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.
+ */
+
+/*
+ * @author Valerie PENG
+ * @author Yun Ke
+ * @author Alexander Fomin
+ * @author rhalade
+ */
+import java.security.spec.AlgorithmParameterSpec;
+
+import java.util.StringTokenizer;
+
+import java.security.InvalidKeyException;
+import java.security.Provider;
+
+import java.io.PrintStream;
+
+import javax.crypto.Cipher;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.PBEKeySpec;
+import javax.crypto.spec.PBEParameterSpec;
+
+public class PBECipherWrapper extends PBEWrapper {
+
+    private final AlgorithmParameterSpec aps;
+
+    public PBECipherWrapper(
+            Provider p, String algo, String passwd, PrintStream out)
+            throws Exception {
+        super(algo,
+                SecretKeyFactory.getInstance(
+                        new StringTokenizer(algo, "/").nextToken(), p).generateSecret(
+                        new PBEKeySpec(passwd.toCharArray())),
+                Cipher.getInstance(algo, p), out);
+
+        int SALT_SIZE = 8;
+        aps = new PBEParameterSpec(generateSalt(SALT_SIZE), ITERATION_COUNT);
+    }
+
+    @Override
+    public boolean execute(int edMode, byte[] inputText, int offset,
+            int len) {
+        StringTokenizer st = new StringTokenizer(algo, "/");
+        String baseAlgo = st.nextToken().toUpperCase();
+
+        // Perform encryption or decryption depends on the specified edMode
+        try {
+            ci.init(edMode, key, aps);
+
+            // First, generate the cipherText at an allocated buffer
+            byte[] outputText = ci.doFinal(inputText, offset, len);
+
+            // Second, generate cipherText again at the same buffer of
+            // plainText
+            int myoff = offset / 2;
+            int off = ci.update(inputText, offset, len, inputText, myoff);
+
+            ci.doFinal(inputText, myoff + off);
+
+            if (baseAlgo.endsWith("TRIPLEDES")
+                    || baseAlgo.endsWith("AES_256")) {
+                out.print("Expected exception uncaught,"
+                        + "keyStrength > 128 within " + this.algo);
+
+                return false;
+            }
+
+            // Compare to see whether the two results are the same or not
+            boolean result = equalsBlock(inputText, myoff, outputText, 0,
+                    outputText.length);
+
+            return result;
+        } catch (Exception ex) {
+            if ((ex instanceof InvalidKeyException)
+                    && (baseAlgo.endsWith("TRIPLEDES")
+                    || baseAlgo.endsWith("AES_256"))) {
+                out.println("Expected InvalidKeyException exception: "
+                        + ex.getMessage());
+
+                return true;
+            }
+
+            out.println("Catch unexpected exception within " + algo);
+            ex.printStackTrace(out);
+
+            return false;
+        }
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESameBuffer/PBESameBuffer.java b/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESameBuffer/PBESameBuffer.java
new file mode 100644
index 0000000..4fe20f8
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESameBuffer/PBESameBuffer.java
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2012, 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.
+ *
+ * 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 8041787
+ * @library .
+ * @build PBEWrapper PBEWrapperCreator PBKDF2Wrapper AESPBEWrapper PBECipherWrapper
+ * @summary Verify that same encrypt/decrypt buffer can be used for PBE ciphers
+ * @author Alexander Fomin
+ * @author rhalade
+ * @run main PBESameBuffer
+ */
+import java.io.PrintStream;
+import java.security.*;
+import java.util.Random;
+import javax.crypto.Cipher;
+
+public class PBESameBuffer {
+
+    private static final String[] pbeAlgorithms = {
+        "pbeWithMD5ANDdes", "PBEWithMD5AndDES/CBC/PKCS5Padding",
+        "pbeWithMD5ANDtripledes", "PBEWithMD5AndTRIPLEDES/CBC/PKCS5Padding",
+        "PBEwithSHA1AndDESede", "PBEwithSHA1AndDESede/CBC/PKCS5Padding",
+        "PBEwithSHA1AndRC2_40", "PBEwithSHA1AndRC2_40/CBC/PKCS5Padding",
+        "PBEWithSHA1AndRC2_128", "PBEWithSHA1AndRC2_128/CBC/PKCS5Padding",
+        "PBEWithSHA1AndRC4_40", "PBEWithSHA1AndRC4_40/ECB/NoPadding",
+        "PBEWithSHA1AndRC4_128", "PBEWithSHA1AndRC4_128/ECB/NoPadding",
+        "PBEWithHmacSHA1AndAES_128",
+        "PBEWithHmacSHA224AndAES_128",
+        "PBEWithHmacSHA256AndAES_128",
+        "PBEWithHmacSHA384AndAES_128",
+        "PBEWithHmacSHA512AndAES_128",
+        "PBEWithHmacSHA1AndAES_256",
+        "PBEWithHmacSHA224AndAES_256",
+        "PBEWithHmacSHA256AndAES_256",
+        "PBEWithHmacSHA384AndAES_256",
+        "PBEWithHmacSHA512AndAES_256",
+        "PBKDF2WithHmacSHA1",
+        "PBKDF2WithHmacSHA224",
+        "PBKDF2WithHmacSHA256",
+        "PBKDF2WithHmacSHA384",
+        "PBKDF2WithHmacSHA512"
+    };
+
+    private static final String PBEPASS = "Hush, it's supposed to be a secret!";
+
+    private static final int INPUT_LENGTH = 800;
+    private static final int[] OFFSETS = {0, 1, 2, 3};
+    private static final int NUM_PAD_BYTES = 8;
+    private static final int PBKDF2_ADD_PAD_BYTES = 8;
+
+    private static int OUTPUT_OFFSET;
+
+    public static void main(String[] args) {
+        if (!(new PBESameBuffer().test(args, System.out))) {
+            throw new RuntimeException("Some PBE algorithm tests failed");
+        }
+    }
+
+    public boolean test(String[] args, PrintStream out) {
+        boolean result = true;
+
+        Provider p = Security.getProvider("SunJCE");
+
+        for (int loop : OFFSETS) {
+            OUTPUT_OFFSET = loop;
+
+            // generate input data
+            byte[] inputText = new byte[INPUT_LENGTH + NUM_PAD_BYTES
+                    + OUTPUT_OFFSET * 2 + PBKDF2_ADD_PAD_BYTES];
+            new Random().nextBytes(inputText);
+
+            for (String algorithm : pbeAlgorithms) {
+                out.println("=> Testing algorithm " + algorithm + " and offset "
+                        + OUTPUT_OFFSET + ":");
+
+                try {
+                    // Initialize Cipher and key for this algorithm
+                    PBEWrapper pbeCi = PBEWrapperCreator.createWrapper(p,
+                            algorithm,
+                            PBEPASS,
+                            out);
+
+                    // Encrypt
+                    if ((pbeCi != null) && (!pbeCi.execute(Cipher.ENCRYPT_MODE,
+                            inputText,
+                            OUTPUT_OFFSET * 2,
+                            INPUT_LENGTH))) {
+                        result = false;
+                    }
+
+                    // PBKDF2 required 16 byte padding
+                    int padLength = getPadLength(algorithm);
+
+                    // Decrypt
+                    // Note: inputText is implicitly padded by the above encrypt
+                    // operation so decrypt operation can safely proceed
+                    if ((pbeCi != null) && (!pbeCi.execute(Cipher.DECRYPT_MODE,
+                            inputText,
+                            OUTPUT_OFFSET,
+                            INPUT_LENGTH + padLength))) {
+                        result = false;
+                    }
+                } catch (Exception ex) {
+                    ex.printStackTrace(out);
+                    result = false;
+                }
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * Get the padding length for the given algorithm
+     *
+     * @param theAlgName algorithm name
+     * @return padding length for the given algorithm
+     */
+    private int getPadLength(String theAlgName) {
+        if (theAlgName.toUpperCase().contains("PBKDF2")) {
+            return NUM_PAD_BYTES + PBKDF2_ADD_PAD_BYTES;
+        }
+
+        if (theAlgName.toUpperCase().contains("AES")) {
+            return NUM_PAD_BYTES + PBKDF2_ADD_PAD_BYTES;
+        }
+
+        return NUM_PAD_BYTES;
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESameBuffer/PBEWrapper.java b/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESameBuffer/PBEWrapper.java
new file mode 100644
index 0000000..9e76584
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESameBuffer/PBEWrapper.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2012, 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.
+ *
+ * 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.PrintStream;
+import java.util.Random;
+import javax.crypto.Cipher;
+import javax.crypto.SecretKey;
+
+/**
+ * PBEWrapper is the abstract class for all concrete PBE Cipher wrappers. A
+ * PBEWrapper object encapsulates the information and behavior needed to test if
+ * the multiple-part encryption/decryption is performing by expected way on the
+ * same byte buffer.
+ *
+ * @author Alexandr Fomin
+ * @author rhalade
+ */
+public abstract class PBEWrapper {
+
+    protected final static int ITERATION_COUNT = 1000;
+
+    protected final SecretKey key;
+    protected final Cipher ci;
+    protected final String algo;
+    protected final PrintStream out;
+
+    public PBEWrapper(String pAlgo, SecretKey pKey, Cipher pCi,
+            PrintStream pOut ){
+        this.algo = pAlgo;
+        this.key = pKey;
+        this.ci = pCi;
+        this.out = pOut;
+    }
+
+    /**
+     * Abstract method need to be implemented in the subclasses.
+     *
+     * @param edMode Cipher mode - encrypt/decrypt
+     * @param inputText byte buffer to process
+     * @param offset offset in byte the inputText
+     * @param len length of byte to process in inputText
+     * @return true if cipher operation is successful, false otherwise
+     */
+    public abstract boolean execute(int edMode, byte[] inputText, int offset,
+            int len);
+
+    /**
+     * An utility method to prepare "salt" for following Secret Key generation.
+     *
+     * @param numberOfBytes number of bytes in salt
+     * @return randomly generated byte array
+     */
+    protected static byte[] generateSalt(int numberOfBytes) {
+        byte[] salt = new byte[numberOfBytes];
+        new Random().nextBytes(salt);
+        return salt;
+    }
+
+    /**
+     * An utility method to check if two byte arrays are equal
+     *
+     * @param b1 first byte array
+     * @param off1 offset to compare from in b1
+     * @param b2 second byte array
+     * @param off2 offset to compare from in b2
+     * @param len length to compare
+     * @return true of arrays are equal, false otherwise
+     */
+    protected boolean equalsBlock(byte[] b1, int off1,
+            byte[] b2, int off2, int len) {
+        for (int i = off1, j = off2, k = 0; k < len; i++, j++, k++) {
+            if (b1[i] != b2[j]) {
+                return false;
+            }
+        }
+        return true;
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESameBuffer/PBEWrapperCreator.java b/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESameBuffer/PBEWrapperCreator.java
new file mode 100644
index 0000000..85a19c9
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESameBuffer/PBEWrapperCreator.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2012, 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.
+ *
+ * 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.security.Provider;
+import java.io.PrintStream;
+
+/**
+ * An utility class to create PBEWrapper object for the TestCipherSameBuffer
+ * test.
+ *
+ * @author Alexander Fomin
+ */
+public class PBEWrapperCreator {
+
+    private static final String PBKDF2 = "PBKDF2";
+    private static final String AES = "AES";
+
+    /**
+     * Create PBEWrapper for the TestCipherSameBuffer test using given
+     * parameters.
+     *
+     * @param p security provider
+     * @param algo algorithms to test
+     * @param passwd a password phrase
+     * @param out print stream object
+     * @return PBEWrapper in accordance to requested algorithm
+     * @throws Exception all exception are thrown.
+     */
+    public static PBEWrapper createWrapper(Provider p, String algo,
+            String passwd, PrintStream out) throws Exception {
+        if (algo.toUpperCase().contains(PBKDF2)) {
+            return new PBKDF2Wrapper(p, algo, passwd, out);
+        } else if (algo.toUpperCase().contains(AES)) {
+            return new AESPBEWrapper(p, algo, passwd, out);
+        } else {
+            return new PBECipherWrapper(p, algo, passwd, out);
+        }
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESameBuffer/PBKDF2Wrapper.java b/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESameBuffer/PBKDF2Wrapper.java
new file mode 100644
index 0000000..6a2110d
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESameBuffer/PBKDF2Wrapper.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2012, 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.
+ *
+ * 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.PrintStream;
+import java.security.Provider;
+import javax.crypto.Cipher;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.PBEKeySpec;
+import javax.crypto.spec.SecretKeySpec;
+
+/**
+ * Wrapper class to test a given SecretKeyFactory.PBKDF2 algorithm.
+ *
+ * @author Alexander Fomin
+ */
+public class PBKDF2Wrapper extends PBEWrapper {
+    private static final String CIPHER_TANSFORMATION = "AES/CBC/PKCS5Padding";
+    private static final int SALT_SIZE = 64;
+    private static final int PKDF2_DEFAULT_KEY_LEN = 128;
+
+    private static volatile byte[] iv;
+
+    /**
+     * PBKDF2Wrapper constructor. Instantiate Cipher using
+     * "AES/CBC/PKCS5Padding" transformation. Generate a secret key using given
+     * PKDF2 algorithms.
+     *
+     * @param p security Provider
+     * @param algo PKDF2 algorithm
+     * @param passwd password phrase
+     * @param out print stream
+     * @throws Exception all exceptions are thrown
+     */
+    public PBKDF2Wrapper(Provider p, String algo, String passwd,
+            PrintStream out) throws Exception {
+        super(algo,
+                SecretKeyFactory.getInstance(algo, p).generateSecret(
+                        new PBEKeySpec(passwd.toCharArray(),
+                generateSalt(SALT_SIZE), ITERATION_COUNT, PKDF2_DEFAULT_KEY_LEN)),
+                Cipher.getInstance(CIPHER_TANSFORMATION, p), out);
+    }
+
+    /**
+     * Perform encryption/decryption operation (depending on the specified
+     * edMode) on the same byte buffer. Compare result with the result at an
+     * allocated buffer. If both results are equal - return true, otherwise
+     * return false.
+     *
+     * @param edMode specified mode
+     * @param inputText text to decrypt
+     * @param offset offset in the text
+     * @param len input length
+     * @return ture - test passed; false - test failed
+     */
+    @Override
+    public boolean execute(int edMode, byte[] inputText, int offset, int len) {
+        int needBytesForResult = -1;
+        String KEY_ALGORITHM = "AES";
+
+        try {
+            // init Cipher
+            if (Cipher.ENCRYPT_MODE == edMode) {
+                ci.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key.getEncoded(),
+                        KEY_ALGORITHM));
+                iv = ci.getParameters().getParameterSpec(IvParameterSpec.class).
+                        getIV();
+            } else {
+                ci.init(Cipher.DECRYPT_MODE,
+                        new SecretKeySpec(key.getEncoded(), KEY_ALGORITHM),
+                        new IvParameterSpec(iv));
+            }
+
+            // First, generate the cipherText at an allocated buffer
+            byte[] outputText = ci.doFinal(inputText, offset, len);
+
+            // Second, generate cipherText again at the same buffer of plainText
+            int myoff = offset / 2;
+            int off = ci.update(inputText, offset, len, inputText, myoff);
+            ci.doFinal(inputText, myoff + off);
+
+            // Compare to see whether the two results are the same or not
+            return equalsBlock(inputText, myoff, outputText, 0,
+                    outputText.length);
+        } catch (Exception ex) {
+            out.println("Catch unexpected exception within " + algo
+                    + " " + edMode + ": " + ex.getMessage()
+                    + ". getOutputSize()" + "returned " + needBytesForResult);
+            ex.printStackTrace(out);
+
+            return false;
+        }
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESealedObject.java b/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESealedObject.java
new file mode 100644
index 0000000..2420b9b
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESealedObject.java
@@ -0,0 +1,173 @@
+/*
+ * Copyright (c) 2012, 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.
+ *
+ * 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.PrintStream;
+import java.security.AlgorithmParameters;
+import java.security.InvalidKeyException;
+import java.security.Provider;
+import java.security.Security;
+import java.security.spec.AlgorithmParameterSpec;
+import java.util.Arrays;
+import java.util.Random;
+import java.util.StringTokenizer;
+import javax.crypto.Cipher;
+import javax.crypto.SealedObject;
+import javax.crypto.SecretKey;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.PBEKeySpec;
+import javax.crypto.spec.PBEParameterSpec;
+
+/**
+ * @test
+ * @bug 8041781
+ * @summary test if seal/unseal works correctly with PBE algorithms
+ * @author Yun Ke
+ * @author Bill Situ
+ * @author Alexander Fomin
+ * @run main PBESealedObject
+ */
+public class PBESealedObject {
+
+    private static final String[] PBEAlgorithms = {
+        "pbeWithMD5ANDdes",
+        "PBEWithMD5AndDES/CBC/PKCS5Padding",
+        "PBEWithMD5AndTripleDES",
+        "PBEWithMD5AndTripleDES/CBC/PKCS5Padding",
+        "PBEwithSHA1AndDESede",
+        "PBEwithSHA1AndDESede/CBC/PKCS5Padding",
+        "PBEwithSHA1AndRC2_40",
+        "PBEwithSHA1Andrc2_40/CBC/PKCS5Padding",
+        "PBEWithSHA1AndRC2_128",
+        "PBEWithSHA1andRC2_128/CBC/PKCS5Padding",
+        "PBEWithSHA1AndRC4_40",
+        "PBEWithsha1AndRC4_40/ECB/NoPadding",
+        "PBEWithSHA1AndRC4_128",
+        "pbeWithSHA1AndRC4_128/ECB/NoPadding",
+        "PBEWithHmacSHA1AndAES_128",
+        "PBEWithHmacSHA224AndAES_128",
+        "PBEWithHmacSHA256AndAES_128",
+        "PBEWithHmacSHA384AndAES_128",
+        "PBEWithHmacSHA512AndAES_128",
+        "PBEWithHmacSHA1AndAES_256",
+        "PBEWithHmacSHA224AndAES_256",
+        "PBEWithHmacSHA256AndAES_256",
+        "PBEWithHmacSHA384AndAES_256",
+        "PBEWithHmacSHA512AndAES_256"
+    };
+
+    public static void main(String[] args) {
+        PBESealedObject test = new PBESealedObject();
+        Provider sunjce = Security.getProvider("SunJCE");
+
+        if (!test.runAll(sunjce, System.out)) {
+            throw new RuntimeException("One or more tests have failed....");
+        }
+    }
+
+    public boolean runAll(Provider p, PrintStream out) {
+        boolean finalResult = true;
+
+        for (String algorithm : PBEAlgorithms) {
+            out.println("Running test with " + algorithm + ":");
+            try {
+                if (!runTest(p, algorithm, out)) {
+                    finalResult = false;
+                    out.println("STATUS: Failed");
+                } else {
+                    out.println("STATUS: Passed");
+                }
+            } catch (Exception ex) {
+                finalResult = false;
+                ex.printStackTrace(out);
+                out.println("STATUS:Failed");
+            }
+        }
+
+        return finalResult;
+    }
+
+    // Have a generic throws Exception as it can throw many different exceptions
+    public boolean runTest(Provider p, String algo, PrintStream out)
+            throws Exception {
+
+        byte[] salt = new byte[8];
+        int ITERATION_COUNT = 1000;
+        AlgorithmParameters pbeParams = null;
+
+        String baseAlgo
+                = new StringTokenizer(algo, "/").nextToken().toUpperCase();
+        boolean isAES = baseAlgo.contains("AES");
+
+        try {
+            // Initialization
+            Cipher ci = Cipher.getInstance(algo, p);
+            new Random().nextBytes(salt);
+            AlgorithmParameterSpec aps = new PBEParameterSpec(salt,
+                    ITERATION_COUNT);
+            SecretKeyFactory skf = SecretKeyFactory.getInstance(baseAlgo, p);
+            SecretKey key = skf.generateSecret(
+                    new PBEKeySpec("Secret Lover".toCharArray()));
+
+            // Seal
+            if (isAES) {
+                ci.init(Cipher.ENCRYPT_MODE, key);
+                pbeParams = ci.getParameters();
+            } else {
+                ci.init(Cipher.ENCRYPT_MODE, key, aps);
+            }
+
+            SealedObject so = new SealedObject(key, ci);
+
+            // Unseal and compare
+            if (isAES) {
+                ci.init(Cipher.DECRYPT_MODE, key, pbeParams);
+            } else {
+                ci.init(Cipher.DECRYPT_MODE, key, aps);
+            }
+
+            SecretKey unsealedKey;
+
+            unsealedKey = (SecretKey) so.getObject(ci);
+            if (!Arrays.equals(unsealedKey.getEncoded(), key.getEncoded())) {
+                return false;
+            }
+
+            unsealedKey = (SecretKey) so.getObject(key);
+            if (!Arrays.equals(unsealedKey.getEncoded(), key.getEncoded())) {
+                return false;
+            }
+
+            unsealedKey = (SecretKey) so.getObject(key, "SunJCE");
+            return Arrays.equals(unsealedKey.getEncoded(), key.getEncoded());
+        } catch (InvalidKeyException ex) {
+            if (baseAlgo.endsWith("TRIPLEDES") || baseAlgo.endsWith("AES_256")) {
+                out.println(
+                        "Expected exception , keyStrength > 128 within" + algo);
+                return true;
+            }
+
+            throw ex;
+        }
+    }
+
+}
diff --git a/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBKDF2Translate.java b/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBKDF2Translate.java
new file mode 100644
index 0000000..3668159
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBKDF2Translate.java
@@ -0,0 +1,311 @@
+/*
+ * Copyright (c) 2012, 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.
+ *
+ * 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.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.spec.InvalidKeySpecException;
+import java.util.Arrays;
+import java.util.Random;
+import javax.crypto.SecretKey;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.interfaces.PBEKey;
+import javax.crypto.spec.PBEKeySpec;
+
+/**
+ * @test
+ * @bug 8041781
+ * @summary Verify if the SecretKeyFactory.translateKey() method works
+ * @author Alexander Fomin
+ * @run main PBKDF2Translate
+ */
+public class PBKDF2Translate {
+
+    private static final String[] ALGO_TO_TEST = {
+        "PBKDF2WithHmacSHA1",
+        "PBKDF2WithHmacSHA224",
+        "PBKDF2WithHmacSHA256",
+        "PBKDF2WithHmacSHA384",
+        "PBKDF2WithHmacSHA512"
+    };
+
+    private static final String PASS_PHRASE = "some hidden string";
+    private static final int ITERATION_COUNT = 1000;
+    private static final int KEY_SIZE = 128;
+
+    private final String algoToTest;
+    private final byte[] salt = new byte[8];
+
+    public static void main(String[] args) throws Exception {
+
+        boolean failed = false;
+
+        for (String algo : ALGO_TO_TEST) {
+
+            System.out.println("Testing " + algo + ":");
+            PBKDF2Translate theTest = new PBKDF2Translate(algo);
+
+            try {
+                if (!theTest.testMyOwnSecretKey()
+                        || !theTest.generateAndTranslateKey()
+                        || !theTest.translateSpoiledKey()) {
+                    // we don't want to set failed to false
+                    failed = true;
+                }
+            } catch (InvalidKeyException | NoSuchAlgorithmException |
+                    InvalidKeySpecException e) {
+                e.printStackTrace(System.err);
+                failed = true;
+            }
+        }
+
+        if (failed) {
+            throw new RuntimeException("One or more tests failed....");
+        }
+    }
+
+    public PBKDF2Translate(String algoToTest) {
+        this.algoToTest = algoToTest;
+        new Random().nextBytes(this.salt);
+    }
+
+    /**
+     * The test case scenario implemented in the method: - derive PBKDF2 key
+     * using the given algorithm; - translate the key - check if the translated
+     * and original keys have the same key value.
+     *
+     * @return true if the test case passed; false - otherwise.
+     * @throws NoSuchAlgorithmException
+     * @throws InvalidKeySpecException
+     * @throws InvalidKeyException
+     */
+    public boolean generateAndTranslateKey() throws NoSuchAlgorithmException,
+            InvalidKeySpecException, InvalidKeyException {
+        // derive PBKDF2 key
+        SecretKey key1 = getSecretKeyForPBKDF2(algoToTest);
+
+        // translate key
+        SecretKeyFactory skf = SecretKeyFactory.getInstance(algoToTest);
+        SecretKey key2 = skf.translateKey(key1);
+
+        // check if it still the same after translation
+        if (!Arrays.equals(key1.getEncoded(), key2.getEncoded())) {
+            System.err.println("generateAndTranslateKey test case failed: the "
+                    + "key1 and key2 values in its primary encoding format are "
+                    + "not the same for " + algoToTest + "algorithm.");
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * The test case scenario implemented in the method: - derive Key1 for the
+     * given PBKDF2 algorithm - create my own secret Key2 as an instance of a
+     * class implements PBEKey - translate Key2 - check if the key value of the
+     * translated key and Key1 are the same.
+     *
+     * @return true if the test case passed; false - otherwise.
+     * @throws NoSuchAlgorithmException
+     * @throws InvalidKeySpecException
+     * @throws InvalidKeyException
+     */
+    public boolean testMyOwnSecretKey()
+            throws NoSuchAlgorithmException, InvalidKeySpecException,
+            InvalidKeyException {
+        SecretKey key1 = getSecretKeyForPBKDF2(algoToTest);
+        SecretKey key2 = getMyOwnSecretKey();
+
+        // Is it actually the same?
+        if (!Arrays.equals(key1.getEncoded(), key2.getEncoded())) {
+            System.err.println("We shouldn't be here. The key1 and key2 values "
+                    + "in its primary encoding format have to be the same!");
+            return false;
+        }
+
+        // Translate key
+        SecretKeyFactory skf = SecretKeyFactory.getInstance(algoToTest);
+        SecretKey key3 = skf.translateKey(key2);
+
+        // Check if it still the same after translation
+        if (!Arrays.equals(key1.getEncoded(), key3.getEncoded())) {
+            System.err.println("testMyOwnSecretKey test case failed: the key1 "
+                    + "and key3 values in its primary encoding format are not "
+                    + "the same for " + algoToTest + "algorithm.");
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * The test case scenario implemented in the method: - create my own secret
+     * Key2 as an instance of a class implements PBEKey - spoil the key (set
+     * iteration count to 0, for example) - try to translate key -
+     * InvalidKeyException is expected.
+     *
+     * @return true if InvalidKeyException occurred; false - otherwise.
+     * @throws NoSuchAlgorithmException
+     * @throws InvalidKeySpecException
+     */
+    public boolean translateSpoiledKey() throws NoSuchAlgorithmException,
+            InvalidKeySpecException {
+        // derive the key
+        SecretKey key1 = getMyOwnSecretKey();
+
+        // spoil the key
+        ((MyPBKDF2SecretKey) key1).spoil();
+
+        // translate key
+        SecretKeyFactory skf = SecretKeyFactory.getInstance(algoToTest);
+        try {
+            SecretKey key2 = skf.translateKey(key1);
+        } catch (InvalidKeyException ike) {
+            // this is expected
+            return true;
+        }
+
+        return false;
+    }
+
+    /**
+     * Generate a PBKDF2 secret key using given algorithm.
+     *
+     * @param algoToDeriveKey PBKDF2 algorithm
+     * @return PBKDF2 secret key
+     * @throws NoSuchAlgorithmException
+     * @throws InvalidKeySpecException
+     */
+    private SecretKey getSecretKeyForPBKDF2(String algoToDeriveKey)
+            throws NoSuchAlgorithmException, InvalidKeySpecException {
+        SecretKeyFactory skf = SecretKeyFactory.getInstance(algoToDeriveKey);
+
+        PBEKeySpec spec = new PBEKeySpec(PASS_PHRASE.toCharArray(),
+                this.salt, ITERATION_COUNT, KEY_SIZE);
+
+        return skf.generateSecret(spec);
+    }
+
+    /**
+     * Generate a secrete key as an instance of a class implements PBEKey.
+     *
+     * @return secrete key
+     * @throws InvalidKeySpecException
+     * @throws NoSuchAlgorithmException
+     */
+    private SecretKey getMyOwnSecretKey() throws InvalidKeySpecException,
+            NoSuchAlgorithmException {
+        return new MyPBKDF2SecretKey(PASS_PHRASE, this.algoToTest, this.salt,
+                ITERATION_COUNT, KEY_SIZE);
+    }
+}
+
+/**
+ * An utility class to check the SecretKeyFactory.translateKey() method.
+ */
+class MyPBKDF2SecretKey implements PBEKey {
+
+    private final byte[] key;
+    private final byte[] salt;
+    private final String algorithm;
+    private final int keySize, keyLength;
+    private int itereationCount;
+    private final String pass;
+
+    @Override
+    public String getAlgorithm() {
+        return algorithm;
+    }
+
+    @Override
+    public String getFormat() {
+        return "RAW";
+    }
+
+    @Override
+    public byte[] getEncoded() {
+        byte[] copy = new byte[keyLength];
+        System.arraycopy(this.key, 0, copy, 0, keyLength);
+        return copy;
+    }
+
+    /**
+     * The key is generating by SecretKeyFactory and its value just copying in
+     * the key field of MySecretKey class. So, this is real key derived using
+     * the given algorithm.
+     *
+     * @param passPhrase some string intended to be a password
+     * @param algo PBKDF2 algorithm
+     * @param salt slat for PBKDF2
+     * @param iterationCount iteration count
+     * @param keySize key size in bits
+     * @throws InvalidKeySpecException
+     * @throws NoSuchAlgorithmException
+     */
+    public MyPBKDF2SecretKey(String passPhrase, String algo, byte[] salt,
+            int iterationCount, int keySize)
+            throws InvalidKeySpecException, NoSuchAlgorithmException {
+        this.algorithm = algo;
+        this.salt = salt;
+        this.itereationCount = iterationCount;
+        this.keySize = keySize;
+        this.pass = passPhrase;
+
+        PBEKeySpec spec = new PBEKeySpec(passPhrase.toCharArray(),
+                this.salt, iterationCount, this.keySize);
+
+        SecretKeyFactory keyFactory
+                = SecretKeyFactory.getInstance(algo);
+
+        SecretKey realKey = keyFactory.generateSecret(spec);
+
+        this.keyLength = realKey.getEncoded().length;
+
+        this.key = new byte[this.keyLength];
+        System.arraycopy(realKey.getEncoded(), 0, this.key, 0,
+                this.keyLength);
+    }
+
+    @Override
+    public int getIterationCount() {
+        return itereationCount;
+    }
+
+    @Override
+    public byte[] getSalt() {
+        return salt;
+    }
+
+    @Override
+    public char[] getPassword() {
+        return this.pass.toCharArray();
+    }
+
+    /**
+     * Spoil the generated key (before translation) to cause an
+     * InvalidKeyException
+     */
+    public void spoil() {
+        this.itereationCount = -1;
+    }
+
+}
diff --git a/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBMacBuffer.java b/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBMacBuffer.java
new file mode 100644
index 0000000..fc0256e
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBMacBuffer.java
@@ -0,0 +1,248 @@
+/*
+ * Copyright (c) 2012, 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.
+ *
+ * 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.nio.ByteBuffer;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.security.spec.InvalidKeySpecException;
+import java.util.Random;
+import javax.crypto.Mac;
+import javax.crypto.SecretKey;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.PBEKeySpec;
+
+/**
+ * @test
+ * @bug 8041787
+ * @summary verify that Mac.update works with different size ByteBuffer
+ * @author Alexander Fomin
+ * @run main PBMacBuffer
+ */
+public class PBMacBuffer {
+
+    private final int LARGE_SIZE = 500000;
+
+    public static void main(String[] args) {
+        String[] PBMAC1Algorithms = {
+            "HmacPBESHA1",
+            "PBEWithHmacSHA1",
+            "PBEWithHmacSHA224",
+            "PBEWithHmacSHA256",
+            "PBEWithHmacSHA384",
+            "PBEWithHmacSHA512"
+        };
+
+        String[] PBKDF2Algorithms = {
+            "PBKDF2WithHmacSHA1",
+            "PBKDF2WithHmacSHA224",
+            "PBKDF2WithHmacSHA256",
+            "PBKDF2WithHmacSHA384",
+            "PBKDF2WithHmacSHA512"
+        };
+
+        PBMacBuffer testRunner = new PBMacBuffer();
+        boolean failed = false;
+
+        for (String thePBMacAlgo : PBMAC1Algorithms) {
+
+            for (String thePBKDF2Algo : PBKDF2Algorithms) {
+
+                System.out.println("Running test with " + thePBMacAlgo
+                        + " and " + thePBKDF2Algo + ":");
+                try {
+                    if (!testRunner.doTest(thePBMacAlgo, thePBKDF2Algo)) {
+                        failed = true;
+                    }
+                } catch (NoSuchAlgorithmException | InvalidKeyException |
+                        InvalidKeySpecException e) {
+                    failed = true;
+                    e.printStackTrace(System.out);
+                    System.out.println("Test FAILED.");
+                }
+            }
+        }
+
+        if (failed) {
+            throw new RuntimeException("One or more tests failed....");
+        }
+    }
+
+    /**
+     * Tests Mac.update(ByteBuffer input) method. Three test cases are
+     * performed: - large ByteBuffer test case to test if the update() method
+     * process a large ByteBuffer correctly; - empty ByteBuffer test case to
+     * test if the update() method process an empty ByteBuffer correctly; - NULL
+     * ByteBuffer test case to test if the update() method throws expected
+     * IllegalArgumentException exception.
+     *
+     * @param theMacAlgo PBMAC algorithm to test
+     * @param thePBKDF2Algo PBKDF2 algorithm to test
+     * @return true - test passed; false - otherwise.
+     * @throws NoSuchAlgorithmException
+     * @throws InvalidKeyException
+     * @throws InvalidKeySpecException
+     * @see javax.crypto.Mac
+     */
+    protected boolean doTest(String theMacAlgo, String thePBKDF2Algo)
+            throws NoSuchAlgorithmException, InvalidKeyException,
+            InvalidKeySpecException {
+        // obtain a SecretKey using PBKDF2
+        SecretKey key = getSecretKey(thePBKDF2Algo);
+
+        // Instantiate Mac object and init it with a SecretKey
+        Mac theMac = Mac.getInstance(theMacAlgo);
+        theMac.init(key);
+
+        // Do large ByteBuffer test case
+        if (!largeByteBufferTest(theMac)) {
+            System.out.println("Large ByteBuffer test case failed.");
+            return false;
+        }
+
+        // Do empty ByteBuffer test case
+        if (!emptyByteBufferTest(theMac)) {
+            System.out.println("Empty ByteBuffer test case failed.");
+            return false;
+        }
+
+        // Do null ByteBuffer test case
+        if (!nullByteBufferTest(theMac)) {
+            System.out.println("NULL ByteBuffer test case failed.");
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * Large ByteBuffer test case. Generate random ByteBuffer of LARGE_SIZE
+     * size. Performs MAC operation with the given Mac object (theMac
+     * parameter).Verifies the assertion "Upon return, the buffer's position
+     * will be equal to its limit; its limit will not have changed".
+     *
+     * @param theMac MAC object to test.
+     * @return true - test case passed; false - otherwise;
+     */
+    protected boolean largeByteBufferTest(Mac theMac) {
+        ByteBuffer buf = generateRandomByteBuffer(LARGE_SIZE);
+        int limitBefore = buf.limit();
+
+        theMac.update(buf);
+        theMac.doFinal();
+
+        int limitAfter = buf.limit();
+        int positonAfter = buf.position();
+
+        if (limitAfter != limitBefore) {
+            System.out.println("FAIL: Buffer's limit has been chenged.");
+            return false;
+        }
+
+        if (positonAfter != limitAfter) {
+            System.out.println("FAIL: "
+                    + "Buffer's position isn't equal to its limit");
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * Empty ByteBuffer test case. Generates an empty ByteBuffer. Perform MAC
+     * operation. No exceptions are expected.
+     *
+     * @param theMac
+     * @return true - test case pass; exception otherwise
+     */
+    protected boolean emptyByteBufferTest(Mac theMac) {
+        ByteBuffer buf = generateRandomByteBuffer(0);
+        theMac.update(buf);
+        theMac.doFinal();
+        return true;
+    }
+
+    /**
+     * NULL ByteBuffer test case. Pass NULL ByteBuffer to Mac.update(ByteBuffer
+     * buffer) method. An IllegalArgumentException expected.
+     *
+     * @param theMac Mac object to test.
+     * @return true - test case pass; false - otherwise.
+     */
+    protected boolean nullByteBufferTest(Mac theMac) {
+        try {
+            ByteBuffer buf = null;
+            theMac.update(buf);
+            theMac.doFinal();
+        } catch (IllegalArgumentException e) {
+            // expected exception has been thrown
+            return true;
+        }
+
+        System.out.println("FAIL: "
+                + "IllegalArgumentException hasn't been thrown as expected");
+
+        return false;
+    }
+
+    /**
+     * Get SecretKey for the given PBKDF2 algorithm.
+     *
+     * @param thePBKDF2Algorithm - PBKDF2 algorithm
+     * @return SecretKey according to thePBKDF2Algorithm
+     * @throws NoSuchAlgorithmException
+     * @throws InvalidKeySpecException
+     */
+    protected SecretKey getSecretKey(String thePBKDF2Algorithm)
+            throws NoSuchAlgorithmException, InvalidKeySpecException {
+        // Prepare salt
+        byte[] salt = new byte[64]; // PKCS #5 v2.1 recommendation
+        new SecureRandom().nextBytes(salt);
+
+        // Generate secret key
+        PBEKeySpec pbeKeySpec = new PBEKeySpec(
+                "A #pwd# implied to be hidden!".toCharArray(),
+                salt, 1000, 128);
+        SecretKeyFactory keyFactory
+                = SecretKeyFactory.getInstance(thePBKDF2Algorithm);
+        return keyFactory.generateSecret(pbeKeySpec);
+    }
+
+    /**
+     * An utility method to generate a random ByteBuffer of the requested size.
+     *
+     * @param size size of the ByteBuffer.
+     * @return ByteBuffer populated random data;
+     */
+    private ByteBuffer generateRandomByteBuffer(int size) {
+        // generate randome byte array
+        byte[] data = new byte[size];
+        new Random().nextBytes(data);
+
+        // create ByteBuffer
+        ByteBuffer bb = ByteBuffer.wrap(data);
+
+        return bb;
+    }
+
+}
diff --git a/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBMacDoFinalVsUpdate.java b/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBMacDoFinalVsUpdate.java
new file mode 100644
index 0000000..1f67f16
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBMacDoFinalVsUpdate.java
@@ -0,0 +1,212 @@
+/*
+ * Copyright (c) 2012, 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.
+ *
+ * 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.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.security.spec.InvalidKeySpecException;
+import javax.crypto.Mac;
+import javax.crypto.SecretKey;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.PBEKeySpec;
+
+/**
+ * @test
+ * @bug 8041787
+ * @summary Check if doFinal and update operation result in same PBMac
+ * @author Alexander Fomin
+ * @run main PBMacDoFinalVsUpdate
+ */
+public class PBMacDoFinalVsUpdate {
+
+    public static void main(String[] args) {
+        String[] PBMAC1Algorithms = {
+            "HmacPBESHA1",
+            "PBEWithHmacSHA1",
+            "PBEWithHmacSHA224",
+            "PBEWithHmacSHA256",
+            "PBEWithHmacSHA384",
+            "PBEWithHmacSHA512"
+        };
+
+        String[] PBKDF2Algorithms = {
+            "PBKDF2WithHmacSHA1",
+            "PBKDF2WithHmacSHA224",
+            "PBKDF2WithHmacSHA256",
+            "PBKDF2WithHmacSHA384",
+            "PBKDF2WithHmacSHA512"
+        };
+
+        PBMacDoFinalVsUpdate testRunner = new PBMacDoFinalVsUpdate();
+        boolean failed = false;
+
+        for (String thePBMacAlgo : PBMAC1Algorithms) {
+
+            for (String thePBKDF2Algo : PBKDF2Algorithms) {
+
+                System.out.println("Running test with " + thePBMacAlgo
+                        + " and " + thePBKDF2Algo + ":");
+                try {
+                    if (!testRunner.doTest(thePBMacAlgo, thePBKDF2Algo)) {
+                        failed = true;
+                    }
+                } catch (NoSuchAlgorithmException | InvalidKeyException |
+                        InvalidKeySpecException e) {
+                    failed = true;
+                    e.printStackTrace(System.out);
+                    System.out.println("Test FAILED.");
+                }
+            }
+        }
+
+        if (failed) {
+            throw new RuntimeException("One or more tests failed....");
+        }
+    }
+
+    /**
+     * Uses a random generator to initialize a message, instantiate a Mac object
+     * according to the given PBMAC1 algorithm, initialize the object with a
+     * SecretKey derived using PBKDF2 algorithm (see PKCS #5 v21, chapter 7.1),
+     * feed the message into the Mac object all at once and get the output MAC
+     * as result1. Reset the Mac object, chop the message into three pieces,
+     * feed into the Mac object sequentially, and get the output MAC as result2.
+     * Finally, compare result1 and result2 and see if they are the same.
+     *
+     * @param theMacAlgo PBMAC algorithm to test
+     * @param thePBKDF2Algo PBKDF2 algorithm to test
+     * @return true - the test is passed; false - otherwise.
+     * @throws NoSuchAlgorithmException
+     * @throws InvalidKeyException
+     * @throws InvalidKeySpecException
+     */
+    protected boolean doTest(String theMacAlgo, String thePBKDF2Algo)
+            throws NoSuchAlgorithmException, InvalidKeyException,
+            InvalidKeySpecException {
+        int OFFSET = 5;
+
+        // Some message for which a MAC result will be calculated
+        byte[] plain = new byte[25];
+        new SecureRandom().nextBytes(plain);
+
+        // Form tail - is one of the three pieces
+        byte[] tail = new byte[plain.length - OFFSET];
+        System.arraycopy(plain, OFFSET, tail, 0, tail.length);
+
+        // Obtain a SecretKey using PBKDF2
+        SecretKey key = getSecretKey(thePBKDF2Algo);
+
+        // Instantiate Mac object and init it with a SecretKey and calc result1
+        Mac theMac = Mac.getInstance(theMacAlgo);
+        theMac.init(key);
+        byte[] result1 = theMac.doFinal(plain);
+
+        if (!isMacLengthExpected(theMacAlgo, result1.length)) {
+            return false;
+        }
+
+        // Reset Mac and calculate result2
+        theMac.reset();
+        theMac.update(plain[0]);
+        theMac.update(plain, 1, OFFSET - 1);
+        byte[] result2 = theMac.doFinal(tail);
+
+        // Return result
+        if (!java.util.Arrays.equals(result1, result2)) {
+            System.out.println("result1 and result2 are not the same:");
+            System.out.println("result1: " + dumpByteArray(result1));
+            System.out.println("result2: " + dumpByteArray(result2));
+            return false;
+        } else {
+            System.out.println("Resulted MAC with update and doFinal is same");
+        }
+
+        return true;
+    }
+
+    /**
+     * Get SecretKey for the given PBKDF2 algorithm.
+     *
+     * @param thePBKDF2Algorithm - PBKDF2 algorithm
+     * @return SecretKey according to thePBKDF2Algorithm
+     * @throws NoSuchAlgorithmException
+     * @throws InvalidKeySpecException
+     */
+    protected SecretKey getSecretKey(String thePBKDF2Algorithm)
+            throws NoSuchAlgorithmException, InvalidKeySpecException {
+        // Prepare salt
+        byte[] salt = new byte[64]; // PKCS #5 v2.1 recommendation
+        new SecureRandom().nextBytes(salt);
+
+        // Generate secret key
+        PBEKeySpec pbeKeySpec = new PBEKeySpec(
+                "A #pwd# implied to be hidden!".toCharArray(),
+                salt, 1000, 128);
+        SecretKeyFactory keyFactory
+                = SecretKeyFactory.getInstance(thePBKDF2Algorithm);
+        return keyFactory.generateSecret(pbeKeySpec);
+    }
+
+    /**
+     * Check if the lengthToCheck is expected length for the given MACAlgo.
+     *
+     * @param MACAlgo PBMAC algorithm
+     * @param lengthToCheck the length of MAC need to check
+     * @return true - lengthToCheck is expected length for the MACAlgo; false -
+     * otherwise.
+     */
+    protected boolean isMacLengthExpected(String MACAlgo, int lengthToCheck) {
+        java.util.regex.Pattern p = java.util.regex.Pattern.compile("(\\d+)",
+                java.util.regex.Pattern.CASE_INSENSITIVE);
+        java.util.regex.Matcher m = p.matcher(MACAlgo);
+        int val = 0;
+
+        if (m.find()) {
+            val = Integer.parseInt(m.group(1));
+        }
+
+        // HmacPBESHA1 should return MAC 20 byte length
+        if ((val == 1) && (lengthToCheck == 20)) {
+            return true;
+        }
+
+        return (val / 8) == lengthToCheck;
+    }
+
+    /**
+     * An utility method to dump a byte array for debug output.
+     *
+     * @param theByteArray the byte array to dump
+     * @return string representation of the theByteArray in Hex.
+     */
+    protected String dumpByteArray(byte[] theByteArray) {
+        StringBuilder buf = new StringBuilder();
+
+        for (byte b : theByteArray) {
+            buf.append(Integer.toHexString(b));
+        }
+
+        return buf.toString();
+    }
+
+}
diff --git a/jdk/test/com/sun/crypto/provider/Cipher/PBE/TestCipherKeyWrapperPBEKey.java b/jdk/test/com/sun/crypto/provider/Cipher/PBE/TestCipherKeyWrapperPBEKey.java
new file mode 100644
index 0000000..cc237d0
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Cipher/PBE/TestCipherKeyWrapperPBEKey.java
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2012, 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.
+ *
+ * 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.PrintStream;
+import java.security.AlgorithmParameters;
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.Provider;
+import java.security.Security;
+import java.security.spec.AlgorithmParameterSpec;
+import java.util.Arrays;
+import java.util.Random;
+import java.util.StringTokenizer;
+import javax.crypto.Cipher;
+import javax.crypto.SecretKey;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.PBEKeySpec;
+import javax.crypto.spec.PBEParameterSpec;
+
+/**
+ * @test
+ * @bug 8041781
+ * @summary Test to see if key wrapper works correctly with PBEKey
+ * @author Yu-Ching (Valerie) PENG
+ * @author Bill Situ
+ * @author Yun Ke
+ * @run main TestCipherKeyWrapperPBEKey
+ */
+public class TestCipherKeyWrapperPBEKey {
+
+    private static final String[] PBEAlgorithms = {
+        "pbeWithMD5ANDdes",
+        "PBEWithMD5AndDES/CBC/PKCS5Padding",
+        "PBEWithMD5AndTripleDES",
+        "PBEWithMD5AndTripleDES/CBC/PKCS5Padding",
+        "PBEwithSHA1AndDESede",
+        "PBEwithSHA1AndDESede/CBC/PKCS5Padding",
+        "PBEwithSHA1AndRC2_40",
+        "PBEwithSHA1Andrc2_40/CBC/PKCS5Padding",
+        "PBEWithSHA1AndRC2_128",
+        "PBEWithSHA1andRC2_128/CBC/PKCS5Padding",
+        "PBEWithSHA1AndRC4_40",
+        "PBEWithsha1AndRC4_40/ECB/NoPadding",
+        "PBEWithSHA1AndRC4_128",
+        "pbeWithSHA1AndRC4_128/ECB/NoPadding",
+        "PBEWithHmacSHA1AndAES_128",
+        "PBEWithHmacSHA224AndAES_128",
+        "PBEWithHmacSHA256AndAES_128",
+        "PBEWithHmacSHA384AndAES_128",
+        "PBEWithHmacSHA512AndAES_128",
+        "PBEWithHmacSHA1AndAES_256",
+        "PBEWithHmacSHA224AndAES_256",
+        "PBEWithHmacSHA256AndAES_256",
+        "PBEWithHmacSHA384AndAES_256",
+        "PBEWithHmacSHA512AndAES_256"
+    };
+
+    public static void main(String[] args) {
+
+        TestCipherKeyWrapperPBEKey test = new TestCipherKeyWrapperPBEKey();
+        Provider sunjce = Security.getProvider("SunJCE");
+
+        if (!test.runAll(sunjce, System.out)) {
+            throw new RuntimeException("One or more tests have failed....");
+        }
+    }
+
+    public boolean runAll(Provider p, PrintStream out) {
+        boolean finalResult = true;
+
+        for (String algorithm : PBEAlgorithms) {
+            out.println("Running test with " + algorithm + ":");
+            try {
+                if (!runTest(p, algorithm, out)) {
+                    finalResult = false;
+                    out.println("STATUS: Failed");
+                } else {
+                    out.println("STATUS: Passed");
+                }
+            } catch (Exception ex) {
+                finalResult = false;
+                ex.printStackTrace(out);
+                out.println("STATUS:Failed");
+            }
+        }
+
+        return finalResult;
+    }
+
+    // Have a generic throws Exception as it can throw many different exceptions
+    public boolean runTest(Provider p, String algo, PrintStream out)
+            throws Exception {
+
+        byte[] salt = new byte[8];
+        int ITERATION_COUNT = 1000;
+        AlgorithmParameters pbeParams = null;
+
+        String baseAlgo
+                = new StringTokenizer(algo, "/").nextToken().toUpperCase();
+        boolean isAES = baseAlgo.contains("AES");
+
+        try {
+            // Initialization
+            new Random().nextBytes(salt);
+            AlgorithmParameterSpec aps = new PBEParameterSpec(salt,
+                    ITERATION_COUNT);
+            SecretKeyFactory skf = SecretKeyFactory.getInstance(baseAlgo, p);
+            SecretKey key = skf.generateSecret(new PBEKeySpec(
+                    "Secret Key".toCharArray()));
+            Cipher ci = Cipher.getInstance(algo);
+
+            if (isAES) {
+                ci.init(Cipher.WRAP_MODE, key);
+                pbeParams = ci.getParameters();
+            } else {
+                ci.init(Cipher.WRAP_MODE, key, aps);
+            }
+
+            byte[] keyWrapper = ci.wrap(key);
+            if (isAES) {
+                ci.init(Cipher.UNWRAP_MODE, key, pbeParams);
+            } else {
+                ci.init(Cipher.UNWRAP_MODE, key, aps);
+            }
+
+            Key unwrappedKey = ci.unwrap(keyWrapper, algo, Cipher.SECRET_KEY);
+
+            if (baseAlgo.endsWith("TRIPLEDES")
+                    || baseAlgo.endsWith("AES_256")) {
+                out.print(
+                        "InvalidKeyException not thrown when keyStrength > 128");
+                return false;
+            }
+
+            return (Arrays.equals(key.getEncoded(), unwrappedKey.getEncoded()));
+
+        } catch (InvalidKeyException ex) {
+
+            if ((baseAlgo.endsWith("TRIPLEDES")
+                    || baseAlgo.endsWith("AES_256"))) {
+                out.println("Expected InvalidKeyException, keyStrength > 128");
+                return true;
+            } else {
+                throw ex;
+            }
+        }
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/Cipher/PBE/TestCipherPBECons.java b/jdk/test/com/sun/crypto/provider/Cipher/PBE/TestCipherPBECons.java
new file mode 100644
index 0000000..c429523
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Cipher/PBE/TestCipherPBECons.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2012, 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.
+ *
+ * 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.PrintStream;
+import java.security.NoSuchAlgorithmException;
+import java.security.Provider;
+import java.security.Security;
+import javax.crypto.Cipher;
+import javax.crypto.NoSuchPaddingException;
+
+/**
+ * @test
+ * @bug 8041787
+ * @summary Verify that for PBEWithMD5AndDES cipher, only CBC mode and
+ * PKCS#5Padding is allowed
+ * @author Yun Ke
+ * @author Bill Situ
+ * @author Yu-Ching (Valerie) PENG
+ * @run main TestCipherKeyWrapperPBEKey
+ */
+public class TestCipherPBECons {
+
+    private static final String[] PBEAlgorithms = {"pbeWithMD5ANDdes",
+        "PBEWithMD5AndTripleDES"};
+    private static final String[] cipherModes = {"ECb", "cbC", "cFB", "Cfb32",
+        "OfB", "oFb64", "pCbC"};
+    private static final String[] cipherPaddings = {"Pkcs5Padding", "NoPaDDing"};
+
+    public static void main(String[] args) {
+        TestCipherPBECons test = new TestCipherPBECons();
+        Provider sunjce = Security.getProvider("SunJCE");
+
+        if (!test.runAll(sunjce, System.out)) {
+            throw new RuntimeException("One or more tests have failed....");
+        }
+    }
+
+    public boolean runAll(Provider p, PrintStream out) {
+        boolean finalResult = true;
+
+        for (String algorithm : PBEAlgorithms) {
+            for (String mode : cipherModes) {
+                for (String padding : cipherPaddings) {
+                    out.println("Running test with " + algorithm
+                            + "/" + mode + "/" + padding);
+                    try {
+                        if (!runTest(p, algorithm, mode, padding, out)) {
+                            finalResult = false;
+                            out.println("STATUS: Failed");
+                        } else {
+                            out.println("STATUS: Passed");
+                        }
+                    } catch (Exception ex) {
+                        finalResult = false;
+                        ex.printStackTrace(out);
+                        out.println("STATUS:Failed");
+                    }
+                }
+            }
+        }
+
+        return finalResult;
+    }
+
+    public boolean runTest(Provider p, String algo, String mo, String pad,
+            PrintStream out) throws Exception {
+        try {
+            // Initialization
+            Cipher ci = Cipher.getInstance(algo + "/" + mo + "/" + pad, p);
+
+            // No exception thrown, must be of the right mode and right
+            // padding scheme
+            return (mo.equalsIgnoreCase("CBC"))
+                    && (pad.equalsIgnoreCase("PKCS5Padding"));
+        } catch (NoSuchAlgorithmException ex) {
+            if (p.getName().compareTo("SunJCE") == 0) {
+                if (!(mo.equalsIgnoreCase("CBC")
+                        && pad.equalsIgnoreCase("PKCS5Padding"))) {
+                    out.println("NoSuchAlgorithmException is as expected");
+                    return true;
+                }
+            }
+
+            out.println("Caught exception: " + ex.getMessage());
+            throw ex;
+        } catch (NoSuchPaddingException ex) {
+            if (mo.equalsIgnoreCase("CBC")
+                    && pad.equalsIgnoreCase("NoPadding")) {
+                out.println("NoSuchPaddingException is as expected");
+                return true;
+            } else {
+                out.println("Caught unexpected exception: " + ex.getMessage());
+                return false;
+            }
+        }
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/KeyAgreement/SameDHKeyStressTest.java b/jdk/test/com/sun/crypto/provider/KeyAgreement/SameDHKeyStressTest.java
new file mode 100644
index 0000000..f0067da
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/KeyAgreement/SameDHKeyStressTest.java
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 1999, 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.
+ *
+ * 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 8048819
+ * @summary This test stressful verifies the assertion of "The secret keys generated
+ * by all involved parties should be the same." for javax.crypto.KeyAgreement
+ * @run main SameDHKeyStressTest
+ */
+import java.security.AlgorithmParameterGenerator;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.spec.AlgorithmParameterSpec;
+import java.util.Arrays;
+import javax.crypto.KeyAgreement;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.DHGenParameterSpec;
+import javax.crypto.spec.DHParameterSpec;
+
+public class SameDHKeyStressTest {
+
+    static final String[] ALGORITHMS = {"DH", "DiffieHellman", "dh", "diffieHELLMAN"};
+    static final String[] SECRET_ALOGRITHMS = {"DES", "DESede", "blowfish"};
+    static final int[] NUMBER_OF_PARTIES = {2, 3, 4};
+    static final String[] PA_NAMES = {"Alice", "Bob", "Carol", "David"};
+
+    public static void main(String args[]) {
+        int failedCnt = 0;
+        StringBuilder failedList = new StringBuilder("Failed List:");
+
+        for (String algorithm : ALGORITHMS) {
+            for (int numOfParties : NUMBER_OF_PARTIES) {
+                for (String secretAlgorithm : SECRET_ALOGRITHMS) {
+                    if (!runTest(algorithm, numOfParties, secretAlgorithm)) {
+                        failedCnt++;
+                        failedList.append("\n Altorightm = ").append(algorithm).
+                                append(" Number of Parties = ").append(numOfParties).
+                                append(" Secret Algorithm = ").append(secretAlgorithm);
+                    }
+                }
+            }
+        } //end of for loop
+
+        if (failedCnt > 0) {
+            System.out.println(failedList);
+            throw new RuntimeException("SameDHKeyStressTest Failed");
+        }
+    }
+
+    public static boolean runTest(String algo, int numParties, String secretAlgo) {
+        KAParticipant[] parties = new KAParticipant[numParties];
+        Key[] keyArchives = new Key[numParties];
+        try {
+            // generate AlogirhtmParameterSpec
+            AlgorithmParameterGenerator apg = AlgorithmParameterGenerator.getInstance("DH","SunJCE");
+            AlgorithmParameterSpec aps = new DHGenParameterSpec(512, 64);
+            apg.init(aps);
+            DHParameterSpec spec = apg.generateParameters().
+                    getParameterSpec(DHParameterSpec.class);
+
+            //initilize all KeyAgreement participants
+            for (int i = 0; i < numParties; i++) {
+                parties[i] = new KAParticipant(PA_NAMES[i], algo);
+                parties[i].initialize(spec);
+                keyArchives[i] = parties[i].getPublicKey();
+            }
+
+            // Do all phases in the KeyAgreement for all participants
+            Key[] keyBuffer = new Key[numParties];
+            boolean lastPhase = false;
+            for (int j = 0; j < numParties - 1; j++) {
+                if (j == numParties - 2) {
+                    lastPhase = true;
+                }
+                for (int k = 0; k < numParties; k++) {
+                    if (k == numParties - 1) {
+                        keyBuffer[k] = parties[k].doPhase(keyArchives[0], lastPhase);
+                    } else {
+                        keyBuffer[k] = parties[k].doPhase(keyArchives[k + 1], lastPhase);
+                    }
+                }
+                System.arraycopy(keyBuffer, 0, keyArchives, 0, numParties);
+            }
+
+            //Comparison: The secret keys generated by all involved parties should be the same
+            SecretKey[] sKeys = new SecretKey[numParties];
+            for (int n = 0; n < numParties; n++) {
+                sKeys[n] = parties[n].generateSecret(secretAlgo);
+            }
+            for (int q = 0; q < numParties - 1; q++) {
+                if (!Arrays.equals(sKeys[q].getEncoded(), sKeys[q + 1].getEncoded())) {
+                    return false;
+                }
+            }
+            return true;
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            return false;
+        }
+
+    }
+
+}
+
+class KAParticipant {
+
+    private String name = null;
+    private String algorithm = null;
+    private KeyPairGenerator keyGen = null;
+    private KeyPair keys = null;
+    private KeyAgreement ka = null;
+
+    public KAParticipant(String pName, String algo) throws NoSuchAlgorithmException, NoSuchProviderException {
+        name = pName;
+        algorithm = algo;
+        keyGen = KeyPairGenerator.getInstance(algo,"SunJCE");
+        ka = KeyAgreement.getInstance(algo,"SunJCE");
+    }
+
+    public void initialize(AlgorithmParameterSpec spec) throws InvalidAlgorithmParameterException, InvalidKeyException {
+        keyGen.initialize(spec);
+        keys = keyGen.generateKeyPair();
+        ka.init(keys.getPrivate());
+    }
+
+    public Key doPhase(Key key, boolean lastPhase) throws InvalidKeyException {
+        return ka.doPhase(key, lastPhase);
+    }
+
+    public Key getPublicKey() {
+        return keys.getPublic();
+    }
+
+    public byte[] generateSecret() {
+        return ka.generateSecret();
+    }
+
+    public SecretKey generateSecret(String algo) throws java.lang.IllegalStateException,
+            java.security.NoSuchAlgorithmException,
+            java.security.InvalidKeyException {
+        return ka.generateSecret(algo);
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/Mac/EmptyByteBufferTest.java b/jdk/test/com/sun/crypto/provider/Mac/EmptyByteBufferTest.java
new file mode 100644
index 0000000..9b1dd1c
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Mac/EmptyByteBufferTest.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 1998, 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.
+ *
+ * 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.nio.ByteBuffer;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import javax.crypto.Mac;
+import javax.crypto.SecretKey;
+
+/**
+ * @test
+ * @bug 8048603
+ * @summary Checks if MAC algorithms work fine with empty buffer
+ * @author Alexander Fomin
+ * @build Utils
+ * @run main EmptyByteBufferTest
+ */
+public class EmptyByteBufferTest implements MacTest {
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String[] args) {
+        Utils.runTests(new EmptyByteBufferTest());
+    }
+
+    @Override
+    public void doTest(String alg) throws NoSuchAlgorithmException,
+            InvalidKeyException, NoSuchProviderException {
+        SecretKey key = Utils.getSecretKeySpec();
+
+        // instantiate Mac object and init it with a SecretKey
+        Mac mac = Mac.getInstance(alg, "SunJCE");
+        mac.init(key);
+
+        // prepare buffer
+        byte[] data = new byte[0];
+        ByteBuffer buf = ByteBuffer.wrap(data);
+
+        mac.update(buf);
+        mac.doFinal();
+    }
+
+}
diff --git a/jdk/test/com/sun/crypto/provider/Mac/LargeByteBufferTest.java b/jdk/test/com/sun/crypto/provider/Mac/LargeByteBufferTest.java
new file mode 100644
index 0000000..f294b67
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Mac/LargeByteBufferTest.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 1998, 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.
+ *
+ * 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.nio.ByteBuffer;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import javax.crypto.Mac;
+import javax.crypto.SecretKey;
+
+/**
+ * @test
+ * @bug 8048603
+ * @summary Checks if PBE algorithms work fine with large buffer
+ * @author Alexander Fomin
+ * @build Utils
+ * @run main LargeByteBufferTest
+ */
+public class LargeByteBufferTest implements MacTest {
+
+    private static final int BUFFER_SIZE = 65535;
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String[] args) {
+        Utils.runTests(new LargeByteBufferTest());
+    }
+
+    @Override
+    public void doTest(String alg) throws NoSuchAlgorithmException,
+            InvalidKeyException, NoSuchProviderException {
+        SecretKey key = Utils.getSecretKeySpec();
+
+        // instantiate Mac object and init it with a SecretKey
+        Mac mac = Mac.getInstance(alg, "SunJCE");
+        mac.init(key);
+
+        // prepare buffer
+        byte[] data = new byte[BUFFER_SIZE];
+        for (int i = 0; i < BUFFER_SIZE; i++) {
+            data[i] = (byte) (i % 256);
+        }
+
+        ByteBuffer buf = ByteBuffer.wrap(data);
+        int limitBefore = buf.limit();
+
+        mac.update(buf);
+        mac.doFinal();
+
+        int limitAfter = buf.limit();
+        int positonAfter = buf.position();
+
+        if (limitAfter != limitBefore) {
+            System.out.println("limit after = " + limitAfter);
+            System.out.println("limit before = " + limitBefore);
+            throw new RuntimeException("Test failed: "
+                    + "limit of buffer has been chenged.");
+        }
+
+        if (positonAfter != limitAfter) {
+            System.out.println("position after = " + positonAfter);
+            System.out.println("limit after = " + limitAfter);
+            throw new RuntimeException("Test failed: "
+                    + "position of buffer isn't equal to its limit");
+        }
+    }
+
+}
diff --git a/jdk/test/com/sun/crypto/provider/Mac/MacSameTest.java b/jdk/test/com/sun/crypto/provider/Mac/MacSameTest.java
new file mode 100644
index 0000000..8d97f1a
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Mac/MacSameTest.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 1998, 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.
+ *
+ * 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.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.SecureRandom;
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+
+/**
+ * @test
+ * @bug 8048603
+ * @summary Check if doFinal and update operation result in same Mac
+ * @author Yu-Ching Valerie Peng, Bill Situ, Alexander Fomin
+ * @build Utils
+ * @run main MacSameTest
+ */
+public class MacSameTest implements MacTest {
+
+    private static final int MESSAGE_SIZE = 25;
+    private static final int OFFSET = 5;
+    private static final int KEY_SIZE = 70;
+
+    /**
+     * Initialize a message, instantiate a Mac object,
+     * initialize the object with a SecretKey,
+     * feed the message into the Mac object
+     * all at once and get the output MAC as result1.
+     * Reset the Mac object, chop the message into three pieces,
+     * feed into the Mac object sequentially, and get the output MAC as result2.
+     * Finally, compare result1 and result2 and see if they are the same.
+     *
+     * @param args the command line arguments
+     */
+    public static void main(String[] args) {
+        Utils.runTests(new MacSameTest());
+    }
+
+    @Override
+    public void doTest(String algo) throws NoSuchAlgorithmException,
+            NoSuchProviderException, InvalidKeyException {
+        Mac mac;
+        try {
+            mac = Mac.getInstance(algo, "SunJCE");
+        } catch (NoSuchAlgorithmException nsae) {
+            // depending on Solaris configuration,
+            // it can support HMAC or not with Mac
+            System.out.println("Expected NoSuchAlgorithmException thrown: "
+                    + nsae);
+            return;
+        }
+
+        byte[] plain = new byte[MESSAGE_SIZE];
+        for (int i = 0; i < MESSAGE_SIZE; i++) {
+            plain[i] = (byte) (i % 256);
+        }
+
+        byte[] tail = new byte[plain.length - OFFSET];
+        System.arraycopy(plain, OFFSET, tail, 0, tail.length);
+
+        SecureRandom srdm = new SecureRandom();
+        byte[] keyVal = new byte[KEY_SIZE];
+        srdm.nextBytes(keyVal);
+        SecretKeySpec keySpec = new SecretKeySpec(keyVal, "HMAC");
+
+        mac.init(keySpec);
+        byte[] result1 = mac.doFinal(plain);
+
+        mac.reset();
+        mac.update(plain[0]);
+        mac.update(plain, 1, OFFSET - 1);
+        byte[] result2 = mac.doFinal(tail);
+
+        if (!java.util.Arrays.equals(result1, result2)) {
+            throw new RuntimeException("result1 and result2 are not the same");
+        }
+    }
+
+}
diff --git a/jdk/test/com/sun/crypto/provider/Mac/NullByteBufferTest.java b/jdk/test/com/sun/crypto/provider/Mac/NullByteBufferTest.java
new file mode 100644
index 0000000..d71d4f9
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Mac/NullByteBufferTest.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 1998, 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.
+ *
+ * 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.nio.ByteBuffer;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import javax.crypto.Mac;
+import javax.crypto.SecretKey;
+
+/**
+ * @test
+ * @bug 8048603
+ * @summary Checks if PBE algorithms work fine with null buffer
+ * @author Alexander Fomin
+ * @build Utils
+ * @run main NullByteBufferTest
+ */
+public class NullByteBufferTest implements MacTest {
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String[] args) {
+        Utils.runTests(new NullByteBufferTest());
+    }
+
+    @Override
+    public void doTest(String alg) throws NoSuchAlgorithmException,
+            InvalidKeyException, NoSuchProviderException {
+        SecretKey key = Utils.getSecretKeySpec();
+
+        // instantiate Mac object and init it with a SecretKey
+        Mac mac = Mac.getInstance(alg, "SunJCE");
+        mac.init(key);
+
+        try {
+            ByteBuffer buf = null;
+            mac.update(buf);
+            mac.doFinal();
+            throw new RuntimeException(
+                    "Expected IllegalArgumentException not thrown");
+        } catch (IllegalArgumentException e) {
+            System.out.println("Expected IllegalArgumentException thrown: "
+                    + e);
+        }
+    }
+
+}
diff --git a/jdk/test/com/sun/crypto/provider/Mac/Utils.java b/jdk/test/com/sun/crypto/provider/Mac/Utils.java
new file mode 100644
index 0000000..389d40b
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/Mac/Utils.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 1998, 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.
+ *
+ * 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.security.SecureRandom;
+import javax.crypto.spec.SecretKeySpec;
+
+/**
+ * Helper class.
+ */
+class Utils {
+
+    static final int KEY_SIZE = 70;
+
+    static final String[] MAC_ALGOS = {"HmacMD5", "HmacSHA1", "HmacSHA224",
+        "HmacSHA256", "HmacSHA384", "HmacSHA512"};
+
+    /**
+     * Get SecretKeySpec.
+     */
+    static SecretKeySpec getSecretKeySpec() {
+        SecureRandom srdm = new SecureRandom();
+        byte[] keyVal = new byte[KEY_SIZE];
+        srdm.nextBytes(keyVal);
+        return new SecretKeySpec(keyVal, "HMAC");
+    }
+
+    static void runTests(MacTest... tests) {
+        boolean success = true;
+        for (MacTest test : tests) {
+            success &= runTest(test);
+        }
+
+        if (success) {
+            System.out.println("Test passed");
+        } else {
+            throw new RuntimeException("Test failed");
+        }
+    }
+
+    private static boolean runTest(MacTest test) {
+        boolean success = true;
+        for (String alg : MAC_ALGOS) {
+            try {
+                System.out.println("Test " + alg);
+                test.doTest(alg);
+            } catch (Exception e) {
+                System.out.println("Unexpected exception:");
+                e.printStackTrace();
+                success = false;
+            }
+        }
+
+        return success;
+    }
+}
+
+interface MacTest {
+    void doTest(String alg) throws Exception;
+}
\ No newline at end of file
diff --git a/jdk/test/com/sun/crypto/provider/NSASuiteB/TestAESOids.java b/jdk/test/com/sun/crypto/provider/NSASuiteB/TestAESOids.java
new file mode 100644
index 0000000..062c34c
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/NSASuiteB/TestAESOids.java
@@ -0,0 +1,194 @@
+/*
+ * 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.
+ */
+
+import static javax.crypto.Cipher.ENCRYPT_MODE;
+import static javax.crypto.Cipher.getMaxAllowedKeyLength;
+
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.spec.AlgorithmParameterSpec;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.crypto.BadPaddingException;
+import javax.crypto.Cipher;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.KeyGenerator;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.SecretKey;
+import javax.crypto.ShortBufferException;
+import javax.crypto.spec.IvParameterSpec;
+
+/*
+ * @test
+ * @bug 8075286
+ * @summary Test the AES algorithm OIDs in JDK.
+ *          OID and Algorithm transformation string should match.
+ *          Both could be able to be used to generate the algorithm instance.
+ * @run main TestAESOids
+ */
+public class TestAESOids {
+
+    private static final String PROVIDER_NAME = "SunJCE";
+    private static final byte[] INPUT = "1234567890123456".getBytes();
+
+    private static final List<DataTuple> DATA = Arrays.asList(
+            new DataTuple("2.16.840.1.101.3.4.1.1", "AES_128/ECB/NoPadding",
+                    128, "ECB"),
+            new DataTuple("2.16.840.1.101.3.4.1.2", "AES_128/CBC/NoPadding",
+                    128, "CBC"),
+            new DataTuple("2.16.840.1.101.3.4.1.3", "AES_128/OFB/NoPadding",
+                    128, "OFB"),
+            new DataTuple("2.16.840.1.101.3.4.1.4", "AES_128/CFB/NoPadding",
+                    128, "CFB"),
+            new DataTuple("2.16.840.1.101.3.4.1.21", "AES_192/ECB/NoPadding",
+                    192, "ECB"),
+            new DataTuple("2.16.840.1.101.3.4.1.22", "AES_192/CBC/NoPadding",
+                    192, "CBC"),
+            new DataTuple("2.16.840.1.101.3.4.1.23", "AES_192/OFB/NoPadding",
+                    192, "OFB"),
+            new DataTuple("2.16.840.1.101.3.4.1.24", "AES_192/CFB/NoPadding",
+                    192, "CFB"),
+            new DataTuple("2.16.840.1.101.3.4.1.41", "AES_256/ECB/NoPadding",
+                    256, "ECB"),
+            new DataTuple("2.16.840.1.101.3.4.1.42", "AES_256/CBC/NoPadding",
+                    256, "CBC"),
+            new DataTuple("2.16.840.1.101.3.4.1.43", "AES_256/OFB/NoPadding",
+                    256, "OFB"),
+            new DataTuple("2.16.840.1.101.3.4.1.44", "AES_256/CFB/NoPadding",
+                    256, "CFB"));
+
+    public static void main(String[] args) throws Exception {
+        for (DataTuple dataTuple : DATA) {
+            int maxAllowedKeyLength =
+                    getMaxAllowedKeyLength(dataTuple.algorithm);
+            boolean supportedKeyLength =
+                    maxAllowedKeyLength >= dataTuple.keyLength;
+
+            try {
+                runTest(dataTuple, supportedKeyLength);
+                System.out.println("passed");
+            } catch (InvalidKeyException ike) {
+                if (supportedKeyLength) {
+                    throw new RuntimeException(String.format(
+                            "The key length %d is supported, but test failed.",
+                            dataTuple.keyLength), ike);
+                } else {
+                    System.out.printf(
+                            "Catch expected InvalidKeyException due "
+                                    + "to the key length %d is greater than "
+                                    + "max supported key length %d%n",
+                            dataTuple.keyLength, maxAllowedKeyLength);
+                }
+            }
+        }
+    }
+
+    private static void runTest(DataTuple dataTuple,
+            boolean supportedKeyLength) throws NoSuchAlgorithmException,
+            NoSuchProviderException, NoSuchPaddingException,
+            InvalidKeyException, ShortBufferException,
+            IllegalBlockSizeException, BadPaddingException,
+            InvalidAlgorithmParameterException {
+        Cipher algorithmCipher = Cipher.getInstance(dataTuple.algorithm,
+                PROVIDER_NAME);
+        Cipher oidCipher = Cipher.getInstance(dataTuple.oid, PROVIDER_NAME);
+
+        if (algorithmCipher == null) {
+            throw new RuntimeException(
+                    String.format("Test failed: algorithm string %s getInstance"
+                            + " failed.%n", dataTuple.algorithm));
+        }
+
+        if (oidCipher == null) {
+            throw new RuntimeException(
+                    String.format("Test failed: OID %s getInstance failed.%n",
+                            dataTuple.oid));
+        }
+
+        if (!algorithmCipher.getAlgorithm().equals(dataTuple.algorithm)) {
+            throw new RuntimeException(String.format(
+                    "Test failed: algorithm string %s getInstance "
+                            + "doesn't generate expected algorithm.%n",
+                    dataTuple.algorithm));
+        }
+
+        KeyGenerator kg = KeyGenerator.getInstance("AES");
+        kg.init(dataTuple.keyLength);
+        SecretKey key = kg.generateKey();
+
+        // encrypt
+        algorithmCipher.init(ENCRYPT_MODE, key);
+        if (!supportedKeyLength) {
+            throw new RuntimeException(String.format(
+                    "The key length %d is not supported, so the initialization "
+                            + "of algorithmCipher should fail.%n",
+                    dataTuple.keyLength));
+        }
+
+        byte[] cipherText = new byte[algorithmCipher.getOutputSize(INPUT.length)];
+        int offset = algorithmCipher.update(INPUT, 0, INPUT.length,
+                cipherText, 0);
+        algorithmCipher.doFinal(cipherText, offset);
+
+        AlgorithmParameterSpec aps = null;
+        if (!dataTuple.mode.equalsIgnoreCase("ECB")) {
+            aps = new IvParameterSpec(algorithmCipher.getIV());
+        }
+
+        oidCipher.init(Cipher.DECRYPT_MODE, key, aps);
+        if (!supportedKeyLength) {
+            throw new RuntimeException(String.format(
+                    "The key length %d is not supported, so the "
+                            + "initialization of oidCipher should fail.%n",
+                    dataTuple.keyLength));
+        }
+
+        byte[] recoveredText = new byte[oidCipher.getOutputSize(cipherText.length)];
+        oidCipher.doFinal(cipherText, 0, cipherText.length, recoveredText);
+
+        // Comparison
+        if (!Arrays.equals(INPUT, recoveredText)) {
+            throw new RuntimeException(
+                    "Decrypted data is not the same as the original text");
+        }
+    }
+
+    private static class DataTuple {
+
+        private final String oid;
+        private final String algorithm;
+        private final int keyLength;
+        private final String mode;
+
+        private DataTuple(String oid, String algorithm, int keyLength,
+                String mode) {
+            this.oid = oid;
+            this.algorithm = algorithm;
+            this.keyLength = keyLength;
+            this.mode = mode;
+        }
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/NSASuiteB/TestAESWrapOids.java b/jdk/test/com/sun/crypto/provider/NSASuiteB/TestAESWrapOids.java
new file mode 100644
index 0000000..2db96a5
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/NSASuiteB/TestAESWrapOids.java
@@ -0,0 +1,154 @@
+/*
+ * 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.
+ */
+
+import static javax.crypto.Cipher.getMaxAllowedKeyLength;
+
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.crypto.Cipher;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.KeyGenerator;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.SecretKey;
+
+/*
+ * @test
+ * @bug 8075286
+ * @summary Test the AESWrap algorithm OIDs in JDK.
+ *          OID and Algorithm transformation string should match.
+ *          Both could be able to be used to generate the algorithm instance.
+ * @run main TestAESWrapOids
+ */
+public class TestAESWrapOids {
+
+    private static final String PROVIDER_NAME = "SunJCE";
+
+    private static final List<DataTuple> DATA = Arrays.asList(
+            new DataTuple("2.16.840.1.101.3.4.1.5", "AESWrap_128", 128),
+            new DataTuple("2.16.840.1.101.3.4.1.25", "AESWrap_192", 192),
+            new DataTuple("2.16.840.1.101.3.4.1.45", "AESWrap_256", 256));
+
+    public static void main(String[] args) throws Exception {
+        for (DataTuple dataTuple : DATA) {
+            int maxAllowedKeyLength = getMaxAllowedKeyLength(
+                    dataTuple.algorithm);
+            boolean supportedKeyLength =
+                    maxAllowedKeyLength >= dataTuple.keyLength;
+
+            try {
+                runTest(dataTuple, supportedKeyLength);
+                System.out.println("passed");
+            } catch (InvalidKeyException ike) {
+                if (supportedKeyLength) {
+                    throw new RuntimeException(String.format(
+                            "The key length %d is supported, but test failed.",
+                            dataTuple.keyLength), ike);
+                } else {
+                    System.out.printf(
+                            "Catch expected InvalidKeyException "
+                                    + "due to the key length %d is greater "
+                                    + "than max supported key length %d%n",
+                            dataTuple.keyLength, maxAllowedKeyLength);
+                }
+            }
+        }
+    }
+
+    private static void runTest(DataTuple dataTuple, boolean supportedKeyLength)
+            throws NoSuchAlgorithmException, NoSuchProviderException,
+            NoSuchPaddingException, InvalidKeyException,
+            IllegalBlockSizeException {
+        Cipher algorithmCipher = Cipher.getInstance(
+                dataTuple.algorithm, PROVIDER_NAME);
+        Cipher oidCipher = Cipher.getInstance(dataTuple.oid, PROVIDER_NAME);
+
+        if (algorithmCipher == null) {
+            throw new RuntimeException(String.format(
+                    "Test failed: algorithm string %s getInstance failed.%n",
+                    dataTuple.algorithm));
+        }
+
+        if (oidCipher == null) {
+            throw new RuntimeException(
+                    String.format("Test failed: OID %s getInstance failed.%n",
+                            dataTuple.oid));
+        }
+
+        if (!algorithmCipher.getAlgorithm().equals(
+                dataTuple.algorithm)) {
+            throw new RuntimeException(String.format(
+                    "Test failed: algorithm string %s getInstance "
+                            + "doesn't generate expected algorithm.%n",
+                    dataTuple.oid));
+        }
+
+        KeyGenerator kg = KeyGenerator.getInstance("AES");
+        kg.init(dataTuple.keyLength);
+        SecretKey key = kg.generateKey();
+
+        // Wrap the key
+        algorithmCipher.init(Cipher.WRAP_MODE, key);
+        if (!supportedKeyLength) {
+            throw new RuntimeException(String.format(
+                    "The key length %d is not supported, so the initialization"
+                            + " of algorithmCipher should fail.%n",
+                    dataTuple.keyLength));
+        }
+
+        // Unwrap the key
+        oidCipher.init(Cipher.UNWRAP_MODE, key);
+        if (!supportedKeyLength) {
+            throw new RuntimeException(String.format(
+                    "The key length %d is not supported, so the initialization"
+                            + " of oidCipher should fail.%n",
+                    dataTuple.keyLength));
+        }
+
+        byte[] keyWrapper = algorithmCipher.wrap(key);
+        Key unwrappedKey = oidCipher.unwrap(keyWrapper, "AES",
+                Cipher.SECRET_KEY);
+
+        // Comparison
+        if (!Arrays.equals(key.getEncoded(), unwrappedKey.getEncoded())) {
+            throw new RuntimeException("Key comparison failed");
+        }
+    }
+
+    private static class DataTuple {
+
+        private final String oid;
+        private final String algorithm;
+        private final int keyLength;
+
+        private DataTuple(String oid, String algorithm, int keyLength) {
+            this.oid = oid;
+            this.algorithm = algorithm;
+            this.keyLength = keyLength;
+        }
+    }
+}
diff --git a/jdk/test/com/sun/crypto/provider/NSASuiteB/TestHmacSHAOids.java b/jdk/test/com/sun/crypto/provider/NSASuiteB/TestHmacSHAOids.java
new file mode 100644
index 0000000..15110d7
--- /dev/null
+++ b/jdk/test/com/sun/crypto/provider/NSASuiteB/TestHmacSHAOids.java
@@ -0,0 +1,116 @@
+/*
+ * 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.
+ */
+
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.crypto.KeyGenerator;
+import javax.crypto.Mac;
+import javax.crypto.SecretKey;
+
+/*
+ * @test
+ * @bug 8075286
+ * @summary Test the HmacSHA algorithm OIDs in JDK.
+ *          OID and Algorithm transformation string should match.
+ *          Both could be able to be used to generate the algorithm instance.
+ * @run main TestHmacSHAOids
+ */
+public class TestHmacSHAOids {
+
+    private static final String PROVIDER_NAME = "SunJCE";
+    private static final byte[] INPUT = "1234567890".getBytes();
+
+    private static final List<DataTuple> DATA = Arrays.asList(
+            new DataTuple("1.2.840.113549.2.7", "HmacSHA1"),
+            new DataTuple("1.2.840.113549.2.8", "HmacSHA224"),
+            new DataTuple("1.2.840.113549.2.9", "HmacSHA256"),
+            new DataTuple("1.2.840.113549.2.10", "HmacSHA384"),
+            new DataTuple("1.2.840.113549.2.11", "HmacSHA512"));
+
+    public static void main(String[] args) throws Exception {
+        for (DataTuple dataTuple : DATA) {
+            runTest(dataTuple);
+            System.out.println("passed");
+        }
+        System.out.println("All tests passed");
+    }
+
+    private static void runTest(DataTuple dataTuple)
+            throws NoSuchAlgorithmException, NoSuchProviderException,
+            InvalidKeyException {
+        Mac mcAlgorithm = Mac.getInstance(dataTuple.algorithm,
+                PROVIDER_NAME);
+        Mac mcOid = Mac.getInstance(dataTuple.oid, PROVIDER_NAME);
+
+        if (mcAlgorithm == null) {
+            throw new RuntimeException(String.format(
+                    "Test failed: Mac using algorithm "
+                            + "string %s getInstance failed.%n",
+                    dataTuple.algorithm));
+        }
+
+        if (mcOid == null) {
+            throw new RuntimeException(String.format(
+                    "Test failed: Mac using OID %s getInstance failed.%n",
+                    dataTuple.oid));
+        }
+
+        if (!mcAlgorithm.getAlgorithm().equals(dataTuple.algorithm)) {
+            throw new RuntimeException(String.format(
+                    "Test failed: Mac using algorithm string %s getInstance "
+                            + "doesn't generate expected algorithm.%n",
+                    dataTuple.algorithm));
+        }
+
+        KeyGenerator kg = KeyGenerator.getInstance(dataTuple.algorithm,
+                PROVIDER_NAME);
+        SecretKey key = kg.generateKey();
+
+        mcAlgorithm.init(key);
+        mcAlgorithm.update(INPUT);
+
+        mcOid.init(key);
+        mcOid.update(INPUT);
+
+        // Comparison
+        if (!Arrays.equals(mcAlgorithm.doFinal(), mcOid.doFinal())) {
+            throw new RuntimeException("Digest comparison failed: "
+                    + "the two MACs are not the same");
+        }
+    }
+
+    private static class DataTuple {
+
+        private final String oid;
+        private final String algorithm;
+
+        private DataTuple(String oid, String algorithm) {
+            this.oid = oid;
+            this.algorithm = algorithm;
+        }
+    }
+}
diff --git a/jdk/test/com/sun/jdi/RedefineAddPrivateMethod.sh b/jdk/test/com/sun/jdi/RedefineAddPrivateMethod.sh
new file mode 100644
index 0000000..d91f74a
--- /dev/null
+++ b/jdk/test/com/sun/jdi/RedefineAddPrivateMethod.sh
@@ -0,0 +1,79 @@
+#!/bin/sh
+
+#
+# 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 8149743
+#  @summary crash when adding a breakpoint after redefining to add a private static method
+#  @run shell RedefineAddPrivateMethod.sh
+
+compileOptions=-g
+
+createJavaFile()
+{
+    cat <<EOF > $1.java.1
+public class $1 {
+    static public void main(String[] args) {
+        System.out.println("@1 breakpoint");
+        System.out.println("@2 breakpoint");
+    }
+
+    // @1 uncomment private static void test() {}
+}
+EOF
+}
+
+# This is called to feed cmds to jdb.
+dojdbCmds()
+{
+    setBkpts @1
+    runToBkpt @1
+    redefineClass @1
+    setBkpts @2
+    runToBkpt @2
+    cmd exitJdb
+}
+
+
+mysetup()
+{
+    if [ -z "$TESTSRC" ] ; then
+        TESTSRC=.
+    fi
+
+    for ii in . $TESTSRC $TESTSRC/.. ; do
+        if [ -r "$ii/ShellScaffold.sh" ] ; then
+            . $ii/ShellScaffold.sh 
+            break
+        fi
+    done
+}
+
+# You could replace this next line with the contents
+# of ShellScaffold.sh and this script will run just the same.
+mysetup
+
+runit
+debuggeeFailIfPresent "Internal exception:"
+pass
diff --git a/jdk/test/com/sun/tools/attach/RunnerUtil.java b/jdk/test/com/sun/tools/attach/RunnerUtil.java
index 3555a29..0fd2789 100644
--- a/jdk/test/com/sun/tools/attach/RunnerUtil.java
+++ b/jdk/test/com/sun/tools/attach/RunnerUtil.java
@@ -139,12 +139,19 @@
         String content = null;
 
         // Read file or wait for it to be created.
+        long startTime = System.currentTimeMillis();
+        long lastWarningTime = 0;
         while (true) {
             content = readFile(file);
             if (content != null && content.indexOf("done") >= 0) {
                 break;
             }
             Thread.sleep(100);
+            long elapsedTime = (System.currentTimeMillis() - startTime) / 1000;
+            if (elapsedTime > lastWarningTime) {
+                lastWarningTime = elapsedTime;
+                System.out.println("Waited " + elapsedTime + " seconds for file.");
+            }
         }
 
         ProcessInfo info = new ProcessInfo();
diff --git a/jdk/test/com/sun/tools/attach/TempDirTest.java b/jdk/test/com/sun/tools/attach/TempDirTest.java
index e60f9ce..520b6b6 100644
--- a/jdk/test/com/sun/tools/attach/TempDirTest.java
+++ b/jdk/test/com/sun/tools/attach/TempDirTest.java
@@ -39,13 +39,22 @@
  * @summary Test to make sure attach and jvmstat works correctly when java.io.tmpdir is set
  * @library /lib/testlibrary
  * @run build Application Shutdown RunnerUtil
- * @run main/timeout=10 TempDirTest
+ * @run main/timeout=200 TempDirTest
+ */
+
+/*
+ * This test runs with an extra long timeout since it takes a really long time with -Xcomp
+ * when starting many processes.cd /
  */
 
 public class TempDirTest {
 
+    private static long startTime;
+
     public static void main(String args[]) throws Throwable {
 
+        startTime = System.currentTimeMillis();
+
         Path clientTmpDir = Files.createTempDirectory("TempDirTest-client");
         clientTmpDir.toFile().deleteOnExit();
         Path targetTmpDir = Files.createTempDirectory("TempDirTest-target");
@@ -76,6 +85,9 @@
         System.out.print(" target: " + (targetTmpDir == null ? "no" : "yes"));
         System.out.println(" ###");
 
+        long elapsedTime = (System.currentTimeMillis() - startTime) / 1000;
+        System.out.println("Started after " + elapsedTime + "s");
+
         final String pidFile = "TempDirTest.Application.pid-" + counter++;
         ProcessThread processThread = null;
         RunnerUtil.ProcessInfo info = null;
@@ -95,6 +107,10 @@
             // Make sure the Application process is stopped.
             RunnerUtil.stopApplication(info.shutdownPort, processThread);
         }
+
+        elapsedTime = (System.currentTimeMillis() - startTime) / 1000;
+        System.out.println("Completed after " + elapsedTime + "s");
+
     }
 
     /**
diff --git a/jdk/test/java/awt/Paint/ComponentIsNotDrawnAfterRemoveAddTest/ComponentIsNotDrawnAfterRemoveAddTest.java b/jdk/test/java/awt/Paint/ComponentIsNotDrawnAfterRemoveAddTest/ComponentIsNotDrawnAfterRemoveAddTest.java
new file mode 100644
index 0000000..186b572
--- /dev/null
+++ b/jdk/test/java/awt/Paint/ComponentIsNotDrawnAfterRemoveAddTest/ComponentIsNotDrawnAfterRemoveAddTest.java
@@ -0,0 +1,187 @@
+/*
+ * 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 8139581
+   @summary AWT components are not drawn after removal and addition to a container
+   @author Anton Litvinov
+ */
+
+import java.awt.Button;
+import java.awt.Color;
+import java.awt.Canvas;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.Panel;
+import java.util.ArrayList;
+
+public class ComponentIsNotDrawnAfterRemoveAddTest {
+    private final Frame frame;
+    private final Panel panel;
+    private final ArrayList<Testable> compList = new ArrayList<Testable>();
+
+    public ComponentIsNotDrawnAfterRemoveAddTest() {
+        frame = new Frame("ComponentIsNotDrawnAfterRemoveAddTest");
+        frame.setSize(500, 500);
+        frame.setLocation(200, 200);
+        frame.setLayout(null);
+        frame.setBackground(Color.RED);
+
+        panel = new Panel();
+        panel.setLayout(null);
+        panel.setBounds(25, 100, 455, 295);
+        panel.setBackground(Color.GREEN);
+
+        for (int i = 0; i < 10; i++) {
+            TestCanvas canv1 = new TestCanvas();
+            canv1.setBounds(i * 45 + 5, 15, 30 + i, 30 + i);
+            panel.add(canv1);
+            compList.add(canv1);
+
+            TestButton btn1 = new TestButton();
+            btn1.setBounds(i * 45 + 5, 60, 30 + i, 30 + i);
+            panel.add(btn1);
+            compList.add(btn1);
+
+            TestCanvas canv2 = new TestCanvas();
+            canv2.setBounds(i * 45 + 5, 105, 30 + i, 30 + i);
+            panel.add(canv2);
+            compList.add(canv2);
+
+            TestButton btn2 = new TestButton();
+            btn2.setBounds(i * 45 + 5, 150, 30 + i, 30 + i);
+            panel.add(btn2);
+            compList.add(btn2);
+
+            TestCanvas canv3 = new TestCanvas();
+            canv3.setBounds(i * 45 + 5, 195, 30 + i, 30 + i);
+            panel.add(canv3);
+            compList.add(canv3);
+
+            TestButton btn3 = new TestButton();
+            btn3.setBounds(i * 45 + 5, 240, 30 + i, 30 + i);
+            panel.add(btn3);
+            compList.add(btn3);
+        }
+
+        frame.add(panel);
+        frame.setVisible(true);
+    }
+
+    private void runTest() {
+        try {
+            doSleep(1500);
+            checkTestableComponents();
+
+            for (int i = 0; i < 5; i++) {
+                System.err.println(String.format("Test iteration #%d:", i));
+
+                frame.remove(panel);
+                frame.invalidate();
+                frame.validate();
+                frame.add(panel);
+
+                doSleep(1500);
+                checkTestableComponents();
+            }
+        } finally {
+            frame.dispose();
+        }
+    }
+
+    private void doSleep(long millis) {
+        try {
+            Thread.sleep(millis);
+        } catch (InterruptedException ie) {
+            ie.printStackTrace();
+        }
+    }
+
+    private void checkTestableComponents() throws RuntimeException {
+        int notDrawnCompsCount = 0;
+        for (Testable comp : compList) {
+            if (!comp.wasPaintCalled()) {
+                notDrawnCompsCount++;
+            } else {
+                comp.resetPaintCalledFlag();
+            }
+        }
+        if (notDrawnCompsCount > 0) {
+            throw new RuntimeException(String.format(
+                "'paint' method of %d components was not called.", notDrawnCompsCount));
+        }
+    }
+
+    private interface Testable {
+        boolean wasPaintCalled();
+        void resetPaintCalledFlag();
+    }
+
+    private static class TestCanvas extends Canvas implements Testable {
+        private volatile boolean paintWasCalled = false;
+
+        @Override
+        public void paint(Graphics g) {
+            paintWasCalled = true;
+            super.paint(g);
+            g.setColor(Color.BLUE);
+            g.fillRect(0, 0, getWidth(), getHeight());
+        }
+
+        @Override
+        public boolean wasPaintCalled() {
+            return paintWasCalled;
+        }
+
+        @Override
+        public void resetPaintCalledFlag() {
+            paintWasCalled = false;
+        }
+    }
+
+    private static class TestButton extends Button implements Testable {
+        private volatile boolean paintWasCalled = false;
+
+        @Override
+        public void paint(Graphics g) {
+            paintWasCalled = true;
+            super.paint(g);
+            g.setColor(Color.YELLOW);
+            g.fillRect(0, 0, 15, 15);
+        }
+
+        @Override
+        public boolean wasPaintCalled() {
+            return paintWasCalled;
+        }
+
+        @Override
+        public void resetPaintCalledFlag() {
+            paintWasCalled = false;
+        }
+    }
+
+    public static void main(String[] args) {
+        new ComponentIsNotDrawnAfterRemoveAddTest().runTest();
+    }
+}
diff --git a/jdk/test/java/awt/font/MonospacedGlyphWidth/MonospacedGlyphWidthTest.java b/jdk/test/java/awt/font/MonospacedGlyphWidth/MonospacedGlyphWidthTest.java
new file mode 100644
index 0000000..82dd8ab
--- /dev/null
+++ b/jdk/test/java/awt/font/MonospacedGlyphWidth/MonospacedGlyphWidthTest.java
@@ -0,0 +1,54 @@
+/*
+ * 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 8073400
+ * @summary Some Monospaced logical fonts have a different width
+ * @author Dmitry Markov
+ * @run main MonospacedGlyphWidthTest
+ */
+import java.awt.*;
+import java.awt.font.FontRenderContext;
+
+public class MonospacedGlyphWidthTest {
+    private static final int START_INDEX = 0x2018;
+    private static final int END_INDEX = 0x201F;
+
+    public static void main(String[] args) {
+        Font font = new Font(Font.MONOSPACED, Font.PLAIN, 12);
+        double width = getCharWidth(font, 'a');
+
+        for (int i = START_INDEX; i <= END_INDEX; i++) {
+            if (width != getCharWidth(font, (char)i)) {
+                throw new RuntimeException("Test Failed: characters have different width!");
+            }
+        }
+        System.out.println("Test Passed!");
+    }
+
+    private static double getCharWidth(Font font, char c) {
+        FontRenderContext fontRenderContext = new FontRenderContext(null, false, false);
+        return font.getStringBounds(new char[] {c}, 0, 1, fontRenderContext).getWidth();
+    }
+}
+
diff --git a/jdk/test/java/lang/StringBuilder/Capacity.java b/jdk/test/java/lang/StringBuilder/Capacity.java
new file mode 100644
index 0000000..e23e915
--- /dev/null
+++ b/jdk/test/java/lang/StringBuilder/Capacity.java
@@ -0,0 +1,182 @@
+/*
+ * 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 8149330
+ * @summary Basic set of tests of capacity management
+ * @run testng Capacity
+ */
+
+import java.lang.reflect.Field;
+import java.util.AbstractList;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.SplittableRandom;
+
+import org.testng.annotations.Test;
+import org.testng.annotations.DataProvider;
+import static org.testng.Assert.*;
+
+public class Capacity {
+    static final int DEFAULT_CAPACITY = 16;
+
+    private static int newCapacity(int oldCapacity,
+            int desiredCapacity)
+    {
+        return Math.max(oldCapacity * 2 + 2, desiredCapacity);
+    }
+
+    private static int nextNewCapacity(int oldCapacity) {
+        return newCapacity(oldCapacity, oldCapacity + 1);
+    }
+
+    @Test(dataProvider = "singleChar")
+    public void defaultCapacity(Character ch) {
+        StringBuilder sb = new StringBuilder();
+        assertEquals(sb.capacity(), DEFAULT_CAPACITY);
+        for (int i = 0; i < DEFAULT_CAPACITY; i++) {
+            sb.append(ch);
+            assertEquals(sb.capacity(), DEFAULT_CAPACITY);
+        }
+        sb.append(ch);
+        assertEquals(sb.capacity(), nextNewCapacity(DEFAULT_CAPACITY));
+    }
+
+    @Test(dataProvider = "charCapacity")
+    public void explicitCapacity(Character ch, int initCapacity) {
+        StringBuilder sb = new StringBuilder(initCapacity);
+        assertEquals(sb.capacity(), initCapacity);
+        for (int i = 0; i < initCapacity; i++) {
+            sb.append(ch);
+            assertEquals(sb.capacity(), initCapacity);
+        }
+        sb.append(ch);
+        assertEquals(sb.capacity(), nextNewCapacity(initCapacity));
+    }
+
+    @Test(dataProvider = "singleChar")
+    public void sbFromString(Character ch) {
+        String s = "string " + ch;
+        int expectedCapacity = s.length() + DEFAULT_CAPACITY;
+        StringBuilder sb = new StringBuilder(s);
+        assertEquals(sb.capacity(), expectedCapacity);
+        for (int i = 0; i < DEFAULT_CAPACITY; i++) {
+            sb.append(ch);
+            assertEquals(sb.capacity(), expectedCapacity);
+        }
+        sb.append(ch);
+        assertEquals(sb.capacity(), nextNewCapacity(expectedCapacity));
+    }
+
+    @Test(dataProvider = "singleChar")
+    public void sbFromCharSeq(Character ch) {
+        CharSequence cs = new MyCharSeq("char seq " + ch);
+        int expectedCapacity = cs.length() + DEFAULT_CAPACITY;
+        StringBuilder sb = new StringBuilder(cs);
+        assertEquals(sb.capacity(), expectedCapacity);
+        for (int i = 0; i < DEFAULT_CAPACITY; i++) {
+            sb.append(ch);
+            assertEquals(sb.capacity(), expectedCapacity);
+        }
+        sb.append(ch);
+        assertEquals(sb.capacity(), nextNewCapacity(expectedCapacity));
+    }
+
+    @Test(dataProvider = "charCapacity")
+    public void ensureCapacity(Character ch, int cap) {
+        StringBuilder sb = new StringBuilder(0);
+        assertEquals(sb.capacity(), 0);
+        sb.ensureCapacity(cap); // only has effect if cap > 0
+        int newCap = (cap == 0) ? 0 : newCapacity(0, cap);
+        assertEquals(sb.capacity(), newCap);
+        sb.ensureCapacity(newCap + 1);
+        assertEquals(sb.capacity(), nextNewCapacity(newCap));
+        sb.append(ch);
+        assertEquals(sb.capacity(), nextNewCapacity(newCap));
+    }
+
+    @Test(dataProvider = "negativeCapacity",
+          expectedExceptions = NegativeArraySizeException.class)
+    public void negativeInitialCapacity(int negCap) {
+        StringBuilder sb = new StringBuilder(negCap);
+    }
+
+    @Test(dataProvider = "negativeCapacity")
+    public void ensureNegativeCapacity(int negCap) {
+        StringBuilder sb = new StringBuilder();
+        sb.ensureCapacity(negCap);
+        assertEquals(sb.capacity(), DEFAULT_CAPACITY);
+    }
+
+    @Test(dataProvider = "charCapacity")
+    public void trimToSize(Character ch, int cap) {
+        StringBuilder sb = new StringBuilder(cap);
+        int halfOfCap = cap / 2;
+        for (int i = 0; i < halfOfCap; i++) {
+            sb.append(ch);
+        }
+        sb.trimToSize();
+        // according to the spec, capacity doesn't have to
+        // become exactly the size
+        assertTrue(sb.capacity() >= halfOfCap);
+    }
+
+    @DataProvider
+    public Object[][] singleChar() {
+        return new Object[][] { {'J'}, {'\u042b'} };
+    }
+
+    @DataProvider
+    public Object[][] charCapacity() {
+        return new Object[][] {
+            {'J', 0},
+            {'J', 1},
+            {'J', 15},
+            {'J', DEFAULT_CAPACITY},
+            {'J', 1024},
+            {'\u042b', 0},
+            {'\u042b', 1},
+            {'\u042b', 15},
+            {'\u042b', DEFAULT_CAPACITY},
+            {'\u042b', 1024},
+        };
+    }
+
+    @DataProvider
+    public Object[][] negativeCapacity() {
+        return new Object[][] { {-1}, {Integer.MIN_VALUE} };
+    }
+
+    private static class MyCharSeq implements CharSequence {
+        private CharSequence s;
+        public MyCharSeq(CharSequence s) { this.s = s; }
+        public char charAt(int i) { return s.charAt(i); }
+        public int length() { return s.length(); }
+        public CharSequence subSequence(int st, int e) {
+            return s.subSequence(st, e);
+        }
+        public String toString() { return s.toString(); }
+    }
+}
diff --git a/jdk/test/java/lang/StringBuilder/HugeCapacity.java b/jdk/test/java/lang/StringBuilder/HugeCapacity.java
new file mode 100644
index 0000000..4140a02
--- /dev/null
+++ b/jdk/test/java/lang/StringBuilder/HugeCapacity.java
@@ -0,0 +1,66 @@
+/*
+ * 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 8149330
+ * @summary Capacity should not get close to Integer.MAX_VALUE unless
+ *          necessary
+ * @run main/othervm -Xmx10G HugeCapacity
+ * @ignore This test has huge memory requirements
+ */
+
+public class HugeCapacity {
+    private static int failures = 0;
+
+    public static void main(String[] args) {
+        testLatin1();
+        testUtf16();
+        if (failures > 0) {
+            throw new RuntimeException(failures + " tests failed");
+        }
+    }
+
+    private static void testLatin1() {
+        try {
+            StringBuilder sb = new StringBuilder();
+            sb.ensureCapacity(Integer.MAX_VALUE / 2);
+            sb.ensureCapacity(Integer.MAX_VALUE / 2 + 1);
+        } catch (OutOfMemoryError oom) {
+            oom.printStackTrace();
+            failures++;
+        }
+    }
+
+    private static void testUtf16() {
+        try {
+            StringBuilder sb = new StringBuilder();
+            sb.append('\u042b');
+            sb.ensureCapacity(Integer.MAX_VALUE / 4);
+            sb.ensureCapacity(Integer.MAX_VALUE / 4 + 1);
+        } catch (OutOfMemoryError oom) {
+            oom.printStackTrace();
+            failures++;
+        }
+    }
+}
diff --git a/jdk/test/java/lang/invoke/AccessControlTest.java b/jdk/test/java/lang/invoke/AccessControlTest.java
index 891710f..06da815 100644
--- a/jdk/test/java/lang/invoke/AccessControlTest.java
+++ b/jdk/test/java/lang/invoke/AccessControlTest.java
@@ -23,9 +23,7 @@
 
 /* @test
  * @summary test access checking by java.lang.invoke.MethodHandles.Lookup
- * @library ../../../..
- * @build test.java.lang.invoke.AccessControlTest
- * @build test.java.lang.invoke.AccessControlTest_subpkg.Acquaintance_remote
+ * @compile AccessControlTest.java AccessControlTest_subpkg/Acquaintance_remote.java
  * @run testng/othervm test.java.lang.invoke.AccessControlTest
  */
 
diff --git a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest2.sh b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest2.sh
index d05a759..b584c08 100644
--- a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest2.sh
+++ b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest2.sh
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 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
@@ -25,7 +25,7 @@
 # @test
 # @bug     4982128
 # @summary Test low memory detection of non-heap memory pool
-#
+# @requires vm.gc=="null"
 # @run build LowMemoryTest2 MemoryUtil
 # @run shell/timeout=600 LowMemoryTest2.sh
 #
diff --git a/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementConcMarkSweepGC.sh b/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementConcMarkSweepGC.sh
index 8db7814..a80f2c4 100644
--- a/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementConcMarkSweepGC.sh
+++ b/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementConcMarkSweepGC.sh
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2003, 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
@@ -26,7 +26,7 @@
 # @bug     4530538
 # @summary Run MemoryManagement test with concurrent mark sweep GC
 # @author  Mandy Chung
-#
+# @requires vm.gc=="ConcMarkSweep" | vm.gc=="null"
 # @run build MemoryManagement
 # @run shell/timeout=600 MemoryManagementConcMarkSweepGC.sh
 #
diff --git a/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementParallelGC.sh b/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementParallelGC.sh
index 0435302..f315c96 100644
--- a/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementParallelGC.sh
+++ b/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementParallelGC.sh
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2003, 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
@@ -26,7 +26,7 @@
 # @bug     4530538
 # @summary Run MemoryManagement test with parallel GC
 # @author  Mandy Chung
-#
+# @requires vm.gc=="Parallel" | vm.gc=="null"
 # @run build MemoryManagement
 # @run shell/timeout=600 MemoryManagementParallelGC.sh
 #
diff --git a/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementSerialGC.sh b/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementSerialGC.sh
index e7ea40a..0433230 100644
--- a/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementSerialGC.sh
+++ b/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementSerialGC.sh
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2003, 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
@@ -26,7 +26,7 @@
 # @bug     4530538
 # @summary Run MemoryManagement test with serial GC
 # @author  Mandy Chung
-#
+# @requires vm.gc=="Serial" | vm.gc=="null"
 # @run build MemoryManagement
 # @run shell/timeout=600 MemoryManagementSerialGC.sh
 #
diff --git a/jdk/test/java/lang/management/MemoryMXBean/MemoryTestAllGC.sh b/jdk/test/java/lang/management/MemoryMXBean/MemoryTestAllGC.sh
index be0827a..6dbbc16 100644
--- a/jdk/test/java/lang/management/MemoryMXBean/MemoryTestAllGC.sh
+++ b/jdk/test/java/lang/management/MemoryMXBean/MemoryTestAllGC.sh
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2003, 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
@@ -26,7 +26,7 @@
 # @bug     4530538
 # @summary 
 # @author  Mandy Chung
-#
+# @requires vm.gc=="Parallel" | vm.gc=="null"
 # @run compile MemoryTest.java
 # @run shell MemoryTestAllGC.sh
 #
@@ -52,7 +52,5 @@
 # Test MemoryTest with parallel scavenger collector
 runOne -XX:+UseParallelGC MemoryTest 2
 
-# Test MemoryTest with concurrent collector
-#runOne -XX:+UseConcMarkSweepGC MemoryTest 3
 
 exit 0
diff --git a/jdk/test/java/lang/management/MemoryMXBean/PendingAllGC.sh b/jdk/test/java/lang/management/MemoryMXBean/PendingAllGC.sh
index edf18b3..2a1ccc3 100644
--- a/jdk/test/java/lang/management/MemoryMXBean/PendingAllGC.sh
+++ b/jdk/test/java/lang/management/MemoryMXBean/PendingAllGC.sh
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2003, 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
@@ -26,7 +26,7 @@
 # @bug     4530538
 # @summary 
 # @author  Mandy Chung
-#
+# @requires vm.gc=="null"
 # @run compile Pending.java
 # @run shell PendingAllGC.sh
 #
diff --git a/jdk/test/java/lang/management/RuntimeMXBean/TestInputArgument.sh b/jdk/test/java/lang/management/RuntimeMXBean/TestInputArgument.sh
index 5c57e48..6c13541 100644
--- a/jdk/test/java/lang/management/RuntimeMXBean/TestInputArgument.sh
+++ b/jdk/test/java/lang/management/RuntimeMXBean/TestInputArgument.sh
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2003, 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
@@ -26,7 +26,6 @@
 # @bug     4530538
 # @summary 
 # @author  Mandy Chung
-#
 # @run compile InputArgument.java
 # @run shell TestInputArgument.sh
 #
@@ -48,8 +47,8 @@
 
 runOne InputArgument 
 
-runOne -XX:+UseParallelGC -XX:+PrintGCDetails InputArgument -XX:+PrintGCDetails
-runOne -XX:+UseParallelGC -XX:+PrintGCDetails InputArgument -XX:+UseParallelGC
+runOne -XX:+UseFastJNIAccessors -XX:+PrintGCDetails InputArgument -XX:+PrintGCDetails
+runOne -XX:+UseFastJNIAccessors -XX:+PrintGCDetails InputArgument -XX:+UseFastJNIAccessors
 runOne "-Dprops=one two three" InputArgument "-Dprops=one two three"
 
 exit 0
diff --git a/jdk/test/java/lang/management/ThreadMXBean/Locks.java b/jdk/test/java/lang/management/ThreadMXBean/Locks.java
index 9223364..1c8da46 100644
--- a/jdk/test/java/lang/management/ThreadMXBean/Locks.java
+++ b/jdk/test/java/lang/management/ThreadMXBean/Locks.java
@@ -170,6 +170,9 @@
     private static CheckerThread checker;
     static class WaitingThread extends Thread {
         private final Phaser p;
+
+        volatile boolean waiting = false;
+
         public WaitingThread(Phaser p) {
             super("WaitingThread");
             this.p = p;
@@ -180,7 +183,9 @@
                 log("WaitingThread about to wait on objC");
                 try {
                     // Signal checker thread, about to wait on objC.
+                    waiting = false;
                     p.arriveAndAwaitAdvance(); // Phase 1 (waiting)
+                    waiting = true;
                     objC.wait();
                 } catch (InterruptedException e) {
                     e.printStackTrace();
@@ -199,7 +204,9 @@
             synchronized(objC) {
                 try {
                     // signal checker thread, about to wait on objC
+                    waiting = false;
                     p.arriveAndAwaitAdvance(); // Phase 3 (waiting)
+                    waiting = true;
                     objC.wait();
                 } catch (InterruptedException e) {
                     e.printStackTrace();
@@ -208,25 +215,35 @@
             }
             log("WaitingThread about to exit waiting on objC 2");
         }
-    }
-    static class CheckerThread extends Thread {
-        private final Phaser p;
-        public CheckerThread(Phaser p) {
-            super("CheckerThread");
-            this.p = p;
+
+        public void waitForWaiting() {
+            p.arriveAndAwaitAdvance();
+            while (!waiting) {
+                goSleep(10);
+            }
+            waitForState(State.WAITING);
+        }
+
+        public void waitForBlocked() {
+            p.arriveAndAwaitAdvance();
+            waitForState(State.BLOCKED);
         }
 
         private void waitForState(Thread.State state) {
-            p.arriveAndAwaitAdvance();
             while (!waiter.isInterrupted() && waiter.getState() != state) {
-                goSleep(10);
+                Thread.yield();
             }
         }
+    }
+    static class CheckerThread extends Thread {
+        public CheckerThread() {
+            super("CheckerThread");
+        }
 
         public void run() {
             synchronized (ready) {
                 // wait until WaitingThread about to wait for objC
-                waitForState(Thread.State.WAITING); // Phase 1 (waiting)
+                waiter.waitForWaiting(); // Phase 1 (waiting)
                 checkBlockedObject(waiter, objC, null, Thread.State.WAITING);
 
                 synchronized (objC) {
@@ -235,13 +252,13 @@
 
                 // wait for waiter thread to about to enter
                 // synchronized object ready.
-                waitForState(Thread.State.BLOCKED); // Phase 2 (waiting)
+                waiter.waitForBlocked(); // Phase 2 (waiting)
                 checkBlockedObject(waiter, ready, this, Thread.State.BLOCKED);
             }
 
             // wait for signal from waiting thread that it is about
             // wait for objC.
-            waitForState(Thread.State.WAITING); // Phase 3 (waiting)
+            waiter.waitForWaiting(); // Phase 3 (waiting)
             synchronized(objC) {
                 checkBlockedObject(waiter, objC, Thread.currentThread(), Thread.State.WAITING);
                 objC.notify();
@@ -289,7 +306,7 @@
         waiter = new WaitingThread(p);
         waiter.start();
 
-        checker = new CheckerThread(p);
+        checker = new CheckerThread();
         checker.start();
 
         try {
diff --git a/jdk/test/java/lang/ref/EnqueuePollRace.java b/jdk/test/java/lang/ref/EnqueuePollRace.java
index c19a366..5171e13 100644
--- a/jdk/test/java/lang/ref/EnqueuePollRace.java
+++ b/jdk/test/java/lang/ref/EnqueuePollRace.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -25,7 +25,7 @@
  * @bug 8014890
  * @summary Verify that a race between ReferenceQueue.enqueue() and poll() does not occur.
  * @author thomas.schatzl@oracle.com
- * @run main/othervm -XX:+UseSerialGC -Xmx10M EnqueuePollRace
+ * @run main/othervm -Xmx10M EnqueuePollRace
  */
 
 import java.lang.ref.*;
diff --git a/jdk/test/java/net/InetAddress/B6246242.java b/jdk/test/java/net/InetAddress/B6246242.java
index 8ca8017..77e9628 100644
--- a/jdk/test/java/net/InetAddress/B6246242.java
+++ b/jdk/test/java/net/InetAddress/B6246242.java
@@ -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
@@ -23,7 +23,7 @@
 
 /**
  * @test
- * @bug 6246242
+ * @bug 6246242 8135259
  * @summary UnknownHostException contains wrong error message
  */
 
@@ -36,7 +36,7 @@
             a = InetAddress.getByName("foo.bar");
         } catch (UnknownHostException e) {
             String s = e.getMessage();
-            if (s.indexOf("foo.bar: foo.bar") >= 0)
+            if (s.contains("foo.bar: foo.bar") || s.contains("unknown error"))
                 throw new RuntimeException("UnknownHostException has wrong message: " + s);
         }
     }
diff --git a/jdk/test/java/net/SetFactoryPermission/SetFactoryPermission.java b/jdk/test/java/net/SetFactoryPermission/SetFactoryPermission.java
new file mode 100644
index 0000000..9477962
--- /dev/null
+++ b/jdk/test/java/net/SetFactoryPermission/SetFactoryPermission.java
@@ -0,0 +1,87 @@
+/*
+ * 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.
+ *
+ * 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 8048052
+ * @summary Test a series of methods which requires "setFactory" runtime permission
+ * @run main SetFactoryPermission success
+ * @run main/othervm/policy=policy.fail SetFactoryPermission fail
+ * @run main/othervm/policy=policy.success SetFactoryPermission success
+ */
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.URL;
+import java.net.URLConnection;
+import java.rmi.server.RMISocketFactory;
+import java.security.AccessControlException;
+
+public class SetFactoryPermission {
+    static boolean success = false;
+
+    interface Runner {
+        public void run() throws Exception;
+    }
+
+    public static void main (String[] args) throws Exception {
+        if (args.length > 0) {
+            success = System.getSecurityManager() == null || args[0].equals("success");
+        }
+
+        doTest(()->{
+            System.out.println("Verify URLConnection.setContentHandlerFactor()");
+            URLConnection.setContentHandlerFactory(null);
+        });
+        doTest(()->{
+            System.out.println("Verify URL.setURLStreamHandlerFactory()");
+            URL.setURLStreamHandlerFactory(null);
+        });
+        doTest(()->{
+            System.out.println("Verify ServerSocket.setSocketFactory()");
+            ServerSocket.setSocketFactory(null);
+        });
+        doTest(()->{
+            System.out.println("Verify Socket.setSocketImplFactory()");
+            Socket.setSocketImplFactory(null);
+        });
+        doTest(()->{
+            System.out.println("Verify RMISocketFactory.setSocketFactory()");
+            RMISocketFactory.setSocketFactory(null);
+        });
+    }
+
+    static void doTest(Runner func) throws Exception {
+        try {
+            func.run();
+            if (!success) {
+                throw new RuntimeException("AccessControlException is not thrown. Test failed");
+            }
+        } catch (SecurityException e) {
+            if (success) {
+                e.printStackTrace();
+                throw new RuntimeException("AccessControlException is thrown unexpectedly. Test failed");
+            }
+        }
+    }
+}
diff --git a/jdk/test/java/net/SetFactoryPermission/policy.fail b/jdk/test/java/net/SetFactoryPermission/policy.fail
new file mode 100644
index 0000000..a4c6d11
--- /dev/null
+++ b/jdk/test/java/net/SetFactoryPermission/policy.fail
@@ -0,0 +1,3 @@
+grant {
+	
+};
diff --git a/jdk/test/java/net/SetFactoryPermission/policy.success b/jdk/test/java/net/SetFactoryPermission/policy.success
new file mode 100644
index 0000000..d382afc
--- /dev/null
+++ b/jdk/test/java/net/SetFactoryPermission/policy.success
@@ -0,0 +1,4 @@
+grant {
+	permission java.lang.RuntimePermission "setFactory";
+};
+
diff --git a/jdk/test/java/net/SocketPermission/SocketPermissionTest.java b/jdk/test/java/net/SocketPermission/SocketPermissionTest.java
new file mode 100644
index 0000000..1552acc
--- /dev/null
+++ b/jdk/test/java/net/SocketPermission/SocketPermissionTest.java
@@ -0,0 +1,339 @@
+/*
+ * 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.
+ *
+ * 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 8047031
+ * @summary SocketPermission tests for legacy socket types
+ * @run testng/othervm SocketPermissionTest
+ */
+import java.io.IOException;
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+import java.net.InetAddress;
+import java.net.MulticastSocket;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketPermission;
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.CodeSource;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.security.Permissions;
+import java.security.Policy;
+import java.security.PrivilegedExceptionAction;
+import java.security.ProtectionDomain;
+
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+
+public class SocketPermissionTest {
+
+    @BeforeMethod
+    public void setupSecurityManager() throws Exception {
+        // All permissions, a specific ACC will be used to when testing
+        // with a reduced permission set.
+        Policy.setPolicy(new Policy() {
+             final PermissionCollection perms = new Permissions();
+             { perms.add(new java.security.AllPermission()); }
+             public PermissionCollection getPermissions(ProtectionDomain domain) {
+                 return perms;
+             }
+             public PermissionCollection getPermissions(CodeSource codesource) {
+                 return perms;
+             }
+             public boolean implies(ProtectionDomain domain, Permission perm) {
+                 return perms.implies(perm);
+             }
+        } );
+        System.setSecurityManager(new SecurityManager());
+    }
+
+    static final AccessControlContext RESTRICTED_ACC = getAccessControlContext();
+
+    @Test
+    public void connectSocketTest() throws Exception {
+        try (ServerSocket ss = new ServerSocket(0)) {
+            int port = ss.getLocalPort();
+
+            String addr = "localhost:" + port;
+            AccessControlContext acc = getAccessControlContext(
+                    new SocketPermission(addr, "listen,connect,resolve"));
+
+            // Positive
+            AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
+                try (Socket client = new Socket(InetAddress.getLocalHost(), port)) {
+                }
+                return null;
+            }, acc);
+
+            //Negative
+            try {
+                AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
+                    Socket client = new Socket(InetAddress.getLocalHost(), port);
+                    fail("Expected SecurityException");
+                    return null;
+                }, RESTRICTED_ACC);
+            } catch (SecurityException expected) { }
+        }
+    }
+
+    @Test
+    public void connectDatagramSocketTest() throws Exception {
+        byte[] msg = "Hello".getBytes(UTF_8);
+        InetAddress lh = InetAddress.getLocalHost();
+
+        try (DatagramSocket ds = new DatagramSocket(0)) {
+            int port = ds.getLocalPort();
+
+            String addr = lh.getHostAddress() + ":" + port;
+            AccessControlContext acc = getAccessControlContext(
+                    new SocketPermission(addr, "connect,resolve"));
+
+            // Positive
+            AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
+                DatagramPacket dp = new DatagramPacket(msg, msg.length, lh, port);
+                ds.send(dp);
+                return null;
+            }, acc);
+
+            // Negative
+            try {
+                AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
+                    DatagramPacket dp = new DatagramPacket(msg, msg.length, lh, port);
+                    ds.send(dp);
+                    fail("Expected SecurityException");
+                    return null;
+                }, RESTRICTED_ACC);
+            } catch (SecurityException expected) { }
+        }
+    }
+
+    @Test
+    public void acceptServerSocketTest() throws Exception {
+        try (ServerSocket ss = new ServerSocket(0)) {
+            int port = ss.getLocalPort();
+
+            String addr = "localhost:" + port;
+            AccessControlContext acc = getAccessControlContext(
+                    new SocketPermission(addr, "listen,connect,resolve"),
+                    new SocketPermission("localhost:1024-", "accept"));
+
+            // Positive
+            AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
+                InetAddress me = InetAddress.getLocalHost();
+                try (Socket client = new Socket(me, port)) {
+                    ss.accept();
+                }
+                return null;
+            }, acc);
+
+            // Negative
+            try {
+                AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
+                    InetAddress me = InetAddress.getLocalHost();
+                    try (Socket client = new Socket(me, port)) {
+                        ss.accept();
+                    }
+                    fail("Expected SecurityException");
+                    return null;
+                }, RESTRICTED_ACC);
+            } catch (SecurityException expected) { }
+        }
+    }
+
+    @Test
+    public void sendDatagramPacketTest() throws Exception {
+        byte[] msg = "Hello".getBytes(UTF_8);
+        InetAddress group = InetAddress.getByName("229.227.226.221");
+
+        try (DatagramSocket ds = new DatagramSocket(0)) {
+            int port = ds.getLocalPort();
+
+            String addr = "localhost:" + port;
+            //test for SocketPermission "229.227.226.221", "connect,accept"
+            AccessControlContext acc = getAccessControlContext(
+                    new SocketPermission(addr, "listen,resolve"),
+                    new SocketPermission("229.227.226.221", "connect,accept"));
+
+            // Positive
+            AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
+                DatagramPacket hi = new DatagramPacket(msg, msg.length, group, port);
+                ds.send(hi);
+                return null;
+            }, acc);
+
+            // Negative
+            try {
+                AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
+                    DatagramPacket hi = new DatagramPacket(msg, msg.length, group, port);
+                    ds.send(hi);
+                    fail("Expected SecurityException");
+                    return null;
+                }, RESTRICTED_ACC);
+            } catch (SecurityException expected) { }
+        }
+    }
+
+    @Test
+    public void joinGroupMulticastTest() throws Exception {
+        InetAddress group = InetAddress.getByName("229.227.226.221");
+        try (MulticastSocket s = new MulticastSocket(0)) {
+            int port = s.getLocalPort();
+
+            String addr = "localhost:" + port;
+            AccessControlContext acc = getAccessControlContext(
+                    new SocketPermission(addr, "listen,resolve"),
+                    new SocketPermission("229.227.226.221", "connect,accept"));
+
+            // Positive
+            AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
+                s.joinGroup(group);
+                s.leaveGroup(group);
+                return null;
+            }, acc);
+
+            // Negative
+            try {
+                AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
+                    s.joinGroup(group);
+                    s.leaveGroup(group);
+                    fail("Expected SecurityException");
+                    return null;
+                }, RESTRICTED_ACC);
+            } catch (SecurityException expected) { }
+        }
+
+    }
+
+    @Test
+    public void listenDatagramSocketTest() throws Exception {
+        // the hardcoded port number doesn't really matter since we expect the
+        // security permission to be checked before the underlying operation.
+        int port = 8899;
+        String addr = "localhost:" + port;
+        AccessControlContext acc = getAccessControlContext(
+                new SocketPermission(addr, "listen"));
+
+        // Positive
+        AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
+            try (DatagramSocket ds = new DatagramSocket(port)) { }
+            catch (IOException intermittentlyExpected) { /* ignore */ }
+            return null;
+        }, acc);
+
+        // Negative
+        try {
+            AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
+                try (DatagramSocket ds = new DatagramSocket(port)) { }
+                catch (IOException intermittentlyExpected) { /* ignore */ }
+                fail("Expected SecurityException");
+                return null;
+            }, RESTRICTED_ACC);
+        } catch (SecurityException expected) { }
+    }
+
+    @Test
+    public void listenMulticastSocketTest() throws Exception {
+        // the hardcoded port number doesn't really matter since we expect the
+        // security permission to be checked before the underlying operation.
+        int port = 8899;
+        String addr = "localhost:" + port;
+        AccessControlContext acc = getAccessControlContext(
+                new SocketPermission(addr, "listen"));
+
+        // Positive
+        AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
+            try (MulticastSocket ms = new MulticastSocket(port)) { }
+            catch (IOException intermittentlyExpected) { /* ignore */ }
+            return null;
+        }, acc);
+
+        // Negative
+        try {
+            AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
+                try (MulticastSocket ms = new MulticastSocket(port)) { }
+                catch (IOException intermittentlyExpected) { /* ignore */ }
+                fail("Expected SecurityException");
+                return null;
+            }, RESTRICTED_ACC);
+        } catch (SecurityException expected) { }
+    }
+
+    @Test
+    public void listenServerSocketTest() throws Exception {
+        // the hardcoded port number doesn't really matter since we expect the
+        // security permission to be checked before the underlying operation.
+        int port = 8899;
+        String addr = "localhost:" + port;
+        AccessControlContext acc = getAccessControlContext(
+                new SocketPermission(addr, "listen"));
+
+        // Positive
+        AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
+            try (ServerSocket ss = new ServerSocket(port)) { }
+            catch (IOException intermittentlyExpected) { /* ignore */ }
+            return null;
+        }, acc);
+
+        // Negative
+        try {
+            AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
+                try (ServerSocket ss = new ServerSocket(port)) { }
+                catch (IOException intermittentlyExpected) { /* ignore */ }
+                fail("Expected SecurityException");
+                return null;
+            }, RESTRICTED_ACC);
+        } catch (SecurityException expected) { }
+
+    }
+
+    private static AccessControlContext getAccessControlContext(Permission... ps) {
+        Permissions perms = new Permissions();
+        for (Permission p : ps) {
+            perms.add(p);
+        }
+        /*
+         *Create an AccessControlContext that consist a single protection domain
+         * with only the permissions calculated above
+         */
+        ProtectionDomain pd = new ProtectionDomain(null, perms);
+        return new AccessControlContext(new ProtectionDomain[]{pd});
+    }
+
+    // Standalone entry point for running with, possibly older, JDKs.
+    public static void main(String[] args) throws Throwable {
+        SocketPermissionTest test = new SocketPermissionTest();
+        test.setupSecurityManager();
+        for (java.lang.reflect.Method m : SocketPermissionTest.class.getDeclaredMethods()) {
+            if (m.getAnnotation(Test.class) != null) {
+                System.out.println("Invoking " + m.getName());
+                m.invoke(test);
+            }
+        }
+    }
+}
diff --git a/jdk/test/java/rmi/dgc/dgcAckFailure/DGCAckFailure.java b/jdk/test/java/rmi/dgc/dgcAckFailure/DGCAckFailure.java
index 82eeab0..bc1c2dc 100644
--- a/jdk/test/java/rmi/dgc/dgcAckFailure/DGCAckFailure.java
+++ b/jdk/test/java/rmi/dgc/dgcAckFailure/DGCAckFailure.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2012, 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
@@ -22,7 +22,7 @@
  */
 
 /* @test
- * @bug 4017232
+ * @bug 4017232 8046339
  * @summary If, after returning a reference to a remote object in the current
  * VM (which gets implicitly converted to a remote stub), the client fails to
  * both send a DGC dirty call and to send a "DGC acknowledgment", the RMI
@@ -36,10 +36,14 @@
 
 import java.io.*;
 import java.net.*;
+import java.lang.reflect.Field;
 import java.lang.ref.*;
 
 import java.rmi.*;
 import java.rmi.server.*;
+import java.util.Map;
+
+import sun.rmi.transport.DGCAckHandler;
 
 interface ReturnRemote extends Remote {
     Object returnRemote() throws RemoteException;
@@ -48,6 +52,7 @@
 public class DGCAckFailure implements ReturnRemote {
 
     private static final long TIMEOUT = 20000;
+    private static final long ACK_TIMEOUT = TIMEOUT / 2;
 
     public Object returnRemote() {
         return new Wrapper(this);
@@ -55,7 +60,8 @@
 
     public static void main(String[] args) throws Exception {
 
-        System.setProperty("sun.rmi.dgc.ackTimeout", "10000");
+        System.setProperty("sun.rmi.dgc.ackTimeout",
+                Long.toString(ACK_TIMEOUT));
 
         /*
          * Set a socket factory that has a hook for shutting down all client
@@ -93,12 +99,31 @@
                     break;
                 }
             }
-            if (ref == weakRef) {
-                System.err.println("TEST PASSED");
-            } else {
+            if (ref != weakRef) {
                 throw new RuntimeException("TEST FAILED: " +
                     "timed out, remote object not garbage collected");
             }
+
+            // 8046339
+            // All DGCAckHandlers must be properly released after timeout
+            Thread.sleep(ACK_TIMEOUT + 100);
+            try {
+                Field field =
+                        DGCAckHandler.class.getDeclaredField("idTable");
+                field.setAccessible(true);
+                Object obj = field.get(null);
+                Map<?,?> idTable = (Map<?,?>)obj;
+
+                if (!idTable.isEmpty()) {
+                    throw new RuntimeException("TEST FAILED: " +
+                            "DGCAckHandler.idTable isn't empty");
+                }
+            } catch (ReflectiveOperationException roe) {
+                throw new RuntimeException(roe);
+            }
+
+            System.err.println("TEST PASSED");
+
         } finally {
             try {
                 UnicastRemoteObject.unexportObject((Remote) weakRef.get(),
diff --git a/jdk/src/share/classes/sun/invoke/anon/InvalidConstantPoolFormatException.java b/jdk/test/java/security/AccessController/DoPrivAccomplice.java
similarity index 65%
rename from jdk/src/share/classes/sun/invoke/anon/InvalidConstantPoolFormatException.java
rename to jdk/test/java/security/AccessController/DoPrivAccomplice.java
index d420d34..6cc2846 100644
--- a/jdk/src/share/classes/sun/invoke/anon/InvalidConstantPoolFormatException.java
+++ b/jdk/test/java/security/AccessController/DoPrivAccomplice.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
@@ -23,23 +23,12 @@
  * questions.
  */
 
-package sun.invoke.anon;
+public class DoPrivAccomplice {
 
-/** Exception used when there is an error in the constant pool
- *  format.
- */
-public class InvalidConstantPoolFormatException extends Exception {
-    private static final long serialVersionUID=-6103888330523770949L;
-
-    public InvalidConstantPoolFormatException(String message,Throwable cause) {
-        super(message,cause);
-    }
-
-    public InvalidConstantPoolFormatException(String message) {
-        super(message);
-    }
-
-    public InvalidConstantPoolFormatException(Throwable cause) {
-        super(cause);
+    public String go() {
+        String name = (String)java.security.AccessController.
+                doPrivileged((java.security.PrivilegedAction)() ->
+                        System.getProperty("user.name"));
+        return name;
     }
 }
diff --git a/jdk/test/java/security/AccessController/DoPrivAccompliceTest.java b/jdk/test/java/security/AccessController/DoPrivAccompliceTest.java
new file mode 100644
index 0000000..d18038c
--- /dev/null
+++ b/jdk/test/java/security/AccessController/DoPrivAccompliceTest.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2007, 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.
+ */
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @test
+ * @bug 8048362
+ * @compile ../../../lib/testlibrary/JavaToolUtils.java
+ *                             DoPrivAccomplice.java DoPrivTest.java
+ * @summary Tests the doPrivileged with accomplice Generate two jars
+ * (DoPrivTest.jar and DoPrivAccomplice.jar) and grant permission to
+ * DoPrivAccmplice.jar for reading user.home property from a PrivilagedAction.
+ * Run DoPrivTest.jar and try to access user.home property using
+ * DoPrivAccmplice.jar.
+ * @run main/othervm DoPrivAccompliceTest
+ */
+
+public class DoPrivAccompliceTest {
+
+    private static final String PWD = System.getProperty("test.classes", "./");
+    private static final String ACTION_SOURCE = "DoPrivAccomplice";
+    private static final String TEST_SOURCE = "DoPrivTest";
+
+    public static void createPolicyFile(URI codebaseURL) throws IOException {
+        String codebase = codebaseURL.toString();
+        String quotes = "\"";
+        StringBuilder policyFile = new StringBuilder();
+        policyFile.append("grant codeBase ").append(quotes).
+                append(codebase).append(quotes).append("{\n").
+                append("permission java.util.PropertyPermission ").
+                append(quotes).append("user.name").append(quotes).
+                append(",").append(quotes).append("read").append(quotes).
+                append(";\n};");
+        try (FileWriter writer = new FileWriter(new File(PWD, "java.policy"))) {
+            writer.write(policyFile.toString());
+            writer.close();
+        } catch (IOException e) {
+            System.err.println("Error while creating policy file");
+            throw e;
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        final File class1 = new File(PWD, ACTION_SOURCE + ".class");
+        final File class2 = new File(PWD, TEST_SOURCE + ".class");
+        final File jarFile1 = new File(PWD, ACTION_SOURCE + ".jar");
+        final File jarFile2 = new File(PWD, TEST_SOURCE + ".jar");
+        System.out.println("Compilation successfull");
+        JavaToolUtils.createJar(jarFile1, Arrays.asList(new File[]{class1}));
+        System.out.println("Created jar file " + jarFile1);
+        JavaToolUtils.createJar(jarFile2, Arrays.asList(new File[]{class2}));
+        System.out.println("Created jar file " + jarFile2);
+        createPolicyFile(jarFile1.toURI());
+
+        List<String> commands = new ArrayList<>();
+        final String pathSepartor = System.getProperty("path.separator");
+        commands.add("-Djava.security.manager");
+        commands.add("-Djava.security.policy=" + PWD + "/java.policy");
+        commands.add("-classpath");
+        commands.add(PWD + "/" + TEST_SOURCE + ".jar" + pathSepartor
+                + PWD + "/" + ACTION_SOURCE + ".jar");
+        commands.add(TEST_SOURCE);
+        if (JavaToolUtils.runJava(commands) == 0) {
+            System.out.println("Test PASSES");
+        }
+    }
+
+}
diff --git a/jdk/src/share/classes/sun/invoke/anon/InvalidConstantPoolFormatException.java b/jdk/test/java/security/AccessController/DoPrivTest.java
similarity index 65%
copy from jdk/src/share/classes/sun/invoke/anon/InvalidConstantPoolFormatException.java
copy to jdk/test/java/security/AccessController/DoPrivTest.java
index d420d34..9ed0f97 100644
--- a/jdk/src/share/classes/sun/invoke/anon/InvalidConstantPoolFormatException.java
+++ b/jdk/test/java/security/AccessController/DoPrivTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
@@ -23,23 +23,10 @@
  * questions.
  */
 
-package sun.invoke.anon;
+public class DoPrivTest {
 
-/** Exception used when there is an error in the constant pool
- *  format.
- */
-public class InvalidConstantPoolFormatException extends Exception {
-    private static final long serialVersionUID=-6103888330523770949L;
-
-    public InvalidConstantPoolFormatException(String message,Throwable cause) {
-        super(message,cause);
-    }
-
-    public InvalidConstantPoolFormatException(String message) {
-        super(message);
-    }
-
-    public InvalidConstantPoolFormatException(Throwable cause) {
-        super(cause);
+    public static void main(String[] args) {
+        String name = new DoPrivAccomplice().go();
+        System.out.println("Received Name : " + name);
     }
 }
diff --git a/jdk/test/java/security/AccessController/LimitedDoPrivilegedWithNullPerms.java b/jdk/test/java/security/AccessController/LimitedDoPrivilegedWithNullPerms.java
new file mode 100644
index 0000000..13b2db4
--- /dev/null
+++ b/jdk/test/java/security/AccessController/LimitedDoPrivilegedWithNullPerms.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2013,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.
+ *
+ * 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 8050281
+ * @summary Test that NullPointerException is thrown if any element of perms
+ * parameter is null
+ * @run testng LimitedDoPrivilegedWithNullPerms
+ */
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.Permission;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.PropertyPermission;
+import org.testng.annotations.Test;
+
+public class LimitedDoPrivilegedWithNullPerms {
+
+    AccessControlContext acc = AccessController.getContext();
+    Permission p1 = new PropertyPermission("user.name", "read");
+
+    @Test(expectedExceptions = NullPointerException.class)
+    public void test1() {
+        AccessController.doPrivileged(
+                (PrivilegedAction<Void>) () -> null, acc, null);
+    }
+
+    @Test(expectedExceptions = NullPointerException.class)
+    public void test2() {
+        AccessController.doPrivileged(
+                (PrivilegedAction<Void>) () -> null, acc, p1, null);
+    }
+
+    @Test(expectedExceptions = NullPointerException.class)
+    public void test3() {
+        AccessController.doPrivilegedWithCombiner(
+                (PrivilegedAction<Void>) () -> null, acc, null);
+    }
+
+    @Test(expectedExceptions = NullPointerException.class)
+    public void test4() {
+        AccessController.doPrivilegedWithCombiner(
+                (PrivilegedAction<Void>) () -> null, acc, p1, null);
+    }
+
+    @Test(expectedExceptions = NullPointerException.class)
+    public void test5() throws PrivilegedActionException {
+        AccessController.doPrivileged(
+                (PrivilegedExceptionAction<Void>) () -> null,
+                acc, null);
+    }
+
+    @Test(expectedExceptions = NullPointerException.class)
+    public void test6() throws PrivilegedActionException {
+        AccessController.doPrivileged(
+                (PrivilegedExceptionAction<Void>) () -> null,
+                acc, p1, null);
+    }
+
+    @Test(expectedExceptions = NullPointerException.class)
+    public void test7() throws PrivilegedActionException {
+        AccessController.doPrivilegedWithCombiner(
+                (PrivilegedExceptionAction<Void>) () -> null,
+                acc, null);
+    }
+
+    @Test(expectedExceptions = NullPointerException.class)
+    public void test8() throws PrivilegedActionException {
+        AccessController.doPrivilegedWithCombiner(
+                (PrivilegedExceptionAction<Void>) () -> null,
+                acc, p1, null);
+    }
+}
diff --git a/jdk/test/java/security/AccessController/LimitedDoPrivilegedWithThread.java b/jdk/test/java/security/AccessController/LimitedDoPrivilegedWithThread.java
new file mode 100644
index 0000000..955f39d
--- /dev/null
+++ b/jdk/test/java/security/AccessController/LimitedDoPrivilegedWithThread.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2013,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.
+ *
+ * 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 8050281
+ * @summary Test limited doprivileged action with trhead calls.
+ * @run main/othervm/policy=policy LimitedDoPrivilegedWithThread
+ */
+import java.io.FilePermission;
+import java.security.AccessControlContext;
+import java.security.AccessControlException;
+import java.security.AccessController;
+import java.security.Permission;
+import java.security.PrivilegedAction;
+import java.security.ProtectionDomain;
+import java.util.PropertyPermission;
+
+public class LimitedDoPrivilegedWithThread {
+
+    private static final Permission PROPERTYPERM
+            = new PropertyPermission("user.name", "read");
+    private static final Permission FILEPERM
+            = new FilePermission("*", "read");
+    private static final AccessControlContext ACC
+            = new AccessControlContext(
+                    new ProtectionDomain[]{new ProtectionDomain(null, null)});
+
+    public static void main(String args[]) {
+        //parent thread without any permission
+        AccessController.doPrivileged(
+                (PrivilegedAction) () -> {
+                    Thread ct = new Thread(
+                            new ChildThread(PROPERTYPERM, FILEPERM));
+                    ct.start();
+                    try {
+                        ct.join();
+                    } catch (InterruptedException ie) {
+                        Thread.currentThread().interrupt();
+                        ie.printStackTrace();
+                        throw new RuntimeException("Unexpected InterruptedException");
+                    }
+                    return null;
+                }, ACC);
+    }
+}
+
+class ChildThread implements Runnable {
+
+    private final Permission P1;
+    private final Permission P2;
+    private boolean catchACE = false;
+
+    public ChildThread(Permission p1, Permission p2) {
+        this.P1 = p1;
+        this.P2 = p2;
+    }
+
+    @Override
+    public void run() {
+        //Verified that child thread has permission p1,
+        runTest(null, P1, false, 1);
+        //Verified that child thread inherits parent thread's access control context
+        AccessControlContext childAcc = AccessController.getContext();
+        runTest(childAcc, P1, true, 2);
+        //Verified that we can give permision p2 to limit the "privilege" of the
+        //class calling doprivileged action, stack walk will continue
+        runTest(null, P2, true, 3);
+
+    }
+
+    public void runTest(AccessControlContext acc, Permission perm,
+            boolean expectACE, int id) {
+
+        AccessController.doPrivileged(
+                (PrivilegedAction) () -> {
+                    try {
+                        AccessController.getContext().checkPermission(P1);
+                    } catch (AccessControlException ace) {
+                        catchACE = true;
+                    }
+                    if (catchACE ^ expectACE) {
+                        throw new RuntimeException("test" + id + " failed");
+                    }
+                    return null;
+                }, acc, perm);
+    }
+}
diff --git a/jdk/test/java/security/AccessController/policy b/jdk/test/java/security/AccessController/policy
new file mode 100644
index 0000000..83ed146
--- /dev/null
+++ b/jdk/test/java/security/AccessController/policy
@@ -0,0 +1,4 @@
+grant{
+	permission java.util.PropertyPermission "user.name", "read";
+ 	permission java.io.FilePermission "*", "read";
+};
diff --git a/jdk/test/java/security/KeyStore/PKCS12/CheckDefaults.java b/jdk/test/java/security/KeyStore/PKCS12/CheckDefaults.java
new file mode 100644
index 0000000..59a7b80
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/CheckDefaults.java
@@ -0,0 +1,67 @@
+/*
+ * 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
+ * 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.
+ */
+import java.security.KeyStore;
+import java.security.Security;
+import static java.lang.System.out;
+
+/**
+ * @test
+ * @bug 8048830
+ * @summary Set up keystore.type secure property and check that
+ * KeyStore.getDefaultType() value is related to property value. Expect a full
+ * match the value 'keystore.type' and the value of the
+ * KeyStore.getDefaultType()
+ * @run  main/othervm CheckDefaults
+ */
+public class CheckDefaults {
+    private static final String DEFAULT_KEY_STORE_TYPE = "jks";
+    private static final String[] KEY_STORE_TYPES = {"jks", "pkcs12", "jceks",
+        "Unregistered_type_of_KS"};
+
+    private void runTest(String[] args) {
+        if (!KeyStore.getDefaultType().
+                equalsIgnoreCase(DEFAULT_KEY_STORE_TYPE)) {
+            throw new RuntimeException(String.format("Default keystore type "
+                    + "Expected '%s' . Actual: '%s' ", DEFAULT_KEY_STORE_TYPE,
+                    KeyStore.getDefaultType()));
+        }
+        for (String ksDefaultType : KEY_STORE_TYPES) {
+            Security.setProperty("keystore.type", ksDefaultType);
+            if (!KeyStore.getDefaultType().equals(ksDefaultType)) {
+                throw new RuntimeException(String.format(
+                        "Keystore default type value: '%s' cannot be set up via"
+                        + " keystore.type "
+                        + "security property, Actual: '%s'",
+                        ksDefaultType, KeyStore.getDefaultType()));
+            }
+        }
+        out.println("Test Passed");
+    }
+
+    public static void main(String[] args) {
+        CheckDefaults checkDefaultsTest = new CheckDefaults();
+        checkDefaultsTest.runTest(args);
+    }
+}
diff --git a/jdk/test/java/security/KeyStore/PKCS12/ConvertP12Test.java b/jdk/test/java/security/KeyStore/PKCS12/ConvertP12Test.java
new file mode 100644
index 0000000..f5334bf
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/ConvertP12Test.java
@@ -0,0 +1,234 @@
+/*
+ * Copyright (c) 2008, 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.
+ *
+ * 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 static java.lang.System.out;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.security.Key;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.Certificate;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Enumeration;
+
+/*
+ * @test
+ * @bug 8048619
+ * @author  Bill Situ
+ * @summary Test converting keystore from jceks to P12 and from P12 to other
+ *  (jceks,jks). including following test cases:
+ * Read jceks key store and convert to the p12 key store, then compare entries
+ *  in the two key stores.
+ * Read p12 key store and convert to the jceks key store, then compare entries
+ *  in the two key stores.
+ * Read p12 key store (contains only private key and a self-signed certificate)
+ *  and convert to the jceks key store, then compare entries of two key stores.
+ * Read p12 key store (contains 2 entries) and convert to the jceks key store,
+ *  then compare entries in the two key stores.
+ * Read p12 key store (entry password and key store password are different) and
+ *  convert to the jceks key store, then compare entries in the two key stores.
+ * Read p12 key store and convert to the jks key store, then compare entries
+ *  in the two key stores.
+ * Read p12 key store (contains only private key and a self-signed certificate)
+ *  and convert to the jks key store, then compare entries in the two key stores.
+ * Read p12 key store (contains 2 entries) and convert to the jks key store,
+ *  then compare entries in the two key stores.
+ * Read p12 key store (entry password and key store password are different) and
+ * convert to the jks key store, then compare entries in the two key stores.
+ */
+
+public class ConvertP12Test {
+
+    private static final String SUN_JSSE = "SunJSSE";
+    private static final String SUN_JCE = "SunJCE";
+    private static final String SUN = "SUN";
+    private static final String PKCS12 = "pkcs12";
+    private static final String JCE_KS = "JceKS";
+    private static final String JKS = "JKS";
+
+    public static void main(String args[]) throws Exception {
+
+        ConvertP12Test jstest = new ConvertP12Test();
+
+        jstest.driver("JceksToP12", "keystoreCA.jceks.data", JCE_KS, SUN_JCE,
+                "storepass", "keypass", PKCS12, SUN_JSSE);
+
+        jstest.driver("P12ToJceks_Chain", "ie_jceks_chain.pfx.data", PKCS12,
+                SUN_JSSE, "pass", "pass", JCE_KS, SUN_JCE);
+
+        jstest.driver("P12ToJceks_SelfSigned", "jdk_jceks_selfsigned.p12.data",
+                PKCS12, SUN_JSSE, "pass", "pass", JCE_KS, SUN_JCE);
+
+        jstest.driver("P12ToJceks_TwoEntry", "jdk_jceks_twoentry.p12.data",
+                PKCS12, SUN_JSSE, "pass", "pass", JCE_KS, SUN_JCE);
+
+        jstest.driver("P12ToJceks_TwoPass", "jdk_jceks_twopass.p12.data",
+                PKCS12, SUN_JSSE, "storepass", "keypass", JCE_KS, SUN_JCE);
+
+        jstest.driver("P12ToJks_Chain", "ie_jks_chain.pfx.data", PKCS12,
+                SUN_JSSE, "pass", "pass", JKS, SUN);
+
+        jstest.driver("P12ToJks_SelfSigned", "jdk_jks_selfsigned.p12.data",
+                PKCS12, SUN_JSSE, "pass", "pass", JKS, SUN);
+
+        jstest.driver("P12ToJks_TwoEntry", "jdk_jks_twoentry.p12.data", PKCS12,
+                SUN_JSSE, "pass", "pass", JKS, SUN);
+
+        jstest.driver("P12ToJks_TwoPass", "jdk_jks_twopass.p12.data", PKCS12,
+                SUN_JSSE, "storepass", "keypass", JKS, SUN);
+
+    }
+
+    private void driver(String testCase, String inKeyStore,
+            String inKeyStoreType, String inKeyStoreTypePrv,
+            String inStorePass, String inKeyPass, String outKeyStoreType,
+            String outKeyStorePrv) throws Exception {
+
+        String outStorePass = "pass";
+        String outKeyPass = "pass";
+        KeyStore inputKeyStore, outputKeyStore;
+
+        out.println("Testing " + testCase);
+        String keystorePath = System.getProperty("test.src", ".")
+                + File.separator + "certs" + File.separator + "convertP12";
+        out.println("Output KeyStore : " + inKeyStore + ".out");
+        String outKeyStoreName = inKeyStore + ".out";
+        try (FileOutputStream fout = new FileOutputStream(outKeyStoreName);) {
+            inputKeyStore = KeyStore.getInstance(inKeyStoreType,
+                    inKeyStoreTypePrv);
+
+            // KeyStore have encoded by Base64.getMimeEncoder().encode(),need
+            // decode first.
+            byte[] input = Files.readAllBytes(Paths.get(keystorePath,
+                    inKeyStore));
+            ByteArrayInputStream arrayIn = new ByteArrayInputStream(Base64
+                    .getMimeDecoder().decode(input));
+
+            out.println("Input KeyStore : " + inKeyStore);
+
+            inputKeyStore.load(arrayIn, inStorePass.toCharArray());
+
+            outputKeyStore = KeyStore.getInstance(outKeyStoreType,
+                    outKeyStorePrv);
+            outputKeyStore.load(null, null);
+
+            run(inputKeyStore, outputKeyStore, inKeyPass, outKeyPass);
+
+            outputKeyStore.store(fout, outStorePass.toCharArray());
+
+            // for P12ToJks_TwoEntry test case will test includes each other,
+            // others just test compareKeystore
+            if (testCase.contains("TwoEntry")) {
+
+                compareKeyStore(inputKeyStore, outputKeyStore, inKeyPass,
+                        outKeyPass, 2);
+                compareKeyStore(outputKeyStore, inputKeyStore, outKeyPass,
+                        inKeyPass, 2);
+            } else {
+                compareKeyStore(inputKeyStore, outputKeyStore, inKeyPass,
+                        outKeyPass, 1);
+            }
+            out.println("Test " + testCase + " STATUS: Pass!!");
+        } catch (Exception ex) {
+            out.println("Test " + testCase + " STATUS: failed with exception: "
+                    + ex.getMessage());
+            throw ex;
+        }
+    }
+
+    private void run(KeyStore inputKeyStore, KeyStore outputKeyStore,
+            String inKeyPass, String outKeyPass) throws Exception {
+        Enumeration<String> e = inputKeyStore.aliases();
+        String alias;
+        while (e.hasMoreElements()) {
+            alias = e.nextElement();
+            Certificate[] certs = inputKeyStore.getCertificateChain(alias);
+
+            boolean isCertEntry = inputKeyStore.isCertificateEntry(alias);
+            // Test KeyStore only contain key pair entries.
+            if (isCertEntry == true) {
+                throw new RuntimeException(
+                        "inputKeystore should not be certEntry because test"
+                                + " keystore only contain key pair entries"
+                                + " for alias:" + alias);
+            }
+
+            boolean isKeyEntry = inputKeyStore.isKeyEntry(alias);
+            Key key = null;
+            if (isKeyEntry) {
+                key = inputKeyStore.getKey(alias, inKeyPass.toCharArray());
+            } else {
+                throw new RuntimeException("Entry type unknown for alias:"
+                        + alias);
+            }
+            outputKeyStore.setKeyEntry(alias, key, outKeyPass.toCharArray(),
+                    certs);
+        }
+    }
+
+    private void compareKeyStore(KeyStore a, KeyStore b, String inKeyPass,
+            String outKeyPass, int keyStoreSize) throws Exception {
+        if (a.size() != keyStoreSize || b.size() != keyStoreSize) {
+            throw new RuntimeException("size not match or size not equal to "
+                    + keyStoreSize);
+        }
+
+        Enumeration<String> eA = a.aliases();
+        while (eA.hasMoreElements()) {
+            String aliasA = eA.nextElement();
+
+            if (!b.containsAlias(aliasA)) {
+                throw new RuntimeException("alias not match for alias:"
+                        + aliasA);
+            }
+
+            compareKeyEntry(a, b, inKeyPass, outKeyPass, aliasA);
+        }
+    }
+
+    private void compareKeyEntry(KeyStore a, KeyStore b, String aPass,
+            String bPass, String alias) throws KeyStoreException,
+            UnrecoverableKeyException, NoSuchAlgorithmException {
+        Certificate[] certsA = a.getCertificateChain(alias);
+        Certificate[] certsB = b.getCertificateChain(alias);
+
+        if (!Arrays.equals(certsA, certsB)) {
+            throw new RuntimeException("Certs don't match for alias:" + alias);
+        }
+
+        Key keyA = a.getKey(alias, aPass.toCharArray());
+        Key keyB = b.getKey(alias, bPass.toCharArray());
+
+        if (!keyA.equals(keyB)) {
+            throw new RuntimeException(
+                    "Key don't match for alias:" + alias);
+        }
+    }
+}
diff --git a/jdk/test/java/security/KeyStore/PKCS12/EntryProtectionTest.java b/jdk/test/java/security/KeyStore/PKCS12/EntryProtectionTest.java
new file mode 100644
index 0000000..586eda3
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/EntryProtectionTest.java
@@ -0,0 +1,151 @@
+/*
+ * 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
+ * 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.
+ */
+import java.io.File;
+import static java.lang.System.err;
+import java.security.*;
+import java.security.cert.Certificate;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+import javax.crypto.spec.PBEParameterSpec;
+import jdk.testlibrary.RandomFactory;
+import static java.lang.System.out;
+import java.util.Arrays;
+
+/**
+ * @test
+ * @bug 8048830
+ * @summary Test for feature 'support stronger entry protection'. An entry is
+ * stored to keystore with different PasswordProtection objects which are
+ * specified by different PBE algorithms (use -Dseed=X to set PRNG seed)
+ * @library /lib/testlibrary ../
+ */
+public class EntryProtectionTest {
+    private static final char[] PASSWORD = "passwd".toCharArray();
+    private static final String ALIAS = "testkey";
+    private static final byte[] SALT = new byte[8];
+    private static final int ITERATION_COUNT = 1024;
+    private static final List<KeyStore.PasswordProtection> PASSWORD_PROTECTION
+            = new ArrayList<>();
+    private static final String KEYSTORE_PATH = System.getProperty(
+            "test.classes" + File.separator + "ks.pkcs12",
+            "." + File.separator + "ks.pkcs12");
+
+    private void runTest() throws Exception {
+            KeyStore ksIn = Utils.loadKeyStore(KEYSTORE_PATH,
+                    Utils.KeyStoreType.pkcs12, PASSWORD);
+            KeyStore ksTest = KeyStore
+                    .getInstance(Utils.KeyStoreType.pkcs12.name());
+            ksTest.load(null);
+            Certificate cert = ksIn.getCertificate(ALIAS);
+            Key key = ksIn.getKey(ALIAS, PASSWORD);
+            KeyStore.Entry keyStoreEntry = new KeyStore.PrivateKeyEntry(
+                    (PrivateKey) key, new Certificate[]{cert});
+            for (KeyStore.PasswordProtection passwordAlgorithm :
+                    PASSWORD_PROTECTION) {
+                out.println("Try to use: " +
+                        passwordAlgorithm.getProtectionAlgorithm());
+                ksTest.setEntry(ALIAS, keyStoreEntry, passwordAlgorithm);
+                KeyStore.Entry entryRead = ksTest.getEntry(ALIAS,
+                        new KeyStore.PasswordProtection(PASSWORD));
+                if (!isPrivateKeyEntriesEqual((KeyStore.PrivateKeyEntry)
+                        keyStoreEntry, (KeyStore.PrivateKeyEntry)entryRead)) {
+                    err.println("Original entry in KeyStore: " + keyStoreEntry);
+                    err.println("Enc/Dec entry : " + entryRead);
+                    throw new RuntimeException(
+                            String.format(
+                                    "Decrypted & original enities do "
+                                    + "not match. Algo: %s, Actual: %s, "
+                                    + "Expected: %s",
+                                    passwordAlgorithm.getProtectionAlgorithm(),
+                                    entryRead, keyStoreEntry));
+                }
+                ksTest.deleteEntry(ALIAS);
+            }
+            out.println("Test Passed");
+    }
+
+    public static void main(String args[]) throws Exception {
+        EntryProtectionTest entryProtectionTest = new EntryProtectionTest();
+        entryProtectionTest.setUp();
+        entryProtectionTest.runTest();
+    }
+
+    private void setUp() {
+        out.println("Using KEYSTORE_PATH:"+KEYSTORE_PATH);
+        Utils.createKeyStore(Utils.KeyStoreType.pkcs12, KEYSTORE_PATH, ALIAS);
+        Random rand = RandomFactory.getRandom();
+        rand.nextBytes(SALT);
+        out.print("Salt: ");
+        for (byte b : SALT) {
+            out.format("%02X ", b);
+        }
+        out.println("");
+        PASSWORD_PROTECTION
+                .add(new KeyStore.PasswordProtection(PASSWORD,
+                                "PBEWithMD5AndDES", new PBEParameterSpec(SALT,
+                                        ITERATION_COUNT)));
+        PASSWORD_PROTECTION.add(new KeyStore.PasswordProtection(PASSWORD,
+                "PBEWithSHA1AndDESede", null));
+        PASSWORD_PROTECTION.add(new KeyStore.PasswordProtection(PASSWORD,
+                "PBEWithSHA1AndRC2_40", null));
+        PASSWORD_PROTECTION.add(new KeyStore.PasswordProtection(PASSWORD,
+                "PBEWithSHA1AndRC2_128", null));
+        PASSWORD_PROTECTION.add(new KeyStore.PasswordProtection(PASSWORD,
+                "PBEWithSHA1AndRC4_40", null));
+        PASSWORD_PROTECTION.add(new KeyStore.PasswordProtection(PASSWORD,
+                "PBEWithSHA1AndRC4_128", null));
+    }
+
+    /**
+     * Checks whether given two KeyStore.PrivateKeyEntry parameters are equal
+     * The KeyStore.PrivateKeyEntry fields like {privateKey, certificateChain[]}
+     * are checked for equality and another field Set<attributes> is not checked
+     * as default implementation adds few PKCS12 attributes during read
+     * operation
+     * @param  first
+     *         parameter is of type KeyStore.PrivateKeyEntry
+     * @param  second
+     *         parameter is of type KeyStore.PrivateKeyEntry
+     * @return boolean
+     *         true when both the KeyStore.PrivateKeyEntry fields are equal
+    */
+    boolean isPrivateKeyEntriesEqual(KeyStore.PrivateKeyEntry first,
+            KeyStore.PrivateKeyEntry second) {
+        //compare privateKey
+        if (!Arrays.equals(first.getPrivateKey().getEncoded(),
+                second.getPrivateKey().getEncoded())) {
+            err.println("Mismatch found in privateKey!");
+            return false;
+        }
+        //compare certificateChain[]
+        if (!Arrays.equals(first.getCertificateChain(),
+                second.getCertificateChain())) {
+            err.println("Mismatch found in certificate chain!");
+            return false;
+        }
+        return true;
+    }
+}
diff --git a/jdk/test/java/security/KeyStore/PKCS12/KeytoolReaderP12Test.java b/jdk/test/java/security/KeyStore/PKCS12/KeytoolReaderP12Test.java
new file mode 100644
index 0000000..4c7e55b
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/KeytoolReaderP12Test.java
@@ -0,0 +1,155 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.StandardOpenOption;
+import java.util.Base64;
+import jdk.testlibrary.OutputAnalyzer;
+import static java.lang.System.out;
+import java.nio.file.Paths;
+import java.util.List;
+
+/**
+ * @test
+ * @bug 8048830
+ * @summary Test for PKCS12 keystore list , export commands. Refer README for
+ * keystore files information
+ * @library /lib/testlibrary ../
+ * @run main KeytoolReaderP12Test
+ */
+public class KeytoolReaderP12Test {
+    private static final String WORKING_DIRECTORY = System.getProperty(
+            "test.classes", "."+ File.separator);
+    private static final String KS_PASSWD = "storepass";
+    private static final String CERT_CHAIN_PASSWD = "password";
+    private static final String SOURCE_DIRECTORY =
+            System.getProperty("test.src", "." + File.separator);
+
+    public static void main(String[] args) throws Exception {
+        List<String> expectedValues = null;
+        out.println("Self signed test");
+        expectedValues = Files.readAllLines(Paths.get(SOURCE_DIRECTORY,
+                "api_private_key.p12_expected.data"));
+        readTest("api_private_key.p12.data", KS_PASSWD, expectedValues);
+        out.println("Self signed test Passed");
+
+        out.println("private key with selfsigned cert, key pair not match");
+        expectedValues = Files.readAllLines(Paths.get(SOURCE_DIRECTORY,
+                "api_private_key_not_match.p12_expected.data"));
+        readTest("api_private_key_not_match.p12.data", KS_PASSWD,
+                expectedValues);
+        out.println("private key with selfsigned cert, key pair "
+                + "not match passed");
+
+        out.println("cert chain test");
+        expectedValues = Files.readAllLines(Paths.get(SOURCE_DIRECTORY,
+                "api_cert_chain.p12_expected.data"));
+        readTest("api_cert_chain.p12.data", CERT_CHAIN_PASSWD, expectedValues);
+        out.println("cert chain test passed");
+
+        out.println("IE self test");
+        expectedValues = Files.readAllLines(Paths.get(SOURCE_DIRECTORY,
+                "ie_self.pfx.pem"));
+        exportTest("ie_self.pfx.data", "pkcs12testenduser1",
+                KS_PASSWD, expectedValues);
+        out.println("IE self test passed");
+
+        out.println("IE chain test");
+        expectedValues = Files.readAllLines(Paths.get(SOURCE_DIRECTORY,
+                "ie_chain.pfx.pem"));
+        exportTest("ie_chain.pfx.data", "servercert",
+                CERT_CHAIN_PASSWD, expectedValues);
+        out.println("IE chain test passed");
+
+        out.println("Netscape self");
+        expectedValues = Files.readAllLines(Paths.get(SOURCE_DIRECTORY,
+                "netscape_self.p12.pem"));
+        exportTest("netscape_self.p12.data", "pkcs12testenduser1",
+                KS_PASSWD, expectedValues);
+        out.println("Netscape self passed");
+
+        out.println("Mozilla self test");
+        expectedValues = Files.readAllLines(Paths.get(SOURCE_DIRECTORY,
+                "mozilla_self.p12.pem"));
+        exportTest("mozilla_self.p12.data", "pkcs12testenduser1",
+                KS_PASSWD, expectedValues);
+        out.println("Mozilla self test passed");
+
+        out.println("Openssl test");
+        expectedValues = Files.readAllLines(Paths.get(SOURCE_DIRECTORY,
+                "openssl.p12.pem"));
+        exportTest("openssl.p12.data", "servercert", CERT_CHAIN_PASSWD, expectedValues);
+        out.println("openssl test passed");
+
+        out.println("with different keystore and entrykey password");
+        expectedValues = Files.readAllLines(Paths.get(SOURCE_DIRECTORY,
+                "api_two_pass.p12_expected.data"));
+        readTest("api_two_pass.p12.data", KS_PASSWD,
+                expectedValues);
+        out.println("two pass test passed");
+    }
+
+    private static void readTest(String name, String password,
+            List<String> expectedValues)
+            throws IOException {
+        convertToPFX(name);
+        final String[] command = new String[]{"-debug", "-list", "-v",
+            "-keystore", WORKING_DIRECTORY + File.separator + name,
+            "-storetype", "pkcs12", "-storepass", password};
+        runAndValidate(command, expectedValues);
+    }
+
+    private static void exportTest(String name, String alias,
+            String password, List<String> expectedValues)
+            throws IOException {
+        convertToPFX(name);
+        final String[] command = new String[]{"-debug", "-export", "-alias",
+            alias, "-keystore", WORKING_DIRECTORY + File.separator + name,
+            "-storepass", password, "-storetype", "pkcs12", "-rfc"};
+        runAndValidate(command, expectedValues);
+    }
+
+    private static void runAndValidate(String[] command,
+            List<String> expectedValues) throws IOException {
+        OutputAnalyzer output = Utils.executeKeytoolCommand(command);
+        if (expectedValues != null) {
+            expectedValues.stream().forEach(line -> {
+                output.shouldContain(line);
+            });
+        }
+    }
+
+    /**
+     * Decodes the base64 encoded keystore and writes into new file
+     * @param name base64 encoded keystore name
+     */
+    private static void convertToPFX(String name) throws IOException{
+        File base64File = new File(SOURCE_DIRECTORY, name);
+        File pkcs12File = new File(WORKING_DIRECTORY, name);
+        byte[] input = Files.readAllBytes(base64File.toPath());
+        Files.write(pkcs12File.toPath(), Base64.getMimeDecoder().
+                decode(input), StandardOpenOption.CREATE);
+    }
+}
diff --git a/jdk/test/java/security/KeyStore/PKCS12/KeytoolWriteP12Test.java b/jdk/test/java/security/KeyStore/PKCS12/KeytoolWriteP12Test.java
new file mode 100644
index 0000000..b35751f
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/KeytoolWriteP12Test.java
@@ -0,0 +1,128 @@
+/*
+ * 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
+ * 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.
+ */
+
+import java.io.File;
+import jdk.testlibrary.OutputAnalyzer;
+import static java.lang.System.out;
+
+/**
+ * @test
+ * @bug 8048830
+ * @summary Tests for creating pkcs12 keystore with various algorithms
+ * @library /lib/testlibrary ../
+ * @run main KeytoolWriteP12Test
+ */
+public class KeytoolWriteP12Test {
+    private static final String ALIAS = "pkcs12testCA";
+    private static final Utils.KeyStoreType PKCS12 = Utils.KeyStoreType.pkcs12;
+    private static final int FAILED_EXIT_CODE = 1;
+    private static final String CERT_FILE_NAME = "cert.data";
+    private static final String DNAME = "CN=PKCS12 Test CA, OU=Security SQE, "
+            + "O=JavaSoft, C=US";
+    private static final String WORKING_DIRECTORY = System.
+            getProperty("test.classes", "." + File.separator);
+    private enum Algorithm {
+        DSA, RSA, ECC
+    };
+    private void run() {
+        out.println("Running DSA Test");
+        keytoolListTest("kt_DSA.p12", Algorithm.DSA);
+        out.println("DSA Test passed");
+
+        out.println("Running RSA Test");
+        final String rsaKeyStoreName = "kt_RSA_MD5.p12";
+        keytoolListTest(rsaKeyStoreName, Algorithm.RSA);
+        out.println("RSA Test passed");
+
+        out.println("Running RSA and Signing Algorithm SHA1withRSA Test");
+        keytoolListTest("kt_RSA_SHA1.p12", Algorithm.RSA,
+                "-sigalg", "SHA1withRSA");
+        out.println("RSA and Signing Algorithm SHA1withRSA Test Passed");
+
+        out.println("Running Keysize 256 Test");
+        keytoolListNegativeTest("kt_DSA_256.p12", Algorithm.DSA, "-keysize",
+                "256");
+        out.println("Keysize 256 Test Passed");
+
+        out.println("Running Keysize 1023 Test");
+        keytoolListTest("kt_RSA_MD5_1023.p12", Algorithm.RSA, "-keysize",
+                "1023");
+        out.println("Keysize 1023 Test Passed");
+        out.println("Running Export certificate Test");
+        exportTest(rsaKeyStoreName);
+        out.println("Export certificate Test Passed");
+    }
+
+    private void exportTest(String keyStore) {
+        final String keyStoreName = WORKING_DIRECTORY + File.separator
+                + keyStore;
+        deleteKeyStoreFile(keyStoreName);
+        Utils.createKeyStore(DNAME, PKCS12, keyStore, ALIAS,
+                Algorithm.RSA.name());
+        final String certFilePath = WORKING_DIRECTORY + File.separator
+                + CERT_FILE_NAME;
+        Utils.exportCert(PKCS12, keyStore,
+                ALIAS, certFilePath);
+        final String[] command = new String[]{"-debug", "-printcert", "-v",
+            "-file", certFilePath};
+        Utils.executeKeytoolCommand(command);
+    }
+
+    private void keytoolListTest(String keyStore, Algorithm algorithm,
+            String ...optionalArgs) {
+        final String keyStoreName = WORKING_DIRECTORY + File.separator
+                + keyStore;
+        final String[] command = new String[]{"-debug", "-list", "-v", "-alias",
+            ALIAS, "-keystore", keyStoreName, "-storetype", "pkcs12",
+            "-storepass", Utils.DEFAULT_PASSWD};
+        deleteKeyStoreFile(keyStoreName);
+        Utils.createKeyStore(DNAME, PKCS12, keyStoreName, ALIAS,
+                algorithm.name(), optionalArgs);
+        OutputAnalyzer output = Utils.executeKeytoolCommand(command);
+        output.shouldContain(DNAME);
+    }
+
+    private void keytoolListNegativeTest(String keyStore, Algorithm algorithm,
+            String... optionalArgs) {
+        final String keyStoreName = WORKING_DIRECTORY  + File.separator
+                + keyStore;
+        deleteKeyStoreFile(keyStoreName);
+        Utils.createKeyStore(DNAME, PKCS12, keyStoreName, ALIAS,
+                algorithm.name(), optionalArgs, FAILED_EXIT_CODE);
+    }
+
+    public static void main(String[] args) {
+        KeytoolWriteP12Test test = new KeytoolWriteP12Test();
+        test.run();
+        out.println("Test Passed");
+    }
+
+    private void deleteKeyStoreFile(String fileName) {
+        File file = new File(fileName);
+        if (file.exists()) {
+            file.delete();
+        }
+    }
+}
diff --git a/jdk/test/java/security/KeyStore/PKCS12/MetadataEmptyTest.java b/jdk/test/java/security/KeyStore/PKCS12/MetadataEmptyTest.java
new file mode 100644
index 0000000..1874241
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/MetadataEmptyTest.java
@@ -0,0 +1,79 @@
+/*
+ * 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
+ * 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.
+ */
+
+import java.io.File;
+import java.security.Key;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.Certificate;
+import java.io.IOException;
+import java.security.cert.CertificateException;
+import static java.lang.System.out;
+
+/**
+ * @test
+ * @bug 8048830
+ * @summary Entry's attribute set should be empty
+ * @library /lib/testlibrary ../
+ * @run main MetadataEmptyTest
+ */
+public class MetadataEmptyTest {
+    private static final char[] PASSWORD = "passwd".toCharArray();
+    private static final String ALIAS = "testkey";
+    private static final String KEYSTORE_PATH = System.getProperty(
+            "test.classes" + File.separator + "ks.pkcs12",
+            "." + File.separator + "ks.pkcs12");
+
+    private void runTest() throws IOException, KeyStoreException,
+            NoSuchAlgorithmException, CertificateException,
+            UnrecoverableKeyException {
+        KeyStore ks = Utils.loadKeyStore(KEYSTORE_PATH,
+                Utils.KeyStoreType.pkcs12, PASSWORD);
+        Key key = ks.getKey(ALIAS, PASSWORD);
+        Certificate cert = ks
+                .getCertificate(ALIAS);
+        KeyStore.Entry entry = new KeyStore.PrivateKeyEntry(
+                (PrivateKey) key,
+                new Certificate[]{cert});
+        if (!entry.getAttributes().isEmpty()) {
+            throw new RuntimeException("Entry's attributes set "
+                    + "must be empty");
+        }
+        out.println("Test Passed");
+    }
+
+    public static void main(String[] args) throws Exception{
+        MetadataEmptyTest test = new MetadataEmptyTest();
+        test.setUp();
+        test.runTest();
+    }
+
+    private void setUp() {
+        Utils.createKeyStore(Utils.KeyStoreType.pkcs12, KEYSTORE_PATH, ALIAS);
+    }
+}
diff --git a/jdk/test/java/security/KeyStore/PKCS12/MetadataStoreLoadTest.java b/jdk/test/java/security/KeyStore/PKCS12/MetadataStoreLoadTest.java
new file mode 100644
index 0000000..729c5fb
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/MetadataStoreLoadTest.java
@@ -0,0 +1,148 @@
+/*
+ * 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
+ * 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.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import java.security.Key;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.PKCS12Attribute;
+import java.security.PrivateKey;
+import java.security.UnrecoverableEntryException;
+import java.security.cert.Certificate;
+import java.util.Arrays;
+import java.util.Set;
+import static java.lang.System.out;
+import java.util.HashSet;
+
+/**
+ * @test
+ * @bug 8048830
+ * @summary Test store metadata attributes to PKCS12 keystore.
+ * @library /lib/testlibrary ../
+ * @run main MetadataStoreLoadTest
+ */
+public class MetadataStoreLoadTest {
+    private static final char[] PASSWORD = "passwd".toCharArray();
+    private static final char[] KEY_PASSWORD = "keypasswd".toCharArray();
+    private static final String ALIAS = "testkey_metadata";
+    private static final String KEYSTORE = "ks.pkcs12";
+    private static final String KESTORE_NEW = "ks-attr.pkcs12";
+    private static final int MAX_HUGE_SIZE = 2000000;
+    private static final String WORKING_DIRECTORY = System.getProperty(
+            "test.classes", "." + File.separator);
+    private static final String KEYSTORE_PATH = WORKING_DIRECTORY
+            + File.separator + KEYSTORE;
+    private static KeyStore.Entry.Attribute[] ATTR_SET;
+
+    private void runTest() throws GeneralSecurityException,
+            UnrecoverableEntryException, NoSuchAlgorithmException,
+            KeyStoreException, IOException {
+        storeAttrs();
+        checkAttrs();
+    }
+
+    private void storeAttrs() throws UnrecoverableEntryException,
+            GeneralSecurityException, NoSuchAlgorithmException,
+            KeyStoreException, IOException {
+        KeyStore ksIn = Utils.loadKeyStore(KEYSTORE_PATH,
+                Utils.KeyStoreType.pkcs12, PASSWORD);
+        KeyStore ksAttr = KeyStore
+                .getInstance(Utils.KeyStoreType.pkcs12.name());
+        ksAttr.load(null);
+        Key key = ksIn.getKey(ALIAS, PASSWORD);
+        Certificate cert = ksIn.getCertificate(ALIAS);
+        Set<KeyStore.Entry.Attribute> attrs =
+                new HashSet<>(Arrays.asList(ATTR_SET));
+        KeyStore.Entry e = new KeyStore.PrivateKeyEntry((PrivateKey) key,
+                new Certificate[]{cert}, attrs);
+        ksAttr.setEntry(ALIAS, e, new KeyStore.PasswordProtection(
+                KEY_PASSWORD));
+
+        out.println("Attributes before store:");
+        e.getAttributes().stream().forEach((attr) -> {
+            out.println(attr.getName() + ", '" + attr.getValue() + "'");
+        });
+        Utils.saveKeyStore(ksAttr, WORKING_DIRECTORY + File.separator
+                + KESTORE_NEW, PASSWORD);
+    }
+
+    private void checkAttrs() throws UnrecoverableEntryException,
+            GeneralSecurityException, NoSuchAlgorithmException,
+            KeyStoreException, IOException {
+        KeyStore ks = Utils.loadKeyStore(WORKING_DIRECTORY
+                + File.separator
+                + KESTORE_NEW, Utils.KeyStoreType.pkcs12, PASSWORD);
+        KeyStore.Entry keyStoreEntry = ks.getEntry(ALIAS,
+                new KeyStore.PasswordProtection(KEY_PASSWORD));
+        out.println("Attributes after store:");
+        //print attribute values
+        keyStoreEntry.getAttributes().stream().forEach((attr) -> {
+            out.println(attr.getName() + ", '" + attr.getValue() + "'");
+        });
+        Arrays.stream(ATTR_SET).forEach((attr) -> {
+            if (!keyStoreEntry.getAttributes().contains(attr)) {
+                throw new RuntimeException("Entry doesn't contain attribute: ("
+                        + attr.getName() + ", '" + attr.getValue() + "')");
+            }
+        });
+    }
+
+    public static void main(String[] args) throws Exception {
+        MetadataStoreLoadTest test = new MetadataStoreLoadTest();
+        test.setUp();
+        test.runTest();
+        out.println("Test Passed");
+    }
+
+    private void setUp() {
+        Utils.createKeyStore(Utils.KeyStoreType.pkcs12, KEYSTORE_PATH, ALIAS);
+        final String allCharsString = "`1234567890-=qwertyuiop[]asdfghjkl;'\\zx"
+                + "cvbnm,./!@#$%^&*()_+QWERTYUIOP{}ASDFGHJKL:|>ZXCVBNM<>?\"";
+        StringBuilder sbPrintable = new StringBuilder();
+        while (sbPrintable.length() < MAX_HUGE_SIZE) {
+            sbPrintable.append(allCharsString);
+        }
+        final String hugePrintable = sbPrintable.toString();
+        final String binaryString = "00:11:22:33:44:55:66:77:88:99:AA:BB:DD:"
+                + "EE:FF:";
+        StringBuilder sbBinary = new StringBuilder();
+        sbBinary.append(binaryString);
+        while (sbBinary.length() < MAX_HUGE_SIZE) {
+            sbBinary.append(":").append(binaryString);
+        }
+        sbBinary.insert(0, "[").append("]");
+        final String hugeBinary = sbBinary.toString();
+        ATTR_SET = new PKCS12Attribute[5];
+        ATTR_SET[0] = new PKCS12Attribute("1.2.840.113549.1.9.1",
+                "Test email addres attr <test@oracle.com>");
+        ATTR_SET[1] = new PKCS12Attribute("1.2.110.1", "not registered attr");
+        ATTR_SET[2] = new PKCS12Attribute("1.2.110.2", hugePrintable);
+        ATTR_SET[3] = new PKCS12Attribute("1.2.110.3", hugeBinary);
+        ATTR_SET[4] = new PKCS12Attribute("1.2.110.2", " ");
+    }
+}
diff --git a/jdk/test/java/security/KeyStore/PKCS12/ReadP12Test.java b/jdk/test/java/security/KeyStore/PKCS12/ReadP12Test.java
new file mode 100644
index 0000000..429a498
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/ReadP12Test.java
@@ -0,0 +1,193 @@
+/*
+ * Copyright (c) 2003,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.
+ *
+ * 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 static java.lang.System.out;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.security.Key;
+import java.security.KeyStore;
+import java.security.cert.Certificate;
+import java.security.cert.X509Certificate;
+import java.util.Base64;
+import java.util.Enumeration;
+
+/*
+ * @test
+ * @bug 8048617
+ * @author  Bill Situ
+ * @summary Read different types p12 key store to Check the read related APIs.
+ *  including following test cases:
+ * ReadP12_IE_Chain: Read p12 key store (contains private key and associated
+ *  certificate chain) from IE.
+ * ReadP12_IE_Self: Read p12 key store (contains only private key and
+ *  self-signed certificate) from IE.
+ * ReadP12_JDK_Chain: Read p12 key store (contains private key and associated
+ *  certificate chain) from JDK
+ * ReadP12_JDK_Self: Read p12 key store (contains only private key and
+ *  self-signed certificate) from JDK.
+ * ReadP12_Mozilla_Self: Read p12 key store (contains only private key and
+ *  self-signed certificate) from Mozilla.
+ * ReadP12_Mozilla_Chain: Read p12 key store (contains private key and
+ *  associated certificate chain) from Mozilla.
+ * ReadP12_Mozilla_TwoEntries: Read p12 key store (contains 2 entries) from
+ *  Mozilla.
+ * ReadP12_Netscape_Chain: Read p12 key store (contains private key and
+ *  associated certificate chain) from Netscape.
+ * ReadP12_Netscape_Self: Read p12 key store (contains only private key and
+ *  self-signed certificate) from Netscape.
+ * ReadP12_Netscape_TwoEntries: Read p12 key store (contains 2 entries) from
+ *  Netscape.
+ * ReadP12_OpenSSL: Read p12 key store from OpenSSL.
+ */
+
+public class ReadP12Test {
+
+    private final static String IN_KETYSTORE_TYPE = "pkcs12";
+    private final static String IN_KEYSTORE_PRV = "SunJSSE";
+    private final static String IN_STORE_PASS = "pass";
+
+    public static void main(String args[]) throws Exception {
+
+        ReadP12Test jstest = new ReadP12Test();
+        String testCase = "";
+        try {
+            testCase = "ReadP12_IE_Chain";
+            jstest.readTest("ie_chain.pfx.data");
+
+            testCase = "ReadP12_IE_Self";
+            jstest.readTest("ie_self.pfx.data");
+
+            testCase = "ReadP12_JDK_Chain";
+            jstest.readTest("jdk_chain.p12.data");
+
+            testCase = "ReadP12_JDK_Self";
+            jstest.readTest("jdk_self.p12.data");
+
+            testCase = "ReadP12_Mozilla_Chain";
+            jstest.readTest("mozilla_chain.p12.data");
+
+            testCase = "ReadP12_Mozilla_Self";
+            jstest.readTest("mozilla_self.p12.data");
+
+            testCase = "ReadP12_Mozilla_TwoEntries";
+            jstest.readTest("mozilla_twoentries.p12.data");
+
+            testCase = "ReadP12_Netscape_Chain";
+            jstest.readTest("netscape_chain.p12.data");
+
+            testCase = "ReadP12_Netscape_Self";
+            jstest.readTest("netscape_self.p12.data");
+
+            testCase = "ReadP12_Netscape_TwoEntries";
+            jstest.readTest("netscape_twoentries.p12.data");
+
+            testCase = "ReadP12_openssl";
+            jstest.readTest("openssl.p12.data");
+
+        } catch (Exception e) {
+            System.err.println(testCase + ": failed with execption: "
+                    + e.getMessage());
+            throw e;
+
+        }
+        out.println(testCase + ": Pass!!");
+    }
+
+    private void readTest(String inKeyStore) throws Exception {
+
+        KeyStore inputKeyStore;
+
+        // Initialize KeyStore
+        String dir = System.getProperty("test.src", ".");
+        String keystorePath = dir + File.separator + "certs" + File.separator
+                + "readP12";
+        inputKeyStore = KeyStore
+                .getInstance(IN_KETYSTORE_TYPE, IN_KEYSTORE_PRV);
+        // KeyStore have encoded by Base64.getMimeEncoder().encode(),need decode
+        // first.
+        byte[] input = Files.readAllBytes(Paths.get(keystorePath, inKeyStore));
+        ByteArrayInputStream arrayIn = new ByteArrayInputStream(Base64
+                .getMimeDecoder().decode(input));
+        inputKeyStore.load(arrayIn, IN_STORE_PASS.toCharArray());
+        out.println("Initialize KeyStore : " + inKeyStore + " success");
+
+        out.println("getProvider : " + inputKeyStore.getProvider());
+        out.println("getType : " + inputKeyStore.getType());
+        out.println("getDefaultType : " + KeyStore.getDefaultType());
+
+        int idx = 0;
+        Enumeration<String> e = inputKeyStore.aliases();
+        String alias;
+        while (e.hasMoreElements()) {
+            alias = e.nextElement();
+            out.println("Alias " + idx + " : " + alias);
+            if (inputKeyStore.containsAlias(alias) == false) {
+                throw new RuntimeException("Alias not found");
+            }
+
+            out.println("getCreationDate : "
+                    + inputKeyStore.getCreationDate(alias));
+
+            X509Certificate cert = (X509Certificate) inputKeyStore
+                    .getCertificate(alias);
+            out.println("getCertificate : " + cert.getSubjectDN());
+            String retAlias = inputKeyStore.getCertificateAlias(cert);
+            if (!retAlias.equals(alias)) {
+                throw new RuntimeException("Alias mismatch");
+            }
+            out.println("getCertificateAlias : " + retAlias);
+
+            Certificate[] certs = inputKeyStore.getCertificateChain(alias);
+            for (int i = 0; i < certs.length; i++) {
+                out.println("getCertificateChain " + i + " : "
+                        + ((X509Certificate) certs[i]).getSubjectDN());
+            }
+
+            boolean isCertEntry = inputKeyStore.isCertificateEntry(alias);
+            // test KeyStore only contain key pair entries.
+            if (isCertEntry == true) {
+                throw new RuntimeException(
+                        "inputKeystore should not be certEntry because test keystore only contain key pair entries.");
+            }
+
+            boolean isKeyEntry = inputKeyStore.isKeyEntry(alias);
+            if (isKeyEntry) {
+                Key key = inputKeyStore.getKey(alias,
+                        IN_STORE_PASS.toCharArray());
+                out.println("Key : " + key.toString());
+            } else {
+                throw new RuntimeException("Entry type unknown\n");
+            }
+            idx++;
+        }
+
+        int size = inputKeyStore.size();
+        if (idx != size) {
+            throw new RuntimeException("Size not match");
+        }
+
+    }
+}
diff --git a/jdk/test/java/security/KeyStore/PKCS12/StoreTrustedCertAPITest.java b/jdk/test/java/security/KeyStore/PKCS12/StoreTrustedCertAPITest.java
new file mode 100644
index 0000000..68efa2b
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/StoreTrustedCertAPITest.java
@@ -0,0 +1,97 @@
+/*
+ * 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
+ * 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.
+ */
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import static java.lang.System.err;
+import static java.lang.System.out;
+
+/**
+ * @test
+ * @bug 8048830
+ * @summary Test imports certificate from file to PKCS12 keystore store it as
+ * trusted certificate Check import errors (must be not errors) & check keystore
+ * content after import
+ * @library /lib/testlibrary ../
+ * @run main StoreTrustedCertAPITest
+ */
+public class StoreTrustedCertAPITest {
+    private static final char[] PASSWORD = "passwd".toCharArray();
+    private static final String ALIAS = "testkey_stcapi";
+    private static final String WORKING_DIRECTORY = System.getProperty(
+            "test.classes", "." + File.separator);
+    private static final String CERT_PATH = WORKING_DIRECTORY + File.separator
+            + "cert.data";
+    private static final String KEYSTORE_PATH = WORKING_DIRECTORY
+            + File.separator + "ks.pkcs12";
+
+    /**
+     * Test logic (environment has set up)
+     */
+    private void runTest() throws FileNotFoundException, CertificateException,
+            KeyStoreException, IOException, NoSuchAlgorithmException {
+        Certificate cert;
+        CertificateFactory cf;
+        try (FileInputStream fi = new FileInputStream(CERT_PATH)) {
+            cf = CertificateFactory.getInstance("X.509");
+            cert = cf.generateCertificate(fi);
+            KeyStore ks = KeyStore.getInstance(
+                    Utils.KeyStoreType.pkcs12.name());
+            ks.load(null, null);
+            ks.setCertificateEntry(ALIAS, cert);
+            Utils.saveKeyStore(ks, KEYSTORE_PATH, PASSWORD);
+            ks = Utils.loadKeyStore(KEYSTORE_PATH, Utils.KeyStoreType.pkcs12,
+                    PASSWORD);
+            final Certificate ksCert = ks.getCertificate(ALIAS);
+            if (!ksCert.equals(cert)) {
+                err.println("Orig cert: " + cert.toString());
+                err.println("Cert from keystore: " + ksCert.toString());
+                throw new RuntimeException("Certificates don't match");
+            }
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        StoreTrustedCertAPITest test = new StoreTrustedCertAPITest();
+        test.setUp();
+        test.runTest();
+        out.println("Test Passed");
+    }
+
+    private void setUp() {
+        Utils.createKeyStore(Utils.KeyStoreType.pkcs12, KEYSTORE_PATH, ALIAS);
+        Utils.exportCert(Utils.KeyStoreType.pkcs12, KEYSTORE_PATH,
+                ALIAS, CERT_PATH);
+        new File(KEYSTORE_PATH).delete();
+    }
+}
diff --git a/jdk/test/java/security/KeyStore/PKCS12/StoreTrustedCertKeytool.java b/jdk/test/java/security/KeyStore/PKCS12/StoreTrustedCertKeytool.java
new file mode 100644
index 0000000..1b1672d
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/StoreTrustedCertKeytool.java
@@ -0,0 +1,128 @@
+/*
+ * 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
+ * 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.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import jdk.testlibrary.OutputAnalyzer;
+import static java.lang.System.out;
+
+/**
+ * @test
+ * @bug 8048830
+ * @summary Tests keytool command imports certificate , list keystore, print
+ * certificate and import password help.
+ * @library /lib/testlibrary ../
+ * @run main StoreTrustedCertKeytool
+ */
+public class StoreTrustedCertKeytool {
+    private static final String PASSWORD = "passwd";
+    private static final String ALIAS = "testkey_stckey";
+    private static final String FILE_SEPARATOR = File.separator;
+    private static final String WORKING_DIRECTORY = System.getProperty(
+            "test.classes", "." + FILE_SEPARATOR);
+    private static final String CERT_PATH = WORKING_DIRECTORY
+            + FILE_SEPARATOR
+            + "cert.data";
+    private static final String KEYSTORE_PATH = WORKING_DIRECTORY
+            + FILE_SEPARATOR + "ks.pkcs12";
+
+    protected void run() throws IOException, KeyStoreException,
+            NoSuchAlgorithmException, CertificateException {
+        setUp();
+        importCert();
+        out.println("Import Cert test passed");
+        listCerts();
+        out.println("listCerts test passed");
+        printCert();
+        out.println("print cert test passed");
+        helpImportPassword();
+        out.println("help import test passed");
+    }
+
+    private void importCert() {
+        final String[] command = new String[]{"-debug", "-importcert",
+            "-alias", ALIAS, "-file", CERT_PATH, "-noprompt", "-keystore",
+            KEYSTORE_PATH, "-storetype", "pkcs12", "-storepass", PASSWORD};
+        // If the keystore exists delete it.
+        File keystoreFile = new File(KEYSTORE_PATH);
+        if (keystoreFile.exists()) {
+            keystoreFile.delete();
+        }
+        Utils.executeKeytoolCommand(command);
+    }
+
+    private void listCerts() throws IOException, KeyStoreException,
+            NoSuchAlgorithmException, CertificateException {
+        final String[] command = new String[]{"-debug", "-list", "-v",
+            "-alias", ALIAS, "-keystore", KEYSTORE_PATH, "-storetype", "pkcs12",
+            "-storepass", PASSWORD};
+        OutputAnalyzer output = Utils.executeKeytoolCommand(command);
+        if (output == null) {
+            throw new RuntimeException("Keystore print fails");
+        }
+        X509Certificate ksCert = null;
+        final KeyStore ks = Utils.loadKeyStore(KEYSTORE_PATH,
+                Utils.KeyStoreType.pkcs12, PASSWORD.toCharArray());
+        ksCert = (X509Certificate) ks.getCertificate(ALIAS);
+
+        if (ksCert == null) {
+            throw new RuntimeException("Certificate " + ALIAS
+                    + " not found in Keystore " + KEYSTORE_PATH);
+        }
+        String serialNumber = ksCert.getSerialNumber().toString(16);
+        output.shouldContain(serialNumber);
+    }
+
+    private void printCert() {
+        final String[] command = new String[]{"-debug", "-printcert",
+            "-file", CERT_PATH};
+        Utils.executeKeytoolCommand(command);
+
+    }
+
+    private void helpImportPassword() {
+        final String[] command = new String[]{"-debug", "-help",
+            "-importpassword"};
+        Utils.executeKeytoolCommand(command);
+    }
+
+    public static void main(String[] args) throws Exception {
+        final StoreTrustedCertKeytool test = new StoreTrustedCertKeytool();
+        test.run();
+        out.println("Test Passed");
+    }
+
+    private void setUp() {
+        Utils.createKeyStore(Utils.KeyStoreType.pkcs12, KEYSTORE_PATH, ALIAS);
+        Utils.exportCert(Utils.KeyStoreType.pkcs12, KEYSTORE_PATH, ALIAS,
+                CERT_PATH);
+        new File(KEYSTORE_PATH).delete();
+    }
+}
diff --git a/jdk/test/java/security/KeyStore/PKCS12/Utils.java b/jdk/test/java/security/KeyStore/PKCS12/Utils.java
new file mode 100644
index 0000000..2689415
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/Utils.java
@@ -0,0 +1,137 @@
+/*
+ * 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
+ * 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.
+ */
+
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.util.Arrays;
+import java.util.List;
+import jdk.testlibrary.ProcessTools;
+import jdk.testlibrary.OutputAnalyzer;
+import jdk.testlibrary.JDKToolFinder;
+import static java.lang.System.out;
+import java.util.ArrayList;
+
+/**
+ * Helper class for creating keystore and executing keytool commands
+ */
+public class Utils {
+    public enum KeyStoreType {
+        jks, pkcs12;
+    }
+    public static final String DEFAULT_DNAME
+            = "CN=TestKey, T=FuncTestCertKey, O=Oracle, OU=JDKSQE, C=US";
+    public static final String DEFAULT_PASSWD = "passwd";
+    public static final String RSA = "rsa";
+    public static final String JAVA_HOME = System.getProperty("java.home");
+    public static final String KEYTOOL = "keytool";
+    private static final int SUCCESS_EXIT_CODE = 0;
+
+    public static OutputAnalyzer executeKeytoolCommand(String[] command) {
+        return executeKeytoolCommand(command, SUCCESS_EXIT_CODE);
+    }
+
+    public static OutputAnalyzer executeKeytoolCommand(String[] command,
+            int exitCode) {
+        String[] keytoolCmd = new String[command.length + 1];
+        OutputAnalyzer output = null;
+        try {
+            keytoolCmd[0] = JDKToolFinder.getJDKTool(KEYTOOL);
+            System.arraycopy(command, 0, keytoolCmd, 1, command.length);
+            output = ProcessTools.executeCommand(keytoolCmd);
+            output.shouldHaveExitValue(exitCode);
+            out.println("Executed keytool command sucessfully:"
+                    + Arrays.toString(keytoolCmd));
+        } catch (Throwable e) {
+            e.printStackTrace(System.err);
+            throw new RuntimeException("Keytool Command execution failed : "
+                    + Arrays.toString(keytoolCmd), e);
+        }
+        return output;
+    }
+
+    public static void createKeyStore(KeyStoreType type, String name,
+            String alias) {
+        createKeyStore(DEFAULT_DNAME, type, name, alias, RSA);
+    }
+
+    public static void createKeyStore(String dName, KeyStoreType type,
+            String name, String alias, String algorithm,
+            String... optionalArgs) {
+        createKeyStore(dName, type, name, alias, algorithm, optionalArgs,
+                SUCCESS_EXIT_CODE);
+    }
+
+    public static void createKeyStore(String dName, KeyStoreType type,
+            String name, String alias, String algorithm,
+            String[] optionalArgs, int exitCode) {
+        String[] command = new String[]{"-debug", "-genkeypair", "-alias",
+            alias, "-keystore", name, "-dname", dName, "-storepass",
+            DEFAULT_PASSWD, "-keypass", DEFAULT_PASSWD, "-validity", "7300",
+            "-keyalg", algorithm, "-storetype", type.name()};
+        if (optionalArgs != null && optionalArgs.length > 0) {
+            List<String> commandArgs = new ArrayList<>(Arrays.asList(command));
+            List<String> temp = Arrays.asList(optionalArgs);
+            commandArgs.addAll(temp);
+            if (!commandArgs.contains(("-keysize"))) {
+                commandArgs.add("-keysize");
+                commandArgs.add("1024");
+            }
+            command = commandArgs.toArray(new String[commandArgs.size()]);
+        }
+        executeKeytoolCommand(command, exitCode);
+    }
+
+    public static void exportCert(KeyStoreType type, String name,
+            String alias, String cert) {
+        String[] command = {"-debug", "-exportcert", "-keystore", name,
+            "-storetype", type.name(), "-storepass", DEFAULT_PASSWD, "-alias",
+            alias,"-file",cert,"-noprompt"};
+        executeKeytoolCommand(command);
+    }
+
+    public static KeyStore loadKeyStore(String file, KeyStoreType type,
+            char[] passwd)
+            throws IOException, KeyStoreException,
+            NoSuchAlgorithmException, CertificateException {
+        KeyStore ks = KeyStore.getInstance(type.name());
+        try (FileInputStream fin = new FileInputStream(file)) {
+            ks.load(fin, passwd);
+        }
+        return ks;
+    }
+
+    public static void saveKeyStore(KeyStore ks, String file, char[] passwd)
+            throws IOException, KeyStoreException, NoSuchAlgorithmException,
+            CertificateException {
+        try (FileOutputStream fout = new FileOutputStream(file)) {
+            ks.store(fout, passwd);
+        }
+    }
+}
diff --git a/jdk/test/java/security/KeyStore/PKCS12/WriteP12Test.java b/jdk/test/java/security/KeyStore/PKCS12/WriteP12Test.java
new file mode 100644
index 0000000..f402409
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/WriteP12Test.java
@@ -0,0 +1,371 @@
+/*
+ * Copyright (c) 2003, 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.
+ */
+
+import static java.lang.System.out;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.security.Key;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Enumeration;
+
+/*
+ * @test
+ * @bug 8048618
+ * @summary Write different types p12 key store to Check the write related
+ *  APIs.
+ * @run main WriteP12Test
+ */
+
+public class WriteP12Test {
+
+    private static final String IN_KEYSTORE_TYPE = "jks";
+    private static final String IN_KEYSTORE_PRV = "SUN";
+
+    private static final String IN_KEYSTORE_ENDUSER = "keystoreEU.jks.data";
+    private static final String IN_KEYSTORE_CA = "keystoreCA.jks.data";
+    private static final String OUT_KEYSTORE = "outKeyStore.p12";
+
+    private static final String IN_STORE_PASS = "storepass";
+    private static final String IN_KEY_PASS = "keypass";
+
+    private static final String CERT_PATH = System.getProperty("test.src", ".")
+            + File.separator + "certs" + File.separator + "writeP12"
+            + File.separator;
+
+    private static final String CA_CERT_STR = "-----BEGIN CERTIFICATE-----\n"
+            + "MIIDFzCCAf8CBD8+0nAwDQYJKoZIhvcNAQEFBQAwUDELMAkGA1UEBhMCV\n"
+            + "VMxETAPBgNVBAoTCEphdmFTb2Z0MRUwEwYDVQQLEwxTZWN1cml0eSBTUU\n"
+            + "UxFzAVBgNVBAMTDlBLQ1MxMiBUZXN0IENBMB4XDTAzMDgxNzAwNTUxMlo\n"
+            + "XDTEzMDgxNDAwNTUxMlowUDELMAkGA1UEBhMCVVMxETAPBgNVBAoTCEph\n"
+            + "dmFTb2Z0MRUwEwYDVQQLEwxTZWN1cml0eSBTUUUxFzAVBgNVBAMTDlBLQ\n"
+            + "1MxMiBUZXN0IENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQ\n"
+            + "EAk7Sh+K/yGsmJacZnjfkZfuWxGNJCPW0q69exwoRP+eBHMQwG00yi9aL\n"
+            + "SsZAqNpJSCDvpgySOAUmBd+f8WFhHqJfRVREVfv3mradDKZCjhqtsUI7I\n"
+            + "wRTYYy9clFkeeK4dHaxbuFMPpUu7yQfwSTXgvOA/UJ4kJuGtaYAdTJI4e\n"
+            + "f1mUASo6+dea0UZA/FHCuV7O6z3hr5VHlyhJL2/o/8M5tGBTBISODJSnn\n"
+            + "GNBvtQLNHnWYvs470UAE2BtuCGYh1V/3HAH1tRirS3MBBcb1XnIkiiXR3\n"
+            + "tjaBSB+XhoCfuG8KtInXXFaAnvKfY9mYFw6VJt9JYQpY2VDC7281/Pbz0\n"
+            + "dQIDAQABMA0GCSqGSIb3DQEBBQUAA4IBAQBzXZ8zHWrnC8/E+N/n2Czhx\n"
+            + "i18YQc2LPWBDLYTTxoFEazWmYLv1k/JT7Nta1qu1quvxXJ4uV1XHbd9NF\n"
+            + "AJWKwtFQEpfv4o6I7qWUPoxnfA+jyqKXxv27z25tzt+Y4xOEhqvO03G0Q\n"
+            + "imhkiNt9MF7L69y2U0/U73+uFNGzdAEDiI9EibvICiOnr1TeQ5GekK3Yb\n"
+            + "k5qe3lviMZPkkSXepTJI8m0AiXCji+eXj97jVLeH+RxeBchBY+uELrqUr\n"
+            + "sVOVWh7IBCqC/V7FqUTkmD1IFlzkkinatpl42s1MbhJId2yQkzaeBRc\n"
+            + "suE63bDEtuRWp9ynMO3QA4Yu85uBRWGzQ1Di\n"
+            + "-----END CERTIFICATE-----";
+    private static final String LEAD_CERT = "-----BEGIN CERTIFICATE-----\n"
+            + "MIICwDCCAaigAwIBAgIEPz7S1jANBgkqhkiG9w0BAQQFADBQMQswCQYDV\n"
+            + "QQGEwJVUzERMA8GA1UEChMISmF2YVNvZnQxFTATBgNVBAsTDFNlY3VyaX\n"
+            + "R5IFNRRTEXMBUGA1UEAxMOUEtDUzEyIFRlc3QgQ0EwHhcNMDAwODA5MDc\n"
+            + "wMDAwWhcNMTAwODA3MDcwMDAwWjBSMQswCQYDVQQGEwJVUzERMA8GA1UE\n"
+            + "ChMISmF2YVNvZnQxFTATBgNVBAsTDFNlY3VyaXR5IFNRRTEZMBcGA1UEA\n"
+            + "xMQUEtDUzEyIFRlc3QgTGVhZDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgY\n"
+            + "kCgYEAzq9X2USz/WjDhT+jUyZWqB5h4A33tS11YqH5qYvqjTXjcUI6gOp\n"
+            + "moXMafDG9RHRlIccvp51xLp7Ap3WMrv411lWBttqtZi5c1/DEC1cEM/Sl\n"
+            + "PCk1r2zFbkJu7QKieXeMcrjZEo6LcBHMwQjIpI+up9cr3VjuyqG/olQkU\n"
+            + "mXVuS0CAwEAAaMkMCIwDwYDVR0PAQH/BAUDAweAADAPBgNVHRMBAf8EBT\n"
+            + "ADAQH/MA0GCSqGSIb3DQEBBAUAA4IBAQBhbuim98TWmtv9vSldRE7RvQ8\n"
+            + "FlS0TyZVO7kcSNtfCUE4R76J1ElN74Koc5pQnUtduLeQJs2ao/mEcCZsE\n"
+            + "zVcwI3mSZrSzPhc8s7w5gOQA4TUwVLSSjKgBCaZ7R3+qJ3QeqPJ5O6sFz\n"
+            + "pvBYkgSa4MWptK41jbmT8cwZQJXFCi8WxFFJ+p97F1Ppm3LgmYmtiUP4M\n"
+            + "ZQwOBvpTZWXU0WrqFXpzWQx0mg4SX19fZm4nLcJAerCEUphf8ILagtpQM\n"
+            + "EErT3/jg6mfCdT3Rj055QXPfF4OiRFevPF5a1fZgrCePCukRQZcd7s8K5\n"
+            + "OBIaryuM0MdFtlzxi6XWeUNpVFFHURcy\n"
+            + "-----END CERTIFICATE-----";
+    private static final String END_CERT = "-----BEGIN CERTIFICATE-----\n"
+            + "MIICNjCCAZ+gAwIBAgIEPz7WtzANBgkqhkiG9w0BAQQFADBSMQswCQYDV\n"
+            + "QQGEwJVUzERMA8GA1UEChMISmF2YVNvZnQxFTATBgNVBAsTDFNlY3VyaX\n"
+            + "R5IFNRRTEZMBcGA1UEAxMQUEtDUzEyIFRlc3QgTGVhZDAeFw0wMDA4MDk\n"
+            + "wNzAwMDBaFw0xMDA4MDcwNzAwMDBaMFgxCzAJBgNVBAYTAlVTMREwDwYD\n"
+            + "VQQKEwhKYXZhU29mdDEVMBMGA1UECxMMU2VjdXJpdHkgU1FFMR8wHQYDV\n"
+            + "QQDExZQS0NTMTIgVGVzdCBFbmQgVXNlciAxMIGfMA0GCSqGSIb3DQEBAQ\n"
+            + "UAA4GNADCBiQKBgQDIKomSYomDzH/V63eDQEG7od0DLcnnVZ81pbWhDss\n"
+            + "8gHV2m8pADdRqdihBmnSQEaMW4D3uZ4sFE1LtkQls6hjd7SdOsG5Y24L8\n"
+            + "15jot9a2JcB73H8H0VKirrObL5BZdt7BtASPDnYtW4Spt++YjDoJFxyF0\n"
+            + "HchkavzXaVTlexakwIDAQABoxMwETAPBgNVHQ8BAf8EBQMDB4AAMA0GCS\n"
+            + "qGSIb3DQEBBAUAA4GBAIFA3JXEmb9AXn3RD7t+Mn6DoyVDIy5jsn6xOKT\n"
+            + "JV25I0obpDUzgw4QaAMmM0ZvusOmZ2wZNS8MtyTUgdANyakbzn5SdxbTy\n"
+            + "TLEqQsFbX8UVC38fx5ZM6ExA5YSAvgmXudZpOVC0ATccoZS3JFU8CxSfW\n"
+            + "+Q3IC2MLh+QTg3hUJ5b\n-----END CERTIFICATE-----";
+
+    private final Certificate testerCert;
+    private final Certificate testLeadCert;
+    private final Certificate caCert;
+
+    WriteP12Test() throws CertificateException {
+        CertificateFactory cf = CertificateFactory.getInstance("X.509");
+        caCert = cf.generateCertificate(new ByteArrayInputStream(CA_CERT_STR
+                .getBytes()));
+        testLeadCert = cf.generateCertificate(new ByteArrayInputStream(
+                LEAD_CERT.getBytes()));
+        testerCert = cf.generateCertificate(new ByteArrayInputStream(END_CERT
+                .getBytes()));
+    }
+
+    public static void main(String[] args) throws CertificateException,
+            UnrecoverableKeyException, KeyStoreException,
+            NoSuchProviderException, NoSuchAlgorithmException, IOException {
+        WriteP12Test jstest = new WriteP12Test();
+        out.println("test WriteP12CertChain");
+        /*
+         * WriteP12CertChain: This test creates a p12 keystore contains one
+         * entry with private key and a certificate chains contains three
+         * certificates in the order of user->lead->ca. This case expects to
+         * pass.
+         */
+        jstest.test(new Certificate[] { jstest.testerCert, jstest.testLeadCert,
+                jstest.caCert }, IN_KEYSTORE_ENDUSER, "pkcs12testenduser1",
+                "pass", "pass");
+
+        /*
+         * WriteP12CertChainBad: same as WriteP12CertChain but chains order is
+         * user-ca-lead, the order is wrong so expects to fail.
+         */
+        out.println("test WriteP12CertChainBad");
+        try {
+            jstest.test(new Certificate[] { jstest.testerCert, jstest.caCert,
+                    jstest.testLeadCert }, IN_KEYSTORE_ENDUSER,
+                    "pkcs12testenduser1", "pass", "pass");
+            throw new RuntimeException(
+                    " Certificate chain is not valid, test should not pass."
+                            + " Test failed.");
+        } catch (KeyStoreException e) {
+            e.printStackTrace();
+            out.println(" Certificate chain is not valid,exception is"
+                    + " expected. Test passed.");
+        }
+        /*
+         * WriteP12PrivateKey:This test creates a p12 contains a self-signed
+         * cert and private key,expects no exception
+         */
+        out.println("test WriteP12PrivateKey");
+        jstest.test(null, IN_KEYSTORE_ENDUSER, "pkcs12testenduser1", "pass",
+                "pass");
+
+        /*
+         * WriteP12TwoEntry: This test creates a p12 keystore with different
+         * storepass and keypass, and contains two entries.
+         */
+        out.println("test WriteP12TwoEntry");
+        jstest.testTwoEntry(IN_KEYSTORE_ENDUSER, IN_KEYSTORE_CA,
+                "pkcs12testenduser1", "pass", "pass");
+        /*
+         * WriteP12TwoPass: This test creates a p12 keystore with different
+         * storepass and keypass, and contains one entry with private key and a
+         * certificate
+         */
+        out.println("test WriteP12TwoPass");
+        jstest.test(null, IN_KEYSTORE_CA, "pkcs12testCA", "storepass",
+                "keypass");
+    }
+
+    private void test(Certificate certs[], String inKeyStorePath,
+            String userAlias, String outStorePass, String outKeyPass)
+            throws KeyStoreException, NoSuchProviderException, IOException,
+            CertificateException, UnrecoverableKeyException,
+            NoSuchAlgorithmException {
+        // init output key store
+        KeyStore outputKeyStore = KeyStore.getInstance("pkcs12", "SunJSSE");
+        outputKeyStore.load(null, null);
+        try (FileOutputStream fout = new FileOutputStream(OUT_KEYSTORE)) {
+            // KeyStore have encoded by Base64.getMimeEncoder().encode(),need
+            // decode first.
+            byte[] input = Files.readAllBytes(Paths.get(CERT_PATH,
+                    inKeyStorePath));
+            ByteArrayInputStream arrayIn = new ByteArrayInputStream(Base64
+                    .getMimeDecoder().decode(input));
+            // input key store
+            KeyStore inputKeyStore = KeyStore.getInstance(IN_KEYSTORE_TYPE,
+                    IN_KEYSTORE_PRV);
+            inputKeyStore.load(arrayIn, IN_STORE_PASS.toCharArray());
+            // add key/certificate to output key store
+            Key key = inputKeyStore
+                    .getKey(userAlias, IN_KEY_PASS.toCharArray());
+            out.println("Input Key Algorithm " + key.getAlgorithm());
+            out.println("====Input Certs=====");
+            if (certs == null) {
+                certs = new Certificate[] { inputKeyStore
+                        .getCertificate(userAlias) };
+            }
+            for (Certificate cert : certs) {
+                out.println(((X509Certificate) cert).getSubjectDN());
+            }
+            outputKeyStore.setKeyEntry(userAlias, key,
+                    outKeyPass.toCharArray(), certs);
+            Certificate retCerts[] = outputKeyStore
+                    .getCertificateChain(userAlias);
+            out.println("====Output Certs=====");
+            for (Certificate retCert : retCerts) {
+                out.println(((X509Certificate) retCert).getSubjectDN());
+            }
+            out.println("====Output Key Algorithm=====");
+            Key outKey = outputKeyStore.getKey(userAlias,
+                    outKeyPass.toCharArray());
+            out.println(outKey.getAlgorithm());
+
+            if (!key.equals(outKey)) {
+                throw new RuntimeException("key don't match");
+            }
+            if (!Arrays.equals(certs, retCerts)) {
+                throw new RuntimeException("certs don't match");
+            }
+            // save output
+            outputKeyStore.store(fout, outStorePass.toCharArray());
+            // test output
+            testKeyStore(outputKeyStore, outKeyPass.toCharArray());
+        }
+    }
+
+    private void testTwoEntry(String inKeyStoreOnePath,
+            String inKeyStoreTwoPath, String userAlias, String outStorePass,
+            String outKeyPass) throws KeyStoreException,
+            NoSuchProviderException, NoSuchAlgorithmException,
+            CertificateException, IOException, UnrecoverableKeyException {
+        // initial KeyStore
+        KeyStore outputKeyStore = KeyStore.getInstance("pkcs12", "SunJSSE");
+        try (FileOutputStream fout = new FileOutputStream(OUT_KEYSTORE);) {
+            outputKeyStore.load(null, null);
+            KeyStore inputKeyStoreOne, inputKeyStoreTwo;
+            inputKeyStoreOne = KeyStore.getInstance(IN_KEYSTORE_TYPE,
+                    IN_KEYSTORE_PRV);
+            // KeyStore have encoded by Base64.getMimeEncoder().encode(),need
+            // decode first.
+            byte[] inputBytes = Files.readAllBytes(Paths.get(CERT_PATH,
+                    inKeyStoreOnePath));
+            ByteArrayInputStream arrayIn = new ByteArrayInputStream(Base64
+                    .getMimeDecoder().decode(inputBytes));
+            // input key store
+            inputKeyStoreOne.load(arrayIn, IN_STORE_PASS.toCharArray());
+
+            inputBytes = Files.readAllBytes(Paths.get(CERT_PATH,
+                    inKeyStoreTwoPath));
+            arrayIn = new ByteArrayInputStream(Base64.getMimeDecoder().decode(
+                    inputBytes));
+            inputKeyStoreTwo = KeyStore.getInstance(IN_KEYSTORE_TYPE,
+                    IN_KEYSTORE_PRV);
+            inputKeyStoreTwo.load(arrayIn, IN_STORE_PASS.toCharArray());
+
+            // add key/certificate to output key store
+            out.println("====First Entry=====");
+            Key inputKey = inputKeyStoreOne.getKey(userAlias,
+                    IN_KEY_PASS.toCharArray());
+            Certificate cert = inputKeyStoreOne.getCertificate(userAlias);
+            Certificate certs[] = new Certificate[1];
+            certs[0] = cert;
+
+            out.println("====Input1 Key=====");
+            out.println(inputKey.getAlgorithm());
+            out.println("====Input1 Certs=====");
+            out.println("Certificate :");
+            out.println(((X509Certificate) cert).getSubjectDN());
+            outputKeyStore.setKeyEntry("USER", inputKey,
+                    outKeyPass.toCharArray(), certs);
+            out.println("====Second Entry=====");
+            String caAlias = "pkcs12testca";
+            inputKey = inputKeyStoreTwo.getKey(caAlias,
+                    IN_KEY_PASS.toCharArray());
+            cert = inputKeyStoreTwo.getCertificate(caAlias);
+            certs[0] = cert;
+            out.println("====Input2 Key=====");
+            out.println(inputKey.getAlgorithm());
+            out.println("====Input2 Certs=====");
+            out.println("Certificate :");
+            out.println(((X509Certificate) cert).getSubjectDN());
+            outputKeyStore.setKeyEntry("CA", inputKey,
+                    outKeyPass.toCharArray(), certs);
+            // save output
+            outputKeyStore.store(fout, outStorePass.toCharArray());
+            // test output
+            testKeyStore(outputKeyStore, outKeyPass.toCharArray());
+        }
+    }
+
+    private void testKeyStore(KeyStore inputKeyStore, char[] keypass)
+            throws KeyStoreException, UnrecoverableKeyException,
+            NoSuchAlgorithmException {
+        out.println("========== Key Store ==========");
+        out.println("getProvider : " + inputKeyStore.getProvider());
+        out.println("getType : " + inputKeyStore.getType());
+        out.println("getDefaultType : " + KeyStore.getDefaultType());
+
+        int idx = 0;
+        Enumeration<String> e = inputKeyStore.aliases();
+        String alias;
+        while (e.hasMoreElements()) {
+            alias = e.nextElement();
+            if (!inputKeyStore.containsAlias(alias)) {
+                throw new RuntimeException("Alias not found");
+            }
+            out.println("Alias " + idx + " : " + alias);
+            out.println("getCreationDate : "
+                    + inputKeyStore.getCreationDate(alias));
+            X509Certificate cert = (X509Certificate) inputKeyStore
+                    .getCertificate(alias);
+            out.println("getCertificate : " + cert.getSubjectDN());
+            String retAlias = inputKeyStore.getCertificateAlias(cert);
+            if (!retAlias.equals(alias)) {
+                throw new RuntimeException("Alias mismatch, actually "
+                        + retAlias + ", expected " + alias);
+            }
+            out.println("getCertificateAlias : " + retAlias);
+            Certificate[] certs = inputKeyStore.getCertificateChain(alias);
+            int i = 0;
+            for (Certificate certification : certs) {
+                out.println("getCertificateChain " + i
+                        + ((X509Certificate) certification).getSubjectDN());
+                i++;
+            }
+            if (inputKeyStore.isCertificateEntry(alias)) {
+                throw new RuntimeException(
+                        "inputKeystore should not be certEntry because this"
+                                + " keystore only contain key pair entries.");
+            }
+            if (!inputKeyStore.isKeyEntry(alias)) {
+                throw new RuntimeException("Entry type unknown.");
+            }
+            idx++;
+        }
+        int size = inputKeyStore.size();
+        if (idx != size) {
+            throw new RuntimeException("Size not match, actually " + idx
+                    + ", expected " + size);
+        }
+    }
+
+}
diff --git a/jdk/test/java/security/KeyStore/PKCS12/api_cert_chain.p12.data b/jdk/test/java/security/KeyStore/PKCS12/api_cert_chain.p12.data
new file mode 100644
index 0000000..b4da479
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/api_cert_chain.p12.data
@@ -0,0 +1,76 @@
+MIIQ6AIBAzCCEKIGCSqGSIb3DQEHAaCCEJMEghCPMIIQizCCBXAGCSqGSIb3DQEHAaCCBWEEggVd
+MIIFWTCCBVUGCyqGSIb3DQEMCgECoIIE+jCCBPYwKAYKKoZIhvcNAQwBAzAaBBSKdWqt6IsXyQA9
+6SNtYnk7vaT/CQICBAAEggTIv5XR91OsI7r831ltprYhtOfAhl3TFKj+cqnohJF1xm60K5dQN5BZ
+enfVw4YPbCTR16+zTiGyHJ/MFELwOrOogPdSQBTuy1PtUZOfskD/EKFQaCVSQ1omNlgOWqVh0dhF
+TMjw6KLaTfhwx2Qw3aLIjhy7rvS5SEsUbGZ/IvJ7ym+DHzFuP8oQFfISUkNxh7wOqk4BSsY1Yh9H
+JbK7Y7JtWReDTbAtuACQSPO0Z7RSWKC2y29cG6x3gIiB8iKTNrPKc6m0wb48RKipzF6r35GQRMoS
+rsordIc22RS/KYFfU4W9LAdV+/vJBuZazc+3MgcOXYUWDaMpAG697aim1yDjudcVnPoUdzdWQvAj
+Z7dHqeplZ8h4Ur+dKH3EeWoipXBXhVI0i9hFbOU+36OZ96LUjlRfaAI3NXVMEa9+kATwDHh9cqnQ
+1zkbVPCXBY6Y6+wnq5o0mpES++MCc8zELiFYZOJl6UWBE/D16QAv+6Qd/JHmRaZfNt+vNxKm1ltm
+nvdyWcO4FlF9F5cC66AS3NcdZ94GNkRBW964+yaUCFHCeVGSfwxqox++akNOyfrw9lP8a24usPLj
+ScueTLGCftprwUGLb9g/zRhPWBHrYELbUplER+KQeWnX84OqyAZXNnBUFhrH8CBJAPDIVCpZj7ti
+Z23eQoplPpL+z/CYKqx1BTk+E82+Z3cXXRhgiguXHqJhf8mR+3ZGsNsS0r23AnHQGJVvh09wbb02
+o1fAJpOkw34GGoLwqstakkO1/nKO2ln2g7UTdkzcGp9GCrhbxAmZ0jXjPy5RFG1m4yEhjAJ/lnRm
+3bwCb3z1mBjtrRO9hnb4iQBzwpvctHlVzAUh77JTbUzsu7TxrranUq2+Z1MWjqsymoPjDxct0GK0
+WrWV5iwVTIB73CW7IcKbAKVxsus9kRjbLaLxkfio6HGiYz2e+30CJX8sB5DPLBjfAZQiWMkq0k3T
+SfAKPRSlX7okdrXpfON57naUPw6biIcbDQovH7sMDSP58VLiGI7CNUuj5rhGu9O6Jhc6n5/krhjI
+W7xUkXZmZPq2yww1OSSD3LF4K7Uu6ukZMQU5NfUOVeeAkq+4RMns/nZdQd3JhP0CyuF4vLrEWq8n
+6WD+Sta3ZvCxbLPs9xylnlqevmq0zUhxbY7gzObEMGH1YpZT/nSjHpAbt0bcwFIiFncCC0t9/d07
+REJjWvG7J0GB9cNb4aNbE05fCx0tlipyNu2GASwT8fw0tPXrcdaHxL+1+/fDdLlsnrODN+Hvx2GC
+oixNMf1NSC1M0evf/8tqPDwwUBcKdFumILwEeWHwOP7Tx3/2eRfSPP3e6iGDYv0KrzHzWV2uyoXj
+bTwfRHs4W+71v91dtrKH8Q+IRKxkiSKdT0KnpDkGlnFwK88TAZso6L1agTshdtjvwNAJ/yaIN1S7
+FBBKcM2/rc3SJwNTmjsHrX3C8VvenO6rAxBvn151pzMjCY9eijJwnUKHEB8V3wSP+eSM/INL1swA
+BPIJba5Jg5Zhch4SpV8B5rjxAz+qkiLlGOxbsPeyfv3jzINZhkBqRtBA3gLxJjPgfPlu2s3U+HBa
+iHm0/K6VlSztjs4Ez30tfgym6vbWv/rrRXNfUqWumNqC5LXyDbVy7MarS5iKMUgwIwYJKoZIhvcN
+AQkUMRYeFABzAGUAcgB2AGUAcgBjAGUAcgB0MCEGCSqGSIb3DQEJFTEUBBJUaW1lIDE0MzI2OTE3
+MzM4NTgwggsTBgkqhkiG9w0BBwagggsEMIILAAIBADCCCvkGCSqGSIb3DQEHATAoBgoqhkiG9w0B
+DAEGMBoEFMrHJAy5G2zs/2U91Kv84axmE50HAgIEAICCCsDf0VQQ5aHERkv1me9S5cr3KQ73vg0h
+gawyFpFcMRGhzwMggy460MuwHIJk9aQ9rlvGi7FNWsPdBrwpJzyU6LFHUl5w/L94hjULrHeSaJ3T
+oltDs8jMK+I7Bx3B96kc5GvYzOlaq3OtRbITPs47a4qA7/TTAJxYC5pgTXiulu4lZ/scaHnBQc2N
+wX6ZFSKMz38lzEllA+ndnhgLNrL7yozrVFslFu0XrDcZC8ga4tm59rn/Dzmyz+hPcK+JKv7nq5gt
+MTGOGwtmaWUh/kSKPNETWVasa7UDlYexSwSadNlDSxWCHXEXb3YXOVvLDbnVB8OmWChBlw78vz/9
+UmeTpaCvH3SbgulOzW1TgsV4R7oTkib/Ck2R1XBPOssDg56VSeRrsd1pVy1GKxUsD/T5tih7wK1I
+IiLPrAh488GELpPadKjsv/990OSbv0q72V4kJWXn6m9RsQVGaOV2QiEjQPWSCq0FEglD8ikpg44X
+HpdCf5hL87iY1z0zONG8OP0IMEEJn091wfegCJZu5XsvT9PFaBm4mjMol1Hr1ZT/w6Qzfc/AmKn2
+serI/uAzOoMWGOEtzpof8M+DFD1saMCRG9Lf4A6fkub2968ZMbiSsdIu2YJefcOMWtmcW277l1Pz
+EjNlLXV40bfv/0tnBlbD2dYfGS2iCi4eMsWEWbV2kBq9gie24+NsDSlGXZjd7x9F0D7xUKGlXnR/
+4NzEilOURjEvxJloqd88K4xM1ZUELm/OYZwIkOmDZdqR1/8Wh82TYW5Mq4NKUbfltTOcvLE0fM5N
+VGyio8qGEVzgLWOGnh7V73QMBidu3cTWKf/OYYp13ywF0CxsGRVZmskFa3uH0C2pAoWnx13Plmo8
+lLtDFtxQ+u9ZBn8dZDGDD4gY2YSYj08/5MBWZQ5EWVLwn9A6xNGQMhFUuFhjmKCuulScaJ6v9aW4
+QBg5SfWzfuYD1G922wx7/TtQFBVR4NIKxTOroIjSpI+lYriNDa3c1UYRa+DY8suC90Wz90sbR37T
+QGOenU/QCSavPIiVijQzQbXz4eEMhddIwoCHTtkn4NgUO+pn4zMl9jCrwwMCSG1t2DZ1L6y67q4Q
+UnI0mU/O8cqglykl5Rz9G2TraHMv5SMGyHgi/jKyfGfAZriopPHWsXXNs85okMoM8j3YCFsM7EJ9
+l4We6J4euWK9WM7YboiSgKltJGXUgTU0l2HYN17ihF3sY3PaBiLdrNARM9blkzAhdhx0Q3NNFn3N
+7g0PniTkvW07aZoemdN/yric2grhC5P3rkuaw0j/AwTDC68ReJbOmdn7Gmv+4RSIXN9DIM/JV0Dd
+Xn06zLhnl9mim5hLtB1+f0E4oSz1MOOh1qoajm/lpr4o7zyHjb3v8mKrTMXvYO4PiQZ5HKWgvbB3
+iMCvdn859bv5X5ckz2SVtpnTjYTemICmEPRk7hRb/DZJkMptlhG2uFIq1ZUSDwVMGrrnRkEwlyLT
+f7wU5C2KoNGVgGhF9W6w/RBzYyTFVrsCTxpR9M9Jy875JnCmOBYUQLoDno+4qR00a70R2AdG7c3q
+gCZQBLzKqEp+gu0YUPGZzda1i8RhSF6c0w2A7ToynDf9gTbKSsyV1iblTm1UhjG/lXtU/9rzOMth
+7ZCrvd1EZGbmn2SP+CsQzoGMh9T0j+FygWx1u/yYO0kRXCjcyzOVq+p+XraDwxiI+GNcqNkrVKUW
+kIJO6ajXZg0cNekZyhiR3vLdY5EOBVWahvTnWFrEPpNt6tavVHyQ+AJP5t3VLq16AkBGgICYAdnG
+zKUgim96I0xNd37EKTmIlBccpNc0uVLgGEzuQiONBBcZPUwD6y4EvJnLmEaOdgRYjcaO8aeuIX/U
+VEC4zQEXI99ghQ7TWuNNOwyR+kyKQQsER5GRct9fzv6qMk0Xei914IdbL7DAy2pSfyaYNNlk339H
+/ji5lQPG1y8qQAw6sDtQPt0LcHg3bMX5Q/r1/LmlpML7rOUz1QwVH7QdHrHWjGvC1kjrmGtZjB7j
+XwQMItY3n/J1/vBfeuSk3sgWeHBYxgmnIjhqMVEoTSTUyelfrOte9N+5fomUWqnujl6rmqHl62oO
+695wUiKq6BVpXQtJEhqauQYAQ+DoGn3Klbmd5iHaqG5PU68wtEQPtSvXG6RPtteUi/H2jpnaG/Z+
+6HVQejCGJrZ4h1C/afq7WnCg5ZM8dy9zE02+CtqTq1hEiXF5mF6rhpKgxJZLlWk8wq0zP47ahnI+
+0VyAljgH5CW5BOwGrZdV8LHPbk+gVhqqBYIw/05HACbO4K32rEEUuvK+DSYQ0wxY8ufa1QttqQnv
+YRQ3XU+M4reL3pDJwPg+3LGP7jcIEqUY+trGeWbhASAETsLUURYuIkAydPKkEvb1rFPJGfiuMAVi
+PhSSTvDSrV8FZR9NNTr7zeHAbbJWArKi0hcv67noStYzBQT++SuiD5stp9Ym4DCE6/sAIR7Sa/1Y
+rhViLtpHp06WzkXi5lSVBCpJjaWKznmQp580gyAjjOx3mRqkEwx440yJq0LfqTdF8jiV2IZhjiT3
+MjdanLQOlldjGL64SpIKCQ0FzQcnB+sNbTtkYSRR9x4ImNYFGQpQtXimbAJAlaS5R4bOLbOygO/C
+mUDjpo1NkTIyAe/YzALpbCyJqaEOPm5Yp+1C6EQfb+DUxv2MyUWNuKw0xvFWhy4TuCCsrzIfQLYi
+2UxpILq8zr8ZhPUGv6KnN4j+jTo92A3DvtBbTLdRLf1n6hfAhWAOBmGu7c8N0kmfNcDJuWtvsG08
+1+xqLNni149FrNDzMjLwMg2YwaHJuwdKZsMcRtEfmGi2uAsTthsq6MxMHZPBFqNaNwrcaN7+PEK1
+c21PW/X6+kATvCRpKJxlChyZE5yEanvsIwpFB9IRmyEZIyYnCIcFl08Mbaw9jGdlxg32VdjIdQTY
+LVQ/8NOQGuz8RJepxoBQQ4dveiWJTPeEY879EC+3U8NgA84O3YZKfNxE4uSbjeGKu4tvVp5DoByW
+H7ZZWKAScltteuKFpP4ME6gGwvgF122HNzfrwztjcooIGfsxRvRSNerbAVjyZbBy3jC/3m3pOmqy
+kJfzhbVqEesBRCJKaCXVHZRSoziSqlwtMgbU+tPYGMERJT727cIFFKhqLILybZbc6LKI/SV852TD
+JXQ420HZX76GTSEWURDsu8glvYuGVosvBdg/63lVf8z15vJiaFbJEQDR7dHAquTAsynB2PVUErhJ
+sNz4kuQRbRoD6vS07fM2avNTLouZUX3bpwugyumgl2H0lvxLWXnXelFHnIc7NzdEqx6oS1YZBgq3
+7U21OG5t9hA02eZZT+LrcAWH1NUV2fFWps60WHKdCKcIN7w/vy/D8dDr1jdOppdubN35oR5ZOwob
+HYjk/KepGNTDeH8el2SX9yhjj5a0aTtMTdy/DvpAN7u9Xaq0bRH1lZZyE0n4F1MysND8sWwQPTH8
+uJoD4msqelGrx81lThyhwwk/8+2AWGG0sU9l0sK4xMmeMCPtdGdg9C4g5m08mHoa/etbOj+7spqf
+MG4Gq1hLOygsHwFRRQe3eRi4BSoE7HvgdyP84qVnLnc4g0RDLhFdDgyBLGTYRqpCX8iZA4Nf4uRJ
+pteB+CANzKjx9HqxBO/jGtOwFBg0eSXBU4d4CI6MoAS4NxUjlqhIGEKJBwJ78jPsCq2JMD0wITAJ
+BgUrDgMCGgUABBTxMWXHZ4F5ADtYXqKlpD5cMihu7wQUsiXIcUR/3TChw09nR5rrIaFsN+MCAgQA
diff --git a/jdk/test/java/security/KeyStore/PKCS12/api_cert_chain.p12_expected.data b/jdk/test/java/security/KeyStore/PKCS12/api_cert_chain.p12_expected.data
new file mode 100644
index 0000000..7cf01d6
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/api_cert_chain.p12_expected.data
@@ -0,0 +1,7 @@
+SHA1: 09:F1:08:B1:B3:28:22:23:22:F7:5F:6D:4A:8D:0E:0A:5E:6D:56:FB
+SHA256: AD:57:47:67:20:96:49:86:53:E4:10:EF:BD:4D:D2:B0:81:C0:B0:BB:62:AE:BE:47:80:DC:00:F8:E3:E7:66:B5
+SHA1: 2B:CE:0C:E1:35:B9:9D:FE:5A:6E:25:88:01:F7:E9:E5:7B:89:17:42
+SHA256: 65:F3:0A:64:F2:52:B2:4E:F8:76:C5:D0:6D:53:7C:E8:00:AE:F4:95:3C:CC:CB:01:6B:22:AF:46:36:50:CF:FF
+SHA1: 7D:48:4D:1C:F8:55:E8:79:6A:B0:19:E1:26:4F:AC:FD:57:6B:38:A0
+SHA256: 0A:14:3F:88:8D:C2:D6:97:3E:02:0F:5F:17:E3:D9:FE:CF:93:10:2C:3C:8D:81:AC:06:2F:32:39:4D:0E:CB:6A
+Alias name: servercert
diff --git a/jdk/test/java/security/KeyStore/PKCS12/api_private_key.p12.data b/jdk/test/java/security/KeyStore/PKCS12/api_private_key.p12.data
new file mode 100644
index 0000000..4daf029
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/api_private_key.p12.data
@@ -0,0 +1,31 @@
+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
diff --git a/jdk/test/java/security/KeyStore/PKCS12/api_private_key.p12_expected.data b/jdk/test/java/security/KeyStore/PKCS12/api_private_key.p12_expected.data
new file mode 100644
index 0000000..d579bc5
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/api_private_key.p12_expected.data
@@ -0,0 +1,3 @@
+SHA1: 48:22:E2:C2:47:9F:75:E3:52:56:9C:20:37:DF:03:7F:CD:9F:87:38
+SHA256: 9B:DF:B9:EC:DB:3E:EF:BD:61:8F:C3:62:BD:3E:95:FE:E5:B6:A3:F9:94:3D:8D:C1:AE:E9:44:86:25:FA:C1:1B
+Alias name: pkcs12testenduser1
diff --git a/jdk/test/java/security/KeyStore/PKCS12/api_private_key_not_match.p12.data b/jdk/test/java/security/KeyStore/PKCS12/api_private_key_not_match.p12.data
new file mode 100644
index 0000000..899a4e3
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/api_private_key_not_match.p12.data
@@ -0,0 +1,21 @@
+MIIEpAIBAzCCBF4GCSqGSIb3DQEHAaCCBE8EggRLMIIERzCCBEMGCSqGSIb3DQEHBqCCBDQwggQw
+AgEAMIIEKQYJKoZIhvcNAQcBMCgGCiqGSIb3DQEMAQYwGgQUgIXKrki/1oMI4cCRpYWa/iQtL0cC
+AgQAgIID8L1nh0C0Gmm9/AbAYbiwBJeb5oCAHa5E6BXJO9DP+m7774lUoQFuAmHJRoqr9hRzJulD
+FfdkmRO9JdCs1tRgmnik66ybBb2wqr9gsAhPHFhDWuYIQTJcYqYlBTS8hbg5stDYWCeyaqK3+Zyp
+bV3nHZtCe0AO+Rd3derZ3qhluPhc2FWX05fIomTZNiJsbi5wp95ejH4tGX5OdQoWXBjDzlrxopUd
+pmdmHfJvRRTEtMr45VPfuHOkAX8Fe2tPFUgkE2tUalUth90AuPXVlMm5Ne+OdKcj+V2EN2s5JxA6
+28H1IL753Hov3R80/+Rzn+NIN/BCwLfHyTFa4Ur7Z2dyOJHvM5qeaz580RR8MwsEjqSpmXiyVhQW
+3LNuziqs21woC7ueDW7TLiLhHp2Mt8BqFyfUYqBoS29lchRTHZbWTN2h66xycXlzbUCGIOHDXPXB
+mqgxQWIltgluel+9Uf//D5yzIkXbtnW9dkMwKkybctAUs9VN8V44UBxv4+noSxepUs0iG+07c5Uu
+dfvzwYtnKqKUrtTT8tA/MBNd4P1paYJR2Angx5tInyNKp8TwOaSrFUfg9stMYMh2fbWHLJFS9RDz
+P7BDkrBgEO7jDu3O/XyyXzgUQRcQBv/Mw7sCFQ8BBMFzwf/dc6q277w+DJmwz2ex23iXQXQi/b6Y
+iHbPwYHVwURWpVAq3P36pCTYjnUpPHMgRKo/9Iy+tL39H46SyGqBFlriM4jDEu7dbi7n1MuMxRYD
+zocSkdsnlsJUBOhHLFFYIUIqx6jOgnOESKPWbG9XIHCTZJYnpasmP/VidrQMljzC7c3piePsI03D
+8NcJq+BqCRrX+7Z5vPAU022hMryQqHesgnx0T0dWXaCyabzjjjOaWvacxRRCiJ4+EFZqAahMNQp/
+XTNlpW1eI0oQ3YBlJl5FWuwhk6YuoNSoi8ya1wp42rFnTwXIG8enfa0wyx/ORAvfypW4wcohsCdP
+oRjc9foQsdcjxv2e1yMn9TlgjTOemY81mFfaSMa+4OIhSgLnIYI96QztrY9n8WHJer1hxVdKrb+8
+Mhf2vcNEToVF9ypst1C7fXSeOKdAYlNDskPAAm3prcuLMf1dzceIADr+4JOYxzdz6lLvjR+tpAHo
+zWO1xh73P+p+Bo82wxnoWCopqOUCEoAYhsy+JBGZNM4AHvPAo4g0Sett3qixZhvbmw9kzKsiFAjf
+wQHYPUfl0O02HvBizHK7dRDqJ94G/djGBhqfe34P0hKrCzW+n0u5nFmkFEdk50LpsTu0z3AaaaNh
+E6485FDeW3R3/67pGXglNJHBWPsl2AYFimUTzxQqOfoCzBiw9St7hNvuCJBv5jA9MCEwCQYFKw4D
+AhoFAAQUczIrgX5A0QTP7tpYDiY3MaSbEM8EFAprSM643ml+k9DGSQKZ7MG0UEhKAgIEAA==
diff --git a/jdk/test/java/security/KeyStore/PKCS12/api_private_key_not_match.p12_expected.data b/jdk/test/java/security/KeyStore/PKCS12/api_private_key_not_match.p12_expected.data
new file mode 100644
index 0000000..d25641f
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/api_private_key_not_match.p12_expected.data
@@ -0,0 +1,3 @@
+SHA1: 2B:CE:0C:E1:35:B9:9D:FE:5A:6E:25:88:01:F7:E9:E5:7B:89:17:42
+SHA256: 65:F3:0A:64:F2:52:B2:4E:F8:76:C5:D0:6D:53:7C:E8:00:AE:F4:95:3C:CC:CB:01:6B:22:AF:46:36:50:CF:FF
+Alias name: pkcs12testenduser1
diff --git a/jdk/test/java/security/KeyStore/PKCS12/api_two_pass.p12.data b/jdk/test/java/security/KeyStore/PKCS12/api_two_pass.p12.data
new file mode 100644
index 0000000..453b66e
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/api_two_pass.p12.data
@@ -0,0 +1,46 @@
+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
++FjQ0fq7d/D+Ilu6e2EBG1y/ngICBAA=
diff --git a/jdk/test/java/security/KeyStore/PKCS12/api_two_pass.p12_expected.data b/jdk/test/java/security/KeyStore/PKCS12/api_two_pass.p12_expected.data
new file mode 100644
index 0000000..4113ade
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/api_two_pass.p12_expected.data
@@ -0,0 +1,3 @@
+SHA1: 77:90:EC:65:C5:0C:FD:F2:1E:B0:3A:BD:43:21:1A:C6:FD:18:8C:AB
+SHA256: 8E:C8:49:82:B8:4B:89:8E:61:2D:CD:F6:D6:34:96:04:91:6F:1B:08:F5:CD:BD:23:ED:94:22:5A:B4:7A:39:DD
+Alias name: pkcs12testenduser1
diff --git a/jdk/test/java/security/KeyStore/PKCS12/certs/convertP12/ie_jceks_chain.pfx.data b/jdk/test/java/security/KeyStore/PKCS12/certs/convertP12/ie_jceks_chain.pfx.data
new file mode 100644
index 0000000..3dbe7e4
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/certs/convertP12/ie_jceks_chain.pfx.data
@@ -0,0 +1,61 @@
+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

+CxwCAgfQ
\ No newline at end of file
diff --git a/jdk/test/java/security/KeyStore/PKCS12/certs/convertP12/ie_jks_chain.pfx.data b/jdk/test/java/security/KeyStore/PKCS12/certs/convertP12/ie_jks_chain.pfx.data
new file mode 100644
index 0000000..3dbe7e4
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/certs/convertP12/ie_jks_chain.pfx.data
@@ -0,0 +1,61 @@
+MIINXgIBAzCCDRoGCSqGSIb3DQEHAaCCDQsEgg0HMIINAzCCA7wGCSqGSIb3DQEHAaCCA60EggOp

+MIIDpTCCA6EGCyqGSIb3DQEMCgECoIICtjCCArIwHAYKKoZIhvcNAQwBAzAOBAipOP0AVsizDgIC

+B9AEggKQIP/YI9/C2WYbIWxKuqXMD8WPCvqj1fhHmZJ0epCzgEdOR7GT/h2Fy4/wxrthPkj4JqkS

+akQog3pjOFtj9D8QtkOw/b761qsyj17TYlQS9C6qVhcddMA+Ca2NcDhKlYofQMNTuYPXkXlpCh5R

+CNFgQ+PLVZwNZjqoitjv0RLQqBudhTmJSvfDlW2w+CpbziEeRNzn0pX0/Ts7KxykDscOmUCGHKic

+b6FqHoioElcmBp7ae3zdXuvI1x/1Y435qju2yODPpMXEZbdsD5iL07RZyL2vm6lfQbLc37TszDBx

+ZZJ7ja5F4V/j/6/AVLkcqfZxFOnXz5Ki9rQblYJbkkTpJAyiNqi8Gx+zgPGtLWvV6KRD0zmxo6q/

+OmdjKz4v9aG7MDSXenoy6tPAOvAQcQYaksvFZs1FjorJJpFzasfTUfy94JzrHUzRSPzNRDANHG/6

+TgxC1FMNw+iQUY9L8j4xrWsr2JN5tAgYcWz1qZrp4cx0he9cbQeqYcjv7ZvIQbIe2zxdvxh7WByy

+r8hNMe3RkMOM2yuP85JuWipq+9jt4/CrimKljN1ULPw+V9FZzY8kKcEiSPD+KXdJNkrMr77/lUJz

+PGNYpFBFb4natmi31ZBH2VomTeKPpeanN/ghWojft1mGd1s1nD4NelrWATMVquH2Cq6nhKLRHi4c

+KbQsMo+ftLvkDHHtpYenjGHbwEFfowkwn9slsZqmPEATV6caHNITCBbhQmvvhqPDPPViV+u1M1c7

+vwf/ol7IjBlubwzBJAg6f5GW0tMNHxfg5E7O27AyREyvexk0IVakzIwUuP2anPTjPW0vyeePLtiG

+TXNoUe+5UIzpshnLmSlerhVGoB+HBM1yoaaJHay7sdyQbVUxgdcwEwYJKoZIhvcNAQkVMQYEBAEA

+AAAwWwYJKoZIhvcNAQkUMU4eTAB7ADcAMQA5AEIAQgA4ADkANAAtADMANQA2ADEALQA0AEMAMAA0

+AC0AOQBCADIAMAAtADMAOQBCAEMARAAzADQANwAzADUAMQAwAH0wYwYJKwYBBAGCNxEBMVYeVABN

+AGkAYwByAG8AcwBvAGYAdAAgAEIAYQBzAGUAIABDAHIAeQBwAHQAbwBnAHIAYQBwAGgAaQBjACAA

+UAByAG8AdgBpAGQAZQByACAAdgAxAC4AMDCCCT8GCSqGSIb3DQEHBqCCCTAwggksAgEAMIIJJQYJ

+KoZIhvcNAQcBMBwGCiqGSIb3DQEMAQYwDgQIEmpyonjQeMACAgfQgIII+Pr+GLKaSN1U1soCnWsw

+4kRoDxPPLNbzv/K+lsbGVk9vXjv5aBTi55FMCXvA5kGvdnQYrQ1KfIZmFVh3PnFQn/J6LVrpLbHC

+/D27wvnOMausJA7uJi6wgkUCkQmXn7kesWhr+bBI9Ci7uyOUxdY53Yg43OQtZbWvQjGe6GiVRqWm

+8NANuZ3c1IT2TmJw5xfvvE4tcHK0d75ApvTa43CkKmUY5A4SyNY4SUVdl9Cx50LEHcqGwV+uVGzy

+kdO0+bgXI66FPKriuqPfayeTmL8T9PimwhOfY38OqtTKHwJ7E817i/B8ULpkRO67uYYJpeK4cIz1

+0rDW/JPG8BqN47Rej8rCpmY1F4hOuFzYA3PAh50YlI2wD2vSSqVPMUe/AtsL+u2Nxl/EidWp/8EL

+l8rBgYJjSl+YjSRV22C/ZwDu/8oV3LeCuwL2SaO1r1tww3WuRAFcCctsemP84YI27Q8Z54P6wM8c

+kjYH9F3oT9bHUAfJUm2d6d3wd+iGbrrxdkLrD5tEQB16K8RAbhPPfrM5rcRlh+Zvn068H/Kc9rEa

+sfJD7ygUBZJ5MSsr4zP4koMZ0xjxAaXRUsURsF13772XL3zfTCVd5fV3wIpJsoXugZTOQ6hjAmeN

+yGMZDn14GyxvwLbGFB0Yx8GAIRDxBvDXkYOqEMocmNwZo+uxPew1H4PMkWMm/yh4Y4V/H9Jmyd3v

+aD2BWVyx7PIJ4cet3RdydHrKSNVBzwrO+y5HKZc7V7aRM0kZgdAJh9eDTlYk6B+ZHd1EawYRlIfl

+f4JydqRkRaya7FOfQ3mLgrz6bdde720XZVWqe9bbsBucbYAJsYvklYYYutnsx1Ri9UYYAbRDy920

+Z6iO1EGF5wcUc0nifXObYJ2x0ldlQskUdThPjZBl2Mk4F9oxS6W5j2llm1hS/vGnFtykQ5NMaxzi

+Jkhi1Mjm/KZJUo2xJai1gtHwBOnlocXZYqJQECabBayA7rLH3pFUhU/Wqkycz4m8dUVXLNHiMIEd

+3sc0QASMF56kqXtzph2zbXBbCD8afyt8WjMzZvO4lEGNM8xi/7C6h45QsdGZgqkHrYBJbSHfrU05

+ZvNpV8YcfhkzX6gNtZU5XDDBPgkYn41sEt3aVRHvRAqc+uhczQ8svVhPUsriWnKk2bfw8iAn1xex

+5huB52uVPRfuL7wJxyV1Rk8WhK10xCzFDnJtRUAJ6UtuezrMOh28NPULQnLIx1kF00+uflY5vAHM

+rAf92+NqORZUflKVidqHYmF7bdeNGw3qshaK/0+3grs6rQeQAvxiTdmG+sBP9poBIeeHo2OzcACB

+wTuerZiYlzL7mAUegdiPD+wOa2yfGF+WG2vM9npO+a1ZWsoWceAxpLOyubBVfLyc7lfCo7ma70Vd

+Kl/o7VevEqLIz5ZkaCoupWk7nDKDMG73vGXqJwaYjd8teOw66aELd2WI4cAoFTvPayxMKHD8hf4n

+78riWe2XomUzafZLoMhj5vfYsiwwL3F5O/KUtTOXNNDDVuAwByiCfN65LIjU/Dhn8t6Izkox/Tnl

+9kPqNxqJAxFtARCFo9Xpgba761dTBmUF9J+Krg6B53NEv+0qvJY3w1H8Fnop9S+eEs6/4qUMmgO4

+wrm3aEaLY4XWGejuxUEQ9+3/cxK1YTJIpBeK8Q1/yPgj2mq62RRGcyDPEMbcbFcsI4MKlGggcpHV

+H8hv1XPLbrMi56lax3dB/EkJzJ+5IEnYd0NkXclyQm4d7KUy6LG5I2Quwt0J50dxbqmfR0gWwGsY

+nsT4Kk71NiUyU9AWl46EOZIzONN4Vnm0qq3oNJ5e8VpKTb2g80m5ouw+tPiDA/IA3Vu3VKLT589j

+5IQrNYhrizZnEApqPAQwBiN6D+0BLgsNeQDUn56emMj1ETDgfjukqAQjlGUvAr/VV/+eFHvkqwJU

+Hy6Xzd36Cq4/sYKYVU7OFzh6Ts9gCvblZxbFI1yNimEvwZ/bINKAemQLoji3s1UIs5X+BYqKZpI5

+nZsjbIHLafNjfPoMKUlpQa27jFc4s4GQ9WLBDRnVIuzqpdmdslxc2Q+dwzbT+zFoAAe5VzA+ABxv

+cjPYCBVpys4hYH1p3uwUq/hKkR7QgPE2c25qIHl+6VVS9dgaQ4XnHtVZjFzDk8u5YNenHx8E3lx4

+Ebe3mNjsM51X16ERkGC7X+w4Ko89wvb7jnnOheC0W5ICZQgphdasjff259yEJuhfk62r6bhZH2Um

+2IkUACGxKaEzh55Z5P2rcaSjAwIeWnLHDCPSOJ819/4XQEtPfbZs9eymDwNOg13kZhadSQF8+zht

+0Tko/9k41bNaT2ZqogskrIF9oltpofddqOa5IcE2d13T2IuDkV8/whV87P8Dg6fmFYpFCHN7zsks

+X+IHrRIt7gILXPwecu2LfUZxdH/Cr5WbfMzTnsWWSB7/Z9MLrlEISHM4zC7DlkbRSD7LyXyI4weh

+HNelf0uLtYRhXku5BkJUyysIYDpSHHxsMJ04Th+RZ7s8seoLBeAn7gbsj3B/JUOxIaEx8+W3bjb1

+wq6cc+KqLnvcO2BDvH30PfeQo7YjTNr4wcEoUFZXwhTL5owVc4GKtlfl/YxBXs2E6r6l43svlay6

+vCq58xTvWzzRtzvb6oh6qnoMP2xc8YTdpKma64TBmnFOVE/eGXZxVyk19TXwrokqUliutqhM6acv

+x87+Yru+uXTbUpMA0MuW0Ch6uvcwxmM1hq5vHDVBTAfGuXsdQMapKoqseFUfza7N2eSgU8oaJCGQ

+rmhvDn+MNzh2VyLOnPBwJ+sUnHM7XOnz/rCD99uRhhssEwZ5Xij+FG3EeTYyntGp6Z7ODIazLHM8

+81QtQDrJg2EDJ5RZHHrPbyUQDCkGpLZNOOoJkAD7I0VZRC3jJb8lTMXdKQjCd39F842+FXTSvOv9

+lmEOFH4AEyI6CokzFQCD0TXhTaG9wtzaE2q41eEKF45J5vyQxrNabZXeovNIVZryK+N8ep28M084

+vXp7uJm0bg5NunK6vTIqsxenQZWvXay8EwYLbAm8crDxK5sbW4tZtNeVxPE6ekCbifdxdgm0671w

+rt4wOzAfMAcGBSsOAwIaBBT1C0A3jyKtjUTFASRSO852mKBZQQQUqy721AxhZ26s5Tsue4OHTjEB

+CxwCAgfQ
\ No newline at end of file
diff --git a/jdk/test/java/security/KeyStore/PKCS12/certs/convertP12/jdk_jceks_selfsigned.p12.data b/jdk/test/java/security/KeyStore/PKCS12/certs/convertP12/jdk_jceks_selfsigned.p12.data
new file mode 100644
index 0000000..e64b3b4
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/certs/convertP12/jdk_jceks_selfsigned.p12.data
@@ -0,0 +1,30 @@
+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
\ No newline at end of file
diff --git a/jdk/test/java/security/KeyStore/PKCS12/certs/convertP12/jdk_jceks_twoentry.p12.data b/jdk/test/java/security/KeyStore/PKCS12/certs/convertP12/jdk_jceks_twoentry.p12.data
new file mode 100644
index 0000000..9d58b00
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/certs/convertP12/jdk_jceks_twoentry.p12.data
@@ -0,0 +1,69 @@
+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
\ No newline at end of file
diff --git a/jdk/test/java/security/KeyStore/PKCS12/certs/convertP12/jdk_jceks_twopass.p12.data b/jdk/test/java/security/KeyStore/PKCS12/certs/convertP12/jdk_jceks_twopass.p12.data
new file mode 100644
index 0000000..e26169f
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/certs/convertP12/jdk_jceks_twopass.p12.data
@@ -0,0 +1,45 @@
+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

+1QoCAgQA
\ No newline at end of file
diff --git a/jdk/test/java/security/KeyStore/PKCS12/certs/convertP12/jdk_jks_selfsigned.p12.data b/jdk/test/java/security/KeyStore/PKCS12/certs/convertP12/jdk_jks_selfsigned.p12.data
new file mode 100644
index 0000000..362a88e
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/certs/convertP12/jdk_jks_selfsigned.p12.data
@@ -0,0 +1,45 @@
+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

+xp4CAgQA
\ No newline at end of file
diff --git a/jdk/test/java/security/KeyStore/PKCS12/certs/convertP12/jdk_jks_twoentry.p12.data b/jdk/test/java/security/KeyStore/PKCS12/certs/convertP12/jdk_jks_twoentry.p12.data
new file mode 100644
index 0000000..9d58b00
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/certs/convertP12/jdk_jks_twoentry.p12.data
@@ -0,0 +1,69 @@
+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
\ No newline at end of file
diff --git a/jdk/test/java/security/KeyStore/PKCS12/certs/convertP12/jdk_jks_twopass.p12.data b/jdk/test/java/security/KeyStore/PKCS12/certs/convertP12/jdk_jks_twopass.p12.data
new file mode 100644
index 0000000..e26169f
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/certs/convertP12/jdk_jks_twopass.p12.data
@@ -0,0 +1,45 @@
+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

+1QoCAgQA
\ No newline at end of file
diff --git a/jdk/test/java/security/KeyStore/PKCS12/certs/convertP12/keystoreCA.jceks.data b/jdk/test/java/security/KeyStore/PKCS12/certs/convertP12/keystoreCA.jceks.data
new file mode 100644
index 0000000..be06f6a
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/certs/convertP12/keystoreCA.jceks.data
@@ -0,0 +1,38 @@
+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

+FgNW1MI40XfEdWafFXeJ+yQTHPyoNdk=
\ No newline at end of file
diff --git a/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/ie_chain.pfx.data b/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/ie_chain.pfx.data
new file mode 100644
index 0000000..3dbe7e4
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/ie_chain.pfx.data
@@ -0,0 +1,61 @@
+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

+CxwCAgfQ
\ No newline at end of file
diff --git a/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/ie_self.pfx.data b/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/ie_self.pfx.data
new file mode 100644
index 0000000..acde65c
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/ie_self.pfx.data
@@ -0,0 +1,47 @@
+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

+/FfU1hlVl8YCAgfQ
\ No newline at end of file
diff --git a/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/jdk_chain.p12.data b/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/jdk_chain.p12.data
new file mode 100644
index 0000000..f379d2b
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/jdk_chain.p12.data
@@ -0,0 +1,62 @@
+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

+IsNed5PjTXd1/rQmWIcCDOy9lgICBAA=
\ No newline at end of file
diff --git a/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/jdk_self.p12.data b/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/jdk_self.p12.data
new file mode 100644
index 0000000..b643ba4
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/jdk_self.p12.data
@@ -0,0 +1,45 @@
+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

+I6oCAgQA
\ No newline at end of file
diff --git a/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/mozilla_chain.p12.data b/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/mozilla_chain.p12.data
new file mode 100644
index 0000000..623d470
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/mozilla_chain.p12.data
@@ -0,0 +1,73 @@
+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
\ No newline at end of file
diff --git a/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/mozilla_self.p12.data b/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/mozilla_self.p12.data
new file mode 100644
index 0000000..c36f26b
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/mozilla_self.p12.data
@@ -0,0 +1,54 @@
+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

+0AQQxrOtDDKIzjpW4+rATcwNPAAA
\ No newline at end of file
diff --git a/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/mozilla_twoentries.p12.data b/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/mozilla_twoentries.p12.data
new file mode 100644
index 0000000..d0c451b
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/mozilla_twoentries.p12.data
@@ -0,0 +1,125 @@
+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

+AoiyQ6u3imI281gAAA==
\ No newline at end of file
diff --git a/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/netscape_chain.p12.data b/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/netscape_chain.p12.data
new file mode 100644
index 0000000..af0557a
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/netscape_chain.p12.data
@@ -0,0 +1,73 @@
+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
\ No newline at end of file
diff --git a/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/netscape_self.p12.data b/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/netscape_self.p12.data
new file mode 100644
index 0000000..bdc9483
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/netscape_self.p12.data
@@ -0,0 +1,54 @@
+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

+HwQQ6Vxq63yfCeamza5PZKytWQAA
\ No newline at end of file
diff --git a/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/netscape_twoentries.p12.data b/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/netscape_twoentries.p12.data
new file mode 100644
index 0000000..cdc8438
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/netscape_twoentries.p12.data
@@ -0,0 +1,125 @@
+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

+LK2fdlxrCGzUHTgAAA==
\ No newline at end of file
diff --git a/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/openssl.p12.data b/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/openssl.p12.data
new file mode 100644
index 0000000..101a039
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/certs/readP12/openssl.p12.data
@@ -0,0 +1,41 @@
+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
\ No newline at end of file
diff --git a/jdk/test/java/security/KeyStore/PKCS12/certs/writeP12/keystoreCA.jks.data b/jdk/test/java/security/KeyStore/PKCS12/certs/writeP12/keystoreCA.jks.data
new file mode 100644
index 0000000..1d6b5a4
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/certs/writeP12/keystoreCA.jks.data
@@ -0,0 +1,38 @@
+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
\ No newline at end of file
diff --git a/jdk/test/java/security/KeyStore/PKCS12/certs/writeP12/keystoreEU.jks.data b/jdk/test/java/security/KeyStore/PKCS12/certs/writeP12/keystoreEU.jks.data
new file mode 100644
index 0000000..c8e4ecf
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/certs/writeP12/keystoreEU.jks.data
@@ -0,0 +1,79 @@
+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

+VL+NWQOgtME=
\ No newline at end of file
diff --git a/jdk/test/java/security/KeyStore/PKCS12/ie_chain.pfx.data b/jdk/test/java/security/KeyStore/PKCS12/ie_chain.pfx.data
new file mode 100644
index 0000000..a509e05
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/ie_chain.pfx.data
@@ -0,0 +1,65 @@
+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
+fAQEFPL7KYm4NrHpQSKpto5+pPs7NgLWAgIEAA==
diff --git a/jdk/test/java/security/KeyStore/PKCS12/ie_chain.pfx.pem b/jdk/test/java/security/KeyStore/PKCS12/ie_chain.pfx.pem
new file mode 100644
index 0000000..6caea3f
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/ie_chain.pfx.pem
@@ -0,0 +1,23 @@
+-----BEGIN CERTIFICATE-----
+MIID7DCCAtSgAwIBAgIBBDANBgkqhkiG9w0BAQsFADBXMQswCQYDVQQGEwJJTjEL
+MAkGA1UECAwCS0ExDDAKBgNVBAcMA2JscjEPMA0GA1UECgwGT3JhY2xlMQ0wCwYD
+VQQLDARKYXZhMQ0wCwYDVQQDDARMZWFkMB4XDTE1MDUyODAzNDMwN1oXDTI1MDUy
+NTAzNDMwN1owSzELMAkGA1UEBhMCSU4xCzAJBgNVBAgMAktBMQ8wDQYDVQQKDAZP
+cmFjbGUxDTALBgNVBAsMBEphdmExDzANBgNVBAMMBk1lbWJlcjCCASIwDQYJKoZI
+hvcNAQEBBQADggEPADCCAQoCggEBAMr07JoRV0kR5mNKgLFKLYeUQ2eFEyV8alkC
+3OL2Ew9tP9CT+60kqlbyLfxa8+8XU/SClch6yf7R4majR85PgfJuZKRvyUdWgw5y
+K0wbxWkRVqRAgSo0Zp8hkhV9BDe1R7s4r4XBI/rSVTQmDsMVZdigDtIDYKMS0BtW
+DnW4ueWbZHdNHyxlTEJc6trsvU2KH5pY69VgGZzonNuMa9p17aQpOnVbWNhS6Mcs
+mHonU5d19Xh543T8ovbA8cj0osdYgcOQ42FEBqON4Lih8SyhqZQyi4UvkiHek3Pu
+i5Q0dwwVT1lnorUwH3bXp4boMaUmh7bvKMe/BQ5T18wkXlgYuVECAwEAAaOBzjCB
+yzAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NMIEdlbmVyYXRlZCBD
+ZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUWDsl+9vHtuuQRhb+Zyd//f6qSXEwcQYDVR0j
+BGowaKFbpFkwVzELMAkGA1UEBhMCSU4xCzAJBgNVBAgMAktBMQwwCgYDVQQHDANi
+bHIxDzANBgNVBAoMBk9yYWNsZTENMAsGA1UECwwESmF2YTENMAsGA1UEAwwETGVh
+ZIIJAIQbGsfQ2qikMA0GCSqGSIb3DQEBCwUAA4IBAQABEg/vV+ckqMwwA6QLdk6i
+Q+oaYcjz2C7wcZmvmrdYGHUrtlf4aWQd4G/TDBtqKZ6MfA2AaciDe7lAI2agdKCM
+MFG6XeqtjElCa77b8KrE3Ha+N07pmYnU42vZrqMpayjj/Eey9bOuSaTgLVTA00BI
+5wiTbLokTrYW3lhMityeFyvGw7bEvfGbXLs/7hyZ6wEXindgaGT9adL9jz2LT2Tt
+YorRvxRSRMbBWCc6o+ICfawU226ZOetGVfdTSYgL3a9AQ+zAMhgdJq+ac077G1vA
+HzKZgygYAHIr1G0DxwEPOAHBQFtbTbAQURpjzKWFYeGiZuCEBwwsKgDIT0kGF76E
+-----END CERTIFICATE-----
diff --git a/jdk/test/java/security/KeyStore/PKCS12/ie_self.pfx.data b/jdk/test/java/security/KeyStore/PKCS12/ie_self.pfx.data
new file mode 100644
index 0000000..0500db5
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/ie_self.pfx.data
@@ -0,0 +1,31 @@
+MIIGwAIBAzCCBnoGCSqGSIb3DQEHAaCCBmsEggZnMIIGYzCCAzAGCSqGSIb3DQEHAaCCAyEEggMd
+MIIDGTCCAxUGCyqGSIb3DQEMCgECoIICqjCCAqYwKAYKKoZIhvcNAQwBAzAaBBSZNW+Sd+0mytcN
+A/vZXbBxiRZHxgICBAAEggJ4YAYE4bHqC0rxj3w6eUmXqp/tebM75dLfm/YyOQqKTE5bPJNWAT2E
+njhtDTNDigxhLjy4tH1sligytYgABTOcBotniRGM9yZ/52JR7bv6NxGCbv+SU2v10Srug+onIhFM
+639E7bG1yRfNW7IATgKLX1KxIBWFX973MBnsDVK5gZEhy17hzLUdaJRk3AyiCIB17R3d0SthtIW+
+WR/1rYUDOUe4weJYPsVW+WwtYtdOllcDLopS+B/QgXPrv9FOLUfEHtNO9crLMnGU8Kr9uqMyHu99
+ZdIgH1wuuK3Na7noc4KI4Q3JoTsRRfWpl6nEt5FERpRY8Q1spNwzo9mZ9NwtVyMkjGfSnZP8RE7M
+2csqZESd88PGVcnrMzNb/y+5X1qgj+bx56v+6m91QcIcv3RMK645Wiow9WjtmZL5sGl0SNUcwzP1
+zYGjZrWnTICjMmuNDIDznX2yrtHLxoM8AzhUwIvirTROv+RaqO+gopDxTBy9kymPiHS6PLllC3hL
+GYqZ1CFCIkn7nf9DP4tKJmfvOhrURCFnbXSlIbu7d5j8TNI+6CLuD9H1c8vlp6kdvaJejLzAVFt8
+eY8A/zIDUKcyKXCFPS4F25X6vJ6ZdQOKBVzg8ueAUety6o44eJ7NxusLoMyHneLCTQ7jRobSihss
+eXa182Yk1Q+H7Dx+zbPr6FsNp8wNf90CM6zZAbgBqBzM5eGb2Y/Ich1eG2oLAFurrpqgxXlb6nJS
+nJ7e7NgAqf3S4VbKt3uCvVtrZfUUvCdx4BUfeNSNOGmAtgCRlPn93Gc2+IL7eJYNqDScNjGf/hj+
+rHCL7jNPRvoovzBdUSzJ1Y92r0iUWu4xWDAzBgkqhkiG9w0BCRQxJh4kAHAAawBjAHMAMQAyAHQA
+ZQBzAHQAZQBuAGQAdQBzAGUAcgAxMCEGCSqGSIb3DQEJFTEUBBJUaW1lIDE0MzI3MDQxMTIzNzQw
+ggMrBgkqhkiG9w0BBwagggMcMIIDGAIBADCCAxEGCSqGSIb3DQEHATAoBgoqhkiG9w0BDAEGMBoE
+FNSn/NMdKj9fmg+dMmEFE2rlvLY8AgIEAICCAtiFvAUXr/bKf77WWVx2Y9OnqlUNkXkeE7XEI5XB
+qKid6iUlv4eRWY3PyK5gLIDELGJHOIpHKAkjSef6kBU04E/jcQmg+kA+3GScXFZXTw+jjgGmaX9x
+zbAzXAvEURwh/T0HRtxsxXLf+7D3gdiIAQcVyh50xD58HOOox7mo1NFQ9Vi63f82wyJgQH1tYSid
+ExsC2ZJ2H7mncZrD/RtKgShwEmn8CTappx9iILVGkyRTbliWKxfr5EaEY0yXpDN8aj5N4pgGWg8O
+Qh9axIRFuTxhZ4jIDMEI6VUT0ugBn1rfBbaqWfmM3IfQZsQQsidARCISyajzjEDaiB0wRRCSuoyU
+FJdkCttHj8M85VvsRDN9YQa2ilBDfSjaJT8SQsvmMP8fpohnalGZsADBSTCZp1s6m5vgPErSCmY3
+w347fK3UtnDhtpxy6KvtiosJq2YLszC16O2KaiwvDoOteJSTv3aJfMXuZWF0QCBwN2pPhyPCnQZq
+sUe7YlnaihKqzAj+jyaWRI48HJY3y94zeEESXuY4Y1fgrWfsEuO7oHcqTvy0O10otPOnG5etIvNL
+uFBmYYL3Ag9HNKYHwl1d/lqrh7a3dHi8IuREQ1vY74sFbhefzDsZs4Foz0m60oJY2BeNl1BPtFKW
+yVrwIMKAlLovx5+sH/HvVtchabl0RPlNtYJNEUDVnp40OLE4B7fDQaNOY3hQJErCsE+ffhHMqy0k
+bLVM73XKBhS4GypIBx+GSZauuOXmxBKJCz/00ZUXfeRDqjSUe901eip9fILUmFObBlohbE02xt15
+8b0m+tHgj3aNvF5RkTnendRGh3D+O8hBWz9+AHSpIsXxemuWJ+VQgIeMOERwD+62zkEqLgOsn1pB
+3ZmN3pUl8mIWNDrdC7nGLU6YJt4PNVFRYtJIhuo8fN3I/Fk0CMCwZhZMsP8UcEH9GJOBK5/MtCds
+ZBMUE/UJsjlGCzcq/7OVTDA9MCEwCQYFKw4DAhoFAAQUPQnz3GvfsIzh1/29KwCg+E8LeVAEFMmb
+qHeo0noP26ViWalg3FeT8Lk+AgIEAA==
diff --git a/jdk/test/java/security/KeyStore/PKCS12/ie_self.pfx.pem b/jdk/test/java/security/KeyStore/PKCS12/ie_self.pfx.pem
new file mode 100644
index 0000000..b877893
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/ie_self.pfx.pem
@@ -0,0 +1,15 @@
+-----BEGIN CERTIFICATE-----
+MIICRTCCAa6gAwIBAgIEFjfyzjANBgkqhkiG9w0BAQQFADBWMQswCQYDVQQGEwJV
+UzEPMA0GA1UEChMGT3JhY2xlMRUwEwYDVQQLEwxTZWN1cml0eSBTUUUxHzAdBgNV
+BAMTFlBLQ1MxMiBUZXN0IEVuZCBVc2VyIDEwHhcNMTUwNTI3MDUyMTUyWhcNMzUw
+MjExMDUyMTUyWjBWMQswCQYDVQQGEwJVUzEPMA0GA1UEChMGT3JhY2xlMRUwEwYD
+VQQLEwxTZWN1cml0eSBTUUUxHzAdBgNVBAMTFlBLQ1MxMiBUZXN0IEVuZCBVc2Vy
+IDEwgZ4wDQYJKoZIhvcNAQEBBQADgYwAMIGIAoGAUPl3dSLSQd+ocj4oDJI6qdt+
+iIamUd6aDHllX/vNfguuX5G1/NO/aas5XofV9Zfy+XCdqGI/rUE294vod1BkBOiP
+UmsgHl30nWCwEq5FuFWLwLWgm2DkNMGVJnvvCVLDzuYhvkymNbOoppHywIMVAryP
+Xi2082vRKvW677VqcT0CAwEAAaMhMB8wHQYDVR0OBBYEFLpLVS5KZoGIDGmden5r
+AK3/D9+5MA0GCSqGSIb3DQEBBAUAA4GBAEomR40Sj+BvNYiL8Lfr2vMadCF23R3X
+fjPd3TCGuMJtI78N9lSTnrZCnrxn4ep7FuVl59jqEX7mBQcVtUNPqw/xrFI/sv4z
+Nwxa18TG78i85OXapvVsX1fWx0GeeK2XTKetHLMEc8zcW8IHcukSX+5Z6Y/pg+lB
+mqEx9bvLCJTW
+-----END CERTIFICATE-----
diff --git a/jdk/test/java/security/KeyStore/PKCS12/mozilla_self.p12.data b/jdk/test/java/security/KeyStore/PKCS12/mozilla_self.p12.data
new file mode 100644
index 0000000..03ef955
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/mozilla_self.p12.data
@@ -0,0 +1,31 @@
+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
diff --git a/jdk/test/java/security/KeyStore/PKCS12/mozilla_self.p12.pem b/jdk/test/java/security/KeyStore/PKCS12/mozilla_self.p12.pem
new file mode 100644
index 0000000..fb0c5d1
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/mozilla_self.p12.pem
@@ -0,0 +1,15 @@
+-----BEGIN CERTIFICATE-----
+MIICRTCCAa6gAwIBAgIEL8ZaXTANBgkqhkiG9w0BAQQFADBWMQswCQYDVQQGEwJV
+UzEPMA0GA1UEChMGT3JhY2xlMRUwEwYDVQQLEwxTZWN1cml0eSBTUUUxHzAdBgNV
+BAMTFlBLQ1MxMiBUZXN0IEVuZCBVc2VyIDEwHhcNMTUwNTI3MDUzNTI1WhcNMzUw
+MjExMDUzNTI1WjBWMQswCQYDVQQGEwJVUzEPMA0GA1UEChMGT3JhY2xlMRUwEwYD
+VQQLEwxTZWN1cml0eSBTUUUxHzAdBgNVBAMTFlBLQ1MxMiBUZXN0IEVuZCBVc2Vy
+IDEwgZ4wDQYJKoZIhvcNAQEBBQADgYwAMIGIAoGARub+B5xAEtoE2Sv9+oRnKYIC
+AZZ5dpTdMUWiExsXBcK6KQ61X5GftMz4a5io7PoxJxsDkPyTPNaHov2dzOBblbn2
+Gd0YgRdI3jcmm6ELDN7CqzsO7FK48L8maLeIj/0hYPBZPxKohjChi2GUNKn97OMf
+Y0LTeDqpO6+oc2E25XECAwEAAaMhMB8wHQYDVR0OBBYEFLC2ChLxDu/yacB3s0ON
+NNDusz2SMA0GCSqGSIb3DQEBBAUAA4GBADhG2wSf4KHMspsKv8bkjWrDA6wTjwnx
+pQES8E2dMmmp/LybH0CerpcShGGw35uh8wnCaWA1hBgMAs1mfghTt9X8tZCG5MmA
+VmkR7VPu1lNbdB1sswXAy3/423ncWbPJKIvbXBLJrzvC3Ri6d/AiH/0Tud0H15IN
+YQ+ThBRF5iQC
+-----END CERTIFICATE-----
diff --git a/jdk/test/java/security/KeyStore/PKCS12/netscape_self.p12.data b/jdk/test/java/security/KeyStore/PKCS12/netscape_self.p12.data
new file mode 100644
index 0000000..5c4a0b0
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/netscape_self.p12.data
@@ -0,0 +1,31 @@
+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
diff --git a/jdk/test/java/security/KeyStore/PKCS12/netscape_self.p12.pem b/jdk/test/java/security/KeyStore/PKCS12/netscape_self.p12.pem
new file mode 100644
index 0000000..cd303ff
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/netscape_self.p12.pem
@@ -0,0 +1,16 @@
+-----BEGIN CERTIFICATE-----
+MIICRTCCAa6gAwIBAgIECrE+nTANBgkqhkiG9w0BAQQFADBWMQswCQYDVQQGEwJV
+UzEPMA0GA1UEChMGT3JhY2xlMRUwEwYDVQQLEwxTZWN1cml0eSBTUUUxHzAdBgNV
+BAMTFlBLQ1MxMiBUZXN0IEVuZCBVc2VyIDEwHhcNMTUwNTI3MDUzMDEyWhcNMzUw
+MjExMDUzMDEyWjBWMQswCQYDVQQGEwJVUzEPMA0GA1UEChMGT3JhY2xlMRUwEwYD
+VQQLEwxTZWN1cml0eSBTUUUxHzAdBgNVBAMTFlBLQ1MxMiBUZXN0IEVuZCBVc2Vy
+IDEwgZ4wDQYJKoZIhvcNAQEBBQADgYwAMIGIAoGAUJKwuZJOuG+EZ9d8L4BDYOzv
+2sFCyCTrDbw6lH/vaG/kkhJgZdYMV1pwqxmsspUrSYwATx3usPElv+OOjEJlwuLo
+wj+/6Ob9LirwUAHb9LbcF5r9dRxLBcFUaTnDlqzgOuS1gn9dnD9z4CugId9t9IjF
+tLiump5zXNcZw/+/JKMCAwEAAaMhMB8wHQYDVR0OBBYEFOKLf8ckktSBUTDRoYxV
+b56vtgd8MA0GCSqGSIb3DQEBBAUAA4GBACgrbEqfqtgKx0iLiQEgKb4K+O4Gg8Td
+wuSjtXn9WQR5Fux7XNoM8f3xRw95CROg1/JEYhsH7fzeG/Aq6BbFooyHZsQ7yGXJ
+ujJ3O7hl0MuFZRChf9QP7YQjYb4toj1wdE0EvA9lNWomr2Ox9b3+QFTdxPcBElv6
++ImhOPtF6/lt
+-----END CERTIFICATE-----
+
diff --git a/jdk/test/java/security/KeyStore/PKCS12/openssl.p12.data b/jdk/test/java/security/KeyStore/PKCS12/openssl.p12.data
new file mode 100644
index 0000000..b4da479
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/openssl.p12.data
@@ -0,0 +1,76 @@
+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
diff --git a/jdk/test/java/security/KeyStore/PKCS12/openssl.p12.pem b/jdk/test/java/security/KeyStore/PKCS12/openssl.p12.pem
new file mode 100644
index 0000000..0243a37
--- /dev/null
+++ b/jdk/test/java/security/KeyStore/PKCS12/openssl.p12.pem
@@ -0,0 +1,22 @@
+-----BEGIN CERTIFICATE-----
+MIIDjjCCAnagAwIBAgIBAzANBgkqhkiG9w0BAQsFADBMMQswCQYDVQQGEwJJTjEL
+MAkGA1UECAwCS0ExDzANBgNVBAoMBk9yYWNsZTENMAsGA1UECwwESmF2YTEQMA4G
+A1UEAwwHQ2xpZW50MTAeFw0xNTA1MjYyMjE3MThaFw0yNTA1MjMyMjE3MThaMEwx
+CzAJBgNVBAYTAklOMQswCQYDVQQIDAJLQTEPMA0GA1UECgwGT3JhY2xlMQ0wCwYD
+VQQLDARKYXZhMRAwDgYDVQQDDAdDbGllbnQyMIIBIjANBgkqhkiG9w0BAQEFAAOC
+AQ8AMIIBCgKCAQEA2HADVMaKPd7xAYK0BTsCcQzglk8H2qp0Sg5nDYgb7KqB/1cb
+RyMB3g3FG4Isv6L0Lp2GLAeHVn35YljHNrcBUU5fG/+DNJPNiM+srevblMeksOcA
+frPnxmog+GMgiO97O2/3Xtgl0ailsOHidPH9hBXr+WikNu7ITPXkJiYi0d1n8p2N
+e/p4W4cBitxIUlZm2OTSW4d3EDW86saf657kSpTlb2zBT/r9fjWluHlTg+jGnGIz
+UdpYP7sSnye8oym5PxT2IMPU6vRgF9Gzwg+6bPaZnrYNURifGJIuQH+/wDaqA+Ix
+g2Q2Ij8SiDhkNrCoeLf77Aot9d5ZPtledJPSRQIDAQABo3sweTAJBgNVHRMEAjAA
+MCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NMIEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAd
+BgNVHQ4EFgQUhxNmvHpNjpjnl/vMVkEnyF5Msk0wHwYDVR0jBBgwFoAUHyFP2xAx
+0GeDCQPTzfxG7M8di7QwDQYJKoZIhvcNAQELBQADggEBAD4rXzKq8PdSK7rzuwfu
+q+RzeYZnNM7OsoBGhMfHQKnnI3LH5bgyttuCoV665X2mgy6+LZcrXqom/ZrLXQ6x
+JVtGxNHr7rqbnC/9tB2/s9HHN3YiRs966shWHGkhCubsUGre7Z25Pq55K6Pyl+nU
+hb+K8aQ54z4oDt+raAdbuILq91fUjw5j1qex3d62fHvf4IO3spcKY4HhnwBPifg2
+YZCiZRZOoVysi2FTdsvW2NfQCYgtUftbkfNrKglkRuIa9rQEduhDy1cwn4fc9S1f
+6WTvuJNoIp3o1nQppFjfO7fzfIDCrlaEkkXU7O54KQ5HTKu62tZp9xKW71oolOnZ
+bZQ=
+-----END CERTIFICATE-----
diff --git a/jdk/test/java/security/MessageDigest/TestDigestIOStream.java b/jdk/test/java/security/MessageDigest/TestDigestIOStream.java
new file mode 100644
index 0000000..46028e8
--- /dev/null
+++ b/jdk/test/java/security/MessageDigest/TestDigestIOStream.java
@@ -0,0 +1,335 @@
+/*
+ * Copyright (c) 2003, 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.
+ *
+ * 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.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.security.DigestInputStream;
+import java.security.DigestOutputStream;
+import java.security.MessageDigest;
+import java.util.Arrays;
+import java.util.Random;
+import static java.lang.System.out;
+
+/**
+ * @test
+ * @bug 8050370
+ * @summary MessageDigest tests with DigestIOStream
+ * @author Kevin Liu
+ */
+
+enum ReadModel {
+    READ, BUFFER_READ, MIX_READ
+}
+
+public class TestDigestIOStream {
+
+    private static final int[] DATA_LEN_ARRAY = {
+        1, 50, 2500, 125000, 6250000
+    };
+    private static final String[] ALGORITHM_ARRAY = {
+        "MD2", "MD5", "SHA1", "SHA-224", "SHA-256", "SHA-384", "SHA-512"
+    };
+
+    private static byte[] data;
+
+    private static MessageDigest md = null;
+
+    public static void main(String argv[]) throws Exception {
+        TestDigestIOStream test = new TestDigestIOStream();
+        test.run();
+    }
+
+    public void run() throws Exception {
+        for (String algorithm: ALGORITHM_ARRAY) {
+
+            md = MessageDigest.getInstance(algorithm);
+
+            for (int length: DATA_LEN_ARRAY) {
+
+                Random rdm = new Random();
+                data = new byte[length];
+                rdm.nextBytes(data);
+
+                if (!testMDChange(algorithm, length)) {
+                    throw new RuntimeException("testMDChange failed at:"
+                            + algorithm + "/" + length);
+                }
+                if (!testMDShare(algorithm, length)) {
+                    throw new RuntimeException("testMDShare failed at:"
+                            + algorithm + "/" + length);
+                }
+                for (ReadModel readModel: ReadModel.values()) {
+                    // test Digest function when digest switch on
+                    if (!testDigestOnOff(algorithm, readModel, true, length)) {
+                        throw new RuntimeException("testDigestOn failed at:"
+                                + algorithm + "/" + length + "/" + readModel);
+                    }
+                    // test Digest function when digest switch off
+                    if (!testDigestOnOff(algorithm, readModel, false, length)) {
+                        throw new RuntimeException("testDigestOff failed at:"
+                                + algorithm + "/" + length + "/" + readModel);
+                    }
+                }
+            }
+        }
+        int testNumber = ALGORITHM_ARRAY.length * ReadModel.values().length
+                * DATA_LEN_ARRAY.length * 2 + ALGORITHM_ARRAY.length
+                * DATA_LEN_ARRAY.length * 2;
+        out.println("All " + testNumber + " Tests Passed");
+    }
+
+    /**
+     * Test DigestInputStream and DigestOutputStream digest function when digest
+     * set on and off
+     *
+     * @param algo
+     *            Message Digest algorithm
+     * @param readModel
+     *            which read method used(READ, BUFFER_READ, MIX_READ)
+     * @param on
+     *            digest switch(on and off)
+     * @param dataLength
+     *            plain test data length.
+     * @exception Exception
+     *                throw unexpected exception
+     */
+    public boolean testDigestOnOff(String algo, ReadModel readModel,
+            boolean on, int dataLength) throws Exception {
+
+        // Generate the DigestInputStream/DigestOutputStream object
+        try (ByteArrayInputStream bais = new ByteArrayInputStream(data);
+                DigestInputStream dis = new DigestInputStream(bais,
+                        MessageDigest.getInstance(algo));
+                ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                DigestOutputStream dos = new DigestOutputStream(baos,
+                        MessageDigest.getInstance(algo));
+                ByteArrayOutputStream baOut = new ByteArrayOutputStream();) {
+
+            // Perform the update using all available/possible update methods
+            int k = 0;
+            byte[] buffer = new byte[5];
+            boolean enDigest = true;
+            // Make sure the digest function is on (default)
+            dis.on(enDigest);
+            dos.on(enDigest);
+
+            switch (readModel) {
+            case READ: // use only read()
+                while ((k = dis.read()) != -1) {
+                    if (on) {
+                        dos.write(k);
+                    } else {
+                        dos.write(k);
+                        if (enDigest) {
+                            baOut.write(k);
+                        }
+                        enDigest = !enDigest;
+                        dos.on(enDigest);
+                        dis.on(enDigest);
+                    }
+                }
+                break;
+            case BUFFER_READ: // use only read(byte[], int, int)
+                while ((k = dis.read(buffer, 0, buffer.length)) != -1) {
+                    if (on) {
+                        dos.write(buffer, 0, k);
+                    } else {
+                        dos.write(buffer, 0, k);
+                        if (enDigest) {
+                            baOut.write(buffer, 0, k);
+                        }
+                        enDigest = !enDigest;
+                        dis.on(enDigest);
+                        dos.on(enDigest);
+                    }
+                }
+                break;
+            case MIX_READ: // use both read() and read(byte[], int, int)
+                while ((k = dis.read()) != -1) {
+                    if (on) {
+                        dos.write(k);
+                        if ((k = dis.read(buffer, 0, buffer.length)) != -1) {
+                            dos.write(buffer, 0, k);
+                        }
+                    } else {
+                        dos.write(k);
+                        if (enDigest) {
+                            baOut.write(k);
+                        }
+                        enDigest = !enDigest;
+                        dis.on(enDigest);
+                        dos.on(enDigest);
+                        if ((k = dis.read(buffer, 0, buffer.length)) != -1) {
+                            dos.write(buffer, 0, k);
+                            if (enDigest) {
+                                baOut.write(buffer, 0, k);
+                            }
+                            enDigest = !enDigest;
+                            dis.on(enDigest);
+                            dos.on(enDigest);
+                        }
+                    }
+                }
+                break;
+            default:
+                out.println("ERROR: Invalid read/write combination choice!");
+                return false;
+            }
+
+            // Get the output and the "correct" digest values
+            byte[] output1 = dis.getMessageDigest().digest();
+            byte[] output2 = dos.getMessageDigest().digest();
+            byte[] standard;
+            if (on) {
+                standard = md.digest(data);
+            } else {
+                byte[] dataDigested = baOut.toByteArray();
+                standard = md.digest(dataDigested);
+            }
+
+            // Compare the output byte array value to the input data
+            if (!MessageDigest.isEqual(data, baos.toByteArray())) {
+                out.println("ERROR of " + readModel
+                        + ": output and input data unexpectedly changed");
+                return false;
+            }
+            // Compare generated digest values
+            if (!MessageDigest.isEqual(output1, standard)
+                    || !MessageDigest.isEqual(output2, standard)) {
+                out.println("ERROR" + readModel
+                        + ": generated digest data unexpectedly changed");
+                return false;
+            }
+
+            return true;
+        } catch (Exception ex) {
+            out.println("testDigestOnOff failed at:" + algo + "/" + readModel
+                    + "/" + dataLength + " with unexpected exception");
+            throw ex;
+        }
+    }
+
+    /**
+     * Test DigestInputStream and DigestOutputStream digest function when Swap
+     * the message digest engines between DigestIn/OutputStream
+     *
+     * @param algo
+     *            Message Digest algorithm
+     * @param dataLength
+     *            plain test data length.
+     * @exception Exception
+     *                throw unexpected exception
+     */
+    public boolean testMDChange(String algo, int dataLength) throws Exception {
+        // Generate the DigestInputStream/DigestOutputStream object
+        MessageDigest mdIn = MessageDigest.getInstance(algo);
+        MessageDigest mdOut = MessageDigest.getInstance(algo);
+        try (ByteArrayInputStream bais = new ByteArrayInputStream(data);
+                DigestInputStream dis = new DigestInputStream(bais, mdIn);
+                ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                DigestOutputStream dos = new DigestOutputStream(baos, mdOut);) {
+
+            // Perform the update using all available/possible update methods
+            int k = 0;
+            byte[] buffer = new byte[10];
+
+            // use both read() and read(byte[], int, int)
+            while ((k = dis.read()) != -1) {
+                dos.write(k);
+                if ((k = dis.read(buffer, 0, buffer.length)) != -1) {
+                    dos.write(buffer, 0, k);
+                }
+
+                // Swap the message digest engines between
+                // DigestIn/OutputStream objects
+                dis.setMessageDigest(mdOut);
+                dos.setMessageDigest(mdIn);
+                mdIn = dis.getMessageDigest();
+                mdOut = dos.getMessageDigest();
+            }
+
+            // Get the output and the "correct" digest values
+            byte[] output1 = mdIn.digest();
+            byte[] output2 = mdOut.digest();
+            byte[] standard = md.digest(data);
+
+            // Compare generated digest values
+            return MessageDigest.isEqual(output1, standard)
+                    && MessageDigest.isEqual(output2, standard);
+        } catch (Exception ex) {
+            out.println("testMDChange failed at:" + algo + "/" + dataLength
+                    + " with unexpected exception");
+            throw ex;
+        }
+    }
+
+    /**
+     * Test DigestInputStream and DigestOutputStream digest function when use
+     * same message digest object.
+     *
+     * @param algo
+     *            Message Digest algorithm
+     * @param dataLength
+     *            plain test data length.
+     * @exception Exception
+     *                throw unexpected exception
+     */
+    public boolean testMDShare(String algo, int dataLength) throws Exception {
+        MessageDigest mdCommon = MessageDigest.getInstance(algo);
+        // Generate the DigestInputStream/DigestOutputStream object
+        try (ByteArrayInputStream bais = new ByteArrayInputStream(data);
+                DigestInputStream dis = new DigestInputStream(bais, mdCommon);
+                ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                DigestOutputStream dos = new DigestOutputStream(baos, mdCommon);) {
+
+            // Perform the update using all available/possible update methods
+            int k = 0;
+            byte[] buffer = new byte[10];
+
+            // use both read() and read(byte[], int, int)
+            while (k < data.length) {
+                int len = dis.read(buffer, 0, buffer.length);
+                if (len != -1) {
+                    k += len;
+                    if (k < data.length) {
+                        dos.write(data[k]);
+                        k++;
+                        dis.skip(1);
+                    }
+                }
+            }
+
+            // Get the output and the "correct" digest values
+            byte[] output = mdCommon.digest();
+            byte[] standard = md.digest(data);
+
+            // Compare generated digest values
+            return MessageDigest.isEqual(output, standard);
+        } catch (Exception ex) {
+            out.println("TestMDShare failed at:" + algo + "/" + dataLength
+                    + " with unexpected exception");
+            throw ex;
+        }
+    }
+}
diff --git a/jdk/test/java/security/MessageDigest/TestSameLength.java b/jdk/test/java/security/MessageDigest/TestSameLength.java
new file mode 100644
index 0000000..eb59815
--- /dev/null
+++ b/jdk/test/java/security/MessageDigest/TestSameLength.java
@@ -0,0 +1,143 @@
+/*
+ * 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.
+ */
+
+import static java.lang.System.out;
+
+import java.nio.ByteBuffer;
+import java.security.MessageDigest;
+import java.util.Random;
+
+/**
+ * @test
+ * @bug 8050371
+ * @summary Check md.getDigestLength() equal digest output length with various
+ *          algorithm/dataLen/(update,digest methods).
+ * @author Kevin Liu
+ */
+
+public class TestSameLength {
+
+    public static void main(String[] args) throws Exception {
+        TestSameLength test = new TestSameLength();
+        test.run();
+    }
+
+    private void run() throws Exception {
+        String[] algorithmArr = {
+                "SHA", "Sha", "SHA-1", "sha-1", "SHA1", "sha1", "MD5", "md5",
+                "SHA-224", "SHA-256", "SHA-384", "SHA-512"
+        };
+        int[] nUpdatesArr = {
+                0, 1, 2, 3
+        };
+        int[] dataLenArr = {
+                1, 50, 2500, 125000, 6250000
+        };
+
+        for (String algorithm: algorithmArr) {
+            for (UpdateMethod update: UpdateMethod.values()) {
+                for (int dataLen: dataLenArr) {
+                    if (!runTest(algorithm, dataLen, update)) {
+                        throw new RuntimeException(
+                                "Test failed at algorithm/dataLen/numUpdate:"
+                                        + algorithm + "/" + dataLen + "/"
+                                        + update.toString());
+                    }
+                }
+            }
+        }
+
+        out.println("All " + algorithmArr.length * nUpdatesArr.length
+                * dataLenArr.length + " tests Passed");
+    }
+
+    private boolean runTest(String algo, long dataLen,
+            UpdateMethod whichUpdate) throws Exception {
+        try {
+            // Do initialization
+            byte[] data = new byte[(int) dataLen];
+            new Random().nextBytes(data);
+            MessageDigest md = MessageDigest.getInstance(algo);
+            int outputLen = md.getDigestLength();
+
+            // Perform the update using all available/possible update methods
+            whichUpdate.updateDigest(data, md, dataLen);
+            // Get the output
+            byte[] output = md.digest();
+
+            // Compare input and output
+            return outputLen == output.length;
+        } catch (Exception ex) {
+            System.err.println("Testing: " + algo + "/" + dataLen + "/"
+                    + whichUpdate.toString()
+                    + " failed with unexpected exception");
+            ex.printStackTrace();
+            throw ex;
+        }
+    }
+
+    private static enum UpdateMethod {
+        UPDATE_BYTE {
+            @Override
+            public void updateDigest(byte[] data,
+                    MessageDigest md, long dataLen) {
+
+                for (int i = 0; i < dataLen; i++) {
+                    md.update(data[i]);
+                }
+            }
+        },
+
+        UPDATE_BUFFER {
+            @Override
+            public void updateDigest(byte[] data,
+                    MessageDigest md, long dataLen) {
+
+                md.update(data);
+            }
+        },
+
+        UPDATE_BUFFER_LEN {
+            @Override
+            public void updateDigest(byte[] data,
+                    MessageDigest md, long dataLen) {
+
+                for (int i = 0; i < dataLen; i++) {
+                    md.update(data, i, 1);
+                }
+            }
+        },
+
+        UPDATE_BYTE_BUFFER {
+            @Override
+            public void updateDigest(byte[] data,
+                    MessageDigest md, long dataLen) {
+
+                md.update(ByteBuffer.wrap(data));
+            }
+        };
+
+        public abstract void updateDigest(byte[] data,
+                    MessageDigest md, long dataLen);
+        }
+}
diff --git a/jdk/test/java/security/MessageDigest/TestSameValue.java b/jdk/test/java/security/MessageDigest/TestSameValue.java
new file mode 100644
index 0000000..aef4cea
--- /dev/null
+++ b/jdk/test/java/security/MessageDigest/TestSameValue.java
@@ -0,0 +1,310 @@
+/*
+ * 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.
+ */
+
+import static java.lang.System.out;
+
+import java.nio.ByteBuffer;
+import java.security.DigestException;
+import java.security.MessageDigest;
+import java.util.Random;
+
+/**
+ * @test
+ * @bug 8050371
+ * @summary Check md.digest(data) value whether same with digest output value
+ *          with various update/digest methods.
+ * @author Kevin Liu
+ */
+
+public class TestSameValue {
+
+    public static void main(String[] args) throws Exception {
+        TestSameValue test1 = new TestSameValue();
+        test1.run();
+    }
+
+    private void run() throws Exception {
+
+        byte[] data = new byte[6706];
+        MessageDigest md = null;
+        // Initialize input data
+        new Random().nextBytes(data);
+
+        String[] providers = {
+                null, "SUN"
+        };
+        String[] algorithmArr = {
+                "SHA", "Sha", "MD5", "md5", "SHA-224", "SHA-256", "SHA-384",
+                "SHA-512"
+        };
+
+        for (String algorithm: algorithmArr) {
+            for (String provider: providers) {
+                if (provider != null) {
+                    md = MessageDigest.getInstance(algorithm, provider);
+                } else {
+                    md = MessageDigest.getInstance(algorithm);
+                }
+                for (UpdateDigestMethod updateMethod: UpdateDigestMethod
+                        .values()) {
+                    byte[] output = updateMethod.updateDigest(data, md);
+                    // Get the output and the "correct" one
+                    byte[] standard = md.digest(data);
+                    // Compare input and output
+                    if (!MessageDigest.isEqual(output, standard)) {
+                        throw new RuntimeException(
+                                "Test failed at algorithm/provider/numUpdate:"
+                                        + algorithm + "/" + provider + "/"
+                                        + updateMethod);
+                    }
+                }
+            }
+        }
+
+        out.println("All " + algorithmArr.length
+                * UpdateDigestMethod.values().length * providers.length
+                + " tests Passed");
+    }
+
+    private static enum UpdateDigestMethod {
+
+        /*
+         * update the data one by one using method update(byte input) then
+         * do digest (giving the output buffer, offset, and the number of
+         * bytes to put in the output buffer)
+         */
+        UPDATE_DIGEST_BUFFER {
+            @Override
+            public byte[] updateDigest(byte[] data, MessageDigest md)
+                    throws DigestException {
+                for (byte element: data) {
+                    md.update(element);
+                }
+                byte[] output = new byte[md.getDigestLength()];
+                int len = md.digest(output, 0, output.length);
+                if (len != output.length) {
+                    throw new RuntimeException(
+                        "ERROR" + ": digest length differs!");
+                }
+                return output;
+            }
+        },
+
+        /*
+         * update the data one by one using method update(byte input)
+         * then do digest
+         */
+        UPDATE_DIGEST {
+            @Override
+            public byte[] updateDigest(byte[] data, MessageDigest md) {
+                for (byte element: data) {
+                    md.update(element);
+                }
+                return md.digest();
+            }
+        },
+
+        /*
+         * update all the data at once as a block, then do digest ( giving the
+         * output buffer, offset, and the number of bytes to put in the output
+         * buffer)
+         */
+        UPDATE_BLOCK_DIGEST_BUFFER {
+            @Override
+            public byte[] updateDigest(byte[] data, MessageDigest md)
+                    throws DigestException {
+                md.update(data);
+                byte[] output = new byte[md.getDigestLength()];
+                int len = md.digest(output, 0, output.length);
+                if (len != output.length) {
+                    throw new RuntimeException(
+                        "ERROR" + ": digest length differs!");
+                }
+                return output;
+            }
+        },
+
+        // update all the data at once as a block, then do digest
+        UPDATE_BLOCK_DIGEST {
+            @Override
+            public byte[] updateDigest(byte[] data, MessageDigest md) {
+                md.update(data);
+                return md.digest();
+            }
+        },
+
+        /*
+         * update the leading bytes (length is "data.length-LASTNBYTES")
+         * at once as a block, then do digest (do a final update using
+         * the left LASTNBYTES bytes which is passed as a parameter for
+         * the digest method, then complete the digest)
+         */
+        UPDATE_LEADING_BLOCK_DIGEST_REMAIN {
+            @Override
+            public byte[] updateDigest(byte[] data, MessageDigest md) {
+                byte[] mainPart = new byte[data.length - LASTNBYTES];
+                for (int i = 0; i < mainPart.length; i++) {
+                    mainPart[i] = data[i];
+                }
+                for (int j = 0; j < LASTNBYTES; j++) {
+                    REMAIN[j] = data[data.length - LASTNBYTES + j];
+                }
+                md.update(mainPart);
+                return md.digest(REMAIN);
+            }
+        },
+
+        /*
+         * update the data 2 bytes each time, after finishing updating,
+         * do digest (giving the output buffer, offset, and the number
+         * of bytes to put in the output buffer)
+         */
+        UPDATE_BYTES_DIGEST_BUFFER {
+            @Override
+            public byte[] updateDigest(byte[] data, MessageDigest md)
+                    throws DigestException {
+
+                for (int i = 0; i < data.length / 2; i++) {
+                    md.update(data, i * 2, 2);
+                }
+                byte[] output = new byte[md.getDigestLength()];
+                int len = md.digest(output, 0, output.length);
+                if (len != output.length) {
+                    throw new RuntimeException(
+                        "ERROR" + ": digest length differs!");
+                }
+                return output;
+            }
+        },
+
+        /*
+         * update the data 2 bytes each time, after finishing updating,
+         * do digest
+         */
+        UPDATE_BYTES_DIGEST {
+            @Override
+            public byte[] updateDigest(byte[] data, MessageDigest md) {
+                for (int i=0;i<data.length/2;i++){
+                    md.update(data,i*2,2);
+                }
+                return md.digest();
+            }
+        },
+
+        /*
+         * update the data one by one using method update(byte[] input,
+         * int offset, int len) for the leading bytes (length is
+         * "data.length-LASTNBYTES"), then do digest (do a final
+         * update using the left LASTNBYTES bytes which is passed
+         * as a parameter for digest method then complete the digest)
+         */
+        UPDATE_BUFFER_LEADING_DIGEST_REMAIN {
+            @Override
+            public byte[] updateDigest(byte[] data, MessageDigest md) {
+                for (int i = 0; i < data.length - LASTNBYTES; i++) {
+                    md.update(data, i, 1);
+                }
+                for (int j = 0; j < LASTNBYTES; j++) {
+                    REMAIN[j] = data[data.length - LASTNBYTES + j];
+                }
+                return md.digest(REMAIN);
+            }
+        },
+
+        /*
+         * update the data one by one using method update(byte input)
+         * for the leading bytes (length is "data.length-LASTNBYTES"),
+         * then do digest (do a final update using the left LASTNBYTES
+         * bytes which is passed as a parameter for digest method,
+         * then complete the digest)
+         */
+        UPDATE_LEADING_DIGEST_REMAIN {
+            @Override
+            public byte[] updateDigest(byte[] data, MessageDigest md) {
+                for (int i = 0; i < data.length - LASTNBYTES; i++) {
+                    md.update(data[i]);
+                }
+                for (int j = 0; j < LASTNBYTES; j++) {
+                    REMAIN[j] = data[data.length - LASTNBYTES + j];
+                }
+                return md.digest(REMAIN);
+            }
+        },
+
+        /*
+         * update all the data at once as a ByteBuffer, then do digest
+         * (giving the output buffer, offset, and the number of bytes
+         * to put in the output buffer)
+         */
+        UPDATE_BYTE_BUFFER_DIGEST_BUFFER {
+            @Override
+            public byte[] updateDigest(byte[] data, MessageDigest md)
+                    throws DigestException {
+                md.update(ByteBuffer.wrap(data));
+                byte[] output = new byte[md.getDigestLength()];
+                int len = md.digest(output, 0, output.length);
+                if (len != output.length) {
+                    throw new RuntimeException(
+                          "ERROR" + ": digest length differs!");
+                }
+                return output;
+            }
+        },
+
+        // update all the data at once as a ByteBuffer, then do digest
+        UPDATE_BYTE_BUFFER_DIGEST {
+            @Override
+            public byte[] updateDigest(byte[] data, MessageDigest md) {
+                md.update(ByteBuffer.wrap(data));
+                return md.digest();
+            }
+        },
+
+        /*
+         * update the leading bytes (length is "data.length-LASTNBYTES")
+         * at once as a ByteBuffer, then do digest (do a final update
+         * using the left LASTNBYTES bytes which is passed as a parameter
+         * for the digest method, then complete the digest)
+         */
+        UPDATE_BYTE_BUFFER_LEADING_DIGEST_REMAIN {
+            @Override
+            public byte[] updateDigest(byte[] data, MessageDigest md) {
+                byte[] mainPart = new byte[data.length - LASTNBYTES];
+                for (int i = 0; i < mainPart.length; i++) {
+                    mainPart[i] = data[i];
+                }
+                for (int j = 0; j < LASTNBYTES; j++) {
+                    REMAIN[j] = data[data.length - LASTNBYTES + j];
+                }
+                md.update(ByteBuffer.wrap(mainPart));
+                return md.digest(REMAIN);
+            }
+        };
+
+        private static final int LASTNBYTES = 5;
+        private static final byte[] REMAIN = new byte[LASTNBYTES];
+
+        public abstract byte[] updateDigest(byte[] data, MessageDigest md)
+                throws DigestException;
+    }
+}
diff --git a/jdk/test/java/security/Policy/SignedJar/SignedJarTest.java b/jdk/test/java/security/Policy/SignedJar/SignedJarTest.java
new file mode 100644
index 0000000..715a96c
--- /dev/null
+++ b/jdk/test/java/security/Policy/SignedJar/SignedJarTest.java
@@ -0,0 +1,186 @@
+/*
+ * 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.
+ */
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.security.AccessControlException;
+import java.security.AccessController;
+import java.security.Permission;
+import java.security.PrivilegedAction;
+import jdk.testlibrary.ProcessTools;
+
+/**
+ * @test
+ * @bug 8048360
+ * @summary test policy entry with signedBy alias
+ * @library /lib/testlibrary
+ * @run main/othervm SignedJarTest
+ */
+public class SignedJarTest {
+
+    private static final String FS = File.separator;
+    private static final String JAVA_HOME = System.getProperty("test.jdk");
+    private static final String TESTCLASSES = System.getProperty("test.classes", "");
+    private static final String TESTSRC = System.getProperty("test.src", "");
+    private static final String KEYTOOL = JAVA_HOME + FS + "bin" + FS + "keytool";
+    private static final String JAR = JAVA_HOME + FS + "bin" + FS + "jar";
+    private static final String JARSIGNER = JAVA_HOME + FS + "bin" + FS + "jarsigner";
+    private static final String PASSWORD = "password";
+    private static final String PWDFILE = "keypass";
+    private static final String POLICY1 = "SignedJarTest_1.policy";
+    private static final String POLICY2 = "SignedJarTest_2.policy";
+    private static final String KEYSTORE1 = "both.jks";
+    private static final String KEYSTORE2 = "first.jks";
+
+    public static void main(String args[]) throws Throwable {
+        //copy PrivilegeTest.class, policy files and keystore password file into current direcotry
+        Files.copy(Paths.get(TESTCLASSES, "PrivilegeTest.class"), Paths.get("PrivilegeTest.class"));
+        Files.copy(Paths.get(TESTSRC, POLICY1), Paths.get(POLICY1));
+        Files.copy(Paths.get(TESTSRC, POLICY2), Paths.get(POLICY2));
+        Files.copy(Paths.get(TESTSRC, PWDFILE), Paths.get(PWDFILE));
+
+        //create Jar file
+        ProcessTools.executeCommand(JAR, "-cvf", "test.jar", "PrivilegeTest.class");
+
+        //Creating first key , keystore both.jks
+        ProcessTools.executeCommand(KEYTOOL,
+                "-genkey",
+                "-alias", "first",
+                "-keystore", KEYSTORE1,
+                "-keypass", PASSWORD,
+                "-dname", "cn=First",
+                "-storepass", PASSWORD
+        ).shouldHaveExitValue(0);
+
+        //Creating Second key, keystore both.jks
+        ProcessTools.executeCommand(KEYTOOL,
+                "-genkey",
+                // "-storetype","JKS",
+                "-alias", "second",
+                "-keystore", KEYSTORE1,
+                "-keypass", PASSWORD,
+                "-dname", "cn=Second",
+                "-storepass", PASSWORD
+        ).shouldHaveExitValue(0);
+
+        //copy both.jks to first.jks, remove second Keypair from first.jks
+        Files.copy(Paths.get(KEYSTORE1), Paths.get(KEYSTORE2));
+        ProcessTools.executeCommand(KEYTOOL,
+                "-delete",
+                "-keystore", KEYSTORE2,
+                "-alias", "second",
+                "-storepass", PASSWORD
+        ).shouldHaveExitValue(0);
+
+        //sign jar with first key, first.jar is only signed by first signer
+        ProcessTools.executeCommand(JARSIGNER,
+                "-keystore", KEYSTORE1,
+                "-storepass", PASSWORD,
+                "-keypass", PASSWORD,
+                "-signedjar", "first.jar", "test.jar",
+                "first").shouldHaveExitValue(0);
+
+        //sign jar with second key, both.jar is signed by first and second signer
+        ProcessTools.executeCommand(JARSIGNER,
+                "-keystore", KEYSTORE1,
+                "-storepass", PASSWORD,
+                "-keypass", PASSWORD,
+                "-signedjar", "both.jar", "first.jar",
+                "second").shouldHaveExitValue(0);
+
+        //test case 1
+        //setIO permission granted to code that was signed by first signer
+        //setFactory permission granted to code that was signed by second signer
+        //Keystore that contains both first and second  keypairs
+        //code was singed by first signer
+        //Expect AccessControlException for setFactory permission
+        System.out.println("Test Case 1");
+        //copy policy file into current directory
+        String[] cmd = constructCMD("first.jar", POLICY1, "false", "true");
+        ProcessTools.executeTestJvm(cmd).shouldHaveExitValue(0);
+
+        //test case 2, test with both.jar
+        //setIO permission granted to code that was signed by first signer
+        //setFactory permission granted to code that was signed by second signer
+        //Keystore that contains both first and second  keypairs
+        //code was singed by first signer and second signer
+        //Expect no AccessControlException
+        System.out.println("Test Case 2");
+        cmd = constructCMD("both.jar", POLICY1, "false", "false");
+        ProcessTools.executeTestJvm(cmd).shouldHaveExitValue(0);
+
+        //test case 3
+        //setIO permission granted to code that was signed by first signer
+        //setFactory permission granted to code that was signed by second signer
+        //Keystore that contains only first keypairs
+        //code was singed by first signer and second signer
+        //Expect AccessControlException for setFactory permission
+        System.out.println("Test Case 3");
+        cmd = constructCMD("both.jar", POLICY2, "false", "true");
+        ProcessTools.executeTestJvm(cmd).shouldHaveExitValue(0);
+
+    }
+
+    private static String[] constructCMD(String classpath, String policy, String arg1, String arg2) {
+        String[] cmd = {
+            "-classpath", classpath,
+            "-Djava.security.manager",
+            "-Djava.security.policy=" + policy,
+            "PrivilegeTest",
+            arg1, arg2};
+        return cmd;
+    }
+}
+
+class PrivilegeTest {
+
+    private static final Permission PERM1 = new RuntimePermission("setIO");
+    private static final Permission PERM2 = new RuntimePermission("setFactory");
+
+    public static void main(String args[]) {
+        boolean expectException1 = Boolean.parseBoolean(args[0]);
+        boolean expectException2 = Boolean.parseBoolean(args[1]);
+        test(PERM1, expectException1);
+        test(PERM2, expectException2);
+    }
+
+    public static void test(Permission perm, boolean expectException) {
+        boolean getException = (Boolean) AccessController.doPrivileged((PrivilegedAction) () -> {
+            try {
+                AccessController.checkPermission(perm);
+                return (Boolean) false;
+            } catch (AccessControlException ex) {
+                return (Boolean) true;
+            }
+        });
+
+        if (expectException ^ getException) {
+            String message = "Check Permission :" + perm + "\n ExpectException = "
+                    + expectException + "\n getException = " + getException;
+            throw new RuntimeException(message);
+        }
+
+    }
+
+}
diff --git a/jdk/test/java/security/Policy/SignedJar/SignedJarTest_1.policy b/jdk/test/java/security/Policy/SignedJar/SignedJarTest_1.policy
new file mode 100644
index 0000000..6094fe5
--- /dev/null
+++ b/jdk/test/java/security/Policy/SignedJar/SignedJarTest_1.policy
@@ -0,0 +1,10 @@
+keystore "file:both.jks";
+keystorePasswordURL "file:keypass";
+
+grant signedBy "first" {
+    permission java.lang.RuntimePermission "setIO";
+};
+
+grant signedBy "second" {
+    permission java.lang.RuntimePermission "setFactory";
+};
diff --git a/jdk/test/java/security/Policy/SignedJar/SignedJarTest_2.policy b/jdk/test/java/security/Policy/SignedJar/SignedJarTest_2.policy
new file mode 100644
index 0000000..596dd38
--- /dev/null
+++ b/jdk/test/java/security/Policy/SignedJar/SignedJarTest_2.policy
@@ -0,0 +1,11 @@
+keystore "file:first.jks";
+keystorePasswordURL "file:keypass";
+
+grant signedBy "first" {
+    permission java.lang.RuntimePermission "setIO";
+};
+
+grant signedBy "second" {
+    permission java.lang.RuntimePermission "setFactory";
+};
+
diff --git a/jdk/test/java/security/Policy/SignedJar/keypass b/jdk/test/java/security/Policy/SignedJar/keypass
new file mode 100644
index 0000000..f3097ab
--- /dev/null
+++ b/jdk/test/java/security/Policy/SignedJar/keypass
@@ -0,0 +1 @@
+password
diff --git a/jdk/test/java/security/SecureRandom/DefaultProvider.java b/jdk/test/java/security/SecureRandom/DefaultProvider.java
new file mode 100644
index 0000000..50b4719
--- /dev/null
+++ b/jdk/test/java/security/SecureRandom/DefaultProvider.java
@@ -0,0 +1,110 @@
+/*
+ * 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.
+ */
+
+import static java.lang.System.out;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+
+/**
+ * @test
+ * @bug 8048356
+ * @summary Assert default provider used on all OS for SecureRandom
+ */
+public class DefaultProvider {
+
+    private static final String OS_NAME = System.getProperty("os.name");
+    private static final String SUNOS = "SunOS";
+    private static final String WINDOWS = "Windows";
+
+    public static void main(String[] args) throws NoSuchAlgorithmException {
+        out.println("Operating System: " + OS_NAME);
+
+        /* Test default provider used with constructor */
+        out.println("TEST: Default provider with constructor");
+        SecureRandom secureRandom = new SecureRandom();
+        String provider = secureRandom.getProvider().getName();
+        if (OS_NAME.startsWith(SUNOS)) {
+            if (!provider.startsWith("SunPKCS11-")) {
+                throw new RuntimeException("Unexpected provider name: "
+                        + provider);
+            }
+        } else if (!provider.equals("SUN")) {
+            throw new RuntimeException("Unexpected provider name: "
+                    + provider);
+        }
+        out.println("Passed, default provider with constructor: " + provider);
+
+        /* Test default provider with getInstance(String algorithm) */
+        out.println("TEST: SHA1PRNG supported on all platforms by SUN provider");
+        String algorithm = "SHA1PRNG";
+        provider = "SUN";
+
+        SecureRandom instance = SecureRandom.getInstance(algorithm);
+        assertInstance(instance, algorithm, provider);
+        out.println("Passed.");
+
+        if (!OS_NAME.startsWith(WINDOWS)) {
+            out.println("TEST: NativePRNG supported on all platforms"
+                    + "(except Windows), by SUN provider");
+            algorithm = "NativePRNG";
+            provider = "SUN";
+        } else {
+            out.println(
+                    "TEST: Windows-PRNG supported on windows by SunMSCAPI provider");
+            algorithm = "Windows-PRNG";
+            provider = "SunMSCAPI";
+        }
+        instance = SecureRandom.getInstance(algorithm);
+        assertInstance(instance, algorithm, provider);
+        out.println("Passed.");
+
+        if (OS_NAME.startsWith(SUNOS)) {
+            out.println(
+                    "TEST: PKCS11 is supported on Solaris by SunPKCS11 provider");
+            algorithm = "PKCS11";
+            provider = "SunPKCS11-Solaris";
+            instance = SecureRandom.getInstance(algorithm);
+            assertInstance(instance, algorithm, provider);
+            out.println("Passed.");
+        }
+    }
+
+    private static void assertInstance(SecureRandom instance,
+            String expectedAlgorithm,
+            String expectedProvider) {
+        if (instance != null) {
+            if (!expectedAlgorithm.equalsIgnoreCase(instance.getAlgorithm())) {
+                throw new RuntimeException("Expected algorithm:"
+                        + expectedAlgorithm + " actual: " + instance.getAlgorithm());
+            }
+
+            if (!expectedProvider.equalsIgnoreCase(instance.getProvider().getName())) {
+                throw new RuntimeException("Expected provider: "
+                        + expectedProvider + " actual: "
+                        + instance.getProvider().getName());
+            }
+        } else {
+            throw new RuntimeException("Secure instance is not created");
+        }
+    }
+}
diff --git a/jdk/test/java/security/Signature/Offsets.java b/jdk/test/java/security/Signature/Offsets.java
new file mode 100644
index 0000000..9e71690
--- /dev/null
+++ b/jdk/test/java/security/Signature/Offsets.java
@@ -0,0 +1,251 @@
+/*
+ * 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.
+ */
+
+import java.security.InvalidKeyException;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.Signature;
+import java.security.SignatureException;
+import jdk.testlibrary.RandomFactory;
+
+/*
+ * @test
+ * @bug 8050374
+ * @key randomness
+ * @summary This test validates signature verification
+ *          Signature.verify(byte[], int, int). The test uses RandomFactory to
+ *          get random set of clear text data to sign. After the signature
+ *          generation, the test tries to verify signature with the above API
+ *          and passing in different signature offset (0, 33, 66, 99).
+ * @library /lib/testlibrary
+ * @run main Offsets SUN NONEwithDSA
+ * @run main Offsets SUN SHA1withDSA
+ * @run main Offsets SUN SHA224withDSA
+ * @run main Offsets SUN SHA256withDSA
+ */
+public class Offsets {
+
+    private final int size;
+    private final byte[] cleartext;
+    private final PublicKey pubkey;
+    private final Signature signature;
+    private final byte[] signed;
+
+    private Offsets(Signature signature, PublicKey pubkey, PrivateKey privkey,
+            int size, byte[] cleartext) throws InvalidKeyException,
+                SignatureException {
+        this.pubkey = pubkey;
+        this.signature = signature;
+        this.size = size;
+        this.cleartext = cleartext;
+
+        signature.initSign(privkey);
+        signature.update(cleartext, 0, size);
+        signed = signature.sign();
+    }
+
+    int getDataSize() {
+        return size;
+    }
+
+    int getSignatureLength() {
+        return signed.length;
+    }
+
+    byte[] shiftSignData(int offset) {
+        byte[] testSignData = new byte[offset + signed.length];
+        System.arraycopy(signed, 0, testSignData, offset,
+                signed.length);
+        return testSignData;
+    }
+
+    boolean verifySignature(byte[] sigData, int sigOffset, int sigLength,
+            int updateOffset, int updateLength)
+                throws InvalidKeyException, SignatureException {
+        signature.initVerify(pubkey);
+        signature.update(cleartext, updateOffset, updateLength);
+        return signature.verify(sigData, sigOffset, sigLength);
+    }
+
+    static Offsets init(String provider, String algorithm)
+            throws NoSuchAlgorithmException, NoSuchProviderException,
+            InvalidKeyException, SignatureException {
+        // fill the cleartext data with random bytes
+        byte[] cleartext = new byte[100];
+        RandomFactory.getRandom().nextBytes(cleartext);
+
+        // NONEwith requires input to be of 20 bytes
+        int size = algorithm.contains("NONEwith") ? 20 : 100;
+
+        // create signature instance
+        Signature signature = Signature.getInstance(algorithm, provider);
+
+        String keyAlgo;
+        if (algorithm.contains("RSA")) {
+            keyAlgo = "RSA";
+        } else if (algorithm.contains("ECDSA")) {
+            keyAlgo = "EC";
+        } else if (algorithm.contains("DSA")) {
+            keyAlgo = "DSA";
+        } else {
+            throw new RuntimeException("Test doesn't support this signature "
+                    + "algorithm: " + algorithm);
+        }
+
+        KeyPairGenerator kpg = KeyPairGenerator.getInstance(keyAlgo, provider);
+        KeyPair kp = kpg.generateKeyPair();
+        PublicKey pubkey = kp.getPublic();
+        PrivateKey privkey = kp.getPrivate();
+
+        return new Offsets(signature, pubkey, privkey, size, cleartext);
+    }
+
+    public static void main(String[] args) throws NoSuchAlgorithmException,
+            InvalidKeyException, SignatureException {
+        if (args.length < 2) {
+            throw new RuntimeException("Wrong parameters");
+        }
+
+        boolean result = true;
+        try {
+            Offsets test = init(args[0], args[1]);
+
+            // We are trying 3 different offsets, data size has nothing to do
+            // with signature length
+            for (int chunk = 3; chunk > 0; chunk--) {
+                int signOffset = test.getDataSize() / chunk;
+
+                System.out.println("Running test with offset " + signOffset);
+                byte[] signData = test.shiftSignData(signOffset);
+
+                boolean success = test.verifySignature(signData, signOffset,
+                        test.getSignatureLength(), 0, test.getDataSize());
+
+                if (success) {
+                    System.out.println("Successfully verified with offset "
+                            + signOffset);
+                } else {
+                    System.out.println("Verification failed with offset "
+                            + signOffset);
+                    result = false;
+                }
+            }
+
+            // save signature to offset 0
+            byte[] signData = test.shiftSignData(0);
+
+            // Negative tests
+
+            // Test signature offset 0.
+            // Wrong test data will be passed to update,
+            // so signature verification should fail.
+            for (int chunk = 3; chunk > 0; chunk--) {
+                int dataOffset = (test.getDataSize() - 1) / chunk;
+                boolean success;
+                try {
+                    success = test.verifySignature(signData, 0,
+                            test.getSignatureLength(), dataOffset,
+                            (test.getDataSize() - dataOffset));
+                } catch (SignatureException e) {
+                    // Since we are trying different data size, it can throw
+                    // SignatureException
+                    success = false;
+                }
+
+                if (!success) {
+                    System.out.println("Signature verification failed "
+                            + "as expected, with data offset " + dataOffset
+                            + " and length "
+                            + (test.getDataSize() - dataOffset));
+                } else {
+                    System.out.println("Signature verification "
+                            + "should not succeed, with data offset "
+                            + dataOffset + " and length "
+                            + (test.getDataSize() - dataOffset));
+                    result = false;
+                }
+            }
+
+            // Tests with manipulating offset and length
+            result &= Offsets.checkFailure(test, signData, -1,
+                    test.getSignatureLength());
+
+            result &= Offsets.checkFailure(test, signData, 0,
+                    test.getSignatureLength() - 1);
+
+            result &= Offsets.checkFailure(test, signData,
+                    test.getSignatureLength() + 1, test.getSignatureLength());
+
+            result &= Offsets.checkFailure(test, signData, 0,
+                    test.getSignatureLength() + 1);
+
+            result &= Offsets.checkFailure(test, signData, 0, 0);
+
+            result &= Offsets.checkFailure(test, signData, 0, -1);
+
+            result &= Offsets.checkFailure(test, signData,
+                    2147483646, test.getSignatureLength());
+
+            result &= Offsets.checkFailure(test, null, 0,
+                    test.getSignatureLength());
+        } catch (NoSuchProviderException nspe) {
+            System.out.println("No such provider: " + nspe);
+        }
+
+        if (!result) {
+            throw new RuntimeException("Some test cases failed");
+        }
+    }
+
+    static boolean checkFailure(Offsets test, byte[] signData, int offset,
+            int length) {
+        boolean success;
+        try {
+            success = test.verifySignature(signData, offset, length, 0,
+                    test.getDataSize());
+        } catch (IllegalArgumentException | SignatureException e) {
+            System.out.println("Expected exception: " + e);
+            success = false;
+        } catch (InvalidKeyException e) {
+            System.out.println("Unexpected exception: " + e);
+            return false;
+        }
+
+        if (!success) {
+            System.out.println("Signature verification failed as expected, "
+                    + "with signature offset " + offset + " and length "
+                    + length);
+            return true;
+        } else {
+            System.out.println("Signature verification should not succeed, "
+                    + "with signature offset " + offset + " and length "
+                    + length);
+            return false;
+        }
+    }
+
+}
diff --git a/jdk/test/java/security/SignedObject/Chain.java b/jdk/test/java/security/SignedObject/Chain.java
new file mode 100644
index 0000000..e6c423c
--- /dev/null
+++ b/jdk/test/java/security/SignedObject/Chain.java
@@ -0,0 +1,216 @@
+/*
+ * 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.
+ */
+
+import java.security.Signature;
+import java.security.SignedObject;
+import java.security.KeyPairGenerator;
+import java.security.KeyPair;
+import java.security.NoSuchProviderException;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.util.Arrays;
+
+/*
+ * @test
+ * @bug 8050374
+ * @summary Verify a chain of signed objects
+ */
+public class Chain {
+
+    static enum KeyAlg {
+        RSA("RSA"),
+        DSA("DSA"),
+        EC("EC");
+
+        final String name;
+
+        KeyAlg(String alg) {
+            this.name = alg;
+        }
+    }
+
+    static enum Provider {
+        Default("default"),
+        SunRsaSign("SunRsaSign"),
+        Sun("SUN"),
+        SunEC("SunEC"),
+        SunJSSE("SunJSSE"),
+        SunMSCAPI("SunMSCAPI");
+
+        final String name;
+
+        Provider(String name) {
+            this.name = name;
+        }
+    }
+
+    static enum SigAlg {
+        MD2withRSA("MD2withRSA"),
+        MD5withRSA("md5withRSA"),
+
+        SHA1withDSA("SHA1withDSA"),
+        SHA224withDSA("SHA224withDSA"),
+        SHA256withDSA("SHA256withDSA"),
+
+        SHA1withRSA("Sha1withrSA"),
+        SHA224withRSA("SHA224withRSA"),
+        SHA256withRSA("SHA256withRSA"),
+        SHA384withRSA("SHA384withRSA"),
+        SHA512withRSA("SHA512withRSA"),
+
+        SHA1withECDSA("SHA1withECDSA"),
+        SHA256withECDSA("SHA256withECDSA"),
+        SHA224withECDSA("SHA224withECDSA"),
+        SHA384withECDSA("SHA384withECDSA"),
+        SHA512withECDSA("SHA512withECDSA"),
+
+        MD5andSHA1withRSA("MD5andSHA1withRSA");
+
+        final String name;
+
+        SigAlg(String name) {
+            this.name = name;
+        }
+    }
+
+    static class Test {
+        final Provider provider;
+        final KeyAlg keyAlg;
+        final SigAlg sigAlg;
+
+        Test(SigAlg sigAlg, KeyAlg keyAlg, Provider privider) {
+            this.provider = privider;
+            this.keyAlg = keyAlg;
+            this.sigAlg = sigAlg;
+        }
+    }
+
+    private static final Test[] tests = {
+        new Test(SigAlg.SHA1withDSA, KeyAlg.DSA, Provider.Default),
+        new Test(SigAlg.MD2withRSA, KeyAlg.RSA, Provider.Default),
+        new Test(SigAlg.MD5withRSA, KeyAlg.RSA, Provider.Default),
+        new Test(SigAlg.SHA1withRSA, KeyAlg.RSA, Provider.Default),
+        new Test(SigAlg.SHA1withDSA, KeyAlg.DSA, Provider.Sun),
+        new Test(SigAlg.SHA224withDSA, KeyAlg.DSA, Provider.Sun),
+        new Test(SigAlg.SHA256withDSA, KeyAlg.DSA, Provider.Sun),
+    };
+
+    private static final String str = "to-be-signed";
+    private static final int N = 3;
+
+    public static void main(String argv[]) {
+        boolean result = Arrays.stream(tests).allMatch((test) -> runTest(test));
+        if(result) {
+            System.out.println("All tests passed");
+        } else {
+            throw new RuntimeException("Some tests failed");
+        }
+    }
+
+    static boolean runTest(Test test) {
+        System.out.format("Test: provider = %s, signature algorithm = %s, "
+                + "key algorithm = %s\n",
+                test.provider, test.sigAlg, test.keyAlg);
+        try {
+            // Generate all private/public key pairs
+            PrivateKey[] privKeys = new PrivateKey[N];
+            PublicKey[] pubKeys = new PublicKey[N];
+            PublicKey[] anotherPubKeys = new PublicKey[N];
+            KeyPairGenerator kpg = KeyPairGenerator.getInstance(
+                    test.keyAlg.name);
+            for (int j=0; j < N; j++) {
+                KeyPair kp = kpg.genKeyPair();
+                KeyPair anotherKp = kpg.genKeyPair();
+                privKeys[j] = kp.getPrivate();
+                pubKeys[j] = kp.getPublic();
+                anotherPubKeys[j] = anotherKp.getPublic();
+
+                if (Arrays.equals(pubKeys[j].getEncoded(),
+                        anotherPubKeys[j].getEncoded())) {
+                    System.out.println("Failed: it should not get "
+                            + "the same pair of public key");
+                    return false;
+                }
+            }
+
+            Signature signature;
+            if (test.provider != Provider.Default) {
+                signature = Signature.getInstance(test.sigAlg.name,
+                        test.provider.name);
+            } else {
+                signature = Signature.getInstance(test.sigAlg.name);
+            }
+
+            // Create a chain of signed objects
+            SignedObject[] objects = new SignedObject[N];
+            objects[0] = new SignedObject(str, privKeys[0], signature);
+            for (int j = 1; j < N; j++) {
+                objects[j] = new SignedObject(objects[j - 1], privKeys[j],
+                        signature);
+            }
+
+            // Verify the chain
+            int n = objects.length - 1;
+            SignedObject object = objects[n];
+            do {
+                if (!object.verify(pubKeys[n], signature)) {
+                    System.out.println("Failed: verification failed, n = " + n);
+                    return false;
+                }
+
+                if (object.verify(anotherPubKeys[n], signature)) {
+                    System.out.println("Failed: verification should not "
+                            + "succeed with wrong public key, n = " + n);
+                    return false;
+                }
+
+                object = (SignedObject) object.getObject();
+                n--;
+            } while (n > 0);
+
+            System.out.println("signed data: " + object.getObject());
+            if (!str.equals(object.getObject())) {
+                System.out.println("Failed: signed data is not equal to "
+                        + "original one");
+                return false;
+            }
+
+            System.out.println("Test passed");
+            return true;
+        } catch (NoSuchProviderException nspe) {
+            if (test.provider == Provider.SunMSCAPI
+                    && !System.getProperty("os.name").startsWith("Windows")) {
+                System.out.println("SunMSCAPI is available only on Windows: "
+                        + nspe);
+                return true;
+            }
+            System.out.println("Unexpected exception: " + nspe);
+            return false;
+        } catch (Exception e) {
+            System.out.println("Unexpected exception: " + e);
+            e.printStackTrace(System.out);
+            return false;
+        }
+    }
+}
+
diff --git a/jdk/test/java/security/SignedObject/Copy.java b/jdk/test/java/security/SignedObject/Copy.java
new file mode 100644
index 0000000..22406ea
--- /dev/null
+++ b/jdk/test/java/security/SignedObject/Copy.java
@@ -0,0 +1,123 @@
+/*
+ * 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.
+ */
+
+import java.io.Serializable;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.Signature;
+import java.security.SignedObject;
+
+/*
+ * @test
+ * @bug 8050374
+ * @summary Checks if a signed object is a copy of an original object
+ */
+public class Copy {
+
+    private static final String DSA = "DSA";
+    private static final int KEY_SIZE = 512;
+    private static final int MAGIC = 123;
+
+    public static void main(String args[]) throws Exception {
+        KeyPairGenerator kg = KeyPairGenerator.getInstance(DSA);
+        kg.initialize(KEY_SIZE);
+        KeyPair kp = kg.genKeyPair();
+
+        Signature signature = Signature.getInstance(DSA);
+        Test original = new Test();
+        SignedObject so = new SignedObject(original, kp.getPrivate(),
+                signature);
+        System.out.println("Signature algorithm: " + so.getAlgorithm());
+
+        signature = Signature.getInstance(DSA, "SUN");
+        if (!so.verify(kp.getPublic(), signature)) {
+            throw new RuntimeException("Verification failed");
+        }
+
+        kg = KeyPairGenerator.getInstance(DSA);
+        kg.initialize(KEY_SIZE);
+        kp = kg.genKeyPair();
+
+        if (so.verify(kp.getPublic(), signature)) {
+            throw new RuntimeException("Unexpected success");
+        }
+
+        Object copy = so.getObject();
+        if (!original.equals(copy)) {
+            throw new RuntimeException("Signed object is not equal "
+                    + "to original one: " + copy);
+        }
+
+        /*
+         * The signed object is a copy of an original one.
+         * Once the copy is made, further manipulation
+         * of the original object shouldn't has any effect on the copy.
+         */
+        original.set(MAGIC - 1);
+        copy = so.getObject();
+        if (original.equals(copy)) {
+            throw new RuntimeException("Signed object is not a copy "
+                    + "of original one: " + copy);
+        }
+
+        System.out.println("Test passed");
+    }
+
+    private static class Test implements Serializable {
+        private int number = MAGIC;
+
+        public int get() {
+            return number;
+        }
+
+        public void set(int magic) {
+            this.number = magic;
+        }
+
+        @Override
+        public int hashCode() {
+            return number;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (obj == null) {
+                return false;
+            }
+
+            if (!(obj instanceof Test)) {
+                return false;
+            }
+
+            Test other = (Test) obj;
+            return number == other.number;
+        }
+
+        @Override
+        public String toString() {
+            return "" + number;
+        }
+    }
+}
+
+
diff --git a/jdk/test/java/security/cert/CertPathEncodingTest.java b/jdk/test/java/security/cert/CertPathEncodingTest.java
new file mode 100644
index 0000000..2bcfcc7
--- /dev/null
+++ b/jdk/test/java/security/cert/CertPathEncodingTest.java
@@ -0,0 +1,253 @@
+/*
+ * Copyright (c) 1998, 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.
+ */
+import java.io.ByteArrayInputStream;
+import java.security.cert.CertPath;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateFactory;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.List;
+
+/*
+ * @test
+ * @bug 8074931
+ * @summary CertPathEncodingTest tests the ability of the CertPath and
+ *          CertificateFactory to encode and decode CertPaths.
+ */
+public final class CertPathEncodingTest {
+    /*
+            Certificate:
+                Data:
+                    Version: 3 (0x2)
+                    Serial Number: 935438132 (0x37c1a734)
+                Signature Algorithm: dsaWithSHA1
+                    Issuer: C=us, O=sun, OU=east, OU=bcn, CN=yassir
+                    Validity
+                        Not Before: Aug 23 19:55:32 1999 GMT
+                        Not After : Aug 22 19:55:32 2000 GMT
+                    Subject: C=us, O=sun, OU=east, OU=bcn
+                    Subject Public Key Info:
+                        Public Key Algorithm: dsaEncryption
+                            pub:
+                                63:47:4f:f6:29:e5:98:a2:21:fd:da:97:9e:3f:ca:
+                                b0:17:49:8d:8a:a7:06:0d:a6:78:97:39:59:33:72:
+                                a2:a5:74:d5:3a:ef:e6:7c:07:d7:8e:8e:d1:66:73:
+                                99:14:04:96:f5:31:d6:72:ee:d2:53:f8:90:b5:f3:
+                                c3:f1:64:ba:1a:9e:c0:0a:da:92:48:c5:d3:84:7e:
+                                48:09:66:d9:51:ba:74:56:5a:77:8a:8c:9a:9c:f6:
+                                84:12:61:12:51:dc:c6:4f:84:94:ec:cb:78:51:83:
+                                8c:20:8a:53:7b:d2:b6:36:df:50:35:95:1f:cb:50:
+                                55:8b:3f:fb:e2:77:cb
+                            P:
+                                00:fd:7f:53:81:1d:75:12:29:52:df:4a:9c:2e:ec:
+                                e4:e7:f6:11:b7:52:3c:ef:44:00:c3:1e:3f:80:b6:
+                                51:26:69:45:5d:40:22:51:fb:59:3d:8d:58:fa:bf:
+                                c5:f5:ba:30:f6:cb:9b:55:6c:d7:81:3b:80:1d:34:
+                                6f:f2:66:60:b7:6b:99:50:a5:a4:9f:9f:e8:04:7b:
+                                10:22:c2:4f:bb:a9:d7:fe:b7:c6:1b:f8:3b:57:e7:
+                                c6:a8:a6:15:0f:04:fb:83:f6:d3:c5:1e:c3:02:35:
+                                54:13:5a:16:91:32:f6:75:f3:ae:2b:61:d7:2a:ef:
+                                f2:22:03:19:9d:d1:48:01:c7
+                            Q:
+                                00:97:60:50:8f:15:23:0b:cc:b2:92:b9:82:a2:eb:
+                                84:0b:f0:58:1c:f5
+                            G:
+                                00:f7:e1:a0:85:d6:9b:3d:de:cb:bc:ab:5c:36:b8:
+                                57:b9:79:94:af:bb:fa:3a:ea:82:f9:57:4c:0b:3d:
+                                07:82:67:51:59:57:8e:ba:d4:59:4f:e6:71:07:10:
+                                81:80:b4:49:16:71:23:e8:4c:28:16:13:b7:cf:09:
+                                32:8c:c8:a6:e1:3c:16:7a:8b:54:7c:8d:28:e0:a3:
+                                ae:1e:2b:b3:a6:75:91:6e:a3:7f:0b:fa:21:35:62:
+                                f1:fb:62:7a:01:24:3b:cc:a4:f1:be:a8:51:90:89:
+                                a8:83:df:e1:5a:e5:9f:06:92:8b:66:5e:80:7b:55:
+                                25:64:01:4c:3b:fe:cf:49:2a
+                    X509v3 extensions:
+                        X509v3 Key Usage: critical
+                            Digital Signature, Key Encipherment, Certificate Sign
+                Signature Algorithm: dsaWithSHA1
+                     r:
+                         52:80:52:2b:2c:3d:02:66:58:b4:dc:ef:52:26:70:
+                         1b:53:ca:b3:7d
+                     s:
+                         62:03:b2:ab:3e:18:2a:66:09:b6:ce:d4:05:a5:8e:
+                         a5:7a:0d:55:67
+    */
+    private static final String cert1 =
+            "-----BEGIN CERTIFICATE-----\n" +
+            "MIICzTCCAougAwIBAgIEN8GnNDALBgcqhkjOOAQDBQAwSTELMAkGA1UEBhMCdXMx\n" +
+            "DDAKBgNVBAoTA3N1bjENMAsGA1UECxMEZWFzdDEMMAoGA1UECxMDYmNuMQ8wDQYD\n" +
+            "VQQDEwZ5YXNzaXIwHhcNOTkwODIzMTk1NTMyWhcNMDAwODIyMTk1NTMyWjA4MQsw\n" +
+            "CQYDVQQGEwJ1czEMMAoGA1UEChMDc3VuMQ0wCwYDVQQLEwRlYXN0MQwwCgYDVQQL\n" +
+            "EwNiY24wggG1MIIBLAYHKoZIzjgEATCCAR8CgYEA/X9TgR11EilS30qcLuzk5/YR\n" +
+            "t1I870QAwx4/gLZRJmlFXUAiUftZPY1Y+r/F9bow9subVWzXgTuAHTRv8mZgt2uZ\n" +
+            "UKWkn5/oBHsQIsJPu6nX/rfGG/g7V+fGqKYVDwT7g/bTxR7DAjVUE1oWkTL2dfOu\n" +
+            "K2HXKu/yIgMZndFIAccCFQCXYFCPFSMLzLKSuYKi64QL8Fgc9QKBgQD34aCF1ps9\n" +
+            "3su8q1w2uFe5eZSvu/o66oL5V0wLPQeCZ1FZV4661FlP5nEHEIGAtEkWcSPoTCgW\n" +
+            "E7fPCTKMyKbhPBZ6i1R8jSjgo64eK7OmdZFuo38L+iE1YvH7YnoBJDvMpPG+qFGQ\n" +
+            "iaiD3+Fa5Z8GkotmXoB7VSVkAUw7/s9JKgOBggACf2NHT/Yp5ZiiIf3al54/yrAX\n" +
+            "SY2KpwYNpniXOVkzcqKldNU67+Z8B9eOjtFmc5kUBJb1MdZy7tJT+JC188PxZLoa\n" +
+            "nsAK2pJIxdOEfkgJZtlRunRWWneKjJqc9oQSYRJR3MZPhJTsy3hRg4wgilN70rY2\n" +
+            "31A1lR/LUFWLP/vid8ujEzARMA8GA1UdDwEB/wQFAwMHpAAwCwYHKoZIzjgEAwUA\n" +
+            "Ay8AMCwCFFKAUissPQJmWLTc71ImcBtTyrN9AhRiA7KrPhgqZgm2ztQFpY6leg1V\n" +
+            "Zw==\n" +
+            "-----END CERTIFICATE-----\n" +
+            "";
+
+    /*
+            Certificate:
+                Data:
+                    Version: 3 (0x2)
+                    Serial Number: 935095671 (0x37bc6d77)
+                Signature Algorithm: dsaWithSHA1
+                    Issuer: C=us, O=sun, OU=east, OU=bcn, CN=yassir
+                    Validity
+                        Not Before: Aug 19 20:47:51 1999 GMT
+                        Not After : Aug 18 20:47:51 2000 GMT
+                    Subject: C=us, O=sun, OU=east, OU=bcn, CN=yassir
+                    Subject Public Key Info:
+                        Public Key Algorithm: dsaEncryption
+                            pub:
+                                0a:cc:a4:ec:d6:88:45:c2:24:6b:0d:78:f1:82:f3:
+                                5e:3e:31:5d:fb:64:d5:06:5e:39:16:f1:0a:85:d1:
+                                ff:d1:a4:74:c5:e6:b0:ba:93:1c:ee:69:51:be:3b:
+                                a6:66:44:50:b4:f0:5e:0e:dd:9f:08:71:fe:a1:91:
+                                2e:d4:9e:6b:b2:c0:82:3c:91:6c:18:b0:d9:bc:a3:
+                                48:91:3f:8b:59:01:61:00:02:ab:22:31:bc:7c:6c:
+                                0d:9f:ed:be:33:e6:5c:44:9e:62:30:95:f8:6d:22:
+                                d7:e5:85:4c:b0:98:6e:ad:cc:ca:3b:ad:cb:fa:f7:
+                                9f:37:13:f7:ca:e2:22:ba
+                            P:
+                                00:fd:7f:53:81:1d:75:12:29:52:df:4a:9c:2e:ec:
+                                e4:e7:f6:11:b7:52:3c:ef:44:00:c3:1e:3f:80:b6:
+                                51:26:69:45:5d:40:22:51:fb:59:3d:8d:58:fa:bf:
+                                c5:f5:ba:30:f6:cb:9b:55:6c:d7:81:3b:80:1d:34:
+                                6f:f2:66:60:b7:6b:99:50:a5:a4:9f:9f:e8:04:7b:
+                                10:22:c2:4f:bb:a9:d7:fe:b7:c6:1b:f8:3b:57:e7:
+                                c6:a8:a6:15:0f:04:fb:83:f6:d3:c5:1e:c3:02:35:
+                                54:13:5a:16:91:32:f6:75:f3:ae:2b:61:d7:2a:ef:
+                                f2:22:03:19:9d:d1:48:01:c7
+                            Q:
+                                00:97:60:50:8f:15:23:0b:cc:b2:92:b9:82:a2:eb:
+                                84:0b:f0:58:1c:f5
+                            G:
+                                00:f7:e1:a0:85:d6:9b:3d:de:cb:bc:ab:5c:36:b8:
+                                57:b9:79:94:af:bb:fa:3a:ea:82:f9:57:4c:0b:3d:
+                                07:82:67:51:59:57:8e:ba:d4:59:4f:e6:71:07:10:
+                                81:80:b4:49:16:71:23:e8:4c:28:16:13:b7:cf:09:
+                                32:8c:c8:a6:e1:3c:16:7a:8b:54:7c:8d:28:e0:a3:
+                                ae:1e:2b:b3:a6:75:91:6e:a3:7f:0b:fa:21:35:62:
+                                f1:fb:62:7a:01:24:3b:cc:a4:f1:be:a8:51:90:89:
+                                a8:83:df:e1:5a:e5:9f:06:92:8b:66:5e:80:7b:55:
+                                25:64:01:4c:3b:fe:cf:49:2a
+                    X509v3 extensions:
+                        X509v3 Key Usage: critical
+                            Digital Signature, Key Encipherment, Certificate Sign
+                        X509v3 Basic Constraints: critical
+                            CA:TRUE, pathlen:5
+                Signature Algorithm: dsaWithSHA1
+                     r:
+                         2f:88:46:37:94:92:b2:02:07:5b:8d:76:e5:81:23:
+                         85:7f:bc:8d:b9
+                     s:
+                         00:8b:d7:41:fa:11:c7:ab:27:92:5d:0a:03:98:56:
+                         36:42:5f:f5:1f:9d
+    */
+    private static final String cert2 =
+            "-----BEGIN CERTIFICATE-----\n" +
+            "MIIC9TCCArKgAwIBAgIEN7xtdzALBgcqhkjOOAQDBQAwSTELMAkGA1UEBhMCdXMx\n" +
+            "DDAKBgNVBAoTA3N1bjENMAsGA1UECxMEZWFzdDEMMAoGA1UECxMDYmNuMQ8wDQYD\n" +
+            "VQQDEwZ5YXNzaXIwHhcNOTkwODE5MjA0NzUxWhcNMDAwODE4MjA0NzUxWjBJMQsw\n" +
+            "CQYDVQQGEwJ1czEMMAoGA1UEChMDc3VuMQ0wCwYDVQQLEwRlYXN0MQwwCgYDVQQL\n" +
+            "EwNiY24xDzANBgNVBAMTBnlhc3NpcjCCAbcwggEsBgcqhkjOOAQBMIIBHwKBgQD9\n" +
+            "f1OBHXUSKVLfSpwu7OTn9hG3UjzvRADDHj+AtlEmaUVdQCJR+1k9jVj6v8X1ujD2\n" +
+            "y5tVbNeBO4AdNG/yZmC3a5lQpaSfn+gEexAiwk+7qdf+t8Yb+DtX58aophUPBPuD\n" +
+            "9tPFHsMCNVQTWhaRMvZ1864rYdcq7/IiAxmd0UgBxwIVAJdgUI8VIwvMspK5gqLr\n" +
+            "hAvwWBz1AoGBAPfhoIXWmz3ey7yrXDa4V7l5lK+7+jrqgvlXTAs9B4JnUVlXjrrU\n" +
+            "WU/mcQcQgYC0SRZxI+hMKBYTt88JMozIpuE8FnqLVHyNKOCjrh4rs6Z1kW6jfwv6\n" +
+            "ITVi8ftiegEkO8yk8b6oUZCJqIPf4VrlnwaSi2ZegHtVJWQBTDv+z0kqA4GEAAKB\n" +
+            "gArMpOzWiEXCJGsNePGC814+MV37ZNUGXjkW8QqF0f/RpHTF5rC6kxzuaVG+O6Zm\n" +
+            "RFC08F4O3Z8Icf6hkS7UnmuywII8kWwYsNm8o0iRP4tZAWEAAqsiMbx8bA2f7b4z\n" +
+            "5lxEnmIwlfhtItflhUywmG6tzMo7rcv69583E/fK4iK6oycwJTAPBgNVHQ8BAf8E\n" +
+            "BQMDB6QAMBIGA1UdEwEB/wQIMAYBAf8CAQUwCwYHKoZIzjgEAwUAAzAAMC0CFC+I\n" +
+            "RjeUkrICB1uNduWBI4V/vI25AhUAi9dB+hHHqyeSXQoDmFY2Ql/1H50=\n" +
+            "-----END CERTIFICATE-----\n" +
+            "";
+
+    private static final String pkcs7path =
+            "MIIF9QYJKoZIhvcNAQcCoIIF5jCCBeICAQExADALBgkqhkiG9w0BBwGgggXKMIICzTCCAougAwIB\n" +
+            "AgIEN8GnNDALBgcqhkjOOAQDBQAwSTELMAkGA1UEBhMCdXMxDDAKBgNVBAoTA3N1bjENMAsGA1UE\n" +
+            "CxMEZWFzdDEMMAoGA1UECxMDYmNuMQ8wDQYDVQQDEwZ5YXNzaXIwHhcNOTkwODIzMTk1NTMyWhcN\n" +
+            "MDAwODIyMTk1NTMyWjA4MQswCQYDVQQGEwJ1czEMMAoGA1UEChMDc3VuMQ0wCwYDVQQLEwRlYXN0\n" +
+            "MQwwCgYDVQQLEwNiY24wggG1MIIBLAYHKoZIzjgEATCCAR8CgYEA/X9TgR11EilS30qcLuzk5/YR\n" +
+            "t1I870QAwx4/gLZRJmlFXUAiUftZPY1Y+r/F9bow9subVWzXgTuAHTRv8mZgt2uZUKWkn5/oBHsQ\n" +
+            "IsJPu6nX/rfGG/g7V+fGqKYVDwT7g/bTxR7DAjVUE1oWkTL2dfOuK2HXKu/yIgMZndFIAccCFQCX\n" +
+            "YFCPFSMLzLKSuYKi64QL8Fgc9QKBgQD34aCF1ps93su8q1w2uFe5eZSvu/o66oL5V0wLPQeCZ1FZ\n" +
+            "V4661FlP5nEHEIGAtEkWcSPoTCgWE7fPCTKMyKbhPBZ6i1R8jSjgo64eK7OmdZFuo38L+iE1YvH7\n" +
+            "YnoBJDvMpPG+qFGQiaiD3+Fa5Z8GkotmXoB7VSVkAUw7/s9JKgOBggACf2NHT/Yp5ZiiIf3al54/\n" +
+            "yrAXSY2KpwYNpniXOVkzcqKldNU67+Z8B9eOjtFmc5kUBJb1MdZy7tJT+JC188PxZLoansAK2pJI\n" +
+            "xdOEfkgJZtlRunRWWneKjJqc9oQSYRJR3MZPhJTsy3hRg4wgilN70rY231A1lR/LUFWLP/vid8uj\n" +
+            "EzARMA8GA1UdDwEB/wQFAwMHpAAwCwYHKoZIzjgEAwUAAy8AMCwCFFKAUissPQJmWLTc71ImcBtT\n" +
+            "yrN9AhRiA7KrPhgqZgm2ztQFpY6leg1VZzCCAvUwggKyoAMCAQICBDe8bXcwCwYHKoZIzjgEAwUA\n" +
+            "MEkxCzAJBgNVBAYTAnVzMQwwCgYDVQQKEwNzdW4xDTALBgNVBAsTBGVhc3QxDDAKBgNVBAsTA2Jj\n" +
+            "bjEPMA0GA1UEAxMGeWFzc2lyMB4XDTk5MDgxOTIwNDc1MVoXDTAwMDgxODIwNDc1MVowSTELMAkG\n" +
+            "A1UEBhMCdXMxDDAKBgNVBAoTA3N1bjENMAsGA1UECxMEZWFzdDEMMAoGA1UECxMDYmNuMQ8wDQYD\n" +
+            "VQQDEwZ5YXNzaXIwggG3MIIBLAYHKoZIzjgEATCCAR8CgYEA/X9TgR11EilS30qcLuzk5/YRt1I8\n" +
+            "70QAwx4/gLZRJmlFXUAiUftZPY1Y+r/F9bow9subVWzXgTuAHTRv8mZgt2uZUKWkn5/oBHsQIsJP\n" +
+            "u6nX/rfGG/g7V+fGqKYVDwT7g/bTxR7DAjVUE1oWkTL2dfOuK2HXKu/yIgMZndFIAccCFQCXYFCP\n" +
+            "FSMLzLKSuYKi64QL8Fgc9QKBgQD34aCF1ps93su8q1w2uFe5eZSvu/o66oL5V0wLPQeCZ1FZV466\n" +
+            "1FlP5nEHEIGAtEkWcSPoTCgWE7fPCTKMyKbhPBZ6i1R8jSjgo64eK7OmdZFuo38L+iE1YvH7YnoB\n" +
+            "JDvMpPG+qFGQiaiD3+Fa5Z8GkotmXoB7VSVkAUw7/s9JKgOBhAACgYAKzKTs1ohFwiRrDXjxgvNe\n" +
+            "PjFd+2TVBl45FvEKhdH/0aR0xeawupMc7mlRvjumZkRQtPBeDt2fCHH+oZEu1J5rssCCPJFsGLDZ\n" +
+            "vKNIkT+LWQFhAAKrIjG8fGwNn+2+M+ZcRJ5iMJX4bSLX5YVMsJhurczKO63L+vefNxP3yuIiuqMn\n" +
+            "MCUwDwYDVR0PAQH/BAUDAwekADASBgNVHRMBAf8ECDAGAQH/AgEFMAsGByqGSM44BAMFAAMwADAt\n" +
+            "AhQviEY3lJKyAgdbjXblgSOFf7yNuQIVAIvXQfoRx6snkl0KA5hWNkJf9R+dMQA=\n" +
+            "";
+
+    // Runs test of CertPath encoding and decoding.
+    public static void main(String[] args) throws Exception {
+        // Make the CertPath whose encoded form has already been stored
+        CertificateFactory certFac = CertificateFactory.getInstance("X509");
+
+        final List<Certificate> certs = new ArrayList<>();
+        certs.add(certFac.generateCertificate(new ByteArrayInputStream(cert1.getBytes())));
+        certs.add(certFac.generateCertificate(new ByteArrayInputStream(cert2.getBytes())));
+
+        CertPath cp = certFac.generateCertPath(certs);
+
+        // Get the encoded form of the CertPath we made
+        byte[] encoded = cp.getEncoded("PKCS7");
+
+        // check if it matches the encoded value
+        if (!Arrays.equals(encoded, Base64.getMimeDecoder().decode(pkcs7path.getBytes()))) {
+            throw new RuntimeException("PKCS#7 encoding doesn't match stored value");
+        }
+
+        // Generate a CertPath from the encoded value and check if it equals
+        // the CertPath generated from the certificates
+        CertPath decodedCP = certFac.generateCertPath(new ByteArrayInputStream(encoded), "PKCS7");
+        if (!decodedCP.equals(cp)) {
+            throw new RuntimeException("CertPath decoded from PKCS#7 isn't equal to original");
+        }
+    }
+}
diff --git a/jdk/test/java/security/cert/X509CertSelectorTest.java b/jdk/test/java/security/cert/X509CertSelectorTest.java
new file mode 100644
index 0000000..f41c52c
--- /dev/null
+++ b/jdk/test/java/security/cert/X509CertSelectorTest.java
@@ -0,0 +1,536 @@
+/*
+ * 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
+ * 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 static sun.security.x509.GeneralNameInterface.NAME_DIRECTORY;
+import static sun.security.x509.NameConstraintsExtension.EXCLUDED_SUBTREES;
+import static sun.security.x509.NameConstraintsExtension.PERMITTED_SUBTREES;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigInteger;
+import java.security.GeneralSecurityException;
+import java.security.KeyFactory;
+import java.security.PublicKey;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509CertSelector;
+import java.security.cert.X509Certificate;
+import java.security.spec.X509EncodedKeySpec;
+import java.util.Base64;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import sun.security.util.DerInputStream;
+import sun.security.util.DerOutputStream;
+import sun.security.util.DerValue;
+import sun.security.util.ObjectIdentifier;
+import sun.security.x509.AlgorithmId;
+import sun.security.x509.AuthorityKeyIdentifierExtension;
+import sun.security.x509.CertificatePoliciesExtension;
+import sun.security.x509.DNSName;
+import sun.security.x509.GeneralName;
+import sun.security.x509.GeneralNameInterface;
+import sun.security.x509.GeneralNames;
+import sun.security.x509.GeneralSubtree;
+import sun.security.x509.GeneralSubtrees;
+import sun.security.x509.KeyIdentifier;
+import sun.security.x509.NameConstraintsExtension;
+import sun.security.x509.PolicyInformation;
+import sun.security.x509.PrivateKeyUsageExtension;
+import sun.security.x509.SubjectAlternativeNameExtension;
+import sun.security.x509.X500Name;
+
+/*
+ * @test
+ * @bug 8074931
+ * @summary This class tests the X509CertSelector. The tests check particular criteria
+ *          by setting them to a value that should match our test certificate and
+ *          ensuring that they do match, then setting them to a value that should not
+ *          match our test certificate and ensuring that they do not match.
+ */
+public class X509CertSelectorTest {
+    /*
+            Certificate:
+                Data:
+                    Version: 3 (0x2)
+                    Serial Number: 954172088 (0x38df82b8)
+                Signature Algorithm: dsaWithSHA1
+                    Issuer: C=us, O=sun, OU=testing
+                    Validity
+                        Not Before: Mar 27 15:48:08 2000 GMT
+                        Not After : Jun 25 14:48:08 2000 GMT
+                    Subject: C=us, O=sun, OU=testing, CN=mullan
+                    Subject Public Key Info:
+                        Public Key Algorithm: dsaEncryption
+                            pub:  0
+                            P:    0
+                            Q:    0
+                            G:    0
+                    X509v3 extensions:
+                        X509v3 Name Constraints: critical
+                            0D.B0@.>1.0...U....us1.0
+            ..U.
+            ..sun1.0...U....testing1.0
+            ..U....mullan
+                        X509v3 Subject Key Identifier:
+                            56:E8:88:AE:9D:B5:3F:2B:CB:A0:4C:4B:E2:87:53:07:33:77:1B:DF
+                        X509v3 Authority Key Identifier:
+                            keyid:8E:DD:AF:6F:EE:02:12:F4:61:E9:2F:E3:64:1A:6F:71:32:25:20:C0
+
+                        X509v3 Subject Alternative Name:
+                            email:mullan@east.sun.com
+                        X509v3 Private Key Usage Period:
+                            Not Before: Jan  1 05:00:00 2000 GMT, Not After: Jan  1 05:00:00 2001 GMT
+                        X509v3 Key Usage: critical
+                            Digital Signature
+                        X509v3 Certificate Policies:
+                            0$0\..*...0.0...+.......0..
+            Testing...
+                Signature Algorithm: dsaWithSHA1
+                     r:
+                         44:c7:35:40:5d:6c:28:75:7f:73:b2:f8:0d:72:6c:
+                         09:65:b8:81:14
+                     s:
+                         76:79:f5:c7:37:3b:0d:9b:db:70:2f:20:80:36:e3:
+                         80:e8:a6:c6:71
+    */
+    private static final String testCert =
+            "-----BEGIN CERTIFICATE-----\n" +
+            "MIICLjCCAeygAwIBAgIEON+CuDALBgcqhkjOOAQDBQAwLTELMAkGA1UEBhMCdXMx\n" +
+            "DDAKBgNVBAoTA3N1bjEQMA4GA1UECxMHdGVzdGluZzAeFw0wMDAzMjcxNTQ4MDha\n" +
+            "Fw0wMDA2MjUxNDQ4MDhaMD4xCzAJBgNVBAYTAnVzMQwwCgYDVQQKEwNzdW4xEDAO\n" +
+            "BgNVBAsTB3Rlc3RpbmcxDzANBgNVBAMTBm11bGxhbjAcMBQGByqGSM44BAEwCQIB\n" +
+            "AAIBAAIBAAMEAAIBAKOCASMwggEfMFAGA1UdHgEB/wRGMESgQjBApD4xCzAJBgNV\n" +
+            "BAYTAnVzMQwwCgYDVQQKEwNzdW4xEDAOBgNVBAsTB3Rlc3RpbmcxDzANBgNVBAMT\n" +
+            "Bm11bGxhbjAdBgNVHQ4EFgQUVuiIrp21PyvLoExL4odTBzN3G98wHwYDVR0jBBgw\n" +
+            "FoAUjt2vb+4CEvRh6S/jZBpvcTIlIMAwHgYDVR0RBBcwFYETbXVsbGFuQGVhc3Qu\n" +
+            "c3VuLmNvbTArBgNVHRAEJDAigA8yMDAwMDEwMTA1MDAwMFqBDzIwMDEwMTAxMDUw\n" +
+            "MDAwWjAPBgNVHQ8BAf8EBQMDB4AAMC0GA1UdIAQmMCQwIgYEKoSAADAaMBgGCCsG\n" +
+            "AQUFBwICMAwSClRlc3RpbmcuLi4wCwYHKoZIzjgEAwUAAy8AMCwCFETHNUBdbCh1\n" +
+            "f3Oy+A1ybAlluIEUAhR2efXHNzsNm9twLyCANuOA6KbGcQ==\n" +
+            "-----END CERTIFICATE-----\n" +
+            "";
+
+    private static final String testKey =
+            "MIIBtjCCASsGByqGSM44BAEwggEeAoGBAIVWPEkcxbxhQRCqVzg55tNqbP5j0K4kdu4bkmXvfqC5\n" +
+            "+qA75DvnfzsOJseb+9AuKXWk/DvCzFDmrY1YaU3scZC3OQEO9lEO3F4VDKOaudY6OT1SI22pAIwz\n" +
+            "j5pvq+i7zOp4xUqkQUeh/4iQSfxOT5UrFGjkcbnbpVkCXD/GxAz7AhUAjtnm3dVIddUUHl6wxpZ7\n" +
+            "GcA6gSsCgYAf/PXzQtemgIDjpFrNNSgTEKkLposBXKatAM+gUKlMUjf8SQvquqPxDtRrscGjXkoL\n" +
+            "oTkaR7/akULYFpBvUcFkeIFiCnJg8M9XhCWdLvn9MPt+jR2oxookvCb9xLtD6WvIM/wd/nZ1iK4u\n" +
+            "iY1+q85xvns/Awbtwl7oZDAwE2TUKAOBhAACgYBDc9UZ+3xsZubUZvRG5cpyJceYpJp2exOPVJXn\n" +
+            "jR4CcR+cT9bAJpFSxqE/8KtNHXxHdu4f3DU67IMOVDpugzihyzXJvNm3w2H9x+6xczHG2wjvAJeh\n" +
+            "X62EWbUatxPXFAoVKZWuUbaYaZzdWBDtNRrCuKKsLo0GFy8g2BZISuD3jw==\n" +
+            "";
+
+    // Certificate to run tests on
+    private final X509Certificate cert;
+
+    public static void main(String[] args) throws Exception {
+        X509CertSelectorTest test = new X509CertSelectorTest();
+        test.doTest();
+    }
+
+    public X509CertSelectorTest() throws CertificateException, IOException {
+        cert = (X509Certificate) CertificateFactory.getInstance("X.509")
+                .generateCertificate(new ByteArrayInputStream(testCert.getBytes()));
+    }
+
+    // Runs the test.
+    private void doTest() throws Exception {
+        System.out.println("START OF TESTS FOR " + "X509CertSelector");
+
+        testSerialNumber();
+        testIssuer();
+        testSubjectKeyIdentifier();
+        testAuthorityKeyIdentifier();
+        testCertificateValid();
+        testPrivateKeyValid();
+        testSubjectPublicKeyAlgID();
+        testKeyUsage();
+        testSubjectAltName();
+        testPolicy();
+        testPathToName();
+        testSubject();
+        testSubjectPublicKey();
+        testNameConstraints();
+        testBasicConstraints();
+        testCertificate();
+    }
+
+    // Tests matching on the serial number contained in the certificate.
+    private void testSerialNumber() {
+        System.out.println("X.509 Certificate Match on serialNumber");
+        // bad match
+        X509CertSelector selector = new X509CertSelector();
+        selector.setSerialNumber(new BigInteger("999999999"));
+        checkMatch(selector, cert, false);
+
+        // good match
+        selector.setSerialNumber(cert.getSerialNumber());
+        checkMatch(selector, cert, true);
+    }
+
+    // Tests matching on the issuer name contained in the certificate.
+    private void testIssuer() throws IOException {
+        System.out.println("X.509 Certificate Match on issuer");
+        // bad match
+        X509CertSelector selector = new X509CertSelector();
+        selector.setIssuer("ou=bogus,ou=east,o=sun,c=us");
+        checkMatch(selector, cert, false);
+
+        // good match
+        selector.setIssuer((cert.getIssuerX500Principal()).getName("RFC2253"));
+        checkMatch(selector, cert, true);
+    }
+
+    /*
+     * Tests matching on the subject key identifier contained in the
+     * certificate.
+     */
+    private void testSubjectKeyIdentifier() throws IOException {
+        System.out.println("X.509 Certificate Match on subjectKeyIdentifier");
+        // bad match
+        X509CertSelector selector = new X509CertSelector();
+        byte[] b = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+        selector.setSubjectKeyIdentifier(b);
+        checkMatch(selector, cert, false);
+
+        // good match
+        DerInputStream in = new DerInputStream(cert.getExtensionValue("2.5.29.14"));
+        byte[] encoded = in.getOctetString();
+        selector.setSubjectKeyIdentifier(encoded);
+        checkMatch(selector, cert, true);
+    }
+
+    /*
+     * Tests matching on the authority key identifier contained in the
+     * certificate.
+     */
+    private void testAuthorityKeyIdentifier() throws IOException {
+        System.out.println("X.509 Certificate Match on authorityKeyIdentifier");
+        // bad match
+        X509CertSelector selector = new X509CertSelector();
+        byte[] b = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+        AuthorityKeyIdentifierExtension a = new AuthorityKeyIdentifierExtension(new KeyIdentifier(b), null, null);
+        selector.setAuthorityKeyIdentifier(a.getExtensionValue());
+        checkMatch(selector, cert, false);
+
+        // good match
+        DerInputStream in = new DerInputStream(cert.getExtensionValue("2.5.29.35"));
+        byte[] encoded = in.getOctetString();
+        selector.setAuthorityKeyIdentifier(encoded);
+        checkMatch(selector, cert, true);
+    }
+
+    /*
+     * Tests matching on the certificate validity component contained in the
+     * certificate.
+     */
+    private void testCertificateValid() {
+        System.out.println("X.509 Certificate Match on certificateValid");
+        // bad match
+        X509CertSelector selector = new X509CertSelector();
+        Calendar cal = Calendar.getInstance();
+        cal.set(1968, 12, 31);
+        selector.setCertificateValid(cal.getTime());
+        checkMatch(selector, cert, false);
+
+        // good match
+        selector.setCertificateValid(cert.getNotBefore());
+        checkMatch(selector, cert, true);
+    }
+
+    /*
+     * Tests matching on the private key validity component contained in the
+     * certificate.
+     */
+    private void testPrivateKeyValid() throws IOException, CertificateException {
+        System.out.println("X.509 Certificate Match on privateKeyValid");
+        // bad match
+        X509CertSelector selector = new X509CertSelector();
+        Calendar cal = Calendar.getInstance();
+        cal.set(1968, 12, 31);
+        selector.setPrivateKeyValid(cal.getTime());
+        checkMatch(selector, cert, false);
+
+        // good match
+        DerInputStream in = new DerInputStream(cert.getExtensionValue("2.5.29.16"));
+        byte[] encoded = in.getOctetString();
+        PrivateKeyUsageExtension ext = new PrivateKeyUsageExtension(false, encoded);
+        Date validDate = (Date) ext.get(PrivateKeyUsageExtension.NOT_BEFORE);
+        selector.setPrivateKeyValid(validDate);
+        checkMatch(selector, cert, true);
+
+    }
+
+    private ObjectIdentifier getCertPubKeyAlgOID(X509Certificate xcert) throws IOException {
+        byte[] encodedKey = xcert.getPublicKey().getEncoded();
+        DerValue val = new DerValue(encodedKey);
+        if (val.tag != DerValue.tag_Sequence) {
+            throw new RuntimeException("invalid key format");
+        }
+
+        return AlgorithmId.parse(val.data.getDerValue()).getOID();
+    }
+
+    /*
+     * Tests matching on the subject public key algorithm ID component contained
+     * in the certificate.
+     */
+    private void testSubjectPublicKeyAlgID() throws IOException {
+        System.out.println("X.509 Certificate Match on subjectPublicKeyAlgID");
+        // bad match
+        X509CertSelector selector = new X509CertSelector();
+        selector.setSubjectPublicKeyAlgID("2.5.29.14");
+        checkMatch(selector, cert, false);
+
+        // good match
+        selector.setSubjectPublicKeyAlgID(getCertPubKeyAlgOID(cert).toString());
+        checkMatch(selector, cert, true);
+
+    }
+
+    // Tests matching on the key usage extension contained in the certificate.
+    private void testKeyUsage() {
+        System.out.println("X.509 Certificate Match on keyUsage");
+        // bad match
+        X509CertSelector selector = new X509CertSelector();
+        boolean[] keyUsage = { true, false, true, false, true, false, true, false };
+        selector.setKeyUsage(keyUsage);
+        System.out.println("Selector = " + selector.toString());
+        checkMatch(selector, cert, false);
+
+        // good match
+        selector.setKeyUsage(cert.getKeyUsage());
+        System.out.println("Selector = " + selector.toString());
+        checkMatch(selector, cert, true);
+    }
+
+    /*
+     * Tests matching on the subject alternative name extension contained in the
+     * certificate.
+     */
+    private void testSubjectAltName() throws IOException {
+        System.out.println("X.509 Certificate Match on subjectAltName");
+        // bad match
+        X509CertSelector selector = new X509CertSelector();
+        GeneralNameInterface dnsName = new DNSName("foo.com");
+        DerOutputStream tmp = new DerOutputStream();
+        dnsName.encode(tmp);
+        selector.addSubjectAlternativeName(2, tmp.toByteArray());
+        checkMatch(selector, cert, false);
+
+        // good match
+        DerInputStream in = new DerInputStream(cert.getExtensionValue("2.5.29.17"));
+        byte[] encoded = in.getOctetString();
+        SubjectAlternativeNameExtension ext = new SubjectAlternativeNameExtension(false, encoded);
+        GeneralNames names = (GeneralNames) ext.get(SubjectAlternativeNameExtension.SUBJECT_NAME);
+        GeneralName name = (GeneralName) names.get(0);
+        selector.setSubjectAlternativeNames(null);
+        DerOutputStream tmp2 = new DerOutputStream();
+        name.getName().encode(tmp2);
+        selector.addSubjectAlternativeName(name.getType(), tmp2.toByteArray());
+        checkMatch(selector, cert, true);
+
+        // good match 2 (matches at least one)
+        selector.setMatchAllSubjectAltNames(false);
+        selector.addSubjectAlternativeName(2, "foo.com");
+        checkMatch(selector, cert, true);
+    }
+
+    /*
+     * Tests matching on the policy constraints extension contained in the
+     * certificate.
+     */
+    private void testPolicy() throws IOException {
+        System.out.println("X.509 Certificate Match on certificatePolicies");
+        // test encoding of CertificatePoliciesExtension because we wrote the
+        // code
+        // bad match
+        X509CertSelector selector = new X509CertSelector();
+        Set<String> s = new HashSet<>();
+        s.add(new String("1.2.5.7.68"));
+        selector.setPolicy(s);
+        checkMatch(selector, cert, false);
+
+        // good match
+        DerInputStream in = new DerInputStream(cert.getExtensionValue("2.5.29.32"));
+        CertificatePoliciesExtension ext = new CertificatePoliciesExtension(false, in.getOctetString());
+        List<PolicyInformation> policies = ext.get(CertificatePoliciesExtension.POLICIES);
+        // match on the first policy id
+        PolicyInformation policyInfo = (PolicyInformation) policies.get(0);
+        s.clear();
+        s.add(policyInfo.getPolicyIdentifier().getIdentifier().toString());
+        selector.setPolicy(s);
+        checkMatch(selector, cert, true);
+    }
+
+    /*
+     * Tests matching on the name constraints extension contained in the
+     * certificate.
+     */
+    private void testPathToName() throws IOException {
+        System.out.println("X.509 Certificate Match on pathToName");
+
+        X509CertSelector selector = null;
+        DerInputStream in = new DerInputStream(cert.getExtensionValue("2.5.29.30"));
+        byte[] encoded = in.getOctetString();
+        NameConstraintsExtension ext = new NameConstraintsExtension(false, encoded);
+        GeneralSubtrees permitted = (GeneralSubtrees) ext.get(PERMITTED_SUBTREES);
+        GeneralSubtrees excluded = (GeneralSubtrees) ext.get(EXCLUDED_SUBTREES);
+
+        // bad matches on pathToName within excluded subtrees
+        if (excluded != null) {
+            Iterator<GeneralSubtree> e = excluded.iterator();
+            while (e.hasNext()) {
+                GeneralSubtree tree = e.next();
+                if (tree.getName().getType() == NAME_DIRECTORY) {
+                    X500Name excludedDN1 = new X500Name(tree.getName().toString());
+                    X500Name excludedDN2 = new X500Name("CN=Bogus, " + tree.getName().toString());
+                    DerOutputStream derDN1 = new DerOutputStream();
+                    DerOutputStream derDN2 = new DerOutputStream();
+                    excludedDN1.encode(derDN1);
+                    excludedDN2.encode(derDN2);
+                    selector = new X509CertSelector();
+                    selector.addPathToName(NAME_DIRECTORY, derDN1.toByteArray());
+                    checkMatch(selector, cert, false);
+                    selector.setPathToNames(null);
+                    selector.addPathToName(NAME_DIRECTORY, derDN2.toByteArray());
+                    checkMatch(selector, cert, false);
+                }
+            }
+        }
+
+        // good matches on pathToName within permitted subtrees
+        if (permitted != null) {
+            Iterator<GeneralSubtree> e = permitted.iterator();
+            while (e.hasNext()) {
+                GeneralSubtree tree = e.next();
+                if (tree.getName().getType() == NAME_DIRECTORY) {
+                    X500Name permittedDN1 = new X500Name(tree.getName().toString());
+                    X500Name permittedDN2 = new X500Name("CN=good, " + tree.getName().toString());
+                    DerOutputStream derDN1 = new DerOutputStream();
+                    DerOutputStream derDN2 = new DerOutputStream();
+                    permittedDN1.encode(derDN1);
+                    permittedDN2.encode(derDN2);
+                    selector = new X509CertSelector();
+                    selector.addPathToName(NAME_DIRECTORY, derDN1.toByteArray());
+                    checkMatch(selector, cert, true);
+                    selector.setPathToNames(null);
+                    selector.addPathToName(NAME_DIRECTORY, derDN2.toByteArray());
+                    checkMatch(selector, cert, true);
+                }
+            }
+        }
+    }
+
+    // Tests matching on the subject name contained in the certificate.
+    private void testSubject() throws IOException {
+        System.out.println("X.509 Certificate Match on subject");
+        // bad match
+        X509CertSelector selector = new X509CertSelector();
+        selector.setSubject("ou=bogus,ou=east,o=sun,c=us");
+        checkMatch(selector, cert, false);
+
+        // good match
+        selector.setSubject(cert.getSubjectX500Principal().getName("RFC2253"));
+        checkMatch(selector, cert, true);
+    }
+
+    // Tests matching on the subject public key contained in the certificate.
+    private void testSubjectPublicKey() throws IOException, GeneralSecurityException {
+        System.out.println("X.509 Certificate Match on subject public key");
+        // bad match
+        X509CertSelector selector = new X509CertSelector();
+        X509EncodedKeySpec keySpec = new X509EncodedKeySpec(
+                Base64.getMimeDecoder().decode(testKey.getBytes()));
+        KeyFactory keyFactory = KeyFactory.getInstance("DSA");
+        PublicKey pubKey = keyFactory.generatePublic(keySpec);
+        selector.setSubjectPublicKey(pubKey);
+        checkMatch(selector, cert, false);
+
+        // good match
+        selector.setSubjectPublicKey(cert.getPublicKey());
+        checkMatch(selector, cert, true);
+    }
+
+    // Tests matching on the name constraints contained in the certificate.
+    private void testNameConstraints() throws IOException {
+        System.out.println("X.509 Certificate Match on name constraints");
+        // bad match
+        GeneralSubtrees subjectTree = new GeneralSubtrees();
+        subjectTree.add(getGeneralSubtree((X500Name) cert.getSubjectDN()));
+        NameConstraintsExtension ext = new NameConstraintsExtension((GeneralSubtrees) null, subjectTree);
+        X509CertSelector selector = new X509CertSelector();
+        selector.setNameConstraints(ext.getExtensionValue());
+        checkMatch(selector, cert, false);
+
+        // good match
+        ext = new NameConstraintsExtension(subjectTree, null);
+        selector.setNameConstraints(ext.getExtensionValue());
+        checkMatch(selector, cert, true);
+    }
+
+    // Tests matching on basic constraints.
+    private void testBasicConstraints() {
+        System.out.println("X.509 Certificate Match on basic constraints");
+        // bad match
+        X509CertSelector selector = new X509CertSelector();
+        int mpl = cert.getBasicConstraints();
+        selector.setBasicConstraints(0);
+        checkMatch(selector, cert, false);
+
+        // good match
+        selector.setBasicConstraints(mpl);
+        checkMatch(selector, cert, true);
+    }
+
+    // Tests certificateEquals criterion
+    private void testCertificate() {
+        System.out.println("X.509 Certificate Match on certificateEquals criterion");
+
+        X509CertSelector selector = new X509CertSelector();
+        // good match
+        selector.setCertificate(cert);
+        checkMatch(selector, cert, true);
+    }
+
+    private void checkMatch(X509CertSelector selector, X509Certificate cert, boolean match) {
+        boolean result = selector.match(cert);
+        if (match != result)
+            throw new RuntimeException(selector + " match " + cert + " is " + result + ", but expect " + match);
+    }
+
+    private static GeneralSubtree getGeneralSubtree(GeneralNameInterface gni) {
+        // Create a new GeneralSubtree with the specified name, 0 base, and
+        // unlimited length
+        GeneralName gn = new GeneralName(gni);
+        GeneralSubtree subTree = new GeneralSubtree(gn, 0, -1);
+        return subTree;
+    }
+}
diff --git a/jdk/test/java/text/Format/DateFormat/Bug8141243.java b/jdk/test/java/text/Format/DateFormat/Bug8141243.java
new file mode 100644
index 0000000..8d156b1
--- /dev/null
+++ b/jdk/test/java/text/Format/DateFormat/Bug8141243.java
@@ -0,0 +1,83 @@
+/*
+ * 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 8141243
+ * @summary Make sure that SimpleDateFormat parses "UTC" as the UTC time zone.
+ * @run main Bug8141243
+ */
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+import java.util.TimeZone;
+import static java.util.TimeZone.*;
+
+public class Bug8141243 {
+    public static void main(String[] args) {
+        TimeZone UTC = TimeZone.getTimeZone("UTC");
+        TimeZone initTz = TimeZone.getDefault();
+
+        List<String> errors = new ArrayList<>();
+        try {
+            TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
+            for (Locale locale : DateFormat.getAvailableLocales()) {
+                // exclude any locales which localize "UTC".
+                String utc = UTC.getDisplayName(false, SHORT, locale);
+                if (!"UTC".equals(utc)) {
+                    System.out.println("Skipping " + locale + " due to localized UTC name: " + utc);
+                    continue;
+                }
+                SimpleDateFormat fmt = new SimpleDateFormat("z", locale);
+                try {
+                    Date date = fmt.parse("UTC");
+                    // Parsed one may not exactly be UTC. Universal, UCT, etc. are equivalents.
+                    if (!fmt.getTimeZone().getID().matches("(Etc/)?(UTC|Universal|UCT|Zulu)")) {
+                        errors.add("timezone: " + fmt.getTimeZone().getID()
+                                   + ", locale: " + locale);
+                    }
+                } catch (ParseException e) {
+                    errors.add("parse exception: " + e + ", locale: " + locale);
+                }
+            }
+        } finally {
+            // Restore the default time zone
+            TimeZone.setDefault(initTz);
+        }
+
+        if (!errors.isEmpty()) {
+            System.out.println("Got unexpected results:");
+            for (String s : errors) {
+                System.out.println("    " + s);
+            }
+            throw new RuntimeException("Test failed.");
+        } else {
+            System.out.println("Test passed.");
+        }
+    }
+}
diff --git a/jdk/test/java/text/Format/DateFormat/DateFormatSymbolsCloneTest.java b/jdk/test/java/text/Format/DateFormat/DateFormatSymbolsCloneTest.java
new file mode 100644
index 0000000..7214d1f
--- /dev/null
+++ b/jdk/test/java/text/Format/DateFormat/DateFormatSymbolsCloneTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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 8151431
+ * @summary Make sure that clone() of a DateFormatSymbols subclass is not
+ *          called from DateFormatSymbols constructor.
+ */
+import java.text.DateFormatSymbols;
+
+public class DateFormatSymbolsCloneTest extends DateFormatSymbols {
+    private int value;
+
+    public DateFormatSymbolsCloneTest() {
+        value = 1;
+    }
+
+    @Override
+    public Object clone() {
+        if (this.value == 0) {
+            throw new RuntimeException("clone() should not be called from a DateFormatSymbols constructor");
+        }
+        return super.clone();
+    }
+
+    public static void main(String[] args) {
+        new DateFormatSymbolsCloneTest();
+    }
+}
diff --git a/jdk/test/java/time/test/java/time/format/TestZoneTextPrinterParser.java b/jdk/test/java/time/test/java/time/format/TestZoneTextPrinterParser.java
index 079af06..7808624 100644
--- a/jdk/test/java/time/test/java/time/format/TestZoneTextPrinterParser.java
+++ b/jdk/test/java/time/test/java/time/format/TestZoneTextPrinterParser.java
@@ -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
@@ -49,7 +49,7 @@
 
 /*
  * @test
- * @bug 8081022
+ * @bug 8081022 8151876
  * @key randomness
  */
 
@@ -84,6 +84,14 @@
                 TimeZone tz = TimeZone.getTimeZone(zid);
                 boolean isDST = tz.inDaylightTime(new Date(zdt.toInstant().toEpochMilli()));
                 for (Locale locale : locales) {
+                    String longDisplayName = tz.getDisplayName(isDST, TimeZone.LONG, locale);
+                    String shortDisplayName = tz.getDisplayName(isDST, TimeZone.SHORT, locale);
+                    if ((longDisplayName.startsWith("GMT+") && shortDisplayName.startsWith("GMT+"))
+                            || (longDisplayName.startsWith("GMT-") && shortDisplayName.startsWith("GMT-"))) {
+                        printText(locale, zdt, TextStyle.FULL, tz, tz.getID());
+                        printText(locale, zdt, TextStyle.SHORT, tz, tz.getID());
+                        continue;
+                    }
                     printText(locale, zdt, TextStyle.FULL, tz,
                             tz.getDisplayName(isDST, TimeZone.LONG, locale));
                     printText(locale, zdt, TextStyle.SHORT, tz,
diff --git a/jdk/test/java/util/Hashtable/DeserializedLength.java b/jdk/test/java/util/Hashtable/DeserializedLength.java
new file mode 100644
index 0000000..1497eb8d
--- /dev/null
+++ b/jdk/test/java/util/Hashtable/DeserializedLength.java
@@ -0,0 +1,110 @@
+/*
+ * 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.
+ *
+ * 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.*;
+import java.lang.reflect.Field;
+import java.util.Hashtable;
+
+/**
+ * @test
+ * @bug 8068427
+ * @summary Hashtable deserialization reconstitutes table with wrong capacity
+ */
+public class DeserializedLength {
+
+    static boolean testDeserializedLength(int elements, float loadFactor) throws Exception {
+
+        // construct Hashtable with minimal initial capacity and given loadFactor
+        Hashtable<Integer, Integer> ht1 = new Hashtable<>(1, loadFactor);
+
+        // add given number of unique elements
+        for (int i = 0; i < elements; i++) {
+            ht1.put(i, i);
+        }
+
+        // serialize and deserialize into a deep clone
+        Hashtable<Integer, Integer> ht2 = serialClone(ht1);
+
+        // compare lengths of internal tables
+        Object[] table1 = (Object[]) hashtableTableField.get(ht1);
+        Object[] table2 = (Object[]) hashtableTableField.get(ht2);
+        assert table1 != null;
+        assert table2 != null;
+
+        int minLength = (int) (ht1.size() / loadFactor) + 1;
+        int maxLength = minLength * 2;
+
+        boolean ok = (table2.length >= minLength && table2.length <= maxLength);
+
+        System.out.printf(
+            "%7d %5.2f %7d %7d %7d...%7d %s\n",
+            ht1.size(), loadFactor,
+            table1.length, table2.length,
+            minLength, maxLength,
+            (ok ? "OK" : "NOT-OK")
+        );
+
+        return ok;
+    }
+
+    static <T> T serialClone(T o) throws IOException, ClassNotFoundException {
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        try (ObjectOutputStream oos = new ObjectOutputStream(bos)) {
+            oos.writeObject(o);
+        }
+        @SuppressWarnings("unchecked")
+        T clone = (T) new ObjectInputStream(
+            new ByteArrayInputStream(bos.toByteArray())).readObject();
+        return clone;
+    }
+
+    private static final Field hashtableTableField;
+
+    static {
+        try {
+            hashtableTableField = Hashtable.class.getDeclaredField("table");
+            hashtableTableField.setAccessible(true);
+        } catch (NoSuchFieldException e) {
+            throw new Error(e);
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        boolean ok = true;
+
+        System.out.printf("Results:\n" +
+                "                 ser.  deser.\n" +
+                "   size  load  lentgh  length       valid range ok?\n" +
+                "------- ----- ------- ------- ----------------- ------\n"
+        );
+
+        for (int elements : new int[]{10, 50, 500, 5000}) {
+            for (float loadFactor : new float[]{0.15f, 0.5f, 0.75f, 1.0f, 2.5f}) {
+                ok &= testDeserializedLength(elements, loadFactor);
+            }
+        }
+        if (!ok) {
+            throw new AssertionError("Test failed.");
+        }
+    }
+}
diff --git a/jdk/test/java/util/concurrent/ConcurrentLinkedQueue/RemoveLeak.java b/jdk/test/java/util/concurrent/ConcurrentLinkedQueue/RemoveLeak.java
new file mode 100644
index 0000000..fd1e52d
--- /dev/null
+++ b/jdk/test/java/util/concurrent/ConcurrentLinkedQueue/RemoveLeak.java
@@ -0,0 +1,60 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Written by Martin Buchholz with assistance from members of JCP
+ * JSR-166 Expert Group and released to the public domain, as
+ * explained at http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+/*
+ * @test
+ * @bug 8054446 8137184 8137185
+ * @summary Regression test for memory leak in remove(Object)
+ * @run main/othervm -Xmx2200k RemoveLeak
+ */
+
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+public class RemoveLeak {
+    public static void main(String[] args) {
+        int i = 0;
+        // Without bug fix, OutOfMemoryError was observed at iteration 65120
+        int iterations = 10 * 65120;
+        try {
+            ConcurrentLinkedQueue<Long> queue = new ConcurrentLinkedQueue<>();
+            queue.add(0L);
+            while (i++ < iterations) {
+                queue.add(1L);
+                queue.remove(1L);
+            }
+        } catch (Error t) {
+            System.err.printf("failed at iteration %d/%d%n", i, iterations);
+            throw t;
+        }
+    }
+}
diff --git a/jdk/test/java/util/logging/LogManagerAppContextDeadlock.java b/jdk/test/java/util/logging/LogManagerAppContextDeadlock.java
index 3e4918e..bb6c471 100644
--- a/jdk/test/java/util/logging/LogManagerAppContextDeadlock.java
+++ b/jdk/test/java/util/logging/LogManagerAppContextDeadlock.java
@@ -136,6 +136,7 @@
         t1.setDaemon(true);
         t1.start();
         Thread t2 = new Thread() {
+            public Object logger;
             public void run() {
                 sem3.release();
                 try {
@@ -146,7 +147,10 @@
                     Thread.interrupted();
                 }
                 System.out.println("Logger.getLogger(name).info(name)");
-                Logger.getLogger(test.name());//.info(name);
+                // stick the logger in an instance variable to prevent it
+                // from being garbage collected before the main thread
+                // calls LogManager.getLogger() below.
+                logger = Logger.getLogger(test.name());//.info(name);
                 System.out.println("Done: Logger.getLogger(name).info(name)");
             }
         };
diff --git a/jdk/test/javax/crypto/JceSecurity/FinalRestricted.java b/jdk/test/javax/crypto/JceSecurity/FinalRestricted.java
new file mode 100644
index 0000000..fdfa76d
--- /dev/null
+++ b/jdk/test/javax/crypto/JceSecurity/FinalRestricted.java
@@ -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.
+ *
+ * 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 8149417
+ * @summary Use final restricted flag
+ */
+
+import java.security.*;
+import java.lang.reflect.*;
+
+public class FinalRestricted {
+
+    public static void main(String[] args) throws Exception {
+
+        int modifiers = Class.forName("javax.crypto.JceSecurity")
+                    .getDeclaredField("isRestricted").getModifiers();
+        if (!(Modifier.isFinal(modifiers) && Modifier.isStatic(modifiers) &&
+                Modifier.isPrivate(modifiers))) {
+            throw new Exception("JceSecurity.isRestricted is not " +
+                                "a private static final field!");
+        }
+    }
+}
diff --git a/jdk/test/javax/crypto/KeyGenerator/TestKGParity.java b/jdk/test/javax/crypto/KeyGenerator/TestKGParity.java
new file mode 100644
index 0000000..0f4c8a5
--- /dev/null
+++ b/jdk/test/javax/crypto/KeyGenerator/TestKGParity.java
@@ -0,0 +1,122 @@
+/*
+ * 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.
+ */
+
+import java.io.PrintStream;
+import java.lang.String;
+import java.lang.System;
+import java.security.Provider;
+import java.security.SecureRandom;
+import java.security.Security;
+import javax.crypto.KeyGenerator;
+import static java.lang.System.out;
+
+/*
+ * @test
+ * @bug 8048607
+ * @compile ../../../com/sun/crypto/provider/Cipher/DES/TestUtility.java
+ * @run main TestKGParity
+ * @summary Test key generation of DES and DESEDE
+ */
+public class TestKGParity {
+
+    private static final String[] ALGORITHM_ARR = {
+        "deS", "DesEDE"
+    };
+
+    public static void main(String argv[]) throws Exception {
+
+        TestKGParity test = new TestKGParity();
+        test.run();
+    }
+
+    private void run() throws Exception {
+        Provider[] providers = Security.getProviders();
+        for (Provider p : providers) {
+            String prvName = p.getName();
+            if (prvName.startsWith("SunJCE")
+                    || prvName.startsWith("SunPKCS11-")) {
+                for (String algorithm : ALGORITHM_ARR) {
+                    if (!runTest(p, algorithm)) {
+                        throw new RuntimeException(
+                                "Test failed with provider/algorithm:"
+                                        + p.getName() + "/" + algorithm);
+                    } else {
+                        out.println("Test passed with provider/algorithm:"
+                                + p.getName() + "/" + algorithm);
+                    }
+                }
+            }
+        }
+    }
+
+    public boolean runTest(Provider p, String algo) throws Exception {
+        byte[] keyValue = null;
+        try {
+            // Initialization
+            SecureRandom sRdm = new SecureRandom();
+            KeyGenerator kg = KeyGenerator.getInstance(algo, p);
+            kg.init(sRdm);
+
+            // Generate a SecretKey and retrieve its value
+            keyValue = kg.generateKey().getEncoded();
+
+            // Verify its parity in the unit of byte
+            for (int i = 0; i < keyValue.length; i++) {
+                if (!checkParity(keyValue[i])) {
+                    out.println("Testing: "
+                        + p.getName()
+                        + "/"
+                        + algo
+                        + " failed when verify its parity in the unit of byte:"
+                        + TestUtility.hexDump(keyValue, i));
+                    return false;
+                }
+            }
+            return true;
+        } catch (Exception ex) {
+            out.println("Testing: " + p.getName() + "/" + algo
+                    + " failed with unexpected exception");
+            ex.printStackTrace();
+            throw ex;
+        }
+    }
+
+    private boolean checkParity(byte keyByte) {
+        boolean even = false;
+        byte[] PARITY_BIT_MASK = {
+                (byte) 0x40, (byte) 0x20, (byte) 0x10, (byte) 0x08,
+                (byte) 0x04, (byte) 0x02, (byte) 0x01
+        };
+
+        for (int i = 0; i < 7; i++) {
+            if ((keyByte & PARITY_BIT_MASK[i]) > 0) {
+                even = !even;
+            }
+        }
+        if (keyByte < 0) {
+            even = !even;
+        }
+
+        return even;
+    }
+}
diff --git a/jdk/test/javax/crypto/SealedObject/TestSealedObjectNull.java b/jdk/test/javax/crypto/SealedObject/TestSealedObjectNull.java
new file mode 100644
index 0000000..4b6eff2
--- /dev/null
+++ b/jdk/test/javax/crypto/SealedObject/TestSealedObjectNull.java
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+
+import java.io.IOException;
+import javax.crypto.BadPaddingException;
+import javax.crypto.Cipher;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.NullCipher;
+import javax.crypto.SealedObject;
+
+/*
+ * @test
+ * @bug 8048624
+ * @summary This test instantiate a NullCipher, seal and unseal a String
+ *  object using the SealedObject with the initialized NullCipher,
+ *  and then compare the String content.
+ */
+public class TestSealedObjectNull {
+
+    private static final String SEAL_STR = "Any String!@#$%^";
+
+    public static void main(String[] args) throws IOException,
+            IllegalBlockSizeException, ClassNotFoundException,
+            BadPaddingException {
+        Cipher nullCipher = new NullCipher();
+
+        // Seal
+        SealedObject so = new SealedObject(SEAL_STR, nullCipher);
+
+        // Unseal and compare
+        if (!(SEAL_STR.equals(so.getObject(nullCipher)))) {
+            throw new RuntimeException("Unseal and compare failed.");
+        }
+
+        System.out.println("Test passed.");
+    }
+}
diff --git a/jdk/test/javax/crypto/SecretKeyFactory/PBKDF2TranslateTest.java b/jdk/test/javax/crypto/SecretKeyFactory/PBKDF2TranslateTest.java
new file mode 100644
index 0000000..acd2081
--- /dev/null
+++ b/jdk/test/javax/crypto/SecretKeyFactory/PBKDF2TranslateTest.java
@@ -0,0 +1,270 @@
+/*
+ * Copyright (c) 2003, 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.
+ */
+
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.spec.InvalidKeySpecException;
+import java.util.Arrays;
+import java.util.Random;
+import javax.crypto.SecretKey;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.interfaces.PBEKey;
+import javax.crypto.spec.PBEKeySpec;
+import javax.security.auth.DestroyFailedException;
+
+import static java.lang.System.out;
+
+/*
+ * @test
+ * @bug 8048820
+ * @summary The test verifies if the SecretKeyFactory.translateKey() method
+ *  works as expected for the PBKDF2 algorithms.
+ */
+
+public class PBKDF2TranslateTest {
+
+    private static final String PASS_PHRASE = "some hidden string";
+    private static final int ITERATION_COUNT = 1000;
+    private static final int KEY_SIZE = 128;
+    private static final String[] TEST_ALGOS = { "PBKDF2WithHmacSHA1",
+            "PBKDF2WithHmacSHA224", "PBKDF2WithHmacSHA256",
+            "PBKDF2WithHmacSHA384", "PBKDF2WithHmacSHA512" };
+    private final String algoForTest;
+
+    public static void main(String[] args) throws Exception {
+        for (String algo : TEST_ALGOS) {
+            PBKDF2TranslateTest theTest = new PBKDF2TranslateTest(algo);
+            byte[] salt = new byte[8];
+            new Random().nextBytes(salt);
+            theTest.testMyOwnSecretKey(salt);
+            theTest.generateAndTranslateKey(salt);
+            theTest.translateSpoiledKey(salt);
+        }
+    }
+
+    public PBKDF2TranslateTest(String algo) {
+        algoForTest = algo;
+    }
+
+    /**
+     * The test case scenario implemented in the method: - derive PBKDF2 key
+     * using the given algorithm; - translate the key - check if the translated
+     * and original keys have the same key value.
+     *
+     */
+    public void generateAndTranslateKey(byte[] salt)
+            throws NoSuchAlgorithmException, InvalidKeySpecException,
+            InvalidKeyException {
+        // derive PBKDF2 key
+        SecretKey key1 = getSecretKeyForPBKDF2(algoForTest, salt);
+
+        // translate key
+        SecretKeyFactory skf = SecretKeyFactory.getInstance(algoForTest);
+        SecretKey key2 = skf.translateKey(key1);
+
+        // Check if it still the same after translation
+        if (!Arrays.equals(key1.getEncoded(), key2.getEncoded())) {
+            System.out.println("Key1=" + new String(key1.getEncoded())
+                    + " key2=" + new String(key2.getEncoded()) + " salt="
+                    + new String(salt));
+            throw new RuntimeException(
+                    "generateAndTranslateKey test case failed: the  key1 and"
+                            + " key2 values in its primary encoding format are"
+                            + " not the same for " + algoForTest
+                            + " algorithm.");
+        }
+    }
+
+    /**
+     * The test case scenario implemented in the method: - derive Key1 for the
+     * given PBKDF2 algorithm - create my own secret Key2 as an instance of a
+     * class implements PBEKey - translate Key2 - check if the key value of the
+     * translated key and Key1 are the same.
+     */
+    private void testMyOwnSecretKey(byte[] salt)
+            throws NoSuchAlgorithmException, InvalidKeySpecException,
+            InvalidKeyException {
+        SecretKey key1 = getSecretKeyForPBKDF2(algoForTest, salt);
+        SecretKey key2 = getMyOwnSecretKey(salt);
+
+        // Is it actually the same?
+        if (!Arrays.equals(key1.getEncoded(), key2.getEncoded())) {
+            throw new RuntimeException(
+                    "We shouldn't be here. The key1 and key2 values in its"
+                            + " primary encoding format have to be the same!");
+        }
+
+        // translate key
+        SecretKeyFactory skf = SecretKeyFactory.getInstance(algoForTest);
+        SecretKey key3 = skf.translateKey(key2);
+
+        // Check if it still the same after translation
+        if (!Arrays.equals(key1.getEncoded(), key3.getEncoded())) {
+            System.out.println("Key1=" + new String(key1.getEncoded())
+                    + " key3=" + new String(key3.getEncoded()) + " salt="
+                    + new String(salt));
+            throw new RuntimeException(
+                    "testMyOwnSecretKey test case failed: the key1  and key3"
+                            + " values in its primary encoding format are not"
+                            + " the same for " + algoForTest + " algorithm.");
+        }
+
+    }
+
+    /**
+     * The test case scenario implemented in the method: - create my own secret
+     * Key2 as an instance of a class implements PBEKey - spoil the key (set
+     * iteration count to 0, for example) - try to translate key -
+     * InvalidKeyException is expected.
+     */
+    public void translateSpoiledKey(byte[] salt)
+            throws NoSuchAlgorithmException, InvalidKeySpecException {
+        // derive the key
+        SecretKey key1 = getMyOwnSecretKey(salt);
+
+        // spoil the key
+        ((MyPBKDF2SecretKey) key1).spoil();
+
+        // translate key
+        SecretKeyFactory skf = SecretKeyFactory.getInstance(algoForTest);
+        try {
+            skf.translateKey(key1);
+            throw new RuntimeException(
+                    "translateSpoiledKey test case failed, should throw"
+                            + " InvalidKeyException when spoil the key");
+        } catch (InvalidKeyException ike) {
+            out.println("Expected exception when spoil the key");
+        }
+
+    }
+
+    /**
+     * Generate a PBKDF2 secret key using given algorithm.
+     */
+    private SecretKey getSecretKeyForPBKDF2(String algoDeriveKey, byte[] salt)
+            throws NoSuchAlgorithmException, InvalidKeySpecException {
+
+        SecretKeyFactory skf = SecretKeyFactory.getInstance(algoDeriveKey);
+        PBEKeySpec spec = new PBEKeySpec(PASS_PHRASE.toCharArray(), salt,
+                ITERATION_COUNT, KEY_SIZE);
+
+        return skf.generateSecret(spec);
+    }
+
+    /**
+     * Generate a secrete key as an instance of a class implements PBEKey.
+     */
+    private SecretKey getMyOwnSecretKey(byte[] salt)
+            throws InvalidKeySpecException, NoSuchAlgorithmException {
+        return new MyPBKDF2SecretKey(PASS_PHRASE, algoForTest, salt,
+                ITERATION_COUNT, KEY_SIZE);
+    }
+
+    /**
+     * An utility class to check the SecretKeyFactory.translateKey() method.
+     */
+    class MyPBKDF2SecretKey implements PBEKey {
+        private final byte[] key;
+        private final byte[] salt;
+        private final String algorithm;
+        private final int keyLength;
+        private final String pass;
+        private int itereationCount;
+
+        /**
+         * The key is generating by SecretKeyFactory and its value just copying
+         * in the key field of MySecretKey class. So, this is real key derived
+         * using the given algo.
+         */
+        public MyPBKDF2SecretKey(String passPhrase, String algo, byte[] salt1,
+                int iterationCount, int keySize)
+                throws InvalidKeySpecException, NoSuchAlgorithmException {
+            algorithm = algo;
+            salt = salt1;
+            itereationCount = iterationCount;
+            pass = passPhrase;
+
+            PBEKeySpec spec = new PBEKeySpec(passPhrase.toCharArray(), salt,
+                    iterationCount, keySize);
+
+            SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(algo);
+
+            SecretKey realKey = keyFactory.generateSecret(spec);
+
+            keyLength = realKey.getEncoded().length;
+
+            key = new byte[keyLength];
+            System.arraycopy(realKey.getEncoded(), 0, key, 0, keyLength);
+        }
+
+        @Override
+        public String getAlgorithm() {
+            return algorithm;
+        }
+
+        @Override
+        public String getFormat() {
+            return "RAW";
+        }
+
+        @Override
+        public byte[] getEncoded() {
+            byte[] copy = new byte[keyLength];
+            System.arraycopy(key, 0, copy, 0, keyLength);
+            return copy;
+        }
+
+        @Override
+        public int getIterationCount() {
+            return itereationCount;
+        }
+
+        @Override
+        public byte[] getSalt() {
+            return salt;
+        }
+
+        @Override
+        public char[] getPassword() {
+            return pass.toCharArray();
+        }
+
+        /**
+         * Spoil the generated key (before translation) to cause an
+         * InvalidKeyException
+         */
+        public void spoil() {
+            itereationCount = -1;
+        }
+
+        @Override
+        public void destroy() throws DestroyFailedException {
+        }
+
+        @Override
+        public boolean isDestroyed() {
+            return false;
+        }
+
+    }
+}
\ No newline at end of file
diff --git a/jdk/test/javax/crypto/SecretKeyFactory/SecKFTranslateTest.java b/jdk/test/javax/crypto/SecretKeyFactory/SecKFTranslateTest.java
new file mode 100644
index 0000000..f1b5c82
--- /dev/null
+++ b/jdk/test/javax/crypto/SecretKeyFactory/SecKFTranslateTest.java
@@ -0,0 +1,206 @@
+/*
+ * Copyright (c) 2003, 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.
+ */
+
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.SecureRandom;
+import java.security.spec.AlgorithmParameterSpec;
+import java.security.spec.InvalidKeySpecException;
+import java.util.Arrays;
+import java.util.Random;
+
+import javax.crypto.BadPaddingException;
+import javax.crypto.Cipher;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.SecretKey;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.ShortBufferException;
+import javax.crypto.spec.PBEKeySpec;
+import javax.crypto.spec.PBEParameterSpec;
+import javax.security.auth.DestroyFailedException;
+
+/*
+ * @test
+ * @bug 8048820
+ * @summary The test verifies SecretKey values should remain the same after
+ *  translation with SecretKeyFactory.translateKey().
+ */
+
+public class SecKFTranslateTest {
+    private static final String SUN_JCE = "SunJCE";
+
+    public static void main(String[] args) throws Exception {
+
+        SecKFTranslateTest test = new SecKFTranslateTest();
+        test.run();
+    }
+
+    private void run() throws Exception {
+
+        for (Algorithm algorithm : Algorithm.values()) {
+            runTest(algorithm);
+        }
+    }
+
+    private void runTest(Algorithm algo) throws NoSuchAlgorithmException,
+            NoSuchProviderException, InvalidKeyException,
+            InvalidKeySpecException, NoSuchPaddingException,
+            InvalidAlgorithmParameterException, ShortBufferException,
+            IllegalBlockSizeException, BadPaddingException {
+        AlgorithmParameterSpec[] aps = new AlgorithmParameterSpec[1];
+        byte[] plainText = new byte[800];
+
+        SecretKey key1 = algo.intSecurityKey(aps);
+        Random random = new Random();
+        // Initialization
+        SecretKeyFactory skf = SecretKeyFactory.getInstance(algo.toString(),
+                SUN_JCE);
+
+        random.nextBytes(plainText);
+        Cipher ci = Cipher.getInstance(algo.toString(), SUN_JCE);
+        // Encryption
+        ci.init(Cipher.ENCRYPT_MODE, key1, aps[0]);
+        byte[] cipherText = new byte[ci.getOutputSize(plainText.length)];
+        int offset = ci.update(plainText, 0, plainText.length, cipherText, 0);
+        ci.doFinal(cipherText, offset);
+        // translate key
+        SecretKey key2 = skf.translateKey(key1);
+
+        // Decryption
+        ci.init(Cipher.DECRYPT_MODE, key2, aps[0]);
+        byte[] recoveredText = new byte[ci.getOutputSize(plainText.length)];
+        ci.doFinal(cipherText, 0, cipherText.length, recoveredText);
+
+        // Comparison
+        if (!Arrays.equals(plainText, recoveredText)) {
+            System.out.println("Key1:" + new String(key1.getEncoded())
+                    + " Key2:" + new String(key2.getEncoded()));
+            throw new RuntimeException("Testing translate key failed with "
+                    + algo);
+        }
+
+    }
+}
+
+class MyOwnSecKey implements SecretKey {
+
+    private static final String DEFAULT_ALGO = "PBEWithMD5AndDES";
+    private final byte[] key;
+    private final String algorithm;
+    private final int keySize;
+
+    public MyOwnSecKey(byte[] key1, int offset, String algo)
+            throws InvalidKeyException {
+        algorithm = algo;
+        if (algo.equalsIgnoreCase("DES")) {
+            keySize = 8;
+        } else if (algo.equalsIgnoreCase("DESede")) {
+            keySize = 24;
+        } else {
+            throw new InvalidKeyException(
+                    "Inappropriate key format and algorithm");
+        }
+
+        if (key1 == null || key1.length - offset < keySize) {
+            throw new InvalidKeyException("Wrong key size");
+        }
+        key = new byte[keySize];
+        System.arraycopy(key, offset, key, 0, keySize);
+    }
+
+    public MyOwnSecKey(PBEKeySpec ks) throws InvalidKeySpecException {
+        algorithm = DEFAULT_ALGO;
+        key = new String(ks.getPassword()).getBytes();
+        keySize = key.length;
+    }
+
+    @Override
+    public String getAlgorithm() {
+        return algorithm;
+    }
+
+    @Override
+    public String getFormat() {
+        return "RAW";
+    }
+
+    @Override
+    public byte[] getEncoded() {
+        byte[] copy = new byte[keySize];
+        System.arraycopy(key, 0, copy, 0, keySize);
+        return copy;
+    }
+
+    @Override
+    public void destroy() throws DestroyFailedException {
+    }
+
+    @Override
+    public boolean isDestroyed() {
+        return false;
+    }
+}
+
+enum Algorithm {
+    DES {
+        @Override
+        SecretKey intSecurityKey(AlgorithmParameterSpec[] spec)
+                throws InvalidKeyException {
+            int keyLength = 8;
+            byte[] keyVal = new byte[keyLength];
+            new SecureRandom().nextBytes(keyVal);
+            SecretKey key1 = new MyOwnSecKey(keyVal, 0, this.toString());
+            return key1;
+        }
+    },
+    DESEDE {
+        @Override
+        SecretKey intSecurityKey(AlgorithmParameterSpec[] spec)
+                throws InvalidKeyException {
+            int keyLength = 24;
+            byte[] keyVal = new byte[keyLength];
+            new SecureRandom().nextBytes(keyVal);
+            SecretKey key1 = new MyOwnSecKey(keyVal, 0, this.toString());
+            return key1;
+        }
+    },
+    PBEWithMD5ANDdes {
+        @Override
+        SecretKey intSecurityKey(AlgorithmParameterSpec[] spec)
+                throws InvalidKeySpecException {
+            byte[] salt = new byte[8];
+            int iterCnt = 6;
+            new Random().nextBytes(salt);
+            spec[0] = new PBEParameterSpec(salt, iterCnt);
+            PBEKeySpec pbeKS = new PBEKeySpec(
+                    new String("So far so good").toCharArray());
+            SecretKey key1 = new MyOwnSecKey(pbeKS);
+            return key1;
+        }
+    };
+    abstract SecretKey intSecurityKey(AlgorithmParameterSpec[] spec)
+            throws InvalidKeyException, InvalidKeySpecException;
+}
diff --git a/jdk/test/javax/net/ssl/TLS/CipherTestUtils.java b/jdk/test/javax/net/ssl/TLS/CipherTestUtils.java
new file mode 100644
index 0000000..3b6664b
--- /dev/null
+++ b/jdk/test/javax/net/ssl/TLS/CipherTestUtils.java
@@ -0,0 +1,689 @@
+/**
+ * Copyright (c) 2010, 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.
+ *
+ * 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.ByteArrayInputStream;
+import java.io.EOFException;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.security.KeyFactory;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.Principal;
+import java.security.PrivateKey;
+import java.security.SecureRandom;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import java.security.interfaces.RSAPrivateKey;
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.PKCS8EncodedKeySpec;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Collections;
+import java.util.List;
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLEngine;
+import javax.net.ssl.SSLServerSocket;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.TrustManagerFactory;
+import javax.net.ssl.X509ExtendedKeyManager;
+import javax.net.ssl.X509TrustManager;
+
+/**
+ * Test that all ciphersuites work in all versions and all client authentication
+ * types. The way this is setup the server is stateless and all checking is done
+ * on the client side.
+ */
+
+public class CipherTestUtils {
+
+    public static final int TIMEOUT = 20 * 1000;
+    public static final SecureRandom secureRandom = new SecureRandom();
+    public static char[] PASSWORD = "passphrase".toCharArray();
+    private static final List<TestParameters> TESTS = new ArrayList<>(3);
+    private static final List<Exception> EXCEPTIONS
+            = Collections.synchronizedList(new ArrayList<>(1));
+    private static final String CLIENT_PUBLIC_KEY
+        = "-----BEGIN CERTIFICATE-----\n"
+        + "MIICtTCCAh4CCQDkYJ46DMcGRjANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMC\n"
+        + "VVMxCzAJBgNVBAgMAkNBMRYwFAYDVQQHDA1Nb3VudGFpbiBWaWV3MR8wHQYDVQQK\n"
+        + "DBZTdW4gTWljcm9zeXN0ZW1zLCBJbmMuMSYwJAYDVQQLDB1TdW4gTWljcm9zeXN0\n"
+        + "ZW1zIExhYm9yYXRvcmllczEfMB0GA1UEAwwWVGVzdCBDQSAoMTAyNCBiaXQgUlNB\n"
+        + "KTAeFw0wOTA0MjcwNDA0MDhaFw0xMzA2MDUwNDA0MDhaMIGgMQswCQYDVQQGEwJV\n"
+        + "UzELMAkGA1UECAwCQ0ExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxHzAdBgNVBAoM\n"
+        + "FlN1biBNaWNyb3N5c3RlbXMsIEluYy4xJjAkBgNVBAsMHVN1biBNaWNyb3N5c3Rl\n"
+        + "bXMgTGFib3JhdG9yaWVzMSMwIQYDVQQDDBpUZXN0IENsaWVudCAoMTAyNCBiaXQg\n"
+        + "UlNBKTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAm5rwjmhO7Nwd5GWs+KvQ\n"
+        + "UnDiqpRDvRriOUFdF0rCI2Op24C+iwUMDGxPsgP7VkUpOdJhw3c72aP0CAWcZ5dN\n"
+        + "UCW7WVDAxnogCahLCir1jjoGdEjiNGOy0L9sypsM9UvBzJN8uvXsxsTZX4Z88cKU\n"
+        + "G7RUvN8LQ88zDljk5zr3c2MCAwEAATANBgkqhkiG9w0BAQUFAAOBgQA7LUDrzHln\n"
+        + "EXuGmwZeeroACB6DVtkClMskF/Pj5GnTxoeNN9DggycX/eOeIDKRloHuMpBeZPJH\n"
+        + "NUwFu4LB6HBDeldQD9iRp8zD/fPakOdN+1Gk5hciIZZJ5hQmeCl7Va2Gr64vUqZG\n"
+        + "MkVU755t+7ByLgzWuhPhhsX9QCuPR5FjvQ==\n"
+        + "-----END CERTIFICATE-----";
+
+    private static final String CLIENT_PRIVATE_KEY
+        = "-----BEGIN PRIVATE KEY-----\n"
+        + "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJua8I5oTuzcHeRl\n"
+        + "rPir0FJw4qqUQ70a4jlBXRdKwiNjqduAvosFDAxsT7ID+1ZFKTnSYcN3O9mj9AgF\n"
+        + "nGeXTVAlu1lQwMZ6IAmoSwoq9Y46BnRI4jRjstC/bMqbDPVLwcyTfLr17MbE2V+G\n"
+        + "fPHClBu0VLzfC0PPMw5Y5Oc693NjAgMBAAECgYA5w73zj8Nk6J3sMNaShe3S/PcY\n"
+        + "TewLopRCnwI46FbDnnbq9pNFtnzvi7HWKuY983THc1M5peTA+b1Y0QRr7F4Vg4x9\n"
+        + "9UM0B/tZcIIcJJ3LS+9fXKCbYLQWq5F05JqeZu+i+QLmJFO5+2p7laeQ4oQfW7QE\n"
+        + "YR4u2mSaLe0SsqHvOQJBAMhgcye9C6pJO0eo2/VtRxAXI7zxNAIjHwKo1cva7bhu\n"
+        + "GdrMaEAJBAsMJ1GEk7/WDI+3KEbTjQdfIJuAvOR4FXUCQQDGzNn/tl2k93v/ugyM\n"
+        + "/tBhCKDipYDIbyJMoG2AOtOGmCsiGo5L7idO4OAcm/QiHBQMXjFIVgTUcH8MhGj4\n"
+        + "blJ3AkA5fUqsxRV6tuYWKkFpif/QgwMS65VDY7Y6+hvVECwSNSyf1PO4I54QWV1S\n"
+        + "ixok+RHDjgY1Q+77hXSCiQ4o8rcdAkBHvjfR+5sx5IpgUGElJPRIgFenU3j1XH3x\n"
+        + "T1gVFaWuhg3S4eiGaGzRH4BhcrqY8K8fg4Kfi0N08yA2gTZsqUujAkEAjuNPTuKx\n"
+        + "ti0LXI09kbGUqOpRMm1zW5TD6LFeEaUN6oxrSZI2YUvu7VyotAqsxX5O0u0f3VQw\n"
+        + "ySF0Q1oZ6qu7cg==\n"
+        + "-----END PRIVATE KEY-----";
+    private static final String SERVER_PUBLIC_KEY
+        = "-----BEGIN CERTIFICATE-----\n"
+        + "MIICtTCCAh4CCQDkYJ46DMcGRTANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMC\n"
+        + "VVMxCzAJBgNVBAgMAkNBMRYwFAYDVQQHDA1Nb3VudGFpbiBWaWV3MR8wHQYDVQQK\n"
+        + "DBZTdW4gTWljcm9zeXN0ZW1zLCBJbmMuMSYwJAYDVQQLDB1TdW4gTWljcm9zeXN0\n"
+        + "ZW1zIExhYm9yYXRvcmllczEfMB0GA1UEAwwWVGVzdCBDQSAoMTAyNCBiaXQgUlNB\n"
+        + "KTAeFw0wOTA0MjcwNDA0MDhaFw0xMzA2MDUwNDA0MDhaMIGgMQswCQYDVQQGEwJV\n"
+        + "UzELMAkGA1UECAwCQ0ExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxHzAdBgNVBAoM\n"
+        + "FlN1biBNaWNyb3N5c3RlbXMsIEluYy4xJjAkBgNVBAsMHVN1biBNaWNyb3N5c3Rl\n"
+        + "bXMgTGFib3JhdG9yaWVzMSMwIQYDVQQDDBpUZXN0IFNlcnZlciAoMTAyNCBiaXQg\n"
+        + "UlNBKTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEArsHHeZ1O67yuxQKDSAOC\n"
+        + "Xm271ViwBrXkxe5cvhG8MCCem6Z3XeZ/m6c2ucRwLaQxnmG1m0G6/OYaUXTivjcG\n"
+        + "/K4bc1I+yjghAWQNLBtsOiP9w0LKibg3TSDehpeuuz/lmB5A4HMqQr8KkY4K7peD\n"
+        + "1QkJ2Dn3zhbwQ/0d8f5CCbkCAwEAATANBgkqhkiG9w0BAQUFAAOBgQBOd8XojEnu\n"
+        + "eTUHBwqfmnvRQvbICFDNbbL4KuX/JNPSy1WMGAEbNCTLZ+5yP69js8aUYqAk5vVf\n"
+        + "dWRLU3MDiEzW7zxE1ubuKWjVuyGbG8Me0G01Hw+evBcZqB64Fz3OFISVfQh7MqE/\n"
+        + "O0AeakRMH350FRLNl4o6KBSXmF/AADfqQQ==\n"
+        + "-----END CERTIFICATE-----";
+
+    private static final String SERVER_PRIVATE_KEY
+        = "-----BEGIN PRIVATE KEY-----\n"
+        + "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAK7Bx3mdTuu8rsUC\n"
+        + "g0gDgl5tu9VYsAa15MXuXL4RvDAgnpumd13mf5unNrnEcC2kMZ5htZtBuvzmGlF0\n"
+        + "4r43BvyuG3NSPso4IQFkDSwbbDoj/cNCyom4N00g3oaXrrs/5ZgeQOBzKkK/CpGO\n"
+        + "Cu6Xg9UJCdg5984W8EP9HfH+Qgm5AgMBAAECgYAXUv+3qJo+9mjxHHu/IdDFn6nB\n"
+        + "ONwNmTtWe5DfQWi3l7LznU0zOC9x6+hu9NvwC4kf1XSyqxw04tVCZ/JXZurEmEBz\n"
+        + "YtcQ5idRQDkKYXEDOeVUfvtHO6xilzrhPKxxd0GG/sei2pozikkqnYF3OcP0qL+a\n"
+        + "3nWixZQBRoF2nIRLcQJBAN97TJBr0XTRmE7OCKLUy1+ws7vZB9uQ2efHMsgwOpsY\n"
+        + "3cEW5qd95hrxLU72sBeu9loHQgBrT2Q3OAxnsPXmgO0CQQDIL3u9kS/O3Ukx+n1H\n"
+        + "JdPFQCRxrDm/vtJpQEmq+mLqxxnxCFRIYQ2ieAPokBxWeMDtdWJGD3VxhahjPfZm\n"
+        + "5K59AkEAuDVl0tVMfUIWjT5/F9jXGjUIsZofQ/iN5OLpFOHMLPO+Nd6umPjJpwON\n"
+        + "GT11wM/S+DprSPUrJ6vsYy1FTCuHsQJBAMXtnO07xgdE6AAQaRmVnyMiXmY+IQMj\n"
+        + "CyuhsrToyDDWFyIoWB0QSMjg3QxuoHYnAqpGK5qV4ksSGgG13BCz/okCQQCRHTgn\n"
+        + "DuFG2f7GYLFjI4NaTEzHGp+J9LiNYY1kYYLonpwAC3Z5hzJVanYT3/g23AUZ/fdF\n"
+        + "v5PDIViuPo5ZB1eD\n"
+        + "-----END PRIVATE KEY-----";
+
+    private static final String CA_PUBLIC_KEY
+        = "-----BEGIN CERTIFICATE-----\n"
+        + "MIIDCDCCAnGgAwIBAgIJAIYlGfwNBY6NMA0GCSqGSIb3DQEBBQUAMIGcMQswCQYD\n"
+        + "VQQGEwJVUzELMAkGA1UECAwCQ0ExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxHzAd\n"
+        + "BgNVBAoMFlN1biBNaWNyb3N5c3RlbXMsIEluYy4xJjAkBgNVBAsMHVN1biBNaWNy\n"
+        + "b3N5c3RlbXMgTGFib3JhdG9yaWVzMR8wHQYDVQQDDBZUZXN0IENBICgxMDI0IGJp\n"
+        + "dCBSU0EpMB4XDTA5MDQyNzA0MDQwOFoXDTEzMDYwNTA0MDQwOFowgZwxCzAJBgNV\n"
+        + "BAYTAlVTMQswCQYDVQQIDAJDQTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEfMB0G\n"
+        + "A1UECgwWU3VuIE1pY3Jvc3lzdGVtcywgSW5jLjEmMCQGA1UECwwdU3VuIE1pY3Jv\n"
+        + "c3lzdGVtcyBMYWJvcmF0b3JpZXMxHzAdBgNVBAMMFlRlc3QgQ0EgKDEwMjQgYml0\n"
+        + "IFJTQSkwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAOK4DJxxb0XX6MJ1CVjp\n"
+        + "9Gmr/Ua8MS12R58F9lDpSKuq8cFexA4W7OdZ4jtbKv0tRHX5YxmbnXedwS+gdcOA\n"
+        + "GRgXMoeXlgTFGpdL+TR8xKIlMGRSjnR7MpR2tRyIYI2p+UTEiD6LTlIm5Wh4z1q8\n"
+        + "LYbxyMVD1XNNNymvPM44OjsBAgMBAAGjUDBOMB0GA1UdDgQWBBT27BLUflmfdtbi\n"
+        + "WTgjwWnoxop2MTAfBgNVHSMEGDAWgBT27BLUflmfdtbiWTgjwWnoxop2MTAMBgNV\n"
+        + "HRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAEQELNzhZpjnSgigd+QJ6I/3CPDo\n"
+        + "SDkMLdP1BHlT/DkMIZvABm+M09ePNlWiLYCNCsL9nWmX0gw0rFDKsTklZyKTUzaM\n"
+        + "oy/AZCrAaoIc6SO5m1xE1RMyVxd/Y/kg6cbfWxxCJFlMeU5rsSdC97HTE/lDyuoh\n"
+        + "BmlOBB7SdR+1ScjA\n"
+        + "-----END CERTIFICATE-----";
+
+    private static final String CA_PRIVATE_KEY
+        = "-----BEGIN PRIVATE KEY-----\n"
+        + "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAOK4DJxxb0XX6MJ1\n"
+        + "CVjp9Gmr/Ua8MS12R58F9lDpSKuq8cFexA4W7OdZ4jtbKv0tRHX5YxmbnXedwS+g\n"
+        + "dcOAGRgXMoeXlgTFGpdL+TR8xKIlMGRSjnR7MpR2tRyIYI2p+UTEiD6LTlIm5Wh4\n"
+        + "z1q8LYbxyMVD1XNNNymvPM44OjsBAgMBAAECgYEApmMOlk3FrQtsvjGof4GLp3Xa\n"
+        + "tmvs54FzxKhagj0C4UHelNyYpAJ9MLjNiGQ7I31yTeaNrUCAi0XSfsKTSrwbLSnJ\n"
+        + "qsUPKMBrnzcWrOyui2+cupHZXaTlNeYB97teLJYpa6Ql9CZLoTHoim1+//s7diBh\n"
+        + "03Vls+M6Poi5PMvv59UCQQD+k/BiokmbBgWHfBY5cZSlx3Z4VTwSHJmHDTO3Tjso\n"
+        + "EVErXUSVvqD/KHX6eM4VPM8lySV5djWV8lDsESCWMtiLAkEA4/xFNsiOLMQpxW/O\n"
+        + "bt2tukxJkAxldD4lPoFZR+zbXtMtt8OjERtX2wD+nj6h7jfIeSyVuBEcBN8Uj8xe\n"
+        + "kgfgIwJAPbKG4LCqHAsCjgpRrIxNVTwZByLJEy6hOqzFathn19cSj+rjs1Lm28/n\n"
+        + "f9OFRnpdTbAJB/3REM0QNZYVCrG57wJBAN0KuTytZJNouaswhPCew5Kt5mDgc/kp\n"
+        + "S8j3dk2zCto8W8Ygy1iJrzuqEjPxO+UQdrFtlde51vWuKGxnVIW3VwsCQEldqk7r\n"
+        + "8y7PgquPP+k3L0OXno5wGBrPcW1+U0mhIZGnwSzE4SPX2ddqUSEUA/Av4RjAckL/\n"
+        + "fpqmCkpTanyYW9U=\n"
+        + "-----END PRIVATE KEY-----";
+
+    private final SSLSocketFactory factory;
+    private final X509ExtendedKeyManager clientKeyManager;
+    private final X509ExtendedKeyManager serverKeyManager;
+    private final X509TrustManager clientTrustManager;
+    private final X509TrustManager serverTrustManager;
+
+    static abstract class Server implements Runnable {
+
+        final CipherTestUtils cipherTest;
+
+        Server(CipherTestUtils cipherTest) throws Exception {
+            this.cipherTest = cipherTest;
+        }
+
+        @Override
+        public abstract void run();
+
+        void handleRequest(InputStream in, OutputStream out)
+                throws IOException {
+            boolean newline = false;
+            StringBuilder sb = new StringBuilder();
+            while (true) {
+                int ch = in.read();
+                if (ch < 0) {
+                    throw new EOFException();
+                }
+                sb.append((char) ch);
+                if (ch == '\r') {
+                    // empty
+                } else if (ch == '\n') {
+                    if (newline) {
+                        // 2nd newline in a row, end of request
+                        break;
+                    }
+                    newline = true;
+                } else {
+                    newline = false;
+                }
+            }
+            String request = sb.toString();
+            if (request.startsWith("GET / HTTP/1.") == false) {
+                throw new IOException("Invalid request: " + request);
+            }
+            out.write("HTTP/1.0 200 OK\r\n\r\n".getBytes());
+            out.write("Tested Scenario: ".getBytes());
+            TestParameters tp = (TestParameters) CipherTestUtils.TESTS.get(0);
+            out.write(tp.toString().getBytes());
+            out.write(" Test PASSED.".getBytes());
+        }
+    }
+
+    public static class TestParameters {
+
+        String cipherSuite;
+        String protocol;
+        String clientAuth;
+
+        TestParameters(String cipherSuite, String protocol,
+                String clientAuth) {
+            this.cipherSuite = cipherSuite;
+            this.protocol = protocol;
+            this.clientAuth = clientAuth;
+        }
+
+        boolean isEnabled() {
+            return true;
+        }
+
+        @Override
+        public String toString() {
+            String s = cipherSuite + " in " + protocol + " mode";
+            if (clientAuth != null) {
+                s += " with " + clientAuth + " client authentication";
+            }
+            return s;
+        }
+    }
+
+    private static volatile CipherTestUtils instance = null;
+
+    public static CipherTestUtils getInstance() throws IOException,
+            FileNotFoundException, KeyStoreException,
+            NoSuchAlgorithmException, CertificateException,
+            UnrecoverableKeyException, InvalidKeySpecException {
+        if (instance == null) {
+            synchronized (CipherTestUtils.class) {
+                if (instance == null) {
+                    instance = new CipherTestUtils();
+                }
+            }
+        }
+        return instance;
+    }
+
+    public static void setTestedArguments(String testedProtocol,
+            String testedCipherSuite) {
+
+        TestParameters testedParams;
+
+        String cipherSuite = testedCipherSuite.trim();
+        if (cipherSuite.startsWith("SSL_")) {
+            testedParams =
+                new TestParameters(cipherSuite, testedProtocol, null);
+            TESTS.add(testedParams);
+
+        } else {
+            System.out.println("Your input Cipher suites is not correct, "
+                    + "please try another one .");
+        }
+    }
+
+    public X509ExtendedKeyManager getClientKeyManager() {
+        return clientKeyManager;
+    }
+
+    public X509TrustManager getClientTrustManager() {
+        return clientTrustManager;
+    }
+
+    public X509ExtendedKeyManager getServerKeyManager() {
+        return serverKeyManager;
+    }
+
+    public X509TrustManager getServerTrustManager() {
+        return serverTrustManager;
+    }
+
+    public static void addFailure(Exception e) {
+        EXCEPTIONS.add(e);
+    }
+
+    private CipherTestUtils()
+            throws IOException, FileNotFoundException, KeyStoreException,
+            NoSuchAlgorithmException, CertificateException,
+            UnrecoverableKeyException, InvalidKeySpecException {
+        factory = (SSLSocketFactory) SSLSocketFactory.getDefault();
+        KeyStore serverKeyStore = createServerKeyStore(SERVER_PUBLIC_KEY,
+                SERVER_PRIVATE_KEY);
+        KeyStore serverTrustStore = createServerKeyStore(CA_PUBLIC_KEY,
+                CA_PRIVATE_KEY);
+
+        if (serverKeyStore != null) {
+            KeyManagerFactory keyFactory1
+                    = KeyManagerFactory.getInstance(
+                            KeyManagerFactory.getDefaultAlgorithm());
+            keyFactory1.init(serverKeyStore, PASSWORD);
+            serverKeyManager = (X509ExtendedKeyManager) keyFactory1.
+                    getKeyManagers()[0];
+        } else {
+            serverKeyManager = null;
+        }
+        serverTrustManager = serverTrustStore != null
+                ? new AlwaysTrustManager(serverTrustStore) : null;
+
+        KeyStore clientKeyStore, clientTrustStore;
+        clientTrustStore = serverTrustStore;
+        clientKeyStore =
+                createServerKeyStore(CLIENT_PUBLIC_KEY,CLIENT_PRIVATE_KEY);
+        if (clientKeyStore != null) {
+            KeyManagerFactory keyFactory
+                    = KeyManagerFactory.getInstance(
+                            KeyManagerFactory.getDefaultAlgorithm());
+            keyFactory.init(clientKeyStore, PASSWORD);
+            clientKeyManager = (X509ExtendedKeyManager) keyFactory.
+                    getKeyManagers()[0];
+        } else {
+            clientKeyManager = null;
+        }
+        clientTrustManager = (clientTrustStore != null)
+                ? new AlwaysTrustManager(clientTrustStore) : null;
+    }
+
+    void checkResult(String exception) throws Exception {
+        if (EXCEPTIONS.size() >= 1) {
+            Exception actualException = EXCEPTIONS.get(0);
+            if (exception == null) {
+                throw new RuntimeException("FAILED: got unexpected exception: "
+                        + actualException);
+            }
+            if (!exception.equals(actualException.getClass().getName())) {
+                throw new RuntimeException("FAILED: got unexpected exception: "
+                        + actualException);
+            }
+
+            System.out.println("PASSED: got expected exception: "
+                    + actualException);
+        } else {
+            if (exception != null) {
+                throw new RuntimeException("FAILED: " + exception
+                        + " was expected");
+            }
+            System.out.println("PASSED");
+        }
+    }
+
+    SSLSocketFactory getFactory() {
+        return factory;
+    }
+
+    static abstract class Client implements Runnable {
+
+        final CipherTestUtils cipherTest;
+        TestParameters testedParams;
+
+        Client(CipherTestUtils cipherTest) throws Exception {
+            this.cipherTest = cipherTest;
+        }
+
+        Client(CipherTestUtils cipherTest,
+                String testedCipherSuite) throws Exception {
+            this.cipherTest = cipherTest;
+        }
+
+        @Override
+        public final void run() {
+
+            TESTS.stream().map((params) -> {
+                if (!params.isEnabled()) {
+                    System.out.println("Skipping disabled test " + params);
+                }
+                return params;
+            }).forEach((params) -> {
+                try {
+                    runTest(params);
+                    System.out.println("Passed " + params);
+                } catch (Exception e) {
+                    CipherTestUtils.addFailure(e);
+                    System.out.println("** Failed " + params
+                            + "**, got exception:");
+                    e.printStackTrace(System.err);
+                }
+            });
+        }
+
+        abstract void runTest(TestParameters params) throws Exception;
+
+        void sendRequest(InputStream in, OutputStream out) throws IOException {
+            out.write("GET / HTTP/1.0\r\n\r\n".getBytes());
+            out.flush();
+            StringBuilder sb = new StringBuilder();
+            while (true) {
+                int ch = in.read();
+                if (ch < 0) {
+                    break;
+                }
+                sb.append((char) ch);
+            }
+            String response = sb.toString();
+            if (response.startsWith("HTTP/1.0 200 ") == false) {
+                throw new IOException("Invalid response: " + response);
+            } else {
+                System.out.println();
+                System.out.println("--- Response --- ");
+                System.out.println(response);
+                System.out.println("---------------- ");
+            }
+        }
+    }
+
+    public static void printStringArray(String[] stringArray) {
+        System.out.print(stringArray.length + " : ");
+        for (String stringArray1 : stringArray) {
+            System.out.print(stringArray1);
+            System.out.print(",");
+        }
+        System.out.println();
+    }
+
+    public static void printInfo(SSLServerSocket socket) {
+        System.out.println();
+        System.out.println("--- SSL ServerSocket Info ---");
+        System.out.print("SupportedProtocols    : ");
+        printStringArray(socket.getSupportedProtocols());
+        System.out.print("SupportedCipherSuites : ");
+        printStringArray(socket.getSupportedCipherSuites());
+        System.out.print("EnabledProtocols      : ");
+        printStringArray(socket.getEnabledProtocols());
+        System.out.print("EnabledCipherSuites   : ");
+        String[] supportedCipherSuites = socket.getEnabledCipherSuites();
+        Arrays.sort(supportedCipherSuites);
+        printStringArray(supportedCipherSuites);
+        System.out.println("NeedClientAuth        : "
+                + socket.getNeedClientAuth());
+        System.out.println("WantClientAuth        : "
+                + socket.getWantClientAuth());
+        System.out.println("-----------------------");
+    }
+
+    public static void printInfo(SSLSocket socket) {
+        System.out.println();
+        System.out.println("--- SSL Socket Info ---");
+        System.out.print(" SupportedProtocols    : ");
+        printStringArray(socket.getSupportedProtocols());
+        System.out.println(" EnabledProtocols      : "
+                + socket.getEnabledProtocols()[0]);
+        System.out.print(" SupportedCipherSuites : ");
+        String[] supportedCipherSuites = socket.getEnabledCipherSuites();
+        Arrays.sort(supportedCipherSuites);
+        printStringArray(supportedCipherSuites);
+        System.out.println(" EnabledCipherSuites   : "
+                + socket.getEnabledCipherSuites()[0]);
+        System.out.println(" NeedClientAuth        : "
+                + socket.getNeedClientAuth());
+        System.out.println(" WantClientAuth        : "
+                + socket.getWantClientAuth());
+        System.out.println("-----------------------");
+    }
+
+    private static KeyStore createServerKeyStore(String publicKeyStr,
+            String keySpecStr) throws KeyStoreException, IOException,
+            NoSuchAlgorithmException, CertificateException,
+            InvalidKeySpecException {
+
+        KeyStore ks = KeyStore.getInstance("JKS");
+        ks.load(null, null);
+        if (publicKeyStr == null || keySpecStr == null) {
+            throw new IllegalArgumentException("publicKeyStr or "
+                    + "keySpecStr cannot be null");
+        }
+        String strippedPrivateKey = keySpecStr.substring(
+                keySpecStr.indexOf("\n"), keySpecStr.lastIndexOf("\n"));
+
+        // generate the private key.
+        PKCS8EncodedKeySpec priKeySpec = new PKCS8EncodedKeySpec(
+                Base64.getMimeDecoder().decode(strippedPrivateKey));
+        KeyFactory kf = KeyFactory.getInstance("RSA");
+        RSAPrivateKey priKey
+                = (RSAPrivateKey) kf.generatePrivate(priKeySpec);
+
+        // generate certificate chain
+        try (InputStream is =
+                new ByteArrayInputStream(publicKeyStr.getBytes())) {
+            // generate certificate from cert string
+            CertificateFactory cf = CertificateFactory.getInstance("X.509");
+            Certificate keyCert = cf.generateCertificate(is);
+            Certificate[] chain = {keyCert};
+            ks.setKeyEntry("TestEntry", priKey, PASSWORD, chain);
+        }
+
+        return ks;
+    }
+
+    public static void main(PeerFactory peerFactory, String mode,
+            String expectedException)
+            throws Exception {
+        long time = System.currentTimeMillis();
+        setTestedArguments(peerFactory.getTestedProtocol(),
+                peerFactory.getTestedCipher());
+
+        System.out.print(
+                " Initializing test '" + peerFactory.getName() + "'...");
+        secureRandom.nextInt();
+
+        CipherTestUtils cipherTest = CipherTestUtils.getInstance();
+        if (mode.equalsIgnoreCase("Server")) {  // server mode
+            Thread serverThread = new Thread(peerFactory.newServer(cipherTest),
+                    "Server");
+            serverThread.start();
+        } else if (mode.equalsIgnoreCase("Client")) {
+            peerFactory.newClient(cipherTest).run();
+            cipherTest.checkResult(expectedException);
+            JSSEServer.closeServer = true;
+        } else {
+            throw new RuntimeException("unsupported mode");
+        }
+        time = System.currentTimeMillis() - time;
+        System.out.println("Elapsed time " + time);
+
+    }
+
+    public static abstract class PeerFactory {
+
+        abstract String getName();
+
+        abstract String getTestedProtocol();
+
+        abstract String getTestedCipher();
+
+        abstract Client newClient(CipherTestUtils cipherTest) throws Exception;
+
+        abstract Server newServer(CipherTestUtils cipherTest) throws Exception;
+
+        boolean isSupported(String cipherSuite) {
+            return true;
+        }
+    }
+}
+
+class AlwaysTrustManager implements X509TrustManager {
+
+    X509TrustManager trustManager;
+
+    public AlwaysTrustManager(KeyStore keyStore)
+            throws NoSuchAlgorithmException, KeyStoreException {
+
+        TrustManagerFactory tmf
+                = TrustManagerFactory.getInstance(TrustManagerFactory.
+                        getDefaultAlgorithm());
+        tmf.init(keyStore);
+
+        TrustManager tms[] = tmf.getTrustManagers();
+        for (TrustManager tm : tms) {
+            trustManager = (X509TrustManager) tm;
+            return;
+        }
+
+    }
+
+    @Override
+    public void checkClientTrusted(X509Certificate[] chain, String authType)
+            throws CertificateException {
+        try {
+            trustManager.checkClientTrusted(chain, authType);
+        } catch (CertificateException excep) {
+            System.out.println("ERROR in client trust manager");
+        }
+    }
+
+    @Override
+    public void checkServerTrusted(X509Certificate[] chain, String authType)
+            throws CertificateException {
+        try {
+            trustManager.checkServerTrusted(chain, authType);
+        } catch (CertificateException excep) {
+            System.out.println("ERROR in server Trust manger");
+        }
+    }
+
+    @Override
+    public X509Certificate[] getAcceptedIssuers() {
+        return trustManager.getAcceptedIssuers();
+    }
+}
+
+class MyX509KeyManager extends X509ExtendedKeyManager {
+
+    private final X509ExtendedKeyManager keyManager;
+    private String authType;
+
+    MyX509KeyManager(X509ExtendedKeyManager keyManager) {
+        this.keyManager = keyManager;
+    }
+
+    void setAuthType(String authType) {
+        this.authType = "ECDSA".equals(authType) ? "EC" : authType;
+    }
+
+    @Override
+    public String[] getClientAliases(String keyType, Principal[] issuers) {
+        if (authType == null) {
+            return null;
+        }
+        return keyManager.getClientAliases(authType, issuers);
+    }
+
+    @Override
+    public String chooseClientAlias(String[] keyType, Principal[] issuers,
+            Socket socket) {
+        if (authType == null) {
+            return null;
+        }
+        return keyManager.chooseClientAlias(new String[]{authType},
+                issuers, socket);
+    }
+
+    @Override
+    public String chooseEngineClientAlias(String[] keyType,
+            Principal[] issuers, SSLEngine engine) {
+        if (authType == null) {
+            return null;
+        }
+        return keyManager.chooseEngineClientAlias(new String[]{authType},
+                issuers, engine);
+    }
+
+    @Override
+    public String[] getServerAliases(String keyType, Principal[] issuers) {
+        throw new UnsupportedOperationException("Servers not supported");
+    }
+
+    @Override
+    public String chooseServerAlias(String keyType, Principal[] issuers,
+            Socket socket) {
+        throw new UnsupportedOperationException("Servers not supported");
+    }
+
+    @Override
+    public String chooseEngineServerAlias(String keyType, Principal[] issuers,
+            SSLEngine engine) {
+        throw new UnsupportedOperationException("Servers not supported");
+    }
+
+    @Override
+    public X509Certificate[] getCertificateChain(String alias) {
+        return keyManager.getCertificateChain(alias);
+    }
+
+    @Override
+    public PrivateKey getPrivateKey(String alias) {
+        return keyManager.getPrivateKey(alias);
+    }
+}
diff --git a/jdk/test/javax/net/ssl/TLS/JSSEClient.java b/jdk/test/javax/net/ssl/TLS/JSSEClient.java
new file mode 100644
index 0000000..b08ae91
--- /dev/null
+++ b/jdk/test/javax/net/ssl/TLS/JSSEClient.java
@@ -0,0 +1,120 @@
+/**
+ * Copyright (c) 2010, 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.
+ *
+ * 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.InputStream;
+import java.io.OutputStream;
+import java.security.cert.Certificate;
+import javax.net.ssl.KeyManager;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManager;
+
+class JSSEClient extends CipherTestUtils.Client {
+
+    private static final String DEFAULT = "DEFAULT";
+    private static final String TLS = "TLS";
+
+    private final SSLContext sslContext;
+    private final MyX509KeyManager keyManager;
+    private final int serverPort;
+    private final String serverHost;
+    private final String testedProtocol;
+
+    JSSEClient(CipherTestUtils cipherTest, String serverHost, int serverPort,
+            String testedProtocols, String testedCipherSuite) throws Exception {
+        super(cipherTest, testedCipherSuite);
+        this.serverHost = serverHost;
+        this.serverPort = serverPort;
+        this.testedProtocol = testedProtocols;
+        this.keyManager =
+                new MyX509KeyManager(cipherTest.getClientKeyManager());
+        sslContext = SSLContext.getInstance(TLS);
+    }
+
+    @Override
+    void runTest(CipherTestUtils.TestParameters params) throws Exception {
+        SSLSocket socket = null;
+        try {
+            System.out.println("Connecting to server...");
+            keyManager.setAuthType(params.clientAuth);
+            sslContext.init(new KeyManager[]{keyManager},
+                    new TrustManager[]{cipherTest.getClientTrustManager()},
+                    CipherTestUtils.secureRandom);
+            SSLSocketFactory factory = (SSLSocketFactory) sslContext.
+                    getSocketFactory();
+            socket = (SSLSocket) factory.createSocket(serverHost,
+                    serverPort);
+            socket.setSoTimeout(CipherTestUtils.TIMEOUT);
+            socket.setEnabledCipherSuites(params.cipherSuite.split(","));
+            if (params.protocol != null && !params.protocol.trim().equals("")
+                    && !params.protocol.trim().equals(DEFAULT)) {
+                socket.setEnabledProtocols(params.protocol.split(","));
+            }
+            CipherTestUtils.printInfo(socket);
+            InputStream in = socket.getInputStream();
+            OutputStream out = socket.getOutputStream();
+            sendRequest(in, out);
+            SSLSession session = socket.getSession();
+            session.invalidate();
+            String cipherSuite = session.getCipherSuite();
+            if (params.cipherSuite.equals(cipherSuite) == false) {
+                throw new RuntimeException("Negotiated ciphersuite mismatch: "
+                        + cipherSuite + " != " + params.cipherSuite);
+            }
+            String protocol = session.getProtocol();
+            if (!DEFAULT.equals(params.protocol)
+                    && !params.protocol.contains(protocol)) {
+                throw new RuntimeException("Negotiated protocol mismatch: "
+                        + protocol + " != " + params.protocol);
+            }
+            if (!cipherSuite.contains("DH_anon")) {
+                session.getPeerCertificates();
+            }
+            Certificate[] certificates = session.getLocalCertificates();
+            if (params.clientAuth == null) {
+                if (certificates != null) {
+                    throw new RuntimeException("Local certificates "
+                            + "should be null");
+                }
+            } else {
+                if ((certificates == null) || (certificates.length == 0)) {
+                    throw new RuntimeException("Certificates missing");
+                }
+                String keyAlg = certificates[0].getPublicKey().getAlgorithm();
+                if ("EC".equals(keyAlg)) {
+                    keyAlg = "ECDSA";
+                }
+                if (params.clientAuth == null ? keyAlg != null
+                        : !params.clientAuth.equals(keyAlg)) {
+                    throw new RuntimeException("Certificate type mismatch: "
+                            + keyAlg + " != " + params.clientAuth);
+                }
+            }
+        } finally {
+            if (socket != null) {
+                socket.close();
+            }
+        }
+    }
+}
diff --git a/jdk/test/javax/net/ssl/TLS/JSSEServer.java b/jdk/test/javax/net/ssl/TLS/JSSEServer.java
new file mode 100644
index 0000000..f6e55a3
--- /dev/null
+++ b/jdk/test/javax/net/ssl/TLS/JSSEServer.java
@@ -0,0 +1,80 @@
+/**
+ * Copyright (c) 2010, 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.
+ *
+ * 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.InputStream;
+import java.io.OutputStream;
+import javax.net.ssl.KeyManager;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLServerSocket;
+import javax.net.ssl.SSLServerSocketFactory;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.TrustManager;
+
+public class JSSEServer extends CipherTestUtils.Server {
+
+    private final SSLServerSocket serverSocket;
+    private final int serverPort;
+    static volatile boolean closeServer = false;
+
+    JSSEServer(CipherTestUtils cipherTest, int serverPort,
+            String protocol, String cipherSuite) throws Exception {
+        super(cipherTest);
+        this.serverPort = serverPort;
+        SSLContext serverContext = SSLContext.getInstance("TLS");
+        serverContext.init(new KeyManager[]{cipherTest.getServerKeyManager()},
+                new TrustManager[]{cipherTest.getServerTrustManager()},
+                CipherTestUtils.secureRandom);
+        SSLServerSocketFactory factory =
+                (SSLServerSocketFactory)serverContext.getServerSocketFactory();
+        serverSocket =
+                (SSLServerSocket) factory.createServerSocket(serverPort);
+        serverSocket.setEnabledProtocols(protocol.split(","));
+        serverSocket.setEnabledCipherSuites(cipherSuite.split(","));
+
+        CipherTestUtils.printInfo(serverSocket);
+    }
+
+    @Override
+    public void run() {
+        System.out.println("JSSE Server listening on port " + serverPort);
+        while (!closeServer) {
+            try (final SSLSocket socket = (SSLSocket) serverSocket.accept()) {
+                socket.setSoTimeout(CipherTestUtils.TIMEOUT);
+
+                try (InputStream in = socket.getInputStream();
+                        OutputStream out = socket.getOutputStream()) {
+                    handleRequest(in, out);
+                    out.flush();
+                } catch (IOException e) {
+                    CipherTestUtils.addFailure(e);
+                    System.out.println("Got IOException:");
+                    e.printStackTrace(System.err);
+                }
+            } catch (Exception e) {
+                CipherTestUtils.addFailure(e);
+                System.out.println("Exception:");
+                e.printStackTrace(System.err);
+            }
+        }
+    }
+}
diff --git a/jdk/test/javax/net/ssl/TLS/TLSClientPropertyTest.java b/jdk/test/javax/net/ssl/TLS/TLSClientPropertyTest.java
new file mode 100644
index 0000000..8d7c1b2
--- /dev/null
+++ b/jdk/test/javax/net/ssl/TLS/TLSClientPropertyTest.java
@@ -0,0 +1,205 @@
+/*
+ * Copyright (c) 2014, 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.
+ */
+
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.util.Arrays;
+import java.util.List;
+import javax.net.ssl.SSLContext;
+
+/*
+ * @test
+ * @bug 8049432 8069038
+ * @summary New tests for TLS property jdk.tls.client.protocols
+ * @summary javax/net/ssl/TLS/TLSClientPropertyTest.java needs to be
+ *     updated for JDK-8061210
+ * @run main/othervm TLSClientPropertyTest NoProperty
+ * @run main/othervm TLSClientPropertyTest SSLv3
+ * @run main/othervm TLSClientPropertyTest TLSv1
+ * @run main/othervm TLSClientPropertyTest TLSv11
+ * @run main/othervm TLSClientPropertyTest TLSv12
+ * @run main/othervm TLSClientPropertyTest WrongProperty
+ */
+
+/**
+ * Sets the property jdk.tls.client.protocols to one of this protocols:
+ * SSLv3,TLSv1,TLSv1.1,TLSv1.2 and TLSV(invalid) or removes this
+ * property (if any),then validates the default, supported and current
+ * protocols in the SSLContext.
+ */
+public class TLSClientPropertyTest {
+    private final String[] expectedSupportedProtos = new String[] {
+            "SSLv2Hello", "SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2"
+    };
+
+    public static void main(String[] args) throws Exception {
+
+        if (args.length < 1) {
+            throw new RuntimeException(
+                    "Incorrect arguments,expected arguments: testCase");
+        }
+
+        String[] expectedDefaultProtos;
+        String testCase = args[0];
+        String contextProtocol;
+        switch (testCase) {
+        case "NoProperty":
+            if (System.getProperty("jdk.tls.client.protocols") != null) {
+                System.getProperties().remove("jdk.tls.client.protocols");
+            }
+            contextProtocol = null;
+            expectedDefaultProtos = new String[] {
+                    "TLSv1", "TLSv1.1", "TLSv1.2"
+            };
+            break;
+        case "SSLv3":
+            contextProtocol = "SSLv3";
+            expectedDefaultProtos = new String[] {
+            };
+            break;
+        case "TLSv1":
+            contextProtocol = "TLSv1";
+            expectedDefaultProtos = new String[] {
+                    "TLSv1"
+            };
+            break;
+        case "TLSv11":
+            contextProtocol = "TLSv1.1";
+            expectedDefaultProtos = new String[] {
+                    "TLSv1", "TLSv1.1"
+            };
+            break;
+        case "TLSv12":
+            contextProtocol = "TLSv1.2";
+            expectedDefaultProtos = new String[] {
+                    "TLSv1", "TLSv1.1", "TLSv1.2"
+            };
+            break;
+        case "WrongProperty":
+            expectedDefaultProtos = new String[] {};
+            contextProtocol = "TLSV";
+            break;
+        default:
+            throw new RuntimeException("test case is wrong");
+        }
+        if (contextProtocol != null) {
+            System.setProperty("jdk.tls.client.protocols", contextProtocol);
+        }
+        try {
+            TLSClientPropertyTest test = new TLSClientPropertyTest();
+            test.test(contextProtocol, expectedDefaultProtos);
+            if (testCase.equals("WrongProperty")) {
+                throw new RuntimeException(
+                        "Test failed: NoSuchAlgorithmException " +
+                        "is expected when input wrong protocol");
+            } else {
+                System.out.println("Test " + contextProtocol + " passed");
+            }
+        } catch (NoSuchAlgorithmException nsae) {
+            if (testCase.equals("WrongProperty")) {
+                System.out.println("NoSuchAlgorithmException is expected,"
+                        + contextProtocol + " test passed");
+            } else {
+                throw nsae;
+            }
+        }
+
+    }
+
+    /**
+     * The parameter passed is the user enforced protocol. Does not catch
+     * NoSuchAlgorithmException, WrongProperty test will use it.
+     */
+    public void test(String expectedContextProto,
+            String[] expectedDefaultProtos) throws NoSuchAlgorithmException {
+
+        SSLContext context = null;
+        try {
+            if (expectedContextProto != null) {
+                context = SSLContext.getInstance(expectedContextProto);
+                context.init(null, null, null);
+            } else {
+                context = SSLContext.getDefault();
+            }
+            printContextDetails(context);
+        } catch (KeyManagementException ex) {
+            error(null, ex);
+        }
+
+        validateContext(expectedContextProto, expectedDefaultProtos, context);
+    }
+
+    /**
+     * Simple print utility for SSLContext's protocol details.
+     */
+    private void printContextDetails(SSLContext context) {
+        System.out.println("Default   Protocols: "
+                + Arrays.toString(context.getDefaultSSLParameters()
+                        .getProtocols()));
+        System.out.println("Supported Protocols: "
+                + Arrays.toString(context.getSupportedSSLParameters()
+                        .getProtocols()));
+        System.out.println("Current   Protocol : " + context.getProtocol());
+
+    }
+
+    /**
+     * Error handler.
+     */
+    private void error(String msg, Throwable tble) {
+        String finalMsg = "FAILED " + (msg != null ? msg : "");
+        if (tble != null) {
+            throw new RuntimeException(finalMsg, tble);
+        }
+        throw new RuntimeException(finalMsg);
+    }
+
+    /**
+     * Validates the SSLContext's protocols against the user enforced protocol.
+     */
+    private void validateContext(String expectedProto,
+            String[] expectedDefaultProtos, SSLContext context) {
+        if (expectedProto == null) {
+            expectedProto = "Default";
+        }
+        if (!context.getProtocol().equals(expectedProto)) {
+            error("Invalid current protocol: " + context.getProtocol()
+                    + ", Expected:" + expectedProto, null);
+        }
+        List<String> actualDefaultProtos = Arrays.asList(context
+                .getDefaultSSLParameters().getProtocols());
+        for (String p : expectedDefaultProtos) {
+            if (!actualDefaultProtos.contains(p)) {
+                error("Default protocol " + p + "missing", null);
+            }
+        }
+        List<String> actualSupportedProtos = Arrays.asList(context
+                .getSupportedSSLParameters().getProtocols());
+
+        for (String p : expectedSupportedProtos) {
+            if (!actualSupportedProtos.contains(p)) {
+                error("Expected to support protocol:" + p, null);
+            }
+        }
+    }
+}
diff --git a/jdk/test/javax/net/ssl/TLS/TestJSSE.java b/jdk/test/javax/net/ssl/TLS/TestJSSE.java
new file mode 100644
index 0000000..7a776aa
--- /dev/null
+++ b/jdk/test/javax/net/ssl/TLS/TestJSSE.java
@@ -0,0 +1,188 @@
+/**
+ * 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 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 static java.lang.System.out;
+import java.security.Provider;
+import java.security.Security;
+
+/**
+ * @test
+ * @bug 8049429
+ * @library ../../../../lib/testlibrary/
+ * @build jdk.testlibrary.Utils
+ * @compile CipherTestUtils.java JSSEClient.java JSSEServer.java
+ * @summary Test that all cipher suites work in all versions and all client
+ * authentication types. The way this is setup the server is stateless and
+ * all checking is done on the client side.
+ * @run main/othervm -DSERVER_PROTOCOL=SSLv3
+ *        -DCLIENT_PROTOCOL=SSLv3
+ *        -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 TestJSSE
+ * @run main/othervm -DSERVER_PROTOCOL=TLSv1
+ *        -DCLIENT_PROTOCOL=SSLv3,TLSv1,TLSv1.1,TLSv1.2
+ *        -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 TestJSSE
+ * @run main/othervm -DSERVER_PROTOCOL=TLSv1.1
+ *        -DCLIENT_PROTOCOL=SSLv3,TLSv1,TLSv1.1,TLSv1.2
+ *        -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 TestJSSE
+ * @run main/othervm -DSERVER_PROTOCOL=TLSv1.2
+ *        -DCLIENT_PROTOCOL=SSLv3,TLSv1,TLSv1.1,TLSv1.2
+ *        -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 TestJSSE
+ * @run main/othervm -DSERVER_PROTOCOL=SSLv3,TLSv1
+ *        -DCLIENT_PROTOCOL=TLSv1 -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 TestJSSE
+ * @run main/othervm -DSERVER_PROTOCOL=SSLv3,TLSv1,TLSv1.1
+ *        -DCLIENT_PROTOCOL=TLSv1.1 -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 TestJSSE
+ * @run main/othervm -DSERVER_PROTOCOL=SSLv3
+ *        -DCLIENT_PROTOCOL=TLSv1.1,TLSv1.2
+ *        -DCIPHER=SSL_RSA_WITH_RC4_128_MD5
+ *        TestJSSE javax.net.ssl.SSLHandshakeException
+ * @run main/othervm -DSERVER_PROTOCOL=TLSv1
+ *        -DCLIENT_PROTOCOL=TLSv1.1,TLSv1.2
+ *        -DCIPHER=SSL_RSA_WITH_RC4_128_MD5
+ *        TestJSSE javax.net.ssl.SSLHandshakeException
+ * @run main/othervm -DSERVER_PROTOCOL=SSLv3,TLSv1,TLSv1.1,TLSv1.2
+ *        -DCLIENT_PROTOCOL=TLSv1.2 -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 TestJSSE
+ * @run main/othervm -DSERVER_PROTOCOL=SSLv2Hello,SSLv3,TLSv1
+ *        -DCLIENT_PROTOCOL=DEFAULT -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 TestJSSE
+ * @run main/othervm -DSERVER_PROTOCOL=SSLv2Hello,SSLv3,TLSv1,TLSv1.1,TLSv1.2
+ *        -DCLIENT_PROTOCOL=DEFAULT -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 TestJSSE
+ * @run main/othervm -DSERVER_PROTOCOL=SSLv2Hello,SSLv3,TLSv1,TLSv1.1,TLSv1.2
+ *        -DCLIENT_PROTOCOL=DEFAULT -Djdk.tls.client.protocols=TLSv1
+ *        -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 TestJSSE
+ * @run main/othervm -DSERVER_PROTOCOL=SSLv2Hello,SSLv3,TLSv1
+ *        -DCLIENT_PROTOCOL=DEFAULT -Djdk.tls.client.protocols=TLSv1.2
+ *        -DCIPHER=SSL_RSA_WITH_RC4_128_MD5
+ *        TestJSSE javax.net.ssl.SSLHandshakeException
+ *
+ */
+
+public class TestJSSE {
+
+    private static final String LOCAL_IP = "127.0.0.1";
+
+    public static void main(String... args) throws Exception {
+        // reset the security property to make sure that the algorithms
+        // and keys used in this test are not disabled.
+        Security.setProperty("jdk.tls.disabledAlgorithms", "");
+
+        String serverProtocol = System.getProperty("SERVER_PROTOCOL");
+        String clientProtocol = System.getProperty("CLIENT_PROTOCOL");
+        int port = jdk.testlibrary.Utils.getFreePort();
+        String cipher = System.getProperty("CIPHER");
+        if (serverProtocol == null
+                || clientProtocol == null
+                || cipher == null) {
+            throw new IllegalArgumentException("SERVER_PROTOCOL "
+                    + "or CLIENT_PROTOCOL or CIPHER is missing");
+        }
+        out.println("ServerProtocol =" + serverProtocol);
+        out.println("ClientProtocol =" + clientProtocol);
+        out.println("Cipher         =" + cipher);
+        server(serverProtocol, cipher, port, args);
+        client(port, clientProtocol, cipher, args);
+
+    }
+
+    public static void client(int testPort,
+            String testProtocols, String testCipher,
+            String... exception) throws Exception {
+        String expectedException = exception.length >= 1
+                ? exception[0] : null;
+        out.println("=========================================");
+        out.println(" Testing - https://" + LOCAL_IP + ":" + testPort);
+        out.println(" Testing - Protocol : " + testProtocols);
+        out.println(" Testing - Cipher : " + testCipher);
+        Provider p = new sun.security.ec.SunEC();
+        Security.insertProviderAt(p, 1);
+        try {
+            CipherTestUtils.main(new JSSEFactory(LOCAL_IP,
+                    testPort, testProtocols,
+                    testCipher, "client JSSE"),
+                    "client", expectedException);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public static void server(String testProtocol, String testCipher,
+            int testPort,
+            String... exception) throws Exception {
+        String expectedException = exception.length >= 1
+                ? exception[0] : null;
+        out.println(" This is Server");
+        out.println(" Testing Protocol: " + testProtocol);
+        out.println(" Testing Cipher: " + testCipher);
+        out.println(" Testing Port: " + testPort);
+        Provider p = new sun.security.ec.SunEC();
+        Security.insertProviderAt(p, 1);
+        try {
+            CipherTestUtils.main(new JSSEFactory(null, testPort,
+                    testProtocol, testCipher, "Server JSSE"),
+                    "Server", expectedException);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    private static class JSSEFactory extends CipherTestUtils.PeerFactory {
+
+        final String testedCipherSuite, testedProtocol, testHost;
+        final int testPort;
+        final String name;
+
+        JSSEFactory(String testHost, int testPort, String testedProtocol,
+                String testedCipherSuite, String name) {
+            this.testedCipherSuite = testedCipherSuite;
+            this.testedProtocol = testedProtocol;
+            this.testHost = testHost;
+            this.testPort = testPort;
+            this.name = name;
+        }
+
+        @Override
+        String getName() {
+            return name;
+        }
+
+        @Override
+        String getTestedCipher() {
+            return testedCipherSuite;
+        }
+
+        @Override
+        String getTestedProtocol() {
+            return testedProtocol;
+        }
+
+        @Override
+        CipherTestUtils.Client newClient(CipherTestUtils cipherTest)
+                throws Exception {
+            return new JSSEClient(cipherTest, testHost, testPort,
+                    testedProtocol, testedCipherSuite);
+        }
+
+        @Override
+        CipherTestUtils.Server newServer(CipherTestUtils cipherTest)
+                throws Exception {
+            return new JSSEServer(cipherTest, testPort,
+                    testedProtocol, testedCipherSuite);
+        }
+    }
+}
diff --git a/jdk/test/javax/net/ssl/TLSv12/SignatureAlgorithms.java b/jdk/test/javax/net/ssl/TLSv12/SignatureAlgorithms.java
new file mode 100644
index 0000000..cf5ba47
--- /dev/null
+++ b/jdk/test/javax/net/ssl/TLSv12/SignatureAlgorithms.java
@@ -0,0 +1,595 @@
+/*
+ * 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.  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.
+ */
+
+//
+// SunJSSE does not support dynamic system properties, no way to re-use
+// system properties in samevm/agentvm mode.
+//
+
+/*
+ * @test
+ * @bug 8049321
+ * @summary Support SHA256WithDSA in JSSE
+ * @modules java.base/sun.misc
+ * @run main/othervm SignatureAlgorithms PKIX "SHA-224,SHA-256"
+ *                   TLS_DHE_DSS_WITH_AES_128_CBC_SHA
+ * @run main/othervm SignatureAlgorithms PKIX "SHA-1,SHA-224"
+ *                   TLS_DHE_DSS_WITH_AES_128_CBC_SHA
+ * @run main/othervm SignatureAlgorithms PKIX "SHA-1,SHA-256"
+ *                   TLS_DHE_DSS_WITH_AES_128_CBC_SHA
+ * @run main/othervm SignatureAlgorithms PKIX "SHA-224,SHA-256"
+ *                   TLS_DHE_DSS_WITH_AES_128_CBC_SHA256
+ * @run main/othervm SignatureAlgorithms PKIX "SHA-1,SHA-224"
+ *                   TLS_DHE_DSS_WITH_AES_128_CBC_SHA256
+ * @run main/othervm SignatureAlgorithms PKIX "SHA-1,SHA-256"
+ *                   TLS_DHE_DSS_WITH_AES_128_CBC_SHA256
+ */
+
+import java.net.*;
+import java.util.*;
+import java.io.*;
+import javax.net.ssl.*;
+import java.security.Security;
+import java.security.KeyStore;
+import java.security.KeyFactory;
+import java.security.cert.Certificate;
+import java.security.cert.X509Certificate;
+import java.security.cert.CertificateFactory;
+import java.security.spec.*;
+import java.security.interfaces.*;
+import sun.misc.BASE64Decoder;
+
+
+public class SignatureAlgorithms {
+
+    /*
+     * =============================================================
+     * Set the various variables needed for the tests, then
+     * specify what tests to run on each side.
+     */
+
+    /*
+     * Should we run the client or server in a separate thread?
+     * Both sides can throw exceptions, but do you have a preference
+     * as to which side should be the main thread.
+     */
+    static boolean separateServerThread = true;
+
+    /*
+     * Where do we find the keystores?
+     */
+    // Certificates and key (DSA) used in the test.
+    static String trustedCertStr =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIDYTCCAyGgAwIBAgIJAK8/gw6zg/DPMAkGByqGSM44BAMwOzELMAkGA1UEBhMC\n" +
+        "VVMxDTALBgNVBAoTBEphdmExHTAbBgNVBAsTFFN1bkpTU0UgVGVzdCBTZXJpdmNl\n" +
+        "MB4XDTE1MTIwMzEzNTIyNVoXDTM2MTExMjEzNTIyNVowOzELMAkGA1UEBhMCVVMx\n" +
+        "DTALBgNVBAoTBEphdmExHTAbBgNVBAsTFFN1bkpTU0UgVGVzdCBTZXJpdmNlMIIB\n" +
+        "uDCCASwGByqGSM44BAEwggEfAoGBAPH+b+GSMX6KS7jXDRevzc464DFG4X+uxu5V\n" +
+        "b3U4yhsU8A8cuH4gwin6L/IDkmZQ7N0zC0jRsiGVSMsFETTq10F39pH2eBfUv/hJ\n" +
+        "cLfBnIjBEtVqV/dExK88Hul2sZ4mQihQ4issPl7hsroS9EWYicnX0oNAqAB9PO5Y\n" +
+        "zKbfpL7TAhUA13WW48rln2UP/LaAgtnzKhqcNtMCgYEA3Rv0GirTbAaor8iURd82\n" +
+        "b5FlDTevOCTuq7ZIpfZVV30neS7cBYNet6m/3/4cfUlbbrqhbqIJ2I+I81drnN0Y\n" +
+        "lyN4KkuxEcB6OTwfWkIUj6rvPaCQrBH8Q213bDq3HHtYNaP8OoeQUyVXW+SEGADC\n" +
+        "J1+z8uqP3lIB6ltdgOiV/GQDgYUAAoGBAOXRppuJSGdt6AiZkb81P1DCUgIUlZFI\n" +
+        "J9GxWrjbbHDmGllMwPNhK6dU7LJKJJuYVPW+95rUGlSJEjRqSlHuyHkNb6e3e7qx\n" +
+        "tmx1/oIyq+oLult50hBS7uBvLLR0JbIKjBzzkudL8Rjze4G/Wq7KDM2T1JOP49tW\n" +
+        "eocCvaC8h8uQo4GtMIGqMB0GA1UdDgQWBBT17HcqLllsqnZzP+kElcGcBGmubjBr\n" +
+        "BgNVHSMEZDBigBT17HcqLllsqnZzP+kElcGcBGmubqE/pD0wOzELMAkGA1UEBhMC\n" +
+        "VVMxDTALBgNVBAoTBEphdmExHTAbBgNVBAsTFFN1bkpTU0UgVGVzdCBTZXJpdmNl\n" +
+        "ggkArz+DDrOD8M8wDwYDVR0TAQH/BAUwAwEB/zALBgNVHQ8EBAMCAQYwCQYHKoZI\n" +
+        "zjgEAwMvADAsAhQ6Y1I6LtIEBMqNo8o6GIe4LLEJuwIUbVQUKi8tvtWyRoxm8AFV\n" +
+        "0axJYUU=\n" +
+        "-----END CERTIFICATE-----";
+
+    static String[] targetCertStr = {
+        // DSA-SHA1
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIDKTCCAumgAwIBAgIJAOy5c0b+8stFMAkGByqGSM44BAMwOzELMAkGA1UEBhMC\n" +
+        "VVMxDTALBgNVBAoTBEphdmExHTAbBgNVBAsTFFN1bkpTU0UgVGVzdCBTZXJpdmNl\n" +
+        "MB4XDTE1MTIwMzEzNTIyNVoXDTM1MDgyMDEzNTIyNVowTzELMAkGA1UEBhMCVVMx\n" +
+        "DTALBgNVBAoMBEphdmExHTAbBgNVBAsMFFN1bkpTU0UgVGVzdCBTZXJpdmNlMRIw\n" +
+        "EAYDVQQDDAlsb2NhbGhvc3QwggG3MIIBLAYHKoZIzjgEATCCAR8CgYEA8f5v4ZIx\n" +
+        "fopLuNcNF6/NzjrgMUbhf67G7lVvdTjKGxTwDxy4fiDCKfov8gOSZlDs3TMLSNGy\n" +
+        "IZVIywURNOrXQXf2kfZ4F9S/+Elwt8GciMES1WpX90TErzwe6XaxniZCKFDiKyw+\n" +
+        "XuGyuhL0RZiJydfSg0CoAH087ljMpt+kvtMCFQDXdZbjyuWfZQ/8toCC2fMqGpw2\n" +
+        "0wKBgQDdG/QaKtNsBqivyJRF3zZvkWUNN684JO6rtkil9lVXfSd5LtwFg163qb/f\n" +
+        "/hx9SVtuuqFuognYj4jzV2uc3RiXI3gqS7ERwHo5PB9aQhSPqu89oJCsEfxDbXds\n" +
+        "Orcce1g1o/w6h5BTJVdb5IQYAMInX7Py6o/eUgHqW12A6JX8ZAOBhAACgYB+zYqn\n" +
+        "jJwG4GZpBIN/6qhzbp0flChsV+Trlu0SL0agAQzb6XdI/4JnO87Pgbxaxh3VNAj3\n" +
+        "3+Ghr1NLBuBfTKzJ4j9msWT3EpLupkMyNtXvBYM0iyMrll67lSjMdv++wLEw35Af\n" +
+        "/bzVcjGyA5Q0i0cuEzDmHTVfi0OydynbwSLxtKNjMGEwCwYDVR0PBAQDAgPoMB0G\n" +
+        "A1UdDgQWBBQXJI8AxM0qsYCbbkIMuI5zJ+nMEDAfBgNVHSMEGDAWgBT17HcqLlls\n" +
+        "qnZzP+kElcGcBGmubjASBgNVHREBAf8ECDAGhwR/AAABMAkGByqGSM44BAMDLwAw\n" +
+        "LAIUXgyJ0xll4FrZAKXi8bj7Kiz+SA4CFH9WCSZIBYA9lmJkiTgRS7iM/6IC\n" +
+        "-----END CERTIFICATE-----",
+
+        // DSA-SHA224
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIDLzCCAuugAwIBAgIJAOy5c0b+8stGMAsGCWCGSAFlAwQDATA7MQswCQYDVQQG\n" +
+        "EwJVUzENMAsGA1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2\n" +
+        "Y2UwHhcNMTUxMjAzMTU0NDM5WhcNMzUwODIwMTU0NDM5WjBPMQswCQYDVQQGEwJV\n" +
+        "UzENMAsGA1UECgwESmF2YTEdMBsGA1UECwwUU3VuSlNTRSBUZXN0IFNlcml2Y2Ux\n" +
+        "EjAQBgNVBAMMCWxvY2FsaG9zdDCCAbcwggEsBgcqhkjOOAQBMIIBHwKBgQDx/m/h\n" +
+        "kjF+iku41w0Xr83OOuAxRuF/rsbuVW91OMobFPAPHLh+IMIp+i/yA5JmUOzdMwtI\n" +
+        "0bIhlUjLBRE06tdBd/aR9ngX1L/4SXC3wZyIwRLValf3RMSvPB7pdrGeJkIoUOIr\n" +
+        "LD5e4bK6EvRFmInJ19KDQKgAfTzuWMym36S+0wIVANd1luPK5Z9lD/y2gILZ8yoa\n" +
+        "nDbTAoGBAN0b9Boq02wGqK/IlEXfNm+RZQ03rzgk7qu2SKX2VVd9J3ku3AWDXrep\n" +
+        "v9/+HH1JW266oW6iCdiPiPNXa5zdGJcjeCpLsRHAejk8H1pCFI+q7z2gkKwR/ENt\n" +
+        "d2w6txx7WDWj/DqHkFMlV1vkhBgAwidfs/Lqj95SAepbXYDolfxkA4GEAAKBgA81\n" +
+        "CJKEv+pwiqYgxtw/9rkQ9748WP3mKrEC06kjUG+94/Z9dQloNFFfj6LiO1bymc5l\n" +
+        "6QIR8XCi4Po3N80K3+WxhBGFhY+RkVWTh43JV8epb41aH2qiWErarBwBGEh8LyGT\n" +
+        "i30db+Nkz2gfvyz9H/9T0jmYgfLEOlMCusali1qHo2MwYTALBgNVHQ8EBAMCA+gw\n" +
+        "HQYDVR0OBBYEFBqSP0S4+X+zOCTEnlp2hbAjV/W5MB8GA1UdIwQYMBaAFPXsdyou\n" +
+        "WWyqdnM/6QSVwZwEaa5uMBIGA1UdEQEB/wQIMAaHBH8AAAEwCwYJYIZIAWUDBAMB\n" +
+        "AzEAMC4CFQChiRaOnAnsCSJFwdpK22jSxU/mhQIVALgLbj/G39+1Ej8UuSWnEQyU\n" +
+        "4DA+\n" +
+        "-----END CERTIFICATE-----",
+
+        // DSA-SHA256
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIDLTCCAuugAwIBAgIJAOy5c0b+8stHMAsGCWCGSAFlAwQDAjA7MQswCQYDVQQG\n" +
+        "EwJVUzENMAsGA1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2\n" +
+        "Y2UwHhcNMTUxMjAzMTU0NjUxWhcNMzUwODIwMTU0NjUxWjBPMQswCQYDVQQGEwJV\n" +
+        "UzENMAsGA1UECgwESmF2YTEdMBsGA1UECwwUU3VuSlNTRSBUZXN0IFNlcml2Y2Ux\n" +
+        "EjAQBgNVBAMMCWxvY2FsaG9zdDCCAbcwggEsBgcqhkjOOAQBMIIBHwKBgQDx/m/h\n" +
+        "kjF+iku41w0Xr83OOuAxRuF/rsbuVW91OMobFPAPHLh+IMIp+i/yA5JmUOzdMwtI\n" +
+        "0bIhlUjLBRE06tdBd/aR9ngX1L/4SXC3wZyIwRLValf3RMSvPB7pdrGeJkIoUOIr\n" +
+        "LD5e4bK6EvRFmInJ19KDQKgAfTzuWMym36S+0wIVANd1luPK5Z9lD/y2gILZ8yoa\n" +
+        "nDbTAoGBAN0b9Boq02wGqK/IlEXfNm+RZQ03rzgk7qu2SKX2VVd9J3ku3AWDXrep\n" +
+        "v9/+HH1JW266oW6iCdiPiPNXa5zdGJcjeCpLsRHAejk8H1pCFI+q7z2gkKwR/ENt\n" +
+        "d2w6txx7WDWj/DqHkFMlV1vkhBgAwidfs/Lqj95SAepbXYDolfxkA4GEAAKBgEF7\n" +
+        "2qiYxGrjX4KCOy0k5nK/RYlgLy4gYDChihQpiaa+fbA5JOBOxPWsh7rdtmJuDrEJ\n" +
+        "keacU223+DIhOKC49fa+EvhLNqo6U1oPn8n/yvBsvvnWkcynw5KfNzaLlaPmzugh\n" +
+        "v9xl/GhyZNAXc1QUcW3C+ceHVNrKnkfbTKZz5eRSo2MwYTALBgNVHQ8EBAMCA+gw\n" +
+        "HQYDVR0OBBYEFNMkPrt40oO9Dpy+bcbQdEvOlNlyMB8GA1UdIwQYMBaAFPXsdyou\n" +
+        "WWyqdnM/6QSVwZwEaa5uMBIGA1UdEQEB/wQIMAaHBH8AAAEwCwYJYIZIAWUDBAMC\n" +
+        "Ay8AMCwCFCvA2QiKSe/n+6GqSYQwgQ/zL5M9AhQfSiuWdMJKWpgPJKakvzhBUbMb\n" +
+        "vA==\n" +
+        "-----END CERTIFICATE-----"};
+
+    // Private key in the format of PKCS#8, key size is 1024 bits.
+    static String[] targetPrivateKey = {
+        // For cert DSA-SHA1
+        "MIIBSwIBADCCASwGByqGSM44BAEwggEfAoGBAPH+b+GSMX6KS7jXDRevzc464DFG\n" +
+        "4X+uxu5Vb3U4yhsU8A8cuH4gwin6L/IDkmZQ7N0zC0jRsiGVSMsFETTq10F39pH2\n" +
+        "eBfUv/hJcLfBnIjBEtVqV/dExK88Hul2sZ4mQihQ4issPl7hsroS9EWYicnX0oNA\n" +
+        "qAB9PO5YzKbfpL7TAhUA13WW48rln2UP/LaAgtnzKhqcNtMCgYEA3Rv0GirTbAao\n" +
+        "r8iURd82b5FlDTevOCTuq7ZIpfZVV30neS7cBYNet6m/3/4cfUlbbrqhbqIJ2I+I\n" +
+        "81drnN0YlyN4KkuxEcB6OTwfWkIUj6rvPaCQrBH8Q213bDq3HHtYNaP8OoeQUyVX\n" +
+        "W+SEGADCJ1+z8uqP3lIB6ltdgOiV/GQEFgIUOiB7J/lrFrNduQ8nDNTe8VspoAI=",
+
+        // For cert DSA-SHA224
+        "MIIBSwIBADCCASwGByqGSM44BAEwggEfAoGBAPH+b+GSMX6KS7jXDRevzc464DFG\n" +
+        "4X+uxu5Vb3U4yhsU8A8cuH4gwin6L/IDkmZQ7N0zC0jRsiGVSMsFETTq10F39pH2\n" +
+        "eBfUv/hJcLfBnIjBEtVqV/dExK88Hul2sZ4mQihQ4issPl7hsroS9EWYicnX0oNA\n" +
+        "qAB9PO5YzKbfpL7TAhUA13WW48rln2UP/LaAgtnzKhqcNtMCgYEA3Rv0GirTbAao\n" +
+        "r8iURd82b5FlDTevOCTuq7ZIpfZVV30neS7cBYNet6m/3/4cfUlbbrqhbqIJ2I+I\n" +
+        "81drnN0YlyN4KkuxEcB6OTwfWkIUj6rvPaCQrBH8Q213bDq3HHtYNaP8OoeQUyVX\n" +
+        "W+SEGADCJ1+z8uqP3lIB6ltdgOiV/GQEFgIUOj9F5mxWd9W1tiLSdsOAt8BUBzE=",
+
+        // For cert DSA-SHA256
+        "MIIBSwIBADCCASwGByqGSM44BAEwggEfAoGBAPH+b+GSMX6KS7jXDRevzc464DFG\n" +
+        "4X+uxu5Vb3U4yhsU8A8cuH4gwin6L/IDkmZQ7N0zC0jRsiGVSMsFETTq10F39pH2\n" +
+        "eBfUv/hJcLfBnIjBEtVqV/dExK88Hul2sZ4mQihQ4issPl7hsroS9EWYicnX0oNA\n" +
+        "qAB9PO5YzKbfpL7TAhUA13WW48rln2UP/LaAgtnzKhqcNtMCgYEA3Rv0GirTbAao\n" +
+        "r8iURd82b5FlDTevOCTuq7ZIpfZVV30neS7cBYNet6m/3/4cfUlbbrqhbqIJ2I+I\n" +
+        "81drnN0YlyN4KkuxEcB6OTwfWkIUj6rvPaCQrBH8Q213bDq3HHtYNaP8OoeQUyVX\n" +
+        "W+SEGADCJ1+z8uqP3lIB6ltdgOiV/GQEFgIUQ2WGgg+OO39Aujj0e4lM4pP4/9g="};
+
+
+    static char passphrase[] = "passphrase".toCharArray();
+
+    /*
+     * Turn on SSL debugging?
+     */
+    static boolean debug = false;
+
+    /*
+     * Is the server ready to serve?
+     */
+    volatile boolean serverReady = false;
+
+    /*
+     * Define the server side of the test.
+     *
+     * If the server prematurely exits, serverReady will be set to true
+     * to avoid infinite hangs.
+     */
+    void doServerSide() throws Exception {
+
+        SSLContext context = generateSSLContext(
+                null, targetCertStr, targetPrivateKey);
+        SSLServerSocketFactory sslssf = context.getServerSocketFactory();
+        try (SSLServerSocket sslServerSocket =
+                (SSLServerSocket)sslssf.createServerSocket(serverPort)) {
+
+            serverPort = sslServerSocket.getLocalPort();
+
+            /*
+             * Signal Client, we're ready for his connect.
+             */
+            serverReady = true;
+
+            try (SSLSocket sslSocket = (SSLSocket)sslServerSocket.accept()) {
+                sslSocket.setEnabledCipherSuites(
+                        sslSocket.getSupportedCipherSuites());
+                InputStream sslIS = sslSocket.getInputStream();
+                OutputStream sslOS = sslSocket.getOutputStream();
+
+                sslIS.read();
+                sslOS.write('A');
+                sslOS.flush();
+
+                dumpSignatureAlgorithms(sslSocket);
+            }
+        }
+    }
+
+    /*
+     * Define the client side of the test.
+     *
+     * If the server prematurely exits, serverReady will be set to true
+     * to avoid infinite hangs.
+     */
+    void doClientSide() throws Exception {
+
+        /*
+         * Wait for server to get started.
+         */
+        while (!serverReady) {
+            Thread.sleep(50);
+        }
+
+        SSLContext context = generateSSLContext(trustedCertStr, null, null);
+        SSLSocketFactory sslsf = context.getSocketFactory();
+
+        try (SSLSocket sslSocket =
+                (SSLSocket)sslsf.createSocket("localhost", serverPort)) {
+
+            // enable TLSv1.2 only
+            sslSocket.setEnabledProtocols(new String[] {"TLSv1.2"});
+
+            // enable a block cipher
+            sslSocket.setEnabledCipherSuites(new String[] {cipherSuite});
+
+            InputStream sslIS = sslSocket.getInputStream();
+            OutputStream sslOS = sslSocket.getOutputStream();
+
+            sslOS.write('B');
+            sslOS.flush();
+            sslIS.read();
+
+            dumpSignatureAlgorithms(sslSocket);
+        }
+    }
+
+    static void dumpSignatureAlgorithms(SSLSocket sslSocket) throws Exception {
+
+        boolean isClient = sslSocket.getUseClientMode();
+        String mode = "[" + (isClient ? "Client" : "Server") + "]";
+        ExtendedSSLSession session =
+                (ExtendedSSLSession)sslSocket.getSession();
+        String[] signAlgs = session.getLocalSupportedSignatureAlgorithms();
+        System.out.println(
+                mode + " local supported signature algorithms: " +
+                Arrays.asList(signAlgs));
+
+        if (!isClient) {
+            signAlgs = session.getPeerSupportedSignatureAlgorithms();
+            System.out.println(
+                mode + " peer supported signature algorithms: " +
+                Arrays.asList(signAlgs));
+        } else {
+            Certificate[] serverCerts = session.getPeerCertificates();
+
+            // server should always send the authentication cert.
+            String sigAlg = ((X509Certificate)serverCerts[0]).getSigAlgName();
+            System.out.println(
+                mode + " the signature algorithm of server certificate: " +
+                sigAlg);
+            if (sigAlg.contains("SHA1")) {
+                if (disabledAlgorithms.contains("SHA-1")) {
+                    throw new Exception(
+                            "Not the expected server certificate. " +
+                            "SHA-1 should be disabled");
+                }
+            } else if (sigAlg.contains("SHA224")) {
+                if (disabledAlgorithms.contains("SHA-224")) {
+                    throw new Exception(
+                            "Not the expected server certificate. " +
+                            "SHA-224 should be disabled");
+                }
+            } else {    // SHA-256
+                if (disabledAlgorithms.contains("SHA-256")) {
+                    throw new Exception(
+                            "Not the expected server certificate. " +
+                            "SHA-256 should be disabled");
+                }
+            }
+        }
+    }
+
+    /*
+     * =============================================================
+     * The remainder is just support stuff
+     */
+    private static String tmAlgorithm;          // trust manager
+    private static String disabledAlgorithms;   // disabled algorithms
+    private static String cipherSuite;          // cipher suite
+
+    private static void parseArguments(String[] args) {
+        tmAlgorithm = args[0];
+        disabledAlgorithms = args[1];
+        cipherSuite = args[2];
+    }
+
+    private static SSLContext generateSSLContext(String trustedCertStr,
+            String[] keyCertStrs, String[] keySpecStrs) throws Exception {
+
+        // generate certificate from cert string
+        CertificateFactory cf = CertificateFactory.getInstance("X.509");
+
+        // create a key store
+        KeyStore ks = KeyStore.getInstance("JKS");
+        ks.load(null, null);
+
+        // import the trused cert
+        Certificate trusedCert = null;
+        ByteArrayInputStream is = null;
+        if (trustedCertStr != null) {
+            is = new ByteArrayInputStream(trustedCertStr.getBytes());
+            trusedCert = cf.generateCertificate(is);
+            is.close();
+
+            ks.setCertificateEntry("DSA Signer", trusedCert);
+        }
+
+        if (keyCertStrs != null && keyCertStrs.length != 0) {
+            for (int i = 0; i < keyCertStrs.length; i++) {
+                String keyCertStr = keyCertStrs[i];
+                String keySpecStr = keySpecStrs[i];
+
+                // generate the private key.
+                PKCS8EncodedKeySpec priKeySpec = new PKCS8EncodedKeySpec(
+                                new BASE64Decoder().decodeBuffer(keySpecStr));
+                KeyFactory kf = KeyFactory.getInstance("DSA");
+                DSAPrivateKey priKey =
+                        (DSAPrivateKey)kf.generatePrivate(priKeySpec);
+
+                // generate certificate chain
+                is = new ByteArrayInputStream(keyCertStr.getBytes());
+                Certificate keyCert = cf.generateCertificate(is);
+                is.close();
+
+                Certificate[] chain = null;
+                if (trusedCert != null) {
+                    chain = new Certificate[2];
+                    chain[0] = keyCert;
+                    chain[1] = trusedCert;
+                } else {
+                    chain = new Certificate[1];
+                    chain[0] = keyCert;
+                }
+
+                // import the key entry.
+                ks.setKeyEntry("DSA Entry " + i, priKey, passphrase, chain);
+            }
+        }
+
+        // create SSL context
+        TrustManagerFactory tmf = TrustManagerFactory.getInstance(tmAlgorithm);
+        tmf.init(ks);
+
+        SSLContext ctx = SSLContext.getInstance("TLS");
+        if (keyCertStrs != null && keyCertStrs.length != 0) {
+            KeyManagerFactory kmf = KeyManagerFactory.getInstance("NewSunX509");
+            kmf.init(ks, passphrase);
+
+            ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
+            ks = null;
+        } else {
+            ctx.init(null, tmf.getTrustManagers(), null);
+        }
+
+        return ctx;
+    }
+
+
+    // use any free port by default
+    volatile int serverPort = 0;
+
+    volatile Exception serverException = null;
+    volatile Exception clientException = null;
+
+    public static void main(String[] args) throws Exception {
+        /*
+         * debug option
+         */
+        if (debug) {
+            System.setProperty("javax.net.debug", "all");
+        }
+
+        /*
+         * Get the customized arguments.
+         */
+        parseArguments(args);
+
+
+        /*
+         * Ignore testing on Windows if only SHA-224 is available.
+         */
+        if ((Security.getProvider("SunMSCAPI") != null) &&
+                (disabledAlgorithms.contains("SHA-1")) &&
+                (disabledAlgorithms.contains("SHA-256"))) {
+
+            System.out.println(
+                "Windows system does not support SHA-224 algorithms yet. " +
+                "Ignore the testing");
+
+            return;
+        }
+
+        /*
+         * Expose the target algorithms by diabling unexpected algorithms.
+         */
+        Security.setProperty(
+                "jdk.certpath.disabledAlgorithms", disabledAlgorithms);
+
+        /*
+         * Reset the security property to make sure that the algorithms
+         * and keys used in this test are not disabled by default.
+         */
+        Security.setProperty( "jdk.tls.disabledAlgorithms", "");
+
+        /*
+         * Start the tests.
+         */
+        new SignatureAlgorithms();
+    }
+
+    Thread clientThread = null;
+    Thread serverThread = null;
+
+    /*
+     * Primary constructor, used to drive remainder of the test.
+     *
+     * Fork off the other side, then do your work.
+     */
+    SignatureAlgorithms() throws Exception {
+        try {
+            if (separateServerThread) {
+                startServer(true);
+                startClient(false);
+            } else {
+                startClient(true);
+                startServer(false);
+            }
+        } catch (Exception e) {
+            // swallow for now.  Show later
+        }
+
+        /*
+         * Wait for other side to close down.
+         */
+        if (separateServerThread) {
+            serverThread.join();
+        } else {
+            clientThread.join();
+        }
+
+        /*
+         * When we get here, the test is pretty much over.
+         * Which side threw the error?
+         */
+        Exception local;
+        Exception remote;
+        String whichRemote;
+
+        if (separateServerThread) {
+            remote = serverException;
+            local = clientException;
+            whichRemote = "server";
+        } else {
+            remote = clientException;
+            local = serverException;
+            whichRemote = "client";
+        }
+
+        /*
+         * If both failed, return the curthread's exception, but also
+         * print the remote side Exception
+         */
+        if ((local != null) && (remote != null)) {
+            System.out.println(whichRemote + " also threw:");
+            remote.printStackTrace();
+            System.out.println();
+            throw local;
+        }
+
+        if (remote != null) {
+            throw remote;
+        }
+
+        if (local != null) {
+            throw local;
+        }
+    }
+
+    void startServer(boolean newThread) throws Exception {
+        if (newThread) {
+            serverThread = new Thread() {
+                public void run() {
+                    try {
+                        doServerSide();
+                    } catch (Exception e) {
+                        /*
+                         * Our server thread just died.
+                         *
+                         * Release the client, if not active already...
+                         */
+                        System.err.println("Server died..." + e);
+                        serverReady = true;
+                        serverException = e;
+                    }
+                }
+            };
+            serverThread.start();
+        } else {
+            try {
+                doServerSide();
+            } catch (Exception e) {
+                serverException = e;
+            } finally {
+                serverReady = true;
+            }
+        }
+    }
+
+    void startClient(boolean newThread) throws Exception {
+        if (newThread) {
+            clientThread = new Thread() {
+                public void run() {
+                    try {
+                        doClientSide();
+                    } catch (Exception e) {
+                        /*
+                         * Our client thread just died.
+                         */
+                        System.err.println("Client died..." + e);
+                        clientException = e;
+                    }
+                }
+            };
+            clientThread.start();
+        } else {
+            try {
+                doClientSide();
+            } catch (Exception e) {
+                clientException = e;
+            }
+        }
+    }
+}
diff --git a/jdk/test/javax/security/auth/Subject/doAs/NestedActions.java b/jdk/test/javax/security/auth/Subject/doAs/NestedActions.java
new file mode 100644
index 0000000..f02b2ff
--- /dev/null
+++ b/jdk/test/javax/security/auth/Subject/doAs/NestedActions.java
@@ -0,0 +1,539 @@
+/*
+ * 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
+ * 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.ProcessTools;
+
+import javax.security.auth.Subject;
+import javax.security.auth.x500.X500Principal;
+import java.io.*;
+import java.security.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+
+/**
+ * @test
+ * @bug 8048147
+ * @summary Check if proper AccessControlException is thrown
+ *          in case of nested Subject.doAs() invocations
+ *          when one of protection domains doesn't have permissions
+ *
+ * @library /lib/testlibrary
+ *
+ * @run main NestedActions jar NestedActionsACE.jar
+ *              NestedActionsACE.class Utils.class
+ * @run main NestedActions jar NestedActionsPAE.jar
+ *              NestedActionsPAE.class Utils.class
+ * @run main NestedActions jar NestedActionsOnePrincipal.jar
+ *              NestedActionsOnePrincipal.class Utils.class
+ * @run main NestedActions jar NestedActionsTwoPrincipals.jar
+ *              NestedActionsTwoPrincipals.class Utils.class
+ * @run main NestedActions jar WriteToFileAction.jar
+ *              WriteToFileAction.class
+ * @run main NestedActions jar WriteToFileNegativeAction.jar
+ *              WriteToFileNegativeAction.class
+ * @run main NestedActions jar WriteToFileExceptionAction.jar
+ *              WriteToFileExceptionAction.class
+ * @run main NestedActions jar ReadFromFileAction.jar
+ *              ReadFromFileAction.class
+ * @run main NestedActions jar ReadFromFileNegativeAction.jar
+ *              ReadFromFileNegativeAction.class
+ * @run main NestedActions jar ReadFromFileExceptionAction.jar
+ *              ReadFromFileExceptionAction.class
+ * @run main NestedActions jar ReadPropertyAction.jar
+ *              ReadPropertyAction.class
+ * @run main NestedActions jar ReadPropertyNegativeAction.jar
+ *              ReadPropertyNegativeAction.class
+ * @run main NestedActions jar ReadPropertyExceptionAction.jar
+ *              ReadPropertyExceptionAction.class ReadPropertyException.class
+ *
+ * @run main NestedActions NestedActionsACE policy.expect.ace
+ *              NestedActionsACE.jar WriteToFileNegativeAction.jar
+ *              ReadFromFileNegativeAction.jar ReadPropertyNegativeAction.jar
+ * @run main NestedActions NestedActionsPAE policy.expect.pae
+ *              NestedActionsPAE.jar WriteToFileExceptionAction.jar
+ *              ReadFromFileExceptionAction.jar ReadPropertyExceptionAction.jar
+ * @run main NestedActions NestedActionsOnePrincipal policy.one.principal
+ *              NestedActionsOnePrincipal.jar WriteToFileAction.jar
+ *              ReadFromFileAction.jar ReadPropertyAction.jar
+ * @run main NestedActions NestedActionsTwoPrincipals policy.two.principals
+ *              NestedActionsTwoPrincipals.jar WriteToFileAction.jar
+ *              ReadFromFileAction.jar ReadPropertyAction.jar
+ */
+public class NestedActions {
+
+    static final String file = "NestedActions.tmp";
+    static final String PS = System.getProperty("path.separator");
+    static final String FS = System.getProperty("file.separator");
+    static final String TEST_CLASSES = System.getProperty("test.classes");
+    static final String TEST_SOURCES = System.getProperty("test.src");
+    static final String JAVA_OPTS = System.getProperty("test.java.opts");
+    static final String JAVA = System.getProperty("java.home")
+            + FS + "bin" + FS + "java";
+
+    public static void main(String[] args) throws IOException {
+        if (args.length > 0) {
+            if ("jar".equals(args[0]) && args.length > 2) {
+                createJar(args[1],
+                    Arrays.copyOfRange(args, 2, args.length));
+            } else {
+                runJava(args);
+            }
+        } else {
+            throw new RuntimeException("Wrong parameters");
+        }
+    }
+
+    static void createJar(String dest, String... files) throws IOException {
+        System.out.println("Create " + dest + " with the following content:");
+        try (JarOutputStream jos = new JarOutputStream(
+                new FileOutputStream(dest), new Manifest())) {
+            for (String file : files) {
+                System.out.println("  " + file);
+                jos.putNextEntry(new JarEntry(file));
+                try (FileInputStream fis = new FileInputStream(
+                        TEST_CLASSES + FS + file)) {
+                    byte[] buffer = new byte[1024];
+                    int read;
+                    while ((read = fis.read(buffer, 0, buffer.length)) > 0) {
+                        jos.write(buffer, 0, read);
+                    }
+                }
+            }
+        }
+    }
+
+    static void runJava(String[] args) {
+        if (args == null || args.length < 3) {
+            throw new IllegalArgumentException("wrong parameters");
+        }
+
+        List<String> cmds = new ArrayList<>();
+        cmds.add(JAVA);
+        StringBuilder sb = new StringBuilder();
+        cmds.add("-classpath");
+        for (int i=2; i<args.length; i++) {
+            sb.append(args[i]).append(PS);
+        }
+        cmds.add(sb.toString());
+        if (JAVA_OPTS != null && !JAVA_OPTS.isEmpty()) {
+            Collections.addAll(cmds, JAVA_OPTS.trim().split("\\s+"));
+        }
+        cmds.add("-Djava.security.manager");
+        cmds.add("-Djava.security.policy=" + TEST_SOURCES + FS + args[1]);
+        cmds.add(args[0]);
+        try {
+            ProcessTools.executeCommand(cmds.toArray(new String[cmds.size()]))
+                    .shouldHaveExitValue(0);
+        } catch (Throwable e) {
+            throw new RuntimeException(e);
+        }
+    }
+}
+
+/**
+ * Test for nested Subject.doAs() invocation:
+ *
+ * WriteToFileAction (CN=Duke principal) ->
+ *      ReadFromFileAction (CN=Duke principal) ->
+ *          ReadPropertyAction (CN=Duke principal)
+ *
+ * The test expects AccessControllException.
+ */
+class NestedActionsACE {
+
+    public static void main(String args[]) {
+        Subject subject = new Subject();
+        subject.getPrincipals().add(new X500Principal("CN=Duke"));
+        WriteToFileNegativeAction writeToFile
+                = new WriteToFileNegativeAction(NestedActions.file);
+        Subject.doAs(subject, writeToFile);
+    }
+}
+
+/**
+ * Test for nested Subject.doAs() invocation:
+ *
+ * WriteToFileAction (CN=Duke principal) ->
+ *      ReadFromFileAction (CN=Duke principal) ->
+ *          ReadPropertyAction (CN=Duke principal)
+ *
+ * The test expects PrivilegedActionException
+ * that caused by AccessControlEception.
+ */
+class NestedActionsPAE {
+
+    public static void main(String args[]) {
+        Subject subject = new Subject();
+        subject.getPrincipals().add(new X500Principal("CN=Duke"));
+        try {
+            WriteToFileExceptionAction writeToFile =
+                    new WriteToFileExceptionAction(NestedActions.file);
+            Subject.doAs(subject, writeToFile);
+            throw new RuntimeException(
+                    "Test failed: no PrivilegedActionException thrown");
+        } catch (PrivilegedActionException pae) {
+            System.out.println(
+                    "PrivilegedActionException thrown as expected: "
+                    + pae);
+
+            // check if AccessControlException caused PrivilegedActionException
+            Throwable exception = pae.getException();
+            do {
+                if (!(exception instanceof PrivilegedActionException)) {
+                    break;
+                }
+                exception = ((PrivilegedActionException) exception).
+                        getException();
+            } while (true);
+
+            if (!(exception instanceof ReadPropertyException)) {
+                throw new RuntimeException(
+                        "Test failed: PrivilegedActionException "
+                        + "was not caused by ReadPropertyException");
+            }
+
+            exception = exception.getCause();
+            if (!(exception instanceof AccessControlException)) {
+                throw new RuntimeException(
+                        "Test failed: PrivilegedActionException "
+                        + "was not caused by ReadPropertyException");
+            }
+
+            System.out.println(
+                    "Test passed: PrivilegedActionException "
+                    + "was caused by AccessControlException");
+        }
+    }
+}
+
+/**
+ * Test for nested Subject.doAs() invocation:
+ *
+ * WriteToFileAction (CN=Duke principal) ->
+ *      ReadFromFileAction (CN=Duke principal) ->
+ *          ReadPropertyAction (CN=Duke principal)
+ */
+class NestedActionsOnePrincipal {
+
+    public static void main(String args[]) {
+        Subject subject = new Subject();
+        subject.getPrincipals().add(new X500Principal("CN=Duke"));
+        WriteToFileAction writeToFile =
+                new WriteToFileAction(NestedActions.file);
+        Subject.doAs(subject, writeToFile);
+    }
+}
+
+/**
+ * Test for nested Subject.doAs() invocation:
+ *
+ * WriteToFileAction (CN=Duke principal) ->
+ *      ReadFromFileAction (CN=Duke principal) ->
+ *          ReadPropertyAction (CN=Java principal)
+ */
+class NestedActionsTwoPrincipals {
+
+    public static void main(String args[]) {
+        Subject subject = new Subject();
+        subject.getPrincipals().add(new X500Principal("CN=Duke"));
+        Subject anotherSubject = new Subject();
+        anotherSubject.getPrincipals().add(new X500Principal("CN=Java"));
+        ReadFromFileAction readFromFile
+                = new ReadFromFileAction(NestedActions.file, anotherSubject);
+        WriteToFileAction writeToFile
+                = new WriteToFileAction(NestedActions.file, readFromFile);
+        Subject.doAs(subject, writeToFile);
+    }
+}
+
+/**
+ * Helper class.
+ */
+class Utils {
+
+    static void readFile(String filename) {
+        System.out.println("ReadFromFileAction: try to read " + filename);
+        AccessControlContext acc = AccessController.getContext();
+        Subject subject = Subject.getSubject(acc);
+        System.out.println("principals = " + subject.getPrincipals());
+        try (FileInputStream fis = new FileInputStream(filename)) {
+            // do nothing
+        } catch (IOException e) {
+            throw new RuntimeException("Unexpected IOException", e);
+        }
+    }
+
+    static void writeFile(String filename) {
+        System.out.println("WriteToFileAction: try to write to " + filename);
+        AccessControlContext acc = AccessController.getContext();
+        Subject subject = Subject.getSubject(acc);
+        System.out.println("principals = " + subject.getPrincipals());
+        try (BufferedOutputStream bos = new BufferedOutputStream(
+                new FileOutputStream(filename))) {
+            bos.write(0);
+            bos.flush();
+        } catch (IOException e) {
+            throw new RuntimeException("Unexpected IOException", e);
+        }
+    }
+
+}
+
+class WriteToFileAction implements PrivilegedAction {
+
+    private final String filename;
+    private final PrivilegedAction nextAction;
+
+    WriteToFileAction(String filename, PrivilegedAction nextAction) {
+        this.filename = filename;
+        this.nextAction = nextAction;
+    }
+
+    WriteToFileAction(String filename) {
+        this(filename, new ReadFromFileAction(filename));
+    }
+
+    @Override
+    public Object run() {
+        Utils.writeFile(filename);
+        AccessControlContext acc = AccessController.getContext();
+        Subject subject = Subject.getSubject(acc);
+        return Subject.doAs(subject, nextAction);
+    }
+
+}
+
+class ReadFromFileAction implements PrivilegedAction {
+
+    private final String filename;
+    private final Subject anotherSubject;
+
+    ReadFromFileAction(String filename) {
+        this(filename, null);
+    }
+
+    ReadFromFileAction(String filename, Subject anotherSubject) {
+        this.filename = filename;
+        this.anotherSubject = anotherSubject;
+    }
+
+    @Override
+    public Object run() {
+        Utils.readFile(filename);
+
+        AccessControlContext acc = AccessController.getContext();
+        Subject subject = Subject.getSubject(acc);
+        ReadPropertyAction readProperty = new ReadPropertyAction();
+        if (anotherSubject != null) {
+            return Subject.doAs(anotherSubject, readProperty);
+        } else {
+            return Subject.doAs(subject, readProperty);
+        }
+    }
+
+}
+
+class ReadPropertyAction implements PrivilegedAction {
+
+    @Override
+    public java.lang.Object run() {
+        System.out.println("ReadPropertyAction: "
+                + "try to read 'java.class.path' property");
+
+        AccessControlContext acc = AccessController.getContext();
+        Subject s = Subject.getSubject(acc);
+        System.out.println("principals = " + s.getPrincipals());
+        System.out.println("java.class.path = "
+                + System.getProperty("java.class.path"));
+
+        return null;
+    }
+
+}
+
+class WriteToFileNegativeAction implements PrivilegedAction {
+
+    private final String filename;
+
+    public WriteToFileNegativeAction(String filename) {
+        this.filename = filename;
+    }
+
+    @Override
+    public Object run() {
+        AccessControlContext acc = AccessController.getContext();
+        Subject subject = Subject.getSubject(acc);
+        System.out.println("principals = " + subject.getPrincipals());
+
+        try {
+            Utils.writeFile(filename);
+            new File(filename).delete();
+            throw new RuntimeException(
+                    "Test failed: no AccessControlException thrown");
+        } catch (AccessControlException ace) {
+            System.out.println(
+                    "AccessControlException thrown as expected: "
+                    + ace.getMessage());
+        }
+
+        ReadFromFileNegativeAction readFromFile
+                = new ReadFromFileNegativeAction(filename);
+        return Subject.doAs(subject, readFromFile);
+    }
+
+}
+
+class ReadFromFileNegativeAction implements PrivilegedAction {
+
+    private final String filename;
+
+    public ReadFromFileNegativeAction(String filename) {
+        this.filename = filename;
+    }
+
+    @Override
+    public Object run() {
+        AccessControlContext acc = AccessController.getContext();
+        Subject subject = Subject.getSubject(acc);
+        System.out.println("principals = " + subject.getPrincipals());
+
+        try {
+            Utils.readFile(filename);
+            throw new RuntimeException(
+                    "Test failed: no AccessControlException thrown");
+        } catch (AccessControlException ace) {
+            System.out.println(
+                    "AccessControlException thrown as expected: "
+                    + ace.getMessage());
+        }
+
+        ReadPropertyNegativeAction readProperty =
+                new ReadPropertyNegativeAction();
+        return Subject.doAs(subject, readProperty);
+    }
+
+}
+
+class ReadPropertyNegativeAction implements PrivilegedAction {
+
+    @Override
+    public java.lang.Object run() {
+        System.out.println("Try to read 'java.class.path' property");
+
+        AccessControlContext acc = AccessController.getContext();
+        Subject s = Subject.getSubject(acc);
+        System.out.println("principals = " + s.getPrincipals());
+
+        try {
+            System.out.println("java.class.path = "
+                    + System.getProperty("java.class.path"));
+            throw new RuntimeException(
+                    "Test failed: no AccessControlException thrown");
+        } catch (AccessControlException ace) {
+            System.out.println(
+                    "AccessControlException thrown as expected: "
+                    + ace.getMessage());
+        }
+
+        return null;
+    }
+
+}
+
+class WriteToFileExceptionAction implements PrivilegedExceptionAction {
+
+    private final String filename;
+
+    WriteToFileExceptionAction(String filename) {
+        this.filename = filename;
+    }
+
+    @Override
+    public Object run() throws Exception {
+        Utils.writeFile(filename);
+        AccessControlContext acc = AccessController.getContext();
+        Subject subject = Subject.getSubject(acc);
+        ReadFromFileExceptionAction readFromFile =
+                new ReadFromFileExceptionAction(filename);
+        return Subject.doAs(subject, readFromFile);
+    }
+
+}
+
+class ReadFromFileExceptionAction implements PrivilegedExceptionAction {
+
+    private final String filename;
+
+    ReadFromFileExceptionAction(String filename) {
+        this.filename = filename;
+    }
+
+    @Override
+    public Object run() throws Exception {
+        Utils.readFile(filename);
+        AccessControlContext acc = AccessController.getContext();
+        Subject subject = Subject.getSubject(acc);
+        ReadPropertyExceptionAction readProperty =
+                new ReadPropertyExceptionAction();
+        return Subject.doAs(subject, readProperty);
+    }
+
+}
+
+class ReadPropertyExceptionAction implements PrivilegedExceptionAction {
+
+    @Override
+    public java.lang.Object run() throws Exception {
+        System.out.println("Try to read 'java.class.path' property");
+
+        AccessControlContext acc = AccessController.getContext();
+        Subject s = Subject.getSubject(acc);
+        System.out.println("principals = " + s.getPrincipals());
+
+        try {
+            System.out.println("java.class.path = "
+                    + System.getProperty("java.class.path"));
+            throw new RuntimeException(
+                    "Test failed: no AccessControlException thrown");
+        } catch (AccessControlException ace) {
+            System.out.println(
+                    "AccessControlException thrown as expected: "
+                    + ace.getMessage());
+            throw new ReadPropertyException(ace);
+        }
+    }
+
+}
+
+class ReadPropertyException extends Exception {
+
+    ReadPropertyException(Throwable cause) {
+        super(cause);
+    }
+}
diff --git a/jdk/test/javax/security/auth/Subject/doAs/policy.expect.ace b/jdk/test/javax/security/auth/Subject/doAs/policy.expect.ace
new file mode 100644
index 0000000..ac33619
--- /dev/null
+++ b/jdk/test/javax/security/auth/Subject/doAs/policy.expect.ace
@@ -0,0 +1,27 @@
+// this code has limited permissions that should cause ACE
+grant codeBase "file:NestedActionsACE.jar" {
+    permission javax.security.auth.AuthPermission "getSubject";
+    permission javax.security.auth.AuthPermission "modifyPrincipals";
+    permission javax.security.auth.AuthPermission "doAs";
+    permission java.util.PropertyPermission "path.separator", "read";
+    permission java.util.PropertyPermission "file.separator", "read";
+    permission java.util.PropertyPermission "test.classes", "read";
+    permission java.util.PropertyPermission "test.src", "read";
+    permission java.util.PropertyPermission "test.java.opts", "read";
+    permission java.util.PropertyPermission "java.home", "read";
+};
+
+grant codeBase "file:WriteToFileNegativeAction.jar"
+        Principal javax.security.auth.x500.X500Principal "cn=Duke" {
+    permission java.security.AllPermission;
+};
+
+grant codeBase "file:ReadFromFileNegativeAction.jar"
+        Principal javax.security.auth.x500.X500Principal "cn=Duke" {
+    permission java.security.AllPermission;
+};
+
+grant codeBase "file:ReadPropertyNegativeAction.jar"
+        Principal javax.security.auth.x500.X500Principal "cn=Duke" {
+    permission java.security.AllPermission;
+};
\ No newline at end of file
diff --git a/jdk/test/javax/security/auth/Subject/doAs/policy.expect.pae b/jdk/test/javax/security/auth/Subject/doAs/policy.expect.pae
new file mode 100644
index 0000000..c37cd7e
--- /dev/null
+++ b/jdk/test/javax/security/auth/Subject/doAs/policy.expect.pae
@@ -0,0 +1,19 @@
+grant codeBase "file:NestedActionsPAE.jar" {
+    permission java.security.AllPermission;
+};
+
+grant codeBase "file:WriteToFileExceptionAction.jar"
+        Principal javax.security.auth.x500.X500Principal "cn=Duke" {
+    permission java.security.AllPermission;
+};
+
+grant codeBase "file:ReadFromFileExceptionAction.jar"
+        Principal javax.security.auth.x500.X500Principal "cn=Duke" {
+    permission java.security.AllPermission;
+};
+
+// this code has limited permissions that should cause ACE
+grant codeBase "file:ReadPropertyExceptionAction.jar"
+        Principal javax.security.auth.x500.X500Principal "cn=Duke" {
+    permission javax.security.auth.AuthPermission "getSubject";
+};
diff --git a/jdk/test/javax/security/auth/Subject/doAs/policy.one.principal b/jdk/test/javax/security/auth/Subject/doAs/policy.one.principal
new file mode 100644
index 0000000..1f560ed
--- /dev/null
+++ b/jdk/test/javax/security/auth/Subject/doAs/policy.one.principal
@@ -0,0 +1,36 @@
+grant codeBase "file:NestedActionsOnePrincipal.jar" {
+    permission javax.security.auth.AuthPermission "getSubject";
+    permission javax.security.auth.AuthPermission "modifyPrincipals";
+    permission javax.security.auth.AuthPermission "doAs";
+    permission java.util.PropertyPermission "path.separator", "read";
+    permission java.util.PropertyPermission "file.separator", "read";
+    permission java.util.PropertyPermission "test.classes", "read";
+    permission java.util.PropertyPermission "test.src", "read";
+    permission java.util.PropertyPermission "test.java.opts", "read";
+    permission java.util.PropertyPermission "java.home", "read";
+    permission java.util.PropertyPermission "java.class.path", "read";
+    permission java.io.FilePermission "NestedActions.tmp", "read,write";
+};
+
+grant codeBase "file:WriteToFileAction.jar"
+        Principal javax.security.auth.x500.X500Principal "cn=Duke" {
+    permission javax.security.auth.AuthPermission "getSubject";
+    permission javax.security.auth.AuthPermission "doAs";
+    permission java.util.PropertyPermission "java.class.path", "read";
+    permission java.io.FilePermission "NestedActions.tmp", "read,write";
+};
+
+grant codeBase "file:ReadFromFileAction.jar"
+        Principal javax.security.auth.x500.X500Principal "cn=Duke" {
+    permission javax.security.auth.AuthPermission "getSubject";
+    permission javax.security.auth.AuthPermission "doAs";
+    permission java.util.PropertyPermission "java.class.path", "read";
+    permission java.io.FilePermission "NestedActions.tmp", "read";
+};
+
+grant codeBase "file:ReadPropertyAction.jar"
+        Principal javax.security.auth.x500.X500Principal "cn=Duke" {
+    permission javax.security.auth.AuthPermission "getSubject";
+    permission javax.security.auth.AuthPermission "doAs";
+    permission java.util.PropertyPermission "java.class.path", "read";
+};
\ No newline at end of file
diff --git a/jdk/test/javax/security/auth/Subject/doAs/policy.two.principals b/jdk/test/javax/security/auth/Subject/doAs/policy.two.principals
new file mode 100644
index 0000000..c260781
--- /dev/null
+++ b/jdk/test/javax/security/auth/Subject/doAs/policy.two.principals
@@ -0,0 +1,37 @@
+grant codeBase "file:NestedActionsTwoPrincipals.jar" {
+    permission javax.security.auth.AuthPermission "getSubject";
+    permission javax.security.auth.AuthPermission "modifyPrincipals";
+    permission javax.security.auth.AuthPermission "doAs";
+    permission java.util.PropertyPermission "path.separator", "read";
+    permission java.util.PropertyPermission "file.separator", "read";
+    permission java.util.PropertyPermission "test.classes", "read";
+    permission java.util.PropertyPermission "test.src", "read";
+    permission java.util.PropertyPermission "test.java.opts", "read";
+    permission java.util.PropertyPermission "java.home", "read";
+    permission java.util.PropertyPermission "java.class.path", "read";
+    permission java.io.FilePermission "NestedActions.tmp", "read,write,delete";
+};
+
+grant codeBase "file:WriteToFileAction.jar"
+        Principal javax.security.auth.x500.X500Principal "cn=Duke" {
+    permission javax.security.auth.AuthPermission "getSubject";
+    permission javax.security.auth.AuthPermission "doAs";
+    permission javax.security.auth.AuthPermission "modifyPrincipals";
+    permission java.util.PropertyPermission "java.class.path", "read";
+    permission java.io.FilePermission "NestedActions.tmp", "read,write";
+};
+
+grant codeBase "file:ReadFromFileAction.jar"
+        Principal javax.security.auth.x500.X500Principal "cn=Duke"{
+    permission javax.security.auth.AuthPermission "getSubject";
+    permission javax.security.auth.AuthPermission "doAs";
+    permission java.util.PropertyPermission "java.class.path", "read";
+    permission java.io.FilePermission "NestedActions.tmp", "read";
+};
+
+grant codeBase "file:ReadPropertyAction.jar"
+        Principal javax.security.auth.x500.X500Principal "cn=Java" {
+    permission javax.security.auth.AuthPermission "getSubject";
+    permission javax.security.auth.AuthPermission "doAs";
+    permission java.util.PropertyPermission "java.class.path", "read";
+};
\ No newline at end of file
diff --git a/jdk/test/javax/security/auth/login/JAASConfigSyntaxCheck/JAASConfigSyntaxTest.java b/jdk/test/javax/security/auth/login/JAASConfigSyntaxCheck/JAASConfigSyntaxTest.java
new file mode 100644
index 0000000..1a649ea
--- /dev/null
+++ b/jdk/test/javax/security/auth/login/JAASConfigSyntaxCheck/JAASConfigSyntaxTest.java
@@ -0,0 +1,57 @@
+
+/**
+ * Copyright (c) 2007, 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.
+ */
+
+import javax.security.auth.login.LoginContext;
+
+/**
+ * @test
+ * @bug 8050461
+ * @summary Test should throw Configuration error if configuration file contains
+ * syntax error
+ * @build SampleLoginModule JAASConfigSyntaxTest
+ * @run main/othervm -Djava.security.auth.login.config=file:${test.src}/JAASSynWithOutApplication.config JAASConfigSyntaxTest
+ * @run main/othervm -Djava.security.auth.login.config=file:${test.src}/JAASSynWithOutBraces.config JAASConfigSyntaxTest
+ * @run main/othervm -Djava.security.auth.login.config=file:${test.src}/JAASSynWithOutFlag.config JAASConfigSyntaxTest
+ * @run main/othervm -Djava.security.auth.login.config=file:${test.src}/JAASSynWithOutLoginModule.config JAASConfigSyntaxTest
+ * @run main/othervm -Djava.security.auth.login.config=file:${test.src}/JAASSynWithOutSemiColen.config JAASConfigSyntaxTest
+ */
+public class JAASConfigSyntaxTest {
+
+    private static final String TEST_NAME = "JAASConfigSyntaxTest";
+
+    public static void main(String[] args) throws Exception {
+        try {
+            LoginContext lc = new LoginContext(TEST_NAME);
+            lc.login();
+            throw new RuntimeException("Test Case Failed, did not get "
+                    + "expected exception");
+        } catch (Exception ex) {
+            if (ex.getMessage().contains("java.io.IOException: "
+                    + "Configuration Error:")) {
+                System.out.println("Test case passed");
+            } else {
+                throw new RuntimeException(ex);
+            }
+        }
+    }
+}
diff --git a/jdk/test/javax/security/auth/login/JAASConfigSyntaxCheck/JAASSynWithOutApplication.config b/jdk/test/javax/security/auth/login/JAASConfigSyntaxCheck/JAASSynWithOutApplication.config
new file mode 100644
index 0000000..6a7219f
--- /dev/null
+++ b/jdk/test/javax/security/auth/login/JAASConfigSyntaxCheck/JAASSynWithOutApplication.config
@@ -0,0 +1,5 @@
+{
+SampleLoginModule Required;
+SampleLoginModule Required;
+SampleLoginModule Required;
+};
\ No newline at end of file
diff --git a/jdk/test/javax/security/auth/login/JAASConfigSyntaxCheck/JAASSynWithOutBraces.config b/jdk/test/javax/security/auth/login/JAASConfigSyntaxCheck/JAASSynWithOutBraces.config
new file mode 100644
index 0000000..75b6232
--- /dev/null
+++ b/jdk/test/javax/security/auth/login/JAASConfigSyntaxCheck/JAASSynWithOutBraces.config
@@ -0,0 +1,5 @@
+JAASConfigSyntaxTest
+SampleLoginModule Required;
+SampleLoginModule Required;
+SampleLoginModule Required;
+;
\ No newline at end of file
diff --git a/jdk/test/javax/security/auth/login/JAASConfigSyntaxCheck/JAASSynWithOutFlag.config b/jdk/test/javax/security/auth/login/JAASConfigSyntaxCheck/JAASSynWithOutFlag.config
new file mode 100644
index 0000000..a3d4b2b
--- /dev/null
+++ b/jdk/test/javax/security/auth/login/JAASConfigSyntaxCheck/JAASSynWithOutFlag.config
@@ -0,0 +1,5 @@
+JAASConfigSyntaxTest{
+SampleLoginModule ;
+SampleLoginModule ;
+SampleLoginModule ;
+};
\ No newline at end of file
diff --git a/jdk/test/javax/security/auth/login/JAASConfigSyntaxCheck/JAASSynWithOutLoginModule.config b/jdk/test/javax/security/auth/login/JAASConfigSyntaxCheck/JAASSynWithOutLoginModule.config
new file mode 100644
index 0000000..7315d02
--- /dev/null
+++ b/jdk/test/javax/security/auth/login/JAASConfigSyntaxCheck/JAASSynWithOutLoginModule.config
@@ -0,0 +1,5 @@
+JAASConfigSyntaxTest{
+;
+;
+;
+};
\ No newline at end of file
diff --git a/jdk/test/javax/security/auth/login/JAASConfigSyntaxCheck/JAASSynWithOutSemiColen.config b/jdk/test/javax/security/auth/login/JAASConfigSyntaxCheck/JAASSynWithOutSemiColen.config
new file mode 100644
index 0000000..4ccf602
--- /dev/null
+++ b/jdk/test/javax/security/auth/login/JAASConfigSyntaxCheck/JAASSynWithOutSemiColen.config
@@ -0,0 +1,5 @@
+JAASConfigSyntaxTest{
+SampleLoginModule Required;
+SampleLoginModule Required
+SampleLoginModule Required;
+};
\ No newline at end of file
diff --git a/jdk/test/javax/security/auth/login/JAASConfigSyntaxCheck/SampleLoginModule.java b/jdk/test/javax/security/auth/login/JAASConfigSyntaxCheck/SampleLoginModule.java
new file mode 100644
index 0000000..7df77b0
--- /dev/null
+++ b/jdk/test/javax/security/auth/login/JAASConfigSyntaxCheck/SampleLoginModule.java
@@ -0,0 +1,75 @@
+/**
+ * Copyright (c) 2007, 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.
+ */
+
+import static java.lang.System.out;
+import java.util.Map;
+import javax.security.auth.Subject;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.login.LoginException;
+import javax.security.auth.spi.LoginModule;
+
+/**
+ * Login module which passes all the time
+ */
+
+public class SampleLoginModule implements LoginModule {
+
+    private final String name;
+
+    public SampleLoginModule() {
+        name = this.getClass().getName();
+    }
+
+    @Override
+    public void initialize(Subject subject, CallbackHandler callbackHandler,
+            Map<String, ?> sharedState, Map<String, ?> options) {
+    }
+
+    @Override
+    public boolean login() throws LoginException {
+        out.println(name + " Login method of AbstractLoginModule is called ");
+        out.println(name + ":login:PASS");
+        return true;
+    }
+
+    @Override
+    public boolean commit() throws LoginException {
+        out.println("Commit of AbstractLoginModule is called");
+        out.println(name + ":commit:PASS");
+        return true;
+
+    }
+
+    @Override
+    public boolean abort() throws LoginException {
+        out.println("Abourt is called in AbstractLoginModule");
+        out.println(name + ":abort:PASS");
+        return true;
+    }
+
+    @Override
+    public boolean logout() throws LoginException {
+        out.println("logout is called in AbstractLoginModule");
+        out.println(name + ":logout:PASS");
+        return true;
+    }
+}
diff --git a/jdk/test/javax/security/auth/login/LoginContext/CustomLoginModule.java b/jdk/test/javax/security/auth/login/LoginContext/CustomLoginModule.java
new file mode 100644
index 0000000..e47f3de
--- /dev/null
+++ b/jdk/test/javax/security/auth/login/LoginContext/CustomLoginModule.java
@@ -0,0 +1,275 @@
+/*
+ * 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.
+ */
+
+import java.io.IOException;
+import java.security.Principal;
+import java.util.Arrays;
+import java.util.Locale;
+import java.util.Map;
+import javax.security.auth.Subject;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.ChoiceCallback;
+import javax.security.auth.callback.ConfirmationCallback;
+import javax.security.auth.callback.LanguageCallback;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.TextInputCallback;
+import javax.security.auth.callback.TextOutputCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.login.FailedLoginException;
+import javax.security.auth.login.LoginException;
+import javax.security.auth.spi.LoginModule;
+
+public class CustomLoginModule implements LoginModule {
+
+    static final String HELLO = "Hello";
+
+    private Subject subject;
+    private CallbackHandler callbackHandler;
+    private boolean loginSucceeded = false;
+    private String username;
+    private char[] password;
+
+    /*
+     * Initialize this LoginModule.
+     */
+    @Override
+    public void initialize(Subject subject, CallbackHandler callbackHandler,
+            Map<String, ?> sharedState, Map<String, ?> options) {
+        this.subject = subject;
+        this.callbackHandler = callbackHandler;
+
+        // check if custom parameter is passed from comfiguration
+        if (options == null) {
+            throw new RuntimeException("options is null");
+        }
+
+        // read username/password from configuration
+        Object o = options.get("username");
+        if (o == null) {
+            throw new RuntimeException("Custom parameter not passed");
+        }
+        if (!(o instanceof String)) {
+            throw new RuntimeException("Password is not a string");
+        }
+        username = (String) o;
+
+        o = options.get("password");
+        if (o == null) {
+            throw new RuntimeException("Custom parameter not passed");
+        }
+        if (!(o instanceof String)) {
+            throw new RuntimeException("Password is not a string");
+        }
+        password = ((String) o).toCharArray();
+    }
+
+    /*
+     * Authenticate the user.
+     */
+    @Override
+    public boolean login() throws LoginException {
+        // prompt for a user name and password
+        if (callbackHandler == null) {
+            throw new LoginException("No CallbackHandler available");
+        }
+
+        // standard callbacks
+        NameCallback name = new NameCallback("username: ", "default");
+        PasswordCallback passwd = new PasswordCallback("password: ", false);
+
+        LanguageCallback language = new LanguageCallback();
+
+        TextOutputCallback error = new TextOutputCallback(
+                TextOutputCallback.ERROR, "This is an error");
+        TextOutputCallback warning = new TextOutputCallback(
+                TextOutputCallback.WARNING, "This is a warning");
+        TextOutputCallback info = new TextOutputCallback(
+                TextOutputCallback.INFORMATION, "This is a FYI");
+
+        TextInputCallback text = new TextInputCallback("Please type " + HELLO,
+                "Bye");
+
+        ChoiceCallback choice = new ChoiceCallback("Choice: ",
+                new String[] { "pass", "fail" }, 1, true);
+
+        ConfirmationCallback confirmation = new ConfirmationCallback(
+                "confirmation: ", ConfirmationCallback.INFORMATION,
+                ConfirmationCallback.YES_NO_OPTION, ConfirmationCallback.NO);
+
+        CustomCallback custom = new CustomCallback();
+
+        Callback[] callbacks = new Callback[] {
+            choice, info, warning, error, name, passwd, text, language,
+            confirmation, custom
+        };
+
+        boolean uce = false;
+        try {
+            callbackHandler.handle(callbacks);
+        } catch (UnsupportedCallbackException e) {
+            Callback callback = e.getCallback();
+            if (custom.equals(callback)) {
+                uce = true;
+                System.out.println("CustomLoginModule: "
+                        + "custom callback not supported as expected");
+            } else {
+                throw new LoginException("Unsupported callback: " + callback);
+            }
+        } catch (IOException ioe) {
+            throw new LoginException(ioe.toString());
+        }
+
+        if (!uce) {
+            throw new RuntimeException("UnsupportedCallbackException "
+                    + "not thrown");
+        }
+
+        if (!HELLO.equals(text.getText())) {
+            System.out.println("Text: " + text.getText());
+            throw new FailedLoginException("No hello");
+        }
+
+        if (!Locale.GERMANY.equals(language.getLocale())) {
+            System.out.println("Selected locale: " + language.getLocale());
+            throw new FailedLoginException("Achtung bitte");
+        }
+
+        String readUsername = name.getName();
+        char[] readPassword = passwd.getPassword();
+        if (readPassword == null) {
+            // treat a NULL password as an empty password
+            readPassword = new char[0];
+        }
+        passwd.clearPassword();
+
+        // verify the username/password
+        if (!username.equals(readUsername)
+                || !Arrays.equals(password, readPassword)) {
+            loginSucceeded = false;
+            throw new FailedLoginException("Username/password is not correct");
+        }
+
+        // check chosen option
+        int[] selected = choice.getSelectedIndexes();
+        if (selected == null || selected.length == 0) {
+            throw new FailedLoginException("Nothing selected");
+        }
+
+        if (selected[0] != 0) {
+            throw new FailedLoginException("Wrong choice: " + selected[0]);
+        }
+
+        // check confirmation
+        if (confirmation.getSelectedIndex() != ConfirmationCallback.YES) {
+            throw new FailedLoginException("Not confirmed: "
+                    + confirmation.getSelectedIndex());
+        }
+
+        loginSucceeded = true;
+        System.out.println("CustomLoginModule: authentication succeeded");
+        return true;
+    }
+
+    /*
+     * This method is called if the LoginContext's overall authentication
+     * succeeded.
+     */
+    @Override
+    public boolean commit() throws LoginException {
+        if (loginSucceeded) {
+            // add a Principal to the Subject
+            Principal principal = new TestPrincipal(username);
+            if (!subject.getPrincipals().contains(principal)) {
+                subject.getPrincipals().add(principal);
+            }
+            return true;
+        }
+
+        return false;
+    }
+
+    /*
+     * This method is called if the LoginContext's overall authentication
+     * failed.
+     */
+    @Override
+    public boolean abort() throws LoginException {
+        loginSucceeded = false;
+        return true;
+    }
+
+    /*
+     * Logout the user.
+     */
+    @Override
+    public boolean logout() throws LoginException {
+        loginSucceeded = false;
+        boolean removed = subject.getPrincipals().remove(
+                new TestPrincipal(username));
+        if (!removed) {
+            throw new LoginException("Coundn't remove a principal: "
+                    + username);
+        }
+        return true;
+    }
+
+    static class TestPrincipal implements Principal {
+
+        private final String name;
+
+        public TestPrincipal(String name) {
+            this.name = name;
+        }
+
+        @Override
+        public String getName() {
+            return name;
+        }
+
+        @Override
+        public String toString() {
+            return("TestPrincipal [name =" + name + "]");
+        }
+
+        @Override
+        public int hashCode() {
+            return name.hashCode();
+        }
+
+        @Override
+        public boolean equals(Object o) {
+            if (o == null) {
+                return false;
+            }
+            if (!(o instanceof TestPrincipal)) {
+                return false;
+            }
+            TestPrincipal other = (TestPrincipal) o;
+            return name != null ? name.equals(other.name) : other.name == null;
+        }
+    }
+
+    static class CustomCallback implements Callback {}
+}
diff --git a/jdk/test/javax/security/auth/login/LoginContext/DummyLoginModule.java b/jdk/test/javax/security/auth/login/LoginContext/DummyLoginModule.java
new file mode 100644
index 0000000..ae0334d
--- /dev/null
+++ b/jdk/test/javax/security/auth/login/LoginContext/DummyLoginModule.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2004, 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.
+ */
+
+import javax.security.auth.login.LoginException;
+
+/**
+ * Login module which passes all the time
+ */
+
+public class DummyLoginModule extends SmartLoginModule {
+    private final String header;
+
+    public DummyLoginModule() {
+        header = "DummyLoginModule: ";
+    }
+
+    @Override
+    public boolean login() throws LoginException {
+        System.out.println("\t\t" + header + " login method is called ");
+        System.out.println("\t\t" + header + " login:PASS");
+        return true;
+    }
+
+    @Override
+    public boolean commit() throws LoginException {
+        System.out.println("\t\t" + header + " commit method is called");
+        System.out.println("\t\t" + header + " commit:PASS");
+        return true;
+    }
+
+    @Override
+    public boolean abort() throws LoginException {
+        System.out.println("\t\t" + header + " abort method is called ");
+        System.out.println("\t\t" + header + " abort:PASS");
+
+        return true;
+    }
+
+    @Override
+    public boolean logout() throws LoginException {
+        System.out.println("\t\t" + header + " logout method is called");
+        System.out.println("\t\t" + header + " logout:PASS");
+        return true;
+    }
+
+}
diff --git a/jdk/test/javax/security/auth/login/LoginContext/DynamicConfigurationTest.java b/jdk/test/javax/security/auth/login/LoginContext/DynamicConfigurationTest.java
new file mode 100644
index 0000000..c0491bb
--- /dev/null
+++ b/jdk/test/javax/security/auth/login/LoginContext/DynamicConfigurationTest.java
@@ -0,0 +1,165 @@
+/*
+ * Copyright (c) 2004, 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.
+ */
+
+import java.io.IOException;
+import javax.security.auth.Subject;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.login.Configuration;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+
+/**
+ * @test
+ * @bug 8050427 4703361
+ * @summary Test case for RFE: 4703361. Tests the Dynamic Configuration of
+ * Authentication Modules with different methods
+ * @compile SmartLoginModule.java DummyLoginModule.java MyConfiguration.java
+ * @run main/othervm DynamicConfigurationTest
+ */
+public class DynamicConfigurationTest {
+
+    public static void main(String... args) {
+        String rightConfigName = "PT";
+        String wrongConfigName = "NT";
+        char[] rightPwd = new char[]{'t', 'e', 's', 't', 'P', 'a', 's', 's',
+            'w', 'o', 'r', 'd', '1'};
+        char[] wrongPwd = new char[]{'w', 'r', 'o', 'n', 'g', 'P', 'a', 's',
+            's','w', 'o', 'r', 'd'};
+
+        // Test with wrong configuration name
+        // Expect LoginException when initiate a new LoginContext object
+        testConfigName(wrongConfigName, true);
+        System.out.println("Wrong Config Name Test passed ");
+
+        // Spedify two loginModules: SmartLoginModule and DummyLoginModule
+        // Flags: required-required
+        // Test with right password for SmartLoginModule
+        // No exception is expected
+        Configuration cf = new MyConfiguration();
+        testLogin(rightConfigName, rightPwd, cf, false);
+        System.out.println("Positive test passed");
+
+        // Spedify two loginModules: SmartLoginModule and DummyLoginModule
+        // Flags: required-required
+        // Test with wrong password for SmartLoginModule
+        // Expect LoginException by calling LoginContext.login() method
+        testLogin(rightConfigName, wrongPwd, cf, true);
+        System.out.println("Should fail test passed");
+
+        // Spedify two loginModules: SmartLoginModule and DummyLoginModule
+        // Change the flags from required-required to optional-sufficient
+        // Test with wrong password for SmartLoginModule, while DummyLoginModule
+        // always passes
+        // No Exception is expected
+        cf = new MyConfiguration(true);
+        testLogin(rightConfigName, wrongPwd, cf, false);
+        System.out.println("One module fails where are other module succeeeds "
+                + "Test passed with optional-sufficient flags");
+    }
+
+    public static void testConfigName(String confName,
+            boolean expectException) {
+        String expectedMsg = "No LoginModules configured for " + confName;
+        try {
+            LoginContext lc = new LoginContext(confName, new Subject(),
+                    new MyCallbackHandler(), new MyConfiguration());
+
+            if (expectException) {
+                throw new RuntimeException("Wrong Config Name Test failed: "
+                        + "expected LoginException not thrown.");
+            }
+        } catch (LoginException le) {
+            if (!expectException || !le.getMessage().equals(expectedMsg)) {
+                System.out.println("Wrong Config Name Test failed: "
+                        + "received Unexpected exception.");
+                throw new RuntimeException(le);
+            }
+        }
+    }
+
+    public static void testLogin(String confName, char[] passwd,
+            Configuration cf, boolean expectException) {
+        try {
+            CallbackHandler ch = new MyCallbackHandler("testUser", passwd);
+            LoginContext lc = new LoginContext(confName, new Subject(),
+                    ch, cf);
+            lc.login();
+            if (expectException) {
+                throw new RuntimeException("Login Test failed: "
+                        + "expected LoginException not thrown");
+            }
+        } catch (LoginException le) {
+            if (!expectException) {
+                System.out.println("Login Test failed: "
+                        + "received Unexpected exception.");
+                throw new RuntimeException(le);
+            }
+        }
+    }
+}
+
+/**
+ * The application simulates the CallbackHandler. It simulates! which means all
+ * process to get username and password is ignored. We have to take this
+ * approach for automation purpose. So, this is not a real world example at all.
+ */
+class MyCallbackHandler implements CallbackHandler {
+
+    String userName;
+    char[] password;
+
+    /**
+     * This is simply a workaround approach for IO approach to get username and
+     * password. For automation purpose only.
+     */
+    public MyCallbackHandler() {
+        super();
+    }
+
+    public MyCallbackHandler(String username, char[] password) {
+        super();
+        userName = username;
+        this.password = password;
+    }
+
+    @Override
+    public void handle(Callback[] callbacks) throws IOException,
+            UnsupportedCallbackException {
+        for (Callback callback : callbacks) {
+            if (callback instanceof NameCallback) {
+                NameCallback nc = (NameCallback) callback;
+                nc.setName(userName);
+            } else if (callback instanceof PasswordCallback) {
+                PasswordCallback pc = (PasswordCallback) callback;
+                pc.setPassword(password);
+            } else {
+                throw new UnsupportedCallbackException(callback,
+                        "Unrecognized Callback");
+            }
+        }
+    }
+}
diff --git a/jdk/test/javax/security/auth/login/LoginContext/LCTest.jaas.config b/jdk/test/javax/security/auth/login/LoginContext/LCTest.jaas.config
new file mode 100644
index 0000000..f63cff5
--- /dev/null
+++ b/jdk/test/javax/security/auth/login/LoginContext/LCTest.jaas.config
@@ -0,0 +1,57 @@
+
+"AbortRequired" {
+    LCTest$LoginModuleAllPass required;
+    LCTest$LoginModuleWithLoginException required;
+    LCTest$LoginModuleAllPass required;
+};
+
+"AbortRequisite" {
+    LCTest$LoginModuleWithLoginException required;
+    LCTest$LoginModuleWithAbortException requisite;
+    LCTest$LoginModuleAllPass required;
+};
+
+"AbortSufficient" {
+    LCTest$LoginModuleWithLoginException required;
+    LCTest$LoginModuleWithLoginException sufficient;
+    LCTest$LoginModuleAllPass required;
+};
+
+"LogoutRequisite" {
+    LCTest$LoginModuleAllPass required;
+    LCTest$LoginModuleWithLogoutException requisite;
+    LCTest$LoginModuleAllPass required;
+};
+
+"LogoutSufficient" {
+    LCTest$LoginModuleAllPass required;
+    LCTest$LoginModuleWithLoginException sufficient;
+    LCTest$LoginModuleAllPass required;
+};
+
+"LogoutRequired" {
+    LCTest$LoginModuleWithLogoutException required;
+    LCTest$LoginModuleWithAbortException required;
+    LCTest$LoginModuleAllPass required;
+};
+
+"LoginRequired" {
+    LCTest$LoginModuleWithLoginException required;
+    LCTest$LoginModuleWithAbortException required;
+    LCTest$LoginModuleAllPass required;
+};
+
+"LoginSufficient" {
+    LCTest$LoginModuleAllPass required;
+    LCTest$LoginModuleWithLoginException sufficient;
+    LCTest$LoginModuleAllPass required;
+};
+
+"LoginRequisite" {
+    LCTest$LoginModuleWithLoginException required;
+    LCTest$LoginModuleWithAbortException requisite;
+    LCTest$LoginModuleAllPass required;
+};
+
+"EmptyModuleConfig" {
+};
diff --git a/jdk/test/javax/security/auth/login/LoginContext/LCTest.java b/jdk/test/javax/security/auth/login/LoginContext/LCTest.java
new file mode 100644
index 0000000..e5eeb6c
--- /dev/null
+++ b/jdk/test/javax/security/auth/login/LoginContext/LCTest.java
@@ -0,0 +1,337 @@
+/*
+ * 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.
+ */
+
+import com.sun.security.auth.UnixPrincipal;
+
+import javax.security.auth.Subject;
+import javax.security.auth.callback.*;
+import javax.security.auth.login.FailedLoginException;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+import javax.security.auth.spi.LoginModule;
+import java.io.IOException;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/*
+ * @test
+ * @bug 8050460
+ * @summary Test checks that proper methods associated with login/logout process
+ * of LoginContext are called for different configurations and circumstances.
+ * @modules jdk.security.auth
+ *
+ * @run main/othervm  LCTest EmptyModuleConfig false
+ * @run main/othervm  LCTest IncorrectName false
+ * @run main/othervm  LCTest AbortRequisite false abort
+ * @run main/othervm  LCTest AbortSufficient false abort
+ * @run main/othervm  LCTest AbortRequired false abort
+ * @run main/othervm  LCTest LogoutRequisite false logout
+ * @run main/othervm  LCTest LogoutSufficient true logout
+ * @run main/othervm  LCTest LogoutRequired false logout
+ * @run main/othervm  LCTest LoginRequisite false login
+ * @run main/othervm  LCTest LoginSufficient true login
+ * @run main/othervm  LCTest LoginRequired false login
+ */
+
+public class LCTest {
+
+    private static final String USER_NAME = "testUser";
+    private static final String PASSWORD = "testPassword";
+    private static final List<String> loggedActions = new ArrayList<>();
+
+    static {
+        System.setProperty("java.security.auth.login.config",
+                System.getProperty("test.src")
+                        + System.getProperty("file.separator")
+                        + "LCTest.jaas.config");
+    }
+
+    public static void main(String[] args) {
+        if (args.length < 2) {
+            throw new RuntimeException("Incorrect test params");
+        }
+        String nameOfContext = args[0];
+        boolean isPositive = Boolean.parseBoolean(args[1]);
+        String actionName = null;
+        if (args.length == 3) {
+            actionName = args[2];
+        }
+        try {
+            LoginContext lc = new LoginContext(nameOfContext,
+                    new MyCallbackHandler());
+            lc.login();
+            checkPrincipal(lc, true);
+            lc.logout();
+            checkPrincipal(lc, false);
+            if (!isPositive) {
+                throw new RuntimeException("Test failed. Exception expected.");
+            }
+        } catch (LoginException le) {
+            if (isPositive) {
+                throw new RuntimeException("Test failed. Unexpected " +
+                        "exception", le);
+            }
+            System.out.println("Expected exception: "
+                    + le.getMessage());
+        }
+        checkActions(actionName);
+        System.out.println("Test passed.");
+    }
+
+    /*
+     * Log action from login modules
+     */
+    private static void logAction(String actionName) {
+        loggedActions.add(actionName);
+    }
+
+    /*
+     * Check if logged actions are as expected. We always expected 3 actions
+     * if any.
+     */
+    private static void checkActions(String actionName) {
+        if (actionName == null) {
+            if (loggedActions.size() != 0) {
+                throw new RuntimeException("No logged actions expected");
+            }
+        } else {
+            int loggedActionsFound = 0;
+            System.out.println("Logged actions : " + loggedActions);
+            for (String s : loggedActions) {
+                if (s.equals(actionName)) {
+                    loggedActionsFound++;
+                }
+            }
+            if (loggedActionsFound != 3) {
+                throw new RuntimeException("Incorrect number of actions " +
+                        actionName + " : " + loggedActionsFound);
+            }
+        }
+    }
+
+    /*
+     * Check context for principal of the test user.
+     */
+    private static void checkPrincipal(LoginContext loginContext, boolean
+            principalShouldExist) {
+        if (!principalShouldExist) {
+            if (loginContext.getSubject().getPrincipals().size() != 0) {
+                throw new RuntimeException("Test failed. Principal was not " +
+                        "cleared.");
+            }
+        } else {
+            for (Principal p : loginContext.getSubject().getPrincipals()) {
+                if (p instanceof UnixPrincipal &&
+                        USER_NAME.equals(p.getName())) {
+                    //Proper principal was found, return.
+                    return;
+                }
+            }
+            throw new RuntimeException("Test failed. UnixPrincipal "
+                    + USER_NAME + " expected.");
+        }
+    }
+
+    private static class MyCallbackHandler implements CallbackHandler {
+
+        @Override
+        public void handle(Callback[] callbacks) throws IOException,
+                UnsupportedCallbackException {
+            for (Callback callback : callbacks) {
+                if (callback instanceof NameCallback) {
+                    ((NameCallback) callback).setName(USER_NAME);
+                } else if (callback instanceof PasswordCallback) {
+                    ((PasswordCallback) callback).setPassword(
+                            PASSWORD.toCharArray());
+                } else {
+                    throw new UnsupportedCallbackException(callback);
+                }
+            }
+        }
+    }
+
+    /* -------------------------------------------------------------------------
+     * Test login modules
+     * -------------------------------------------------------------------------
+     */
+
+    /*
+     * Login module that should pass through all phases.
+     */
+    public static class LoginModuleAllPass extends LoginModuleBase {
+
+    }
+
+    /*
+     * Login module that throws Exception in abort method.
+     */
+    public static class LoginModuleWithAbortException extends LoginModuleBase {
+
+        @Override
+        public boolean abort() throws LoginException {
+            super.abort();
+            throw new LoginException("Abort failed!");
+        }
+    }
+
+    /*
+     * Login module that throws Exception in login method.
+     */
+    public static class LoginModuleWithLoginException extends LoginModuleBase {
+
+        @Override
+        public boolean login() throws LoginException {
+            super.login();
+            throw new FailedLoginException("Login failed!");
+        }
+    }
+
+    /*
+     * Login module that throws Exception in logout method.
+     */
+    public static class LoginModuleWithLogoutException extends LoginModuleBase {
+
+        @Override
+        public boolean logout() throws LoginException {
+            super.logout();
+            throw new FailedLoginException("Logout failed!");
+        }
+    }
+
+    /*
+     * Base class for login modules
+     */
+    public static abstract class LoginModuleBase implements LoginModule {
+        // initial state
+        private Subject subject;
+        private CallbackHandler callbackHandler;
+        private Map sharedState;
+        private Map options;
+        private UnixPrincipal userPrincipal;
+
+        // username and password
+        private String username;
+        private String password;
+
+        // the authentication status
+        private boolean succeeded = false;
+        private boolean commitSucceeded = false;
+
+        @Override
+        public void initialize(Subject subject, CallbackHandler callbackHandler,
+                               Map<String, ?> sharedState, Map<String, ?> options) {
+
+            this.subject = subject;
+            this.callbackHandler = callbackHandler;
+            this.sharedState = sharedState;
+            this.options = options;
+            System.out.println("Login module initialized.");
+        }
+
+        /*
+         * Authenticate the user by prompting for a username and password.
+         */
+        @Override
+        public boolean login() throws LoginException {
+            LCTest.logAction("login");
+            if (callbackHandler == null) {
+                throw new LoginException("No CallbackHandler available");
+            }
+
+            Callback[] callbacks = new Callback[2];
+            callbacks[0] = new NameCallback("Username: ");
+            callbacks[1] = new PasswordCallback("Password: ", false);
+
+            try {
+                callbackHandler.handle(callbacks);
+                username = ((NameCallback) callbacks[0]).getName();
+                password = new String(((PasswordCallback) callbacks[1])
+                        .getPassword());
+                if (username.equals(LCTest.USER_NAME) &&
+                        password.equals(LCTest.PASSWORD)) {
+                    succeeded = true;
+                    return true;
+                }
+                throw new FailedLoginException("Incorrect username/password!");
+            } catch (IOException | UnsupportedCallbackException e) {
+                throw new LoginException("Login failed: " + e.getMessage());
+            }
+        }
+
+        @Override
+        public boolean commit() throws LoginException {
+            LCTest.logAction("commit");
+            if (succeeded == false) {
+                return false;
+            }
+            userPrincipal = new UnixPrincipal(username);
+            final Subject s = subject;
+            final UnixPrincipal up = userPrincipal;
+            java.security.AccessController.doPrivileged
+                    ((java.security.PrivilegedAction) () -> {
+                        if (!s.getPrincipals().contains(up)) {
+                            s.getPrincipals().add(up);
+                        }
+                        return null;
+                    });
+            password = null;
+            commitSucceeded = true;
+            return true;
+        }
+
+        @Override
+        public boolean abort() throws LoginException {
+            LCTest.logAction("abort");
+            if (succeeded == false) {
+                return false;
+            }
+            clearState();
+            return true;
+        }
+
+        @Override
+        public boolean logout() throws LoginException {
+            LCTest.logAction("logout");
+            clearState();
+            return true;
+        }
+
+        private void clearState() {
+            if (commitSucceeded) {
+                final Subject s = subject;
+                final UnixPrincipal up = userPrincipal;
+                java.security.AccessController.doPrivileged
+                        ((java.security.PrivilegedAction) () -> {
+                            s.getPrincipals().remove(up);
+                            return null;
+                        });
+            }
+            username = null;
+            password = null;
+            userPrincipal = null;
+        }
+    }
+
+}
diff --git a/jdk/test/javax/security/auth/login/LoginContext/MyConfiguration.java b/jdk/test/javax/security/auth/login/LoginContext/MyConfiguration.java
new file mode 100644
index 0000000..5077279
--- /dev/null
+++ b/jdk/test/javax/security/auth/login/LoginContext/MyConfiguration.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2004, 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.
+ */
+
+import java.util.HashMap;
+import javax.security.auth.login.AppConfigurationEntry;
+import static javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag.OPTIONAL;
+import static javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag.REQUIRED;
+import static javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag.SUFFICIENT;
+import javax.security.auth.login.Configuration;
+
+/**
+ * This class is used to test LoginContext constructor API. It simply contains
+ * one configuration entry: PT.
+ */
+public class MyConfiguration extends Configuration {
+
+    private static final AppConfigurationEntry[] ptAE
+            = new AppConfigurationEntry[2];
+    private static final HashMap<String, String> map = new HashMap<>();
+    private boolean optionOrder = false;
+
+    public MyConfiguration() {
+        setupConfiguration();
+    }
+
+    public MyConfiguration(boolean optionOrder) {
+        this.optionOrder = optionOrder;
+        setupConfiguration();
+    }
+
+    private void setupConfiguration() {
+        ptAE[0] = new AppConfigurationEntry("SmartLoginModule",
+                optionOrder ? OPTIONAL : REQUIRED,
+                map);
+        ptAE[1] = new AppConfigurationEntry("DummyLoginModule",
+                optionOrder ? SUFFICIENT : REQUIRED,
+                map);
+    }
+
+    @Override
+    public AppConfigurationEntry[]
+            getAppConfigurationEntry(String applicationName) {
+        if (applicationName.equals("PT")) {
+            return ptAE;
+        } else {
+            return null;
+        }
+    }
+
+}
diff --git a/jdk/test/javax/security/auth/login/LoginContext/SharedState.java b/jdk/test/javax/security/auth/login/LoginContext/SharedState.java
new file mode 100644
index 0000000..d944e5a
--- /dev/null
+++ b/jdk/test/javax/security/auth/login/LoginContext/SharedState.java
@@ -0,0 +1,98 @@
+/*
+ * 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.
+ */
+
+import java.util.Map;
+import javax.security.auth.Subject;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+import javax.security.auth.spi.LoginModule;
+
+/**
+ * @test
+ * @bug 8048138
+ * @summary Check if shared state is passed to login module
+ * @run main/othervm SharedState
+ */
+public class SharedState {
+
+    static final String NAME = "name";
+    static final String VALUE = "shared";
+
+    public static void main(String[] args) throws LoginException {
+        System.setProperty("java.security.auth.login.config",
+                System.getProperty("test.src")
+                        + System.getProperty("file.separator")
+                        + "shared.config");
+
+        new LoginContext("SharedState").login();
+    }
+
+    public static abstract class Module implements LoginModule {
+
+        @Override
+        public boolean login() throws LoginException {
+            return true;
+        }
+
+        @Override
+        public boolean commit() throws LoginException {
+            return true;
+        }
+
+        @Override
+        public boolean abort() throws LoginException {
+            return true;
+        }
+
+        @Override
+        public boolean logout() throws LoginException {
+            return true;
+        }
+    }
+
+    public static class FirstModule extends Module {
+
+        @Override
+        public void initialize(Subject subject, CallbackHandler callbackHandler,
+                            Map<String,?> sharedState, Map<String,?> options) {
+            ((Map)sharedState).put(NAME, VALUE);
+        }
+
+    }
+
+    public static class SecondModule extends Module {
+
+        @Override
+        public void initialize(Subject subject, CallbackHandler callbackHandler,
+                            Map<String,?> sharedState, Map<String,?> options) {
+            // check shared object
+            Object shared = sharedState.get(NAME);
+            if (!VALUE.equals(shared)) {
+                throw new RuntimeException("Unexpected shared object: "
+                        + shared);
+            }
+        }
+
+    }
+}
diff --git a/jdk/test/javax/security/auth/login/LoginContext/SmartLoginModule.java b/jdk/test/javax/security/auth/login/LoginContext/SmartLoginModule.java
new file mode 100644
index 0000000..aa43ea6
--- /dev/null
+++ b/jdk/test/javax/security/auth/login/LoginContext/SmartLoginModule.java
@@ -0,0 +1,253 @@
+/*
+ * Copyright (c) 2004, 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.
+ */
+
+import java.security.Principal;
+import java.util.Arrays;
+import java.util.Map;
+import javax.security.auth.Subject;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.login.FailedLoginException;
+import javax.security.auth.login.LoginException;
+import javax.security.auth.spi.LoginModule;
+
+/**
+ * This code was based on JAAS demo code, small modification is made for testing
+ * purpose.
+ */
+public class SmartLoginModule implements LoginModule {
+
+    // initial state
+    private Subject subject;
+    private CallbackHandler callbackHandler;
+
+    // the authentication status
+    private boolean succeeded = false;
+    private boolean commitSucceeded = false;
+
+    // username and password
+    private String username;
+    private char[] password;
+
+    // Default values for this login module. In real world,
+    // don't do it in this way!
+    private String myUsername;
+    private char[] myPassword;
+    private String header;
+
+    // testUser's SamplePrincipal
+    private SamplePrincipal userPrincipal;
+
+    public SmartLoginModule() {
+        this("testUser",
+                new char[]{'t', 'e', 's', 't', 'P', 'a', 's', 's',
+                    'w', 'o', 'r', 'd', '1'},
+                "SmartLoginModule1: ");
+    }
+
+    public SmartLoginModule(String userName, char[] password, String header) {
+        myUsername = userName;
+        myPassword = password;
+        this.header = header;
+    }
+
+    @Override
+    public boolean abort() throws LoginException {
+        if (!succeeded) {
+            return false;
+        } else if (succeeded && !commitSucceeded) {
+            // login succeeded but overall authentication failed
+            succeeded = false;
+            username = null;
+            password = null;
+            userPrincipal = null;
+        } else {
+            // overall authentication succeeded and commit succeeded,
+            // but someone else's commit failed
+            logout();
+        }
+        return true;
+    }
+
+    @Override
+    public boolean commit() throws LoginException {
+        if (!succeeded) {
+            return false;
+        } else {
+            // add a Principal (authenticated identity) to the Subject
+            // assume the user we authenticated is the SamplePrincipal
+            userPrincipal = new SamplePrincipal(username);
+            if (!subject.getPrincipals().contains(userPrincipal)) {
+                subject.getPrincipals().add(userPrincipal);
+            }
+            // in any case, clean out state
+            username = null;
+            password = null;
+            commitSucceeded = true;
+            return true;
+        }
+    }
+
+    @Override
+    public void initialize(Subject subject, CallbackHandler callbackHandler,
+            Map<String, ?> sharedState, Map<String, ?> options) {
+        this.subject = subject;
+        this.callbackHandler = callbackHandler;
+    }
+
+    @Override
+    public boolean login() throws LoginException {
+        if (callbackHandler == null) {
+            throw new LoginException("Error: no CallbackHandler available to "
+                    + "garner authentication information from the user");
+        }
+
+        Callback[] callbacks = new Callback[2];
+        callbacks[0] = new NameCallback(header + "user name: ");
+        callbacks[1] = new PasswordCallback(header + "password: ", false);
+
+        try {
+            callbackHandler.handle(callbacks);
+            username = ((NameCallback) callbacks[0]).getName();
+            char[] tmpPassword
+                    = ((PasswordCallback) callbacks[1]).getPassword();
+            if (tmpPassword == null) {
+                tmpPassword = new char[0];
+            }
+            password = new char[tmpPassword.length];
+            System.arraycopy(tmpPassword, 0, password, 0, tmpPassword.length);
+            ((PasswordCallback) callbacks[1]).clearPassword();
+        } catch (java.io.IOException ioe) {
+            throw (LoginException) new LoginException().initCause(ioe);
+        } catch (UnsupportedCallbackException uce) {
+            throw new LoginException("Error: " + header
+                    + uce.getCallback().toString()
+                    + " not available to garner authentication information "
+                    + "from the user");
+        }
+
+        // verify the username/password
+        if (username.equals(myUsername)
+                && Arrays.equals(password, myPassword)) {
+            System.out.println("\t\t" + header + " authentication succeeded");
+            succeeded = true;
+            return true;
+        } else {
+            // authentication failed -- clean out state
+            System.out.println("\t\t" + header + " authentication failed");
+            printDebugInfo();
+            succeeded = false;
+            username = null;
+            password = null;
+            throw new FailedLoginException("User Name or Password Incorrect");
+        }
+    }
+
+    @Override
+    public boolean logout() throws LoginException {
+        subject.getPrincipals().remove(userPrincipal);
+        succeeded = false;
+        succeeded = commitSucceeded;
+        username = null;
+        password = null;
+        userPrincipal = null;
+        return true;
+    }
+
+    // print debugging information
+    private void printDebugInfo() {
+        System.out.println("\t\t" + header + " correct user name: "
+                + myUsername);
+        System.out.println("\t\t" + header + " user entered user name: "
+                + username);
+        System.out.print("\t\t" + header + " correct password: ");
+        for (char c : myPassword) {
+            System.out.print(c);
+        }
+        System.out.println();
+        System.out.print("\t\t" + header + " user entered password: ");
+        for (char c : password) {
+            System.out.print(c);
+        }
+        System.out.println();
+    }
+}
+
+class SamplePrincipal implements Principal, java.io.Serializable {
+
+    /**
+     * @serial
+     */
+    private String name;
+
+    /**
+     * Create a SamplePrincipal with a Sample username.
+     *
+     * @param name the Sample username for this user.
+     * @exception NullPointerException if the <code>name</code> is
+     * <code>null</code>.
+     */
+    public SamplePrincipal(String name) {
+        if (name == null) {
+            throw new NullPointerException("illegal null input");
+        }
+
+        this.name = name;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public String toString() {
+        return "SamplePrincipal:  " + name;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (o == null) {
+            return false;
+        }
+
+        if (this == o) {
+            return true;
+        }
+
+        if (!(o instanceof SamplePrincipal)) {
+            return false;
+        }
+        SamplePrincipal that = (SamplePrincipal) o;
+
+        return this.getName().equals(that.getName());
+    }
+
+    @Override
+    public int hashCode() {
+        return name.hashCode();
+    }
+}
diff --git a/jdk/test/javax/security/auth/login/LoginContext/StandardCallbacks.java b/jdk/test/javax/security/auth/login/LoginContext/StandardCallbacks.java
new file mode 100644
index 0000000..4b69f84
--- /dev/null
+++ b/jdk/test/javax/security/auth/login/LoginContext/StandardCallbacks.java
@@ -0,0 +1,189 @@
+/*
+ * 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.
+ */
+
+import java.security.Principal;
+import java.util.Arrays;
+import java.util.Locale;
+import javax.security.auth.Subject;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.ChoiceCallback;
+import javax.security.auth.callback.ConfirmationCallback;
+import javax.security.auth.callback.LanguageCallback;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.TextInputCallback;
+import javax.security.auth.callback.TextOutputCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+
+/*
+ * @test
+ * @bug 8048138
+ * @summary Checks if JAAS login works fine with standard callbacks
+ * @compile DefaultHandlerModule.java
+ * @run main/othervm StandardCallbacks
+ */
+public class StandardCallbacks {
+
+    private static final String USERNAME = "username";
+    private static final char[] PASSWORD = "password".toCharArray();
+
+    public static void main(String[] args) throws LoginException {
+        System.setProperty("java.security.auth.login.config",
+                System.getProperty("test.src")
+                        + System.getProperty("file.separator")
+                        + "custom.config");
+
+        CustomCallbackHandler handler = new CustomCallbackHandler(USERNAME);
+        LoginContext context = new LoginContext("StandardCallbacks", handler);
+
+        handler.setPassword(PASSWORD);
+        System.out.println("Try to login with correct password, "
+                + "successful authentication is expected");
+        context.login();
+        System.out.println("Authentication succeeded!");
+
+        Subject subject = context.getSubject();
+        System.out.println("Authenticated user has the following principals ["
+                + subject.getPrincipals().size() + " ]:");
+        boolean found = true;
+        for (Principal principal : subject.getPrincipals()) {
+            System.out.println("principal: " + principal);
+            if (principal instanceof CustomLoginModule.TestPrincipal) {
+                CustomLoginModule.TestPrincipal testPrincipal =
+                        (CustomLoginModule.TestPrincipal) principal;
+                if (USERNAME.equals(testPrincipal.getName())) {
+                    System.out.println("Found test principal: "
+                            + testPrincipal);
+                    found = true;
+                    break;
+                }
+            }
+        }
+
+        if (!found) {
+            throw new RuntimeException("TestPrincipal not found");
+        }
+
+        // check if all expected text output callbacks have been called
+        if (!handler.info) {
+            throw new RuntimeException("TextOutputCallback.INFO not called");
+        }
+
+        if (!handler.warning) {
+            throw new RuntimeException("TextOutputCallback.WARNING not called");
+        }
+
+        if (!handler.error) {
+            throw new RuntimeException("TextOutputCallback.ERROR not called");
+        }
+
+        System.out.println("Authenticated user has the following public "
+                + "credentials [" + subject.getPublicCredentials().size()
+                + "]:");
+        subject.getPublicCredentials().stream().
+                forEach((o) -> {
+                    System.out.println("public credential: " + o);
+        });
+
+        context.logout();
+
+        System.out.println("Test passed");
+    }
+
+    private static class CustomCallbackHandler implements CallbackHandler {
+
+        private final String username;
+        private char[] password;
+        private boolean info = false;
+        private boolean warning = false;
+        private boolean error = false;
+
+        CustomCallbackHandler(String username) {
+            this.username = username;
+        }
+
+        void setPassword(char[] password) {
+            this.password = password;
+        }
+
+        @Override
+        public void handle(Callback[] callbacks)
+                throws UnsupportedCallbackException {
+            for (Callback callback : callbacks) {
+                if (callback instanceof TextOutputCallback) {
+                    TextOutputCallback toc = (TextOutputCallback) callback;
+                    switch (toc.getMessageType()) {
+                        case TextOutputCallback.INFORMATION:
+                            System.out.println("INFO: " + toc.getMessage());
+                            info = true;
+                            break;
+                        case TextOutputCallback.ERROR:
+                            System.out.println("ERROR: " + toc.getMessage());
+                            error = true;
+                            break;
+                        case TextOutputCallback.WARNING:
+                            System.out.println("WARNING: " + toc.getMessage());
+                            warning = true;
+                            break;
+                        default:
+                            throw new UnsupportedCallbackException(toc,
+                                    "Unsupported message type: "
+                                            + toc.getMessageType());
+                    }
+                } else if (callback instanceof TextInputCallback) {
+                    TextInputCallback tic = (TextInputCallback) callback;
+                    System.out.println(tic.getPrompt());
+                    tic.setText(CustomLoginModule.HELLO);
+                } else if (callback instanceof LanguageCallback) {
+                    LanguageCallback lc = (LanguageCallback) callback;
+                    lc.setLocale(Locale.GERMANY);
+                } else if (callback instanceof ConfirmationCallback) {
+                    ConfirmationCallback cc = (ConfirmationCallback) callback;
+                    System.out.println(cc.getPrompt());
+                    cc.setSelectedIndex(ConfirmationCallback.YES);
+                } else if (callback instanceof ChoiceCallback) {
+                    ChoiceCallback cc = (ChoiceCallback) callback;
+                    System.out.println(cc.getPrompt()
+                            + Arrays.toString(cc.getChoices()));
+                    cc.setSelectedIndex(0);
+                } else if (callback instanceof NameCallback) {
+                    NameCallback nc = (NameCallback) callback;
+                    System.out.println(nc.getPrompt());
+                    nc.setName(username);
+                } else if (callback instanceof PasswordCallback) {
+                    PasswordCallback pc = (PasswordCallback) callback;
+                    System.out.println(pc.getPrompt());
+                    pc.setPassword(password);
+                } else {
+                    throw new UnsupportedCallbackException(callback,
+                            "Unknown callback");
+                }
+            }
+        }
+
+    }
+
+}
diff --git a/jdk/test/javax/security/auth/login/LoginContext/custom.config b/jdk/test/javax/security/auth/login/LoginContext/custom.config
new file mode 100644
index 0000000..6ecdc56
--- /dev/null
+++ b/jdk/test/javax/security/auth/login/LoginContext/custom.config
@@ -0,0 +1,4 @@
+StandardCallbacks {
+    DefaultHandlerModule required;
+    CustomLoginModule required username="username" password="password";
+};
diff --git a/jdk/test/javax/security/auth/login/LoginContext/shared.config b/jdk/test/javax/security/auth/login/LoginContext/shared.config
new file mode 100644
index 0000000..86201e2
--- /dev/null
+++ b/jdk/test/javax/security/auth/login/LoginContext/shared.config
@@ -0,0 +1,4 @@
+SharedState {
+    SharedState$FirstModule required;
+    SharedState$SecondModule required;
+};
\ No newline at end of file
diff --git a/jdk/test/javax/security/sasl/Sasl/ClientServerTest.java b/jdk/test/javax/security/sasl/Sasl/ClientServerTest.java
new file mode 100644
index 0000000..5d1222a
--- /dev/null
+++ b/jdk/test/javax/security/sasl/Sasl/ClientServerTest.java
@@ -0,0 +1,477 @@
+/*
+ * 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.
+ */
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.StringJoiner;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.sasl.AuthorizeCallback;
+import javax.security.sasl.RealmCallback;
+import javax.security.sasl.RealmChoiceCallback;
+import javax.security.sasl.Sasl;
+import javax.security.sasl.SaslClient;
+import javax.security.sasl.SaslException;
+import javax.security.sasl.SaslServer;
+
+/*
+ * @test
+ * @bug 8049814
+ * @summary JAVA SASL server and client tests with CRAM-MD5 and
+ *          DIGEST-MD5 mechanisms. The tests try different QOP values on
+ *          client and server side.
+ * @modules java.security.sasl/javax.security.sasl
+ */
+public class ClientServerTest {
+
+    private static final int DELAY = 100;
+    private static final String LOCALHOST = "localhost";
+    private static final String DIGEST_MD5 = "DIGEST-MD5";
+    private static final String CRAM_MD5 = "CRAM-MD5";
+    private static final String PROTOCOL = "saslservice";
+    private static final String USER_ID = "sasltester";
+    private static final String PASSWD = "password";
+    private static final String QOP_AUTH = "auth";
+    private static final String QOP_AUTH_CONF = "auth-conf";
+    private static final String QOP_AUTH_INT = "auth-int";
+    private static final String AUTHID_SASL_TESTER = "sasl_tester";
+    private static final ArrayList<String> SUPPORT_MECHS = new ArrayList<>();
+
+    static {
+        SUPPORT_MECHS.add(DIGEST_MD5);
+        SUPPORT_MECHS.add(CRAM_MD5);
+    }
+
+    public static void main(String[] args) throws Exception {
+        String[] allQops = { QOP_AUTH_CONF, QOP_AUTH_INT, QOP_AUTH };
+        String[] twoQops = { QOP_AUTH_INT, QOP_AUTH };
+        String[] authQop = { QOP_AUTH };
+        String[] authIntQop = { QOP_AUTH_INT };
+        String[] authConfQop = { QOP_AUTH_CONF };
+        String[] emptyQop = {};
+
+        boolean success = true;
+
+        success &= runTest("", CRAM_MD5, new String[] { QOP_AUTH },
+                new String[] { QOP_AUTH }, false);
+        success &= runTest("", DIGEST_MD5, new String[] { QOP_AUTH },
+                new String[] { QOP_AUTH }, false);
+        success &= runTest(AUTHID_SASL_TESTER, DIGEST_MD5,
+                new String[] { QOP_AUTH }, new String[] { QOP_AUTH }, false);
+        success &= runTest("", DIGEST_MD5, allQops, authQop, false);
+        success &= runTest("", DIGEST_MD5, allQops, authIntQop, false);
+        success &= runTest("", DIGEST_MD5, allQops, authConfQop, false);
+        success &= runTest("", DIGEST_MD5, twoQops, authQop, false);
+        success &= runTest("", DIGEST_MD5, twoQops, authIntQop, false);
+        success &= runTest("", DIGEST_MD5, twoQops, authConfQop, true);
+        success &= runTest("", DIGEST_MD5, authIntQop, authQop, true);
+        success &= runTest("", DIGEST_MD5, authConfQop, authQop, true);
+        success &= runTest("", DIGEST_MD5, authConfQop, emptyQop, true);
+        success &= runTest("", DIGEST_MD5, authIntQop, emptyQop, true);
+        success &= runTest("", DIGEST_MD5, authQop, emptyQop, true);
+
+        if (!success) {
+            throw new RuntimeException("At least one test case failed");
+        }
+
+        System.out.println("Test passed");
+    }
+
+    private static boolean runTest(String authId, String mech,
+            String[] clientQops, String[] serverQops, boolean expectException)
+            throws Exception {
+
+        System.out.println("AuthId:" + authId
+                + " mechanism:" + mech
+                + " clientQops: " + Arrays.toString(clientQops)
+                + " serverQops: " + Arrays.toString(serverQops)
+                + " expect exception:" + expectException);
+
+        try (Server server = Server.start(LOCALHOST, authId, serverQops)) {
+            new Client(LOCALHOST, server.getPort(), mech, authId, clientQops)
+                    .run();
+            if (expectException) {
+                System.out.println("Expected exception not thrown");
+                return false;
+            }
+        } catch (SaslException e) {
+            if (!expectException) {
+                System.out.println("Unexpected exception: " + e);
+                return false;
+            }
+            System.out.println("Expected exception: " + e);
+        }
+
+        return true;
+    }
+
+    static enum SaslStatus {
+        SUCCESS, FAILURE, CONTINUE
+    }
+
+    static class Message implements Serializable {
+
+        private final SaslStatus status;
+        private final byte[] data;
+
+        public Message(SaslStatus status, byte[] data) {
+            this.status = status;
+            this.data = data;
+        }
+
+        public SaslStatus getStatus() {
+            return status;
+        }
+
+        public byte[] getData() {
+            return data;
+        }
+    }
+
+    static class SaslPeer {
+
+        final String host;
+        final String mechanism;
+        final String qop;
+        final CallbackHandler callback;
+
+        SaslPeer(String host, String authId, String... qops) {
+            this(host, null, authId, qops);
+        }
+
+        SaslPeer(String host, String mechanism, String authId, String... qops) {
+            this.host = host;
+            this.mechanism = mechanism;
+
+            StringJoiner sj = new StringJoiner(",");
+            for (String q : qops) {
+                sj.add(q);
+            }
+            qop = sj.toString();
+
+            callback = new TestCallbackHandler(USER_ID, PASSWD, host, authId);
+        }
+
+        Message getMessage(Object ob) {
+            if (!(ob instanceof Message)) {
+                throw new RuntimeException("Expected an instance of Message");
+            }
+            return (Message) ob;
+        }
+    }
+
+    static class Server extends SaslPeer implements Runnable, Closeable {
+
+        private volatile boolean ready = false;
+        private volatile ServerSocket ssocket;
+
+        static Server start(String host, String authId, String[] serverQops)
+                throws UnknownHostException {
+            Server server = new Server(host, authId, serverQops);
+            Thread thread = new Thread(server);
+            thread.setDaemon(true);
+            thread.start();
+
+            while (!server.ready) {
+                try {
+                    Thread.sleep(DELAY);
+                } catch (InterruptedException e) {
+                    throw new RuntimeException(e);
+                }
+            }
+
+            return server;
+        }
+
+        Server(String host, String authId, String... qops) {
+            super(host, authId, qops);
+        }
+
+        int getPort() {
+            return ssocket.getLocalPort();
+        }
+
+        private void processConnection(SaslEndpoint endpoint)
+                throws SaslException, IOException, ClassNotFoundException {
+            System.out.println("process connection");
+            endpoint.send(SUPPORT_MECHS);
+            Object o = endpoint.receive();
+            if (!(o instanceof String)) {
+                throw new RuntimeException("Received unexpected object: " + o);
+            }
+            String mech = (String) o;
+            SaslServer saslServer = createSaslServer(mech);
+            Message msg = getMessage(endpoint.receive());
+            while (!saslServer.isComplete()) {
+                byte[] data = processData(msg.getData(), endpoint,
+                        saslServer);
+                if (saslServer.isComplete()) {
+                    System.out.println("server is complete");
+                    endpoint.send(new Message(SaslStatus.SUCCESS, data));
+                } else {
+                    System.out.println("server continues");
+                    endpoint.send(new Message(SaslStatus.CONTINUE, data));
+                    msg = getMessage(endpoint.receive());
+                }
+            }
+        }
+
+        private byte[] processData(byte[] data, SaslEndpoint endpoint,
+                SaslServer server) throws SaslException, IOException {
+            try {
+                return server.evaluateResponse(data);
+            } catch (SaslException e) {
+                endpoint.send(new Message(SaslStatus.FAILURE, null));
+                System.out.println("Error while processing data");
+                throw e;
+            }
+        }
+
+        private SaslServer createSaslServer(String mechanism)
+                throws SaslException {
+            Map<String, String> props = new HashMap<>();
+            props.put(Sasl.QOP, qop);
+            return Sasl.createSaslServer(mechanism, PROTOCOL, host, props,
+                    callback);
+        }
+
+        @Override
+        public void run() {
+            try (ServerSocket ss = new ServerSocket(0)) {
+                ssocket = ss;
+                System.out.println("server started on port " + getPort());
+                ready = true;
+                Socket socket = ss.accept();
+                try (SaslEndpoint endpoint = new SaslEndpoint(socket)) {
+                    System.out.println("server accepted connection");
+                    processConnection(endpoint);
+                }
+            } catch (Exception e) {
+                // ignore it for now, client will throw an exception
+            }
+        }
+
+        @Override
+        public void close() throws IOException {
+            if (!ssocket.isClosed()) {
+                ssocket.close();
+            }
+        }
+    }
+
+    static class Client extends SaslPeer {
+
+        private final int port;
+
+        Client(String host, int port, String mech, String authId,
+                String... qops) {
+            super(host, mech, authId, qops);
+            this.port = port;
+        }
+
+        public void run() throws Exception {
+            System.out.println("Host:" + host + " port: "
+                    + port);
+            try (SaslEndpoint endpoint = SaslEndpoint.create(host, port)) {
+                negotiateMechanism(endpoint);
+                SaslClient client = createSaslClient();
+                byte[] data = new byte[0];
+                if (client.hasInitialResponse()) {
+                    data = client.evaluateChallenge(data);
+                }
+                endpoint.send(new Message(SaslStatus.CONTINUE, data));
+                Message msg = getMessage(endpoint.receive());
+                while (!client.isComplete()
+                        && msg.getStatus() != SaslStatus.FAILURE) {
+                    switch (msg.getStatus()) {
+                        case CONTINUE:
+                            System.out.println("client continues");
+                            data = client.evaluateChallenge(msg.getData());
+                            endpoint.send(new Message(SaslStatus.CONTINUE,
+                                    data));
+                            msg = getMessage(endpoint.receive());
+                            break;
+                        case SUCCESS:
+                            System.out.println("client succeeded");
+                            data = client.evaluateChallenge(msg.getData());
+                            if (data != null) {
+                                throw new SaslException("data should be null");
+                            }
+                            break;
+                        default:
+                            throw new RuntimeException("Wrong status:"
+                                    + msg.getStatus());
+                    }
+                }
+
+                if (msg.getStatus() == SaslStatus.FAILURE) {
+                    throw new RuntimeException("Status is FAILURE");
+                }
+            }
+
+            System.out.println("Done");
+        }
+
+        private SaslClient createSaslClient() throws SaslException {
+            Map<String, String> props = new HashMap<>();
+            props.put(Sasl.QOP, qop);
+            return Sasl.createSaslClient(new String[] {mechanism}, USER_ID,
+                    PROTOCOL, host, props, callback);
+        }
+
+        private void negotiateMechanism(SaslEndpoint endpoint)
+                throws ClassNotFoundException, IOException {
+            Object o = endpoint.receive();
+            if (o instanceof ArrayList) {
+                ArrayList list = (ArrayList) o;
+                if (!list.contains(mechanism)) {
+                    throw new RuntimeException(
+                            "Server does not support specified mechanism:"
+                                    + mechanism);
+                }
+            } else {
+                throw new RuntimeException(
+                        "Expected an instance of ArrayList, but received " + o);
+            }
+
+            endpoint.send(mechanism);
+        }
+
+    }
+
+    static class SaslEndpoint implements AutoCloseable {
+
+        private final Socket socket;
+        private ObjectInputStream input;
+        private ObjectOutputStream output;
+
+        static SaslEndpoint create(String host, int port) throws IOException {
+            return new SaslEndpoint(new Socket(host, port));
+        }
+
+        SaslEndpoint(Socket socket) throws IOException {
+            this.socket = socket;
+        }
+
+        private ObjectInputStream getInput() throws IOException {
+            if (input == null && socket != null) {
+                input = new ObjectInputStream(socket.getInputStream());
+            }
+            return input;
+        }
+
+        private ObjectOutputStream getOutput() throws IOException {
+            if (output == null && socket != null) {
+                output = new ObjectOutputStream(socket.getOutputStream());
+            }
+            return output;
+        }
+
+        public Object receive() throws IOException, ClassNotFoundException {
+            return getInput().readObject();
+        }
+
+        public void send(Object obj) throws IOException {
+            getOutput().writeObject(obj);
+            getOutput().flush();
+        }
+
+        @Override
+        public void close() throws IOException {
+            if (socket != null && !socket.isClosed()) {
+                socket.close();
+            }
+        }
+
+    }
+
+    static class TestCallbackHandler implements CallbackHandler {
+
+        private final String userId;
+        private final char[] passwd;
+        private final String realm;
+        private String authId;
+
+        TestCallbackHandler(String userId, String passwd, String realm,
+                String authId) {
+            this.userId = userId;
+            this.passwd = passwd.toCharArray();
+            this.realm = realm;
+            this.authId = authId;
+        }
+
+        @Override
+        public void handle(Callback[] callbacks) throws IOException,
+                UnsupportedCallbackException {
+            for (Callback callback : callbacks) {
+                if (callback instanceof NameCallback) {
+                    System.out.println("NameCallback");
+                    ((NameCallback) callback).setName(userId);
+                } else if (callback instanceof PasswordCallback) {
+                    System.out.println("PasswordCallback");
+                    ((PasswordCallback) callback).setPassword(passwd);
+                } else if (callback instanceof RealmCallback) {
+                    System.out.println("RealmCallback");
+                    ((RealmCallback) callback).setText(realm);
+                } else if (callback instanceof RealmChoiceCallback) {
+                    System.out.println("RealmChoiceCallback");
+                    RealmChoiceCallback choice = (RealmChoiceCallback) callback;
+                    if (realm == null) {
+                        choice.setSelectedIndex(choice.getDefaultChoice());
+                    } else {
+                        String[] choices = choice.getChoices();
+                        for (int j = 0; j < choices.length; j++) {
+                            if (realm.equals(choices[j])) {
+                                choice.setSelectedIndex(j);
+                                break;
+                            }
+                        }
+                    }
+                } else if (callback instanceof AuthorizeCallback) {
+                    System.out.println("AuthorizeCallback");
+                    ((AuthorizeCallback) callback).setAuthorized(true);
+                    if (authId == null || authId.trim().length() == 0) {
+                        authId = userId;
+                    }
+                    ((AuthorizeCallback) callback).setAuthorizedID(authId);
+                } else {
+                    throw new UnsupportedCallbackException(callback);
+                }
+            }
+        }
+    }
+
+}
diff --git a/hotspot/test/gc/8000311/Test8000311.java b/jdk/test/javax/xml/bind/jxc/8073872/Foo.java
similarity index 60%
copy from hotspot/test/gc/8000311/Test8000311.java
copy to jdk/test/javax/xml/bind/jxc/8073872/Foo.java
index 2c33191..9a2e3d6 100644
--- a/hotspot/test/gc/8000311/Test8000311.java
+++ b/jdk/test/javax/xml/bind/jxc/8073872/Foo.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 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
@@ -21,22 +21,25 @@
  * questions.
  */
 
-/**
- * @test Test8000311
- * @key gc
- * @bug 8000311
- * @summary G1: ParallelGCThreads==0 broken
- * @run main/othervm -XX:+UseG1GC -XX:ParallelGCThreads=0 -XX:+ResizePLAB -XX:+ExplicitGCInvokesConcurrent Test8000311
- * @author filipp.zhinkin@oracle.com
- */
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
 
-import java.util.*;
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {"fooObject"})
+@XmlRootElement(name = "Foo")
 
-public class Test8000311 {
-  public static void main(String args[]) {
-    for(int i = 0; i<100; i++) {
-      byte[] garbage = new byte[1000];
-      System.gc();
+public class Foo {
+
+    protected List<Foo> fooObject;
+
+    public List<Foo> getFooObject() {
+        if (fooObject == null) {
+            fooObject = new ArrayList<Foo>();
+        }
+        return this.fooObject;
     }
-  }
 }
diff --git a/jdk/test/javax/xml/bind/jxc/8073872/SchemagenStackOverflow.java b/jdk/test/javax/xml/bind/jxc/8073872/SchemagenStackOverflow.java
new file mode 100644
index 0000000..695fdef
--- /dev/null
+++ b/jdk/test/javax/xml/bind/jxc/8073872/SchemagenStackOverflow.java
@@ -0,0 +1,76 @@
+/*
+ * 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 8073872
+ * @summary test that stackoverflow is not observable when element
+ *          references containing class
+ * @compile Foo.java
+ * @run testng/othervm SchemagenStackOverflow
+ */
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.stream.Collectors;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.SchemaOutputResolver;
+import javax.xml.transform.Result;
+import javax.xml.transform.stream.StreamResult;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class SchemagenStackOverflow {
+
+    @Test
+    public void schemagenStackOverflowTest() throws Exception {
+        // Create new instance of JAXB context
+        JAXBContext context = JAXBContext.newInstance(Foo.class);
+        context.generateSchema(new TestOutputResolver());
+
+        // Read schema content from file
+        String content = Files.lines(resultSchemaFile).collect(Collectors.joining(""));
+        System.out.println("Generated schema content:" + content);
+
+        // Check if schema was generated: check class and list object names
+        Assert.assertTrue(content.contains("name=\"Foo\""));
+        Assert.assertTrue(content.contains("name=\"fooObject\""));
+    }
+
+    // Schemagen output resolver
+    class TestOutputResolver extends SchemaOutputResolver {
+        @Override
+        public Result createOutput(String namespaceUri, String fileName)
+                throws IOException {
+            return new StreamResult(resultSchemaFile.toFile());
+        }
+    }
+
+    // Schemagen output file name and path
+    static final String SCHEMA_FILENAME = "generatedSchema.xsd";
+    Path resultSchemaFile = Paths.get(System.getProperty("user.dir", "."))
+            .resolve(SCHEMA_FILENAME);
+
+}
diff --git a/jdk/test/javax/xml/bind/marshal/8134111/UnmarshalTest.java b/jdk/test/javax/xml/bind/marshal/8134111/UnmarshalTest.java
new file mode 100644
index 0000000..e1f595f
--- /dev/null
+++ b/jdk/test/javax/xml/bind/marshal/8134111/UnmarshalTest.java
@@ -0,0 +1,66 @@
+/*
+ * 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 8134111
+ * @summary test that elements without namespace is ignored by unmarshaller
+ *          when elementFormDefault is set to QUALIFIED.
+ * @compile testTypes/package-info.java testTypes/Root.java
+ *          testTypes/WhenType.java testTypes/ObjectFactory.java
+ * @run testng/othervm UnmarshalTest
+ */
+
+import java.io.StringReader;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+import org.testng.annotations.Test;
+import static org.testng.Assert.assertNull;
+import org.xml.sax.InputSource;
+import testTypes.Root;
+
+public class UnmarshalTest {
+
+    @Test
+    public void unmarshalUnexpectedNsTest() throws Exception {
+        JAXBContext context;
+        Unmarshaller unm;
+        // Create JAXB context from testTypes package
+        context = JAXBContext.newInstance("testTypes");
+        // Create unmarshaller from JAXB context
+        unm = context.createUnmarshaller();
+        // Unmarshall xml document with unqualified dtime element
+        Root r = (Root) unm.unmarshal(new InputSource(new StringReader(DOC)));
+        // Print dtime value and check if it is null
+        System.out.println("dtime is:"+r.getWhen().getDtime());
+        assertNull(r.getWhen().getDtime());
+    }
+
+    //Xml document to unmarshall with unqualified dtime element
+    private final String DOC =
+            "<tns:root xmlns:tns=\"http://www.example.org/testNamespace/\">" +
+            "<tns:when>" +
+            "<dtime>2015-06-24T13:16:14.933-04:00</dtime>" +
+            "</tns:when>" +
+            "</tns:root>";
+}
diff --git a/jdk/test/javax/xml/bind/marshal/8134111/testTypes/ObjectFactory.java b/jdk/test/javax/xml/bind/marshal/8134111/testTypes/ObjectFactory.java
new file mode 100644
index 0000000..5f93353
--- /dev/null
+++ b/jdk/test/javax/xml/bind/marshal/8134111/testTypes/ObjectFactory.java
@@ -0,0 +1,61 @@
+/*
+ * 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 testTypes;
+
+import javax.xml.bind.annotation.XmlRegistry;
+
+/**
+ * This object contains factory methods for each
+ * Java content interface and Java element interface
+ * generated in the testTypes package.
+ *
+ */
+@XmlRegistry
+public class ObjectFactory {
+
+    /**
+     * Create a new ObjectFactory that can be used to create
+     * new instances of schema derived classes for package: testTypes
+     *
+     */
+    public ObjectFactory() {
+    }
+
+    /**
+     * Create an instance of {@link Root }
+     *
+     */
+    public Root createRoot() {
+        return new Root();
+    }
+
+    /**
+     * Create an instance of {@link WhenType }
+     *
+     */
+    public WhenType createWhenType() {
+        return new WhenType();
+    }
+
+}
diff --git a/jdk/test/javax/xml/bind/marshal/8134111/testTypes/Root.java b/jdk/test/javax/xml/bind/marshal/8134111/testTypes/Root.java
new file mode 100644
index 0000000..d9b2335
--- /dev/null
+++ b/jdk/test/javax/xml/bind/marshal/8134111/testTypes/Root.java
@@ -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.
+ *
+ * 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 testTypes;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * <p>Java class for anonymous complex type.
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {"when"})
+@XmlRootElement(name = "root",
+                namespace = "http://www.example.org/testNamespace/")
+public class Root {
+
+    @XmlElement(required = true,
+                namespace = "http://www.example.org/testNamespace/")
+    protected WhenType when;
+
+    /**
+     * Gets the value of the when property.
+     *
+     * @return
+     *     possible object is
+     *     {@link WhenType }
+     *
+     */
+    public WhenType getWhen() {
+        return when;
+    }
+
+    /**
+     * Sets the value of the when property.
+     *
+     * @param value
+     *     allowed object is
+     *     {@link WhenType }
+     *
+     */
+    public void setWhen(WhenType value) {
+        this.when = value;
+    }
+
+}
diff --git a/jdk/test/javax/xml/bind/marshal/8134111/testTypes/WhenType.java b/jdk/test/javax/xml/bind/marshal/8134111/testTypes/WhenType.java
new file mode 100644
index 0000000..3e2b1b7
--- /dev/null
+++ b/jdk/test/javax/xml/bind/marshal/8134111/testTypes/WhenType.java
@@ -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.
+ *
+ * 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 testTypes;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.datatype.XMLGregorianCalendar;
+
+/**
+ * <p>Java class for WhenType complex type.
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "WhenType",
+         propOrder = {"dtime"})
+public class WhenType {
+
+    @XmlElement(required = true)
+    @XmlSchemaType(name = "dateTime")
+    protected XMLGregorianCalendar dtime;
+
+    /**
+     * Gets the value of the dtime property.
+     *
+     * @return
+     *     possible object is
+     *     {@link XMLGregorianCalendar }
+     *
+     */
+    public XMLGregorianCalendar getDtime() {
+        return dtime;
+    }
+
+    /**
+     * Sets the value of the dtime property.
+     *
+     * @param value
+     *     allowed object is
+     *     {@link XMLGregorianCalendar }
+     *
+     */
+    public void setDtime(XMLGregorianCalendar value) {
+        this.dtime = value;
+    }
+
+}
diff --git a/hotspot/test/gc/8000311/Test8000311.java b/jdk/test/javax/xml/bind/marshal/8134111/testTypes/package-info.java
similarity index 65%
copy from hotspot/test/gc/8000311/Test8000311.java
copy to jdk/test/javax/xml/bind/marshal/8134111/testTypes/package-info.java
index 2c33191..aedba8a 100644
--- a/hotspot/test/gc/8000311/Test8000311.java
+++ b/jdk/test/javax/xml/bind/marshal/8134111/testTypes/package-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 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
@@ -21,22 +21,7 @@
  * questions.
  */
 
-/**
- * @test Test8000311
- * @key gc
- * @bug 8000311
- * @summary G1: ParallelGCThreads==0 broken
- * @run main/othervm -XX:+UseG1GC -XX:ParallelGCThreads=0 -XX:+ResizePLAB -XX:+ExplicitGCInvokesConcurrent Test8000311
- * @author filipp.zhinkin@oracle.com
- */
-
-import java.util.*;
-
-public class Test8000311 {
-  public static void main(String args[]) {
-    for(int i = 0; i<100; i++) {
-      byte[] garbage = new byte[1000];
-      System.gc();
-    }
-  }
-}
+@javax.xml.bind.annotation.XmlSchema(
+        namespace = "http://www.example.org/testNamespace/",
+        elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
+package testTypes;
diff --git a/jdk/test/javax/xml/bind/xjc/8145039/JaxbMarshallTest.java b/jdk/test/javax/xml/bind/xjc/8145039/JaxbMarshallTest.java
new file mode 100644
index 0000000..7de90ad
--- /dev/null
+++ b/jdk/test/javax/xml/bind/xjc/8145039/JaxbMarshallTest.java
@@ -0,0 +1,157 @@
+/*
+ * 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.
+ * @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;
+}
diff --git a/jdk/test/javax/xml/bind/xjc/8145039/testSchema.xsd b/jdk/test/javax/xml/bind/xjc/8145039/testSchema.xsd
new file mode 100644
index 0000000..f625d06
--- /dev/null
+++ b/jdk/test/javax/xml/bind/xjc/8145039/testSchema.xsd
@@ -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>
diff --git a/jdk/test/javax/xml/crypto/dsig/ValidationTests.java b/jdk/test/javax/xml/crypto/dsig/ValidationTests.java
index 5a86692..278d64c 100644
--- a/jdk/test/javax/xml/crypto/dsig/ValidationTests.java
+++ b/jdk/test/javax/xml/crypto/dsig/ValidationTests.java
@@ -35,6 +35,7 @@
 import java.security.*;
 import javax.xml.crypto.Data;
 import javax.xml.crypto.KeySelector;
+import javax.xml.crypto.MarshalException;
 import javax.xml.crypto.OctetStreamData;
 import javax.xml.crypto.URIDereferencer;
 import javax.xml.crypto.URIReference;
@@ -60,9 +61,17 @@
     static class Test {
         String file;
         KeySelector ks;
-        Test(String file, KeySelector ks) {
+        Class exception;
+
+        Test(String file, KeySelector ks, Class exception) {
             this.file = file;
             this.ks = ks;
+            this.exception = exception;
+        }
+
+        // XMLSignatureException is expected by default
+        Test(String file, KeySelector ks) {
+            this(file, ks, XMLSignatureException.class);
         }
     }
 
@@ -109,7 +118,17 @@
     private final static Test[] INVALID_TESTS = {
         new Test("signature-enveloping-hmac-sha1-40.xml", SKKS),
         new Test("signature-enveloping-hmac-sha1-trunclen-0-attack.xml", SKKS),
-        new Test("signature-enveloping-hmac-sha1-trunclen-8-attack.xml", SKKS)
+        new Test("signature-enveloping-hmac-sha1-trunclen-8-attack.xml", SKKS),
+        new Test("signature-extra-text-in-signed-info.xml", SKKS,
+                MarshalException.class),
+        new Test("signature-wrong-canonicalization-method-algorithm.xml", SKKS,
+                MarshalException.class),
+        new Test("signature-wrong-transform-algorithm.xml", SKKS,
+                MarshalException.class),
+        new Test("signature-no-reference-uri.xml", SKKS),
+        new Test("signature-wrong-signature-method-algorithm.xml", SKKS,
+                MarshalException.class),
+        new Test("signature-wrong-tag-names.xml", SKKS, MarshalException.class)
     };
 
     public static void main(String args[]) throws Exception {
@@ -142,9 +161,14 @@
                 test_signature(test);
                 System.out.println("FAILED");
                 atLeastOneFailed = true;
-            } catch (XMLSignatureException xse) {
-                System.out.println(xse.getMessage());
-                System.out.println("PASSED");
+            } catch (Exception e) {
+                System.out.println("Exception: " + e);
+                if (e.getClass() != test.exception) {
+                    System.out.println("FAILED: unexpected exception");
+                    atLeastOneFailed = true;
+                } else {
+                    System.out.println("PASSED");
+                }
             }
         }
 
diff --git a/jdk/test/javax/xml/crypto/dsig/data/signature-extra-text-in-signed-info.xml b/jdk/test/javax/xml/crypto/dsig/data/signature-extra-text-in-signed-info.xml
new file mode 100644
index 0000000..578e7bb
--- /dev/null
+++ b/jdk/test/javax/xml/crypto/dsig/data/signature-extra-text-in-signed-info.xml
@@ -0,0 +1,3 @@
+<test xmlns="http://example.org/envelope">test<Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo xmlns="http://www.w3.org/2000/09/xmldsig#"><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"></CanonicalizationMethod><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"></SignatureMethod><Reference URI=""><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"></Transform></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></DigestMethod><DigestValue>1Bq8FsjajUBYPD7stQeJSc66GlM=</DigestValue><test>extra text</test></Reference></SignedInfo><SignatureValue>iTrgJERmYeD5hFwY8/MwJpkF+nd++AAOgf/Kxt9SwdE6BIYq2Vyxq4CQPhD+t2971BGTgvF6ejZd
++/Ko4Zs5Dqf4Lt65Vck0q43rM0PdP1e8gJov0IPYnZ1zeqFpah+N/OjmqTbshaZWRIjf3eqS6en5
+ZKjn+TkCQ1kOX/YUNDc=</SignatureValue></Signature></test>
\ No newline at end of file
diff --git a/jdk/test/javax/xml/crypto/dsig/data/signature-no-reference-uri.xml b/jdk/test/javax/xml/crypto/dsig/data/signature-no-reference-uri.xml
new file mode 100644
index 0000000..eb199f7
--- /dev/null
+++ b/jdk/test/javax/xml/crypto/dsig/data/signature-no-reference-uri.xml
@@ -0,0 +1,3 @@
+<test xmlns="http://example.org/envelope">test<Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo xmlns="http://www.w3.org/2000/09/xmldsig#"><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"></CanonicalizationMethod><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"></SignatureMethod><Reference><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"></Transform></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></DigestMethod><DigestValue>1Bq8FsjajUBYPD7stQeJSc66GlM=</DigestValue></Reference></SignedInfo><SignatureValue>BNPSYlNcyXcO/Tc1tr9mQ/KAZ40eFybLTDyB/HH1EHHMpc972A+nOX2EWBaLsVgG8apl0Isp1ZqV
+gmoDHNF6xrcJJQVydVJzU08GVV4GiXHMqRYQbted7STQLhlhssvNNdMEoVApsX5ByL66wxKZQXrT
+z1kZtOHAi88DOrmIJu0=</SignatureValue></Signature></test>
\ No newline at end of file
diff --git a/jdk/test/javax/xml/crypto/dsig/data/signature-wrong-canonicalization-method-algorithm.xml b/jdk/test/javax/xml/crypto/dsig/data/signature-wrong-canonicalization-method-algorithm.xml
new file mode 100644
index 0000000..2ce430e
--- /dev/null
+++ b/jdk/test/javax/xml/crypto/dsig/data/signature-wrong-canonicalization-method-algorithm.xml
@@ -0,0 +1,3 @@
+<test xmlns="http://example.org/envelope">test<Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo xmlns="http://www.w3.org/2000/09/xmldsig#"><CanonicalizationMethod Algorithm="http://oracle.com"></CanonicalizationMethod><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"></SignatureMethod><Reference URI=""><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"></Transform></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></DigestMethod><DigestValue>1Bq8FsjajUBYPD7stQeJSc66GlM=</DigestValue></Reference></SignedInfo><SignatureValue>EBbyEV7e+1CTUsyCTyxiN8p+U3/za1oTjK7q+kF8Q87r8e/7C1z4ndGWbk6zyI3w6leT+I2suW9U
+KkdvkrDXX2OyLw0GfgJfLkNn+1pGK6kyWpL95NoWJZhHkUAKKBZ0ikfZ4j33gYxrYK+IYCLeZYzr
+hlZjdXXXCiSH0Sq+weQ=</SignatureValue></Signature></test>
\ No newline at end of file
diff --git a/jdk/test/javax/xml/crypto/dsig/data/signature-wrong-signature-method-algorithm.xml b/jdk/test/javax/xml/crypto/dsig/data/signature-wrong-signature-method-algorithm.xml
new file mode 100644
index 0000000..a2709ca
--- /dev/null
+++ b/jdk/test/javax/xml/crypto/dsig/data/signature-wrong-signature-method-algorithm.xml
@@ -0,0 +1,3 @@
+<test xmlns="http://example.org/envelope">test<Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo xmlns="http://www.w3.org/2000/09/xmldsig#"><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"></CanonicalizationMethod><SignatureMethod Algorithm="bogus://bogus"></SignatureMethod><Reference URI=""><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"></Transform></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></DigestMethod><DigestValue>1Bq8FsjajUBYPD7stQeJSc66GlM=</DigestValue></Reference></SignedInfo><SignatureValue>RjL9nfQg9u6+KEFfAlBBH7E7ilFgB7YEQ5MxOIJN/fOdQmc5iDD+YuhiHzNGXGi/UOyo6t8LxTxl
+X4oFE1RNlPVkSAZK4LcTWhVa757WwgW1/EZo8PQYWp5NScLq6PumYaujoovSYBKW2N6+jQpnD/L6
+4cuEVNnwEFqvOLrjogY=</SignatureValue></Signature></test>
\ No newline at end of file
diff --git a/jdk/test/javax/xml/crypto/dsig/data/signature-wrong-tag-names.xml b/jdk/test/javax/xml/crypto/dsig/data/signature-wrong-tag-names.xml
new file mode 100644
index 0000000..152eb79
--- /dev/null
+++ b/jdk/test/javax/xml/crypto/dsig/data/signature-wrong-tag-names.xml
@@ -0,0 +1,3 @@
+<test xmlns="http://example.org/envelope">test<Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><aSignedInfo xmlns="http://www.w3.org/2000/09/xmldsig#"><aCanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"></aCanonicalizationMethod><aSignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"></aSignatureMethod><aReference URI=""><Transforms><aTransform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"></aTransform></Transforms><aDigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></aDigestMethod><aDigestValue>1Bq8FsjajUBYPD7stQeJSc66GlM=</aDigestValue></aReference></aSignedInfo><aSignatureValue>cbNpPGavhM0BGUtrvLxvy2SCIt+I27BPpVEt0Q9mXrdPYurMqWF/67AdY9m5RqS7+ZZlwUtem083
+MczRYbKoOIq7sMbCqKKdzbSE/U6rfmky/ACQ5wgemZl8jtipwu5LhAUzjhzT8hhTjVqOYpHdkVJz
+l9dnd9eWbLmEr3BI0VA=</aSignatureValue></Signature></test>
\ No newline at end of file
diff --git a/jdk/test/javax/xml/crypto/dsig/data/signature-wrong-transform-algorithm.xml b/jdk/test/javax/xml/crypto/dsig/data/signature-wrong-transform-algorithm.xml
new file mode 100644
index 0000000..a64abc7
--- /dev/null
+++ b/jdk/test/javax/xml/crypto/dsig/data/signature-wrong-transform-algorithm.xml
@@ -0,0 +1,4 @@
+<!-- This XML signature contains a Transform with wrong algorithm -->
+<test xmlns="http://example.org/envelope">test<Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo xmlns="http://www.w3.org/2000/09/xmldsig#"><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"></CanonicalizationMethod><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"></SignatureMethod><Reference URI=""><Transforms><Transform Algorithm="bogus://bogus"></Transform></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></DigestMethod><DigestValue>1Bq8FsjajUBYPD7stQeJSc66GlM=</DigestValue></Reference></SignedInfo><SignatureValue>Wzyx3jgEKGwY+pBXBmqWLWhASHQYCCGZVii5sKKKeZUBKxNBthjiSVfzKANuLgX6zAt16XRycrSL
+zFKTPuvGeWVPDvd+KTNKCJxN9ccrG7v23EM7RY2eMJGu2r5DLfKwV7H6YuJPsOuWifVkKAhvq7gd
+6akJshxyAj9Ud+mjo48=</SignatureValue></Signature></test>
\ No newline at end of file
diff --git a/jdk/test/javax/xml/jaxp/common/8144593/TestSAXDriver.java b/jdk/test/javax/xml/jaxp/common/8144593/TestSAXDriver.java
new file mode 100644
index 0000000..627fe1a
--- /dev/null
+++ b/jdk/test/javax/xml/jaxp/common/8144593/TestSAXDriver.java
@@ -0,0 +1,56 @@
+/*
+ * 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 com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl;
+import javax.xml.XMLConstants;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
+
+/*
+ * Test implementation of SAXParser. It is extended from JDK parser and two methods
+ * are overriden to disable support of specific features and properties.
+ * This class is used in ValidationWarningsTest and TransformationWarningsTest
+ * to generate multiple warnings during xml validation and transformation processes.
+*/
+public class TestSAXDriver extends SAXParserImpl.JAXPSAXParser {
+
+    @Override
+    public synchronized void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException {
+        if (XMLConstants.FEATURE_SECURE_PROCESSING.equals(name)) {
+            throw new SAXNotRecognizedException(name+" feature is not recognised by test SAX parser intentionally.");
+        } else {
+            super.setFeature(name, value);
+        }
+    }
+
+    @Override
+    public synchronized void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException {
+        if (XMLConstants.ACCESS_EXTERNAL_DTD.equals(name) || ENT_EXP_LIMIT_PROP.equals(name)) {
+            throw new SAXNotRecognizedException(name+" property is not recognised by test SAX parser intentionally.");
+        } else {
+            super.setProperty(name, value);
+        }
+    }
+
+    private static final String ENT_EXP_LIMIT_PROP = "http://www.oracle.com/xml/jaxp/properties/entityExpansionLimit";
+}
diff --git a/jdk/test/javax/xml/jaxp/common/8144593/TransformationWarningsTest.java b/jdk/test/javax/xml/jaxp/common/8144593/TransformationWarningsTest.java
new file mode 100644
index 0000000..71c3ed1
--- /dev/null
+++ b/jdk/test/javax/xml/jaxp/common/8144593/TransformationWarningsTest.java
@@ -0,0 +1,92 @@
+/*
+ * 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.StringReader;
+import java.io.StringWriter;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeClass;
+
+/*
+ * @test
+ * @bug 8144593
+ * @summary Check that warnings about unsupported properties from parsers
+ * are suppressed during the transformation process.
+ * @compile -XDignore.symbol.file TestSAXDriver.java
+ * @run testng/othervm TransformationWarningsTest
+ */
+public class TransformationWarningsTest extends WarningsTestBase {
+
+    @BeforeClass
+    public void setup() {
+        //Set test SAX driver implementation.
+        System.setProperty("org.xml.sax.driver", "TestSAXDriver");
+    }
+
+    @Test
+    public void testTransformation() throws Exception {
+        startTest();
+    }
+
+    //One iteration of xml transformation test case. It will be called from each
+    //TestWorker task defined in WarningsTestBase class.
+    void doOneTestIteration() throws Exception {
+        // Prepare output stream
+        StringWriter xmlResultString = new StringWriter();
+        StreamResult xmlResultStream = new StreamResult(xmlResultString);
+        // Prepare xml source stream
+        Source src = new StreamSource(new StringReader(xml));
+        Transformer t = createTransformer();
+        //Transform the xml
+        t.transform(src, xmlResultStream);
+    }
+
+    //Create transformer from xsl test string
+    Transformer createTransformer() throws Exception {
+        // Prepare sources for transormation
+        Source xslsrc = new StreamSource(new StringReader(xsl));
+
+        // Create factory and transformer
+        TransformerFactory tf = TransformerFactory.newInstance();
+        Transformer t = tf.newTransformer(xslsrc);
+
+        // Set URI Resolver to return the newly constructed xml
+        // stream source object from xml test string
+        t.setURIResolver((String href, String base) -> new StreamSource(new StringReader(xml)));
+        return t;
+    }
+
+    //Xsl and Xml contents used in the transformation test
+    private static final String xsl = "<xsl:stylesheet version='2.0'"
+            + " xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>"
+            + " <xsl:output method='xml' indent='yes' omit-xml-declaration='yes'/>"
+            + " <xsl:template match='/'>"
+            + " <test>Simple Transformation Result. No warnings should be printed to console</test>"
+            + " </xsl:template>"
+            + "</xsl:stylesheet>";
+    private static final String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><root></root>";
+}
diff --git a/jdk/test/javax/xml/jaxp/common/8144593/ValidationWarningsTest.java b/jdk/test/javax/xml/jaxp/common/8144593/ValidationWarningsTest.java
new file mode 100644
index 0000000..28c003c
--- /dev/null
+++ b/jdk/test/javax/xml/jaxp/common/8144593/ValidationWarningsTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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.ByteArrayInputStream;
+import java.io.StringReader;
+import javax.xml.XMLConstants;
+import javax.xml.transform.Source;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.Validator;
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeClass;
+import org.xml.sax.InputSource;
+
+/*
+ * @test
+ * @bug 8144593
+ * @summary Check that warnings about unsupported properties from SAX
+ *  parsers are suppressed during the xml validation process.
+ * @compile -XDignore.symbol.file TestSAXDriver.java
+ * @run testng/othervm ValidationWarningsTest
+ */
+public class ValidationWarningsTest extends WarningsTestBase {
+
+    @BeforeClass
+    public void setup() {
+        //Set test SAX driver implementation.
+        System.setProperty("org.xml.sax.driver", "TestSAXDriver");
+    }
+
+    @Test
+    public void testValidation() throws Exception {
+        startTest();
+    }
+
+    //One iteration of xml validation test case. It will be called from each
+    //TestWorker task defined in WarningsTestBase class.
+    void doOneTestIteration() throws Exception {
+        Source src = new StreamSource(new StringReader(xml));
+        SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+        SAXSource xsdSource = new SAXSource(new InputSource(new ByteArrayInputStream(xsd.getBytes())));
+        Schema schema = schemaFactory.newSchema(xsdSource);
+        Validator v = schema.newValidator();
+        v.validate(src);
+    }
+
+    //Xsd and Xml contents used in the validation test
+    private static final String xsd = "<?xml version='1.0'?>"
+            + " <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>"
+            + " <xs:element name='test' type='xs:string'/>\n"
+            + " </xs:schema>";
+    private static final String xml = "<?xml version='1.0'?><test>Element</test>";
+
+}
diff --git a/jdk/test/javax/xml/jaxp/common/8144593/WarningsTestBase.java b/jdk/test/javax/xml/jaxp/common/8144593/WarningsTestBase.java
new file mode 100644
index 0000000..7f31f62
--- /dev/null
+++ b/jdk/test/javax/xml/jaxp/common/8144593/WarningsTestBase.java
@@ -0,0 +1,134 @@
+/*
+ * 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.PrintStream;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import javax.xml.XMLConstants;
+import org.testng.Assert;
+
+/*
+ * This class helps to test suppression of unsupported parser properties
+ * messages printed to standard error output.
+ * It launches THREADS_COUNT tasks. Each task does ITERATIONS_PER_THREAD
+ * sequential calls to doOneIteration method implemented by specific test class.
+ */
+public abstract class WarningsTestBase {
+
+    /*
+     * Abstract method that should be implemented by test class.
+     * It is repeatedly called by each TestWorker task.
+     */
+    abstract void doOneTestIteration() throws Exception;
+
+    /*
+     * Launches parallel test tasks and check the output for the number of
+     * generated warning messages. There should be no more than one message of
+     * each type.
+     */
+    void startTest() throws Exception {
+        //Save standard error stream
+        PrintStream defStdErr = System.err;
+        //Set new byte array stream as standard error stream
+        ByteArrayOutputStream byteStream = new ByteArrayOutputStream(5000);
+        System.setErr(new PrintStream(byteStream));
+        //Execute multiple TestWorker tasks
+        for (int id = 0; id < THREADS_COUNT; id++) {
+            EXECUTOR.execute(new TestWorker(id));
+        }
+        //Initiate shutdown of previously submitted task
+        EXECUTOR.shutdown();
+        //Wait for termination of submitted tasks
+        if (!EXECUTOR.awaitTermination(THREADS_COUNT, TimeUnit.SECONDS)) {
+            //If not all tasks terminates during the time out force them to shutdown
+            EXECUTOR.shutdownNow();
+        }
+        //Restore default standard error stream
+        System.setErr(defStdErr);
+        //Print tasks stderr output
+        String errContent = byteStream.toString();
+        System.out.println("Standard error output content:");
+        System.out.println(errContent);
+        //Check tasks stderr output for quatity of warning messages
+        Assert.assertTrue(warningPrintedOnce(XMLConstants.ACCESS_EXTERNAL_DTD, errContent));
+        Assert.assertTrue(warningPrintedOnce(ENT_EXP_PROPERTY, errContent));
+        Assert.assertTrue(warningPrintedOnce(XMLConstants.FEATURE_SECURE_PROCESSING, errContent));
+    }
+
+    // Count occurences of warning messages in standard error and check if warning is printed
+    // not more than once
+    private boolean warningPrintedOnce(String propertyName, String testOutput) {
+        //Count for property name in test output
+        Pattern p = Pattern.compile(propertyName);
+        Matcher m = p.matcher(testOutput);
+        int count = 0;
+        while (m.find()) {
+            count += 1;
+        }
+        System.out.println("'" + propertyName + "' print count: " + count);
+        //If count is more than 1 then consider test failed
+        return count <= 1;
+    }
+
+    //TestWorker task that sequentially calls test method
+    private class TestWorker implements Runnable {
+        // Task id
+        private final int id;
+
+        TestWorker(int id) {
+            this.id = id;
+        }
+
+        @Override
+        public void run() {
+            try {
+                System.out.printf("%d: waiting for barrier%n", id);
+                //Synchronize startup of all tasks
+                BARRIER.await();
+                System.out.printf("%d: starting iterations%n", id);
+                //Call test method multiple times
+                for (int i = 0; i < ITERATIONS_PER_THREAD; i++) {
+                    doOneTestIteration();
+                }
+            } catch (Exception ex) {
+                throw new RuntimeException("TestWorker id:" + id + " failed", ex);
+            }
+        }
+    }
+
+    //Entity expansion limit property name
+    private static final String ENT_EXP_PROPERTY = "http://www.oracle.com/xml/jaxp/properties/entityExpansionLimit";
+    //Number of simultaneous test threads
+    private static final int THREADS_COUNT = 10;
+    //Number of iterations per one thread
+    private static final int ITERATIONS_PER_THREAD = 4;
+    //Test thread pool
+    private static final ExecutorService EXECUTOR = Executors.newCachedThreadPool();
+    //Cyclic barrier for threads startup synchronisation
+    private static final CyclicBarrier BARRIER = new CyclicBarrier(THREADS_COUNT);
+}
diff --git a/jdk/test/javax/xml/jaxp/parsers/8072081/SupplementaryChars.java b/jdk/test/javax/xml/jaxp/parsers/8072081/SupplementaryChars.java
new file mode 100644
index 0000000..288a96b
--- /dev/null
+++ b/jdk/test/javax/xml/jaxp/parsers/8072081/SupplementaryChars.java
@@ -0,0 +1,91 @@
+/*
+ * 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.
+ */
+
+import java.io.ByteArrayInputStream;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * @test
+ * @bug 8072081
+ * @summary verifies that supplementary characters are supported as character
+ * data in xml 1.0, and also names in xml 1.1.
+ * @run testng/othervm SupplementaryChars
+ */
+/*
+ * Joe Wang (huizhe.wang@oracle.com)
+ */
+
+public class SupplementaryChars {
+
+    @Test(dataProvider = "supported")
+    public void test(String xml) throws Exception {
+        ByteArrayInputStream stream = new ByteArrayInputStream(xml.getBytes("UTF-8"));
+        getParser().parse(stream, new DefaultHandler());
+        stream.close();
+    }
+
+    @Test(dataProvider = "unsupported", expectedExceptions = SAXParseException.class)
+    public void testInvalid(String xml) throws Exception {
+        ByteArrayInputStream stream = new ByteArrayInputStream(xml.getBytes("UTF-8"));
+        getParser().parse(stream, new DefaultHandler());
+        stream.close();
+    }
+
+    @DataProvider(name = "supported")
+    private Object[][] supported() {
+
+        return new Object[][] {
+            {"<?xml version=\"1.0\"?><tag>\uD840\uDC0B</tag>"},
+            {"<?xml version=\"1.0\"?><!-- \uD840\uDC0B --><tag/>"},
+            {"<?xml version=\"1.1\"?><tag\uD840\uDC0B>in tag name</tag\uD840\uDC0B>"},
+            {"<?xml version=\"1.1\"?><tag attr\uD840\uDC0B=\"in attribute\">in attribute name</tag>"},
+            {"<?xml version=\"1.1\"?><tag>\uD840\uDC0B</tag>"},
+            {"<?xml version=\"1.1\"?><!-- \uD840\uDC0B --><dontCare/>"}
+        };
+    }
+
+    @DataProvider(name = "unsupported")
+    private Object[][] unsupported() {
+        return new Object[][] {
+            {"<?xml version=\"1.0\"?><tag\uD840\uDC0B>in tag name</tag\uD840\uDC0B>"},
+            {"<?xml version=\"1.0\"?><tag attr\uD840\uDC0B=\"in attribute\">in attribute name</tag>"}
+        };
+    }
+
+    private SAXParser getParser() {
+        SAXParser parser = null;
+        try {
+            SAXParserFactory factory = SAXParserFactory.newInstance();
+            parser = factory.newSAXParser();
+        } catch (Exception e) {
+            throw new RuntimeException(e.getMessage());
+        }
+        return parser;
+    }
+}
diff --git a/jdk/test/javax/xml/jaxp/stream/8145974/SurrogatesTest.java b/jdk/test/javax/xml/jaxp/stream/8145974/SurrogatesTest.java
new file mode 100644
index 0000000..9dcaa15
--- /dev/null
+++ b/jdk/test/javax/xml/jaxp/stream/8145974/SurrogatesTest.java
@@ -0,0 +1,169 @@
+/*
+ * 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.
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+import org.testng.annotations.DataProvider;
+
+/*
+ * @test
+ * @bug 8145974
+ * @run testng/othervm SurrogatesTest
+ * @summary Check that XMLStreamWriter generates valid xml with surrogate pair
+ *  used within element text
+ */
+
+public class SurrogatesTest {
+
+    // Test that valid surrogate characters can be written/readen by xml stream
+    // reader/writer
+    @Test(dataProvider = "validData")
+    public void xmlWithValidSurrogatesTest(String content)
+            throws Exception {
+        generateAndReadXml(content);
+    }
+
+    // Test that unbalanced surrogate character will
+    @Test(dataProvider = "invalidData",
+            expectedExceptions = XMLStreamException.class)
+    public void xmlWithUnbalancedSurrogatesTest(String content)
+            throws Exception {
+        generateAndReadXml(content);
+    }
+
+    // Generates xml content with XMLStreamWriter and read it to check
+    // for correctness of xml and generated data
+    void generateAndReadXml(String content) throws Exception {
+        ByteArrayOutputStream stream = new ByteArrayOutputStream();
+        XMLOutputFactory factory = XMLOutputFactory.newInstance();
+        OutputStreamWriter streamWriter = new OutputStreamWriter(stream);
+        XMLStreamWriter writer = factory.createXMLStreamWriter(streamWriter);
+
+        // Generate xml with selected stream writer type
+        generateXML(writer, content);
+        String output = stream.toString();
+        System.out.println("Generated xml: " + output);
+        // Read generated xml with StAX parser
+        readXML(output.getBytes(), content);
+    }
+
+    // Generates XML with provided xml stream writer. Provided string
+    // is inserted into xml twice: with usage of writeCharacters( String )
+    // and writeCharacters( char [], int , int )
+    private void generateXML(XMLStreamWriter writer, String sequence)
+            throws XMLStreamException {
+        char[] seqArr = sequence.toCharArray();
+        writer.writeStartDocument();
+        writer.writeStartElement("root");
+
+        // Use writeCharacters( String ) to write characters
+        writer.writeStartElement("writeCharactersWithString");
+        writer.writeCharacters(sequence);
+        writer.writeEndElement();
+
+        // Use writeCharacters( char [], int , int ) to write characters
+        writer.writeStartElement("writeCharactersWithArray");
+        writer.writeCharacters(seqArr, 0, seqArr.length);
+        writer.writeEndElement();
+
+        // Close root element and document
+        writer.writeEndElement();
+        writer.writeEndDocument();
+        writer.flush();
+        writer.close();
+    }
+
+    // Reads generated XML data and check if it contains expected
+    // text in writeCharactersWithString and writeCharactersWithArray
+    // elements
+    private void readXML(byte[] xmlData, String expectedContent)
+            throws Exception {
+        InputStream stream = new ByteArrayInputStream(xmlData);
+        XMLInputFactory factory = XMLInputFactory.newInstance();
+        XMLStreamReader xmlReader
+                = factory.createXMLStreamReader(stream);
+        boolean inTestElement = false;
+        StringBuilder sb = new StringBuilder();
+        while (xmlReader.hasNext()) {
+            String ename;
+            switch (xmlReader.getEventType()) {
+                case XMLStreamConstants.START_ELEMENT:
+                    ename = xmlReader.getLocalName();
+                    if (ename.equals("writeCharactersWithString")
+                            || ename.equals("writeCharactersWithArray")) {
+                        inTestElement = true;
+                    }
+                    break;
+                case XMLStreamConstants.END_ELEMENT:
+                    ename = xmlReader.getLocalName();
+                    if (ename.equals("writeCharactersWithString")
+                            || ename.equals("writeCharactersWithArray")) {
+                        inTestElement = false;
+                        String content = sb.toString();
+                        System.out.println(ename + " text:'" + content + "' expected:'" + expectedContent+"'");
+                        Assert.assertEquals(content, expectedContent);
+                        sb.setLength(0);
+                    }
+                    break;
+                case XMLStreamConstants.CHARACTERS:
+                    if (inTestElement) {
+                        sb.append(xmlReader.getText());
+                    }
+                    break;
+            }
+            xmlReader.next();
+        }
+    }
+
+    @DataProvider(name = "validData")
+    Object[][] getValidData() {
+        return new Object[][] {
+            {"Don't Worry Be \uD83D\uDE0A"},
+            {"BMP characters \uE000\uFFFD"},
+            {"Simple text"},
+        };
+    }
+
+    @DataProvider(name = "invalidData")
+    Object[][] getInvalidData() {
+        return new Object[][] {
+            {"Unbalanced surrogate \uD83D"},
+            {"Unbalanced surrogate \uD83Dis here"},
+            {"Surrogate with followup BMP\uD83D\uFFF9"},
+        };
+    }
+}
diff --git a/jdk/test/javax/xml/jaxp/transform/8150704/Bug8150704-1.ref b/jdk/test/javax/xml/jaxp/transform/8150704/Bug8150704-1.ref
new file mode 100644
index 0000000..0af2588
--- /dev/null
+++ b/jdk/test/javax/xml/jaxp/transform/8150704/Bug8150704-1.ref
@@ -0,0 +1 @@
+................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
diff --git a/jdk/test/javax/xml/jaxp/transform/8150704/Bug8150704-1.xml b/jdk/test/javax/xml/jaxp/transform/8150704/Bug8150704-1.xml
new file mode 100644
index 0000000..382a25f
--- /dev/null
+++ b/jdk/test/javax/xml/jaxp/transform/8150704/Bug8150704-1.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<element>
+  <text>.</text>
+</element>
diff --git a/jdk/test/javax/xml/jaxp/transform/8150704/Bug8150704-1.xsl b/jdk/test/javax/xml/jaxp/transform/8150704/Bug8150704-1.xsl
new file mode 100644
index 0000000..f390323
--- /dev/null
+++ b/jdk/test/javax/xml/jaxp/transform/8150704/Bug8150704-1.xsl
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+  <xsl:output method="text"/>
+
+  <xsl:template match="/">
+    <xsl:call-template name="recurse1">
+      <xsl:with-param name="num">
+        <xsl:value-of select="0"/>
+      </xsl:with-param>
+    </xsl:call-template>
+    <xsl:text>&#xa;</xsl:text>
+  </xsl:template>
+
+  <xsl:template name="recurse1">
+    <xsl:param name="num"/>
+    <xsl:call-template name="recurse2">
+      <xsl:with-param name="num" select="0"/>
+    </xsl:call-template>
+    <xsl:if test="not($num = 19)">
+      <xsl:variable name="tmpnumber"><xsl:value-of select="$num + 1"/></xsl:variable>
+      <xsl:call-template name="recurse1">
+        <xsl:with-param name="num">
+          <xsl:value-of select="$tmpnumber"/>
+        </xsl:with-param>
+      </xsl:call-template>
+    </xsl:if>
+  </xsl:template>
+
+  <xsl:template name="recurse2">
+    <xsl:param name="num"/>
+    <xsl:call-template name="recursefinal">
+      <xsl:with-param name="num" select="0"/>
+    </xsl:call-template>
+    <xsl:if test="not($num = 19)">
+      <xsl:variable name="tmpnumber"><xsl:value-of select="$num + 1"/></xsl:variable>
+      <xsl:call-template name="recurse2">
+        <xsl:with-param name="num" select="$tmpnumber"/>
+      </xsl:call-template>
+    </xsl:if>
+  </xsl:template>
+
+  <xsl:template name="recursefinal">
+    <xsl:param name="num"/>
+    <xsl:call-template name="dodot"/>
+    <xsl:call-template name="dodot"/>
+    <xsl:call-template name="dodot"/>
+    <xsl:call-template name="dodot"/>
+    <xsl:call-template name="dodot"/>
+    <xsl:call-template name="dodot"/>
+    <xsl:call-template name="dodot"/>
+    <xsl:call-template name="dodot"/>
+    <xsl:call-template name="dodot"/>
+    <xsl:call-template name="dodot"/>
+    <xsl:call-template name="dodot"/>
+    <xsl:call-template name="dodot"/>
+    <xsl:call-template name="dodot"/>
+    <xsl:call-template name="dodot"/>
+    <xsl:call-template name="dodot"/>
+    <xsl:if test="not($num = 10)">
+      <xsl:variable name="tmpnumber"><xsl:value-of select="$num + 1"/></xsl:variable>
+      <xsl:call-template name="recursefinal">
+        <xsl:with-param name="num" select="$tmpnumber"/>
+      </xsl:call-template>
+    </xsl:if>
+  </xsl:template>
+
+  <xsl:template name="dodot">
+    <xsl:variable name="ElementTexts">
+      <xsl:for-each select="element">
+        <xsl:value-of select="text"/>
+      </xsl:for-each>
+    </xsl:variable>
+    <xsl:value-of select="$ElementTexts"/>
+  </xsl:template>
+</xsl:stylesheet>
diff --git a/jdk/test/javax/xml/jaxp/transform/8150704/Bug8150704-2.ref b/jdk/test/javax/xml/jaxp/transform/8150704/Bug8150704-2.ref
new file mode 100644
index 0000000..b012e31
--- /dev/null
+++ b/jdk/test/javax/xml/jaxp/transform/8150704/Bug8150704-2.ref
@@ -0,0 +1,83 @@
+0fto-erech   200amos-batch  00000000X/
+1FB01                20150709  EWF 2016021207USD  0000,9302122026623  ////////91284422        ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000007366,71////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////D8OOoOOooooOoooooO////15/07 P0480715                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////40090597         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150630  EWF 2016021206USD  0000,9302122026624  ////////1500006837      ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000003844,00////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////b3oooooooooooooooo////15/07 R1683315                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////40127254         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150709  EWF 2016021207CHF  0001,0000022026625  ////////94043801        ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000000438,50////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////0CooOooooooooooOOo////15/07 P0472115                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////30092874         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150702  EWF 2016021207EUR  0001,0468822026626  ////////TL152062        ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000000661,30////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////3coooooooooooooooo////15/07 P0431815                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////40099751         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150617  EWF 2016021206EUR  0001,0468822026627  ////////TKL100216       ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000000699,92////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////55oooooOoOooooOoOo////15/07 L0032815                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////2014686          ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150702  EWF 2016021207EUR  0001,0468822026628  ////////TL152063        ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000001983,00////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////9boooooooooooooooo////15/07 P0431815                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////40099751         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150713  EWF 2016021207EUR  0001,0468822026629  ////////000359084       ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000002230,76////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////51oOoOoOoOoooooOOO////15/07 R1735915                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////40128088         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150708  EWF 2016021207CHF  0001,0000022026630  ////////90864081        ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000001893,20////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////acoooooooooooooooo////15/07 P0470615                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////30090668         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150708  EWF 2016021207USD  0000,9302122026631  ////////123939          ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000007896,34////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////09oooooooooooooooo////15/07 P0400015                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////40128846         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150707  EWF 2016021207USD  0000,9302122026633  ////////000358117       ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000006810,00////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////f5oooooooooooooooo////15/07 P0462815                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////40128088         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150713  EWF 2016021207CHF  0001,0000022026635  ////////M90257500       ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000016300,50////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////C3oOOOooOoOooOOOoo////15/07 R1488615                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////30124373         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150713  EWF 2016021207USD  0000,9302122026637  ////////M90257457       ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000000831,90////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////60ooooOooOOOoOoOoo////15/07 P0463815                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////30124373         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         40///////////////0000000000055,22////////////////////////////////////////////////  /////////////////////////////////////7000      //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////P0463815          ////15/07                                             //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////400158           ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150713  EWF 2016021207USD  0000,9302122026638  ////////M90257509       ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000002218,00////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////60OoooooOOooooOooo////15/07 P0491115                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////30124373         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         40///////////////0000000000055,22////////////////////////////////////////////////  /////////////////////////////////////7000      //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////P0491115          ////15/07                                             //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////400158           ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150713  EWF 2016021207CHF  0001,0000022026639  ////////M90257515       ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000005833,20////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////A6OOooOoOoOooOoooo////15/07 R1575215                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////30124373         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150701  EWF 2016021207USD  0000,9302122026642  ////////C/5 335835      ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000000515,00////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////16OooooOooOOoOoooo////15/07 R1612715                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////40126141         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150701  EWF 2016021207USD  0000,9302122026643  ////////C/5 335833      ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000000835,00////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////58OOoOOooooOooOOoo////15/07 R1441715                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////40126141         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150706  EWF 2016021207USD  0000,9302122026644  ////////C/5 336036      ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000000515,00////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////6BooooOOoooOooOooo////15/07 R1659015                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////40126141         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150701  EWF 2016021207USD  0000,9302122026645  ////////C/5 335836      ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000000515,00////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////6DoOoooOooOOoOooOo////15/07 R1613415                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////40126141         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150708  EWF 2016021207USD  0000,9302122026646  ////////C/5 336201      ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000000515,00////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////74ooOoOooooooooOoO////15/07 R1728915                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////40126141         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150706  EWF 2016021207USD  0000,9302122026647  ////////C/5 336035      ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000000515,00////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////86OoooOOoooOoooOOo////15/07 R1612615                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////40126141         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150706  EWF 2016021207USD  0000,9302122026648  ////////C/5 336034      ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000000835,00////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////99OOooooooOooOoooo////15/07 R1445115                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////40126141         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150701  EWF 2016021207USD  0000,9302122026649  ////////C/5 335834      ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000000835,00////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////D8OOoooOOOooooOOoo////15/07 R1445315                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////40126141         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150706  EWF 2016021207CHF  0001,0000022026650  ////////351732          ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000000192,80////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////4BooOooooOOOoOOOOo////15/07 P0448015                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////30090682         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150706  EWF 2016021207CHF  0001,0000022026651  ////////351730          ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000000057,25////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////69ooOoOooooooooooO////15/07 P0451715                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////30090682         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         40///////////////0000000000007,02////////////////////////////////////////////////  /////////////////////////////////////7000      //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////P0451715          ////15/07                                             //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////400122           ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150706  EWF 2016021207CHF  0001,0000022026652  ////////351731          ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000000100,05////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////A9oooooooOoOooOOOo////15/07 P0448015                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////30090682         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150707  EWF 2016021207EUR  0001,0468822026653  ////////05/91014407     ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000000225,00////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////22oooOooooOooOooOO////15/07 R1727915                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////40096899         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150707  EWF 2016021207EUR  0001,0468822026654  ////////05/91015508     ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000000225,00////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////24OooooOOoOooOoOoO////15/07 R1728015                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////40096899         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150701  EWF 2016021207EUR  0001,0468822026655  ////////05/91015531     ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000000768,45////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////76oOOOOooOoOooooOO////15/07 W0054415                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////40096899         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150708  EWF 2016021207USD  0000,9302122026656  ////////SI156008034     ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000000261,79////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////96OooooOoOoooOOOoo////15/07 P0479215                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////40126601         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150709  EWF 2016021207EUR  0001,0468822026657  ////////05/91015509     ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000000705,35////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////99ooOoOOoooooOoooo////15/07 R1625015                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////40096899         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150713  EWF 2016021207EUR  0001,0468822026662  ////////55941607        ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000000725,60////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////4BOoooOOOoOoooooOo////15/07 P0486115                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////40091085         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150708  EWF 2016021207CHF  0001,0000022026663  ////////100-120606      ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000004229,50////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////0boooooooooooooooo////15/07 P0474115                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////30094003         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         40///////////////0000000000430,56////////////////////////////////////////////////  /////////////////////////////////////7000      //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////P0474115          ////15/07                                             //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////400158           ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         40///////////////0000000000054,38////////////////////////////////////////////////  /////////////////////////////////////7000      //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////P0474115          ////15/07                                             //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////400122           ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150707  EWF 2016021207CHF  0001,0000022026664  ////////13143106        ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000000318,65////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////6eoooooooooooooooo////15/07 P0468115                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////30092269         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         40///////////////0000000000014,04////////////////////////////////////////////////  /////////////////////////////////////7000      //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////P0468115          ////15/07                                             //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////400122           ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150709  EWF 2016021207EUR  0001,0468822026665  ////////TL152315        ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000001983,90////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////74oooooooooooooooo////15/07 P0431815                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////40099751         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150710  EWF 2016021207EUR  0001,0468822026667  ////////11321           ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000000840,00////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////caoooooooooooooooo////15/07 P0471915                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////950//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////40129316         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20150401  EWF 2016021204EUR  0001,0553176278995  ////////76278995        ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000007833,33////////////////////////////////////////////////  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////15/04 S0026415                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////566//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////VERB05001        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20110209  EWF 2016021202CHF  0001,0000090149059  ////////M90149059       ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000001077,30////////////////////////////////////////////////  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////11/03 S0080410                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////566//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////30124373         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1FB01                20110209  EWF 2016021202USD  0000,9570290149062  ////////90149062        ///////////////////////////////////////////////////////////X///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+2BBSEG                         31///////////////0000000002185,78////////////////////////////////////////////////  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////11/03 S0125011                                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////566//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////30124374         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/jdk/test/javax/xml/jaxp/transform/8150704/Bug8150704-2.xml b/jdk/test/javax/xml/jaxp/transform/8150704/Bug8150704-2.xml
new file mode 100644
index 0000000..19a8381
--- /dev/null
+++ b/jdk/test/javax/xml/jaxp/transform/8150704/Bug8150704-2.xml
@@ -0,0 +1,2438 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<transferInvoice version="0.32"> 
+  <invoice> 
+    <invoiceNumber>22026623</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>OPEN</invoiceState> 
+      <type>I</type> 
+      <vendor>V0409</vendor> 
+      <vendorCAGECode>CAGE1</vendorCAGECode> 
+      <vendorAccountNumber>40090597</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>91284422</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-09</invoiceDate> 
+      <closingDate/> 
+      <bookingDate>2015-07-15</bookingDate> 
+      <createdDate>2015-07-15</createdDate> 
+      <invoiceText>D8OOoOOooooOoooooOOOOooOoooOoOoo</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="USD">7366.71</totalAmount> 
+        <nettoAmount internationalCurrencyCode="USD">0.0</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="USD">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>V0</taxCode> 
+          <taxAmount internationalCurrencyCode="USD">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>P</orderType> 
+        <orderNumber>P0480715</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-08-08</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>USD</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>0.93021</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026624</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>OPEN</invoiceState> 
+      <type>I</type> 
+      <vendor>V0307</vendor> 
+      <vendorCAGECode>CAGE2</vendorCAGECode> 
+      <vendorAccountNumber>40127254</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>1500006837</creditorInvoiceNumber> 
+      <invoiceDate>2015-06-30</invoiceDate> 
+      <closingDate/> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>b3oooooooooooooooooooooooooooooo</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="USD">3844.0</totalAmount> 
+        <nettoAmount internationalCurrencyCode="USD">0.0</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="USD">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>V0</taxCode> 
+          <taxAmount internationalCurrencyCode="USD">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>R</orderType> 
+        <orderNumber>R1683315</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-07-30</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>USD</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>0.93021</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026625</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>CLOSED</invoiceState> 
+      <type>I</type> 
+      <vendor>V0568</vendor> 
+      <vendorAccountNumber>30092874</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>94043801</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-09</invoiceDate> 
+      <closingDate>2015-07-16</closingDate> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>0CooOooooooooooOOoooOooOoOOoooOo</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="CHF">438.5</totalAmount> 
+        <nettoAmount internationalCurrencyCode="CHF">190.008</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="CHF">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>4V</taxCode> 
+          <taxAmount internationalCurrencyCode="CHF">32.48</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>P</orderType> 
+        <orderNumber>P0472115</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-08-08</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>CHF</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>1.0</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026626</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>OPEN</invoiceState> 
+      <type>I</type> 
+      <vendor>V0316</vendor> 
+      <vendorCAGECode>CAGE3</vendorCAGECode> 
+      <vendorAccountNumber>40099751</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>TL152062</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-02</invoiceDate> 
+      <closingDate/> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>3coooooooooooooooooooooooooooooo</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="EUR">661.3</totalAmount> 
+        <nettoAmount internationalCurrencyCode="EUR">0.0</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="EUR">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>V0</taxCode> 
+          <taxAmount internationalCurrencyCode="EUR">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>P</orderType> 
+        <orderNumber>P0431815</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-08-01</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>EUR</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>1.04688</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026627</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>OPEN</invoiceState> 
+      <type>I</type> 
+      <vendor>V0440</vendor> 
+      <vendorAccountNumber>2014686</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>TKL100216</creditorInvoiceNumber> 
+      <invoiceDate>2015-06-17</invoiceDate> 
+      <closingDate/> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>55oooooOoOooooOoOoOOOoOOOoooOOoo</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="EUR">699.92</totalAmount> 
+        <nettoAmount internationalCurrencyCode="EUR">0.0</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="EUR">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>V0</taxCode> 
+          <taxAmount internationalCurrencyCode="EUR">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>L</orderType> 
+        <orderNumber>L0032815</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-07-17</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>EUR</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>1.04688</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026628</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>OPEN</invoiceState> 
+      <type>I</type> 
+      <vendor>V0316</vendor> 
+      <vendorCAGECode>CAGE4</vendorCAGECode> 
+      <vendorAccountNumber>40099751</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>TL152063</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-02</invoiceDate> 
+      <closingDate/> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>9boooooooooooooooooooooooooooooo</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="EUR">1983.0</totalAmount> 
+        <nettoAmount internationalCurrencyCode="EUR">0.0</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="EUR">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>V0</taxCode> 
+          <taxAmount internationalCurrencyCode="EUR">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>P</orderType> 
+        <orderNumber>P0431815</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-08-01</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>EUR</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>1.04688</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026629</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>OPEN</invoiceState> 
+      <type>I</type> 
+      <vendor>V0506</vendor> 
+      <vendorAccountNumber>40128088</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>000359084</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-13</invoiceDate> 
+      <closingDate/> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>51oOoOoOoOoooooOOOoOooooOOoooOoO</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="EUR">2230.76</totalAmount> 
+        <nettoAmount internationalCurrencyCode="EUR">0.0</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="EUR">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>V0</taxCode> 
+          <taxAmount internationalCurrencyCode="EUR">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>R</orderType> 
+        <orderNumber>R1735915</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-08-12</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>EUR</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>1.04688</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026630</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>OPEN</invoiceState> 
+      <type>I</type> 
+      <vendor>V0497</vendor> 
+      <vendorAccountNumber>30090668</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>90864081</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-08</invoiceDate> 
+      <closingDate/> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>acoooooooooooooooooooooooooooooo</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="CHF">1893.2</totalAmount> 
+        <nettoAmount internationalCurrencyCode="CHF">0.0</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="CHF">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>4V</taxCode> 
+          <taxAmount internationalCurrencyCode="CHF">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>P</orderType> 
+        <orderNumber>P0470615</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-08-07</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>CHF</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>1.0</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026631</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>OPEN</invoiceState> 
+      <type>I</type> 
+      <vendor>V0512</vendor> 
+      <vendorAccountNumber>40128846</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>123939</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-08</invoiceDate> 
+      <closingDate/> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>09oooooooooooooooooooooooooooooo</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="USD">7896.34</totalAmount> 
+        <nettoAmount internationalCurrencyCode="USD">0.0</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="USD">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>TAX</taxCode> 
+          <taxAmount internationalCurrencyCode="USD">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>P</orderType> 
+        <orderNumber>P0400015</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-08-07</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>USD</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>0.93021</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026633</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>CLOSED</invoiceState> 
+      <type>I</type> 
+      <vendor>V0202</vendor> 
+      <vendorAccountNumber>40128088</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>000358117</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-07</invoiceDate> 
+      <closingDate>2015-07-16</closingDate> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>f5oooooooooooooooooooooooooooooo</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="USD">6810.0</totalAmount> 
+        <nettoAmount internationalCurrencyCode="USD">3187.08</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="USD">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>V0</taxCode> 
+          <taxAmount internationalCurrencyCode="USD">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>P</orderType> 
+        <orderNumber>P0462815</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-08-06</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>USD</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>0.93021</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026635</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>OPEN</invoiceState> 
+      <type>I</type> 
+      <vendor>V0011</vendor> 
+      <vendorAccountNumber>30124373</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>M90257500</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-13</invoiceDate> 
+      <closingDate/> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>C3oOOOooOoOooOOOoooOOOoOOoooOoOO</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="CHF">16300.5</totalAmount> 
+        <nettoAmount internationalCurrencyCode="CHF">0.0</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="CHF">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>V0</taxCode> 
+          <taxAmount internationalCurrencyCode="CHF">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>R</orderType> 
+        <orderNumber>R1488615</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-08-12</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>CHF</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>1.0</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026637</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>CLOSED</invoiceState> 
+      <type>I</type> 
+      <vendor>V0139</vendor> 
+      <vendorAccountNumber>30124373</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>M90257457</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-13</invoiceDate> 
+      <closingDate>2015-07-16</closingDate> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>60ooooOooOOOoOoOoooooooOOOOoooOO</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="USD">831.9</totalAmount> 
+        <nettoAmount internationalCurrencyCode="USD">334.1052</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="USD">118.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>V0</taxCode> 
+          <taxAmount internationalCurrencyCode="USD">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>P</orderType> 
+        <orderNumber>P0463815</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-08-12</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>USD</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>0.93021</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+    <invoiceCharges> 
+      <chargeType> 
+        <chargeCode>H</chargeCode> 
+        <description>HANDLING CHARGE</description> 
+        <isTax>N</isTax> 
+        <affectsAveragePrice>N</affectsAveragePrice> 
+      </chargeType> 
+      <accountNumber>400158</accountNumber> 
+      <costType/> 
+      <costcenter>7000</costcenter> 
+      <financialCostcenter>7000</financialCostcenter> 
+      <costcenter2/> 
+      <chargeAmount> 
+        <totalAmount internationalCurrencyCode="USD">55.224</totalAmount> 
+        <nettoAmount internationalCurrencyCode="USD">55.224</nettoAmount> 
+        <taxation> 
+          <taxCode>V0</taxCode> 
+          <financialTaxCode>V0</financialTaxCode> 
+          <taxAmount internationalCurrencyCode="USD">0.0</taxAmount> 
+        </taxation> 
+      </chargeAmount> 
+      <bookingType>D</bookingType> 
+    </invoiceCharges> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026638</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>CLOSED</invoiceState> 
+      <type>I</type> 
+      <vendor>V0139</vendor> 
+      <vendorAccountNumber>30124373</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>M90257509</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-13</invoiceDate> 
+      <closingDate>2015-07-16</closingDate> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>60OoooooOOooooOoooooooooOOooOOOO</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="USD">2218.0</totalAmount> 
+        <nettoAmount internationalCurrencyCode="USD">982.8</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="USD">118.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>V0</taxCode> 
+          <taxAmount internationalCurrencyCode="USD">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>P</orderType> 
+        <orderNumber>P0491115</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-08-12</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>USD</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>0.93021</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+    <invoiceCharges> 
+      <chargeType> 
+        <chargeCode>H</chargeCode> 
+        <description>HANDLING CHARGE</description> 
+        <isTax>N</isTax> 
+        <affectsAveragePrice>N</affectsAveragePrice> 
+      </chargeType> 
+      <accountNumber>400158</accountNumber> 
+      <costType/> 
+      <costcenter>7000</costcenter> 
+      <financialCostcenter>7000</financialCostcenter> 
+      <costcenter2/> 
+      <chargeAmount> 
+        <totalAmount internationalCurrencyCode="USD">55.224</totalAmount> 
+        <nettoAmount internationalCurrencyCode="USD">55.224</nettoAmount> 
+        <taxation> 
+          <taxCode>V0</taxCode> 
+          <financialTaxCode>V0</financialTaxCode> 
+          <taxAmount internationalCurrencyCode="USD">0.0</taxAmount> 
+        </taxation> 
+      </chargeAmount> 
+      <bookingType>D</bookingType> 
+    </invoiceCharges> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026639</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>OPEN</invoiceState> 
+      <type>I</type> 
+      <vendor>V0162</vendor> 
+      <vendorAccountNumber>30124373</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>M90257515</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-13</invoiceDate> 
+      <closingDate/> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>A6OOooOoOoOooOoooooooooOooooOOoo</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="CHF">5833.2</totalAmount> 
+        <nettoAmount internationalCurrencyCode="CHF">0.0</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="CHF">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>V0</taxCode> 
+          <taxAmount internationalCurrencyCode="CHF">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>R</orderType> 
+        <orderNumber>R1575215</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-08-12</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>CHF</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>1.0</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026642</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>OPEN</invoiceState> 
+      <type>I</type> 
+      <vendor>V0400</vendor> 
+      <vendorCAGECode>CAGE5</vendorCAGECode> 
+      <vendorAccountNumber>40126141</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>C/5 335835</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-01</invoiceDate> 
+      <closingDate/> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>16OooooOooOOoOooooOoooooooooooOO</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="USD">515.0</totalAmount> 
+        <nettoAmount internationalCurrencyCode="USD">0.0</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="USD">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>V0</taxCode> 
+          <taxAmount internationalCurrencyCode="USD">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>R</orderType> 
+        <orderNumber>R1612715</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-07-31</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>USD</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>0.93021</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026643</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>OPEN</invoiceState> 
+      <type>I</type> 
+      <vendor>V0400</vendor> 
+      <vendorCAGECode>CAGE6</vendorCAGECode> 
+      <vendorAccountNumber>40126141</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>C/5 335833</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-01</invoiceDate> 
+      <closingDate/> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>58OOoOOooooOooOOooOoooOooooOOoOo</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="USD">835.0</totalAmount> 
+        <nettoAmount internationalCurrencyCode="USD">0.0</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="USD">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>V0</taxCode> 
+          <taxAmount internationalCurrencyCode="USD">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>R</orderType> 
+        <orderNumber>R1441715</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-07-31</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>USD</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>0.93021</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026644</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>OPEN</invoiceState> 
+      <type>I</type> 
+      <vendor>V0400</vendor> 
+      <vendorCAGECode>CAGE7</vendorCAGECode> 
+      <vendorAccountNumber>40126141</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>C/5 336036</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-06</invoiceDate> 
+      <closingDate/> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>6BooooOOoooOooOooooOooooOoOOoooo</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="USD">515.0</totalAmount> 
+        <nettoAmount internationalCurrencyCode="USD">0.0</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="USD">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>V0</taxCode> 
+          <taxAmount internationalCurrencyCode="USD">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>R</orderType> 
+        <orderNumber>R1659015</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-08-05</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>USD</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>0.93021</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026645</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>OPEN</invoiceState> 
+      <type>I</type> 
+      <vendor>V0400</vendor> 
+      <vendorCAGECode>CAGE8</vendorCAGECode> 
+      <vendorAccountNumber>40126141</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>C/5 335836</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-01</invoiceDate> 
+      <closingDate/> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>6DoOoooOooOOoOooOoOoOoOOOoOoOooo</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="USD">515.0</totalAmount> 
+        <nettoAmount internationalCurrencyCode="USD">0.0</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="USD">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>V0</taxCode> 
+          <taxAmount internationalCurrencyCode="USD">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>R</orderType> 
+        <orderNumber>R1613415</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-07-31</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>USD</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>0.93021</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026646</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>OPEN</invoiceState> 
+      <type>I</type> 
+      <vendor>V0400</vendor> 
+      <vendorCAGECode>CAGE9</vendorCAGECode> 
+      <vendorAccountNumber>40126141</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>C/5 336201</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-08</invoiceDate> 
+      <closingDate/> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>74ooOoOooooooooOoOOOoOoOooOoooOO</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="USD">515.0</totalAmount> 
+        <nettoAmount internationalCurrencyCode="USD">0.0</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="USD">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>V0</taxCode> 
+          <taxAmount internationalCurrencyCode="USD">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>R</orderType> 
+        <orderNumber>R1728915</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-08-07</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>USD</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>0.93021</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026647</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>OPEN</invoiceState> 
+      <type>I</type> 
+      <vendor>V0400</vendor> 
+      <vendorCAGECode>CAGEA</vendorCAGECode> 
+      <vendorAccountNumber>40126141</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>C/5 336035</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-06</invoiceDate> 
+      <closingDate/> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>86OoooOOoooOoooOOoOooOoooOOoOoOo</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="USD">515.0</totalAmount> 
+        <nettoAmount internationalCurrencyCode="USD">0.0</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="USD">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>V0</taxCode> 
+          <taxAmount internationalCurrencyCode="USD">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>R</orderType> 
+        <orderNumber>R1612615</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-08-05</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>USD</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>0.93021</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026648</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>OPEN</invoiceState> 
+      <type>I</type> 
+      <vendor>V0400</vendor> 
+      <vendorCAGECode>CAGEB</vendorCAGECode> 
+      <vendorAccountNumber>40126141</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>C/5 336034</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-06</invoiceDate> 
+      <closingDate/> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>99OOooooooOooOooooOooOooOoOOoOoo</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="USD">835.0</totalAmount> 
+        <nettoAmount internationalCurrencyCode="USD">0.0</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="USD">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>V0</taxCode> 
+          <taxAmount internationalCurrencyCode="USD">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>R</orderType> 
+        <orderNumber>R1445115</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-08-05</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>USD</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>0.93021</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026649</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>OPEN</invoiceState> 
+      <type>I</type> 
+      <vendor>V0400</vendor> 
+      <vendorCAGECode>CAGEC</vendorCAGECode> 
+      <vendorAccountNumber>40126141</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>C/5 335834</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-01</invoiceDate> 
+      <closingDate/> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>D8OOoooOOOooooOOoooOOoOoooOoOOOO</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="USD">835.0</totalAmount> 
+        <nettoAmount internationalCurrencyCode="USD">0.0</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="USD">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>V0</taxCode> 
+          <taxAmount internationalCurrencyCode="USD">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>R</orderType> 
+        <orderNumber>R1445315</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-07-31</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>USD</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>0.93021</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026650</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>OPEN</invoiceState> 
+      <type>I</type> 
+      <vendor>V0429</vendor> 
+      <vendorAccountNumber>30090682</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>351732</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-06</invoiceDate> 
+      <closingDate/> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>4BooOooooOOOoOOOOooo</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="CHF">192.8</totalAmount> 
+        <nettoAmount internationalCurrencyCode="CHF">0.0</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="CHF">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>4V</taxCode> 
+          <taxAmount internationalCurrencyCode="CHF">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>P</orderType> 
+        <orderNumber>P0448015</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-08-05</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>CHF</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>1.0</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026651</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>CLOSED</invoiceState> 
+      <type>I</type> 
+      <vendor>V0429</vendor> 
+      <vendorAccountNumber>30090682</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>351730</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-06</invoiceDate> 
+      <closingDate>2015-07-16</closingDate> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>69ooOoOooooooooooOoOooOOOOoooOoO</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="CHF">57.25</totalAmount> 
+        <nettoAmount internationalCurrencyCode="CHF">17.784</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="CHF">15.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>4V</taxCode> 
+          <taxAmount internationalCurrencyCode="CHF">4.24</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>P</orderType> 
+        <orderNumber>P0451715</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-08-05</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>CHF</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>1.0</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+    <invoiceCharges> 
+      <chargeType> 
+        <chargeCode>F</chargeCode> 
+        <description>FREIGHT</description> 
+        <isTax>N</isTax> 
+        <affectsAveragePrice>N</affectsAveragePrice> 
+      </chargeType> 
+      <accountNumber>400122</accountNumber> 
+      <costType/> 
+      <costcenter>7000</costcenter> 
+      <financialCostcenter>7000</financialCostcenter> 
+      <costcenter2/> 
+      <chargeAmount> 
+        <totalAmount internationalCurrencyCode="CHF">7.02</totalAmount> 
+        <nettoAmount internationalCurrencyCode="CHF">7.02</nettoAmount> 
+        <taxation> 
+          <taxCode>4V</taxCode> 
+          <financialTaxCode>4V</financialTaxCode> 
+          <taxAmount internationalCurrencyCode="CHF">0.5616</taxAmount> 
+        </taxation> 
+      </chargeAmount> 
+      <bookingType>D</bookingType> 
+    </invoiceCharges> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026652</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>OPEN</invoiceState> 
+      <type>I</type> 
+      <vendor>V0429</vendor> 
+      <vendorAccountNumber>30090682</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>351731</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-06</invoiceDate> 
+      <closingDate/> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>A9oooooooOoOooOOOoOO</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="CHF">100.05</totalAmount> 
+        <nettoAmount internationalCurrencyCode="CHF">0.0</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="CHF">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>4V</taxCode> 
+          <taxAmount internationalCurrencyCode="CHF">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>P</orderType> 
+        <orderNumber>P0448015</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-08-05</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>CHF</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>1.0</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026653</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>OPEN</invoiceState> 
+      <type>I</type> 
+      <vendor>V0028</vendor> 
+      <vendorCAGECode>CAGED</vendorCAGECode> 
+      <vendorAccountNumber>40096899</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>05/91014407</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-07</invoiceDate> 
+      <closingDate/> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>22oooOooooOooOooOOoOooOoooooOooO</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="EUR">225.0</totalAmount> 
+        <nettoAmount internationalCurrencyCode="EUR">0.0</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="EUR">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>V0</taxCode> 
+          <taxAmount internationalCurrencyCode="EUR">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>R</orderType> 
+        <orderNumber>R1727915</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-08-06</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>EUR</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>1.04688</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026654</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>OPEN</invoiceState> 
+      <type>I</type> 
+      <vendor>V0028</vendor> 
+      <vendorCAGECode>CAGEE</vendorCAGECode> 
+      <vendorAccountNumber>40096899</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>05/91015508</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-07</invoiceDate> 
+      <closingDate/> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>24OooooOOoOooOoOoOoOoooOOoOOooOo</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="EUR">225.0</totalAmount> 
+        <nettoAmount internationalCurrencyCode="EUR">0.0</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="EUR">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>V0</taxCode> 
+          <taxAmount internationalCurrencyCode="EUR">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>R</orderType> 
+        <orderNumber>R1728015</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-08-06</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>EUR</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>1.04688</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026655</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>CLOSED</invoiceState> 
+      <type>I</type> 
+      <vendor>V0028</vendor> 
+      <vendorCAGECode>CAGEF</vendorCAGECode> 
+      <vendorAccountNumber>40096899</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>05/91015531</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-01</invoiceDate> 
+      <closingDate>2015-07-16</closingDate> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>76oOOOOooOoOooooOOoOoOOooOooOoOO</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="EUR">768.45</totalAmount> 
+        <nettoAmount internationalCurrencyCode="EUR">359.6346</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="EUR">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>V0</taxCode> 
+          <taxAmount internationalCurrencyCode="EUR">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>W</orderType> 
+        <orderNumber>W0054415</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-07-31</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>EUR</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>1.04688</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026656</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>OPEN</invoiceState> 
+      <type>I</type> 
+      <vendor>V0651</vendor> 
+      <vendorAccountNumber>40126601</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>SI156008034</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-08</invoiceDate> 
+      <closingDate/> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>96OooooOoOoooOOOoooOOoooOoOOOOoO</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="USD">261.79</totalAmount> 
+        <nettoAmount internationalCurrencyCode="USD">0.0</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="USD">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>V0</taxCode> 
+          <taxAmount internationalCurrencyCode="USD">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>P</orderType> 
+        <orderNumber>P0479215</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-08-07</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>USD</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>0.93021</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026657</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>CLOSED</invoiceState> 
+      <type>I</type> 
+      <vendor>V0028</vendor> 
+      <vendorCAGECode>CAGEG</vendorCAGECode> 
+      <vendorAccountNumber>40096899</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>05/91015509</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-09</invoiceDate> 
+      <closingDate>2015-07-16</closingDate> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>99ooOoOOoooooOooooOOOOoooOOoOOoO</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="EUR">705.35</totalAmount> 
+        <nettoAmount internationalCurrencyCode="EUR">330.1038</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="EUR">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>V0</taxCode> 
+          <taxAmount internationalCurrencyCode="EUR">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>R</orderType> 
+        <orderNumber>R1625015</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-08-08</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>EUR</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>1.04688</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026662</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>OPEN</invoiceState> 
+      <type>I</type> 
+      <vendor>V0495</vendor> 
+      <vendorCAGECode>CAGEH</vendorCAGECode> 
+      <vendorAccountNumber>40091085</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>55941607</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-13</invoiceDate> 
+      <closingDate/> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>4BOoooOOOoOoooooOoOOooOooooOoOoo</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="EUR">725.6</totalAmount> 
+        <nettoAmount internationalCurrencyCode="EUR">0.0</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="EUR">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>V0</taxCode> 
+          <taxAmount internationalCurrencyCode="EUR">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>P</orderType> 
+        <orderNumber>P0486115</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-08-12</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>EUR</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>1.04688</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026663</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>CLOSED</invoiceState> 
+      <type>I</type> 
+      <vendor>V0604</vendor> 
+      <vendorAccountNumber>30094003</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>100-120606</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-08</invoiceDate> 
+      <closingDate>2015-07-16</closingDate> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>0boooooooooooooooooooooooooooooo</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="CHF">4229.5</totalAmount> 
+        <nettoAmount internationalCurrencyCode="CHF">1347.84</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="CHF">1036.2</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>TAX</taxCode> 
+          <taxAmount internationalCurrencyCode="CHF">313.3</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>P</orderType> 
+        <orderNumber>P0474115</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-08-07</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>CHF</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>1.0</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+    <invoiceCharges> 
+      <chargeType> 
+        <chargeCode>H</chargeCode> 
+        <description>HANDLING CHARGE</description> 
+        <isTax>N</isTax> 
+        <affectsAveragePrice>N</affectsAveragePrice> 
+      </chargeType> 
+      <accountNumber>400158</accountNumber> 
+      <costType/> 
+      <costcenter>7000</costcenter> 
+      <financialCostcenter>7000</financialCostcenter> 
+      <costcenter2/> 
+      <chargeAmount> 
+        <totalAmount internationalCurrencyCode="CHF">430.56</totalAmount> 
+        <nettoAmount internationalCurrencyCode="CHF">430.56</nettoAmount> 
+        <taxation> 
+          <taxCode>4V</taxCode> 
+          <financialTaxCode>4V</financialTaxCode> 
+          <taxAmount internationalCurrencyCode="CHF">34.4448</taxAmount> 
+        </taxation> 
+      </chargeAmount> 
+      <bookingType>D</bookingType> 
+    </invoiceCharges> 
+    <invoiceCharges> 
+      <chargeType> 
+        <chargeCode>F</chargeCode> 
+        <description>FREIGHT</description> 
+        <isTax>N</isTax> 
+        <affectsAveragePrice>N</affectsAveragePrice> 
+      </chargeType> 
+      <accountNumber>400122</accountNumber> 
+      <costType/> 
+      <costcenter>7000</costcenter> 
+      <financialCostcenter>7000</financialCostcenter> 
+      <costcenter2/> 
+      <chargeAmount> 
+        <totalAmount internationalCurrencyCode="CHF">54.3816</totalAmount> 
+        <nettoAmount internationalCurrencyCode="CHF">54.3816</nettoAmount> 
+        <taxation> 
+          <taxCode>4V</taxCode> 
+          <financialTaxCode>4V</financialTaxCode> 
+          <taxAmount internationalCurrencyCode="CHF">4.3524</taxAmount> 
+        </taxation> 
+      </chargeAmount> 
+      <bookingType>D</bookingType> 
+    </invoiceCharges> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026664</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>CLOSED</invoiceState> 
+      <type>I</type> 
+      <vendor>V0634</vendor> 
+      <vendorAccountNumber>30092269</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>13143106</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-07</invoiceDate> 
+      <closingDate>2015-07-16</closingDate> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>6eoooooooooooooooooooooooooooooo</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="CHF">318.65</totalAmount> 
+        <nettoAmount internationalCurrencyCode="CHF">124.0434</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="CHF">30.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>4V</taxCode> 
+          <taxAmount internationalCurrencyCode="CHF">23.599999999999998</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>P</orderType> 
+        <orderNumber>P0468115</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-08-06</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>CHF</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>1.0</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+    <invoiceCharges> 
+      <chargeType> 
+        <chargeCode>F</chargeCode> 
+        <description>FREIGHT</description> 
+        <isTax>N</isTax> 
+        <affectsAveragePrice>N</affectsAveragePrice> 
+      </chargeType> 
+      <accountNumber>400122</accountNumber> 
+      <costType/> 
+      <costcenter>7000</costcenter> 
+      <financialCostcenter>7000</financialCostcenter> 
+      <costcenter2/> 
+      <chargeAmount> 
+        <totalAmount internationalCurrencyCode="CHF">14.04</totalAmount> 
+        <nettoAmount internationalCurrencyCode="CHF">14.04</nettoAmount> 
+        <taxation> 
+          <taxCode>4V</taxCode> 
+          <financialTaxCode>4V</financialTaxCode> 
+          <taxAmount internationalCurrencyCode="CHF">1.1232</taxAmount> 
+        </taxation> 
+      </chargeAmount> 
+      <bookingType>D</bookingType> 
+    </invoiceCharges> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026665</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>OPEN</invoiceState> 
+      <type>I</type> 
+      <vendor>V0316</vendor> 
+      <vendorCAGECode>CAGEI</vendorCAGECode> 
+      <vendorAccountNumber>40099751</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>TL152315</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-09</invoiceDate> 
+      <closingDate/> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>74oooooooooooooooooooooooooooooo</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="EUR">1983.9</totalAmount> 
+        <nettoAmount internationalCurrencyCode="EUR">0.0</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="EUR">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>V0</taxCode> 
+          <taxAmount internationalCurrencyCode="EUR">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>P</orderType> 
+        <orderNumber>P0431815</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-08-08</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>EUR</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>1.04688</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>22026667</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>OPEN</invoiceState> 
+      <type>I</type> 
+      <vendor>V0642</vendor> 
+      <vendorAccountNumber>40129316</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>11321</creditorInvoiceNumber> 
+      <invoiceDate>2015-07-10</invoiceDate> 
+      <closingDate/> 
+      <bookingDate>2015-07-16</bookingDate> 
+      <createdDate>2015-07-16</createdDate> 
+      <invoiceText>caoooooooooooooooooooooooooooooo</invoiceText> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="EUR">840.0</totalAmount> 
+        <nettoAmount internationalCurrencyCode="EUR">0.0</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="EUR">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>V0</taxCode> 
+          <taxAmount internationalCurrencyCode="EUR">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>P</orderType> 
+        <orderNumber>P0471915</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>30D</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-08-09</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>07</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>EUR</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>1.04688</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>76278995</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>CLOSED</invoiceState> 
+      <type>I</type> 
+      <vendor>V0166</vendor> 
+      <vendorCAGECode>CAGEJ</vendorCAGECode> 
+      <vendorAccountNumber>VERB05001</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>76278995</creditorInvoiceNumber> 
+      <invoiceDate>2015-04-01</invoiceDate> 
+      <closingDate>2015-04-17</closingDate> 
+      <bookingDate>2015-04-17</bookingDate> 
+      <createdDate>2015-04-17</createdDate> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="EUR">7833.33</totalAmount> 
+        <nettoAmount internationalCurrencyCode="EUR">3394.4414</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="EUR">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>V0</taxCode> 
+          <taxAmount internationalCurrencyCode="EUR">580.25</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>S</orderType> 
+        <orderNumber>S0026415</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>Y</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code/> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2015-04-01</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>Y</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>04</financialPeriodMonth> 
+        <financialPeriodYear>2015</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>EUR</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>1.05531</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>90149059</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>CLOSED</invoiceState> 
+      <type>I</type> 
+      <vendor>V0016</vendor> 
+      <vendorAccountNumber>30124373</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>M90149059</creditorInvoiceNumber> 
+      <invoiceDate>2011-02-09</invoiceDate> 
+      <closingDate>2011-02-18</closingDate> 
+      <bookingDate>2011-02-18</bookingDate> 
+      <createdDate>2011-02-18</createdDate> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="CHF">1077.3</totalAmount> 
+        <nettoAmount internationalCurrencyCode="CHF">504.1764</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="CHF">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>TAX</taxCode> 
+          <taxAmount internationalCurrencyCode="CHF">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>S</orderType> 
+        <orderNumber>S0080410</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>N</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>5</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2011-02-09</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>N</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>03</financialPeriodMonth> 
+        <financialPeriodYear>2011</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>CHF</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 
+        <conversionRate>1.0</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+  <invoice> 
+    <invoiceNumber>90149062</invoiceNumber> 
+    <invoiceHeader> 
+      <entityInformation> 
+        <entityCode>CRX</entityCode> 
+        <currency>CHF</currency> 
+      </entityInformation> 
+      <invoiceState>CLOSED</invoiceState> 
+      <type>I</type> 
+      <vendor>V0016</vendor> 
+      <vendorAccountNumber>30124374</vendorAccountNumber> 
+      <mandator/> 
+      <creditorInvoiceNumber>90149062</creditorInvoiceNumber> 
+      <invoiceDate>2011-02-09</invoiceDate> 
+      <closingDate>2011-02-21</closingDate> 
+      <bookingDate>2011-02-21</bookingDate> 
+      <createdDate>2011-02-21</createdDate> 
+      <invoiceAmount> 
+        <totalAmount internationalCurrencyCode="USD">2185.78</totalAmount> 
+        <nettoAmount internationalCurrencyCode="USD">1022.945</nettoAmount> 
+        <handlingAmount internationalCurrencyCode="USD">0.0</handlingAmount> 
+        <discount>0.0</discount> 
+        <taxation> 
+          <taxCode>TAX</taxCode> 
+          <taxAmount internationalCurrencyCode="USD">0.0</taxAmount> 
+        </taxation> 
+      </invoiceAmount> 
+      <orderInformation> 
+        <orderType>S</orderType> 
+        <orderNumber>S0125011</orderNumber> 
+      </orderInformation> 
+      <invoiceTransferInformation> 
+        <transferDate>2016-02-12</transferDate> 
+        <preTransferDate/> 
+        <transferRelease>N</transferRelease> 
+      </invoiceTransferInformation> 
+      <paymentInformation> 
+        <paymentCondition> 
+          <code>6</code> 
+        </paymentCondition> 
+        <paymentMode> 
+          <code/> 
+        </paymentMode> 
+        <paymentDate/> 
+        <paymentDueDate>2011-02-09</paymentDueDate> 
+        <paymentReminderCount>0</paymentReminderCount> 
+        <paymentRelease>N</paymentRelease> 
+      </paymentInformation> 
+      <financialPeriodInformation> 
+        <financialPeriodMonth>03</financialPeriodMonth> 
+        <financialPeriodYear>2011</financialPeriodYear> 
+      </financialPeriodInformation> 
+      <currencyConversionInformation> 
+        <targetCurrency>USD</targetCurrency> 
+        <sourceCurrency>CHF</sourceCurrency> 	
+        <conversionRate>0.95702</conversionRate> 
+      </currencyConversionInformation> 
+    </invoiceHeader> 
+  </invoice> 
+</transferInvoice> 
+
diff --git a/jdk/test/javax/xml/jaxp/transform/8150704/Bug8150704-2.xsl b/jdk/test/javax/xml/jaxp/transform/8150704/Bug8150704-2.xsl
new file mode 100644
index 0000000..03040b7
--- /dev/null
+++ b/jdk/test/javax/xml/jaxp/transform/8150704/Bug8150704-2.xsl
@@ -0,0 +1,1935 @@
+<?xml version="1.0" encoding="UTF-8"?> 
+<!-- 
+Invoice Transfer XSLT 
+--> 
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exslt="http://exslt.org/common" exclude-result-prefixes="exslt" version="1.0"> 
+
+<!--<xsl:output method="xml" indent="yes"/>--> 
+<xsl:output method="text" encoding="iso-8859-1"/> 
+<xsl:decimal-format name="european" decimal-separator="," grouping-separator="'"/> 
+
+<!-- Definition of global constants --> 
+<xsl:variable name="batchSTYPE">0</xsl:variable> 
+<xsl:variable name="batchGROUP">fto-erech</xsl:variable>	
+<xsl:variable name="batchMANDT">200</xsl:variable> 
+<xsl:variable name="batchUSNAM">amos-batch</xsl:variable> 
+<xsl:variable name="batchSTART">00000000</xsl:variable> 
+<xsl:variable name="batchXKEEP">X</xsl:variable> 
+
+<!-- KREDI constants --> 
+<xsl:variable name="constTCODE">FB01</xsl:variable>	
+<xsl:variable name="constBLART">TP</xsl:variable>	
+<xsl:variable name="constBUKRS">EWF</xsl:variable>	
+
+<!-- LZBKZ constants 
+"566" for S-Orders and "950" for all the rest --> 
+<xsl:variable name="constLZBZK_S_ORDER">566</xsl:variable> 
+<xsl:variable name="constLZBZK_OTHER">950</xsl:variable> 
+
+<!-- Tax code uised for charges flagged as "TAX" --> 
+<xsl:variable name="taxCodeConst">2w</xsl:variable> 
+<!-- Tax code used for all other occurences in file --> 
+<xsl:variable name="taxCodeDefaultConst">V0</xsl:variable>	
+
+<!-- entry point --> 
+<xsl:template match="/"> 
+
+<xsl:variable name="transformation_1"> 
+<xsl:call-template name="transformation_1_elements"/> 
+</xsl:variable> 
+
+<xsl:variable name="transformation_2"> 
+<transformation_2_elements> 
+<batchInformation> 
+<xsl:call-template name="batchInformation"/> 
+</batchInformation> 
+<xsl:for-each select="exslt:node-set($transformation_1)"> 
+<xsl:apply-templates select="transformation_1_elements"/> 
+</xsl:for-each> 
+</transformation_2_elements> 
+</xsl:variable> 
+
+<xsl:variable name="transformation_3"> 
+<transformation_3_elements> 
+<xsl:for-each select="exslt:node-set($transformation_2)"> 
+<xsl:apply-templates select="transformation_2_elements"/> 
+</xsl:for-each> 
+</transformation_3_elements> 
+</xsl:variable> 
+
+<!-- text output --> 
+<xsl:for-each select="exslt:node-set($transformation_3)"> 
+<xsl:apply-templates select="transformation_3_elements" /> 
+</xsl:for-each> 
+
+<!-- xml output 
+<xsl:for-each select="exslt:node-set($transformation_3)"> 
+<xsl:copy-of select="."/> 
+</xsl:for-each>--> 
+
+</xsl:template> 
+
+<xsl:template match="transformation_3_elements"> 
+<xsl:for-each select="*"> 
+<xsl:call-template name="Fill_Up" /> 
+</xsl:for-each> 
+</xsl:template> 
+
+<xsl:template name="Fill_Up"> 
+<xsl:for-each select="*"> 
+<xsl:variable name="align"> 
+<xsl:value-of select="@Alignment" /> 
+</xsl:variable> 
+<xsl:variable name="filler"> 
+<xsl:value-of select="@Filler" /> 
+</xsl:variable> 
+<xsl:variable name="length"> 
+<xsl:value-of select="@Length" /> 
+</xsl:variable> 
+<xsl:variable name="tagValue"> 
+<xsl:value-of select="." /> 
+</xsl:variable> 
+
+<xsl:variable name="defaultFiller"> 
+<xsl:choose> 
+<xsl:when test="$filler = 'blank'"> 
+<!-- make empty fields to be filled with '/' --> 
+<xsl:choose> 
+<xsl:when test="$tagValue = '/'"> 
+<xsl:value-of select="'/'" /> 
+</xsl:when> 
+<xsl:otherwise> 
+<xsl:value-of select="' '" /> 
+</xsl:otherwise> 
+</xsl:choose> 
+</xsl:when> 
+<xsl:otherwise> 
+<xsl:value-of select="$filler" /> 
+</xsl:otherwise> 
+</xsl:choose> 
+</xsl:variable> 
+
+<xsl:call-template name="justify"> 
+<xsl:with-param name="align" select="$align" /> 
+<xsl:with-param name="filler" select="$defaultFiller" /> 
+<xsl:with-param name="value" select="$tagValue" /> 
+<xsl:with-param name="width" select="$length" /> 
+</xsl:call-template> 
+</xsl:for-each> 
+<xsl:text>&#xa;</xsl:text> 
+</xsl:template> 
+
+<!-- start transformation_3 --> 
+<xsl:template match="transformation_2_elements"> 
+<xsl:apply-templates select="batchInformation" /> 
+<xsl:apply-templates select="invoice_elements" mode="transformation_3" /> 
+</xsl:template> 
+
+<xsl:template match="invoice_elements" mode="transformation_3"> 
+<xsl:for-each select="*"> 
+<xsl:if test="contains(name(),'header_elements')"> 
+<xsl:call-template name="header_elements_copy" /> 
+</xsl:if> 
+<xsl:if test="contains(name(),'header_1_elements')"> 
+<xsl:call-template name="header_1_elements_copy" /> 
+</xsl:if> 
+<xsl:if test="contains(name(),'invoiceCharges_1_elements')"> 
+<xsl:call-template name="invoiceCharges_1_elements_copy" /> 
+</xsl:if> 
+<xsl:if test="contains(name(),'invoiceDetails_1_elements')"> 
+<xsl:call-template name="invoiceDetails_1_elements_copy" /> 
+</xsl:if> 
+<xsl:if test="contains(name(),'invoiceDetails_DetailCharges_1_elements')"> 
+<xsl:call-template name="invoiceDetails_DetailCharges_1_elements_copy" /> 
+</xsl:if> 
+
+</xsl:for-each> 
+</xsl:template> 
+
+<xsl:template match="batchInformation"> 
+<xsl:copy-of select="." /> 
+</xsl:template> 
+<xsl:template name="header_elements_copy"> 
+<xsl:copy-of select="." /> 
+</xsl:template> 
+<xsl:template name="header_1_elements_copy"> 
+<xsl:copy-of select="." /> 
+</xsl:template> 
+<xsl:template name="invoiceCharges_1_elements_copy"> 
+<xsl:copy-of select="." /> 
+</xsl:template> 
+<xsl:template name="invoiceDetails_1_elements_copy"> 
+<xsl:copy-of select="." /> 
+</xsl:template> 
+<xsl:template name="invoiceDetails_DetailCharges_1_elements_copy"> 
+<xsl:copy-of select="." /> 
+</xsl:template> 
+<!-- end transformation_3 --> 
+
+<!-- start transformation_2 --> 
+<xsl:template name="batchInformation"> 
+<STYPE ID="1" Length="1" Alignment="left" Filler="blank"> 
+<xsl:value-of select="$batchSTYPE" /> 
+</STYPE> 
+<GROUP ID="2" Length="12" Alignment="left" Filler="blank"> 
+<xsl:value-of select="$batchGROUP" /> 
+</GROUP> 
+<MANDT ID="3" Length="3" Alignment="left" Filler="blank"> 
+<xsl:value-of select="$batchMANDT" /> 
+</MANDT> 
+<USNAM ID="4" Length="12" Alignment="left" Filler="blank"> 
+<xsl:value-of select="$batchUSNAM" /> 
+</USNAM> 
+<START ID="5" Length="8" Alignment="left" Filler="blank"> 
+<xsl:value-of select="$batchSTART" /> 
+</START> 
+<XKEEP ID="6" Length="1" Alignment="left" Filler="blank"> 
+<xsl:value-of select="$batchXKEEP" /> 
+</XKEEP> 
+<NODATA ID="7" Length="1" Alignment="left" Filler="blank">/</NODATA> 
+</xsl:template> 
+
+<xsl:template match="transformation_1_elements"> 
+<xsl:apply-templates select="invoice_elements" mode="transformation_2"/> 
+</xsl:template> 
+
+<xsl:template match="invoice_elements" mode="transformation_2"> 
+<invoice_elements> 
+<xsl:for-each select="@*"> 
+<xsl:attribute name="{local-name(.)}"> 
+<xsl:value-of select="."/> 
+</xsl:attribute> 
+</xsl:for-each> 
+<xsl:call-template name="header_elements"/> 
+<xsl:call-template name="header_1_elements"/> 
+<xsl:for-each select="*[count(./*) &gt; 0]"> 
+<xsl:if test="contains(name(),'invoiceCharges_elements')"> 
+<xsl:call-template name="invoiceCharges_1_elements"/> 
+</xsl:if> 
+<xsl:if test="contains(name(),'invoiceDetails_elements')"> 
+<xsl:call-template name="invoiceDetails_1_elements"/> 
+</xsl:if> 
+<xsl:if test="contains(name(),'invoiceDetails_DetailCharges_elements')"> 
+<xsl:call-template name="invoiceDetails_DetailCharges_1_elements"/> 
+</xsl:if> 
+</xsl:for-each> 
+</invoice_elements> 
+</xsl:template> 
+
+<xsl:template name="header_elements"> 
+<header_elements> 
+<STYPE ID="1" Length="1" Alignment="left" Filler="blank">1</STYPE> 
+<TCODE ID="2" Length="20" Alignment="left" Filler="blank"> 
+<xsl:value-of select="$constTCODE" /> 
+</TCODE> 
+<!-- create invoice date --> 
+<xsl:variable name="invoiceDate"> 
+<xsl:call-template name="getFormatedDate"> 
+<xsl:with-param name="date2format" select="invoiceDate"/> 
+</xsl:call-template> 
+</xsl:variable> 
+<!-- create invoice date month --> 
+<xsl:variable name="invoiceMonth"> 
+<xsl:call-template name="getMonthOfDate"> 
+<xsl:with-param name="date2format" select="invoiceDate"/> 
+</xsl:call-template> 
+</xsl:variable> 
+<BLDAT ID="3" Length="8" Alignment="left" Filler="blank"> 
+<xsl:value-of select="$invoiceDate" /> 
+</BLDAT> 
+<BLART ID="4" Length="2" Alignment="left" Filler="blank"> 
+<xsl:choose> 
+<xsl:when test="(invoiceNumber &gt; 0051053500) and (invoiceNumber &lt; 0051999999)">KA</xsl:when> 
+<xsl:when test="(invoiceNumber &gt; 0054012000) and (invoiceNumber &lt; 0054999999)">EA</xsl:when> 
+<xsl:otherwise> </xsl:otherwise> 
+</xsl:choose> 
+</BLART> 
+<BUKRS ID="5" Length="4" Alignment="left" Filler="blank"> 
+<xsl:value-of select="$constBUKRS" /> 
+</BUKRS> 
+<!-- create transfer date --> 
+<xsl:variable name="transferDate"> 
+<xsl:call-template name="getFormatedDate"> 
+<xsl:with-param name="date2format" select="transferDate"/> 
+</xsl:call-template> 
+</xsl:variable> 
+<BUDAT ID="6" Length="8" Alignment="left" Filler="blank"> 
+<xsl:value-of select="$transferDate" /> 
+</BUDAT> 
+<MONAT ID="7" Length="2" Alignment="left" Filler="blank"> 
+<xsl:value-of select="$invoiceMonth" /> 
+</MONAT> 
+
+<WAERS ID="8" Length="5" Alignment="left" Filler="blank"> 
+<xsl:value-of select="targetCurrency" /> 
+</WAERS> 
+
+<KURSF ID="9" Length="10" Alignment="left" Filler="blank"> 
+<xsl:value-of select="format-number(conversionRate, '0000,00000', 'european')"/>	
+</KURSF> 
+<!--<BELNR ID="10" Length="10" Alignment="left" Filler="blank">/</BELNR>--> 
+<BELNR ID="10" Length="10" Alignment="left" Filler="blank"> 
+<xsl:value-of select="invoiceNumber" /> 
+</BELNR> 
+<WWERT ID="11" Length="8" Alignment="left" Filler="blank">/</WWERT> 
+<XBLNR ID="12" Length="16" Alignment="left" Filler="blank"> 
+<xsl:value-of select="creditorInvoiceNumber" /> 
+</XBLNR> 
+<BVORG ID="13" Length="16" Alignment="left" Filler="blank">/</BVORG> 
+<BKTXT ID="14" Length="25" Alignment="left" Filler="blank">/</BKTXT> 
+<PARGB ID="15" Length="4" Alignment="left" Filler="blank">/</PARGB> 
+<AUGLV ID="16" Length="8" Alignment="left" Filler="blank">/</AUGLV> 
+<VBUND ID="17" Length="6" Alignment="left" Filler="blank">/</VBUND> 
+<XMWST ID="18" Length="1" Alignment="left" Filler="blank">X</XMWST> 
+<DOCID ID="19" Length="10" Alignment="left" Filler="blank">/</DOCID> 
+<BARCD ID="20" Length="40" Alignment="left" Filler="blank">/</BARCD> 
+<STODT ID="21" Length="8" Alignment="left" Filler="blank">/</STODT> 
+<BRNCH ID="22" Length="4" Alignment="left" Filler="blank">/</BRNCH> 
+<NUMPG ID="23" Length="3" Alignment="left" Filler="blank">/</NUMPG> 
+<STGRD ID="24" Length="2" Alignment="left" Filler="blank">/</STGRD> 
+<KURSF_M ID="25" Length="10" Alignment="left" Filler="blank">/</KURSF_M> 
+<AUGTX ID="26" Length="50" Alignment="left" Filler="blank">/</AUGTX> 
+<XPRFG ID="27" Length="1" Alignment="left" Filler="blank">/</XPRFG> 
+<XBWAE ID="28" Length="1" Alignment="left" Filler="blank">/</XBWAE> 
+<LDGRP ID="29" Length="4" Alignment="left" Filler="blank">/</LDGRP> 
+<PROPMANO ID="30" Length="13" Alignment="left" Filler="blank">/</PROPMANO> 
+<VATDATE ID="31" Length="8" Alignment="left" Filler="blank">/</VATDATE> 
+<SENDE ID="32" Length="1" Alignment="left" Filler="blank">/</SENDE> 
+</header_elements> 
+</xsl:template> 
+
+<xsl:template name="header_1_elements"> 
+<!-- KREDITOR SECTION --> 
+<header_1_elements> 
+<STYPE ID="1"	Length="1"	Alignment="left" Filler="blank">2</STYPE> 
+<TBNAM ID="2"	Length="30"	Alignment="left" Filler="blank">BBSEG</TBNAM> 
+<NEWBS ID="3"	Length="2"	Alignment="left" Filler="blank"> 
+<xsl:if test="type='I'">31</xsl:if> 
+<xsl:if test="type='C'">21</xsl:if> 
+</NEWBS> 
+<DUMMYX	ID="4"	Length="10"	Alignment="left" Filler="blank">/</DUMMYX> 
+<NEWUM	ID="5"	Length="1"	Alignment="left" Filler="blank">/</NEWUM> 
+<NEWBK	ID="6"	Length="4"	Alignment="left" Filler="blank">/</NEWBK> 
+<WRBTR	ID="7"	Length="16"	Alignment="left" Filler="blank"> 
+<!--	<xsl:value-of select="format-number(totalAmount, '#0.00', 'european')"/>	--> 
+<xsl:value-of select="format-number(totalAmount, '0000000000000,00', 'european')"/>	
+</WRBTR> 
+<DMBTR	ID="8"	Length="16"	Alignment="left" Filler="blank">/</DMBTR> 
+<WMWST	ID="9"	Length="16"	Alignment="left" Filler="blank">/</WMWST> 
+<MWSTS	ID="10"	Length="16"	Alignment="left" Filler="blank">/</MWSTS> 
+<MWSKZ	ID="11"	Length="2"	Alignment="left" Filler="blank"> 
+<xsl:value-of select="financialTaxCode" /> 
+</MWSKZ> 
+<XSKRL	ID="12"	Length="1"	Alignment="left" Filler="blank">/</XSKRL> 
+<FWZUZ	ID="13"	Length="16"	Alignment="left" Filler="blank">/</FWZUZ> 
+<HWZUZ	ID="14"	Length="16"	Alignment="left" Filler="blank">/</HWZUZ> 
+<GSBER	ID="15"	Length="4"	Alignment="left" Filler="blank">/</GSBER> 
+<KOSTL	ID="16"	Length="10"	Alignment="left" Filler="blank">/</KOSTL> 
+<DUMMY4	ID="17"	Length="4"	Alignment="left" Filler="blank">/</DUMMY4> 
+<AUFNR	ID="18"	Length="12"	Alignment="left" Filler="blank">/</AUFNR> 
+<EBELN	ID="19"	Length="10"	Alignment="left" Filler="blank">/</EBELN> 
+<EBELP	ID="20"	Length="5"	Alignment="left" Filler="blank">/</EBELP> 
+<PROJN	ID="21"	Length="16"	Alignment="left" Filler="blank">/</PROJN> 
+<MATNR	ID="22"	Length="18"	Alignment="left" Filler="blank">/</MATNR> 
+<WERKS	ID="23"	Length="4"	Alignment="left" Filler="blank">/</WERKS> 
+<MENGE	ID="24"	Length="17"	Alignment="left" Filler="blank">/</MENGE> 
+<MEINS	ID="25"	Length="3"	Alignment="left" Filler="blank">/</MEINS> 
+<VBEL2	ID="26"	Length="10"	Alignment="left" Filler="blank">/</VBEL2> 
+<POSN2	ID="27"	Length="6"	Alignment="left" Filler="blank">/</POSN2> 
+<ETEN2	ID="28"	Length="4"	Alignment="left" Filler="blank">/</ETEN2> 
+<PERNR	ID="29"	Length="8"	Alignment="left" Filler="blank">/</PERNR> 
+<BEWAR	ID="30"	Length="3"	Alignment="left" Filler="blank">/</BEWAR> 
+<VALUT	ID="31"	Length="8"	Alignment="left" Filler="blank">/</VALUT> 
+<ZFBDT	ID="32"	Length="8"	Alignment="left" Filler="blank">/</ZFBDT> 
+<ZINKZ	ID="33"	Length="2"	Alignment="left" Filler="blank">/</ZINKZ> 
+<ZUONR	ID="34"	Length="18"	Alignment="left" Filler="blank"> 
+<xsl:choose> 
+<xsl:when test="invoiceText and string-length(invoiceText) &gt; 0"> 
+<!-- <xsl:value-of select="invoiceText" /> --> 
+<xsl:value-of select="normalize-space(invoiceText)"/> 
+</xsl:when> 
+<xsl:otherwise> 
+<xsl:value-of select="'/'" /> 
+</xsl:otherwise> 
+</xsl:choose> 
+</ZUONR> 
+<FKONT	ID="35"	Length="3"	Alignment="left" Filler="blank">/</FKONT> 
+<XAABG	ID="36"	Length="1"	Alignment="left" Filler="blank">/</XAABG> 
+<SGTXT	ID="37"	Length="50"	Alignment="left" Filler="blank"> 
+<!-- fa_period Month/fa_period Year Orderno projectno cost_type --> 
+<xsl:variable name="twoDigitYear"> 
+<xsl:value-of select="substring(financialPeriodYear, 3, 4)"/> 
+</xsl:variable> 
+<xsl:value-of select="$twoDigitYear" /> 
+<xsl:value-of select="'/'" /> 
+<xsl:value-of select="financialPeriodMonth" />	
+<xsl:value-of select="' '" /> 
+<xsl:value-of select="orderNumber" />	
+</SGTXT> 
+<BLNKZ	ID="38"	Length="2"	Alignment="left" Filler="blank">/</BLNKZ> 
+<BLNBT	ID="39" Alignment="left" Filler="blank" Length="16">/</BLNBT> 
+<BLNPZ	ID="40" Alignment="left" Filler="blank" Length="8">/</BLNPZ> 
+<MABER	ID="41" Alignment="left" Filler="blank" Length="2">/</MABER> 
+<SKFBT	ID="42" Alignment="left" Filler="blank" Length="16">/</SKFBT> 
+<WSKTO	ID="43" Alignment="left" Filler="blank" Length="16">/</WSKTO> 
+<ZTERM	ID="44" Alignment="left" Filler="blank" Length="4">/</ZTERM> 
+<ZBD1T	ID="45" Alignment="left" Filler="blank" Length="3">/</ZBD1T> 
+<ZBD1P	ID="46" Alignment="left" Filler="blank" Length="6">/</ZBD1P> 
+<ZBD2T	ID="47" Alignment="left" Filler="blank" Length="3">/</ZBD2T> 
+<ZBD2P	ID="48" Alignment="left" Filler="blank" Length="6">/</ZBD2P> 
+<ZBD3T	ID="49" Alignment="left" Filler="blank" Length="3">/</ZBD3T> 
+<ZLSPR	ID="50" Alignment="left" Filler="blank" Length="1">/</ZLSPR> 
+<REBZG	ID="51" Alignment="left" Filler="blank" Length="10">/</REBZG> 
+<REBZJ	ID="52" Alignment="left" Filler="blank" Length="4">/</REBZJ> 
+<REBZZ	ID="53" Alignment="left" Filler="blank" Length="3">/</REBZZ> 
+<ZLSCH	ID="54" Alignment="left" Filler="blank" Length="1">/</ZLSCH> 
+<SAMNR	ID="55" Alignment="left" Filler="blank" Length="8">/</SAMNR> 
+<ZBFIX	ID="56" Alignment="left" Filler="blank" Length="1">/</ZBFIX> 
+<QSSKZ	ID="57" Alignment="left" Filler="blank" Length="2">/</QSSKZ> 
+<QSSHB	ID="58" Alignment="left" Filler="blank" Length="16">/</QSSHB> 
+<QSFBT	ID="59" Alignment="left" Filler="blank" Length="16">/</QSFBT> 
+<ESRNR	ID="60" Alignment="left" Filler="blank" Length="11">/</ESRNR> 
+<ESRPZ	ID="61" Alignment="left" Filler="blank" Length="2">/</ESRPZ> 
+<ESRRE	ID="62" Alignment="left" Filler="blank" Length="27">/</ESRRE> 
+<FDTAG	ID="63" Alignment="left" Filler="blank" Length="8">/</FDTAG> 
+<FDLEV	ID="64" Alignment="left" Filler="blank" Length="2">/</FDLEV> 
+<ANLN1	ID="65" Alignment="left" Filler="blank" Length="12">/</ANLN1> 
+<ANLN2	ID="66" Alignment="left" Filler="blank" Length="4">/</ANLN2> 
+<BZDAT	ID="67" Alignment="left" Filler="blank" Length="8">/</BZDAT> 
+<ANBWA	ID="68" Alignment="left" Filler="blank" Length="3">/</ANBWA> 
+<ABPER	ID="69" Alignment="left" Filler="blank" Length="7">/</ABPER> 
+<GBETR	ID="70" Alignment="left" Filler="blank" Length="16">/</GBETR> 
+<KURSR	ID="71" Alignment="left" Filler="blank" Length="10">/</KURSR> 
+<MANSP	ID="72" Alignment="left" Filler="blank" Length="1">/</MANSP> 
+<MSCHL	ID="73" Alignment="left" Filler="blank" Length="1">/</MSCHL> 
+<HBKID	ID="74" Alignment="left" Filler="blank" Length="5">/</HBKID> 
+<BVTYP	ID="75" Alignment="left" Filler="blank" Length="4">/</BVTYP> 
+<ANFBN	ID="76" Alignment="left" Filler="blank" Length="10">/</ANFBN> 
+<ANFBU	ID="77" Alignment="left" Filler="blank" Length="4">/</ANFBU> 
+<ANFBJ	ID="78" Alignment="left" Filler="blank" Length="4">/</ANFBJ> 
+<LZBKZ	ID="79" Alignment="left" Filler="blank" Length="3"> 
+<xsl:choose> 
+<xsl:when test="orderType='S'"> 
+<xsl:value-of select="$constLZBZK_S_ORDER" /> 
+</xsl:when> 
+<xsl:otherwise> 
+<xsl:value-of select="$constLZBZK_OTHER" /> 
+</xsl:otherwise> 
+</xsl:choose> 
+</LZBKZ> 
+<LANDL	ID="80" Alignment="left" Filler="blank" Length="3">/</LANDL> 
+<DIEKZ	ID="81" Alignment="left" Filler="blank" Length="1">/</DIEKZ> 
+<ZOLLD	ID="82" Alignment="left" Filler="blank" Length="8">/</ZOLLD> 
+<ZOLLT	ID="83" Alignment="left" Filler="blank" Length="8">/</ZOLLT> 
+<VRSDT	ID="84" Alignment="left" Filler="blank" Length="8">/</VRSDT> 
+<VRSKZ	ID="85" Alignment="left" Filler="blank" Length="1">/</VRSKZ> 
+<HZUON	ID="86" Alignment="left" Filler="blank" Length="18">/</HZUON> 
+<REGUL	ID="87" Alignment="left" Filler="blank" Length="1">/</REGUL> 
+<NAME1	ID="88" Alignment="left" Filler="blank" Length="35">/</NAME1> 
+<NAME2	ID="89" Alignment="left" Filler="blank" Length="35">/</NAME2> 
+<NAME3	ID="90" Alignment="left" Filler="blank" Length="35">/</NAME3> 
+<NAME4	ID="91" Alignment="left" Filler="blank" Length="35">/</NAME4> 
+<STRAS	ID="92" Alignment="left" Filler="blank" Length="35">/</STRAS> 
+<ORT01	ID="93" Alignment="left" Filler="blank" Length="35">/</ORT01> 
+<PSTLZ	ID="94" Alignment="left" Filler="blank" Length="10">/</PSTLZ> 
+<LAND1	ID="95" Alignment="left" Filler="blank" Length="3">/</LAND1> 
+<REGIO	ID="96" Alignment="left" Filler="blank" Length="3">/</REGIO> 
+<BANKL	ID="97" Alignment="left" Filler="blank" Length="15">/</BANKL> 
+<BANKS	ID="98" Alignment="left" Filler="blank" Length="3">/</BANKS> 
+<BANKN	ID="99" Alignment="left" Filler="blank" Length="18">/</BANKN> 
+<BKONT	ID="100" Alignment="left" Filler="blank" Length="2">/</BKONT> 
+<STCD1	ID="101" Alignment="left" Filler="blank" Length="16">/</STCD1> 
+<STCD2	ID="102" Alignment="left" Filler="blank" Length="11">/</STCD2> 
+<MADAT	ID="103" Alignment="left" Filler="blank" Length="8">/</MADAT> 
+<MANST	ID="104" Alignment="left" Filler="blank" Length="1">/</MANST> 
+<EGMLD	ID="105" Alignment="left" Filler="blank" Length="3">/</EGMLD> 
+<DUMMY2	ID="106" Alignment="left" Filler="blank" Length="3">/</DUMMY2> 
+<STCEG	ID="107" Alignment="left" Filler="blank" Length="20">/</STCEG> 
+<STKZA	ID="108" Alignment="left" Filler="blank" Length="1">/</STKZA> 
+<STKZU	ID="109" Alignment="left" Filler="blank" Length="1">/</STKZU> 
+<PFACH	ID="110" Alignment="left" Filler="blank" Length="10">/</PFACH> 
+<PSTL2	ID="111" Alignment="left" Filler="blank" Length="10">/</PSTL2> 
+<SPRAS	ID="112" Alignment="left" Filler="blank" Length="1">/</SPRAS> 
+<XINVE	ID="113" Alignment="left" Filler="blank" Length="1">/</XINVE> 
+<NEWKO ID="114" Alignment="left" Filler="blank" Length="17"> 
+<xsl:value-of select="vendorAccountNumber" /> 
+</NEWKO> 
+<NEWBW	Length="3"	Alignment="left" Filler="blank" ID="115">/</NEWBW> 
+<KNRZE	Length="17"	Alignment="left" Filler="blank" ID="116">/</KNRZE> 
+<HKONT	Length="10"	Alignment="left" Filler="blank" ID="117">/</HKONT> 
+<PRCTR	Length="10"	Alignment="left" Filler="blank" ID="118">/</PRCTR> 
+<VERTN	Length="13"	Alignment="left" Filler="blank" ID="119">/</VERTN> 
+<VERTT	Length="1"	Alignment="left" Filler="blank" ID="120">/</VERTT> 
+<VBEWA	Length="4"	Alignment="left" Filler="blank" ID="121">/</VBEWA> 
+<HWBAS	Length="16"	Alignment="left" Filler="blank" ID="122">/</HWBAS> 
+<FWBAS	Length="16"	Alignment="left" Filler="blank" ID="123">/</FWBAS> 
+<FIPOS	Length="14"	Alignment="left" Filler="blank" ID="124">/</FIPOS> 
+<VNAME	Length="6"	Alignment="left" Filler="blank" ID="125">/</VNAME> 
+<EGRUP	Length="3"	Alignment="left" Filler="blank" ID="126">/</EGRUP> 
+<BTYPE	Length="2"	Alignment="left" Filler="blank" ID="127">/</BTYPE> 
+<PAOBJNR	Length="10"	Alignment="left" Filler="blank" ID="128">/</PAOBJNR> 
+<KSTRG	Length="12"	Alignment="left" Filler="blank" ID="129">/</KSTRG> 
+<IMKEY	Length="8"	Alignment="left" Filler="blank" ID="130">/</IMKEY> 
+<DUMMY3	Length="8"	Alignment="left" Filler="blank" ID="131">/</DUMMY3> 
+<VPTNR	Length="10"	Alignment="left" Filler="blank" ID="132">/</VPTNR> 
+<NPLNR	Length="12"	Alignment="left" Filler="blank" ID="133">/</NPLNR> 
+<VORNR	Length="4"	Alignment="left" Filler="blank" ID="134">/</VORNR> 
+<XEGDR	Length="1"	Alignment="left" Filler="blank" ID="135">/</XEGDR> 
+<RECID	Length="2"	Alignment="left" Filler="blank" ID="136">/</RECID> 
+<PPRCT	Length="10"	Alignment="left" Filler="blank" ID="137">/</PPRCT> 
+<PROJK	Length="24"	Alignment="left" Filler="blank" ID="138">/</PROJK> 
+<UZAWE	Length="2"	Alignment="left" Filler="blank" ID="139">/</UZAWE> 
+<TXJCD	Length="15"	Alignment="left" Filler="blank" ID="140">/</TXJCD> 
+<FISTL	Length="16"	Alignment="left" Filler="blank" ID="141">/</FISTL> 
+<GEBER	Length="10"	Alignment="left" Filler="blank" ID="142">/</GEBER> 
+<DMBE2	Length="16"	Alignment="left" Filler="blank" ID="143">/</DMBE2> 
+<DMBE3	Length="16"	Alignment="left" Filler="blank" ID="144">/</DMBE3> 
+<PARGB	Length="4"	Alignment="left" Filler="blank" ID="145">/</PARGB> 
+<XREF1	Length="12"	Alignment="left" Filler="blank" ID="146">/</XREF1> 
+<XREF2	Length="12"	Alignment="left" Filler="blank" ID="147">/</XREF2> 
+<KBLNR	Length="10"	Alignment="left" Filler="blank" ID="149">/</KBLNR> 
+<KBLPOS	Length="3"	Alignment="left" Filler="blank" ID="150">/</KBLPOS> 
+<WDATE	Length="8"	Alignment="left" Filler="blank" ID="151">/</WDATE> 
+<WGBKZ	Length="1"	Alignment="left" Filler="blank" ID="152">/</WGBKZ> 
+<XAKTZ	Length="1"	Alignment="left" Filler="blank" ID="153">/</XAKTZ> 
+<WNAME	Length="30"	Alignment="left" Filler="blank" ID="154">/</WNAME> 
+<WORT1	Length="30"	Alignment="left" Filler="blank" ID="155">/</WORT1> 
+<WBZOG	Length="30"	Alignment="left" Filler="blank" ID="156">/</WBZOG> 
+<WORT2	Length="30"	Alignment="left" Filler="blank" ID="157">/</WORT2> 
+<WBANK	Length="60"	Alignment="left" Filler="blank" ID="158">/</WBANK> 
+<WLZBP	Length="60"	Alignment="left" Filler="blank" ID="159">/</WLZBP> 
+<DISKP	Length="8"	Alignment="left" Filler="blank" ID="160">/</DISKP> 
+<DISKT	Length="3"	Alignment="left" Filler="blank" ID="161">/</DISKT> 
+<WINFW	Length="16"	Alignment="left" Filler="blank" ID="162">/</WINFW> 
+<WINHW	Length="16"	Alignment="left" Filler="blank" ID="163">/</WINHW> 
+<WEVWV	Length="1"	Alignment="left" Filler="blank" ID="164">/</WEVWV> 
+<WSTAT	Length="1"	Alignment="left" Filler="blank" ID="165">/</WSTAT> 
+<WMWKZ	Length="2"	Alignment="left" Filler="blank" ID="166">/</WMWKZ> 
+<WSTKZ	Length="1"	Alignment="left" Filler="blank" ID="167">/</WSTKZ> 
+<RKE_ARTNR	Length="18"	Alignment="left" Filler="blank" ID="169">/</RKE_ARTNR> 
+<RKE_BONUS	Length="2"	Alignment="left" Filler="blank" ID="170">/</RKE_BONUS> 
+<RKE_BRSCH	Length="4"	Alignment="left" Filler="blank" ID="171">/</RKE_BRSCH> 
+<RKE_BUKRS	Length="4"	Alignment="left" Filler="blank" ID="172">/</RKE_BUKRS> 
+<RKE_BZIRK	Length="6"	Alignment="left" Filler="blank" ID="173">/</RKE_BZIRK> 
+<RKE_EFORM	Length="5"	Alignment="left" Filler="blank" ID="174">/</RKE_EFORM> 
+<RKE_FKART	Length="4"	Alignment="left" Filler="blank" ID="175">/</RKE_FKART> 
+<RKE_GEBIE	Length="4"	Alignment="left" Filler="blank" ID="176">/</RKE_GEBIE> 
+<RKE_GSBER	Length="4"	Alignment="left" Filler="blank" ID="177">/</RKE_GSBER> 
+<RKE_KAUFN	Length="10"	Alignment="left" Filler="blank" ID="178">/</RKE_KAUFN> 
+<RKE_KDGRP	Length="2"	Alignment="left" Filler="blank" ID="179">/</RKE_KDGRP> 
+<RKE_KDPOS	Length="6"	Alignment="left" Filler="blank" ID="180">/</RKE_KDPOS> 
+<RKE_KNDNR	Length="10"	Alignment="left" Filler="blank" ID="181">/</RKE_KNDNR> 
+<RKE_KOKRS	Length="4"	Alignment="left" Filler="blank" ID="182">/</RKE_KOKRS> 
+<RKE_KSTRG	Length="12"	Alignment="left" Filler="blank" ID="183">/</RKE_KSTRG> 
+<RKE_LAND1	Length="3"	Alignment="left" Filler="blank" ID="184">/</RKE_LAND1> 
+<RKE_MAABC	Length="1"	Alignment="left" Filler="blank" ID="185">/</RKE_MAABC> 
+<RKE_MATKL	Length="9"	Alignment="left" Filler="blank" ID="186">/</RKE_MATKL> 
+<RKE_PRCTR	Length="10"	Alignment="left" Filler="blank" ID="187">/</RKE_PRCTR> 
+<RKE_PSPNR	Length="24"	Alignment="left" Filler="blank" ID="188">/</RKE_PSPNR> 
+<RKE_RKAUFNR	Length="12"	Alignment="left" Filler="blank" ID="189">/</RKE_RKAUFNR> 
+<RKE_SPART	Length="2"	Alignment="left" Filler="blank" ID="190">/</RKE_SPART> 
+<RKE_VKBUR	Length="4"	Alignment="left" Filler="blank" ID="191">/</RKE_VKBUR> 
+<RKE_VKGRP	Length="3"	Alignment="left" Filler="blank" ID="192">/</RKE_VKGRP> 
+<RKE_VKORG	Length="4"	Alignment="left" Filler="blank" ID="193">/</RKE_VKORG> 
+<RKE_VTWEG	Length="2"	Alignment="left" Filler="blank" ID="194">/</RKE_VTWEG> 
+<RKE_WERKS	Length="4"	Alignment="left" Filler="blank" ID="195">/</RKE_WERKS> 
+<RKE_KMBRND	Length="2"	Alignment="left" Filler="blank" ID="196">/</RKE_KMBRND> 
+<RKE_KMCATG	Length="2"	Alignment="left" Filler="blank" ID="197">/</RKE_KMCATG> 
+<RKE_KMHI01	Length="10"	Alignment="left" Filler="blank" ID="198">/</RKE_KMHI01> 
+<RKE_KMHI02	Length="10"	Alignment="left" Filler="blank" ID="199">/</RKE_KMHI02> 
+<RKE_KMHI03	Length="10"	Alignment="left" Filler="blank" ID="200">/</RKE_KMHI03> 
+<RKE_KMKDGR	Length="2"	Alignment="left" Filler="blank" ID="201">/</RKE_KMKDGR> 
+<RKE_KMLAND	Length="3"	Alignment="left" Filler="blank" ID="202">/</RKE_KMLAND> 
+<RKE_KMMAKL	Length="9"	Alignment="left" Filler="blank" ID="203">/</RKE_KMMAKL> 
+<RKE_KMNIEL	Length="2"	Alignment="left" Filler="blank" ID="204">/</RKE_KMNIEL> 
+<RKE_KMSTGE	Length="2"	Alignment="left" Filler="blank" ID="205">/</RKE_KMSTGE> 
+<RKE_KMVKBU	Length="4"	Alignment="left" Filler="blank" ID="206">/</RKE_KMVKBU> 
+<RKE_KMVKGR	Length="3"	Alignment="left" Filler="blank" ID="207">/</RKE_KMVKGR> 
+<RKE_KMVTNR	Length="8"	Alignment="left" Filler="blank" ID="208">/</RKE_KMVTNR> 
+<RKE_PPRCTR	Length="10"	Alignment="left" Filler="blank" ID="209">/</RKE_PPRCTR> 
+
+<!-- START new RKE-elements --> 
+<RKE_WW005	Length="5"	Alignment="left" Filler="blank" ID="276">/</RKE_WW005> 
+<RKE_WW006	Length="5"	Alignment="left" Filler="blank" ID="277">/</RKE_WW006> 
+<RKE_WW007	Length="3"	Alignment="left" Filler="blank" ID="278">/</RKE_WW007> 
+<RKE_WW008	Length="3"	Alignment="left" Filler="blank" ID="279">/</RKE_WW008> 
+<RKE_WW009	Length="1"	Alignment="left" Filler="blank" ID="280">/</RKE_WW009> 
+<RKE_WW010	Length="3"	Alignment="left" Filler="blank" ID="281">/</RKE_WW010> 
+<RKE_WW011	Length="2"	Alignment="left" Filler="blank" ID="282">/</RKE_WW011> 
+<RKE_WW012	Length="6"	Alignment="left" Filler="blank" ID="283">/</RKE_WW012> 
+<RKE_WW013	Length="10"	Alignment="left" Filler="blank" ID="284">/</RKE_WW013> 
+<RKE_WW015	Length="1"	Alignment="left" Filler="blank" ID="285">/</RKE_WW015> 
+<RKE_WW016	Length="2"	Alignment="left" Filler="blank" ID="286">/</RKE_WW016> 
+<RKE_WW017	Length="7"	Alignment="left" Filler="blank" ID="287">/</RKE_WW017> 
+<RKE_WW019	Length="6"	Alignment="left" Filler="blank" ID="289">/</RKE_WW019> 
+<!-- END new RKE-elements --> 
+
+<VBUND	Length="6"	Alignment="left" Filler="blank" ID="210">/</VBUND> 
+<FKBER	Length="4"	Alignment="left" Filler="blank" ID="211">/</FKBER> 
+<DABRZ	Length="8"	Alignment="left" Filler="blank" ID="212">/</DABRZ> 
+<XSTBA	Length="1"	Alignment="left" Filler="blank" ID="213">/</XSTBA> 
+
+<!-- START Additional (empty) tags --> 
+<RSTGR	Length="3" Alignment="left" Filler="blank" ID="214">/</RSTGR> 
+<FIPEX	Length="24" Alignment="left" Filler="blank" ID="215">/</FIPEX> 
+<XNEGP	Length="1" Alignment="left" Filler="blank" ID="216">/</XNEGP> 
+<GRICD	Length="2" Alignment="left" Filler="blank" ID="217">/</GRICD> 
+<GRIRG	Length="3" Alignment="left" Filler="blank" ID="218">/</GRIRG> 
+<GITYP	Length="2" Alignment="left" Filler="blank" ID="219">/</GITYP> 
+<FITYP	Length="2" Alignment="left" Filler="blank" ID="220">/</FITYP> 
+<STCDT	Length="2" Alignment="left" Filler="blank" ID="221">/</STCDT> 
+<STKZN	Length="1" Alignment="left" Filler="blank" ID="222">/</STKZN> 
+<STCD3	Length="18" Alignment="left" Filler="blank" ID="223">/</STCD3> 
+<STCD4	Length="18" Alignment="left" Filler="blank" ID="224">/</STCD4> 
+<XREF3	Length="20" Alignment="left" Filler="blank" ID="225">/</XREF3> 
+<KIDNO	Length="30" Alignment="left" Filler="blank" ID="226">/</KIDNO> 
+<DTWS1	Length="2" Alignment="left" Filler="blank" ID="227">/</DTWS1> 
+<DTWS2	Length="2" Alignment="left" Filler="blank" ID="228">/</DTWS2> 
+<DTWS3	Length="2" Alignment="left" Filler="blank" ID="229">/</DTWS3> 
+<DTWS4	Length="2" Alignment="left" Filler="blank" ID="230">/</DTWS4> 
+<DTAWS	Length="2" Alignment="left" Filler="blank" ID="231">/</DTAWS> 
+<PYCUR	Length="5" Alignment="left" Filler="blank" ID="232">/</PYCUR> 
+<PYAMT	Length="16" Alignment="left" Filler="blank" ID="233">/</PYAMT> 
+<BUPLA	Length="4" Alignment="left" Filler="blank" ID="234">/</BUPLA> 
+<SECCO	Length="4" Alignment="left" Filler="blank" ID="235">/</SECCO> 
+<LSTAR	Length="6" Alignment="left" Filler="blank" ID="236">/</LSTAR> 
+<EGDEB	Length="10" Alignment="left" Filler="blank" ID="237">/</EGDEB> 
+<WENR	Length="8" Alignment="left" Filler="blank" ID="238">/</WENR> 
+<GENR	Length="8" Alignment="left" Filler="blank" ID="239">/</GENR> 
+<GRNR	Length="8" Alignment="left" Filler="blank" ID="240">/</GRNR> 
+<MENR	Length="8" Alignment="left" Filler="blank" ID="241">/</MENR> 
+<MIVE	Length="13" Alignment="left" Filler="blank" ID="242">/</MIVE> 
+<NKSL	Length="4" Alignment="left" Filler="blank" ID="243">/</NKSL> 
+<EMPSL	Length="5" Alignment="left" Filler="blank" ID="244">/</EMPSL> 
+<SVWNR	Length="13" Alignment="left" Filler="blank" ID="245">/</SVWNR> 
+<SBERI	Length="10" Alignment="left" Filler="blank" ID="246">/</SBERI> 
+<KKBER	Length="4" Alignment="left" Filler="blank" ID="247">/</KKBER> 
+<EMPFB	Length="10" Alignment="left" Filler="blank" ID="248">/</EMPFB> 
+<KURSR_M	Length="10" Alignment="left" Filler="blank" ID="249">/</KURSR_M> 
+<J_1KFREPRE	Length="10" Alignment="left" Filler="blank" ID="250">/</J_1KFREPRE> 
+<J_1KFTBUS	Length="30" Alignment="left" Filler="blank" ID="251">/</J_1KFTBUS> 
+<J_1KFTIND	Length="30" Alignment="left" Filler="blank" ID="252">/</J_1KFTIND> 
+<IDXSP	Length="5" Alignment="left" Filler="blank" ID="253">/</IDXSP> 
+<ANRED	Length="15" Alignment="left" Filler="blank" ID="254">/</ANRED> 
+<RECNNR	Length="13" Alignment="left" Filler="blank" ID="255">/</RECNNR> 
+<E_MIVE	Length="13" Alignment="left" Filler="blank" ID="256">/</E_MIVE> 
+<BKREF	Length="20" Alignment="left" Filler="blank" ID="257">/</BKREF> 
+<DTAMS	Length="1" Alignment="left" Filler="blank" ID="258">/</DTAMS> 
+<CESSION_KZ	Length="2" Alignment="left" Filler="blank" ID="259">/</CESSION_KZ> 
+<GRANT_NBR	Length="20" Alignment="left" Filler="blank" ID="260">/</GRANT_NBR> 
+<FKBER_LONG	Length="16" Alignment="left" Filler="blank" ID="261">/</FKBER_LONG> 
+<ERLKZ	Length="1" Alignment="left" Filler="blank" ID="262">/</ERLKZ> 
+<IBAN	Length="34" Alignment="left" Filler="blank" ID="263">/</IBAN> 
+<VALID_FROM	Length="8" Alignment="left" Filler="blank" ID="264">/</VALID_FROM> 
+<SEGMENT	Length="10" Alignment="left" Filler="blank" ID="265">/</SEGMENT> 
+<PSEGMENT	Length="10" Alignment="left" Filler="blank" ID="266">/</PSEGMENT> 
+<HKTID	Length="5" Alignment="left" Filler="blank" ID="267">/</HKTID> 
+<XSIWE	Length="1" Alignment="left" Filler="blank" ID="268">/</XSIWE> 
+<TCNO	Length="16" Alignment="left" Filler="blank" ID="269">/</TCNO> 
+<DATEOFSERVICE	Length="8" Alignment="left" Filler="blank" ID="270">/</DATEOFSERVICE> 
+<NOTAXCORR	Length="1" Alignment="left" Filler="blank" ID="271">/</NOTAXCORR> 
+<DIFFOPTRATE	Length="10" Alignment="left" Filler="blank" ID="272">/</DIFFOPTRATE> 
+<HASDIFFOPTRATE	Length="1" Alignment="left" Filler="blank" ID="273">/</HASDIFFOPTRATE> 
+<SENDE	Length="1" Alignment="left" Filler="blank" ID="274">/</SENDE> 
+<PRODPER	Length="8" Alignment="left" Filler="blank" ID="275">/</PRODPER> 
+<!-- END Additional tags --> 
+
+</header_1_elements> 
+</xsl:template> 
+
+<xsl:template name="invoiceCharges_1_elements"> 
+<invoiceCharges_1_elements> 
+<STYPE ID="1"	Length="1"	Alignment="left" Filler="blank">2</STYPE> 
+<TBNAM ID="2"	Length="30"	Alignment="left" Filler="blank">BBSEG</TBNAM> 
+<NEWBS ID="3"	Length="2"	Alignment="left" Filler="blank"> 
+<xsl:if test="parent::node()/type='I'">40</xsl:if> 
+<xsl:if test="parent::node()/type='C'">50</xsl:if> 
+</NEWBS> 
+<DUMMYX	ID="4"	Length="10"	Alignment="left" Filler="blank">/</DUMMYX> 
+<NEWUM	ID="5"	Length="1"	Alignment="left" Filler="blank">/</NEWUM> 
+<NEWBK	ID="6"	Length="4"	Alignment="left" Filler="blank">/</NEWBK> 
+<WRBTR	ID="7"	Length="16"	Alignment="left" Filler="blank"> 
+<!--	<xsl:value-of select="format-number(totalAmount, '#0.00', 'european')"/>	--> 
+<xsl:value-of select="format-number(totalAmount, '0000000000000,00', 'european')"/>	
+</WRBTR> 
+<DMBTR	ID="8"	Length="16"	Alignment="left" Filler="blank">/</DMBTR> 
+<WMWST	ID="9"	Length="16"	Alignment="left" Filler="blank">/</WMWST> 
+<MWSTS	ID="10"	Length="16"	Alignment="left" Filler="blank">/</MWSTS> 
+<MWSKZ	ID="11"	Length="2"	Alignment="left" Filler="blank"> 
+<xsl:value-of select="parent::node()/financialTaxCode" /> 
+</MWSKZ> 
+<XSKRL	ID="12"	Length="1"	Alignment="left" Filler="blank">/</XSKRL> 
+<FWZUZ	ID="13"	Length="16"	Alignment="left" Filler="blank">/</FWZUZ> 
+<HWZUZ	ID="14"	Length="16"	Alignment="left" Filler="blank">/</HWZUZ> 
+<GSBER	ID="15"	Length="4"	Alignment="left" Filler="blank">/</GSBER> 
+<KOSTL	ID="16"	Length="10"	Alignment="left" Filler="blank"> 
+<xsl:choose> 
+<xsl:when test="financialCostcenter and string-length(financialCostcenter) &gt; 0"> 
+<xsl:value-of select="financialCostcenter" /> 
+</xsl:when> 
+<xsl:otherwise> 
+<xsl:value-of select="'/'" /> 
+</xsl:otherwise> 
+</xsl:choose> 
+</KOSTL> 
+<DUMMY4	ID="17"	Length="4"	Alignment="left" Filler="blank">/</DUMMY4> 
+<AUFNR	ID="18"	Length="12"	Alignment="left" Filler="blank"> 
+<xsl:choose> 
+<xsl:when test="costcenter2 and string-length(costcenter2) &gt; 0"> 
+<xsl:value-of select="costcenter2" /> 
+</xsl:when> 
+<xsl:otherwise> 
+<xsl:value-of select="'/'" /> 
+</xsl:otherwise> 
+</xsl:choose> 
+</AUFNR> 
+<EBELN	ID="19"	Length="10"	Alignment="left" Filler="blank">/</EBELN> 
+<EBELP	ID="20"	Length="5"	Alignment="left" Filler="blank">/</EBELP> 
+<PROJN	ID="21"	Length="16"	Alignment="left" Filler="blank">/</PROJN> 
+<MATNR	ID="22"	Length="18"	Alignment="left" Filler="blank">/</MATNR> 
+<WERKS	ID="23"	Length="4"	Alignment="left" Filler="blank">/</WERKS> 
+<MENGE	ID="24"	Length="17"	Alignment="left" Filler="blank">/</MENGE> 
+<MEINS	ID="25"	Length="3"	Alignment="left" Filler="blank">/</MEINS> 
+<VBEL2	ID="26"	Length="10"	Alignment="left" Filler="blank">/</VBEL2> 
+<POSN2	ID="27"	Length="6"	Alignment="left" Filler="blank">/</POSN2> 
+<ETEN2	ID="28"	Length="4"	Alignment="left" Filler="blank">/</ETEN2> 
+<PERNR	ID="29"	Length="8"	Alignment="left" Filler="blank">/</PERNR> 
+<BEWAR	ID="30"	Length="3"	Alignment="left" Filler="blank">/</BEWAR> 
+<VALUT	ID="31"	Length="8"	Alignment="left" Filler="blank">/</VALUT> 
+<ZFBDT	ID="32"	Length="8"	Alignment="left" Filler="blank">/</ZFBDT> 
+<ZINKZ	ID="33"	Length="2"	Alignment="left" Filler="blank">/</ZINKZ> 
+<ZUONR	ID="34"	Length="18"	Alignment="left" Filler="blank"> 
+<xsl:value-of select="orderNumber" /> 
+</ZUONR> 
+<FKONT	ID="35"	Length="3"	Alignment="left" Filler="blank">/</FKONT> 
+<XAABG	ID="36"	Length="1"	Alignment="left" Filler="blank">/</XAABG> 
+<SGTXT	ID="37"	Length="50"	Alignment="left" Filler="blank"> 
+<xsl:variable name="twoDigitYear"> 
+<xsl:value-of select="substring(parent::node()/financialPeriodYear, 3, 4)"/> 
+</xsl:variable> 
+<xsl:value-of select="$twoDigitYear" /> 
+<xsl:value-of select="'/'" /> 
+<xsl:value-of select="parent::node()/financialPeriodMonth" /> 
+</SGTXT> 
+<BLNKZ	ID="38"	Length="2"	Alignment="left" Filler="blank">/</BLNKZ> 
+<BLNBT	ID="39" Alignment="left" Filler="blank" Length="16">/</BLNBT> 
+<BLNPZ	ID="40" Alignment="left" Filler="blank" Length="8">/</BLNPZ> 
+<MABER	ID="41" Alignment="left" Filler="blank" Length="2">/</MABER> 
+<SKFBT	ID="42" Alignment="left" Filler="blank" Length="16">/</SKFBT> 
+<WSKTO	ID="43" Alignment="left" Filler="blank" Length="16">/</WSKTO> 
+<ZTERM	ID="44" Alignment="left" Filler="blank" Length="4">/</ZTERM> 
+<ZBD1T	ID="45" Alignment="left" Filler="blank" Length="3">/</ZBD1T> 
+<ZBD1P	ID="46" Alignment="left" Filler="blank" Length="6">/</ZBD1P> 
+<ZBD2T	ID="47" Alignment="left" Filler="blank" Length="3">/</ZBD2T> 
+<ZBD2P	ID="48" Alignment="left" Filler="blank" Length="6">/</ZBD2P> 
+<ZBD3T	ID="49" Alignment="left" Filler="blank" Length="3">/</ZBD3T> 
+<ZLSPR	ID="50" Alignment="left" Filler="blank" Length="1">/</ZLSPR> 
+<REBZG	ID="51" Alignment="left" Filler="blank" Length="10">/</REBZG> 
+<REBZJ	ID="52" Alignment="left" Filler="blank" Length="4">/</REBZJ> 
+<REBZZ	ID="53" Alignment="left" Filler="blank" Length="3">/</REBZZ> 
+<ZLSCH	ID="54" Alignment="left" Filler="blank" Length="1">/</ZLSCH> 
+<SAMNR	ID="55" Alignment="left" Filler="blank" Length="8">/</SAMNR> 
+<ZBFIX	ID="56" Alignment="left" Filler="blank" Length="1">/</ZBFIX> 
+<QSSKZ	ID="57" Alignment="left" Filler="blank" Length="2">/</QSSKZ> 
+<QSSHB	ID="58" Alignment="left" Filler="blank" Length="16">/</QSSHB> 
+<QSFBT	ID="59" Alignment="left" Filler="blank" Length="16">/</QSFBT> 
+<ESRNR	ID="60" Alignment="left" Filler="blank" Length="11">/</ESRNR> 
+<ESRPZ	ID="61" Alignment="left" Filler="blank" Length="2">/</ESRPZ> 
+<ESRRE	ID="62" Alignment="left" Filler="blank" Length="27">/</ESRRE> 
+<FDTAG	ID="63" Alignment="left" Filler="blank" Length="8">/</FDTAG> 
+<FDLEV	ID="64" Alignment="left" Filler="blank" Length="2">/</FDLEV> 
+<ANLN1	ID="65" Alignment="left" Filler="blank" Length="12">/</ANLN1> 
+<ANLN2	ID="66" Alignment="left" Filler="blank" Length="4">/</ANLN2> 
+<BZDAT	ID="67" Alignment="left" Filler="blank" Length="8">/</BZDAT> 
+<ANBWA	ID="68" Alignment="left" Filler="blank" Length="3">/</ANBWA> 
+<ABPER	ID="69" Alignment="left" Filler="blank" Length="7">/</ABPER> 
+<GBETR	ID="70" Alignment="left" Filler="blank" Length="16">/</GBETR> 
+<KURSR	ID="71" Alignment="left" Filler="blank" Length="10">/</KURSR> 
+<MANSP	ID="72" Alignment="left" Filler="blank" Length="1">/</MANSP> 
+<MSCHL	ID="73" Alignment="left" Filler="blank" Length="1">/</MSCHL> 
+<HBKID	ID="74" Alignment="left" Filler="blank" Length="5">/</HBKID> 
+<BVTYP	ID="75" Alignment="left" Filler="blank" Length="4">/</BVTYP> 
+<ANFBN	ID="76" Alignment="left" Filler="blank" Length="10">/</ANFBN> 
+<ANFBU	ID="77" Alignment="left" Filler="blank" Length="4">/</ANFBU> 
+<ANFBJ	ID="78" Alignment="left" Filler="blank" Length="4">/</ANFBJ> 
+<LZBKZ	ID="79" Alignment="left" Filler="blank" Length="3"> 
+<xsl:choose> 
+<xsl:when test="parent::node()/orderType='S'"> 
+<xsl:value-of select="$constLZBZK_S_ORDER" /> 
+</xsl:when> 
+<xsl:otherwise> 
+<xsl:value-of select="$constLZBZK_OTHER" /> 
+</xsl:otherwise> 
+</xsl:choose> 
+</LZBKZ> 
+<LANDL	ID="80" Alignment="left" Filler="blank" Length="3">/</LANDL> 
+<DIEKZ	ID="81" Alignment="left" Filler="blank" Length="1">/</DIEKZ> 
+<ZOLLD	ID="82" Alignment="left" Filler="blank" Length="8">/</ZOLLD> 
+<ZOLLT	ID="83" Alignment="left" Filler="blank" Length="8">/</ZOLLT> 
+<VRSDT	ID="84" Alignment="left" Filler="blank" Length="8">/</VRSDT> 
+<VRSKZ	ID="85" Alignment="left" Filler="blank" Length="1">/</VRSKZ> 
+<HZUON	ID="86" Alignment="left" Filler="blank" Length="18">/</HZUON> 
+<REGUL	ID="87" Alignment="left" Filler="blank" Length="1">/</REGUL> 
+<NAME1	ID="88" Alignment="left" Filler="blank" Length="35">/</NAME1> 
+<NAME2	ID="89" Alignment="left" Filler="blank" Length="35">/</NAME2> 
+<NAME3	ID="90" Alignment="left" Filler="blank" Length="35">/</NAME3> 
+<NAME4	ID="91" Alignment="left" Filler="blank" Length="35">/</NAME4> 
+<STRAS	ID="92" Alignment="left" Filler="blank" Length="35">/</STRAS> 
+<ORT01	ID="93" Alignment="left" Filler="blank" Length="35">/</ORT01> 
+<PSTLZ	ID="94" Alignment="left" Filler="blank" Length="10">/</PSTLZ> 
+<LAND1	ID="95" Alignment="left" Filler="blank" Length="3">/</LAND1> 
+<REGIO	ID="96" Alignment="left" Filler="blank" Length="3">/</REGIO> 
+<BANKL	ID="97" Alignment="left" Filler="blank" Length="15">/</BANKL> 
+<BANKS	ID="98" Alignment="left" Filler="blank" Length="3">/</BANKS> 
+<BANKN	ID="99" Alignment="left" Filler="blank" Length="18">/</BANKN> 
+<BKONT	ID="100" Alignment="left" Filler="blank" Length="2">/</BKONT> 
+<STCD1	ID="101" Alignment="left" Filler="blank" Length="16">/</STCD1> 
+<STCD2	ID="102" Alignment="left" Filler="blank" Length="11">/</STCD2> 
+<MADAT	ID="103" Alignment="left" Filler="blank" Length="8">/</MADAT> 
+<MANST	ID="104" Alignment="left" Filler="blank" Length="1">/</MANST> 
+<EGMLD	ID="105" Alignment="left" Filler="blank" Length="3">/</EGMLD> 
+<DUMMY2	ID="106" Alignment="left" Filler="blank" Length="3">/</DUMMY2> 
+<STCEG	ID="107" Alignment="left" Filler="blank" Length="20">/</STCEG> 
+<STKZA	ID="108" Alignment="left" Filler="blank" Length="1">/</STKZA> 
+<STKZU	ID="109" Alignment="left" Filler="blank" Length="1">/</STKZU> 
+<PFACH	ID="110" Alignment="left" Filler="blank" Length="10">/</PFACH> 
+<PSTL2	ID="111" Alignment="left" Filler="blank" Length="10">/</PSTL2> 
+<SPRAS	ID="112" Alignment="left" Filler="blank" Length="1">/</SPRAS> 
+<XINVE	ID="113" Alignment="left" Filler="blank" Length="1">/</XINVE> 
+<NEWKO ID="114" Length="17" Alignment="left" Filler="blank"> 
+<xsl:value-of select="accountNumber" /> 
+</NEWKO> 
+<NEWBW	Length="3"	Alignment="left" Filler="blank" ID="115">/</NEWBW> 
+<KNRZE	Length="17"	Alignment="left" Filler="blank" ID="116">/</KNRZE> 
+<HKONT	Length="10"	Alignment="left" Filler="blank" ID="117">/</HKONT> 
+<PRCTR	Length="10"	Alignment="left" Filler="blank" ID="118">/</PRCTR> 
+<VERTN	Length="13"	Alignment="left" Filler="blank" ID="119">/</VERTN> 
+<VERTT	Length="1"	Alignment="left" Filler="blank" ID="120">/</VERTT> 
+<VBEWA	Length="4"	Alignment="left" Filler="blank" ID="121">/</VBEWA> 
+<HWBAS	Length="16"	Alignment="left" Filler="blank" ID="122">/</HWBAS> 
+<FWBAS	Length="16"	Alignment="left" Filler="blank" ID="123">/</FWBAS> 
+<FIPOS	Length="14"	Alignment="left" Filler="blank" ID="124">/</FIPOS> 
+<VNAME	Length="6"	Alignment="left" Filler="blank" ID="125">/</VNAME> 
+<EGRUP	Length="3"	Alignment="left" Filler="blank" ID="126">/</EGRUP> 
+<BTYPE	Length="2"	Alignment="left" Filler="blank" ID="127">/</BTYPE> 
+<PAOBJNR	Length="10"	Alignment="left" Filler="blank" ID="128">/</PAOBJNR> 
+<KSTRG	Length="12"	Alignment="left" Filler="blank" ID="129">/</KSTRG> 
+<IMKEY	Length="8"	Alignment="left" Filler="blank" ID="130">/</IMKEY> 
+<DUMMY3	Length="8"	Alignment="left" Filler="blank" ID="131">/</DUMMY3> 
+<VPTNR	Length="10"	Alignment="left" Filler="blank" ID="132">/</VPTNR> 
+<NPLNR	Length="12"	Alignment="left" Filler="blank" ID="133">/</NPLNR> 
+<VORNR	Length="4"	Alignment="left" Filler="blank" ID="134">/</VORNR> 
+<XEGDR	Length="1"	Alignment="left" Filler="blank" ID="135">/</XEGDR> 
+<RECID	Length="2"	Alignment="left" Filler="blank" ID="136">/</RECID> 
+<PPRCT	Length="10"	Alignment="left" Filler="blank" ID="137">/</PPRCT> 
+<PROJK	Length="24"	Alignment="left" Filler="blank" ID="138">/</PROJK> 
+<UZAWE	Length="2"	Alignment="left" Filler="blank" ID="139">/</UZAWE> 
+<TXJCD	Length="15"	Alignment="left" Filler="blank" ID="140">/</TXJCD> 
+<FISTL	Length="16"	Alignment="left" Filler="blank" ID="141">/</FISTL> 
+<GEBER	Length="10"	Alignment="left" Filler="blank" ID="142">/</GEBER> 
+<DMBE2	Length="16"	Alignment="left" Filler="blank" ID="143">/</DMBE2> 
+<DMBE3	Length="16"	Alignment="left" Filler="blank" ID="144">/</DMBE3> 
+<PARGB	Length="4"	Alignment="left" Filler="blank" ID="145">/</PARGB> 
+<XREF1	Length="12"	Alignment="left" Filler="blank" ID="146">/</XREF1> 
+<XREF2	Length="12"	Alignment="left" Filler="blank" ID="147">/</XREF2> 
+<KBLNR	Length="10"	Alignment="left" Filler="blank" ID="149">/</KBLNR> 
+<KBLPOS	Length="3"	Alignment="left" Filler="blank" ID="150">/</KBLPOS> 
+<WDATE	Length="8"	Alignment="left" Filler="blank" ID="151">/</WDATE> 
+<WGBKZ	Length="1"	Alignment="left" Filler="blank" ID="152">/</WGBKZ> 
+<XAKTZ	Length="1"	Alignment="left" Filler="blank" ID="153">/</XAKTZ> 
+<WNAME	Length="30"	Alignment="left" Filler="blank" ID="154">/</WNAME> 
+<WORT1	Length="30"	Alignment="left" Filler="blank" ID="155">/</WORT1> 
+<WBZOG	Length="30"	Alignment="left" Filler="blank" ID="156">/</WBZOG> 
+<WORT2	Length="30"	Alignment="left" Filler="blank" ID="157">/</WORT2> 
+<WBANK	Length="60"	Alignment="left" Filler="blank" ID="158">/</WBANK> 
+<WLZBP	Length="60"	Alignment="left" Filler="blank" ID="159">/</WLZBP> 
+<DISKP	Length="8"	Alignment="left" Filler="blank" ID="160">/</DISKP> 
+<DISKT	Length="3"	Alignment="left" Filler="blank" ID="161">/</DISKT> 
+<WINFW	Length="16"	Alignment="left" Filler="blank" ID="162">/</WINFW> 
+<WINHW	Length="16"	Alignment="left" Filler="blank" ID="163">/</WINHW> 
+<WEVWV	Length="1"	Alignment="left" Filler="blank" ID="164">/</WEVWV> 
+<WSTAT	Length="1"	Alignment="left" Filler="blank" ID="165">/</WSTAT> 
+<WMWKZ	Length="2"	Alignment="left" Filler="blank" ID="166">/</WMWKZ> 
+<WSTKZ	Length="1"	Alignment="left" Filler="blank" ID="167">/</WSTKZ> 
+<RKE_ARTNR	Length="18"	Alignment="left" Filler="blank" ID="169">/</RKE_ARTNR> 
+<RKE_BONUS	Length="2"	Alignment="left" Filler="blank" ID="170">/</RKE_BONUS> 
+<RKE_BRSCH	Length="4"	Alignment="left" Filler="blank" ID="171">/</RKE_BRSCH> 
+<RKE_BUKRS	Length="4"	Alignment="left" Filler="blank" ID="172">/</RKE_BUKRS> 
+<RKE_BZIRK	Length="6"	Alignment="left" Filler="blank" ID="173">/</RKE_BZIRK> 
+<RKE_EFORM	Length="5"	Alignment="left" Filler="blank" ID="174">/</RKE_EFORM> 
+<RKE_FKART	Length="4"	Alignment="left" Filler="blank" ID="175">/</RKE_FKART> 
+<RKE_GEBIE	Length="4"	Alignment="left" Filler="blank" ID="176">/</RKE_GEBIE> 
+<RKE_GSBER	Length="4"	Alignment="left" Filler="blank" ID="177">/</RKE_GSBER> 
+<RKE_KAUFN	Length="10"	Alignment="left" Filler="blank" ID="178">/</RKE_KAUFN> 
+<RKE_KDGRP	Length="2"	Alignment="left" Filler="blank" ID="179">/</RKE_KDGRP> 
+<RKE_KDPOS	Length="6"	Alignment="left" Filler="blank" ID="180">/</RKE_KDPOS> 
+<RKE_KNDNR	Length="10"	Alignment="left" Filler="blank" ID="181">/</RKE_KNDNR> 
+<RKE_KOKRS	Length="4"	Alignment="left" Filler="blank" ID="182">/</RKE_KOKRS> 
+<RKE_KSTRG	Length="12"	Alignment="left" Filler="blank" ID="183">/</RKE_KSTRG> 
+<RKE_LAND1	Length="3"	Alignment="left" Filler="blank" ID="184">/</RKE_LAND1> 
+<RKE_MAABC	Length="1"	Alignment="left" Filler="blank" ID="185">/</RKE_MAABC> 
+<RKE_MATKL	Length="9"	Alignment="left" Filler="blank" ID="186">/</RKE_MATKL> 
+<RKE_PRCTR	Length="10"	Alignment="left" Filler="blank" ID="187">/</RKE_PRCTR> 
+<RKE_PSPNR	Length="24"	Alignment="left" Filler="blank" ID="188">/</RKE_PSPNR> 
+<RKE_RKAUFNR	Length="12"	Alignment="left" Filler="blank" ID="189">/</RKE_RKAUFNR> 
+<RKE_SPART	Length="2"	Alignment="left" Filler="blank" ID="190">/</RKE_SPART> 
+<RKE_VKBUR	Length="4"	Alignment="left" Filler="blank" ID="191">/</RKE_VKBUR> 
+<RKE_VKGRP	Length="3"	Alignment="left" Filler="blank" ID="192">/</RKE_VKGRP> 
+<RKE_VKORG	Length="4"	Alignment="left" Filler="blank" ID="193">/</RKE_VKORG> 
+<RKE_VTWEG	Length="2"	Alignment="left" Filler="blank" ID="194">/</RKE_VTWEG> 
+<RKE_WERKS	Length="4"	Alignment="left" Filler="blank" ID="195">/</RKE_WERKS> 
+<RKE_KMBRND	Length="2"	Alignment="left" Filler="blank" ID="196">/</RKE_KMBRND> 
+<RKE_KMCATG	Length="2"	Alignment="left" Filler="blank" ID="197">/</RKE_KMCATG> 
+<RKE_KMHI01	Length="10"	Alignment="left" Filler="blank" ID="198">/</RKE_KMHI01> 
+<RKE_KMHI02	Length="10"	Alignment="left" Filler="blank" ID="199">/</RKE_KMHI02> 
+<RKE_KMHI03	Length="10"	Alignment="left" Filler="blank" ID="200">/</RKE_KMHI03> 
+<RKE_KMKDGR	Length="2"	Alignment="left" Filler="blank" ID="201">/</RKE_KMKDGR> 
+<RKE_KMLAND	Length="3"	Alignment="left" Filler="blank" ID="202">/</RKE_KMLAND> 
+<RKE_KMMAKL	Length="9"	Alignment="left" Filler="blank" ID="203">/</RKE_KMMAKL> 
+<RKE_KMNIEL	Length="2"	Alignment="left" Filler="blank" ID="204">/</RKE_KMNIEL> 
+<RKE_KMSTGE	Length="2"	Alignment="left" Filler="blank" ID="205">/</RKE_KMSTGE> 
+<RKE_KMVKBU	Length="4"	Alignment="left" Filler="blank" ID="206">/</RKE_KMVKBU> 
+<RKE_KMVKGR	Length="3"	Alignment="left" Filler="blank" ID="207">/</RKE_KMVKGR> 
+<RKE_KMVTNR	Length="8"	Alignment="left" Filler="blank" ID="208">/</RKE_KMVTNR> 
+<RKE_PPRCTR	Length="10"	Alignment="left" Filler="blank" ID="209">/</RKE_PPRCTR> 
+
+<!-- START new RKE-elements --> 
+<RKE_WW005	Length="5"	Alignment="left" Filler="blank" ID="276">/</RKE_WW005> 
+<RKE_WW006	Length="5"	Alignment="left" Filler="blank" ID="277">/</RKE_WW006> 
+<RKE_WW007	Length="3"	Alignment="left" Filler="blank" ID="278">/</RKE_WW007> 
+<RKE_WW008	Length="3"	Alignment="left" Filler="blank" ID="279">/</RKE_WW008> 
+<RKE_WW009	Length="1"	Alignment="left" Filler="blank" ID="280">/</RKE_WW009> 
+<RKE_WW010	Length="3"	Alignment="left" Filler="blank" ID="281">/</RKE_WW010> 
+<RKE_WW011	Length="2"	Alignment="left" Filler="blank" ID="282">/</RKE_WW011> 
+<RKE_WW012	Length="6"	Alignment="left" Filler="blank" ID="283">/</RKE_WW012> 
+<RKE_WW013	Length="10"	Alignment="left" Filler="blank" ID="284">/</RKE_WW013> 
+<RKE_WW015	Length="1"	Alignment="left" Filler="blank" ID="285">/</RKE_WW015> 
+<RKE_WW016	Length="2"	Alignment="left" Filler="blank" ID="286">/</RKE_WW016> 
+<RKE_WW017	Length="7"	Alignment="left" Filler="blank" ID="287">/</RKE_WW017> 
+<RKE_WW019	Length="6"	Alignment="left" Filler="blank" ID="289">/</RKE_WW019> 
+<!-- END new RKE-elements --> 
+
+<VBUND	Length="6"	Alignment="left" Filler="blank" ID="210">/</VBUND> 
+<FKBER	Length="4"	Alignment="left" Filler="blank" ID="211">/</FKBER> 
+<DABRZ	Length="8"	Alignment="left" Filler="blank" ID="212">/</DABRZ> 
+<XSTBA	Length="1"	Alignment="left" Filler="blank" ID="213">/</XSTBA> 
+
+<!-- Additional (empty) tags start --> 
+<RSTGR	Length="3" Alignment="left" Filler="blank" ID="214">/</RSTGR> 
+<FIPEX	Length="24" Alignment="left" Filler="blank" ID="215">/</FIPEX> 
+<XNEGP	Length="1" Alignment="left" Filler="blank" ID="216">/</XNEGP> 
+<GRICD	Length="2" Alignment="left" Filler="blank" ID="217">/</GRICD> 
+<GRIRG	Length="3" Alignment="left" Filler="blank" ID="218">/</GRIRG> 
+<GITYP	Length="2" Alignment="left" Filler="blank" ID="219">/</GITYP> 
+<FITYP	Length="2" Alignment="left" Filler="blank" ID="220">/</FITYP> 
+<STCDT	Length="2" Alignment="left" Filler="blank" ID="221">/</STCDT> 
+<STKZN	Length="1" Alignment="left" Filler="blank" ID="222">/</STKZN> 
+<STCD3	Length="18" Alignment="left" Filler="blank" ID="223">/</STCD3> 
+<STCD4	Length="18" Alignment="left" Filler="blank" ID="224">/</STCD4> 
+<XREF3	Length="20" Alignment="left" Filler="blank" ID="225">/</XREF3> 
+<KIDNO	Length="30" Alignment="left" Filler="blank" ID="226">/</KIDNO> 
+<DTWS1	Length="2" Alignment="left" Filler="blank" ID="227">/</DTWS1> 
+<DTWS2	Length="2" Alignment="left" Filler="blank" ID="228">/</DTWS2> 
+<DTWS3	Length="2" Alignment="left" Filler="blank" ID="229">/</DTWS3> 
+<DTWS4	Length="2" Alignment="left" Filler="blank" ID="230">/</DTWS4> 
+<DTAWS	Length="2" Alignment="left" Filler="blank" ID="231">/</DTAWS> 
+<PYCUR	Length="5" Alignment="left" Filler="blank" ID="232">/</PYCUR> 
+<PYAMT	Length="16" Alignment="left" Filler="blank" ID="233">/</PYAMT> 
+<BUPLA	Length="4" Alignment="left" Filler="blank" ID="234">/</BUPLA> 
+<SECCO	Length="4" Alignment="left" Filler="blank" ID="235">/</SECCO> 
+<LSTAR	Length="6" Alignment="left" Filler="blank" ID="236">/</LSTAR> 
+<EGDEB	Length="10" Alignment="left" Filler="blank" ID="237">/</EGDEB> 
+<WENR	Length="8" Alignment="left" Filler="blank" ID="238">/</WENR> 
+<GENR	Length="8" Alignment="left" Filler="blank" ID="239">/</GENR> 
+<GRNR	Length="8" Alignment="left" Filler="blank" ID="240">/</GRNR> 
+<MENR	Length="8" Alignment="left" Filler="blank" ID="241">/</MENR> 
+<MIVE	Length="13" Alignment="left" Filler="blank" ID="242">/</MIVE> 
+<NKSL	Length="4" Alignment="left" Filler="blank" ID="243">/</NKSL> 
+<EMPSL	Length="5" Alignment="left" Filler="blank" ID="244">/</EMPSL> 
+<SVWNR	Length="13" Alignment="left" Filler="blank" ID="245">/</SVWNR> 
+<SBERI	Length="10" Alignment="left" Filler="blank" ID="246">/</SBERI> 
+<KKBER	Length="4" Alignment="left" Filler="blank" ID="247">/</KKBER> 
+<EMPFB	Length="10" Alignment="left" Filler="blank" ID="248">/</EMPFB> 
+<KURSR_M	Length="10" Alignment="left" Filler="blank" ID="249">/</KURSR_M> 
+<J_1KFREPRE	Length="10" Alignment="left" Filler="blank" ID="250">/</J_1KFREPRE> 
+<J_1KFTBUS	Length="30" Alignment="left" Filler="blank" ID="251">/</J_1KFTBUS> 
+<J_1KFTIND	Length="30" Alignment="left" Filler="blank" ID="252">/</J_1KFTIND> 
+<IDXSP	Length="5" Alignment="left" Filler="blank" ID="253">/</IDXSP> 
+<ANRED	Length="15" Alignment="left" Filler="blank" ID="254">/</ANRED> 
+<RECNNR	Length="13" Alignment="left" Filler="blank" ID="255">/</RECNNR> 
+<E_MIVE	Length="13" Alignment="left" Filler="blank" ID="256">/</E_MIVE> 
+<BKREF	Length="20" Alignment="left" Filler="blank" ID="257">/</BKREF> 
+<DTAMS	Length="1" Alignment="left" Filler="blank" ID="258">/</DTAMS> 
+<CESSION_KZ	Length="2" Alignment="left" Filler="blank" ID="259">/</CESSION_KZ> 
+<GRANT_NBR	Length="20" Alignment="left" Filler="blank" ID="260">/</GRANT_NBR> 
+<FKBER_LONG	Length="16" Alignment="left" Filler="blank" ID="261">/</FKBER_LONG> 
+<ERLKZ	Length="1" Alignment="left" Filler="blank" ID="262">/</ERLKZ> 
+<IBAN	Length="34" Alignment="left" Filler="blank" ID="263">/</IBAN> 
+<VALID_FROM	Length="8" Alignment="left" Filler="blank" ID="264">/</VALID_FROM> 
+<SEGMENT	Length="10" Alignment="left" Filler="blank" ID="265">/</SEGMENT> 
+<PSEGMENT	Length="10" Alignment="left" Filler="blank" ID="266">/</PSEGMENT> 
+<HKTID	Length="5" Alignment="left" Filler="blank" ID="267">/</HKTID> 
+<XSIWE	Length="1" Alignment="left" Filler="blank" ID="268">/</XSIWE> 
+<TCNO	Length="16" Alignment="left" Filler="blank" ID="269">/</TCNO> 
+<DATEOFSERVICE	Length="8" Alignment="left" Filler="blank" ID="270">/</DATEOFSERVICE> 
+<NOTAXCORR	Length="1" Alignment="left" Filler="blank" ID="271">/</NOTAXCORR> 
+<DIFFOPTRATE	Length="10" Alignment="left" Filler="blank" ID="272">/</DIFFOPTRATE> 
+<HASDIFFOPTRATE	Length="1" Alignment="left" Filler="blank" ID="273">/</HASDIFFOPTRATE> 
+<SENDE	Length="1" Alignment="left" Filler="blank" ID="274">/</SENDE> 
+<PRODPER	Length="8" Alignment="left" Filler="blank" ID="275">/</PRODPER> 
+<!-- Additional tags end --> 
+
+</invoiceCharges_1_elements> 
+</xsl:template> 
+
+<xsl:template name="invoiceDetails_1_elements"> 
+<invoiceDetails_1_elements> 
+<STYPE ID="1"	Length="1"	Alignment="left" Filler="blank">2</STYPE> 
+<TBNAM ID="2"	Length="30"	Alignment="left" Filler="blank">BBSEG</TBNAM> 
+<NEWBS ID="3"	Length="2"	Alignment="left" Filler="blank"> 
+<xsl:if test="parent::node()/type='I'">40</xsl:if> 
+<xsl:if test="parent::node()/type='C'">50</xsl:if> 
+</NEWBS> 
+<DUMMYX	ID="4"	Length="10"	Alignment="left" Filler="blank">/</DUMMYX> 
+<NEWUM	ID="5"	Length="1"	Alignment="left" Filler="blank">/</NEWUM> 
+<NEWBK	ID="6"	Length="4"	Alignment="left" Filler="blank">/</NEWBK> 
+<WRBTR	ID="7"	Length="16"	Alignment="left" Filler="blank"> 
+<xsl:value-of select="format-number(totalAmount, '0000000000000,00', 'european')"/>	
+</WRBTR> 
+<DMBTR	ID="8"	Length="16"	Alignment="left" Filler="blank">/</DMBTR> 
+<WMWST	ID="9"	Length="16"	Alignment="left" Filler="blank">/</WMWST> 
+<MWSTS	ID="10"	Length="16"	Alignment="left" Filler="blank">/</MWSTS> 
+<MWSKZ	ID="11"	Length="2"	Alignment="left" Filler="blank"> 
+<xsl:value-of select="parent::node()/financialTaxCode" /> 
+</MWSKZ> 
+<XSKRL	ID="12"	Length="1"	Alignment="left" Filler="blank">/</XSKRL> 
+<FWZUZ	ID="13"	Length="16"	Alignment="left" Filler="blank">/</FWZUZ> 
+<HWZUZ	ID="14"	Length="16"	Alignment="left" Filler="blank">/</HWZUZ> 
+<GSBER	ID="15"	Length="4"	Alignment="left" Filler="blank">/</GSBER> 
+<KOSTL	ID="16"	Length="10"	Alignment="left" Filler="blank"> 
+<xsl:choose> 
+<xsl:when test="financialCostcenter and string-length(financialCostcenter) &gt; 0"> 
+<xsl:value-of select="financialCostcenter" /> 
+</xsl:when> 
+<xsl:otherwise> 
+<xsl:value-of select="'/'" /> 
+</xsl:otherwise> 
+</xsl:choose> 
+</KOSTL> 
+<DUMMY4	ID="17"	Length="4"	Alignment="left" Filler="blank">/</DUMMY4> 
+<AUFNR	ID="18"	Length="12"	Alignment="left" Filler="blank"> 
+<xsl:choose> 
+<xsl:when test="costcenter2 and string-length(costcenter2) &gt; 0"> 
+<xsl:value-of select="costcenter2" /> 
+</xsl:when> 
+<xsl:otherwise> 
+<xsl:value-of select="'/'" /> 
+</xsl:otherwise> 
+</xsl:choose> 
+</AUFNR> 
+<EBELN	ID="19"	Length="10"	Alignment="left" Filler="blank">/</EBELN> 
+<EBELP	ID="20"	Length="5"	Alignment="left" Filler="blank">/</EBELP> 
+<PROJN	ID="21"	Length="16"	Alignment="left" Filler="blank">/</PROJN> 
+<MATNR	ID="22"	Length="18"	Alignment="left" Filler="blank">/</MATNR> 
+<WERKS	ID="23"	Length="4"	Alignment="left" Filler="blank">/</WERKS> 
+<MENGE	ID="24"	Length="17"	Alignment="left" Filler="blank">/</MENGE> 
+<MEINS	ID="25"	Length="3"	Alignment="left" Filler="blank">/</MEINS> 
+<VBEL2	ID="26"	Length="10"	Alignment="left" Filler="blank">/</VBEL2> 
+<POSN2	ID="27"	Length="6"	Alignment="left" Filler="blank">/</POSN2> 
+<ETEN2	ID="28"	Length="4"	Alignment="left" Filler="blank">/</ETEN2> 
+<PERNR	ID="29"	Length="8"	Alignment="left" Filler="blank">/</PERNR> 
+<BEWAR	ID="30"	Length="3"	Alignment="left" Filler="blank">/</BEWAR> 
+<VALUT	ID="31"	Length="8"	Alignment="left" Filler="blank">/</VALUT> 
+<ZFBDT	ID="32"	Length="8"	Alignment="left" Filler="blank">/</ZFBDT> 
+<ZINKZ	ID="33"	Length="2"	Alignment="left" Filler="blank">/</ZINKZ> 
+<ZUONR	ID="34"	Length="18"	Alignment="left" Filler="blank"> 
+<xsl:value-of select="orderNumber" /> 
+<xsl:value-of select="'-'" /> 
+<xsl:value-of select="itemNumber" /> 
+</ZUONR> 
+<FKONT	ID="35"	Length="3"	Alignment="left" Filler="blank">/</FKONT> 
+<XAABG	ID="36"	Length="1"	Alignment="left" Filler="blank">/</XAABG> 
+<SGTXT	ID="37"	Length="50"	Alignment="left" Filler="blank"> 
+<xsl:variable name="twoDigitYear"> 
+<xsl:value-of select="substring(parent::node()/financialPeriodYear, 3, 4)"/> 
+</xsl:variable> 
+<xsl:value-of select="$twoDigitYear" /> 
+<xsl:value-of select="'/'" /> 
+<xsl:value-of select="parent::node()/financialPeriodMonth" /> 
+</SGTXT> 
+<BLNKZ	ID="38"	Length="2"	Alignment="left" Filler="blank">/</BLNKZ> 
+<BLNBT	ID="39" Alignment="left" Filler="blank" Length="16">/</BLNBT> 
+<BLNPZ	ID="40" Alignment="left" Filler="blank" Length="8">/</BLNPZ> 
+<MABER	ID="41" Alignment="left" Filler="blank" Length="2">/</MABER> 
+<SKFBT	ID="42" Alignment="left" Filler="blank" Length="16">/</SKFBT> 
+<WSKTO	ID="43" Alignment="left" Filler="blank" Length="16">/</WSKTO> 
+<ZTERM	ID="44" Alignment="left" Filler="blank" Length="4">/</ZTERM> 
+<ZBD1T	ID="45" Alignment="left" Filler="blank" Length="3">/</ZBD1T> 
+<ZBD1P	ID="46" Alignment="left" Filler="blank" Length="6">/</ZBD1P> 
+<ZBD2T	ID="47" Alignment="left" Filler="blank" Length="3">/</ZBD2T> 
+<ZBD2P	ID="48" Alignment="left" Filler="blank" Length="6">/</ZBD2P> 
+<ZBD3T	ID="49" Alignment="left" Filler="blank" Length="3">/</ZBD3T> 
+<ZLSPR	ID="50" Alignment="left" Filler="blank" Length="1">/</ZLSPR> 
+<REBZG	ID="51" Alignment="left" Filler="blank" Length="10">/</REBZG> 
+<REBZJ	ID="52" Alignment="left" Filler="blank" Length="4">/</REBZJ> 
+<REBZZ	ID="53" Alignment="left" Filler="blank" Length="3">/</REBZZ> 
+<ZLSCH	ID="54" Alignment="left" Filler="blank" Length="1">/</ZLSCH> 
+<SAMNR	ID="55" Alignment="left" Filler="blank" Length="8">/</SAMNR> 
+<ZBFIX	ID="56" Alignment="left" Filler="blank" Length="1">/</ZBFIX> 
+<QSSKZ	ID="57" Alignment="left" Filler="blank" Length="2">/</QSSKZ> 
+<QSSHB	ID="58" Alignment="left" Filler="blank" Length="16">/</QSSHB> 
+<QSFBT	ID="59" Alignment="left" Filler="blank" Length="16">/</QSFBT> 
+<ESRNR	ID="60" Alignment="left" Filler="blank" Length="11">/</ESRNR> 
+<ESRPZ	ID="61" Alignment="left" Filler="blank" Length="2">/</ESRPZ> 
+<ESRRE	ID="62" Alignment="left" Filler="blank" Length="27">/</ESRRE> 
+<FDTAG	ID="63" Alignment="left" Filler="blank" Length="8">/</FDTAG> 
+<FDLEV	ID="64" Alignment="left" Filler="blank" Length="2">/</FDLEV> 
+<ANLN1	ID="65" Alignment="left" Filler="blank" Length="12">/</ANLN1> 
+<ANLN2	ID="66" Alignment="left" Filler="blank" Length="4">/</ANLN2> 
+<BZDAT	ID="67" Alignment="left" Filler="blank" Length="8">/</BZDAT> 
+<ANBWA	ID="68" Alignment="left" Filler="blank" Length="3">/</ANBWA> 
+<ABPER	ID="69" Alignment="left" Filler="blank" Length="7">/</ABPER> 
+<GBETR	ID="70" Alignment="left" Filler="blank" Length="16">/</GBETR> 
+<KURSR	ID="71" Alignment="left" Filler="blank" Length="10">/</KURSR> 
+<MANSP	ID="72" Alignment="left" Filler="blank" Length="1">/</MANSP> 
+<MSCHL	ID="73" Alignment="left" Filler="blank" Length="1">/</MSCHL> 
+<HBKID	ID="74" Alignment="left" Filler="blank" Length="5">/</HBKID> 
+<BVTYP	ID="75" Alignment="left" Filler="blank" Length="4">/</BVTYP> 
+<ANFBN	ID="76" Alignment="left" Filler="blank" Length="10">/</ANFBN> 
+<ANFBU	ID="77" Alignment="left" Filler="blank" Length="4">/</ANFBU> 
+<ANFBJ	ID="78" Alignment="left" Filler="blank" Length="4">/</ANFBJ> 
+<LZBKZ	ID="79" Alignment="left" Filler="blank" Length="3"> 
+<xsl:choose> 
+<xsl:when test="orderType='S'"> 
+<xsl:value-of select="$constLZBZK_S_ORDER" /> 
+</xsl:when> 
+<xsl:otherwise> 
+<xsl:value-of select="$constLZBZK_OTHER" /> 
+</xsl:otherwise> 
+</xsl:choose>	
+</LZBKZ> 
+<LANDL	ID="80" Alignment="left" Filler="blank" Length="3">/</LANDL> 
+<DIEKZ	ID="81" Alignment="left" Filler="blank" Length="1">/</DIEKZ> 
+<ZOLLD	ID="82" Alignment="left" Filler="blank" Length="8">/</ZOLLD> 
+<ZOLLT	ID="83" Alignment="left" Filler="blank" Length="8">/</ZOLLT> 
+<VRSDT	ID="84" Alignment="left" Filler="blank" Length="8">/</VRSDT> 
+<VRSKZ	ID="85" Alignment="left" Filler="blank" Length="1">/</VRSKZ> 
+<HZUON	ID="86" Alignment="left" Filler="blank" Length="18">/</HZUON> 
+<REGUL	ID="87" Alignment="left" Filler="blank" Length="1">/</REGUL> 
+<NAME1	ID="88" Alignment="left" Filler="blank" Length="35">/</NAME1> 
+<NAME2	ID="89" Alignment="left" Filler="blank" Length="35">/</NAME2> 
+<NAME3	ID="90" Alignment="left" Filler="blank" Length="35">/</NAME3> 
+<NAME4	ID="91" Alignment="left" Filler="blank" Length="35">/</NAME4> 
+<STRAS	ID="92" Alignment="left" Filler="blank" Length="35">/</STRAS> 
+<ORT01	ID="93" Alignment="left" Filler="blank" Length="35">/</ORT01> 
+<PSTLZ	ID="94" Alignment="left" Filler="blank" Length="10">/</PSTLZ> 
+<LAND1	ID="95" Alignment="left" Filler="blank" Length="3">/</LAND1> 
+<REGIO	ID="96" Alignment="left" Filler="blank" Length="3">/</REGIO> 
+<BANKL	ID="97" Alignment="left" Filler="blank" Length="15">/</BANKL> 
+<BANKS	ID="98" Alignment="left" Filler="blank" Length="3">/</BANKS> 
+<BANKN	ID="99" Alignment="left" Filler="blank" Length="18">/</BANKN> 
+<BKONT	ID="100" Alignment="left" Filler="blank" Length="2">/</BKONT> 
+<STCD1	ID="101" Alignment="left" Filler="blank" Length="16">/</STCD1> 
+<STCD2	ID="102" Alignment="left" Filler="blank" Length="11">/</STCD2> 
+<MADAT	ID="103" Alignment="left" Filler="blank" Length="8">/</MADAT> 
+<MANST	ID="104" Alignment="left" Filler="blank" Length="1">/</MANST> 
+<EGMLD	ID="105" Alignment="left" Filler="blank" Length="3">/</EGMLD> 
+<DUMMY2	ID="106" Alignment="left" Filler="blank" Length="3">/</DUMMY2> 
+<STCEG	ID="107" Alignment="left" Filler="blank" Length="20">/</STCEG> 
+<STKZA	ID="108" Alignment="left" Filler="blank" Length="1">/</STKZA> 
+<STKZU	ID="109" Alignment="left" Filler="blank" Length="1">/</STKZU> 
+<PFACH	ID="110" Alignment="left" Filler="blank" Length="10">/</PFACH> 
+<PSTL2	ID="111" Alignment="left" Filler="blank" Length="10">/</PSTL2> 
+<SPRAS	ID="112" Alignment="left" Filler="blank" Length="1">/</SPRAS> 
+<XINVE	ID="113" Alignment="left" Filler="blank" Length="1">/</XINVE> 
+
+<NEWKO ID="114" Length="17" Alignment="left" Filler="blank"> 
+<xsl:value-of select="accountNumber" /> 
+</NEWKO> 
+
+<NEWBW	Length="3"	Alignment="left" Filler="blank" ID="115">/</NEWBW> 
+<KNRZE	Length="17"	Alignment="left" Filler="blank" ID="116">/</KNRZE> 
+<HKONT	Length="10"	Alignment="left" Filler="blank" ID="117">/</HKONT> 
+<PRCTR	Length="10"	Alignment="left" Filler="blank" ID="118">/</PRCTR> 
+<VERTN	Length="13"	Alignment="left" Filler="blank" ID="119">/</VERTN> 
+<VERTT	Length="1"	Alignment="left" Filler="blank" ID="120">/</VERTT> 
+<VBEWA	Length="4"	Alignment="left" Filler="blank" ID="121">/</VBEWA> 
+<HWBAS	Length="16"	Alignment="left" Filler="blank" ID="122">/</HWBAS> 
+<FWBAS	Length="16"	Alignment="left" Filler="blank" ID="123">/</FWBAS> 
+<FIPOS	Length="14"	Alignment="left" Filler="blank" ID="124">/</FIPOS> 
+<VNAME	Length="6"	Alignment="left" Filler="blank" ID="125">/</VNAME> 
+<EGRUP	Length="3"	Alignment="left" Filler="blank" ID="126">/</EGRUP> 
+<BTYPE	Length="2"	Alignment="left" Filler="blank" ID="127">/</BTYPE> 
+<PAOBJNR	Length="10"	Alignment="left" Filler="blank" ID="128">/</PAOBJNR> 
+<KSTRG	Length="12"	Alignment="left" Filler="blank" ID="129">/</KSTRG> 
+<IMKEY	Length="8"	Alignment="left" Filler="blank" ID="130">/</IMKEY> 
+<DUMMY3	Length="8"	Alignment="left" Filler="blank" ID="131">/</DUMMY3> 
+<VPTNR	Length="10"	Alignment="left" Filler="blank" ID="132">/</VPTNR> 
+<NPLNR	Length="12"	Alignment="left" Filler="blank" ID="133">/</NPLNR> 
+<VORNR	Length="4"	Alignment="left" Filler="blank" ID="134">/</VORNR> 
+<XEGDR	Length="1"	Alignment="left" Filler="blank" ID="135">/</XEGDR> 
+<RECID	Length="2"	Alignment="left" Filler="blank" ID="136">/</RECID> 
+<PPRCT	Length="10"	Alignment="left" Filler="blank" ID="137">/</PPRCT> 
+<PROJK	Length="24"	Alignment="left" Filler="blank" ID="138">/</PROJK> 
+<UZAWE	Length="2"	Alignment="left" Filler="blank" ID="139">/</UZAWE> 
+<TXJCD	Length="15"	Alignment="left" Filler="blank" ID="140">/</TXJCD> 
+<FISTL	Length="16"	Alignment="left" Filler="blank" ID="141">/</FISTL> 
+<GEBER	Length="10"	Alignment="left" Filler="blank" ID="142">/</GEBER> 
+<DMBE2	Length="16"	Alignment="left" Filler="blank" ID="143">/</DMBE2> 
+<DMBE3	Length="16"	Alignment="left" Filler="blank" ID="144">/</DMBE3> 
+<PARGB	Length="4"	Alignment="left" Filler="blank" ID="145">/</PARGB> 
+<XREF1	Length="12"	Alignment="left" Filler="blank" ID="146">/</XREF1> 
+<XREF2	Length="12"	Alignment="left" Filler="blank" ID="147">/</XREF2> 
+<KBLNR	Length="10"	Alignment="left" Filler="blank" ID="149">/</KBLNR> 
+<KBLPOS	Length="3"	Alignment="left" Filler="blank" ID="150">/</KBLPOS> 
+<WDATE	Length="8"	Alignment="left" Filler="blank" ID="151">/</WDATE> 
+<WGBKZ	Length="1"	Alignment="left" Filler="blank" ID="152">/</WGBKZ> 
+<XAKTZ	Length="1"	Alignment="left" Filler="blank" ID="153">/</XAKTZ> 
+<WNAME	Length="30"	Alignment="left" Filler="blank" ID="154">/</WNAME> 
+<WORT1	Length="30"	Alignment="left" Filler="blank" ID="155">/</WORT1> 
+<WBZOG	Length="30"	Alignment="left" Filler="blank" ID="156">/</WBZOG> 
+<WORT2	Length="30"	Alignment="left" Filler="blank" ID="157">/</WORT2> 
+<WBANK	Length="60"	Alignment="left" Filler="blank" ID="158">/</WBANK> 
+<WLZBP	Length="60"	Alignment="left" Filler="blank" ID="159">/</WLZBP> 
+<DISKP	Length="8"	Alignment="left" Filler="blank" ID="160">/</DISKP> 
+<DISKT	Length="3"	Alignment="left" Filler="blank" ID="161">/</DISKT> 
+<WINFW	Length="16"	Alignment="left" Filler="blank" ID="162">/</WINFW> 
+<WINHW	Length="16"	Alignment="left" Filler="blank" ID="163">/</WINHW> 
+<WEVWV	Length="1"	Alignment="left" Filler="blank" ID="164">/</WEVWV> 
+<WSTAT	Length="1"	Alignment="left" Filler="blank" ID="165">/</WSTAT> 
+<WMWKZ	Length="2"	Alignment="left" Filler="blank" ID="166">/</WMWKZ> 
+<WSTKZ	Length="1"	Alignment="left" Filler="blank" ID="167">/</WSTKZ> 
+<RKE_ARTNR	Length="18"	Alignment="left" Filler="blank" ID="169">/</RKE_ARTNR> 
+<RKE_BONUS	Length="2"	Alignment="left" Filler="blank" ID="170">/</RKE_BONUS> 
+<RKE_BRSCH	Length="4"	Alignment="left" Filler="blank" ID="171">/</RKE_BRSCH> 
+<RKE_BUKRS	Length="4"	Alignment="left" Filler="blank" ID="172">/</RKE_BUKRS> 
+<RKE_BZIRK	Length="6"	Alignment="left" Filler="blank" ID="173">/</RKE_BZIRK> 
+<RKE_EFORM	Length="5"	Alignment="left" Filler="blank" ID="174">/</RKE_EFORM> 
+<RKE_FKART	Length="4"	Alignment="left" Filler="blank" ID="175">/</RKE_FKART> 
+<RKE_GEBIE	Length="4"	Alignment="left" Filler="blank" ID="176">/</RKE_GEBIE> 
+<RKE_GSBER	Length="4"	Alignment="left" Filler="blank" ID="177">/</RKE_GSBER> 
+<RKE_KAUFN	Length="10"	Alignment="left" Filler="blank" ID="178">/</RKE_KAUFN> 
+<RKE_KDGRP	Length="2"	Alignment="left" Filler="blank" ID="179">/</RKE_KDGRP> 
+<RKE_KDPOS	Length="6"	Alignment="left" Filler="blank" ID="180">/</RKE_KDPOS> 
+<RKE_KNDNR	Length="10"	Alignment="left" Filler="blank" ID="181">/</RKE_KNDNR> 
+<RKE_KOKRS	Length="4"	Alignment="left" Filler="blank" ID="182">/</RKE_KOKRS> 
+<RKE_KSTRG	Length="12"	Alignment="left" Filler="blank" ID="183">/</RKE_KSTRG> 
+<RKE_LAND1	Length="3"	Alignment="left" Filler="blank" ID="184">/</RKE_LAND1> 
+<RKE_MAABC	Length="1"	Alignment="left" Filler="blank" ID="185">/</RKE_MAABC> 
+<RKE_MATKL	Length="9"	Alignment="left" Filler="blank" ID="186">/</RKE_MATKL> 
+<RKE_PRCTR	Length="10"	Alignment="left" Filler="blank" ID="187">/</RKE_PRCTR> 
+<RKE_PSPNR	Length="24"	Alignment="left" Filler="blank" ID="188">/</RKE_PSPNR> 
+<RKE_RKAUFNR	Length="12"	Alignment="left" Filler="blank" ID="189">/</RKE_RKAUFNR> 
+<RKE_SPART	Length="2"	Alignment="left" Filler="blank" ID="190">/</RKE_SPART> 
+<RKE_VKBUR	Length="4"	Alignment="left" Filler="blank" ID="191">/</RKE_VKBUR> 
+<RKE_VKGRP	Length="3"	Alignment="left" Filler="blank" ID="192">/</RKE_VKGRP> 
+<RKE_VKORG	Length="4"	Alignment="left" Filler="blank" ID="193">/</RKE_VKORG> 
+<RKE_VTWEG	Length="2"	Alignment="left" Filler="blank" ID="194">/</RKE_VTWEG> 
+<RKE_WERKS	Length="4"	Alignment="left" Filler="blank" ID="195">/</RKE_WERKS> 
+<RKE_KMBRND	Length="2"	Alignment="left" Filler="blank" ID="196">/</RKE_KMBRND> 
+<RKE_KMCATG	Length="2"	Alignment="left" Filler="blank" ID="197">/</RKE_KMCATG> 
+<RKE_KMHI01	Length="10"	Alignment="left" Filler="blank" ID="198">/</RKE_KMHI01> 
+<RKE_KMHI02	Length="10"	Alignment="left" Filler="blank" ID="199">/</RKE_KMHI02> 
+<RKE_KMHI03	Length="10"	Alignment="left" Filler="blank" ID="200">/</RKE_KMHI03> 
+<RKE_KMKDGR	Length="2"	Alignment="left" Filler="blank" ID="201">/</RKE_KMKDGR> 
+<RKE_KMLAND	Length="3"	Alignment="left" Filler="blank" ID="202">/</RKE_KMLAND> 
+<RKE_KMMAKL	Length="9"	Alignment="left" Filler="blank" ID="203">/</RKE_KMMAKL> 
+<RKE_KMNIEL	Length="2"	Alignment="left" Filler="blank" ID="204">/</RKE_KMNIEL> 
+<RKE_KMSTGE	Length="2"	Alignment="left" Filler="blank" ID="205">/</RKE_KMSTGE> 
+<RKE_KMVKBU	Length="4"	Alignment="left" Filler="blank" ID="206">/</RKE_KMVKBU> 
+<RKE_KMVKGR	Length="3"	Alignment="left" Filler="blank" ID="207">/</RKE_KMVKGR> 
+<RKE_KMVTNR	Length="8"	Alignment="left" Filler="blank" ID="208">/</RKE_KMVTNR> 
+<RKE_PPRCTR	Length="10"	Alignment="left" Filler="blank" ID="209">/</RKE_PPRCTR> 
+
+<!-- START new RKE-elements --> 
+<RKE_WW005	Length="5"	Alignment="left" Filler="blank" ID="276">/</RKE_WW005> 
+<RKE_WW006	Length="5"	Alignment="left" Filler="blank" ID="277">/</RKE_WW006> 
+<RKE_WW007	Length="3"	Alignment="left" Filler="blank" ID="278">/</RKE_WW007> 
+<RKE_WW008	Length="3"	Alignment="left" Filler="blank" ID="279">/</RKE_WW008> 
+<RKE_WW009	Length="1"	Alignment="left" Filler="blank" ID="280">/</RKE_WW009> 
+<RKE_WW010	Length="3"	Alignment="left" Filler="blank" ID="281">/</RKE_WW010> 
+<RKE_WW011	Length="2"	Alignment="left" Filler="blank" ID="282">/</RKE_WW011> 
+<RKE_WW012	Length="6"	Alignment="left" Filler="blank" ID="283">/</RKE_WW012> 
+<RKE_WW013	Length="10"	Alignment="left" Filler="blank" ID="284">/</RKE_WW013> 
+<RKE_WW015	Length="1"	Alignment="left" Filler="blank" ID="285">/</RKE_WW015> 
+<RKE_WW016	Length="2"	Alignment="left" Filler="blank" ID="286">/</RKE_WW016> 
+<RKE_WW017	Length="7"	Alignment="left" Filler="blank" ID="287">/</RKE_WW017> 
+<RKE_WW019	Length="6"	Alignment="left" Filler="blank" ID="289">/</RKE_WW019> 
+<!-- END new RKE-elements --> 
+
+<VBUND	Length="6"	Alignment="left" Filler="blank" ID="210">/</VBUND> 
+<FKBER	Length="4"	Alignment="left" Filler="blank" ID="211">/</FKBER> 
+<DABRZ	Length="8"	Alignment="left" Filler="blank" ID="212">/</DABRZ> 
+<XSTBA	Length="1"	Alignment="left" Filler="blank" ID="213">/</XSTBA> 
+
+<!-- START Additional (empty) tags start --> 
+<RSTGR	Length="3" Alignment="left" Filler="blank" ID="214">/</RSTGR> 
+<FIPEX	Length="24" Alignment="left" Filler="blank" ID="215">/</FIPEX> 
+<XNEGP	Length="1" Alignment="left" Filler="blank" ID="216">/</XNEGP> 
+<GRICD	Length="2" Alignment="left" Filler="blank" ID="217">/</GRICD> 
+<GRIRG	Length="3" Alignment="left" Filler="blank" ID="218">/</GRIRG> 
+<GITYP	Length="2" Alignment="left" Filler="blank" ID="219">/</GITYP> 
+<FITYP	Length="2" Alignment="left" Filler="blank" ID="220">/</FITYP> 
+<STCDT	Length="2" Alignment="left" Filler="blank" ID="221">/</STCDT> 
+<STKZN	Length="1" Alignment="left" Filler="blank" ID="222">/</STKZN> 
+<STCD3	Length="18" Alignment="left" Filler="blank" ID="223">/</STCD3> 
+<STCD4	Length="18" Alignment="left" Filler="blank" ID="224">/</STCD4> 
+<XREF3	Length="20" Alignment="left" Filler="blank" ID="225">/</XREF3> 
+<KIDNO	Length="30" Alignment="left" Filler="blank" ID="226">/</KIDNO> 
+<DTWS1	Length="2" Alignment="left" Filler="blank" ID="227">/</DTWS1> 
+<DTWS2	Length="2" Alignment="left" Filler="blank" ID="228">/</DTWS2> 
+<DTWS3	Length="2" Alignment="left" Filler="blank" ID="229">/</DTWS3> 
+<DTWS4	Length="2" Alignment="left" Filler="blank" ID="230">/</DTWS4> 
+<DTAWS	Length="2" Alignment="left" Filler="blank" ID="231">/</DTAWS> 
+<PYCUR	Length="5" Alignment="left" Filler="blank" ID="232">/</PYCUR> 
+<PYAMT	Length="16" Alignment="left" Filler="blank" ID="233">/</PYAMT> 
+<BUPLA	Length="4" Alignment="left" Filler="blank" ID="234">/</BUPLA> 
+<SECCO	Length="4" Alignment="left" Filler="blank" ID="235">/</SECCO> 
+<LSTAR	Length="6" Alignment="left" Filler="blank" ID="236">/</LSTAR> 
+<EGDEB	Length="10" Alignment="left" Filler="blank" ID="237">/</EGDEB> 
+<WENR	Length="8" Alignment="left" Filler="blank" ID="238">/</WENR> 
+<GENR	Length="8" Alignment="left" Filler="blank" ID="239">/</GENR> 
+<GRNR	Length="8" Alignment="left" Filler="blank" ID="240">/</GRNR> 
+<MENR	Length="8" Alignment="left" Filler="blank" ID="241">/</MENR> 
+<MIVE	Length="13" Alignment="left" Filler="blank" ID="242">/</MIVE> 
+<NKSL	Length="4" Alignment="left" Filler="blank" ID="243">/</NKSL> 
+<EMPSL	Length="5" Alignment="left" Filler="blank" ID="244">/</EMPSL> 
+<SVWNR	Length="13" Alignment="left" Filler="blank" ID="245">/</SVWNR> 
+<SBERI	Length="10" Alignment="left" Filler="blank" ID="246">/</SBERI> 
+<KKBER	Length="4" Alignment="left" Filler="blank" ID="247">/</KKBER> 
+<EMPFB	Length="10" Alignment="left" Filler="blank" ID="248">/</EMPFB> 
+<KURSR_M	Length="10" Alignment="left" Filler="blank" ID="249">/</KURSR_M> 
+<J_1KFREPRE	Length="10" Alignment="left" Filler="blank" ID="250">/</J_1KFREPRE> 
+<J_1KFTBUS	Length="30" Alignment="left" Filler="blank" ID="251">/</J_1KFTBUS> 
+<J_1KFTIND	Length="30" Alignment="left" Filler="blank" ID="252">/</J_1KFTIND> 
+<IDXSP	Length="5" Alignment="left" Filler="blank" ID="253">/</IDXSP> 
+<ANRED	Length="15" Alignment="left" Filler="blank" ID="254">/</ANRED> 
+<RECNNR	Length="13" Alignment="left" Filler="blank" ID="255">/</RECNNR> 
+<E_MIVE	Length="13" Alignment="left" Filler="blank" ID="256">/</E_MIVE> 
+<BKREF	Length="20" Alignment="left" Filler="blank" ID="257">/</BKREF> 
+<DTAMS	Length="1" Alignment="left" Filler="blank" ID="258">/</DTAMS> 
+<CESSION_KZ	Length="2" Alignment="left" Filler="blank" ID="259">/</CESSION_KZ> 
+<GRANT_NBR	Length="20" Alignment="left" Filler="blank" ID="260">/</GRANT_NBR> 
+<FKBER_LONG	Length="16" Alignment="left" Filler="blank" ID="261">/</FKBER_LONG> 
+<ERLKZ	Length="1" Alignment="left" Filler="blank" ID="262">/</ERLKZ> 
+<IBAN	Length="34" Alignment="left" Filler="blank" ID="263">/</IBAN> 
+<VALID_FROM	Length="8" Alignment="left" Filler="blank" ID="264">/</VALID_FROM> 
+<SEGMENT	Length="10" Alignment="left" Filler="blank" ID="265">/</SEGMENT> 
+<PSEGMENT	Length="10" Alignment="left" Filler="blank" ID="266">/</PSEGMENT> 
+<HKTID	Length="5" Alignment="left" Filler="blank" ID="267">/</HKTID> 
+<XSIWE	Length="1" Alignment="left" Filler="blank" ID="268">/</XSIWE> 
+<TCNO	Length="16" Alignment="left" Filler="blank" ID="269">/</TCNO> 
+<DATEOFSERVICE	Length="8" Alignment="left" Filler="blank" ID="270">/</DATEOFSERVICE> 
+<NOTAXCORR	Length="1" Alignment="left" Filler="blank" ID="271">/</NOTAXCORR> 
+<DIFFOPTRATE	Length="10" Alignment="left" Filler="blank" ID="272">/</DIFFOPTRATE> 
+<HASDIFFOPTRATE	Length="1" Alignment="left" Filler="blank" ID="273">/</HASDIFFOPTRATE> 
+<SENDE	Length="1" Alignment="left" Filler="blank" ID="274">/</SENDE> 
+<PRODPER	Length="8" Alignment="left" Filler="blank" ID="275">/</PRODPER> 
+<!-- END Additional tags -->	
+
+</invoiceDetails_1_elements> 
+</xsl:template> 
+
+<xsl:template name="invoiceDetails_DetailCharges_1_elements"> 
+<invoiceDetails_DetailCharges_1_elements> 
+<STYPE ID="1"	Length="1"	Alignment="left" Filler="blank">2</STYPE> 
+<TBNAM ID="2"	Length="30"	Alignment="left" Filler="blank">BBSEG</TBNAM> 
+<NEWBS ID="3"	Length="2"	Alignment="left" Filler="blank"> 
+<xsl:if test="parent::node()/type='I'">40</xsl:if> 
+<xsl:if test="parent::node()/type='C'">50</xsl:if> 
+</NEWBS> 
+<DUMMYX	ID="4"	Length="10"	Alignment="left" Filler="blank">/</DUMMYX> 
+<NEWUM	ID="5"	Length="1"	Alignment="left" Filler="blank">/</NEWUM> 
+<NEWBK	ID="6"	Length="4"	Alignment="left" Filler="blank">/</NEWBK> 
+<WRBTR	ID="7"	Length="16"	Alignment="left" Filler="blank"> 
+<!--	<xsl:value-of select="format-number(totalAmount, '#0.00', 'european')"/>	--> 
+<xsl:value-of select="format-number(totalAmount, '0000000000000,00', 'european')"/>	
+</WRBTR> 
+<DMBTR	ID="8"	Length="16"	Alignment="left" Filler="blank">/</DMBTR> 
+<WMWST	ID="9"	Length="16"	Alignment="left" Filler="blank">/</WMWST> 
+<MWSTS	ID="10"	Length="16"	Alignment="left" Filler="blank">/</MWSTS> 
+<MWSKZ	ID="11"	Length="2"	Alignment="left" Filler="blank"> 
+<xsl:value-of select="parent::node()/financialTaxCode" /> 
+</MWSKZ> 
+<XSKRL	ID="12"	Length="1"	Alignment="left" Filler="blank">/</XSKRL> 
+<FWZUZ	ID="13"	Length="16"	Alignment="left" Filler="blank">/</FWZUZ> 
+<HWZUZ	ID="14"	Length="16"	Alignment="left" Filler="blank">/</HWZUZ> 
+<GSBER	ID="15"	Length="4"	Alignment="left" Filler="blank">/</GSBER> 
+<KOSTL	ID="16"	Length="10"	Alignment="left" Filler="blank"> 
+<xsl:choose> 
+<xsl:when test="financialCostcenter and string-length(financialCostcenter) &gt; 0"> 
+<xsl:value-of select="financialCostcenter" /> 
+</xsl:when> 
+<xsl:otherwise> 
+<xsl:value-of select="'/'" /> 
+</xsl:otherwise> 
+</xsl:choose> 
+</KOSTL> 
+<DUMMY4	ID="17"	Length="4"	Alignment="left" Filler="blank">/</DUMMY4> 
+<AUFNR	ID="18"	Length="12"	Alignment="left" Filler="blank"> 
+<xsl:choose> 
+<xsl:when test="costcenter2 and string-length(costcenter2) &gt; 0"> 
+<xsl:value-of select="costcenter2" /> 
+</xsl:when> 
+<xsl:otherwise> 
+<xsl:value-of select="'/'" /> 
+</xsl:otherwise> 
+</xsl:choose> 
+</AUFNR> 
+<EBELN	ID="19"	Length="10"	Alignment="left" Filler="blank">/</EBELN> 
+<EBELP	ID="20"	Length="5"	Alignment="left" Filler="blank">/</EBELP> 
+<PROJN	ID="21"	Length="16"	Alignment="left" Filler="blank">/</PROJN> 
+<MATNR	ID="22"	Length="18"	Alignment="left" Filler="blank">/</MATNR> 
+<WERKS	ID="23"	Length="4"	Alignment="left" Filler="blank">/</WERKS> 
+<MENGE	ID="24"	Length="17"	Alignment="left" Filler="blank">/</MENGE> 
+<MEINS	ID="25"	Length="3"	Alignment="left" Filler="blank">/</MEINS> 
+<VBEL2	ID="26"	Length="10"	Alignment="left" Filler="blank">/</VBEL2> 
+<POSN2	ID="27"	Length="6"	Alignment="left" Filler="blank">/</POSN2> 
+<ETEN2	ID="28"	Length="4"	Alignment="left" Filler="blank">/</ETEN2> 
+<PERNR	ID="29"	Length="8"	Alignment="left" Filler="blank">/</PERNR> 
+<BEWAR	ID="30"	Length="3"	Alignment="left" Filler="blank">/</BEWAR> 
+<VALUT	ID="31"	Length="8"	Alignment="left" Filler="blank">/</VALUT> 
+<ZFBDT	ID="32"	Length="8"	Alignment="left" Filler="blank">/</ZFBDT> 
+<ZINKZ	ID="33"	Length="2"	Alignment="left" Filler="blank">/</ZINKZ> 
+<ZUONR	ID="34"	Length="18"	Alignment="left" Filler="blank"> 
+<xsl:value-of select="orderNumber" /> 
+<xsl:value-of select="'-'" /> 
+<xsl:value-of select="itemNumber" /> 
+</ZUONR> 
+<FKONT	ID="35"	Length="3"	Alignment="left" Filler="blank">/</FKONT> 
+<XAABG	ID="36"	Length="1"	Alignment="left" Filler="blank">/</XAABG> 
+<SGTXT	ID="37"	Length="50"	Alignment="left" Filler="blank"> 
+<xsl:variable name="twoDigitYear"> 
+<xsl:value-of select="substring(parent::node()/financialPeriodYear, 3, 4)"/> 
+</xsl:variable> 
+<xsl:value-of select="$twoDigitYear" /> 
+<xsl:value-of select="'/'" /> 
+<xsl:value-of select="parent::node()/financialPeriodMonth" /> 
+</SGTXT> 
+<BLNKZ	ID="38"	Alignment="left" Filler="blank" Length="2">/</BLNKZ> 
+<BLNBT	ID="39" Alignment="left" Filler="blank" Length="16">/</BLNBT> 
+<BLNPZ	ID="40" Alignment="left" Filler="blank" Length="8">/</BLNPZ> 
+<MABER	ID="41" Alignment="left" Filler="blank" Length="2">/</MABER> 
+<SKFBT	ID="42" Alignment="left" Filler="blank" Length="16">/</SKFBT> 
+<WSKTO	ID="43" Alignment="left" Filler="blank" Length="16">/</WSKTO> 
+<ZTERM	ID="44" Alignment="left" Filler="blank" Length="4">/</ZTERM> 
+<ZBD1T	ID="45" Alignment="left" Filler="blank" Length="3">/</ZBD1T> 
+<ZBD1P	ID="46" Alignment="left" Filler="blank" Length="6">/</ZBD1P> 
+<ZBD2T	ID="47" Alignment="left" Filler="blank" Length="3">/</ZBD2T> 
+<ZBD2P	ID="48" Alignment="left" Filler="blank" Length="6">/</ZBD2P> 
+<ZBD3T	ID="49" Alignment="left" Filler="blank" Length="3">/</ZBD3T> 
+<ZLSPR	ID="50" Alignment="left" Filler="blank" Length="1">/</ZLSPR> 
+<REBZG	ID="51" Alignment="left" Filler="blank" Length="10">/</REBZG> 
+<REBZJ	ID="52" Alignment="left" Filler="blank" Length="4">/</REBZJ> 
+<REBZZ	ID="53" Alignment="left" Filler="blank" Length="3">/</REBZZ> 
+<ZLSCH	ID="54" Alignment="left" Filler="blank" Length="1">/</ZLSCH> 
+<SAMNR	ID="55" Alignment="left" Filler="blank" Length="8">/</SAMNR> 
+<ZBFIX	ID="56" Alignment="left" Filler="blank" Length="1">/</ZBFIX> 
+<QSSKZ	ID="57" Alignment="left" Filler="blank" Length="2">/</QSSKZ> 
+<QSSHB	ID="58" Alignment="left" Filler="blank" Length="16">/</QSSHB> 
+<QSFBT	ID="59" Alignment="left" Filler="blank" Length="16">/</QSFBT> 
+<ESRNR	ID="60" Alignment="left" Filler="blank" Length="11">/</ESRNR> 
+<ESRPZ	ID="61" Alignment="left" Filler="blank" Length="2">/</ESRPZ> 
+<ESRRE	ID="62" Alignment="left" Filler="blank" Length="27">/</ESRRE> 
+<FDTAG	ID="63" Alignment="left" Filler="blank" Length="8">/</FDTAG> 
+<FDLEV	ID="64" Alignment="left" Filler="blank" Length="2">/</FDLEV> 
+<ANLN1	ID="65" Alignment="left" Filler="blank" Length="12">/</ANLN1> 
+<ANLN2	ID="66" Alignment="left" Filler="blank" Length="4">/</ANLN2> 
+<BZDAT	ID="67" Alignment="left" Filler="blank" Length="8">/</BZDAT> 
+<ANBWA	ID="68" Alignment="left" Filler="blank" Length="3">/</ANBWA> 
+<ABPER	ID="69" Alignment="left" Filler="blank" Length="7">/</ABPER> 
+<GBETR	ID="70" Alignment="left" Filler="blank" Length="16">/</GBETR> 
+<KURSR	ID="71" Alignment="left" Filler="blank" Length="10">/</KURSR> 
+<MANSP	ID="72" Alignment="left" Filler="blank" Length="1">/</MANSP> 
+<MSCHL	ID="73" Alignment="left" Filler="blank" Length="1">/</MSCHL> 
+<HBKID	ID="74" Alignment="left" Filler="blank" Length="5">/</HBKID> 
+<BVTYP	ID="75" Alignment="left" Filler="blank" Length="4">/</BVTYP> 
+<ANFBN	ID="76" Alignment="left" Filler="blank" Length="10">/</ANFBN> 
+<ANFBU	ID="77" Alignment="left" Filler="blank" Length="4">/</ANFBU> 
+<ANFBJ	ID="78" Alignment="left" Filler="blank" Length="4">/</ANFBJ> 
+<LZBKZ	ID="79" Alignment="left" Filler="blank" Length="3"> 
+<xsl:choose> 
+<xsl:when test="orderType='S'"> 
+<xsl:value-of select="$constLZBZK_S_ORDER" /> 
+</xsl:when> 
+<xsl:otherwise> 
+<xsl:value-of select="$constLZBZK_OTHER" /> 
+</xsl:otherwise> 
+</xsl:choose>	
+</LZBKZ> 
+<LANDL	ID="80" Alignment="left" Filler="blank" Length="3">/</LANDL> 
+<DIEKZ	ID="81" Alignment="left" Filler="blank" Length="1">/</DIEKZ> 
+<ZOLLD	ID="82" Alignment="left" Filler="blank" Length="8">/</ZOLLD> 
+<ZOLLT	ID="83" Alignment="left" Filler="blank" Length="8">/</ZOLLT> 
+<VRSDT	ID="84" Alignment="left" Filler="blank" Length="8">/</VRSDT> 
+<VRSKZ	ID="85" Alignment="left" Filler="blank" Length="1">/</VRSKZ> 
+<HZUON	ID="86" Alignment="left" Filler="blank" Length="18">/</HZUON> 
+<REGUL	ID="87" Alignment="left" Filler="blank" Length="1">/</REGUL> 
+<NAME1	ID="88" Alignment="left" Filler="blank" Length="35">/</NAME1> 
+<NAME2	ID="89" Alignment="left" Filler="blank" Length="35">/</NAME2> 
+<NAME3	ID="90" Alignment="left" Filler="blank" Length="35">/</NAME3> 
+<NAME4	ID="91" Alignment="left" Filler="blank" Length="35">/</NAME4> 
+<STRAS	ID="92" Alignment="left" Filler="blank" Length="35">/</STRAS> 
+<ORT01	ID="93" Alignment="left" Filler="blank" Length="35">/</ORT01> 
+<PSTLZ	ID="94" Alignment="left" Filler="blank" Length="10">/</PSTLZ> 
+<LAND1	ID="95" Alignment="left" Filler="blank" Length="3">/</LAND1> 
+<REGIO	ID="96" Alignment="left" Filler="blank" Length="3">/</REGIO> 
+<BANKL	ID="97" Alignment="left" Filler="blank" Length="15">/</BANKL> 
+<BANKS	ID="98" Alignment="left" Filler="blank" Length="3">/</BANKS> 
+<BANKN	ID="99" Alignment="left" Filler="blank" Length="18">/</BANKN> 
+<BKONT	ID="100" Alignment="left" Filler="blank" Length="2">/</BKONT> 
+<STCD1	ID="101" Alignment="left" Filler="blank" Length="16">/</STCD1> 
+<STCD2	ID="102" Alignment="left" Filler="blank" Length="11">/</STCD2> 
+<MADAT	ID="103" Alignment="left" Filler="blank" Length="8">/</MADAT> 
+<MANST	ID="104" Alignment="left" Filler="blank" Length="1">/</MANST> 
+<EGMLD	ID="105" Alignment="left" Filler="blank" Length="3">/</EGMLD> 
+<DUMMY2	ID="106" Alignment="left" Filler="blank" Length="3">/</DUMMY2> 
+<STCEG	ID="107" Alignment="left" Filler="blank" Length="20">/</STCEG> 
+<STKZA	ID="108" Alignment="left" Filler="blank" Length="1">/</STKZA> 
+<STKZU	ID="109" Alignment="left" Filler="blank" Length="1">/</STKZU> 
+<PFACH	ID="110" Alignment="left" Filler="blank" Length="10">/</PFACH> 
+<PSTL2	ID="111" Alignment="left" Filler="blank" Length="10">/</PSTL2> 
+<SPRAS	ID="112" Alignment="left" Filler="blank" Length="1">/</SPRAS> 
+<XINVE	ID="113" Alignment="left" Filler="blank" Length="1">/</XINVE> 
+
+<NEWKO ID="114" Length="17" Alignment="left" Filler="blank"> 
+<xsl:value-of select="accountNumber" /> 
+</NEWKO> 
+
+<NEWBW	Length="3"	Alignment="left" Filler="blank" ID="115">/</NEWBW> 
+<KNRZE	Length="17"	Alignment="left" Filler="blank" ID="116">/</KNRZE> 
+<HKONT	Length="10"	Alignment="left" Filler="blank" ID="117">/</HKONT> 
+<PRCTR	Length="10"	Alignment="left" Filler="blank" ID="118">/</PRCTR> 
+<VERTN	Length="13"	Alignment="left" Filler="blank" ID="119">/</VERTN> 
+<VERTT	Length="1"	Alignment="left" Filler="blank" ID="120">/</VERTT> 
+<VBEWA	Length="4"	Alignment="left" Filler="blank" ID="121">/</VBEWA> 
+<HWBAS	Length="16"	Alignment="left" Filler="blank" ID="122">/</HWBAS> 
+<FWBAS	Length="16"	Alignment="left" Filler="blank" ID="123">/</FWBAS> 
+<FIPOS	Length="14"	Alignment="left" Filler="blank" ID="124">/</FIPOS> 
+<VNAME	Length="6"	Alignment="left" Filler="blank" ID="125">/</VNAME> 
+<EGRUP	Length="3"	Alignment="left" Filler="blank" ID="126">/</EGRUP> 
+<BTYPE	Length="2"	Alignment="left" Filler="blank" ID="127">/</BTYPE> 
+<PAOBJNR	Length="10"	Alignment="left" Filler="blank" ID="128">/</PAOBJNR> 
+<KSTRG	Length="12"	Alignment="left" Filler="blank" ID="129">/</KSTRG> 
+<IMKEY	Length="8"	Alignment="left" Filler="blank" ID="130">/</IMKEY> 
+<DUMMY3	Length="8"	Alignment="left" Filler="blank" ID="131">/</DUMMY3> 
+<VPTNR	Length="10"	Alignment="left" Filler="blank" ID="132">/</VPTNR> 
+<NPLNR	Length="12"	Alignment="left" Filler="blank" ID="133">/</NPLNR> 
+<VORNR	Length="4"	Alignment="left" Filler="blank" ID="134">/</VORNR> 
+<XEGDR	Length="1"	Alignment="left" Filler="blank" ID="135">/</XEGDR> 
+<RECID	Length="2"	Alignment="left" Filler="blank" ID="136">/</RECID> 
+<PPRCT	Length="10"	Alignment="left" Filler="blank" ID="137">/</PPRCT> 
+<PROJK	Length="24"	Alignment="left" Filler="blank" ID="138">/</PROJK> 
+<UZAWE	Length="2"	Alignment="left" Filler="blank" ID="139">/</UZAWE> 
+<TXJCD	Length="15"	Alignment="left" Filler="blank" ID="140">/</TXJCD> 
+<FISTL	Length="16"	Alignment="left" Filler="blank" ID="141">/</FISTL> 
+<GEBER	Length="10"	Alignment="left" Filler="blank" ID="142">/</GEBER> 
+<DMBE2	Length="16"	Alignment="left" Filler="blank" ID="143">/</DMBE2> 
+<DMBE3	Length="16"	Alignment="left" Filler="blank" ID="144">/</DMBE3> 
+<PARGB	Length="4"	Alignment="left" Filler="blank" ID="145">/</PARGB> 
+<XREF1	Length="12"	Alignment="left" Filler="blank" ID="146">/</XREF1> 
+<XREF2	Length="12"	Alignment="left" Filler="blank" ID="147">/</XREF2> 
+<KBLNR	Length="10"	Alignment="left" Filler="blank" ID="149">/</KBLNR> 
+<KBLPOS	Length="3"	Alignment="left" Filler="blank" ID="150">/</KBLPOS> 
+<WDATE	Length="8"	Alignment="left" Filler="blank" ID="151">/</WDATE> 
+<WGBKZ	Length="1"	Alignment="left" Filler="blank" ID="152">/</WGBKZ> 
+<XAKTZ	Length="1"	Alignment="left" Filler="blank" ID="153">/</XAKTZ> 
+<WNAME	Length="30"	Alignment="left" Filler="blank" ID="154">/</WNAME> 
+<WORT1	Length="30"	Alignment="left" Filler="blank" ID="155">/</WORT1> 
+<WBZOG	Length="30"	Alignment="left" Filler="blank" ID="156">/</WBZOG> 
+<WORT2	Length="30"	Alignment="left" Filler="blank" ID="157">/</WORT2> 
+<WBANK	Length="60"	Alignment="left" Filler="blank" ID="158">/</WBANK> 
+<WLZBP	Length="60"	Alignment="left" Filler="blank" ID="159">/</WLZBP> 
+<DISKP	Length="8"	Alignment="left" Filler="blank" ID="160">/</DISKP> 
+<DISKT	Length="3"	Alignment="left" Filler="blank" ID="161">/</DISKT> 
+<WINFW	Length="16"	Alignment="left" Filler="blank" ID="162">/</WINFW> 
+<WINHW	Length="16"	Alignment="left" Filler="blank" ID="163">/</WINHW> 
+<WEVWV	Length="1"	Alignment="left" Filler="blank" ID="164">/</WEVWV> 
+<WSTAT	Length="1"	Alignment="left" Filler="blank" ID="165">/</WSTAT> 
+<WMWKZ	Length="2"	Alignment="left" Filler="blank" ID="166">/</WMWKZ> 
+<WSTKZ	Length="1"	Alignment="left" Filler="blank" ID="167">/</WSTKZ> 
+<RKE_ARTNR	Length="18"	Alignment="left" Filler="blank" ID="169">/</RKE_ARTNR> 
+<RKE_BONUS	Length="2"	Alignment="left" Filler="blank" ID="170">/</RKE_BONUS> 
+<RKE_BRSCH	Length="4"	Alignment="left" Filler="blank" ID="171">/</RKE_BRSCH> 
+<RKE_BUKRS	Length="4"	Alignment="left" Filler="blank" ID="172">/</RKE_BUKRS> 
+<RKE_BZIRK	Length="6"	Alignment="left" Filler="blank" ID="173">/</RKE_BZIRK> 
+<RKE_EFORM	Length="5"	Alignment="left" Filler="blank" ID="174">/</RKE_EFORM> 
+<RKE_FKART	Length="4"	Alignment="left" Filler="blank" ID="175">/</RKE_FKART> 
+<RKE_GEBIE	Length="4"	Alignment="left" Filler="blank" ID="176">/</RKE_GEBIE> 
+<RKE_GSBER	Length="4"	Alignment="left" Filler="blank" ID="177">/</RKE_GSBER> 
+<RKE_KAUFN	Length="10"	Alignment="left" Filler="blank" ID="178">/</RKE_KAUFN> 
+<RKE_KDGRP	Length="2"	Alignment="left" Filler="blank" ID="179">/</RKE_KDGRP> 
+<RKE_KDPOS	Length="6"	Alignment="left" Filler="blank" ID="180">/</RKE_KDPOS> 
+<RKE_KNDNR	Length="10"	Alignment="left" Filler="blank" ID="181">/</RKE_KNDNR> 
+<RKE_KOKRS	Length="4"	Alignment="left" Filler="blank" ID="182">/</RKE_KOKRS> 
+<RKE_KSTRG	Length="12"	Alignment="left" Filler="blank" ID="183">/</RKE_KSTRG> 
+<RKE_LAND1	Length="3"	Alignment="left" Filler="blank" ID="184">/</RKE_LAND1> 
+<RKE_MAABC	Length="1"	Alignment="left" Filler="blank" ID="185">/</RKE_MAABC> 
+<RKE_MATKL	Length="9"	Alignment="left" Filler="blank" ID="186">/</RKE_MATKL> 
+<RKE_PRCTR	Length="10"	Alignment="left" Filler="blank" ID="187">/</RKE_PRCTR> 
+<RKE_PSPNR	Length="24"	Alignment="left" Filler="blank" ID="188">/</RKE_PSPNR> 
+<RKE_RKAUFNR	Length="12"	Alignment="left" Filler="blank" ID="189">/</RKE_RKAUFNR> 
+<RKE_SPART	Length="2"	Alignment="left" Filler="blank" ID="190">/</RKE_SPART> 
+<RKE_VKBUR	Length="4"	Alignment="left" Filler="blank" ID="191">/</RKE_VKBUR> 
+<RKE_VKGRP	Length="3"	Alignment="left" Filler="blank" ID="192">/</RKE_VKGRP> 
+<RKE_VKORG	Length="4"	Alignment="left" Filler="blank" ID="193">/</RKE_VKORG> 
+<RKE_VTWEG	Length="2"	Alignment="left" Filler="blank" ID="194">/</RKE_VTWEG> 
+<RKE_WERKS	Length="4"	Alignment="left" Filler="blank" ID="195">/</RKE_WERKS> 
+<RKE_KMBRND	Length="2"	Alignment="left" Filler="blank" ID="196">/</RKE_KMBRND> 
+<RKE_KMCATG	Length="2"	Alignment="left" Filler="blank" ID="197">/</RKE_KMCATG> 
+<RKE_KMHI01	Length="10"	Alignment="left" Filler="blank" ID="198">/</RKE_KMHI01> 
+<RKE_KMHI02	Length="10"	Alignment="left" Filler="blank" ID="199">/</RKE_KMHI02> 
+<RKE_KMHI03	Length="10"	Alignment="left" Filler="blank" ID="200">/</RKE_KMHI03> 
+<RKE_KMKDGR	Length="2"	Alignment="left" Filler="blank" ID="201">/</RKE_KMKDGR> 
+<RKE_KMLAND	Length="3"	Alignment="left" Filler="blank" ID="202">/</RKE_KMLAND> 
+<RKE_KMMAKL	Length="9"	Alignment="left" Filler="blank" ID="203">/</RKE_KMMAKL> 
+<RKE_KMNIEL	Length="2"	Alignment="left" Filler="blank" ID="204">/</RKE_KMNIEL> 
+<RKE_KMSTGE	Length="2"	Alignment="left" Filler="blank" ID="205">/</RKE_KMSTGE> 
+<RKE_KMVKBU	Length="4"	Alignment="left" Filler="blank" ID="206">/</RKE_KMVKBU> 
+<RKE_KMVKGR	Length="3"	Alignment="left" Filler="blank" ID="207">/</RKE_KMVKGR> 
+<RKE_KMVTNR	Length="8"	Alignment="left" Filler="blank" ID="208">/</RKE_KMVTNR> 
+<RKE_PPRCTR	Length="10"	Alignment="left" Filler="blank" ID="209">/</RKE_PPRCTR> 
+
+<!-- START new RKE-elements --> 
+<RKE_WW005	Length="5"	Alignment="left" Filler="blank" ID="276">/</RKE_WW005> 
+<RKE_WW006	Length="5"	Alignment="left" Filler="blank" ID="277">/</RKE_WW006> 
+<RKE_WW007	Length="3"	Alignment="left" Filler="blank" ID="278">/</RKE_WW007> 
+<RKE_WW008	Length="3"	Alignment="left" Filler="blank" ID="279">/</RKE_WW008> 
+<RKE_WW009	Length="1"	Alignment="left" Filler="blank" ID="280">/</RKE_WW009> 
+<RKE_WW010	Length="3"	Alignment="left" Filler="blank" ID="281">/</RKE_WW010> 
+<RKE_WW011	Length="2"	Alignment="left" Filler="blank" ID="282">/</RKE_WW011> 
+<RKE_WW012	Length="6"	Alignment="left" Filler="blank" ID="283">/</RKE_WW012> 
+<RKE_WW013	Length="10"	Alignment="left" Filler="blank" ID="284">/</RKE_WW013> 
+<RKE_WW015	Length="1"	Alignment="left" Filler="blank" ID="285">/</RKE_WW015> 
+<RKE_WW016	Length="2"	Alignment="left" Filler="blank" ID="286">/</RKE_WW016> 
+<RKE_WW017	Length="7"	Alignment="left" Filler="blank" ID="287">/</RKE_WW017> 
+<RKE_WW019	Length="6"	Alignment="left" Filler="blank" ID="289">/</RKE_WW019> 
+<!-- END new RKE-elements --> 
+
+<VBUND	Length="6"	Alignment="left" Filler="blank" ID="210">/</VBUND> 
+<FKBER	Length="4"	Alignment="left" Filler="blank" ID="211">/</FKBER> 
+<DABRZ	Length="8"	Alignment="left" Filler="blank" ID="212">/</DABRZ> 
+<XSTBA	Length="1"	Alignment="left" Filler="blank" ID="213">/</XSTBA> 
+
+<!-- Additional (empty) tags start --> 
+<RSTGR	Length="3" Alignment="left" Filler="blank" ID="214">/</RSTGR> 
+<FIPEX	Length="24" Alignment="left" Filler="blank" ID="215">/</FIPEX> 
+<XNEGP	Length="1" Alignment="left" Filler="blank" ID="216">/</XNEGP> 
+<GRICD	Length="2" Alignment="left" Filler="blank" ID="217">/</GRICD> 
+<GRIRG	Length="3" Alignment="left" Filler="blank" ID="218">/</GRIRG> 
+<GITYP	Length="2" Alignment="left" Filler="blank" ID="219">/</GITYP> 
+<FITYP	Length="2" Alignment="left" Filler="blank" ID="220">/</FITYP> 
+<STCDT	Length="2" Alignment="left" Filler="blank" ID="221">/</STCDT> 
+<STKZN	Length="1" Alignment="left" Filler="blank" ID="222">/</STKZN> 
+<STCD3	Length="18" Alignment="left" Filler="blank" ID="223">/</STCD3> 
+<STCD4	Length="18" Alignment="left" Filler="blank" ID="224">/</STCD4> 
+<XREF3	Length="20" Alignment="left" Filler="blank" ID="225">/</XREF3> 
+<KIDNO	Length="30" Alignment="left" Filler="blank" ID="226">/</KIDNO> 
+<DTWS1	Length="2" Alignment="left" Filler="blank" ID="227">/</DTWS1> 
+<DTWS2	Length="2" Alignment="left" Filler="blank" ID="228">/</DTWS2> 
+<DTWS3	Length="2" Alignment="left" Filler="blank" ID="229">/</DTWS3> 
+<DTWS4	Length="2" Alignment="left" Filler="blank" ID="230">/</DTWS4> 
+<DTAWS	Length="2" Alignment="left" Filler="blank" ID="231">/</DTAWS> 
+<PYCUR	Length="5" Alignment="left" Filler="blank" ID="232">/</PYCUR> 
+<PYAMT	Length="16" Alignment="left" Filler="blank" ID="233">/</PYAMT> 
+<BUPLA	Length="4" Alignment="left" Filler="blank" ID="234">/</BUPLA> 
+<SECCO	Length="4" Alignment="left" Filler="blank" ID="235">/</SECCO> 
+<LSTAR	Length="6" Alignment="left" Filler="blank" ID="236">/</LSTAR> 
+<EGDEB	Length="10" Alignment="left" Filler="blank" ID="237">/</EGDEB> 
+<WENR	Length="8" Alignment="left" Filler="blank" ID="238">/</WENR> 
+<GENR	Length="8" Alignment="left" Filler="blank" ID="239">/</GENR> 
+<GRNR	Length="8" Alignment="left" Filler="blank" ID="240">/</GRNR> 
+<MENR	Length="8" Alignment="left" Filler="blank" ID="241">/</MENR> 
+<MIVE	Length="13" Alignment="left" Filler="blank" ID="242">/</MIVE> 
+<NKSL	Length="4" Alignment="left" Filler="blank" ID="243">/</NKSL> 
+<EMPSL	Length="5" Alignment="left" Filler="blank" ID="244">/</EMPSL> 
+<SVWNR	Length="13" Alignment="left" Filler="blank" ID="245">/</SVWNR> 
+<SBERI	Length="10" Alignment="left" Filler="blank" ID="246">/</SBERI> 
+<KKBER	Length="4" Alignment="left" Filler="blank" ID="247">/</KKBER> 
+<EMPFB	Length="10" Alignment="left" Filler="blank" ID="248">/</EMPFB> 
+<KURSR_M	Length="10" Alignment="left" Filler="blank" ID="249">/</KURSR_M> 
+<J_1KFREPRE	Length="10" Alignment="left" Filler="blank" ID="250">/</J_1KFREPRE> 
+<J_1KFTBUS	Length="30" Alignment="left" Filler="blank" ID="251">/</J_1KFTBUS> 
+<J_1KFTIND	Length="30" Alignment="left" Filler="blank" ID="252">/</J_1KFTIND> 
+<IDXSP	Length="5" Alignment="left" Filler="blank" ID="253">/</IDXSP> 
+<ANRED	Length="15" Alignment="left" Filler="blank" ID="254">/</ANRED> 
+<RECNNR	Length="13" Alignment="left" Filler="blank" ID="255">/</RECNNR> 
+<E_MIVE	Length="13" Alignment="left" Filler="blank" ID="256">/</E_MIVE> 
+<BKREF	Length="20" Alignment="left" Filler="blank" ID="257">/</BKREF> 
+<DTAMS	Length="1" Alignment="left" Filler="blank" ID="258">/</DTAMS> 
+<CESSION_KZ	Length="2" Alignment="left" Filler="blank" ID="259">/</CESSION_KZ> 
+<GRANT_NBR	Length="20" Alignment="left" Filler="blank" ID="260">/</GRANT_NBR> 
+<FKBER_LONG	Length="16" Alignment="left" Filler="blank" ID="261">/</FKBER_LONG> 
+<ERLKZ	Length="1" Alignment="left" Filler="blank" ID="262">/</ERLKZ> 
+<IBAN	Length="34" Alignment="left" Filler="blank" ID="263">/</IBAN> 
+<VALID_FROM	Length="8" Alignment="left" Filler="blank" ID="264">/</VALID_FROM> 
+<SEGMENT	Length="10" Alignment="left" Filler="blank" ID="265">/</SEGMENT> 
+<PSEGMENT	Length="10" Alignment="left" Filler="blank" ID="266">/</PSEGMENT> 
+<HKTID	Length="5" Alignment="left" Filler="blank" ID="267">/</HKTID> 
+<XSIWE	Length="1" Alignment="left" Filler="blank" ID="268">/</XSIWE> 
+<TCNO	Length="16" Alignment="left" Filler="blank" ID="269">/</TCNO> 
+<DATEOFSERVICE	Length="8" Alignment="left" Filler="blank" ID="270">/</DATEOFSERVICE> 
+<NOTAXCORR	Length="1" Alignment="left" Filler="blank" ID="271">/</NOTAXCORR> 
+<DIFFOPTRATE	Length="10" Alignment="left" Filler="blank" ID="272">/</DIFFOPTRATE> 
+<HASDIFFOPTRATE	Length="1" Alignment="left" Filler="blank" ID="273">/</HASDIFFOPTRATE> 
+<SENDE	Length="1" Alignment="left" Filler="blank" ID="274">/</SENDE> 
+<PRODPER	Length="8" Alignment="left" Filler="blank" ID="275">/</PRODPER> 
+<!-- Additional tags end --> 
+
+</invoiceDetails_DetailCharges_1_elements> 
+</xsl:template> 
+<!-- end transformation_2 --> 
+
+<!-- start transformation_1 --> 
+<xsl:template name="transformation_1_elements"> 
+<xsl:apply-templates select="transferInvoice"/> 
+</xsl:template> 
+
+<xsl:template match="transferInvoice"> 
+<transformation_1_elements> 
+<xsl:apply-templates select="invoice"/> 
+</transformation_1_elements> 
+</xsl:template> 
+<!-- end transformation_1 --> 
+
+<xsl:template match="invoice"> 
+<invoice_elements> 
+<xsl:attribute name="invoiceNumber"> 
+<xsl:value-of select="invoiceNumber"/> 
+</xsl:attribute> 
+<xsl:for-each select="*[count(./*) = 0]"> 
+<xsl:copy-of select="."/> 
+</xsl:for-each> 
+<xsl:apply-templates select="invoiceHeader"/> 
+<xsl:apply-templates select="invoiceCharges"/> 
+<xsl:apply-templates select="invoiceDetails"/> 
+</invoice_elements> 
+</xsl:template> 
+
+<!-- start invoiceHeader transformation_1 --> 
+<xsl:template match="invoiceHeader"> 
+<xsl:for-each select="*[count(./*) = 0]"> 
+<xsl:copy-of select="."/> 
+</xsl:for-each> 
+<xsl:apply-templates select="invoiceAmount"/> 
+<xsl:apply-templates select="orderInformation"/> 
+<xsl:apply-templates select="invoiceReversal"/> 
+<xsl:apply-templates select="invoiceTransferInformation"/> 
+<xsl:apply-templates select="paymentInformation"/> 
+<xsl:apply-templates select="financialPeriodInformation"/> 
+<xsl:apply-templates select="currencyConversionInformation"/> 
+</xsl:template> 
+
+<xsl:template match="invoiceAmount"> 
+<internationalCurrencyCode> 
+<xsl:value-of select="*[position() = 1]/@internationalCurrencyCode"/> 
+</internationalCurrencyCode> 
+<xsl:for-each select="*[count(./*) = 0]"> 
+<xsl:copy-of select="."/> 
+</xsl:for-each> 
+<xsl:apply-templates select="taxation"/> 
+</xsl:template> 
+
+<xsl:template match="taxation"> 
+<xsl:for-each select="*[count(./*) = 0]"> 
+<xsl:copy-of select="."/> 
+</xsl:for-each> 
+</xsl:template> 
+
+<xsl:template match="orderInformation"> 
+<xsl:for-each select="*[count(./*) = 0]"> 
+<xsl:copy-of select="."/> 
+</xsl:for-each> 
+</xsl:template> 
+
+<xsl:template match="invoiceReversal"> 
+<xsl:for-each select="*[count(./*) = 0]"> 
+<xsl:copy-of select="."/> 
+</xsl:for-each> 
+</xsl:template> 
+
+<xsl:template match="invoiceTransferInformation"> 
+<xsl:for-each select="*[count(./*) = 0]"> 
+<xsl:copy-of select="."/> 
+</xsl:for-each> 
+</xsl:template> 
+
+<xsl:template match="paymentInformation"> 
+<xsl:for-each select="*[count(./*) = 0]"> 
+<xsl:copy-of select="."/> 
+</xsl:for-each> 
+</xsl:template> 
+
+<xsl:template match="financialPeriodInformation"> 
+<xsl:for-each select="*[count(./*) = 0]"> 
+<xsl:copy-of select="."/> 
+</xsl:for-each> 
+</xsl:template> 
+
+<xsl:template match="currencyConversionInformation"> 
+<xsl:for-each select="*[count(./*) = 0]"> 
+<xsl:copy-of select="."/> 
+</xsl:for-each> 
+</xsl:template> 
+<!-- end invoiceHeader transformation_1 --> 
+
+<!-- start invoiceDetails transformation_1 --> 
+<xsl:template match="invoiceDetails"> 
+<invoiceDetails_elements> 
+<xsl:for-each select="*[count(./*) = 0]"> 
+<xsl:copy-of select="."/> 
+</xsl:for-each> 
+<xsl:apply-templates select="partInformation"/> 
+<xsl:apply-templates select="detailAmount"/> 
+<xsl:apply-templates select="orderInformation"/> 
+</invoiceDetails_elements> 
+<xsl:apply-templates select="detailCharges" mode="invoiceDetails"/> 
+</xsl:template> 
+
+<xsl:template match="orderInformation"> 
+<xsl:for-each select="*[count(./*) = 0]"> 
+<xsl:copy-of select="."/> 
+</xsl:for-each> 
+</xsl:template> 
+
+<xsl:template match="partInformation"> 
+<xsl:for-each select="*[count(./*) = 0]"> 
+<xsl:copy-of select="."/> 
+</xsl:for-each> 
+</xsl:template> 
+
+<xsl:template match="detailAmount"> 
+<xsl:for-each select="*[count(./*) = 0]"> 
+<xsl:copy-of select="."/> 
+</xsl:for-each> 
+<xsl:apply-templates select="taxation" /> 
+</xsl:template> 
+
+<xsl:template match="chargeAmount"> 
+<xsl:for-each select="*[count(./*) = 0]"> 
+<xsl:copy-of select="."/> 
+</xsl:for-each> 
+<xsl:apply-templates select="taxation" /> 
+</xsl:template> 
+
+<xsl:template match="detailCharges" mode="invoiceDetails"> 
+<invoiceDetails_DetailCharges_elements> 
+<xsl:apply-templates select="chargeType"/> 
+<xsl:for-each select="*[count(./*) = 0]"> 
+<xsl:copy-of select="."/> 
+</xsl:for-each> 
+<xsl:apply-templates select="chargeAmount"/> 
+<xsl:apply-templates select="parent::node()/orderInformation"/> 
+</invoiceDetails_DetailCharges_elements> 
+</xsl:template> 
+
+<xsl:template match="chargeType"> 
+<xsl:for-each select="*[count(./*) = 0]"> 
+<xsl:copy-of select="."/> 
+</xsl:for-each> 
+</xsl:template> 
+<!-- end invoiceDetails transformation_1 --> 
+
+<!-- start invoiceCharges transformation_1 --> 
+<xsl:template match="invoiceCharges"> 
+<invoiceCharges_elements> 
+<xsl:for-each select="*[count(./*) = 0]"> 
+<xsl:copy-of select="."/> 
+</xsl:for-each> 
+<xsl:apply-templates select="chargeType" mode="invoiceCharges"/> 
+<xsl:apply-templates select="chargeAmount"/> 
+<xsl:apply-templates select="parent::node()/invoiceHeader/orderInformation"/>	
+</invoiceCharges_elements> 
+</xsl:template> 
+
+<xsl:template match="chargeType" mode="invoiceCharges"> 
+<xsl:for-each select="*[count(./*) = 0]"> 
+<xsl:copy-of select="."/> 
+</xsl:for-each> 
+</xsl:template> 
+<!-- end invoiceCharges transformation_1 --> 
+
+<xsl:template name="getFormatedDate"> 
+<xsl:param name="date2format"/> 
+<xsl:variable name="y" select="substring($date2format, 1, 4)"/> 
+<xsl:variable name="m" select="substring($date2format, 6, 2)"/> 
+<xsl:variable name="d" select="substring($date2format, 9, 2)"/> 
+<xsl:value-of select="concat($y,$m,$d)"/> 
+</xsl:template> 
+
+<xsl:template name="getMonthOfDate"> 
+<xsl:param name="date2format"/> 
+<xsl:variable name="y" select="substring($date2format, 1, 4)"/> 
+<xsl:variable name="m" select="substring($date2format, 6, 2)"/> 
+<xsl:variable name="d" select="substring($date2format, 9, 2)"/> 
+<xsl:value-of select="$m"/> 
+</xsl:template> 
+
+<xsl:template name="getYearOfDate"> 
+<xsl:param name="date2format"/> 
+<xsl:variable name="y" select="substring($date2format, 1, 4)"/> 
+<xsl:variable name="m" select="substring($date2format, 6, 2)"/> 
+<xsl:variable name="d" select="substring($date2format, 9, 2)"/> 
+<xsl:value-of select="$y"/> 
+</xsl:template> 
+
+<xsl:template name="dup"> 
+<xsl:param name="input"/> 
+<xsl:param name="count" select="2"/> 
+<xsl:choose> 
+<xsl:when test="not($count) or not($input)"/> 
+<xsl:when test="$count = 1"> 
+<xsl:value-of select="$input"/> 
+</xsl:when> 
+<xsl:otherwise> 
+<!-- If $count is odd append an extra copy of input --> 
+<xsl:if test="$count mod 2"> 
+<xsl:value-of select="$input"/> 
+</xsl:if> 
+<!-- Recursively apply template after doubling input and halving count --> 
+<xsl:call-template name="dup"> 
+<xsl:with-param name="input" select="concat($input,$input)"/> 
+<xsl:with-param name="count" select="floor($count div 2)"/> 
+</xsl:call-template> 
+</xsl:otherwise> 
+</xsl:choose> 
+</xsl:template> 
+
+<xsl:template name="justify"> 
+<xsl:param name="value"/> 
+<xsl:param name="filler" select="' '"/> 
+<xsl:param name="width" select="10"/> 
+<xsl:param name="align" select=" 'left' "/> 
+<!-- Truncate if too long --> 
+<xsl:variable name="output" select="substring($value,1,$width)"/> 
+<xsl:choose> 
+<xsl:when test="$align = 'left' "> 
+<xsl:value-of select="$output"/> 
+<xsl:call-template name="dup"> 
+<xsl:with-param name="input" select="$filler"/> 
+<xsl:with-param name="count" select="$width - string-length($output)"/> 
+</xsl:call-template> 
+</xsl:when> 
+<xsl:when test="$align = 'right' "> 
+<xsl:call-template name="dup"> 
+<xsl:with-param name="input" select="$filler"/> 
+<xsl:with-param name="count" select="$width - string-length($output)"/> 
+</xsl:call-template> 
+<xsl:value-of select="$output"/> 
+</xsl:when> 
+<xsl:when test="$align = 'center' "> 
+<xsl:call-template name="dup"> 
+<xsl:with-param name="input" select="$filler"/> 
+<xsl:with-param name="count" select="floor(($width - string-length($output)) div 2)"/> 
+</xsl:call-template> 
+<xsl:value-of select="$output"/> 
+<xsl:call-template name="dup"> 
+<xsl:with-param name="input" select="$filler"/> 
+<xsl:with-param name="count" select="ceiling(($width - string-length($output)) div 2)"/> 
+</xsl:call-template> 
+</xsl:when> 
+<xsl:otherwise>INVALID ALIGN</xsl:otherwise> 
+</xsl:choose> 
+</xsl:template> 
+
+</xsl:stylesheet>
diff --git a/jdk/test/javax/xml/jaxp/transform/8150704/TransformerTest.java b/jdk/test/javax/xml/jaxp/transform/8150704/TransformerTest.java
new file mode 100644
index 0000000..62ade11
--- /dev/null
+++ b/jdk/test/javax/xml/jaxp/transform/8150704/TransformerTest.java
@@ -0,0 +1,97 @@
+/*
+ * 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 8150704
+ * @summary Test that XSL transformation with lots of temporary result trees will not run out of DTM IDs.
+ * @run testng/othervm TransformerTest
+ */
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.StringWriter;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import org.testng.Assert;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+
+public class TransformerTest {
+
+    @Test(dataProvider = "bug8150704")
+    public final void testBug8150704(String xsl, String xml, String ref) throws Exception {
+        System.out.println("Testing transformation of "+xml);
+        Transformer transformer = createTransformerFromResource(xsl);
+        StringWriter result = transformResourceToStringWriter(transformer, xml);
+        String resultstring = result.toString().replaceAll("\\r\\n", "\n").replaceAll("\\r", "\n");
+        String reference = getFileContentAsString(new File(getClass().getResource(ref).getPath()));
+        Assert.assertEquals(resultstring, reference, "Output of transformation of "+xml+" does not match reference");
+    }
+
+    @DataProvider(name = "bug8150704")
+    private Object[][] dataBug8150704() {
+        return new Object[][] {
+            //xsl file, xml file, reference file
+            {"Bug8150704-1.xsl", "Bug8150704-1.xml", "Bug8150704-1.ref"},
+            {"Bug8150704-2.xsl", "Bug8150704-2.xml", "Bug8150704-2.ref"},
+        };
+    }
+
+    private Transformer createTransformerFromResource(String xslResource) throws TransformerException {
+        return TransformerFactory.newInstance().newTransformer(new StreamSource(getClass().getResource(xslResource).toString()));
+    }
+
+    private StringWriter transformResourceToStringWriter(Transformer transformer, String xmlResource) throws TransformerException {
+        StringWriter sw = new StringWriter();
+        transformer.transform(new StreamSource(getClass().getResource(xmlResource).toString()), new StreamResult(sw));
+        return sw;
+    }
+
+    /**
+     * Reads the contents of the given file into a string.
+     * WARNING: this method adds a final line feed even if the last line of the file doesn't contain one.
+     *
+     * @param f
+     * The file to read
+     * @return The content of the file as a string, with line terminators as \"n"
+     * for all platforms
+     * @throws IOException
+     * If there was an error reading
+     */
+    private String getFileContentAsString(File f) throws IOException {
+        try (BufferedReader reader = new BufferedReader(new FileReader(f))) {
+            String line;
+            StringBuilder sb = new StringBuilder();
+            while ((line = reader.readLine()) != null) {
+                sb.append(line).append("\n");
+            }
+            return sb.toString();
+        }
+    }
+}
diff --git a/jdk/test/javax/xml/jaxp/validation/8149915/Bug8149915.xsd b/jdk/test/javax/xml/jaxp/validation/8149915/Bug8149915.xsd
new file mode 100644
index 0000000..872033f
--- /dev/null
+++ b/jdk/test/javax/xml/jaxp/validation/8149915/Bug8149915.xsd
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+<xs:annotation>
+   <xs:appinfo>Testapp for XSD annotation issue</xs:appinfo>
+   <xs:documentation xml:lang="en">This is an XSD annotation, just for the sake of it.</xs:documentation>
+</xs:annotation>
+</xs:schema>
diff --git a/jdk/test/javax/xml/jaxp/validation/8149915/SchemaTest.java b/jdk/test/javax/xml/jaxp/validation/8149915/SchemaTest.java
new file mode 100644
index 0000000..c58d842
--- /dev/null
+++ b/jdk/test/javax/xml/jaxp/validation/8149915/SchemaTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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
+ * @summary Test Schema creation
+ * @bug 8149915
+ * @run testng/othervm SchemaTest
+ */
+
+import java.io.File;
+import javax.xml.XMLConstants;
+import javax.xml.validation.SchemaFactory;
+import org.testng.annotations.Test;
+
+public class SchemaTest {
+
+    /*
+     * @bug 8149915
+     * Verifies that the annotation validator is initialized with the security manager for schema
+     * creation with http://apache.org/xml/features/validate-annotations=true.
+     */
+    @Test
+    public void testValidation() throws Exception {
+        SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+        factory.setFeature("http://apache.org/xml/features/validate-annotations", true);
+        factory.newSchema(new File(getClass().getResource("Bug8149915.xsd").getFile()));
+    }
+}
diff --git a/jdk/test/lib/testlibrary/JavaToolUtils.java b/jdk/test/lib/testlibrary/JavaToolUtils.java
new file mode 100644
index 0000000..c9736bc
--- /dev/null
+++ b/jdk/test/lib/testlibrary/JavaToolUtils.java
@@ -0,0 +1,209 @@
+/*
+ * 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.
+ */
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.nio.file.Files;
+import java.util.List;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+/**
+ * Utils class for compiling , creating jar file and executing a java command
+ *
+ * @author Raghu Nair
+ */
+
+public class JavaToolUtils {
+
+    public static final long DEFAULT_WAIT_TIME = 10000;
+
+    private JavaToolUtils() {
+    }
+
+    /**
+     * Takes a list of files and compile these files into the working directory.
+     *
+     * @param files
+     * @throws IOException
+     */
+    public static void compileFiles(List<File> files) throws IOException {
+        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+        try (StandardJavaFileManager fileManager = compiler.
+                getStandardFileManager(null, null, null)) {
+            Iterable<? extends JavaFileObject> compilationUnit
+                    = fileManager.getJavaFileObjectsFromFiles(files);
+            compiler.getTask(null, fileManager, null, null, null,
+                    compilationUnit).call();
+        }
+    }
+
+    /**
+     * Create a jar file using the list of files provided.
+     *
+     * @param jar
+     * @param files
+     * @throws IOException
+     */
+    public static void createJar(File jar, List<File> files)
+            throws IOException {
+        Manifest manifest = new Manifest();
+        manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION,
+                "1.0");
+        try (JarOutputStream target = new JarOutputStream(
+                new FileOutputStream(jar), manifest)) {
+            for (File file : files) {
+                add(file, target);
+            }
+        }
+    }
+
+    private static void add(File source, JarOutputStream target)
+            throws IOException {
+        Objects.requireNonNull(source, "source cannot be null");
+        Objects.requireNonNull(target, "target cannot be null");
+        // not tested against directories and from different path.
+        String name = source.getName();
+        if (source.isDirectory()) {
+            if (!name.isEmpty()) {
+                if (!name.endsWith("/")) {
+                    name += "/";
+                }
+                JarEntry entry = new JarEntry(name);
+                entry.setTime(source.lastModified());
+                target.putNextEntry(entry);
+                target.closeEntry();
+            }
+            for (File nestedFile : source.listFiles()) {
+                add(nestedFile, target);
+            }
+            return;
+        }
+        System.out.println("Adding entry " + name);
+        JarEntry entry = new JarEntry(name);
+        entry.setTime(source.lastModified());
+        target.putNextEntry(entry);
+        Files.copy(source.toPath(), target);
+        target.closeEntry();
+    }
+
+    /**
+     * Runs java command with provided arguments. Caller should not pass java
+     * command in the argument list.
+     *
+     * @param commands
+     * @param waitTime time to wait for the command to exit in milli seconds
+     * @return
+     * @throws Exception
+     */
+    public static int runJava(List<String> commands,long waitTime)
+            throws Exception {
+        String java = System.getProperty("java.home") + "/bin/java";
+        commands.add(0, java);
+        String command = commands.toString().replace(",", " ");
+        System.out.println("Executing the following command \n" + command);
+        ProcessBuilder processBuilder = new ProcessBuilder(commands);
+        final Process process = processBuilder.start();
+        BufferedReader errorStream = new BufferedReader(
+                new InputStreamReader(process.getErrorStream()));
+        BufferedReader outStream = new BufferedReader(
+                new InputStreamReader(process.getInputStream()));
+        String errorLine;
+        StringBuilder errors = new StringBuilder();
+        String outLines;
+        while ((errorLine = errorStream.readLine()) != null) {
+            errors.append(errorLine).append("\n");
+        }
+        while ((outLines = outStream.readLine()) != null) {
+            System.out.println(outLines);
+        }
+        errorLine = errors.toString();
+        System.err.println(errorLine);
+        process.waitFor(waitTime, TimeUnit.MILLISECONDS);
+        int exitStatus = process.exitValue();
+        if (exitStatus != 0 && errorLine != null && errorLine.isEmpty()) {
+            throw new RuntimeException(errorLine);
+        }
+        return exitStatus;
+    }
+
+    /**
+     * Runs java command with provided arguments. Caller should not pass java
+     * command in the argument list.
+     *
+     * @param commands
+     * @return
+     * @throws Exception
+     */
+    public static int runJava(List<String> commands) throws Exception {
+        return runJava(commands, DEFAULT_WAIT_TIME);
+    }
+
+    /**
+     * Run any command
+     * @param commands
+     * @return
+     * @throws Exception
+     */
+    public static int runCommand(List<String> commands) throws Exception {
+        String command = commands.toString().replace(",", " ");
+        System.out.println("Executing the following command \n" + command);
+        ProcessBuilder processBuilder = new ProcessBuilder(commands);
+        final Process process = processBuilder.start();
+        BufferedReader errorStream = new BufferedReader(
+                new InputStreamReader(process.getErrorStream()));
+        BufferedReader outStream = new BufferedReader(
+                new InputStreamReader(process.getInputStream()));
+        String errorLine;
+        StringBuilder errors = new StringBuilder();
+        String outLines;
+        while ((errorLine = errorStream.readLine()) != null) {
+            errors.append(errorLine).append("\n");
+        }
+        while ((outLines = outStream.readLine()) != null) {
+            System.out.println(outLines);
+        }
+        errorLine = errors.toString();
+        System.err.println(errorLine);
+        int exitStatus = process.exitValue();
+        if (exitStatus != 0 && errorLine != null && errorLine.isEmpty()) {
+            throw new RuntimeException(errorLine);
+        }
+        return exitStatus;
+    }
+
+
+}
diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/JcmdBase.java b/jdk/test/lib/testlibrary/jdk/testlibrary/JcmdBase.java
index 14599c9..1837cea 100644
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/JcmdBase.java
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/JcmdBase.java
@@ -26,34 +26,91 @@
 import java.util.Arrays;
 
 /**
- * Super class for tests which need to attach jcmd to the current process.
+ * Helper class for starting jcmd process.
+ * <pre>
+ * - jcmd will send diagnostic requests to the current java process:
+ *      jcmd pid_to_current_process PerfCounter.print
+ * - jcmd will be run without sending request to any JVM
+ *      jcmd -h
+ * </pre>
  */
-public class JcmdBase {
+public final class JcmdBase {
 
     private static ProcessBuilder processBuilder = new ProcessBuilder();
 
+    private JcmdBase() {
+        // Private constructor to prevent class instantiation
+    }
+
     /**
-     * Attach jcmd to the current process
+     * Sends the diagnostic command request to the current process
      *
-     * @param toolArgs
-     *            jcmd command line parameters, e.g. VM.flags
-     * @return jcmd output
+     * @see #jcmd(boolean, String[], String[])
+     */
+    public final static OutputAnalyzer jcmd(String... jcmdArgs)
+            throws Exception {
+        return jcmd(true, null, jcmdArgs);
+    }
+
+    /**
+     * Sends the diagnostic command request to the current process.
+     * jcmd will be run with specified {@code vmArgs}.
+     *
+     * @see #jcmd(boolean, String[], String[])
+     */
+    public final static OutputAnalyzer jcmd(String[] vmArgs,
+            String[] jcmdArgs) throws Exception {
+        return jcmd(true, vmArgs, jcmdArgs);
+    }
+
+    /**
+     * Runs jcmd without sending request to any JVM
+     *
+     * @see #jcmd(boolean, String[], String[])
+     */
+    public final static OutputAnalyzer jcmdNoPid(String[] vmArgs,
+            String[] jcmdArgs) throws Exception {
+        return jcmd(false, vmArgs, jcmdArgs);
+    }
+
+    /**
+     * If {@code requestToCurrentProcess} is {@code true}
+     * sends a diagnostic command request to the current process.
+     * If {@code requestToCurrentProcess} is {@code false}
+     * runs jcmd without sending request to any JVM.
+     *
+     * @param requestToCurrentProcess
+     *            Defines if jcmd will send request to the current process
+     * @param vmArgs
+     *            jcmd will be run with VM arguments specified,
+     *            e.g. -XX:+UsePerfData
+     * @param jcmdArgs
+     *            jcmd will be run with option or command and its arguments
+     *            specified, e.g. VM.flags
+     * @return The output from {@link OutputAnalyzer} object
      * @throws Exception
      */
-    public final static OutputAnalyzer jcmd(String... toolArgs)
-            throws Exception {
+    private static final OutputAnalyzer jcmd(boolean requestToCurrentProcess,
+            String[] vmArgs, String[] jcmdArgs) throws Exception {
         JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jcmd");
-        launcher.addToolArg(Integer.toString(ProcessTools.getProcessId()));
-        for (String toolArg : toolArgs) {
-            launcher.addToolArg(toolArg);
+        if (vmArgs != null) {
+            for (String vmArg : vmArgs) {
+                launcher.addVMArg(vmArg);
+            }
+        }
+        if (requestToCurrentProcess) {
+            launcher.addToolArg(Long.toString(ProcessTools.getProcessId()));
+        }
+        if (jcmdArgs != null) {
+            for (String toolArg : jcmdArgs) {
+                launcher.addToolArg(toolArg);
+            }
         }
         processBuilder.command(launcher.getCommand());
         System.out.println(Arrays.toString(processBuilder.command().toArray()).replace(",", ""));
         OutputAnalyzer output = new OutputAnalyzer(processBuilder.start());
         System.out.println(output.getOutput());
 
-        output.shouldHaveExitValue(0);
-
         return output;
     }
 
diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java b/jdk/test/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java
index d39c0ab..7c0d364 100644
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java
@@ -23,11 +23,14 @@
 
 package jdk.testlibrary;
 
+import static jdk.testlibrary.Asserts.*;
+
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import java.util.Scanner;
 
 /**
  * Utility class for verifying output and exit value from a {@code Process}.
@@ -397,22 +400,105 @@
         return exitValue;
     }
 
+
     /**
      * Get the contents of the output buffer (stdout and stderr) as list of strings.
      * Output will be split by system property 'line.separator'.
      *
      * @return Contents of the output buffer as list of strings
      */
-    public List<String> asLines() {
-        return asLines(getOutput());
-    }
+     public List<String> asLines() {
+         return asLines(getOutput());
+     }
 
-    private List<String> asLines(String buffer) {
+     public List<String> asLines(String buffer) {
         List<String> l = new ArrayList<>();
+
         String[] a = buffer.split(Utils.NEW_LINE);
+
         for (String string : a) {
             l.add(string);
         }
         return l;
     }
+
+    /**
+     * Check if there is a line matching {@code pattern} and return its index
+     *
+     * @param pattern Matching pattern
+     * @return Index of first matching line
+     */
+    private int indexOf(List<String> lines, String pattern) {
+        for (int i = 0; i < lines.size(); i++) {
+            if (lines.get(i).matches (pattern)) {
+                return i;
+            }
+        }
+        return -1;
+    }
+
+    /**
+     * @see #shouldMatchByLine(String, String, String)
+     */
+    public int shouldMatchByLine(String pattern) {
+        return shouldMatchByLine(null, null, pattern);
+    }
+
+    /**
+     * @see #shouldMatchByLine(String, String, String)
+     */
+    public int shouldMatchByLineFrom(String from, String pattern) {
+        return shouldMatchByLine(from, null, pattern);
+    }
+
+    /**
+     * @see #shouldMatchByLine(String, String, String)
+     */
+    public int shouldMatchByLineTo(String to, String pattern) {
+        return shouldMatchByLine(null, to, pattern);
+    }
+
+    /**
+     * Verify that the stdout and stderr contents of output buffer match the
+     * {@code pattern} line by line. The whole output could be matched or
+     * just a subset of it.
+     *
+     * @param from
+     *            The line from where output will be matched.
+     *            Set {@code from} to null for matching from the first line.
+     * @param to
+     *            The line until where output will be matched.
+     *            Set {@code to} to null for matching until the last line.
+     * @param pattern
+     *            Matching pattern
+     * @return Count of lines which match the {@code pattern}
+     */
+    public int shouldMatchByLine(String from, String to, String pattern) {
+        List<String> lines = asLines();
+
+        int fromIndex = 0;
+        if (from != null) {
+            fromIndex = indexOf(lines, from);
+            assertGreaterThan(fromIndex, -1,
+                    "The line/pattern '" + from + "' from where the output should match can not be found");
+        }
+
+        int toIndex = lines.size();
+        if (to != null) {
+            toIndex = indexOf(lines, to);
+            assertGreaterThan(toIndex, -1,
+                    "The line/pattern '" + to + "' until where the output should match can not be found");
+        }
+
+        List<String> subList = lines.subList(fromIndex, toIndex);
+        int matchedCount = 0;
+        for (String line : subList) {
+            assertTrue(line.matches(pattern),
+                    "The line '" + line + "' does not match pattern '" + pattern + "'");
+            matchedCount++;
+        }
+
+        return matchedCount;
+    }
+
 }
diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java b/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java
index a5b956f..5050e15 100644
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java
@@ -269,16 +269,46 @@
     }
 
     /**
-     * Create ProcessBuilder using the java launcher from the jdk to be tested
-     * and with any platform specific arguments prepended
+     * Create ProcessBuilder using the java launcher from the jdk to be tested,
+     * and with any platform specific arguments prepended.
+     *
+     * @param command Arguments to pass to the java command.
+     * @return The ProcessBuilder instance representing the java command.
      */
     public static ProcessBuilder createJavaProcessBuilder(String... command)
             throws Exception {
+        return createJavaProcessBuilder(false, command);
+    }
+
+    /**
+     * Create ProcessBuilder using the java launcher from the jdk to be tested,
+     * and with any platform specific arguments prepended.
+     *
+     * @param addTestVmAndJavaOptions If true, adds test.vm.opts and test.java.opts
+     *        to the java arguments.
+     * @param command Arguments to pass to the java command.
+     * @return The ProcessBuilder instance representing the java command.
+     */
+    public static ProcessBuilder createJavaProcessBuilder(boolean addTestVmAndJavaOptions, String... command) throws Exception {
         String javapath = JDKToolFinder.getJDKTool("java");
 
         ArrayList<String> args = new ArrayList<>();
         args.add(javapath);
         Collections.addAll(args, getPlatformSpecificVMArgs());
+
+        if (addTestVmAndJavaOptions) {
+            // -cp is needed to make sure the same classpath is used whether the test is
+            // run in AgentVM mode or OtherVM mode. It was added to the hotspot version
+            // of this API as part of 8077608. However, for the jdk version it is only
+            // added when addTestVmAndJavaOptions is true in order to minimize
+            // disruption to existing JDK tests, which have yet to be tested with -cp
+            // being added. At some point -cp should always be added to be consistent
+            // with what the hotspot version does.
+            args.add("-cp");
+            args.add(System.getProperty("java.class.path"));
+            Collections.addAll(args, Utils.getTestJavaOpts());
+        }
+
         Collections.addAll(args, command);
 
         // Reporting
diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java b/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java
index 67af0cd..c219234 100644
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java
@@ -25,6 +25,9 @@
 
 import static jdk.testlibrary.Asserts.assertTrue;
 
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
 import java.io.IOException;
 import java.net.InetAddress;
 import java.net.ServerSocket;
@@ -241,7 +244,6 @@
      * @throws Exception If multiple matching jvms are found.
      */
     public static int tryFindJvmPid(String key) throws Throwable {
-        ProcessBuilder pb = null;
         OutputAnalyzer output = null;
         try {
             JDKToolLauncher jcmdLauncher = JDKToolLauncher.create("jcmd");
@@ -269,6 +271,25 @@
     }
 
     /**
+     * Returns file content as a list of strings
+     *
+     * @param file File to operate on
+     * @return List of strings
+     * @throws IOException
+     */
+    public static List<String> fileAsList(File file) throws IOException {
+        assertTrue(file.exists() && file.isFile(),
+                file.getAbsolutePath() + " does not exist or not a file");
+        List<String> output = new ArrayList<>();
+        try (BufferedReader reader = new BufferedReader(new FileReader(file.getAbsolutePath()))) {
+            while (reader.ready()) {
+                output.add(reader.readLine().replace(NEW_LINE, ""));
+            }
+        }
+        return output;
+    }
+
+    /**
      * Adjusts the provided timeout value for the TIMEOUT_FACTOR
      * @param tOut the timeout value to be adjusted
      * @return The timeout value adjusted for the value of "test.timeout.factor"
diff --git a/jdk/test/sample/TEST.properties b/jdk/test/sample/TEST.properties
new file mode 100644
index 0000000..8e5f78a
--- /dev/null
+++ b/jdk/test/sample/TEST.properties
@@ -0,0 +1 @@
+external.lib.roots = ../../
diff --git a/jdk/test/sample/chatserver/ChatTest.java b/jdk/test/sample/chatserver/ChatTest.java
index 05d6f44..9cb2daa 100644
--- a/jdk/test/sample/chatserver/ChatTest.java
+++ b/jdk/test/sample/chatserver/ChatTest.java
@@ -25,9 +25,9 @@
 /* @test
  * @summary Test chat server chatserver test
  *
- * @library ../../../src/share/sample/nio/chatserver
+ * @library /src/share/sample/nio/chatserver
  * @build ChatTest ChatServer Client ClientReader DataReader MessageReader NameReader
- * @run main ChatTest
+ * @run testng ChatTest
  */
 
 import java.io.*;
@@ -38,10 +38,13 @@
 import java.util.List;
 import java.util.concurrent.CyclicBarrier;
 
+import org.testng.annotations.Test;
+
 public class ChatTest {
     public static int listeningPort = 0;
 
-    public static void main(String[] args) throws Throwable {
+    @Test
+    public static void doTest() throws Throwable {
         testStartStop();
         testPortOpen();
         testAsksForName();
diff --git a/jdk/test/sample/mergesort/MergeSortTest.java b/jdk/test/sample/mergesort/MergeSortTest.java
index 001e4f0..53b5252 100644
--- a/jdk/test/sample/mergesort/MergeSortTest.java
+++ b/jdk/test/sample/mergesort/MergeSortTest.java
@@ -25,14 +25,16 @@
 /* @test
  * @summary Test MergeSort
  *
- * @library ../../../src/share/sample/forkjoin/mergesort
+ * @library /src/share/sample/forkjoin/mergesort
  * @build MergeSortTest MergeDemo MergeSort
- * @run main MergeSortTest
+ * @run testng MergeSortTest
  */
 
 import java.util.Arrays;
 import java.util.Random;
 
+import org.testng.annotations.Test;
+
 public class MergeSortTest {
     private Random random;
     private MergeSort target;
@@ -42,7 +44,8 @@
         this.target = target;
     }
 
-    public static void main(String[] args) {
+    @Test
+    public static void doTest() {
         MergeSortTest test = new MergeSortTest(new Random(), new MergeSort(Runtime.getRuntime().availableProcessors() * 4));
         test.run();
     }
diff --git a/jdk/test/sun/awt/datatransfer/DataFlavorComparatorTest1.java b/jdk/test/sun/awt/datatransfer/DataFlavorComparatorTest1.java
index cc926c8..d9af913 100644
--- a/jdk/test/sun/awt/datatransfer/DataFlavorComparatorTest1.java
+++ b/jdk/test/sun/awt/datatransfer/DataFlavorComparatorTest1.java
@@ -37,42 +37,61 @@
 
     public static void main(String[] args) throws Exception {
         String[] mimes = new String[] {
+                "text/plain;class=java.nio.ByteBuffer;charset=UTF-8",
+                "text/uri-list;class=java.nio.ByteBuffer;charset=UTF-8",
+                "text/plain;class=java.nio.ByteBuffer;charset=UTF-16LE",
+                "text/uri-list;class=java.nio.ByteBuffer;charset=UTF-16LE",
+                "application/x-java-text-encoding",
+                "application/x-java-serialized-object;class=java.lang.String",
+                "text/plain;class=java.io.InputStream;charset=UTF-8",
+                "text/uri-list;class=java.io.InputStream;charset=UTF-8",
+                "text/plain;class=java.io.InputStream;charset=windows-1252",
+                "text/uri-list;class=java.io.InputStream;charset=windows-1252",
+                "application/x-java-url;class=java.net.URL",
+                "text/plain;class=java.io.Reader",
+                "text/plain;charset=windows-1252",
+                "text/uri-list;class=java.io.Reader",
+                "text/uri-list;charset=windows-1252",
+                "text/plain;charset=UTF-8",
+                "text/uri-list;charset=UTF-8",
+                "text/plain;class=java.io.InputStream;charset=US-ASCII",
+                "text/uri-list;class=java.io.InputStream;charset=US-ASCII",
+                "text/plain;class=java.io.InputStream;charset=UTF-16LE",
+                "text/plain;charset=US-ASCII",
+                "text/uri-list;class=java.io.InputStream;charset=UTF-16LE",
+                "text/uri-list;charset=US-ASCII",
+                "text/plain;charset=UTF-16LE",
+                "text/uri-list;charset=UTF-16LE",
+                "text/plain;class=java.nio.ByteBuffer;charset=UTF-16BE",
+                "text/uri-list;class=java.nio.ByteBuffer;charset=UTF-16BE",
+                "text/plain;class=java.nio.ByteBuffer;charset=ISO-8859-1",
+                "text/uri-list;class=java.nio.ByteBuffer;charset=ISO-8859-1",
                 "text/plain",
-                "text/plain; charset=unicode",
-                "text/plain; charset=cp1251",
-                "text/plain; charset=unicode; class=java.io.InputStream",
-                "text/plain; charset=unicode; class=java.io.Serializable",
-                "text/plain; charset=unicode; class=java.lang.Object",
-                "text/plain; class=java.lang.String",
-                "text/plain; class=java.io.Reader",
-                "text/plain; class=java.lang.Object",
-                "text/html",
-                "text/html; charset=unicode",
-                "text/html; charset=cp1251",
-                "text/html; charset=unicode; class=java.io.InputStream",
-                "text/html; charset=unicode; class=java.io.Serializable",
-                "text/html; charset=unicode; class=java.lang.Object",
-                "text/html; class=java.lang.String",
-                "text/html; class=java.io.Reader",
-                "text/html; class=java.lang.Object",
-                "text/unknown",
-                "text/unknown; charset=unicode",
-                "text/unknown; charset=cp1251",
-                "text/unknown; charset=unicode; class=java.io.InputStream",
-                "text/unknown; charset=unicode; class=java.io.Serializable",
-                "text/unknown; charset=unicode; class=java.lang.Object",
-                "text/unknown; class=java.lang.String",
-                "text/unknown; class=java.io.Reader",
-                "text/unknown; class=java.lang.Object",
-                "application/unknown; class=java.io.InputStream",
-                "application/unknown; class=java.lang.Object",
-                "application/unknown",
-                "application/x-java-jvm-local-objectref; class=java.io.InputStream",
-                "application/x-java-jvm-local-objectref; class=java.lang.Object",
-                "application/x-java-jvm-local-objectref",
-                "unknown/flavor",
-                "unknown/flavor; class=java.io.InputStream",
-                "unknown/flavor; class=java.lang.Object",
+                "text/uri-list",
+                "text/plain;class=java.nio.ByteBuffer;charset=UTF-16",
+                "text/uri-list;class=java.nio.ByteBuffer;charset=UTF-16",
+                "text/plain;class=java.io.InputStream;charset=unicode",
+                "text/uri-list;class=java.io.InputStream;charset=UTF-16",
+                "text/plain;class=java.nio.CharBuffer",
+                "text/uri-list;class=java.nio.CharBuffer",
+                "text/plain;class=java.lang.String",
+                "text/plain;charset=UTF-16BE",
+                "text/uri-list;class=java.lang.String",
+                "text/uri-list;charset=UTF-16BE",
+                "text/plain;charset=ISO-8859-1",
+                "text/uri-list;charset=ISO-8859-1",
+                "text/plain;class=java.io.InputStream;charset=UTF-16BE",
+                "text/uri-list;class=java.io.InputStream;charset=UTF-16BE",
+                "text/plain;class=java.nio.ByteBuffer;charset=US-ASCII",
+                "text/uri-list;class=java.nio.ByteBuffer;charset=US-ASCII",
+                "text/plain;class=java.io.InputStream;charset=ISO-8859-1",
+                "text/uri-list;class=java.io.InputStream;charset=ISO-8859-1",
+                "text/plain;charset=UTF-16",
+                "text/plain;class=java.nio.ByteBuffer;charset=windows-1252",
+                "text/uri-list;charset=UTF-16",
+                "text/uri-list;class=java.nio.ByteBuffer;charset=windows-1252",
+                "text/plain;class=java.io.InputStream;charset=windows-1252",
+                "text/uri-list;class=java.io.InputStream;charset=windows-1252",
         };
 
         DataFlavor[] flavors = new DataFlavor[mimes.length];
diff --git a/jdk/test/sun/management/jmxremote/bootstrap/JMXAgentInterfaceBinding.java b/jdk/test/sun/management/jmxremote/bootstrap/JMXAgentInterfaceBinding.java
new file mode 100644
index 0000000..4647f28
--- /dev/null
+++ b/jdk/test/sun/management/jmxremote/bootstrap/JMXAgentInterfaceBinding.java
@@ -0,0 +1,306 @@
+/*
+ * Copyright (c) 2015, Red Hat Inc
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.MalformedURLException;
+import java.net.Socket;
+import java.net.SocketAddress;
+import java.net.UnknownHostException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
+import javax.management.remote.rmi.RMIConnectorServer;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.SSLSocketFactory;
+import javax.rmi.ssl.SslRMIClientSocketFactory;
+
+/**
+ * Tests client connections to the JDK's built-in JMX agent server on the given
+ * ports/interface combinations.
+ *
+ * @see JMXInterfaceBindingTest
+ *
+ * @author Severin Gehwolf <sgehwolf@redhat.com>
+ *
+ * Usage:
+ *
+ * SSL:
+ *        java -Dcom.sun.management.jmxremote.ssl.need.client.auth=true \
+ *             -Dcom.sun.management.jmxremote.host=127.0.0.1 \
+ *             -Dcom.sun.management.jmxremote.port=9111 \
+ *             -Dcom.sun.management.jmxremote.rmi.port=9112 \
+ *             -Dcom.sun.management.jmxremote.authenticate=false \
+ *             -Dcom.sun.management.jmxremote.ssl=true \
+ *             -Dcom.sun.management.jmxremote.registry.ssl=true
+ *             -Djavax.net.ssl.keyStore=... \
+ *             -Djavax.net.ssl.keyStorePassword=... \
+ *             JMXAgentInterfaceBinding 127.0.0.1 9111 9112 true
+ *
+ * Non-SSL:
+ *        java -Dcom.sun.management.jmxremote.host=127.0.0.1 \
+ *             -Dcom.sun.management.jmxremote.port=9111 \
+ *             -Dcom.sun.management.jmxremote.rmi.port=9112 \
+ *             -Dcom.sun.management.jmxremote.authenticate=false \
+ *             -Dcom.sun.management.jmxremote.ssl=false \
+ *             JMXAgentInterfaceBinding 127.0.0.1 9111 9112 false
+ *
+ */
+public class JMXAgentInterfaceBinding {
+
+    private final MainThread mainThread;
+
+    public JMXAgentInterfaceBinding(InetAddress bindAddress,
+                                   int jmxPort,
+                                   int rmiPort,
+                                   boolean useSSL) {
+        this.mainThread = new MainThread(bindAddress, jmxPort, rmiPort, useSSL);
+    }
+
+    public void startEndpoint() {
+        mainThread.start();
+        try {
+            mainThread.join();
+        } catch (InterruptedException e) {
+            throw new RuntimeException("Test failed", e);
+        }
+        if (mainThread.isFailed()) {
+            mainThread.rethrowException();
+        }
+    }
+
+    public static void main(String[] args) {
+        if (args.length != 4) {
+            throw new RuntimeException(
+                    "Test failed. usage: java JMXInterfaceBindingTest <BIND_ADDRESS> <JMX_PORT> <RMI_PORT> {true|false}");
+        }
+        int jmxPort = parsePortFromString(args[1]);
+        int rmiPort = parsePortFromString(args[2]);
+        boolean useSSL = Boolean.parseBoolean(args[3]);
+        String strBindAddr = args[0];
+        System.out.println(
+                "DEBUG: Running test for triplet (hostname,jmxPort,rmiPort) = ("
+                        + strBindAddr + "," + jmxPort + "," + rmiPort + "), useSSL = " + useSSL);
+        InetAddress bindAddress;
+        try {
+            bindAddress = InetAddress.getByName(args[0]);
+        } catch (UnknownHostException e) {
+            throw new RuntimeException("Test failed. Unknown ip: " + args[0]);
+        }
+        JMXAgentInterfaceBinding test = new JMXAgentInterfaceBinding(bindAddress,
+                jmxPort, rmiPort, useSSL);
+        test.startEndpoint(); // Expect for main test to terminate process
+    }
+
+    private static int parsePortFromString(String port) {
+        try {
+            return Integer.parseInt(port);
+        } catch (NumberFormatException e) {
+            throw new RuntimeException(
+                    "Invalid port specified. Not an integer! Value was: "
+                            + port);
+        }
+    }
+
+    private static class JMXConnectorThread extends Thread {
+
+        private final String addr;
+        private final int jmxPort;
+        private final int rmiPort;
+        private final boolean useSSL;
+        private final CountDownLatch latch;
+        private boolean failed;
+        private boolean jmxConnectWorked;
+        private boolean rmiConnectWorked;
+
+        private JMXConnectorThread(String addr,
+                                   int jmxPort,
+                                   int rmiPort,
+                                   boolean useSSL,
+                                   CountDownLatch latch) {
+            this.addr = addr;
+            this.jmxPort = jmxPort;
+            this.rmiPort = rmiPort;
+            this.latch = latch;
+            this.useSSL = useSSL;
+        }
+
+        @Override
+        public void run() {
+            try {
+                connect();
+            } catch (IOException e) {
+                failed = true;
+            }
+        }
+
+        private void connect() throws IOException {
+            System.out.println(
+                    "JMXConnectorThread: Attempting JMX connection on: "
+                            + addr + " on port " + jmxPort);
+            JMXServiceURL url;
+            try {
+                url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://"
+                        + addr + ":" + jmxPort + "/jmxrmi");
+            } catch (MalformedURLException e) {
+                throw new RuntimeException("Test failed.", e);
+            }
+            Map<String, Object> env = new HashMap<>();
+            if (useSSL) {
+                SslRMIClientSocketFactory csf = new SslRMIClientSocketFactory();
+                env.put("com.sun.jndi.rmi.factory.socket", csf);
+                env.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, csf);
+            }
+            // connect and immediately close
+            JMXConnector c = JMXConnectorFactory.connect(url, env);
+            c.close();
+            System.out.println("JMXConnectorThread: connection to JMX worked");
+            jmxConnectWorked = true;
+            checkRmiSocket();
+            latch.countDown(); // signal we are done.
+        }
+
+        private void checkRmiSocket() throws IOException {
+            Socket rmiConnection;
+            if (useSSL) {
+                rmiConnection = SSLSocketFactory.getDefault().createSocket();
+            } else {
+                rmiConnection = new Socket();
+            }
+            SocketAddress target = new InetSocketAddress(addr, rmiPort);
+            rmiConnection.connect(target);
+            if (useSSL) {
+                ((SSLSocket)rmiConnection).startHandshake();
+            }
+            System.out.println(
+                    "JMXConnectorThread: connection to rmi socket worked host/port = "
+                            + addr + "/" + rmiPort);
+            rmiConnectWorked = true;
+            // Closing the channel without sending any data will cause an
+            // java.io.EOFException on the server endpoint. We don't care about this
+            // though, since we only want to test if we can connect.
+            rmiConnection.close();
+        }
+
+        public boolean isFailed() {
+            return failed;
+        }
+
+        public boolean jmxConnectionWorked() {
+            return jmxConnectWorked;
+        }
+
+        public boolean rmiConnectionWorked() {
+            return rmiConnectWorked;
+        }
+    }
+
+    private static class MainThread extends Thread {
+
+        private static final int WAIT_FOR_JMX_AGENT_TIMEOUT_MS = 500;
+        private final String addr;
+        private final int jmxPort;
+        private final int rmiPort;
+        private final boolean useSSL;
+        private boolean terminated = false;
+        private boolean jmxAgentStarted = false;
+        private Exception excptn;
+
+        private MainThread(InetAddress bindAddress, int jmxPort, int rmiPort, boolean useSSL) {
+            this.addr = wrapAddress(bindAddress.getHostAddress());
+            this.jmxPort = jmxPort;
+            this.rmiPort = rmiPort;
+            this.useSSL = useSSL;
+        }
+
+        @Override
+        public void run() {
+            try {
+                waitUntilReadyForConnections();
+                // Do nothing, but wait for termination.
+                try {
+                    while (!terminated) {
+                        Thread.sleep(100);
+                    }
+                } catch (InterruptedException e) { // ignore
+                }
+                System.out.println("MainThread: Thread stopped.");
+            } catch (Exception e) {
+                this.excptn = e;
+            }
+        }
+
+        private void waitUntilReadyForConnections() {
+            CountDownLatch latch = new CountDownLatch(1);
+            JMXConnectorThread connectionTester = new JMXConnectorThread(
+                    addr, jmxPort, rmiPort, useSSL, latch);
+            connectionTester.start();
+            boolean expired = false;
+            try {
+                expired = !latch.await(WAIT_FOR_JMX_AGENT_TIMEOUT_MS, TimeUnit.MILLISECONDS);
+                System.out.println(
+                        "MainThread: Finished waiting for JMX agent to become available: expired == "
+                                + expired);
+                jmxAgentStarted = !expired;
+            } catch (InterruptedException e) {
+                throw new RuntimeException("Test failed", e);
+            }
+            if (!jmxAgentStarted) {
+                throw new RuntimeException(
+                        "Test failed. JMX server agents not becoming available.");
+            }
+            if (connectionTester.isFailed()
+                    || !connectionTester.jmxConnectionWorked()
+                    || !connectionTester.rmiConnectionWorked()) {
+                throw new RuntimeException(
+                        "Test failed. JMX agent does not seem ready. See log output for details.");
+            }
+            // The main test expects this exact message being printed
+            System.out.println("MainThread: Ready for connections");
+        }
+
+        private boolean isFailed() {
+            return excptn != null;
+        }
+
+        private void rethrowException() throws RuntimeException {
+            throw new RuntimeException(excptn);
+        }
+    }
+
+    /**
+     * Will wrap IPv6 address in '[]'
+     */
+    static String wrapAddress(String address) {
+        if (address.contains(":")) {
+            return "[" + address + "]";
+        }
+        return address;
+    }
+}
diff --git a/jdk/test/sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java b/jdk/test/sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java
new file mode 100644
index 0000000..4a48278
--- /dev/null
+++ b/jdk/test/sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java
@@ -0,0 +1,259 @@
+/*
+ * Copyright (c) 2015, Red Hat Inc
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.File;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Predicate;
+
+import jdk.testlibrary.ProcessTools;
+
+/**
+ * NOTE:
+ *    This test requires at least a setup similar to the following in
+ *    /etc/hosts file (or the windows equivalent). I.e. it expects it to
+ *    be multi-homed and not both being the loop-back interface.
+ *    For example:
+ *    ----->8-------- /etc/hosts ----------->8---
+ *    127.0.0.1   localhost
+ *    192.168.0.1 localhost
+ *    ----->8-------- /etc/hosts ----------->8---
+ *
+ * @test
+ * @bug     6425769
+ * @summary Test JMX agent host address binding. Same ports but different
+ *          interfaces to bind to (using plain sockets and SSL sockets).
+ *
+ * @modules java.management/sun.management
+ *          java.management/sun.management.jmxremote
+ * @library /lib/testlibrary
+ * @build jdk.testlibrary.* JMXAgentInterfaceBinding
+ * @run main/timeout=5 JMXInterfaceBindingTest
+ */
+public class JMXInterfaceBindingTest {
+
+    public static final int COMMUNICATION_ERROR_EXIT_VAL = 1;
+    public static final int STOP_PROCESS_EXIT_VAL = 137;
+    public static final int JMX_PORT = 9111;
+    public static final int RMI_PORT = 9112;
+    public static final String READY_MSG = "MainThread: Ready for connections";
+    public static final String TEST_CLASS = JMXAgentInterfaceBinding.class.getSimpleName();
+    public static final String KEYSTORE_LOC = System.getProperty("test.src", ".") +
+                                              File.separator +
+                                              "ssl" +
+                                              File.separator +
+                                              "keystore";
+    public static final String TRUSTSTORE_LOC = System.getProperty("test.src", ".") +
+                                                File.separator +
+                                                "ssl" +
+                                                File.separator +
+                                                "truststore";
+    public static final String TEST_CLASSPATH = System.getProperty("test.classes", ".");
+
+    public void run(List<InetAddress> addrs) {
+        System.out.println("DEBUG: Running tests with plain sockets.");
+        runTests(addrs, false);
+        System.out.println("DEBUG: Running tests with SSL sockets.");
+        runTests(addrs, true);
+    }
+
+    private void runTests(List<InetAddress> addrs, boolean useSSL) {
+        TestProcessThread[] jvms = new TestProcessThread[addrs.size()];
+        for (int i = 0; i < addrs.size(); i++) {
+            String addr = JMXAgentInterfaceBinding.wrapAddress(addrs.get(i).getHostAddress());
+            System.out.println();
+            String msg = String.format("DEBUG: Launching java tester for triplet (HOSTNAME,JMX_PORT,RMI_PORT) == (%s,%d,%d)",
+                    addr,
+                    JMX_PORT,
+                    RMI_PORT);
+            System.out.println(msg);
+            jvms[i] = runJMXBindingTest(addr, useSSL);
+            jvms[i].start();
+            System.out.println("DEBUG: Started " + (i + 1) + " Process(es).");
+        }
+        int failedProcesses = 0;
+        for (TestProcessThread pt: jvms) {
+            try {
+                pt.stopProcess();
+                pt.join();
+            } catch (InterruptedException e) {
+                System.err.println("Failed to stop process: " + pt.getName());
+                throw new RuntimeException("Test failed", e);
+            }
+            int exitValue = pt.getExitValue();
+            // If there is a communication error (the case we care about)
+            // we get a exit code of 1
+            if (exitValue == COMMUNICATION_ERROR_EXIT_VAL) {
+                // Failure case since the java processes should still be
+                // running.
+                System.err.println("Test FAILURE on " + pt.getName());
+                failedProcesses++;
+            } else if (exitValue == STOP_PROCESS_EXIT_VAL) {
+                System.out.println("DEBUG: OK. Spawned java process terminated with expected exit code of " + STOP_PROCESS_EXIT_VAL);
+            } else {
+                System.err.println("Test FAILURE on " + pt.getName() + " reason: Unexpected exit code => " + exitValue);
+                failedProcesses++;
+            }
+        }
+        if (failedProcesses > 0) {
+            throw new RuntimeException("Test FAILED. " + failedProcesses + " out of " + addrs.size() + " process(es) failed to start the JMX agent.");
+        }
+    }
+
+    private TestProcessThread runJMXBindingTest(String address, boolean useSSL) {
+        List<String> args = new ArrayList<>();
+        args.add("-classpath");
+        args.add(TEST_CLASSPATH);
+        args.add("-Dcom.sun.management.jmxremote.host=" + address);
+        args.add("-Dcom.sun.management.jmxremote.port=" + JMX_PORT);
+        args.add("-Dcom.sun.management.jmxremote.rmi.port=" + RMI_PORT);
+        args.add("-Dcom.sun.management.jmxremote.authenticate=false");
+        args.add("-Dcom.sun.management.jmxremote.ssl=" + Boolean.toString(useSSL));
+        if (useSSL) {
+            args.add("-Dcom.sun.management.jmxremote.registry.ssl=true");
+            args.add("-Djavax.net.ssl.keyStore=" + KEYSTORE_LOC);
+            args.add("-Djavax.net.ssl.trustStore=" + TRUSTSTORE_LOC);
+            args.add("-Djavax.net.ssl.keyStorePassword=password");
+            args.add("-Djavax.net.ssl.trustStorePassword=trustword");
+        }
+        args.add(TEST_CLASS);
+        args.add(address);
+        args.add(Integer.toString(JMX_PORT));
+        args.add(Integer.toString(RMI_PORT));
+        args.add(Boolean.toString(useSSL));
+        try {
+            ProcessBuilder builder = ProcessTools.createJavaProcessBuilder(args.toArray(new String[] {}));
+            System.out.println(ProcessTools.getCommandLine(builder));
+            TestProcessThread jvm = new TestProcessThread("JMX-Tester-" + address, JMXInterfaceBindingTest::isJMXAgentResponseAvailable, builder);
+            return jvm;
+        } catch (Exception e) {
+            throw new RuntimeException("Test failed", e);
+        }
+
+    }
+
+    private static boolean isJMXAgentResponseAvailable(String line) {
+        if (line.equals(READY_MSG)) {
+            System.out.println("DEBUG: Found expected READY_MSG.");
+            return true;
+        } else if (line.startsWith("Error:")) {
+            // Allow for a JVM process that exits with
+            // "Error: JMX connector server communication error: ..."
+            // to continue as well since we handle that case elsewhere.
+            // This has the effect that the test does not timeout and
+            // fails with an exception in the test.
+            System.err.println("PROBLEM: JMX agent of target JVM did not start as it should.");
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public static void main(String[] args) {
+        List<InetAddress> addrs = getAddressesForLocalHost();
+        if (addrs.size() < 2) {
+            System.out.println("Ignoring manual test since no more than one IPs are configured for 'localhost'");
+            return;
+        }
+        JMXInterfaceBindingTest test = new JMXInterfaceBindingTest();
+        test.run(addrs);
+        System.out.println("All tests PASSED.");
+    }
+
+    private static List<InetAddress> getAddressesForLocalHost() {
+        try {
+            List<InetAddress> filtered = new ArrayList<>();
+            for (NetworkInterface iface: Collections.list(NetworkInterface.getNetworkInterfaces())) {
+                for (InetAddress addr: Collections.list(iface.getInetAddresses())) {
+                    if (isNonloopbackLocalhost(addr)) {
+                        filtered.add(addr);
+                    }
+                }
+            }
+            return filtered;
+        } catch (SocketException e) {
+            throw new RuntimeException("Test failed", e);
+        }
+    }
+
+    // we need 'real' localhost addresses only (eg. not loopback ones)
+    // so we can bind the remote JMX connector to them
+    private static boolean isNonloopbackLocalhost(InetAddress i) {
+        if (!i.isLoopbackAddress()) {
+            return i.getHostName().toLowerCase().equals("localhost");
+        }
+        return false;
+    }
+
+    private static class TestProcessThread extends Thread {
+
+        private final Predicate<String> predicate;
+        private final ProcessBuilder pb;
+        private final CountDownLatch latch;
+        private Process process;
+
+        public TestProcessThread(String threadName, Predicate<String> predicate, ProcessBuilder pb) {
+            super(threadName);
+            this.predicate = predicate;
+            this.pb = pb;
+            this.latch = new CountDownLatch(1);
+        }
+
+        @Override
+        public void run() {
+            try {
+                process = ProcessTools.startProcess(getName(), pb, predicate, 10, TimeUnit.SECONDS);
+                latch.countDown();
+                process.waitFor();
+            } catch (Exception e) {
+                throw new RuntimeException("Test failed", e);
+            }
+        }
+
+        public void stopProcess() {
+            try {
+                latch.await();
+            } catch (InterruptedException e1) {
+                throw new RuntimeException("Test failed", e1);
+            }
+            if (process != null) {
+                process.destroyForcibly();
+                try {
+                    process.waitFor();
+                } catch (InterruptedException e) {
+                    throw new RuntimeException("Test failed", e);
+                }
+            }
+        }
+
+        public int getExitValue() {
+            return process.exitValue();
+        }
+    }
+}
diff --git a/jdk/test/sun/nio/ch/TestMaxCachedBufferSize.java b/jdk/test/sun/nio/ch/TestMaxCachedBufferSize.java
new file mode 100644
index 0000000..8c8049b
--- /dev/null
+++ b/jdk/test/sun/nio/ch/TestMaxCachedBufferSize.java
@@ -0,0 +1,252 @@
+/*
+ * 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.lang.management.BufferPoolMXBean;
+import java.lang.management.ManagementFactory;
+
+import java.nio.ByteBuffer;
+
+import java.nio.channels.FileChannel;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import static java.nio.file.StandardOpenOption.CREATE;
+import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING;
+import static java.nio.file.StandardOpenOption.WRITE;
+
+import java.util.List;
+import java.util.Random;
+
+/*
+ * @test
+ * @requires sun.arch.data.model == "64"
+ * @build TestMaxCachedBufferSize
+ * @run main/othervm TestMaxCachedBufferSize
+ * @run main/othervm -Djdk.nio.maxCachedBufferSize=0 TestMaxCachedBufferSize
+ * @run main/othervm -Djdk.nio.maxCachedBufferSize=2000 TestMaxCachedBufferSize
+ * @run main/othervm -Djdk.nio.maxCachedBufferSize=100000 TestMaxCachedBufferSize
+ * @run main/othervm -Djdk.nio.maxCachedBufferSize=10000000 TestMaxCachedBufferSize
+ * @summary Test the implementation of the jdk.nio.maxCachedBufferSize property.
+ */
+public class TestMaxCachedBufferSize {
+    private static final int DEFAULT_ITERS = 10 * 1000;
+    private static final int DEFAULT_THREAD_NUM = 4;
+
+    private static final int SMALL_BUFFER_MIN_SIZE =  4 * 1024;
+    private static final int SMALL_BUFFER_MAX_SIZE = 64 * 1024;
+    private static final int SMALL_BUFFER_DIFF_SIZE =
+                                 SMALL_BUFFER_MAX_SIZE - SMALL_BUFFER_MIN_SIZE;
+
+    private static final int LARGE_BUFFER_MIN_SIZE =      512 * 1024;
+    private static final int LARGE_BUFFER_MAX_SIZE = 4 * 1024 * 1024;
+    private static final int LARGE_BUFFER_DIFF_SIZE =
+                                 LARGE_BUFFER_MAX_SIZE - LARGE_BUFFER_MIN_SIZE;
+
+    private static final int LARGE_BUFFER_FREQUENCY = 100;
+
+    private static final String FILE_NAME_PREFIX = "nio-out-file-";
+    private static final int VERBOSE_PERIOD = 5 * 1000;
+
+    private static int iters = DEFAULT_ITERS;
+    private static int threadNum = DEFAULT_THREAD_NUM;
+
+    private static BufferPoolMXBean getDirectPool() {
+        final List<BufferPoolMXBean> pools =
+                  ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);
+        for (BufferPoolMXBean pool : pools) {
+            if (pool.getName().equals("direct")) {
+                return pool;
+            }
+        }
+        throw new Error("could not find direct pool");
+    }
+    private static final BufferPoolMXBean directPool = getDirectPool();
+
+    // Each worker will do write operations on a file channel using
+    // buffers of various sizes. The buffer size is randomly chosen to
+    // be within a small or a large range. This way we can control
+    // which buffers can be cached (all, only the small ones, or none)
+    // by setting the jdk.nio.maxCachedBufferSize property.
+    private static class Worker implements Runnable {
+        private final int id;
+        private final Random random = new Random();
+        private long smallBufferCount = 0;
+        private long largeBufferCount = 0;
+
+        private int getWriteSize() {
+            int minSize = 0;
+            int diff = 0;
+            if (random.nextInt() % LARGE_BUFFER_FREQUENCY != 0) {
+                // small buffer
+                minSize = SMALL_BUFFER_MIN_SIZE;
+                diff = SMALL_BUFFER_DIFF_SIZE;
+                smallBufferCount += 1;
+            } else {
+                // large buffer
+                minSize = LARGE_BUFFER_MIN_SIZE;
+                diff = LARGE_BUFFER_DIFF_SIZE;
+                largeBufferCount += 1;
+            }
+            return minSize + random.nextInt(diff);
+        }
+
+        private void loop() {
+            final String fileName = String.format("%s%d", FILE_NAME_PREFIX, id);
+
+            try {
+                for (int i = 0; i < iters; i += 1) {
+                    final int writeSize = getWriteSize();
+
+                    // This will allocate a HeapByteBuffer. It should not
+                    // be a direct buffer, otherwise the write() method on
+                    // the channel below will not create a temporary
+                    // direct buffer for the write.
+                    final ByteBuffer buffer = ByteBuffer.allocate(writeSize);
+
+                    // Put some random data on it.
+                    while (buffer.hasRemaining()) {
+                        buffer.put((byte) random.nextInt());
+                    }
+                    buffer.rewind();
+
+                    final Path file = Paths.get(fileName);
+                    try (FileChannel outChannel = FileChannel.open(file, CREATE, TRUNCATE_EXISTING, WRITE)) {
+                        // The write() method will create a temporary
+                        // direct buffer for the write and attempt to cache
+                        // it. It's important that buffer is not a
+                        // direct buffer, otherwise the temporary buffer
+                        // will not be created.
+                        long res = outChannel.write(buffer);
+                    }
+
+                    if ((i + 1) % VERBOSE_PERIOD == 0) {
+                        System.out.printf(
+                          " Worker %3d | %8d Iters | Small %8d Large %8d | Direct %4d / %7dK\n",
+                          id, i + 1, smallBufferCount, largeBufferCount,
+                          directPool.getCount(), directPool.getTotalCapacity() / 1024);
+                    }
+                }
+            } catch (IOException e) {
+                throw new Error("I/O error", e);
+            }
+        }
+
+        @Override
+        public void run() {
+            loop();
+        }
+
+        public Worker(int id) {
+            this.id = id;
+        }
+    }
+
+    public static void checkDirectBuffers(long expectedCount, long expectedMax) {
+        final long directCount = directPool.getCount();
+        final long directTotalCapacity = directPool.getTotalCapacity();
+        System.out.printf("Direct %d / %dK\n",
+                          directCount, directTotalCapacity / 1024);
+
+        // Note that directCount could be < expectedCount. This can
+        // happen if a GC occurs after one of the worker threads exits
+        // since its thread-local DirectByteBuffer could be cleaned up
+        // before we reach here.
+        if (directCount > expectedCount) {
+            throw new Error(String.format(
+                "inconsistent direct buffer total count, expected = %d, found = %d",
+                expectedCount, directCount));
+        }
+
+        if (directTotalCapacity > expectedMax) {
+            throw new Error(String.format(
+                "inconsistent direct buffer total capacity, expectex max = %d, found = %d",
+                expectedMax, directTotalCapacity));
+        }
+    }
+
+    public static void main(String[] args) {
+        final String maxBufferSizeStr = System.getProperty("jdk.nio.maxCachedBufferSize");
+        final long maxBufferSize =
+            (maxBufferSizeStr != null) ? Long.valueOf(maxBufferSizeStr) : Long.MAX_VALUE;
+
+        // We assume that the max cannot be equal to a size of a
+        // buffer that can be allocated (makes sanity checking at the
+        // end easier).
+        if ((SMALL_BUFFER_MIN_SIZE <= maxBufferSize &&
+                                     maxBufferSize <= SMALL_BUFFER_MAX_SIZE) ||
+            (LARGE_BUFFER_MIN_SIZE <= maxBufferSize &&
+                                     maxBufferSize <= LARGE_BUFFER_MAX_SIZE)) {
+            throw new Error(String.format("max buffer size = %d not allowed",
+                                          maxBufferSize));
+        }
+
+        System.out.printf("Threads %d | Iterations %d | MaxBufferSize %d\n",
+                          threadNum, iters, maxBufferSize);
+        System.out.println();
+
+        final Thread[] threads = new Thread[threadNum];
+        for (int i = 0; i < threadNum; i += 1) {
+            threads[i] = new Thread(new Worker(i));
+            threads[i].start();
+        }
+
+        try {
+            for (int i = 0; i < threadNum; i += 1) {
+                threads[i].join();
+            }
+        } catch (InterruptedException e) {
+            throw new Error("join() interrupted!", e);
+        }
+
+        // There is an assumption here that, at this point, only the
+        // cached DirectByteBuffers should be active. Given we
+        // haven't used any other DirectByteBuffers in this test, this
+        // should hold.
+        //
+        // Also note that we can only do the sanity checking at the
+        // end and not during the run given that, at any time, there
+        // could be buffers currently in use by some of the workers
+        // that will not be cached.
+
+        System.out.println();
+        if (maxBufferSize < SMALL_BUFFER_MAX_SIZE) {
+            // The max buffer size is smaller than all buffers that
+            // were allocated. No buffers should have been cached.
+            checkDirectBuffers(0, 0);
+        } else if (maxBufferSize < LARGE_BUFFER_MIN_SIZE) {
+            // The max buffer size is larger than all small buffers
+            // but smaller than all large buffers that were
+            // allocated. Only small buffers could have been cached.
+            checkDirectBuffers(threadNum,
+                               (long) threadNum * (long) SMALL_BUFFER_MAX_SIZE);
+        } else {
+            // The max buffer size is larger than all buffers that
+            // were allocated. All buffers could have been cached.
+            checkDirectBuffers(threadNum,
+                               (long) threadNum * (long) LARGE_BUFFER_MAX_SIZE);
+        }
+    }
+}
diff --git a/jdk/test/sun/security/TestSignatureOidHelper.java b/jdk/test/sun/security/TestSignatureOidHelper.java
new file mode 100644
index 0000000..be13599
--- /dev/null
+++ b/jdk/test/sun/security/TestSignatureOidHelper.java
@@ -0,0 +1,124 @@
+/*
+ * 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.
+ */
+
+import java.security.InvalidKeyException;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.Signature;
+import java.security.SignatureException;
+import java.util.List;
+
+/*
+ * Utilities for testing the signature algorithm OIDs.
+ */
+public class TestSignatureOidHelper {
+
+    private static final byte[] INPUT = "1234567890".getBytes();
+
+    private final String algorithm;
+
+    private final String provider;
+
+    private final int keySize;
+
+    private final List<OidAlgorithmPair> data;
+
+    public TestSignatureOidHelper(String algorithm, String provider,
+            int keySize, List<OidAlgorithmPair> data) {
+        this.algorithm = algorithm;
+        this.provider = provider;
+        this.keySize = keySize;
+        this.data = data;
+    }
+
+    public void execute() throws Exception {
+        KeyPair keyPair = createKeyPair();
+        for (OidAlgorithmPair oidAlgorithmPair : data) {
+            runTest(oidAlgorithmPair, keyPair);
+            System.out.println("passed");
+        }
+        System.out.println("All tests passed");
+    }
+
+    private KeyPair createKeyPair()
+            throws NoSuchAlgorithmException, NoSuchProviderException {
+        KeyPairGenerator keyGen = KeyPairGenerator.getInstance(algorithm,
+                provider);
+        keyGen.initialize(keySize);
+        return keyGen.generateKeyPair();
+    }
+
+    private void runTest(OidAlgorithmPair oidAlgorithmPair, KeyPair keyPair)
+            throws NoSuchAlgorithmException, NoSuchProviderException,
+            InvalidKeyException, SignatureException {
+        Signature sgAlgorithm =
+                Signature.getInstance(oidAlgorithmPair.algorithm, provider);
+        Signature sgOid = Signature.getInstance(oidAlgorithmPair.oid, provider);
+
+        if (sgAlgorithm == null) {
+            throw new RuntimeException(String.format(
+                    "Test failed: algorithm string %s getInstance failed.%n",
+                    oidAlgorithmPair.algorithm));
+        }
+
+        if (sgOid == null) {
+            throw new RuntimeException(
+                    String.format("Test failed: OID %s getInstance failed.%n",
+                            oidAlgorithmPair.oid));
+        }
+
+        if (!sgAlgorithm.getAlgorithm().equals(oidAlgorithmPair.algorithm)) {
+            throw new RuntimeException(String.format(
+                    "Test failed: algorithm string %s getInstance "
+                            + "doesn't generate expected algorithm.%n",
+                    oidAlgorithmPair.algorithm));
+        }
+
+        sgAlgorithm.initSign(keyPair.getPrivate());
+        sgAlgorithm.update(INPUT);
+        sgOid.initVerify(keyPair.getPublic());
+        sgOid.update(INPUT);
+        if (!sgOid.verify(sgAlgorithm.sign())) {
+            throw new RuntimeException(
+                    "Signature verification failed unexpectedly");
+        }
+    }
+}
+
+class OidAlgorithmPair {
+
+    public final String oid;
+    public final String algorithm;
+
+    public OidAlgorithmPair(String oid, String algorithm) {
+        this.oid = oid;
+        this.algorithm = algorithm;
+    }
+
+    @Override
+    public String toString() {
+        return "[oid=" + oid + ", algorithm=" + algorithm + "]";
+    }
+}
diff --git a/jdk/test/sun/security/ec/NSASuiteB/TestSHAwithECDSASignatureOids.java b/jdk/test/sun/security/ec/NSASuiteB/TestSHAwithECDSASignatureOids.java
new file mode 100644
index 0000000..58a8106
--- /dev/null
+++ b/jdk/test/sun/security/ec/NSASuiteB/TestSHAwithECDSASignatureOids.java
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+import java.util.Arrays;
+import java.util.List;
+
+/*
+ * @test
+ * @bug 8075286
+ * @summary Test the SHAwithECDSA signature algorithm OIDs in JDK.
+ *          OID and algorithm transformation string should match.
+ *          Both could be able to be used to generate the algorithm instance.
+ * @compile ../../TestSignatureOidHelper.java
+ * @run main TestSHAwithECDSASignatureOids
+ */
+public class TestSHAwithECDSASignatureOids {
+
+    private static final List<OidAlgorithmPair> DATA = Arrays.asList(
+            new OidAlgorithmPair("1.2.840.10045.4.1", "SHA1withECDSA"),
+            new OidAlgorithmPair("1.2.840.10045.4.3.1", "SHA224withECDSA"),
+            new OidAlgorithmPair("1.2.840.10045.4.3.2", "SHA256withECDSA"),
+            new OidAlgorithmPair("1.2.840.10045.4.3.3", "SHA384withECDSA"),
+            new OidAlgorithmPair("1.2.840.10045.4.3.4", "SHA512withECDSA"));
+
+    public static void main(String[] args) throws Exception {
+        TestSignatureOidHelper helper = new TestSignatureOidHelper("EC",
+                "SunEC", 256, DATA);
+        helper.execute();
+    }
+}
diff --git a/jdk/test/sun/security/ec/SignatureOffsets.java b/jdk/test/sun/security/ec/SignatureOffsets.java
new file mode 100644
index 0000000..948923e
--- /dev/null
+++ b/jdk/test/sun/security/ec/SignatureOffsets.java
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.SignatureException;
+
+/*
+ * @test
+ * @bug 8050374
+ * @key randomness
+ * @summary This test validates signature verification
+ *          Signature.verify(byte[], int, int). The test uses RandomFactory to
+ *          get random set of clear text data to sign. After the signature
+ *          generation, the test tries to verify signature with the above API
+ *          and passing in different signature offset (0, 33, 66, 99).
+ * @library /lib/testlibrary
+ * @compile ../../../java/security/Signature/Offsets.java
+ * @run main SignatureOffsets SunEC NONEwithECDSA
+ * @run main SignatureOffsets SunEC SHA1withECDSA
+ * @run main SignatureOffsets SunEC SHA256withECDSA
+ * @run main SignatureOffsets SunEC SHA224withECDSA
+ * @run main SignatureOffsets SunEC SHA384withECDSA
+ * @run main SignatureOffsets SunEC SHA512withECDSA
+ */
+public class SignatureOffsets {
+
+    public static void main(String[] args) throws NoSuchAlgorithmException,
+            InvalidKeyException, SignatureException {
+        Offsets.main(args);
+    }
+}
\ No newline at end of file
diff --git a/jdk/test/sun/security/ec/SignedObjectChain.java b/jdk/test/sun/security/ec/SignedObjectChain.java
new file mode 100644
index 0000000..6e93053
--- /dev/null
+++ b/jdk/test/sun/security/ec/SignedObjectChain.java
@@ -0,0 +1,57 @@
+/*
+ * 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 8050374
+ * @compile ../../../java/security/SignedObject/Chain.java
+ * @summary Verify a chain of signed objects
+ */
+public class SignedObjectChain {
+
+    private static class Test extends Chain.Test {
+
+        public Test(Chain.SigAlg sigAlg) {
+            super(sigAlg, Chain.KeyAlg.EC, Chain.Provider.SunEC);
+        }
+    }
+
+    private static final Test[] tests = {
+        new Test(Chain.SigAlg.SHA1withECDSA),
+        new Test(Chain.SigAlg.SHA256withECDSA),
+        new Test(Chain.SigAlg.SHA224withECDSA),
+        new Test(Chain.SigAlg.SHA384withECDSA),
+        new Test(Chain.SigAlg.SHA512withECDSA),
+    };
+
+    public static void main(String argv[]) {
+        boolean resutl = java.util.Arrays.stream(tests).allMatch(
+                (test) -> Chain.runTest(test));
+
+        if(resutl) {
+            System.out.println("All tests passed");
+        } else {
+            throw new RuntimeException("Some tests failed");
+        }
+    }
+}
diff --git a/jdk/test/sun/security/mscapi/SignatureOffsets.java b/jdk/test/sun/security/mscapi/SignatureOffsets.java
new file mode 100644
index 0000000..34f91fbf
--- /dev/null
+++ b/jdk/test/sun/security/mscapi/SignatureOffsets.java
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.SignatureException;
+
+/*
+ * @test
+ * @bug 8050374
+ * @key randomness
+ * @summary This test validates signature verification
+ *          Signature.verify(byte[], int, int). The test uses RandomFactory to
+ *          get random set of clear text data to sign. After the signature
+ *          generation, the test tries to verify signature with the above API
+ *          and passing in different signature offset (0, 33, 66, 99).
+ * @library /lib/testlibrary
+ * @compile ../../../java/security/Signature/Offsets.java
+ * @run main SignatureOffsets SunMSCAPI NONEwithRSA
+ * @run main SignatureOffsets SunMSCAPI MD2withRSA
+ * @run main SignatureOffsets SunMSCAPI MD5withRSA
+ * @run main SignatureOffsets SunMSCAPI SHA1withRSA
+ * @run main SignatureOffsets SunMSCAPI SHA256withRSA
+ * @run main SignatureOffsets SunMSCAPI SHA384withRSA
+ * @run main SignatureOffsets SunMSCAPI SHA512withRSA
+ */
+public class SignatureOffsets {
+
+    public static void main(String[] args) throws NoSuchAlgorithmException,
+            InvalidKeyException, SignatureException {
+        Offsets.main(args);
+    }
+}
\ No newline at end of file
diff --git a/jdk/test/sun/security/mscapi/SignedObjectChain.java b/jdk/test/sun/security/mscapi/SignedObjectChain.java
new file mode 100644
index 0000000..9790daa
--- /dev/null
+++ b/jdk/test/sun/security/mscapi/SignedObjectChain.java
@@ -0,0 +1,58 @@
+/*
+ * 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 8050374
+ * @compile ../../../java/security/SignedObject/Chain.java
+ * @summary Verify a chain of signed objects
+ */
+public class SignedObjectChain {
+
+    private static class Test extends Chain.Test {
+
+        public Test(Chain.SigAlg sigAlg) {
+            super(sigAlg, Chain.KeyAlg.RSA, Chain.Provider.SunMSCAPI);
+        }
+    }
+
+    private static final Test[] tests = {
+        new Test(Chain.SigAlg.MD2withRSA),
+        new Test(Chain.SigAlg.MD5withRSA),
+        new Test(Chain.SigAlg.SHA1withRSA),
+        new Test(Chain.SigAlg.SHA256withRSA),
+        new Test(Chain.SigAlg.SHA384withRSA),
+        new Test(Chain.SigAlg.SHA512withRSA),
+    };
+
+    public static void main(String argv[]) {
+        boolean resutl = java.util.Arrays.stream(tests).allMatch(
+                (test) -> Chain.runTest(test));
+
+        if(resutl) {
+            System.out.println("All tests passed");
+        } else {
+            throw new RuntimeException("Some tests failed");
+        }
+    }
+}
diff --git a/jdk/test/sun/security/pkcs/pkcs10/PKCS10AttrEncoding.java b/jdk/test/sun/security/pkcs/pkcs10/PKCS10AttrEncoding.java
new file mode 100644
index 0000000..efca1b0
--- /dev/null
+++ b/jdk/test/sun/security/pkcs/pkcs10/PKCS10AttrEncoding.java
@@ -0,0 +1,140 @@
+/*
+ * 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 8048357
+ * @summary test DER encoding of PKCS10 attributes
+ * @compile -XDignore.symbol.file PKCS10AttrEncoding.java
+ * @run main PKCS10AttrEncoding
+ */
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.PrivateKey;
+import java.security.Signature;
+import java.util.Enumeration;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import sun.security.pkcs.PKCS9Attribute;
+import sun.security.pkcs10.PKCS10;
+import sun.security.pkcs10.PKCS10Attribute;
+import sun.security.pkcs10.PKCS10Attributes;
+import sun.security.util.ObjectIdentifier;
+import sun.security.x509.X500Name;
+import sun.security.x509.X509Key;
+
+public class PKCS10AttrEncoding {
+
+    static final ObjectIdentifier[] ids = {
+        PKCS9Attribute.CONTENT_TYPE_OID, // ContentType
+        PKCS9Attribute.SIGNING_TIME_OID, // SigningTime
+        PKCS9Attribute.CHALLENGE_PASSWORD_OID // ChallengePassword
+    };
+    static int failedCount = 0;
+    static HashMap<ObjectIdentifier, Object> constructedMap = new HashMap<>();
+
+    public static void main(String[] args) throws Exception {
+
+        // initializations
+        int len = ids.length;
+        Object[] values = {
+            new ObjectIdentifier("1.2.3.4"),
+            new GregorianCalendar(1970, 1, 25, 8, 56, 7).getTime(),
+            "challenging"
+        };
+        for (int j = 0; j < len; j++) {
+            constructedMap.put(ids[j], values[j]);
+        }
+
+        X500Name subject = new X500Name("cn=Test");
+        KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA");
+        String sigAlg = "DSA";
+
+        keyGen.initialize(512);
+
+        KeyPair pair = keyGen.generateKeyPair();
+        X509Key publicKey = (X509Key) pair.getPublic();
+        PrivateKey privateKey = pair.getPrivate();
+
+        Signature signature = Signature.getInstance(sigAlg);
+        signature.initSign(privateKey);
+
+        // Create the PKCS10 request
+        PKCS10Attribute[] attrs = new PKCS10Attribute[len];
+        for (int j = 0; j < len; j++) {
+            attrs[j] = new PKCS10Attribute(ids[j], values[j]);
+        }
+        PKCS10 req = new PKCS10(publicKey, new PKCS10Attributes(attrs));
+        System.out.println("List of attributes in constructed PKCS10 "
+                + "request: ");
+        checkAttributes(req.getAttributes().getElements());
+
+        // Encode the PKCS10 request and generate another PKCS10 request from
+        // the encoded byte array
+        req.encodeAndSign(subject, signature);
+        PKCS10 resp = new PKCS10(req.getEncoded());
+        System.out.println("List of attributes in DER encoded PKCS10 Request:");
+        checkAttributes(resp.getAttributes().getElements());
+
+        if (failedCount > 0) {
+            throw new RuntimeException("Attributes Compared : Failed");
+        }
+        System.out.println("Attributes Compared : Pass");
+    }
+
+    static void checkAttributes(Enumeration attrs) {
+        int numOfAttrs = 0;
+        while (attrs.hasMoreElements()) {
+            numOfAttrs ++;
+            PKCS10Attribute attr = (PKCS10Attribute) attrs.nextElement();
+
+            if (constructedMap.containsKey(attr.getAttributeId())) {
+                if (constructedMap.get(attr.getAttributeId()).
+                        equals(attr.getAttributeValue())) {
+                    System.out.print("AttributeId: " + attr.getAttributeId());
+                    System.out.println(" AttributeValue: "
+                            + attr.getAttributeValue());
+                } else {
+                    failedCount++;
+                    System.out.print("< AttributeId: " + attr.getAttributeId());
+                    System.out.println("  AttributeValue: " + constructedMap.
+                            get(attr.getAttributeId()));
+                    System.out.print("< AttributeId: " + attr.getAttributeId());
+                    System.out.println("  AttributeValue: "
+                            + attr.getAttributeValue());
+                }
+            } else {
+                failedCount++;
+                System.out.println("No " + attr.getAttributeId()
+                        + " in DER encoded PKCS10 Request");
+            }
+        }
+        if(numOfAttrs != constructedMap.size()){
+            failedCount++;
+            System.out.println("Incorrect number of attributes.");
+
+        }
+        System.out.println();
+    }
+
+}
diff --git a/jdk/test/sun/security/pkcs/pkcs10/PKCS10AttributeReader.java b/jdk/test/sun/security/pkcs/pkcs10/PKCS10AttributeReader.java
new file mode 100644
index 0000000..d5bde6d
--- /dev/null
+++ b/jdk/test/sun/security/pkcs/pkcs10/PKCS10AttributeReader.java
@@ -0,0 +1,128 @@
+/*
+ * 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 8048357
+ * @summary Read in a file containing a DER encoded PKCS10 certificate request,
+ * flanked with "begin" and "end" lines.
+ * @compile -XDignore.symbol.file PKCS10AttributeReader.java
+ * @run main PKCS10AttributeReader
+ */
+import java.util.Base64;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Date;
+import sun.security.pkcs.PKCS9Attribute;
+import sun.security.pkcs10.PKCS10Attribute;
+import sun.security.pkcs10.PKCS10Attributes;
+import sun.security.util.DerInputStream;
+import sun.security.util.ObjectIdentifier;
+
+/*
+ Tests only reads DER encoding files, contents of corresponding asn.1 files
+ are copied below for reference.
+
+ # An attribute set for testing with PKCS10.
+
+ {A0  # implicit tag
+    {SEQ  # Content Type
+        {OID 1.2.840.113549.1.9.3}
+        {SET
+            {OID "1234"}
+        }
+    }
+     {SEQ  # Challenge Password
+         {OID 1.2.840.113549.1.9.7}
+         {SET
+             {T61String "GuessWhoAmI"}
+         }
+     }
+     {SEQ  # Signing Time
+        {OID 1.2.840.113549.1.9.5}
+        {SET
+            {UTCTime "970422145010Z"}
+        }
+     }
+ }
+ */
+public class PKCS10AttributeReader {
+    // DER encoded files are binary files, to avoid attaching binary files,
+    // DER files were encoded in base64
+    static final String ATTRIBS = "oE8wEwYJKoZIhvcNAQkDMQYGBDEyMzQwGgYJKoZIhv"
+            + "cNAQkHMQ0UC0d1ZXNzV2hv\nQW1JMBwGCSqGSIb3DQEJBTEPFw05NzA0MjIxND"
+            + "UwMTBa";
+
+    public static void main(String[] args) throws Exception {
+
+        // Decode base64 encoded DER file
+        byte[] pkcs10Bytes = Base64.getMimeDecoder().decode(ATTRIBS.getBytes());
+
+        HashMap<ObjectIdentifier, Object> RequestStander = new HashMap() {
+            {
+                put(PKCS9Attribute.CHALLENGE_PASSWORD_OID, "GuessWhoAmI");
+                put(PKCS9Attribute.SIGNING_TIME_OID, new Date(861720610000L));
+                put(PKCS9Attribute.CONTENT_TYPE_OID,
+                        new ObjectIdentifier("1.9.50.51.52"));
+            }
+        };
+
+        int invalidNum = 0;
+        PKCS10Attributes resp = new PKCS10Attributes(
+                new DerInputStream(pkcs10Bytes));
+        Enumeration eReq = resp.getElements();
+        int numOfAttrs = 0;
+        while (eReq.hasMoreElements()) {
+            numOfAttrs++;
+            PKCS10Attribute attr = (PKCS10Attribute) eReq.nextElement();
+            if (RequestStander.containsKey(attr.getAttributeId())) {
+                if (RequestStander.get(attr.getAttributeId())
+                        .equals(attr.getAttributeValue())) {
+                    System.out.println(attr.getAttributeId() + " "
+                            + attr.getAttributeValue());
+                } else {
+                    invalidNum++;
+                    System.out.println("< " + attr.getAttributeId() + " "
+                            + attr.getAttributeValue());
+                    System.out.println("< " + attr.getAttributeId() + " "
+                            + RequestStander.get(attr.getAttributeId()));
+                }
+            } else {
+                invalidNum++;
+                System.out.println("No" + attr.getAttributeId()
+                        + "in Certificate Request list");
+            }
+        }
+        if (numOfAttrs != RequestStander.size()) {
+            invalidNum++;
+            System.out.println("Incorrect number of attributes.");
+        }
+        System.out.println();
+        if (invalidNum > 0) {
+            throw new RuntimeException(
+                    "Attributes Compared with Stander :" + " Failed");
+        }
+        System.out.println("Attributes Compared with Stander: Pass");
+    }
+
+}
diff --git a/jdk/test/sun/security/pkcs/pkcs7/PKCS7VerifyTest.java b/jdk/test/sun/security/pkcs/pkcs7/PKCS7VerifyTest.java
new file mode 100644
index 0000000..24cc111
--- /dev/null
+++ b/jdk/test/sun/security/pkcs/pkcs7/PKCS7VerifyTest.java
@@ -0,0 +1,116 @@
+/*
+ * 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 8048357
+ * @summary Read signed data in one or more PKCS7 objects from individual files,
+ * verify SignerInfos and certificate chain.
+ * @run main PKCS7VerifyTest PKCS7TEST.DSA.base64
+ * @run main PKCS7VerifyTest PKCS7TEST.DSA.base64 PKCS7TEST.SF
+ */
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.cert.X509Certificate;
+import java.util.Base64;
+import java.util.HashMap;
+import java.util.Map;
+import sun.security.pkcs.PKCS7;
+import sun.security.pkcs.SignerInfo;
+
+public class PKCS7VerifyTest {
+
+    static final String TESTSRC = System.getProperty("test.src", ".");
+    static final String FS = File.separator;
+    static final String FILEPATH = TESTSRC + FS + "jarsigner" + FS + "META-INF"
+            + FS;
+
+    public static void main(String[] args) throws Exception {
+        if (args.length == 0) {
+            throw new RuntimeException("usage: java JarVerify <file1> <file2>");
+        }
+
+        // The command " java PKCS7VerifyTest file1 [file2] "
+        // treats file1 as containing the DER encoding of a PKCS7 signed data
+        // object. If file2 is absent, the program verifies that some signature
+        // (SignerInfo) file1 correctly signs the data contained in the
+        // ContentInfo component of the PKCS7 object encoded by file1. If file2
+        // is present, the program verifies file1 contains a correct signature
+        // for the contents of file2.
+
+        PKCS7 pkcs7;
+        byte[] data;
+
+        // to avoid attaching binary DSA file, the DSA file was encoded
+        // in Base64, decode encoded Base64 DSA file below
+        byte[] base64Bytes = Files.readAllBytes(Paths.get(FILEPATH + args[0]));
+        pkcs7 = new PKCS7(new ByteArrayInputStream(
+                Base64.getMimeDecoder().decode(base64Bytes)));
+        if (args.length < 2) {
+            data = null;
+        } else {
+            data = Files.readAllBytes(Paths.get(FILEPATH + args[1]));
+
+        }
+
+        SignerInfo[] signerInfos = pkcs7.verify(data);
+
+        if (signerInfos == null) {
+            throw new RuntimeException("no signers verify");
+        }
+        System.out.println("Verifying SignerInfos:");
+        for (SignerInfo signerInfo : signerInfos) {
+            System.out.println(signerInfo.toString());
+        }
+
+        X509Certificate certs[] = pkcs7.getCertificates();
+
+        HashMap<String, X509Certificate> certTable = new HashMap(certs.length);
+        for (X509Certificate cert : certs) {
+            certTable.put(cert.getSubjectDN().toString(), cert);
+        }
+
+        // try to verify all the certs
+        for (Map.Entry<String, X509Certificate> entry : certTable.entrySet()) {
+
+            X509Certificate cert = entry.getValue();
+            X509Certificate issuerCert = certTable
+                    .get(cert.getIssuerDN().toString());
+
+            System.out.println("Subject: " + cert.getSubjectDN());
+            if (issuerCert == null) {
+                System.out.println("Issuer certificate not found");
+            } else {
+                System.out.println("Issuer:  " + cert.getIssuerDN());
+                cert.verify(issuerCert.getPublicKey());
+                System.out.println("Cert verifies.");
+            }
+            System.out.println();
+        }
+    }
+
+}
diff --git a/jdk/test/sun/security/pkcs/pkcs7/SignerOrder.java b/jdk/test/sun/security/pkcs/pkcs7/SignerOrder.java
new file mode 100644
index 0000000..1848b43
--- /dev/null
+++ b/jdk/test/sun/security/pkcs/pkcs7/SignerOrder.java
@@ -0,0 +1,271 @@
+/*
+ * 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 8048357
+ * @summary test PKCS7 data signing, encoding and verification
+ * @run main SignerOrder
+ */
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.math.BigInteger;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.PrivateKey;
+import java.security.Signature;
+import java.security.SignatureException;
+import java.security.cert.X509Certificate;
+import java.util.Date;
+import sun.misc.HexDumpEncoder;
+import sun.security.pkcs.ContentInfo;
+import sun.security.pkcs.PKCS7;
+import sun.security.pkcs.SignerInfo;
+import sun.security.util.DerOutputStream;
+import sun.security.x509.AlgorithmId;
+import sun.security.x509.CertificateAlgorithmId;
+import sun.security.x509.CertificateSerialNumber;
+import sun.security.x509.CertificateValidity;
+import sun.security.x509.CertificateVersion;
+import sun.security.x509.CertificateX509Key;
+import sun.security.x509.X500Name;
+import sun.security.x509.X509CertImpl;
+import sun.security.x509.X509CertInfo;
+import sun.security.x509.X509Key;
+
+public class SignerOrder {
+
+    static final HexDumpEncoder hexDump = new HexDumpEncoder();
+
+    //signer infos
+    static final byte[] data1 = "12345".getBytes();
+    static final byte[] data2 = "abcde".getBytes();
+
+    public static void main(String[] argv) throws Exception {
+
+        SignerInfo[] signerInfos = new SignerInfo[9];
+        SimpleSigner signer1 = new SimpleSigner(null, null, null, null);
+        signerInfos[8] = signer1.genSignerInfo(data1);
+        signerInfos[7] = signer1.genSignerInfo(new byte[]{});
+        signerInfos[6] = signer1.genSignerInfo(data2);
+
+        SimpleSigner signer2 = new SimpleSigner(null, null, null, null);
+        signerInfos[5] = signer2.genSignerInfo(data1);
+        signerInfos[4] = signer2.genSignerInfo(new byte[]{});
+        signerInfos[3] = signer2.genSignerInfo(data2);
+
+        SimpleSigner signer3 = new SimpleSigner(null, null, null, null);
+        signerInfos[2] = signer3.genSignerInfo(data1);
+        signerInfos[1] = signer3.genSignerInfo(new byte[]{});
+        signerInfos[0] = signer3.genSignerInfo(data2);
+
+        ContentInfo contentInfo = new ContentInfo(data1);
+
+        AlgorithmId[] algIds = {new AlgorithmId(AlgorithmId.SHA256_oid)};
+
+        X509Certificate[] certs = {signer3.getCert(), signer2.getCert(),
+            signer1.getCert()};
+
+        PKCS7 pkcs71 = new PKCS7(algIds, contentInfo,
+                certs,
+                signerInfos);
+
+        System.out.println("SignerInfos in original.");
+        printSignerInfos(pkcs71.getSignerInfos());
+
+        DerOutputStream out = new DerOutputStream();
+        pkcs71.encodeSignedData(out);
+
+        PKCS7 pkcs72 = new PKCS7(out.toByteArray());
+        System.out.println("\nSignerInfos read back in:");
+        printSignerInfos(pkcs72.getSignerInfos());
+
+        System.out.println("Verified signers of original:");
+        SignerInfo[] verifs1 = pkcs71.verify();
+
+        System.out.println("Verified signers of after read-in:");
+        SignerInfo[] verifs2 = pkcs72.verify();
+
+        if (verifs1.length != verifs2.length) {
+            throw new RuntimeException("Length or Original vs read-in "
+                    + "should be same");
+        }
+    }
+
+    static void printSignerInfos(SignerInfo signerInfo) throws IOException {
+        ByteArrayOutputStream strm = new ByteArrayOutputStream();
+        signerInfo.derEncode(strm);
+        System.out.println("SignerInfo, length: "
+                + strm.toByteArray().length);
+        System.out.println(hexDump.encode(strm.toByteArray()));
+        System.out.println("\n");
+        strm.reset();
+    }
+
+    static void printSignerInfos(SignerInfo[] signerInfos) throws IOException {
+        ByteArrayOutputStream strm = new ByteArrayOutputStream();
+        for (int i = 0; i < signerInfos.length; i++) {
+            signerInfos[i].derEncode(strm);
+            System.out.println("SignerInfo[" + i + "], length: "
+                    + strm.toByteArray().length);
+            System.out.println(hexDump.encode(strm.toByteArray()));
+            System.out.println("\n");
+            strm.reset();
+        }
+    }
+
+}
+
+/**
+ * A simple extension of sun.security.x509.X500Signer that adds a no-fuss
+ * signing algorithm.
+ */
+class SimpleSigner {
+
+    private final Signature sig;
+    private final X500Name agent;
+    private final AlgorithmId digestAlgId;
+    private final AlgorithmId encryptionAlgId;
+    private final AlgorithmId algId; // signature algid;
+                                     //combines digest + encryption
+    private final X509Key publicKey;
+    private final PrivateKey privateKey;
+    private final X509Certificate cert;
+
+    public SimpleSigner(String digestAlg,
+            String encryptionAlg,
+            KeyPair keyPair,
+            X500Name agent) throws Exception {
+
+        if (agent == null) {
+            agent = new X500Name("cn=test");
+        }
+        if (digestAlg == null) {
+            digestAlg = "SHA";
+        }
+        if (encryptionAlg == null) {
+            encryptionAlg = "DSA";
+        }
+        if (keyPair == null) {
+            KeyPairGenerator keyGen =
+                    KeyPairGenerator.getInstance(encryptionAlg);
+            keyGen.initialize(1024);
+            keyPair = keyGen.generateKeyPair();
+        }
+        publicKey = (X509Key) keyPair.getPublic();
+        privateKey = keyPair.getPrivate();
+
+        if ("DSA".equals(encryptionAlg)) {
+            this.sig = Signature.getInstance(encryptionAlg);
+        } else { // RSA
+            this.sig = Signature.getInstance(digestAlg + "/" + encryptionAlg);
+        }
+        this.sig.initSign(privateKey);
+
+        this.agent = agent;
+        this.digestAlgId = AlgorithmId.get(digestAlg);
+        this.encryptionAlgId = AlgorithmId.get(encryptionAlg);
+        this.algId = AlgorithmId.get(this.sig.getAlgorithm());
+
+        this.cert = getSelfCert();
+    }
+
+    /**
+     * Take the data and sign it.
+     *
+     * @param buf buffer holding the next chunk of the data to be signed
+     * @param offset starting point of to-be-signed data
+     * @param len how many bytes of data are to be signed
+     * @return the signature for the input data.
+     * @exception SignatureException on errors.
+     */
+    public byte[] simpleSign(byte[] buf, int offset, int len)
+            throws SignatureException {
+        sig.update(buf, offset, len);
+        return sig.sign();
+    }
+
+    /**
+     * Returns the digest algorithm used to sign.
+     */
+    public AlgorithmId getDigestAlgId() {
+        return digestAlgId;
+    }
+
+    /**
+     * Returns the encryption algorithm used to sign.
+     */
+    public AlgorithmId getEncryptionAlgId() {
+        return encryptionAlgId;
+    }
+
+    /**
+     * Returns the name of the signing agent.
+     */
+    public X500Name getSigner() {
+        return agent;
+    }
+
+    public X509Certificate getCert() {
+        return cert;
+    }
+
+    private X509Certificate getSelfCert() throws Exception {
+        long validity = 1000;
+        X509CertImpl certLocal;
+        Date firstDate, lastDate;
+
+        firstDate = new Date();
+        lastDate = new Date();
+        lastDate.setTime(lastDate.getTime() + validity + 1000);
+
+        CertificateValidity interval = new CertificateValidity(firstDate,
+                lastDate);
+
+        X509CertInfo info = new X509CertInfo();
+        // Add all mandatory attributes
+        info.set(X509CertInfo.VERSION,
+                new CertificateVersion(CertificateVersion.V1));
+        info.set(X509CertInfo.SERIAL_NUMBER,
+                new CertificateSerialNumber(
+                        (int) (firstDate.getTime() / 1000)));
+        info.set(X509CertInfo.ALGORITHM_ID,
+                new CertificateAlgorithmId(algId));
+        info.set(X509CertInfo.SUBJECT, agent);
+        info.set(X509CertInfo.KEY, new CertificateX509Key(publicKey));
+        info.set(X509CertInfo.VALIDITY, interval);
+        info.set(X509CertInfo.ISSUER, agent);
+
+        certLocal = new X509CertImpl(info);
+        certLocal.sign(privateKey, algId.getName());
+
+        return certLocal;
+    }
+
+    public SignerInfo genSignerInfo(byte[] data) throws SignatureException {
+        return new SignerInfo((X500Name) cert.getIssuerDN(),
+                new BigInteger("" + cert.getSerialNumber()),
+                getDigestAlgId(), algId,
+                simpleSign(data, 0, data.length));
+    }
+}
diff --git a/jdk/test/sun/security/pkcs/pkcs7/jarsigner/META-INF/MANIFEST.MF b/jdk/test/sun/security/pkcs/pkcs7/jarsigner/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..6be546d
--- /dev/null
+++ b/jdk/test/sun/security/pkcs/pkcs7/jarsigner/META-INF/MANIFEST.MF
@@ -0,0 +1,82 @@
+Manifest-Version: 1.0
+
+Name: CheckCerts.class
+Digest-Algorithms: SHA
+SHA-Digest: xLygljhRro6990piIVEilVI8szQ=
+
+Name: ContentInfoTest.class
+Digest-Algorithms: SHA
+SHA-Digest: TSVdEMQW2gdFi6qeba+UixdHSdo=
+
+Name: JarVerify.class
+Digest-Algorithms: SHA
+SHA-Digest: Wg+PiDzunNGH4KrWAp00/okp39s=
+
+Name: JarVerify2.class
+Digest-Algorithms: SHA
+SHA-Digest: 5uYBQxwGWgYmNBwhnWRbymeXmWM=
+
+Name: PKCS7Read.class
+Digest-Algorithms: SHA
+SHA-Digest: JPIxttHBfRpQaFyiQJ2Wfkvj/ls=
+
+Name: PKCS7Test.class
+Digest-Algorithms: SHA
+SHA-Digest: R64SXXgZrOvGiO/eMsfG/T1Vn30=
+
+Name: PKCS7Test10.class
+Digest-Algorithms: SHA
+SHA-Digest: 2R0yxuxRHTPqdAzJJcrvqkpbQgo=
+
+Name: PKCS7Test11.class
+Digest-Algorithms: SHA
+SHA-Digest: /0HcwnpQi0hwJsJtvt5peWFGvtc=
+
+Name: PKCS7Test12.class
+Digest-Algorithms: SHA
+SHA-Digest: s5CcqimfRqR9CW25tFBY0JK3RVU=
+
+Name: PKCS7Test2.class
+Digest-Algorithms: SHA
+SHA-Digest: 71VkFEMUle5sjXNFbSW31F1ZJ58=
+
+Name: PKCS7Test3.class
+Digest-Algorithms: SHA
+SHA-Digest: mU/D5C6SgPRmwoLQzwF5VnN3aqM=
+
+Name: PKCS7Test4.class
+Digest-Algorithms: SHA
+SHA-Digest: ss9NFvxF8emaEjdKdvtzWXfs0/E=
+
+Name: PKCS7Test5.class
+Digest-Algorithms: SHA
+SHA-Digest: DHvQ20UAXoYgfCPAOeCOrglsJwU=
+
+Name: PKCS7Test6.class
+Digest-Algorithms: SHA
+SHA-Digest: aiCb8chroH7XDaNfAz6wr57lXsA=
+
+Name: PKCS7Test7.class
+Digest-Algorithms: SHA
+SHA-Digest: UoieXLC68alFgfD/Q1NW9/r2kaY=
+
+Name: PKCS7Test8.class
+Digest-Algorithms: SHA
+SHA-Digest: eMW7mq5b/KVB1M5L76wcV1+uFQs=
+
+Name: PKCS7Test9.class
+Digest-Algorithms: SHA
+SHA-Digest: EEWCZG1creWjqVZVIEgr0on3y6A=
+
+Name: SignerInfoTest.class
+Digest-Algorithms: SHA
+SHA-Digest: l6SNfpnFipGg8gy4XqY3HhA0RrY=
+
+Name: SignerInfoTest2.class
+Digest-Algorithms: SHA
+SHA-Digest: 5jbzlkZqXKNmmmE+pcjQka8D6WE=
+
+Name: SimpleSigner.class
+Digest-Algorithms: SHA
+SHA-Digest: l9ODQHY4wxhIvLw4/B0qe9NjwxQ=
+
diff --git a/jdk/test/sun/security/pkcs/pkcs7/jarsigner/META-INF/PKCS7TEST.DSA.base64 b/jdk/test/sun/security/pkcs/pkcs7/jarsigner/META-INF/PKCS7TEST.DSA.base64
new file mode 100644
index 0000000..f084beb
--- /dev/null
+++ b/jdk/test/sun/security/pkcs/pkcs7/jarsigner/META-INF/PKCS7TEST.DSA.base64
@@ -0,0 +1,60 @@
+MIILKAYJKoZIhvcNAQcCoIILGTCCCxUCAQExCzAJBgUrDgMCGgUAMIIHbQYJKoZI
+hvcNAQcBoIIHXgSCB1pTaWduYXR1cmUtVmVyc2lvbjogMS4wDQoNCk5hbWU6IENo
+ZWNrQ2VydHMuY2xhc3MNCkRpZ2VzdC1BbGdvcml0aG1zOiBTSEENClNIQS1EaWdl
+c3Q6IHlhMXh3dnNRTytEUnBRYnczRmgyblJCMkpRYz0NCg0KTmFtZTogQ29udGVu
+dEluZm9UZXN0LmNsYXNzDQpEaWdlc3QtQWxnb3JpdGhtczogU0hBDQpTSEEtRGln
+ZXN0OiBDYStFSmFrVTZ6dzRLQWhvcWNuQ3BOcWsyTEk9DQoNCk5hbWU6IEphclZl
+cmlmeS5jbGFzcw0KRGlnZXN0LUFsZ29yaXRobXM6IFNIQQ0KU0hBLURpZ2VzdDog
+K0RHYVdXa25md2U0Wk9wc29NVEZ6ZldSdmhRPQ0KDQpOYW1lOiBKYXJWZXJpZnky
+LmNsYXNzDQpEaWdlc3QtQWxnb3JpdGhtczogU0hBDQpTSEEtRGlnZXN0OiBHcUR6
+WXlZNFAvV0g1SEt2aVdxWHR0UGc1ckU9DQoNCk5hbWU6IFBLQ1M3UmVhZC5jbGFz
+cw0KRGlnZXN0LUFsZ29yaXRobXM6IFNIQQ0KU0hBLURpZ2VzdDogUW1mOEs5aFhW
+bHdJZFBZNm52MmpGUGZHcWtBPQ0KDQpOYW1lOiBQS0NTN1Rlc3QuY2xhc3MNCkRp
+Z2VzdC1BbGdvcml0aG1zOiBTSEENClNIQS1EaWdlc3Q6IEdiZS9nenl2MkY1OGY2
+RUVoU1oxQnFHWHRsbz0NCg0KTmFtZTogUEtDUzdUZXN0MTAuY2xhc3MNCkRpZ2Vz
+dC1BbGdvcml0aG1zOiBTSEENClNIQS1EaWdlc3Q6IDh3QnFXLy9lVzJzTlJJOTFi
+TFlFT29kY2dhRT0NCg0KTmFtZTogUEtDUzdUZXN0MTEuY2xhc3MNCkRpZ2VzdC1B
+bGdvcml0aG1zOiBTSEENClNIQS1EaWdlc3Q6IGJYaExLRXNsY3VFWGk0dS9haGdU
+MnE2dGNFVT0NCg0KTmFtZTogUEtDUzdUZXN0MTIuY2xhc3MNCkRpZ2VzdC1BbGdv
+cml0aG1zOiBTSEENClNIQS1EaWdlc3Q6IDlLRVkxYjUyUUxtTjBxei81ejB3QkZy
+T216MD0NCg0KTmFtZTogUEtDUzdUZXN0Mi5jbGFzcw0KRGlnZXN0LUFsZ29yaXRo
+bXM6IFNIQQ0KU0hBLURpZ2VzdDogK1VhMzIvMlE4RjJiclFRbVNYWCtYUytNL2g0
+PQ0KDQpOYW1lOiBQS0NTN1Rlc3QzLmNsYXNzDQpEaWdlc3QtQWxnb3JpdGhtczog
+U0hBDQpTSEEtRGlnZXN0OiAwSFhVWnlhU2ZkZUtlZThuWnpFalJTeXJldTQ9DQoN
+Ck5hbWU6IFBLQ1M3VGVzdDQuY2xhc3MNCkRpZ2VzdC1BbGdvcml0aG1zOiBTSEEN
+ClNIQS1EaWdlc3Q6IEo3eXJTMjRvS3VTZ2F1dHZkemhxQmo3ZGJjUT0NCg0KTmFt
+ZTogUEtDUzdUZXN0NS5jbGFzcw0KRGlnZXN0LUFsZ29yaXRobXM6IFNIQQ0KU0hB
+LURpZ2VzdDogSlR2OVdTb3gxTEVTUjJMcTdzMFVxU2x0RFNRPQ0KDQpOYW1lOiBQ
+S0NTN1Rlc3Q2LmNsYXNzDQpEaWdlc3QtQWxnb3JpdGhtczogU0hBDQpTSEEtRGln
+ZXN0OiBnR3Yra05oK3UzSFExdHp4bGNBVzdTcEZUS2s9DQoNCk5hbWU6IFBLQ1M3
+VGVzdDcuY2xhc3MNCkRpZ2VzdC1BbGdvcml0aG1zOiBTSEENClNIQS1EaWdlc3Q6
+IGZpSEYxYUExYWN6czFPd0V5OEc3VkMrcjdMST0NCg0KTmFtZTogUEtDUzdUZXN0
+OC5jbGFzcw0KRGlnZXN0LUFsZ29yaXRobXM6IFNIQQ0KU0hBLURpZ2VzdDogNzRU
+VzdJOVZPdzVWZ0x2aFJtRGZxRVd2ZkFRPQ0KDQpOYW1lOiBQS0NTN1Rlc3Q5LmNs
+YXNzDQpEaWdlc3QtQWxnb3JpdGhtczogU0hBDQpTSEEtRGlnZXN0OiAxY0JJbkdU
+Y08xQVFaKy8wdmhGa2laV3dsQTA9DQoNCk5hbWU6IFNpZ25lckluZm9UZXN0LmNs
+YXNzDQpEaWdlc3QtQWxnb3JpdGhtczogU0hBDQpTSEEtRGlnZXN0OiBjRlk0Q3RT
+anphMUErV2pBS05TVnF1cGpSWUU9DQoNCk5hbWU6IFNpZ25lckluZm9UZXN0Mi5j
+bGFzcw0KRGlnZXN0LUFsZ29yaXRobXM6IFNIQQ0KU0hBLURpZ2VzdDogYU5NMEZQ
+MHpFelF6eGxYeDZxQ0J4dWtta0hRPQ0KDQpOYW1lOiBTaW1wbGVTaWduZXIuY2xh
+c3MNCkRpZ2VzdC1BbGdvcml0aG1zOiBTSEENClNIQS1EaWdlc3Q6IC9MV0NzbkM3
+TVpNUjZHb3czeTJjdnA3STBTTT0NCg0KoIICvzCCArswggJ3AgUA59UzNDALBgcq
+hkjOOAQDBQAwdTELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRIwEAYDVQQHEwlD
+dXBlcnRpbm8xGTAXBgNVBAoTEFN1biBNaWNyb3N5c3RlbXMxETAPBgNVBAsTCEph
+dmFTb2Z0MRcwFQYDVQQDEw5Eb3VnbGFzIEhvb3ZlcjAeFw05NzEwMDIxODEyMDda
+Fw05NzEyMzExNzEyMDdaMHUxCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTESMBAG
+A1UEBxMJQ3VwZXJ0aW5vMRkwFwYDVQQKExBTdW4gTWljcm9zeXN0ZW1zMREwDwYD
+VQQLEwhKYXZhU29mdDEXMBUGA1UEAxMORG91Z2xhcyBIb292ZXIwggFRMIHoBgcq
+hkjOOAQBMIHcAmEA6eZCWZ01XzfJf/01ZxILjiXJzUPpJ7OpZw++xdiQFBki0sOz
+rSSACTeZhp0ehGqrSfqwrSbSzmoiIZ1HC859d31KIfvpwnC1f2BwAvPO+Dk2lM9F
+7jaIwRqMVqsSej2vAhUAnNvYTJ8awvOND4D0KrlS5zOL9RECYDBHCtWgBfsUzi2d
+zYfji8fRscX6y67L6V8ZCqejHSPE27y+BhdFREAaWywCCWXYwr0hcdNmhEV3H3S6
+CE0gKdg8HBWFR/Op8aJxW+I9Ua5NPlofanBk8xaTOjRtP1KSUgNkAAJhAMN5uB+B
+ZJ0W2UjXMyKoFUFXRYiLpnaSw63kl9tKnR9R5rEreiyHQ5IelPxjwCHGgTbYK0y+
+xKTGHVWiQN/YJmHLbSrcSSM/d89aR/sVbGoAwQOyYraFGUNIOTQjjXcXCjALBgcq
+hkjOOAQDBQADMQAwLgIVAJxmL029GLXDJVbk72d4cSPQ4/rvAhUAll9UPl8aOMEg
+V4egANhwbynMGSgxgc4wgcsCAQEwfjB1MQswCQYDVQQGEwJVUzELMAkGA1UECBMC
+Q0ExEjAQBgNVBAcTCUN1cGVydGlubzEZMBcGA1UEChMQU3VuIE1pY3Jvc3lzdGVt
+czERMA8GA1UECxMISmF2YVNvZnQxFzAVBgNVBAMTDkRvdWdsYXMgSG9vdmVyAgUA
+59UzNDAJBgUrDgMCGgUAMAsGByqGSM44BAMFAAQuMCwCFDmry17kzDD6Y5X1BqIS
+lq6swckPAhRtiXvBHa5CRGjbwk8yqf9hGgZfFA==
diff --git a/jdk/test/sun/security/pkcs/pkcs7/jarsigner/META-INF/PKCS7TEST.SF b/jdk/test/sun/security/pkcs/pkcs7/jarsigner/META-INF/PKCS7TEST.SF
new file mode 100644
index 0000000..05a7938
--- /dev/null
+++ b/jdk/test/sun/security/pkcs/pkcs7/jarsigner/META-INF/PKCS7TEST.SF
@@ -0,0 +1,82 @@
+Signature-Version: 1.0

+

+Name: CheckCerts.class

+Digest-Algorithms: SHA

+SHA-Digest: ya1xwvsQO+DRpQbw3Fh2nRB2JQc=

+

+Name: ContentInfoTest.class

+Digest-Algorithms: SHA

+SHA-Digest: Ca+EJakU6zw4KAhoqcnCpNqk2LI=

+

+Name: JarVerify.class

+Digest-Algorithms: SHA

+SHA-Digest: +DGaWWknfwe4ZOpsoMTFzfWRvhQ=

+

+Name: JarVerify2.class

+Digest-Algorithms: SHA

+SHA-Digest: GqDzYyY4P/WH5HKviWqXttPg5rE=

+

+Name: PKCS7Read.class

+Digest-Algorithms: SHA

+SHA-Digest: Qmf8K9hXVlwIdPY6nv2jFPfGqkA=

+

+Name: PKCS7Test.class

+Digest-Algorithms: SHA

+SHA-Digest: Gbe/gzyv2F58f6EEhSZ1BqGXtlo=

+

+Name: PKCS7Test10.class

+Digest-Algorithms: SHA

+SHA-Digest: 8wBqW//eW2sNRI91bLYEOodcgaE=

+

+Name: PKCS7Test11.class

+Digest-Algorithms: SHA

+SHA-Digest: bXhLKEslcuEXi4u/ahgT2q6tcEU=

+

+Name: PKCS7Test12.class

+Digest-Algorithms: SHA

+SHA-Digest: 9KEY1b52QLmN0qz/5z0wBFrOmz0=

+

+Name: PKCS7Test2.class

+Digest-Algorithms: SHA

+SHA-Digest: +Ua32/2Q8F2brQQmSXX+XS+M/h4=

+

+Name: PKCS7Test3.class

+Digest-Algorithms: SHA

+SHA-Digest: 0HXUZyaSfdeKee8nZzEjRSyreu4=

+

+Name: PKCS7Test4.class

+Digest-Algorithms: SHA

+SHA-Digest: J7yrS24oKuSgautvdzhqBj7dbcQ=

+

+Name: PKCS7Test5.class

+Digest-Algorithms: SHA

+SHA-Digest: JTv9WSox1LESR2Lq7s0UqSltDSQ=

+

+Name: PKCS7Test6.class

+Digest-Algorithms: SHA

+SHA-Digest: gGv+kNh+u3HQ1tzxlcAW7SpFTKk=

+

+Name: PKCS7Test7.class

+Digest-Algorithms: SHA

+SHA-Digest: fiHF1aA1aczs1OwEy8G7VC+r7LI=

+

+Name: PKCS7Test8.class

+Digest-Algorithms: SHA

+SHA-Digest: 74TW7I9VOw5VgLvhRmDfqEWvfAQ=

+

+Name: PKCS7Test9.class

+Digest-Algorithms: SHA

+SHA-Digest: 1cBInGTcO1AQZ+/0vhFkiZWwlA0=

+

+Name: SignerInfoTest.class

+Digest-Algorithms: SHA

+SHA-Digest: cFY4CtSjza1A+WjAKNSVqupjRYE=

+

+Name: SignerInfoTest2.class

+Digest-Algorithms: SHA

+SHA-Digest: aNM0FP0zEzQzxlXx6qCBxukmkHQ=

+

+Name: SimpleSigner.class

+Digest-Algorithms: SHA

+SHA-Digest: /LWCsnC7MZMR6Gow3y2cvp7I0SM=

+

diff --git a/jdk/test/sun/security/pkcs/pkcs8/PKCS8Test.java b/jdk/test/sun/security/pkcs/pkcs8/PKCS8Test.java
new file mode 100644
index 0000000..6bd3af5
--- /dev/null
+++ b/jdk/test/sun/security/pkcs/pkcs8/PKCS8Test.java
@@ -0,0 +1,282 @@
+/*
+ * 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 8048357
+ * @summary PKCS8 Standards Conformance Tests
+ * @requires (os.family != "solaris")
+ * @compile -XDignore.symbol.file PKCS8Test.java
+ * @run main PKCS8Test
+ */
+
+/*
+ * Skip Solaris since the DSAPrivateKeys returned by
+ * SunPKCS11 Provider are not subclasses of PKCS8Key
+ */
+import java.io.IOException;
+import java.math.BigInteger;
+import java.security.InvalidKeyException;
+import java.util.Arrays;
+import sun.misc.HexDumpEncoder;
+import sun.security.pkcs.PKCS8Key;
+import sun.security.provider.DSAPrivateKey;
+import sun.security.util.DerOutputStream;
+import sun.security.util.DerValue;
+import sun.security.x509.AlgorithmId;
+import static java.lang.System.out;
+
+public class PKCS8Test {
+
+    static final HexDumpEncoder hexDump = new HexDumpEncoder();
+
+    static final DerOutputStream derOutput = new DerOutputStream();
+
+    static final String FORMAT = "PKCS#8";
+    static final String EXPECTED_ALG_ID_CHRS = "DSA\n\tp:     02\n\tq:     03\n"
+            + "\tg:     04\n";
+    static final String ALGORITHM = "DSA";
+    static final String EXCEPTION_MESSAGE = "version mismatch: (supported:     "
+            + "00, parsed:     01";
+
+    // test second branch in byte[] encode()
+    // DER encoding,include (empty) set of attributes
+    static final int[] NEW_ENCODED_KEY_INTS = { 0x30,
+            // length 30 = 0x1e
+            0x1e,
+            // first element
+            // version Version (= INTEGER)
+            0x02,
+            // length 1
+            0x01,
+            // value 0
+            0x00,
+            // second element
+            // privateKeyAlgorithmIdentifier PrivateKeyAlgorithmIdentifier
+            // (sequence)
+            // (an object identifier?)
+            0x30,
+            // length 18
+            0x12,
+            // contents
+            // object identifier, 5 bytes
+            0x06, 0x05,
+            // { 1 3 14 3 2 12 }
+            0x2b, 0x0e, 0x03, 0x02, 0x0c,
+            // sequence, 9 bytes
+            0x30, 0x09,
+            // integer 2
+            0x02, 0x01, 0x02,
+            // integer 3
+            0x02, 0x01, 0x03,
+            // integer 4
+            0x02, 0x01, 0x04,
+            // third element
+            // privateKey PrivateKey (= OCTET STRING)
+            0x04,
+            // length
+            0x03,
+            // privateKey contents
+            0x02, 0x01, 0x01,
+            // 4th (optional) element -- attributes [0] IMPLICIT Attributes
+            // OPTIONAL
+            // (Attributes = SET OF Attribute) Here, it will be empty.
+            0xA0,
+            // length
+            0x00 };
+
+    // encoding originally created, but with the version changed
+    static final int[] NEW_ENCODED_KEY_INTS_2 = {
+            // sequence
+            0x30,
+            // length 28 = 0x1c
+            0x1c,
+            // first element
+            // version Version (= INTEGER)
+            0x02,
+            // length 1
+            0x01,
+            // value 1 (illegal)
+            0x01,
+            // second element
+            // privateKeyAlgorithmIdentifier PrivateKeyAlgorithmIdentifier
+            // (sequence)
+            // (an object identifier?)
+            0x30,
+            // length 18
+            0x12,
+            // contents
+            // object identifier, 5 bytes
+            0x06, 0x05,
+            // { 1 3 14 3 2 12 }
+            0x2b, 0x0e, 0x03, 0x02, 0x0c,
+            // sequence, 9 bytes
+            0x30, 0x09,
+            // integer 2
+            0x02, 0x01, 0x02,
+            // integer 3
+            0x02, 0x01, 0x03,
+            // integer 4
+            0x02, 0x01, 0x04,
+            // third element
+            // privateKey PrivateKey (= OCTET STRING)
+            0x04,
+            // length
+            0x03,
+            // privateKey contents
+            0x02, 0x01, 0x01 };
+
+    // 0000: 30 1E 02 01 00 30 14 06 07 2A 86 48 CE 38 04 01 0....0...*.H.8..
+    // 0010: 30 09 02 01 02 02 01 03 02 01 04 04 03 02 01 01 0...............
+    static final int[] EXPECTED = { 0x30,
+            // length 30 = 0x1e
+            0x1e,
+            // first element
+            // version Version (= INTEGER)
+            0x02,
+            // length 1
+            0x01,
+            // value 0
+            0x00,
+            // second element
+            // privateKeyAlgorithmIdentifier PrivateKeyAlgorithmIdentifier
+            // (sequence)
+            // (an object identifier?)
+            0x30, 0x14, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x38, 0x04, 0x01,
+            // integer 2
+            0x30, 0x09, 0x02,
+            // integer 3
+            0x01, 0x02, 0x02,
+            // integer 4
+            0x01, 0x03, 0x02,
+            // third element
+            // privateKey PrivateKey (= OCTET STRING)
+            0x01,
+            // length
+            0x04,
+            // privateKey contents
+            0x04, 0x03, 0x02,
+            // 4th (optional) element -- attributes [0] IMPLICIT Attributes
+            // OPTIONAL
+            // (Attributes = SET OF Attribute) Here, it will be empty.
+            0x01,
+            // length
+            0x01 };
+
+    static void raiseException(String expected, String received) {
+        throw new RuntimeException(
+                "Expected " + expected + "; Received " + received);
+    }
+
+    public static void main(String[] args)
+            throws IOException, InvalidKeyException {
+
+        BigInteger p = BigInteger.valueOf(1);
+        BigInteger q = BigInteger.valueOf(2);
+        BigInteger g = BigInteger.valueOf(3);
+        BigInteger x = BigInteger.valueOf(4);
+
+        DSAPrivateKey priv = new DSAPrivateKey(p, q, g, x);
+
+        byte[] encodedKey = priv.getEncoded();
+        byte[] expectedBytes = new byte[EXPECTED.length];
+        for (int i = 0; i < EXPECTED.length; i++) {
+            expectedBytes[i] = (byte) EXPECTED[i];
+        }
+
+        dumpByteArray("encodedKey :", encodedKey);
+        if (!Arrays.equals(encodedKey, expectedBytes)) {
+            raiseException(new String(expectedBytes), new String(encodedKey));
+        }
+
+        PKCS8Key decodedKey = PKCS8Key.parse(new DerValue(encodedKey));
+
+        String alg = decodedKey.getAlgorithm();
+        AlgorithmId algId = decodedKey.getAlgorithmId();
+        out.println("Algorithm :" + alg);
+        out.println("AlgorithmId: " + algId);
+
+        if (!ALGORITHM.equals(alg)) {
+            raiseException(ALGORITHM, alg);
+        }
+        if (!EXPECTED_ALG_ID_CHRS.equalsIgnoreCase(algId.toString())) {
+            raiseException(EXPECTED_ALG_ID_CHRS, algId.toString());
+        }
+
+        decodedKey.encode(derOutput);
+        dumpByteArray("Stream encode: ", derOutput.toByteArray());
+        if (!Arrays.equals(derOutput.toByteArray(), expectedBytes)) {
+            raiseException(new String(expectedBytes), derOutput.toString());
+        }
+
+        dumpByteArray("byte[] encoding: ", decodedKey.getEncoded());
+        if (!Arrays.equals(decodedKey.getEncoded(), expectedBytes)) {
+            raiseException(new String(expectedBytes),
+                    new String(decodedKey.getEncoded()));
+        }
+
+        if (!FORMAT.equals(decodedKey.getFormat())) {
+            raiseException(FORMAT, decodedKey.getFormat());
+        }
+
+        try {
+            byte[] newEncodedKey = new byte[NEW_ENCODED_KEY_INTS.length];
+            for (int i = 0; i < newEncodedKey.length; i++) {
+                newEncodedKey[i] = (byte) NEW_ENCODED_KEY_INTS[i];
+            }
+            PKCS8Key newDecodedKey = PKCS8Key
+                    .parse(new DerValue(newEncodedKey));
+
+            throw new RuntimeException(
+                    "key1: Expected an IOException during " + "parsing");
+        } catch (IOException e) {
+            System.out.println("newEncodedKey: should have excess data due to "
+                    + "attributes, which are not supported");
+        }
+
+        try {
+            byte[] newEncodedKey2 = new byte[NEW_ENCODED_KEY_INTS_2.length];
+            for (int i = 0; i < newEncodedKey2.length; i++) {
+                newEncodedKey2[i] = (byte) NEW_ENCODED_KEY_INTS_2[i];
+            }
+
+            PKCS8Key newDecodedKey2 = PKCS8Key
+                    .parse(new DerValue(newEncodedKey2));
+
+            throw new RuntimeException(
+                    "key2: Expected an IOException during " + "parsing");
+        } catch (IOException e) {
+            out.println("Key 2: should be illegal version");
+            out.println(e.getMessage());
+            if (!EXCEPTION_MESSAGE.equals(e.getMessage())) {
+                throw new RuntimeException("Key2: expected: "
+                        + EXCEPTION_MESSAGE + " get: " + e.getMessage());
+            }
+        }
+    }
+
+    static void dumpByteArray(String nm, byte[] bytes) throws IOException {
+        out.println(nm + " length: " + bytes.length);
+        hexDump.encodeBuffer(bytes, out);
+    }
+}
diff --git a/jdk/test/sun/security/pkcs11/Mac/MacKAT.java b/jdk/test/sun/security/pkcs11/Mac/MacKAT.java
new file mode 100644
index 0000000..c7da929
--- /dev/null
+++ b/jdk/test/sun/security/pkcs11/Mac/MacKAT.java
@@ -0,0 +1,265 @@
+/*
+ * Copyright (c) 2003, 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.
+ *
+ * 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.UnsupportedEncodingException;
+import java.security.Provider;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Random;
+import javax.crypto.Mac;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.SecretKeySpec;
+
+/**
+ * @test
+ * @bug 4846410 6313661 4963723
+ * @summary Basic known-answer-test for Hmac algorithms
+ * @author Andreas Sterbenz
+ * @library ..
+ * @run main MacKAT
+ */
+public class MacKAT extends PKCS11Test {
+
+    private final static byte[] ALONG, BLONG, BKEY, BKEY_20, DDDATA_50,
+            AAKEY_20, CDDATA_50, AAKEY_131;
+
+    static {
+        ALONG = new byte[1024 * 128];
+        Arrays.fill(ALONG, (byte)'a');
+        BLONG = new byte[1024 * 128];
+        Random random = new Random(12345678);
+        random.nextBytes(BLONG);
+        BKEY = new byte[128];
+        random.nextBytes(BKEY);
+        BKEY_20 = new byte[20];
+        Arrays.fill(BKEY_20, (byte) 0x0b);
+        DDDATA_50 = new byte[50];
+        Arrays.fill(DDDATA_50, (byte) 0xdd);
+        AAKEY_20 = new byte[20];
+        Arrays.fill(AAKEY_20, (byte) 0xaa);
+        CDDATA_50 = new byte[50];
+        Arrays.fill(CDDATA_50, (byte) 0xcd);
+        AAKEY_131 = new byte[131];
+        Arrays.fill(AAKEY_131, (byte) 0xaa);
+    }
+
+    private final static Test[] tests = {
+        newMacTest("SslMacMD5",
+                ALONG,
+                "f4:ad:01:71:51:f6:89:56:72:a3:32:bf:d9:2a:f2:a5",
+                "1b:34:61:29:05:0d:73:db:25:d0:dd:64:06:29:f6:8a"),
+        newMacTest("SslMacMD5",
+                BLONG,
+                "34:1c:ad:a0:95:57:32:f8:8e:80:8f:ee:b2:d8:23:e5",
+                "76:00:4a:72:98:9b:65:ec:2e:f1:43:c4:65:4a:13:71"),
+        newMacTest("SslMacSHA1",
+                ALONG,
+                "11:c1:71:2e:61:be:4b:cf:bc:6d:e2:4c:58:ae:27:30:0b:24:a4:87",
+                "23:ae:dd:61:87:6c:7a:45:47:2f:2c:8f:ea:64:99:3e:27:5f:97:a5"),
+        newMacTest("SslMacSHA1",
+                BLONG,
+                "84:af:57:0a:af:ef:16:93:90:50:da:88:f8:ad:1a:c5:66:6c:94:d0",
+                "9b:bb:e2:aa:9b:28:1c:95:0e:ea:30:21:98:a5:7e:31:9e:bf:5f:51"),
+        newMacTest("HmacMD5",
+                ALONG,
+                "76:00:4a:72:98:9b:65:ec:2e:f1:43:c4:65:4a:13:71",
+                "1b:34:61:29:05:0d:73:db:25:d0:dd:64:06:29:f6:8a"),
+        newMacTest("HmacMD5",
+                BLONG,
+                "6c:22:79:bb:34:9e:da:f4:f5:cf:df:0c:62:3d:59:e0",
+                "76:00:4a:72:98:9b:65:ec:2e:f1:43:c4:65:4a:13:71"),
+        newMacTest("HmacMD5",
+                BLONG,
+                "e6:ad:00:c9:49:6b:98:fe:53:a2:b9:2d:7d:41:a2:03",
+                BKEY),
+        newMacTest("HmacSHA1",
+                ALONG,
+                "9e:b3:6e:35:fa:fb:17:2e:2b:f3:b0:4a:9d:38:83:c4:5f:6d:d9:00",
+                "1b:34:61:29:05:0d:73:db:25:d0:dd:64:06:29:f6:8a"),
+        newMacTest("HmacSHA1",
+                BLONG,
+                "80:2d:5b:ea:08:df:a4:1f:e5:3e:1c:fa:fc:ad:dd:31:da:15:60:2c",
+                "76:00:4a:72:98:9b:65:ec:2e:f1:43:c4:65:4a:13:71"),
+        newMacTest("HmacSHA1",
+                BLONG,
+                "a2:fa:2a:85:18:0e:94:b2:a5:e2:17:8b:2a:29:7a:95:cd:e8:aa:82",
+                BKEY),
+        newMacTest("HmacSHA256",
+                ALONG,
+                "3f:6d:08:df:0c:90:b0:e9:ed:13:4a:2e:c3:48:1d:3d:3e:61:2e:f1:"
+                        + "30:c2:63:c4:58:57:03:c2:cb:87:15:07",
+                "1b:34:61:29:05:0d:73:db:25:d0:dd:64:06:29:f6:8a"),
+        newMacTest("HmacSHA256",
+                BLONG,
+                "e2:4e:a3:b9:0b:b8:99:e4:71:cf:ca:9f:f8:4e:f0:34:8b:19:9f:33:"
+                        + "4b:1a:b7:13:f7:c8:57:92:e3:03:74:78",
+                BKEY),
+        newMacTest("HmacSHA384",
+                ALONG,
+                "d0:f0:d4:54:1c:0a:6d:81:ed:15:20:d7:0c:96:06:61:a0:ff:c9:ff:"
+                        + "91:e9:a0:cd:e2:45:64:9d:93:4c:a9:fa:89:ae:c0:90:e6:"
+                        + "0b:a1:a0:56:80:57:3b:ed:4b:b0:71",
+                "1b:34:61:29:05:0d:73:db:25:d0:dd:64:06:29:f6:8a"),
+        newMacTest("HmacSHA384",
+                BLONG,
+                "75:c4:ca:c7:f7:58:9d:d3:23:b1:1b:5c:93:2d:ec:7a:03:dc:8c:eb:"
+                        + "8d:fe:79:46:4f:30:e7:99:62:de:44:e2:38:95:0e:79:91:"
+                        + "78:2f:a4:05:0a:f0:17:10:38:a1:8e",
+                BKEY),
+        newMacTest("HmacSHA512",
+                ALONG,
+                "41:ea:4c:e5:31:3f:7c:18:0e:5e:95:a9:25:0a:10:58:e6:40:53:88:"
+                        + "82:4f:5a:da:6f:29:de:04:7b:8e:d7:ed:7c:4d:b8:2a:48:"
+                        + "2d:17:2a:2d:59:bb:81:9c:bf:33:40:04:77:44:fb:45:25:"
+                        + "1f:fd:b9:29:f4:a6:69:a3:43:6f",
+                "1b:34:61:29:05:0d:73:db:25:d0:dd:64:06:29:f6:8a"),
+        newMacTest("HmacSHA512",
+                BLONG,
+                "fb:cf:4b:c6:d5:49:5a:5b:0b:d9:2a:32:f5:fa:68:d2:68:a4:0f:ae:"
+                        + "53:fc:49:12:e6:1d:53:cf:b2:cb:c5:c5:f2:2d:86:bd:14:"
+                        + "61:30:c3:a6:6f:44:1f:77:9b:aa:a1:22:48:a9:dd:d0:45:"
+                        + "86:d1:a1:82:53:13:c4:03:06:a3",
+                BKEY),
+
+        // Test vectors From RFC 4231
+        newMacTest("HmacSHA224",
+                bytes("Hi There"),
+                "89:6f:b1:12:8a:bb:df:19:68:32:10:7c:d4:9d:f3:3f:47:b4:b1:16:"
+                        + "99:12:ba:4f:53:68:4b:22",
+                BKEY_20),
+        newMacTest("HmacSHA224",
+                bytes("what do ya want for nothing?"),
+                "a3:0e:01:09:8b:c6:db:bf:45:69:0f:3a:7e:9e:6d:0f:8b:be:a2:a3:"
+                        + "9e:61:48:00:8f:d0:5e:44",
+                bytes("Jefe")),
+        newMacTest("HmacSHA224",
+                DDDATA_50,
+                "7f:b3:cb:35:88:c6:c1:f6:ff:a9:69:4d:7d:6a:d2:64:93:65:b0:c1:"
+                        + "f6:5d:69:d1:ec:83:33:ea",
+                AAKEY_20),
+        newMacTest("HmacSHA224",
+                CDDATA_50,
+                "6c:11:50:68:74:01:3c:ac:6a:2a:bc:1b:b3:82:62:7c:ec:6a:90:d8:"
+                        + "6e:fc:01:2d:e7:af:ec:5a",
+                "01:02:03:04:05:06:07:08:09:0a:0b:0c:0d:0e:0f:10:11:12:13:14:"
+                        + "15:16:17:18:19"),
+        newMacTest("HmacSHA224",
+                bytes("Test Using Larger Than Block-Size Key - Hash Key First"),
+                "95:e9:a0:db:96:20:95:ad:ae:be:9b:2d:6f:0d:bc:e2:d4:99:f1:12:"
+                        + "f2:d2:b7:27:3f:a6:87:0e",
+                AAKEY_131),
+        newMacTest("HmacSHA224",
+                bytes("This is a test using a larger than block-size key and "
+                        + "a larger than block-size data. The key needs to be "
+                        + "hashed before being used by the HMAC algorithm."),
+                "3a:85:41:66:ac:5d:9f:02:3f:54:d5:17:d0:b3:9d:bd:94:67:70:db:"
+                        + "9c:2b:95:c9:f6:f5:65:d1",
+                AAKEY_131),
+    };
+
+    public static void main(String[] args) throws Exception {
+        main(new MacKAT());
+    }
+
+    @Override
+    public void main(Provider p) throws Exception {
+        long start = System.currentTimeMillis();
+
+        List<String> algorithms = getSupportedAlgorithms("Mac", "", p);
+        for (Test test : tests) {
+            if(!algorithms.contains(test.getAlg())) {
+                continue;
+            }
+            test.run(p);
+        }
+
+        System.out.println("All tests passed");
+        long stop = System.currentTimeMillis();
+        System.out.println("Done (" + (stop - start) + " ms).");
+    }
+
+    private static byte[] bytes(String s) {
+        try {
+            return s.getBytes("UTF8");
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    private static Test newMacTest(String alg, byte[] input, String macvalue,
+            String key) {
+        return new MacTest(alg, input, parse(macvalue), parse(key));
+    }
+
+    private static Test newMacTest(String alg, byte[] input, String macvalue,
+            byte[] key) {
+        return new MacTest(alg, input, parse(macvalue), key);
+    }
+
+    interface Test {
+        void run(Provider p) throws Exception;
+        String getAlg();
+    }
+
+    static class MacTest implements Test {
+        private final String alg;
+        private final byte[] input;
+        private final byte[] macvalue;
+        private final byte[] key;
+
+        MacTest(String alg, byte[] input, byte[] macvalue, byte[] key) {
+            this.alg = alg;
+            this.input = input;
+            this.macvalue = macvalue;
+            this.key = key;
+        }
+
+        @Override
+        public String getAlg() {
+            return alg;
+        }
+
+        @Override
+        public void run(Provider p) throws Exception {
+            Mac mac = Mac.getInstance(alg, p);
+            SecretKey keySpec = new SecretKeySpec(key, alg);
+            mac.init(keySpec);
+            mac.update(input);
+            byte[] macv = mac.doFinal();
+            if (Arrays.equals(macvalue, macv) == false) {
+                System.out.println("Mac test for " + alg + " failed:");
+                if (input.length < 256) {
+                    System.out.println("input:       "
+                            + PKCS11Test.toString(input));
+                }
+                System.out.println("key:        " + PKCS11Test.toString(key));
+                System.out.println("macvalue:   "
+                        + PKCS11Test.toString(macvalue));
+                System.out.println("calculated: " + PKCS11Test.toString(macv));
+                throw new Exception("Mac test for " + alg + " failed");
+            }
+            System.out.println("passed: " + alg);
+        }
+    }
+
+}
diff --git a/jdk/test/sun/security/pkcs11/Mac/MacSameTest.java b/jdk/test/sun/security/pkcs11/Mac/MacSameTest.java
new file mode 100644
index 0000000..f5e2787
--- /dev/null
+++ b/jdk/test/sun/security/pkcs11/Mac/MacSameTest.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 1998, 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.
+ *
+ * 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.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.Provider;
+import java.security.SecureRandom;
+import java.util.List;
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+
+/**
+ * @test
+ * @bug 8048603
+ * @summary Check if doFinal and update operation result in same Mac
+ * @author Yu-Ching Valerie Peng, Bill Situ, Alexander Fomin
+ * @library ..
+ * @run main MacSameTest
+ */
+public class MacSameTest extends PKCS11Test {
+
+    private static final int MESSAGE_SIZE = 25;
+    private static final int OFFSET = 5;
+    private static final int KEY_SIZE = 70;
+
+    /**
+     * Initialize a message, instantiate a Mac object,
+     * initialize the object with a SecretKey,
+     * feed the message into the Mac object
+     * all at once and get the output MAC as result1.
+     * Reset the Mac object, chop the message into three pieces,
+     * feed into the Mac object sequentially, and get the output MAC as result2.
+     * Finally, compare result1 and result2 and see if they are the same.
+     *
+     * @param args the command line arguments
+     */
+    public static void main(String[] args) throws Exception {
+        main(new MacSameTest());
+    }
+
+    @Override
+    public void main(Provider p) {
+        List<String> algorithms = getSupportedAlgorithms("Mac", "Hmac", p);
+        boolean success = true;
+        for (String alg : algorithms) {
+            try {
+                doTest(alg, p);
+            } catch (Exception e) {
+                System.out.println("Unexpected exception: " + e);
+                e.printStackTrace();
+                success = false;
+            }
+        }
+
+        if (!success) {
+            throw new RuntimeException("Test failed");
+        }
+    }
+
+    private void doTest(String algo, Provider provider)
+            throws NoSuchAlgorithmException, NoSuchProviderException,
+            InvalidKeyException {
+        System.out.println("Test " + algo);
+        Mac mac;
+        try {
+            mac = Mac.getInstance(algo, provider);
+        } catch (NoSuchAlgorithmException nsae) {
+            if ("SunPKCS11-Solaris".equals(provider.getName())) {
+                // depending on Solaris configuration,
+                // it can support HMAC or not with Mac
+                System.out.println("Expected NoSuchAlgorithmException thrown: "
+                        + nsae);
+                return;
+            }
+            throw nsae;
+        }
+
+        byte[] plain = new byte[MESSAGE_SIZE];
+        for (int i = 0; i < MESSAGE_SIZE; i++) {
+            plain[i] = (byte) (i % 256);
+        }
+
+        byte[] tail = new byte[plain.length - OFFSET];
+        System.arraycopy(plain, OFFSET, tail, 0, tail.length);
+
+        SecureRandom srdm = new SecureRandom();
+        byte[] keyVal = new byte[KEY_SIZE];
+        srdm.nextBytes(keyVal);
+        SecretKeySpec keySpec = new SecretKeySpec(keyVal, "HMAC");
+
+        mac.init(keySpec);
+        byte[] result1 = mac.doFinal(plain);
+
+        mac.reset();
+        mac.update(plain[0]);
+        mac.update(plain, 1, OFFSET - 1);
+        byte[] result2 = mac.doFinal(tail);
+
+        if (!java.util.Arrays.equals(result1, result2)) {
+            throw new RuntimeException("result1 and result2 are not the same");
+        }
+    }
+
+}
diff --git a/jdk/test/sun/security/pkcs11/PKCS11Test.java b/jdk/test/sun/security/pkcs11/PKCS11Test.java
index ca836f0..c8a147a 100644
--- a/jdk/test/sun/security/pkcs11/PKCS11Test.java
+++ b/jdk/test/sun/security/pkcs11/PKCS11Test.java
@@ -578,4 +578,21 @@
         return r;
     }
 
+    /**
+     * Returns supported algorithms of specified type.
+     */
+    static List<String> getSupportedAlgorithms(String type, String alg,
+            Provider p) {
+        // prepare a list of supported algorithms
+        List<String> algorithms = new ArrayList<>();
+        Set<Provider.Service> services = p.getServices();
+        for (Provider.Service service : services) {
+            if (service.getType().equals(type)
+                    && service.getAlgorithm().startsWith(alg)) {
+                algorithms.add(service.getAlgorithm());
+            }
+        }
+        return algorithms;
+    }
+
 }
diff --git a/jdk/test/sun/security/pkcs12/P12SecretKey.java b/jdk/test/sun/security/pkcs12/P12SecretKey.java
new file mode 100644
index 0000000..39f95d5
--- /dev/null
+++ b/jdk/test/sun/security/pkcs12/P12SecretKey.java
@@ -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.
+ */
+
+/*
+ * @test
+ * @bug 8149411
+ * @summary Get AES key from keystore (uses SecretKeySpec not SecretKeyFactory)
+ */
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.security.KeyStore;
+import java.security.cert.CertificateException;
+import java.util.Arrays;
+
+import javax.crypto.KeyGenerator;
+import javax.crypto.SecretKey;
+
+public class P12SecretKey {
+
+    private static final String ALIAS = "alias";
+
+    public static void main(String[] args) throws Exception {
+        P12SecretKey testp12 = new P12SecretKey();
+        String keystoreType = "pkcs12";
+        if (args != null && args.length > 0) {
+            keystoreType = args[0];
+        }
+        testp12.run(keystoreType);
+    }
+
+    private void run(String keystoreType) throws Exception {
+        char[] pw = "password".toCharArray();
+        KeyStore ks = KeyStore.getInstance(keystoreType);
+        ks.load(null, pw);
+
+        KeyGenerator kg = KeyGenerator.getInstance("AES");
+        kg.init(128);
+        SecretKey key = kg.generateKey();
+
+        KeyStore.SecretKeyEntry ske = new KeyStore.SecretKeyEntry(key);
+        KeyStore.ProtectionParameter kspp = new KeyStore.PasswordProtection(pw);
+        ks.setEntry(ALIAS, ske, kspp);
+
+        File ksFile = File.createTempFile("test", ".test");
+        try (FileOutputStream fos = new FileOutputStream(ksFile)) {
+            ks.store(fos, pw);
+            fos.flush();
+        }
+
+        // now see if we can get it back
+        try (FileInputStream fis = new FileInputStream(ksFile)) {
+            KeyStore ks2 = KeyStore.getInstance(keystoreType);
+            ks2.load(fis, pw);
+            KeyStore.Entry entry = ks2.getEntry(ALIAS, kspp);
+            SecretKey keyIn = ((KeyStore.SecretKeyEntry)entry).getSecretKey();
+            if (Arrays.equals(key.getEncoded(), keyIn.getEncoded())) {
+                System.err.println("OK: worked just fine with " + keystoreType +
+                                   " keystore");
+            } else {
+                System.err.println("ERROR: keys are NOT equal after storing in "
+                                   + keystoreType + " keystore");
+            }
+        }
+    }
+}
diff --git a/jdk/test/sun/security/pkcs12/StoreSecretKeyTest.java b/jdk/test/sun/security/pkcs12/StoreSecretKeyTest.java
index 97bc375..1588933 100644
--- a/jdk/test/sun/security/pkcs12/StoreSecretKeyTest.java
+++ b/jdk/test/sun/security/pkcs12/StoreSecretKeyTest.java
@@ -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
@@ -23,8 +23,9 @@
 
 /*
  * @test
- * @bug 8005408 8079129
+ * @bug 8005408 8079129 8048830
  * @summary KeyStore API enhancements
+ * @run main StoreSecretKeyTest
  */
 
 import java.io.*;
@@ -44,9 +45,20 @@
     private static final String CERT = DIR + "/trusted.pem";
     private static final String ALIAS = "my trusted cert";
     private static final String ALIAS2 = "my secret key";
-
+    private enum ALGORITHM {
+        DES(56),
+        DESede(168),
+        AES(128);
+        final int len;
+        ALGORITHM(int l) {
+            len = l;
+        }
+        final int getLength() {
+            return len;
+        }
+    }
     public static void main(String[] args) throws Exception {
-
+        boolean isSecretkeyAlgSupported = false;
         // Skip test if AES is unavailable
         try {
             SecretKeyFactory.getInstance("AES");
@@ -55,57 +67,69 @@
             return;
         }
 
+        for (ALGORITHM alg : ALGORITHM.values()) {
+            isSecretkeyAlgSupported |= testSecretKeyAlgorithm(alg);
+        }
+        if (!isSecretkeyAlgSupported) {
+            throw new Exception("None of the SecretKey algorithms is "
+                    + "supported");
+        }
+    }
+
+    private static boolean testSecretKeyAlgorithm(ALGORITHM algorithm) throws
+            Exception {
+
+        System.out.println("Testing algorithm : " + algorithm.name());
         new File(KEYSTORE).delete();
+        try {
+            KeyStore keystore = KeyStore.getInstance("PKCS12");
+            keystore.load(null, null);
 
-        KeyStore keystore = KeyStore.getInstance("PKCS12");
-        keystore.load(null, null);
-
-        // Set trusted certificate entry
-        Certificate cert = loadCertificate(CERT);
-        keystore.setEntry(ALIAS,
+            // Set trusted certificate entry
+            Certificate cert = loadCertificate(CERT);
+            keystore.setEntry(ALIAS,
             new KeyStore.TrustedCertificateEntry(cert), null);
-
-        // Set secret key entry
-        keystore.setEntry(ALIAS2,
-            new KeyStore.SecretKeyEntry(generateSecretKey("AES", 128)),
+            // Set secret key entry
+            SecretKey secretKey = generateSecretKey(algorithm.name(),
+                    algorithm.len);
+            if(secretKey == null) {
+                return false;
+            }
+            keystore.setEntry(ALIAS2,
+                new KeyStore.SecretKeyEntry(secretKey),
                 new KeyStore.PasswordProtection(PASSWORD));
 
-        try (FileOutputStream outStream = new FileOutputStream(KEYSTORE)) {
-            System.out.println("Storing keystore to: " + KEYSTORE);
-            keystore.store(outStream, PASSWORD);
-        }
+            try (FileOutputStream outStream = new FileOutputStream(KEYSTORE)) {
+                System.out.println("Storing keystore to: " + KEYSTORE);
+                keystore.store(outStream, PASSWORD);
+            }
 
-        try (FileInputStream inStream = new FileInputStream(KEYSTORE)) {
-            System.out.println("Loading keystore from: " + KEYSTORE);
-            keystore.load(inStream, PASSWORD);
-            System.out.println("Loaded keystore with " + keystore.size() +
-                " entries");
-        }
+            try (FileInputStream inStream = new FileInputStream(KEYSTORE)) {
+                System.out.println("Loading keystore from: " + KEYSTORE);
+                keystore.load(inStream, PASSWORD);
+                System.out.println("Loaded keystore with " + keystore.size() +
+                    " entries");
+            }
 
-        KeyStore.Entry entry = keystore.getEntry(ALIAS2,
-            new KeyStore.PasswordProtection(PASSWORD));
-        System.out.println("Retrieved entry: " + entry);
+            KeyStore.Entry entry = keystore.getEntry(ALIAS2,
+                new KeyStore.PasswordProtection(PASSWORD));
+            System.out.println("Retrieved entry: " + entry);
 
-        if (entry instanceof KeyStore.SecretKeyEntry) {
-            System.out.println("Retrieved secret key entry: " + entry);
-        } else {
-            throw new Exception("Not a secret key entry");
+            if (entry instanceof KeyStore.SecretKeyEntry) {
+                System.out.println("Retrieved secret key entry: " + entry);
+            } else {
+                throw new Exception("Not a secret key entry");
+            }
+        } catch (KeyStoreException | UnrecoverableKeyException ex) {
+            System.out.println("Unable to check SecretKey algorithm due to "
+                    + "exception: " + ex.getMessage());
+            return false;
         }
+        return true;
     }
 
     private static SecretKey generateSecretKey(String algorithm, int size)
         throws NoSuchAlgorithmException {
-
-        // Failover to DES if the requested secret key factory is unavailable
-        SecretKeyFactory keyFactory;
-        try {
-            keyFactory = SecretKeyFactory.getInstance(algorithm);
-        } catch (NoSuchAlgorithmException nsae) {
-            keyFactory = SecretKeyFactory.getInstance("DES");
-            algorithm = "DES";
-            size = 56;
-        }
-
         KeyGenerator generator = KeyGenerator.getInstance(algorithm);
         generator.init(size);
         return generator.generateKey();
diff --git a/jdk/test/sun/security/provider/NSASuiteB/TestDSAGenParameterSpec.java b/jdk/test/sun/security/provider/NSASuiteB/TestDSAGenParameterSpec.java
new file mode 100644
index 0000000..43a857f
--- /dev/null
+++ b/jdk/test/sun/security/provider/NSASuiteB/TestDSAGenParameterSpec.java
@@ -0,0 +1,185 @@
+/*
+ * 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.
+ */
+
+import java.security.AlgorithmParameterGenerator;
+import java.security.AlgorithmParameters;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidParameterException;
+import java.security.KeyPairGenerator;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.spec.DSAGenParameterSpec;
+import java.security.spec.DSAParameterSpec;
+import java.security.spec.InvalidParameterSpecException;
+import java.util.Arrays;
+import java.util.List;
+
+/*
+ * @test
+ * @bug 8075286
+ * @summary Verify that DSAGenParameterSpec can and can only be used to generate
+ *          DSA within some certain range of key sizes as described in the class
+ *          specification (L, N) as (1024, 160), (2048, 224), (2048, 256) and
+ *          (3072, 256) should be OK for DSAGenParameterSpec. But the real
+ *          implementation SUN doesn't support (3072, 256).
+ * @run main TestDSAGenParameterSpec
+ */
+public class TestDSAGenParameterSpec {
+
+    private static final String ALGORITHM_NAME = "DSA";
+    private static final String PROVIDER_NAME = "SUN";
+
+    private static final List<DataTuple> DATA = Arrays.asList(
+            new DataTuple(1024, 160, true, true),
+            new DataTuple(2048, 224, true, true),
+            new DataTuple(2048, 256, true, true),
+            new DataTuple(3072, 256, true, false),
+            new DataTuple(1024, 224),
+            new DataTuple(2048, 160),
+            new DataTuple(4096, 256),
+            new DataTuple(512, 160),
+            new DataTuple(3072, 224));
+
+    private static void testDSAGenParameterSpec(DataTuple dataTuple)
+            throws NoSuchAlgorithmException, NoSuchProviderException,
+            InvalidParameterSpecException, InvalidAlgorithmParameterException {
+        System.out.printf("Test case: primePLen=%d, " + "subprimeQLen=%d%n",
+                dataTuple.primePLen, dataTuple.subprimeQLen);
+
+        AlgorithmParameterGenerator apg =
+                AlgorithmParameterGenerator.getInstance(ALGORITHM_NAME,
+                        PROVIDER_NAME);
+
+        DSAGenParameterSpec genParamSpec = createGenParameterSpec(dataTuple);
+        // genParamSpec will be null if IllegalAE is thrown when expected.
+        if (genParamSpec == null) {
+            return;
+        }
+
+        try {
+            apg.init(genParamSpec, null);
+            AlgorithmParameters param = apg.generateParameters();
+
+            checkParam(param, genParamSpec);
+            System.out.println("Test case passed");
+        } catch (InvalidParameterException ipe) {
+            // The DSAGenParameterSpec API support this, but the real
+            // implementation in SUN doesn't
+            if (!dataTuple.isSunProviderSupported) {
+                System.out.println("Test case passed: expected "
+                        + "InvalidParameterException is caught");
+            } else {
+                throw new RuntimeException("Test case failed.", ipe);
+            }
+        }
+    }
+
+    private static void checkParam(AlgorithmParameters param,
+            DSAGenParameterSpec genParam) throws InvalidParameterSpecException,
+                    NoSuchAlgorithmException, NoSuchProviderException,
+                    InvalidAlgorithmParameterException {
+        String algorithm = param.getAlgorithm();
+        if (!algorithm.equalsIgnoreCase(ALGORITHM_NAME)) {
+            throw new RuntimeException(
+                    "Unexpected type of parameters: " + algorithm);
+        }
+
+        DSAParameterSpec spec = param.getParameterSpec(DSAParameterSpec.class);
+        int valueL = spec.getP().bitLength();
+        int strengthP = genParam.getPrimePLength();
+        if (strengthP != valueL) {
+            System.out.printf("P: Expected %d but actual %d%n", strengthP,
+                    valueL);
+            throw new RuntimeException("Wrong P strength");
+        }
+
+        int valueN = spec.getQ().bitLength();
+        int strengthQ = genParam.getSubprimeQLength();
+        if (strengthQ != valueN) {
+            System.out.printf("Q: Expected %d but actual %d%n", strengthQ,
+                    valueN);
+            throw new RuntimeException("Wrong Q strength");
+        }
+
+        if (genParam.getSubprimeQLength() != genParam.getSeedLength()) {
+            System.out.println("Defaut seed length should be the same as Q.");
+            throw new RuntimeException("Wrong seed length");
+        }
+
+        // use the parameters to generate real DSA keys
+        KeyPairGenerator keyGen = KeyPairGenerator.getInstance(ALGORITHM_NAME,
+                PROVIDER_NAME);
+        keyGen.initialize(spec);
+        keyGen.generateKeyPair();
+    }
+
+    private static DSAGenParameterSpec createGenParameterSpec(
+            DataTuple dataTuple) {
+        DSAGenParameterSpec genParamSpec = null;
+        try {
+            genParamSpec = new DSAGenParameterSpec(dataTuple.primePLen,
+                    dataTuple.subprimeQLen);
+            if (!dataTuple.isDSASpecSupported) {
+                throw new RuntimeException(
+                        "Test case failed: the key length must not supported");
+            }
+        } catch (IllegalArgumentException e) {
+            if (!dataTuple.isDSASpecSupported) {
+                System.out.println("Test case passed: expected "
+                        + "IllegalArgumentException is caught");
+            } else {
+                throw new RuntimeException("Test case failed: unexpected "
+                        + "IllegalArgumentException is thrown", e);
+            }
+        }
+
+        return genParamSpec;
+    }
+
+    public static void main(String[] args) throws Exception {
+        for (DataTuple dataTuple : DATA) {
+            testDSAGenParameterSpec(dataTuple);
+        }
+        System.out.println("All tests passed");
+    }
+
+    private static class DataTuple {
+
+        private int primePLen;
+        private int subprimeQLen;
+        private boolean isDSASpecSupported;
+        private boolean isSunProviderSupported;
+
+        private DataTuple(int primePLen, int subprimeQLen,
+                boolean isDSASpecSupported, boolean isSunProviderSupported) {
+            this.primePLen = primePLen;
+            this.subprimeQLen = subprimeQLen;
+            this.isDSASpecSupported = isDSASpecSupported;
+            this.isSunProviderSupported = isSunProviderSupported;
+        }
+
+        private DataTuple(int primePLen, int subprimeQLen) {
+            this(primePLen, subprimeQLen, false, false);
+        }
+    }
+}
diff --git a/jdk/test/sun/security/provider/NSASuiteB/TestSHAOids.java b/jdk/test/sun/security/provider/NSASuiteB/TestSHAOids.java
new file mode 100644
index 0000000..66d72b6
--- /dev/null
+++ b/jdk/test/sun/security/provider/NSASuiteB/TestSHAOids.java
@@ -0,0 +1,103 @@
+/*
+ * 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.
+ */
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.util.Arrays;
+import java.util.List;
+
+/*
+ * @test
+ * @bug 8075286
+ * @summary Test the SHA algorithm OIDs in JDK.
+ *          OID and algorithm transformation string should match.
+ *          Both could be able to be used to generate the algorithm instance.
+ * @run main TestSHAOids
+ */
+public class TestSHAOids {
+
+    private static final String PROVIDER_NAME = "SUN";
+    private static final byte[] INPUT = "1234567890".getBytes();
+
+    private static final List<DataTuple> DATA = Arrays.asList(
+            new DataTuple("2.16.840.1.101.3.4.2.1", "SHA-256"),
+            new DataTuple("2.16.840.1.101.3.4.2.2", "SHA-384"),
+            new DataTuple("2.16.840.1.101.3.4.2.3", "SHA-512"),
+            new DataTuple("2.16.840.1.101.3.4.2.4", "SHA-224"));
+
+    public static void main(String[] args) throws Exception {
+        for (DataTuple dataTuple : DATA) {
+            runTest(dataTuple);
+            System.out.println("passed");
+        }
+        System.out.println("All tests passed");
+    }
+
+    private static void runTest(DataTuple dataTuple)
+            throws NoSuchAlgorithmException, NoSuchProviderException {
+        MessageDigest mdAlgorithm = MessageDigest.getInstance(
+                dataTuple.algorithm, PROVIDER_NAME);
+        MessageDigest mdOid = MessageDigest.getInstance(dataTuple.oid,
+                PROVIDER_NAME);
+
+        if (mdAlgorithm == null) {
+            throw new RuntimeException(String.format(
+                    "Test failed: algorithm string %s getInstance failed.%n",
+                    dataTuple.algorithm));
+        }
+
+        if (mdOid == null) {
+            throw new RuntimeException(
+                    String.format("Test failed: OID %s getInstance failed.%n",
+                            dataTuple.oid));
+        }
+
+        if (!mdAlgorithm.getAlgorithm().equals(dataTuple.algorithm)) {
+            throw new RuntimeException(String.format(
+                    "Test failed: algorithm string %s getInstance doesn't "
+                            + "generate expected algorithm.%n",
+                    dataTuple.algorithm));
+        }
+
+        mdAlgorithm.update(INPUT);
+        mdOid.update(INPUT);
+
+        // Comparison
+        if (!Arrays.equals(mdAlgorithm.digest(), mdOid.digest())) {
+            throw new RuntimeException("Digest comparison failed: "
+                    + "the two digests are not the same");
+        }
+    }
+
+    private static class DataTuple {
+
+        private final String oid;
+        private final String algorithm;
+
+        private DataTuple(String oid, String algorithm) {
+            this.oid = oid;
+            this.algorithm = algorithm;
+        }
+    }
+}
diff --git a/jdk/test/sun/security/provider/NSASuiteB/TestSHAwithDSASignatureOids.java b/jdk/test/sun/security/provider/NSASuiteB/TestSHAwithDSASignatureOids.java
new file mode 100644
index 0000000..dad84cc
--- /dev/null
+++ b/jdk/test/sun/security/provider/NSASuiteB/TestSHAwithDSASignatureOids.java
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+import java.util.Arrays;
+import java.util.List;
+
+/*
+ * @test
+ * @bug 8075286
+ * @summary Test the SHAwithDSA signature algorithm OIDs in JDK.
+ *          OID and algorithm transformation string should match.
+ *          Both could be able to be used to generate the algorithm instance.
+ * @compile ../../TestSignatureOidHelper.java
+ * @run main TestSHAwithDSASignatureOids
+ */
+public class TestSHAwithDSASignatureOids {
+
+    private static final List<OidAlgorithmPair> DATA = Arrays.asList(
+            new OidAlgorithmPair("2.16.840.1.101.3.4.3.1", "SHA224withDSA"),
+            new OidAlgorithmPair("2.16.840.1.101.3.4.3.2", "SHA256withDSA"));
+
+    public static void main(String[] args) throws Exception {
+        TestSignatureOidHelper helper = new TestSignatureOidHelper("DSA",
+                "SUN", 1024, DATA);
+        helper.execute();
+    }
+}
diff --git a/jdk/test/sun/security/rsa/KeySizeTest.java b/jdk/test/sun/security/rsa/KeySizeTest.java
new file mode 100644
index 0000000..35f9902
--- /dev/null
+++ b/jdk/test/sun/security/rsa/KeySizeTest.java
@@ -0,0 +1,130 @@
+/*
+ * 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.
+ */
+
+import java.security.KeyFactory;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.interfaces.RSAKey;
+import java.security.interfaces.RSAPrivateKey;
+import java.security.interfaces.RSAPublicKey;
+import java.security.spec.RSAPrivateKeySpec;
+import java.security.spec.RSAPublicKeySpec;
+
+/**
+ * @test
+ * @bug 8044199
+ * @summary test if the private and public key size are the same as what is set
+ * through KeyPairGenerator.
+ * @run main KeySizeTest 512 10
+ * @run main KeySizeTest 768 10
+ * @run main KeySizeTest 1024 10
+ * @run main KeySizeTest 2048 5
+ * @run main KeySizeTest 4096 1
+ */
+public class KeySizeTest {
+
+    /**
+     * ALGORITHM name, fixed as RSA.
+     */
+    private static final String KEYALG = "RSA";
+
+    /**
+     * JDK default RSA Provider.
+     */
+    private static final String PROVIDER_NAME = "SunRsaSign";
+
+    public static void main(String[] args) throws Exception {
+        int iKeyPairSize = Integer.parseInt(args[0]);
+        int maxLoopCnt = Integer.parseInt(args[1]);
+
+        int failCount = 0;
+        KeyPairGenerator keyPairGen
+                = KeyPairGenerator.getInstance(KEYALG, PROVIDER_NAME);
+        keyPairGen.initialize(iKeyPairSize);
+        // Generate RSA keypair
+        KeyPair keyPair = keyPairGen.generateKeyPair();
+
+        // Get priavte and public keys
+        PrivateKey privateKey = keyPair.getPrivate();
+        PublicKey publicKey = keyPair.getPublic();
+        try {
+            if (!sizeTest(keyPair)) {
+                failCount++;
+            }
+        } catch (Exception ex) {
+            ex.printStackTrace(System.err);
+            failCount++;
+        }
+
+        for (int iCnt = 0; iCnt < maxLoopCnt; iCnt++) {
+
+            // Get keysize (modulus) of keys
+            KeyFactory keyFact = KeyFactory.getInstance(KEYALG, PROVIDER_NAME);
+
+            // Comparing binary length.
+            RSAPrivateKeySpec privateKeySpec
+                    = (RSAPrivateKeySpec) keyFact.getKeySpec(privateKey,
+                            RSAPrivateKeySpec.class);
+            int iPrivateKeySize = privateKeySpec.getModulus().bitLength();
+
+            RSAPublicKeySpec publicKeySpec
+                    = (RSAPublicKeySpec) keyFact.getKeySpec(publicKey,
+                            RSAPublicKeySpec.class);
+            int iPublicKeySize = publicKeySpec.getModulus().bitLength();
+
+            if ((iKeyPairSize != iPublicKeySize) || (iKeyPairSize != iPrivateKeySize)) {
+                System.err.println("iKeyPairSize : " + iKeyPairSize);
+                System.err.println("Generated a " + iPrivateKeySize
+                        + " bit RSA private key");
+                System.err.println("Generated a " + iPublicKeySize
+                        + " bit RSA public key");
+                failCount++;
+            }
+        }
+
+        if (failCount > 0) {
+            throw new RuntimeException("There are " + failCount + " tests failed.");
+        }
+    }
+
+    /**
+     * @param kpair test key pair.
+     * @return true if test passed. false if test failed.
+     */
+    private static boolean sizeTest(KeyPair kpair) {
+        RSAPrivateKey priv = (RSAPrivateKey) kpair.getPrivate();
+        RSAPublicKey pub = (RSAPublicKey) kpair.getPublic();
+
+        // test the getModulus method
+        if ((priv instanceof RSAKey) && (pub instanceof RSAKey)) {
+            if (!priv.getModulus().equals(pub.getModulus())) {
+                System.err.println("priv.getModulus() = " + priv.getModulus());
+                System.err.println("pub.getModulus() = " + pub.getModulus());
+                return false;
+            }
+        }
+        return true;
+    }
+}
diff --git a/jdk/test/sun/security/rsa/PrivateKeyEqualityTest.java b/jdk/test/sun/security/rsa/PrivateKeyEqualityTest.java
new file mode 100644
index 0000000..1a3a6df
--- /dev/null
+++ b/jdk/test/sun/security/rsa/PrivateKeyEqualityTest.java
@@ -0,0 +1,108 @@
+/*
+ * 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.
+ */
+import java.security.KeyFactory;
+import java.security.KeyPairGenerator;
+import java.security.KeyPair;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.interfaces.RSAPrivateCrtKey;
+import java.security.interfaces.RSAPrivateKey;
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.RSAPrivateKeySpec;
+import java.security.spec.PKCS8EncodedKeySpec;
+import java.security.spec.RSAPrivateCrtKeySpec;
+
+/**
+ * @test
+ * @bug 8044199 4666485
+ * @summary Equality checking for RSAPrivateKey by SunRsaSign provider.
+ */
+public class PrivateKeyEqualityTest {
+    /**
+     * ALGORITHM name, fixed as RSA.
+     */
+    private static final String KEYALG = "RSA";
+
+    /**
+     * JDK default RSA Provider.
+     */
+    private static final String PROVIDER_NAME = "SunRsaSign";
+
+    public static void main(String[] args) throws NoSuchAlgorithmException,
+            NoSuchProviderException, InvalidKeySpecException {
+        // Generate the first key.
+        KeyPairGenerator generator
+                = KeyPairGenerator.getInstance(KEYALG, PROVIDER_NAME);
+        KeyPair keyPair = generator.generateKeyPair();
+        RSAPrivateKey rsaPrivateKey = (RSAPrivateKey) keyPair.getPrivate();
+        if (!(rsaPrivateKey instanceof RSAPrivateCrtKey)) {
+            System.err.println("rsaPrivateKey class : " + rsaPrivateKey.getClass().getName());
+            throw new RuntimeException("rsaPrivateKey is not a RSAPrivateCrtKey instance");
+        }
+
+        // Generate the second key.
+        KeyFactory factory = KeyFactory.getInstance(KEYALG, PROVIDER_NAME);
+        RSAPrivateKeySpec rsaPrivateKeySpec = new RSAPrivateKeySpec(
+                rsaPrivateKey.getModulus(), rsaPrivateKey.getPrivateExponent());
+        RSAPrivateKey rsaPrivateKey2 = (RSAPrivateKey) factory.generatePrivate(
+                rsaPrivateKeySpec);
+
+        // Generate the third key.
+        PKCS8EncodedKeySpec encodedKeySpec = new PKCS8EncodedKeySpec(
+                rsaPrivateKey.getEncoded());
+        RSAPrivateKey rsaPrivateKey3 = (RSAPrivateKey) factory.generatePrivate(
+                encodedKeySpec);
+
+        // Check for equality.
+        if (rsaPrivateKey.equals(rsaPrivateKey2)) {
+            throw new RuntimeException("rsaPrivateKey should not equal to rsaPrivateKey2");
+        }
+        if (!rsaPrivateKey3.equals(rsaPrivateKey)) {
+            throw new RuntimeException("rsaPrivateKey3 should equal to rsaPrivateKey");
+        }
+        if (rsaPrivateKey3.equals(rsaPrivateKey2)) {
+            throw new RuntimeException("rsaPrivateKey3 should not equal to rsaPrivateKey2");
+        }
+        if (rsaPrivateKey2.equals(rsaPrivateKey3)) {
+            throw new RuntimeException("rsaPrivateKey2 should not equal to rsaPrivateKey3");
+        }
+
+        // Generate the fourth key.
+        RSAPrivateCrtKey rsaPrivateCrtKey =  (RSAPrivateCrtKey)rsaPrivateKey;
+        RSAPrivateCrtKeySpec rsaPrivateCrtKeySpec = new RSAPrivateCrtKeySpec(
+                rsaPrivateCrtKey.getModulus(),
+                rsaPrivateCrtKey.getPublicExponent(),
+                rsaPrivateCrtKey.getPrivateExponent(),
+                rsaPrivateCrtKey.getPrimeP(),
+                rsaPrivateCrtKey.getPrimeQ(),
+                rsaPrivateCrtKey.getPrimeExponentP(),
+                rsaPrivateCrtKey.getPrimeExponentQ(),
+                rsaPrivateCrtKey.getCrtCoefficient()
+            );
+        RSAPrivateCrtKey rsaPrivateKey4 = (RSAPrivateCrtKey) factory.generatePrivate(
+                rsaPrivateCrtKeySpec);
+        if (!rsaPrivateKey.equals(rsaPrivateKey4)) {
+            throw new RuntimeException("rsaPrivateKey should equal to rsaPrivateKey4");
+        }
+    }
+}
diff --git a/jdk/test/sun/security/rsa/SignatureOffsets.java b/jdk/test/sun/security/rsa/SignatureOffsets.java
new file mode 100644
index 0000000..b813b26
--- /dev/null
+++ b/jdk/test/sun/security/rsa/SignatureOffsets.java
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.SignatureException;
+
+/*
+ * @test
+ * @bug 8050374
+ * @key randomness
+ * @summary This test validates signature verification
+ *          Signature.verify(byte[], int, int). The test uses RandomFactory to
+ *          get random set of clear text data to sign. After the signature
+ *          generation, the test tries to verify signature with the above API
+ *          and passing in different signature offset (0, 33, 66, 99).
+ * @library /lib/testlibrary
+ * @compile ../../../java/security/Signature/Offsets.java
+ * @run main SignatureOffsets SunRsaSign MD2withRSA
+ * @run main SignatureOffsets SunRsaSign MD5withRSA
+ * @run main SignatureOffsets SunRsaSign SHA1withRSA
+ * @run main SignatureOffsets SunRsaSign SHA224withRSA
+ * @run main SignatureOffsets SunRsaSign SHA256withRSA
+ * @run main SignatureOffsets SunRsaSign SHA384withRSA
+ * @run main SignatureOffsets SunRsaSign SHA512withRSA
+ */
+public class SignatureOffsets {
+
+    public static void main(String[] args) throws NoSuchAlgorithmException,
+            InvalidKeyException, SignatureException {
+        Offsets.main(args);
+    }
+}
\ No newline at end of file
diff --git a/jdk/test/sun/security/rsa/SignatureTest.java b/jdk/test/sun/security/rsa/SignatureTest.java
new file mode 100644
index 0000000..0eed4ec
--- /dev/null
+++ b/jdk/test/sun/security/rsa/SignatureTest.java
@@ -0,0 +1,209 @@
+/*
+ * 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.
+ */
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.KeyFactory;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.Signature;
+import java.security.SignatureException;
+import java.security.interfaces.RSAPrivateKey;
+import java.security.interfaces.RSAPublicKey;
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.PKCS8EncodedKeySpec;
+import java.security.spec.RSAPrivateKeySpec;
+import java.security.spec.RSAPublicKeySpec;
+import java.security.spec.X509EncodedKeySpec;
+import java.util.Arrays;
+import static javax.crypto.Cipher.PRIVATE_KEY;
+import static javax.crypto.Cipher.PUBLIC_KEY;
+import jdk.testlibrary.RandomFactory;
+
+/**
+ * @test
+ * @bug 8044199
+ * @summary Create a signature for RSA and get its signed data. re-initiate
+ *          the signature with the public key. The signature can be verified
+ *          by acquired signed data.
+ * @key randomness
+ * @library ../../../lib/testlibrary
+ * @run main SignatureTest MD2withRSA 512
+ * @run main SignatureTest MD5withRSA 512
+ * @run main SignatureTest SHA1withRSA 512
+ * @run main SignatureTest SHA256withRSA 512
+ * @run main SignatureTest MD2withRSA 768
+ * @run main SignatureTest MD5withRSA 768
+ * @run main SignatureTest SHA1withRSA 768
+ * @run main SignatureTest SHA256withRSA 768
+ * @run main SignatureTest MD2withRSA 1024
+ * @run main SignatureTest MD5withRSA 1024
+ * @run main SignatureTest SHA1withRSA 1024
+ * @run main SignatureTest SHA256withRSA 1024
+ * @run main SignatureTest MD2withRSA 2048
+ * @run main SignatureTest MD5withRSA 2048
+ * @run main SignatureTest SHA1withRSA 2048
+ * @run main SignatureTest SHA256withRSA 2048
+ * @run main/timeout=240 SignatureTest MD2withRSA 4096
+ * @run main/timeout=240 SignatureTest MD5withRSA 4096
+ * @run main/timeout=240 SignatureTest SHA1withRSA 4096
+ * @run main/timeout=240 SignatureTest SHA256withRSA 4096
+ * @run main/timeout=240 SignatureTest MD2withRSA 5120
+ * @run main/timeout=240 SignatureTest MD5withRSA 5120
+ * @run main/timeout=240 SignatureTest SHA1withRSA 5120
+ * @run main/timeout=240 SignatureTest SHA256withRSA 5120
+ * @run main/timeout=240 SignatureTest MD2withRSA 6144
+ * @run main/timeout=240 SignatureTest MD5withRSA 6144
+ * @run main/timeout=240 SignatureTest SHA1withRSA 6144
+ * @run main/timeout=240 SignatureTest SHA256withRSA 6144
+ */
+public class SignatureTest {
+    /**
+     * ALGORITHM name, fixed as RSA.
+     */
+    private static final String KEYALG = "RSA";
+
+    /**
+     * JDK default RSA Provider.
+     */
+    private static final String PROVIDER = "SunRsaSign";
+
+    /**
+     * How much times signature updated.
+     */
+    private static final int UPDATE_TIMES_FIFTY = 50;
+
+    /**
+     * How much times signature initial updated.
+     */
+    private static final int UPDATE_TIMES_HUNDRED = 100;
+
+    public static void main(String[] args) throws Exception {
+        String testAlg = args[0];
+        int testSize = Integer.parseInt(args[1]);
+
+        byte[] data = new byte[100];
+        RandomFactory.getRandom().nextBytes(data);
+
+        // create a key pair
+        KeyPair kpair = generateKeys(KEYALG, testSize);
+        Key[] privs = manipulateKey(PRIVATE_KEY, kpair.getPrivate());
+        Key[] pubs = manipulateKey(PUBLIC_KEY, kpair.getPublic());
+        // For signature algorithm, create and verify a signature
+
+        Arrays.stream(privs).forEach(priv
+                -> Arrays.stream(pubs).forEach(pub -> {
+                    try {
+                        checkSignature(data, (PublicKey) pub, (PrivateKey) priv,
+                                testAlg);
+                    } catch (NoSuchAlgorithmException | InvalidKeyException
+                            | SignatureException | NoSuchProviderException ex) {
+                        throw new RuntimeException(ex);
+                    }
+                }
+                ));
+
+    }
+
+    private static KeyPair generateKeys(String keyalg, int size)
+            throws NoSuchAlgorithmException {
+        KeyPairGenerator kpg = KeyPairGenerator.getInstance(keyalg);
+        kpg.initialize(size);
+        return kpg.generateKeyPair();
+    }
+
+    private static Key[] manipulateKey(int type, Key key)
+            throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchProviderException {
+        KeyFactory kf = KeyFactory.getInstance(KEYALG, PROVIDER);
+
+        switch (type) {
+            case PUBLIC_KEY:
+                try {
+                    kf.getKeySpec(key, RSAPrivateKeySpec.class);
+                    throw new RuntimeException("Expected InvalidKeySpecException "
+                            + "not thrown");
+                } catch (InvalidKeySpecException expected) {
+                }
+
+                return new Key[]{
+                    kf.generatePublic(kf.getKeySpec(key, RSAPublicKeySpec.class)),
+                    kf.generatePublic(new X509EncodedKeySpec(key.getEncoded())),
+                    kf.generatePublic(new RSAPublicKeySpec(
+                    ((RSAPublicKey) key).getModulus(),
+                    ((RSAPublicKey) key).getPublicExponent()))
+                };
+            case PRIVATE_KEY:
+                try {
+                    kf.getKeySpec(key, RSAPublicKeySpec.class);
+                    throw new RuntimeException("Expected InvalidKeySpecException"
+                            + " not thrown");
+                } catch (InvalidKeySpecException expected) {
+                }
+                return new Key[]{
+                    kf.generatePrivate(kf.getKeySpec(key,
+                    RSAPrivateKeySpec.class)),
+                    kf.generatePrivate(new PKCS8EncodedKeySpec(
+                    key.getEncoded())),
+                    kf.generatePrivate(new RSAPrivateKeySpec(((RSAPrivateKey) key).getModulus(),
+                    ((RSAPrivateKey) key).getPrivateExponent()))
+                };
+        }
+        throw new RuntimeException("We shouldn't reach here");
+    }
+
+    private static void checkSignature(byte[] data, PublicKey pub,
+            PrivateKey priv, String sigalg) throws NoSuchAlgorithmException,
+            InvalidKeyException, SignatureException, NoSuchProviderException {
+        Signature sig = Signature.getInstance(sigalg, PROVIDER);
+        sig.initSign(priv);
+        for (int i = 0; i < UPDATE_TIMES_HUNDRED; i++) {
+            sig.update(data);
+        }
+        byte[] signedData = sig.sign();
+
+        // Make sure signature verifies with original data
+        sig.initVerify(pub);
+        for (int i = 0; i < UPDATE_TIMES_HUNDRED; i++) {
+            sig.update(data);
+        }
+        if (!sig.verify(signedData)) {
+            throw new RuntimeException("Failed to verify " + sigalg
+                    + " signature");
+        }
+
+        // Make sure signature does NOT verify when the original data
+        // has changed
+        sig.initVerify(pub);
+        for (int i = 0; i < UPDATE_TIMES_FIFTY; i++) {
+            sig.update(data);
+        }
+
+        if (sig.verify(signedData)) {
+            throw new RuntimeException("Failed to detect bad " + sigalg
+                    + " signature");
+        }
+    }
+}
diff --git a/jdk/test/sun/security/rsa/SignedObjectChain.java b/jdk/test/sun/security/rsa/SignedObjectChain.java
new file mode 100644
index 0000000..7bda7cd
--- /dev/null
+++ b/jdk/test/sun/security/rsa/SignedObjectChain.java
@@ -0,0 +1,59 @@
+/*
+ * 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 8050374
+ * @compile ../../../java/security/SignedObject/Chain.java
+ * @summary Verify a chain of signed objects
+ */
+public class SignedObjectChain {
+
+    private static class Test extends Chain.Test {
+
+        public Test(Chain.SigAlg sigAlg) {
+            super(sigAlg, Chain.KeyAlg.RSA, Chain.Provider.SunRsaSign);
+        }
+    }
+
+    private static final Test[] tests = {
+        new Test(Chain.SigAlg.MD2withRSA),
+        new Test(Chain.SigAlg.MD5withRSA),
+        new Test(Chain.SigAlg.SHA1withRSA),
+        new Test(Chain.SigAlg.SHA224withRSA),
+        new Test(Chain.SigAlg.SHA256withRSA),
+        new Test(Chain.SigAlg.SHA384withRSA),
+        new Test(Chain.SigAlg.SHA512withRSA),
+    };
+
+    public static void main(String argv[]) {
+        boolean resutl = java.util.Arrays.stream(tests).allMatch(
+                (test) -> Chain.runTest(test));
+
+        if(resutl) {
+            System.out.println("All tests passed");
+        } else {
+            throw new RuntimeException("Some tests failed");
+        }
+    }
+}
diff --git a/jdk/test/sun/security/rsa/SpecTest.java b/jdk/test/sun/security/rsa/SpecTest.java
new file mode 100644
index 0000000..d2ab0a8
--- /dev/null
+++ b/jdk/test/sun/security/rsa/SpecTest.java
@@ -0,0 +1,119 @@
+/*
+ * 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.
+ */
+import java.math.BigInteger;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.interfaces.RSAKey;
+import java.security.interfaces.RSAPrivateKey;
+import java.security.interfaces.RSAPublicKey;
+import java.security.spec.RSAKeyGenParameterSpec;
+
+/**
+ * @test
+ * @bug 8044199
+ * @summary Check same KeyPair's private key and public key have same modulus.
+ *  also check public key's public exponent equals to given spec's public
+ *  exponent.
+ * @run main SpecTest 512
+ * @run main SpecTest 768
+ * @run main SpecTest 1024
+ * @run main SpecTest 2048
+ * @run main/timeout=240 SpecTest 4096
+ * @run main/timeout=240 SpecTest 5120
+ */
+public class SpecTest {
+    /**
+     * ALGORITHM name, fixed as RSA.
+     */
+    private static final String KEYALG = "RSA";
+
+    /**
+     * JDK default RSA Provider.
+     */
+    private static final String PROVIDER = "SunRsaSign";
+
+    /**
+     *
+     * @param kpair test key pair
+     * @param pubExponent expected public exponent.
+     * @return true if test passed. false if test failed.
+     */
+    private static boolean specTest(KeyPair kpair, BigInteger pubExponent) {
+        boolean passed = true;
+        RSAPrivateKey priv = (RSAPrivateKey) kpair.getPrivate();
+        RSAPublicKey pub = (RSAPublicKey) kpair.getPublic();
+
+        // test the getModulus method
+        if ((priv instanceof RSAKey) && (pub instanceof RSAKey)) {
+            if (!priv.getModulus().equals(pub.getModulus())) {
+                System.err.println("priv.getModulus() = " + priv.getModulus());
+                System.err.println("pub.getModulus() = " + pub.getModulus());
+                passed = false;
+            }
+
+            if (!pubExponent.equals(pub.getPublicExponent())) {
+                System.err.println("pubExponent = " + pubExponent);
+                System.err.println("pub.getPublicExponent() = "
+                        + pub.getPublicExponent());
+                passed = false;
+            }
+        }
+        return passed;
+    }
+
+    public static void main(String[] args) {
+        int failCount = 0;
+
+        // Test key size.
+        int size = Integer.parseInt(args[0]);
+
+        try {
+            KeyPairGenerator kpg1 = KeyPairGenerator.getInstance(KEYALG, PROVIDER);
+            kpg1.initialize(new RSAKeyGenParameterSpec(size,
+                    RSAKeyGenParameterSpec.F4));
+            if (!specTest(kpg1.generateKeyPair(),
+                    RSAKeyGenParameterSpec.F4)) {
+                failCount++;
+            }
+
+            KeyPairGenerator kpg2 = KeyPairGenerator.getInstance(KEYALG, PROVIDER);
+            kpg2.initialize(new RSAKeyGenParameterSpec(size,
+                    RSAKeyGenParameterSpec.F0));
+            if (!specTest(kpg2.generateKeyPair(), RSAKeyGenParameterSpec.F0)) {
+                failCount++;
+            }
+        } catch (NoSuchAlgorithmException | NoSuchProviderException
+                | InvalidAlgorithmParameterException ex) {
+            ex.printStackTrace(System.err);
+            failCount++;
+        }
+
+        if (failCount != 0) {
+            throw new RuntimeException("There are " + failCount
+                    + " tests failed.");
+        }
+    }
+}
diff --git a/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLCtxAccessToSessCtx.java b/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLCtxAccessToSessCtx.java
index 41fddc4..c23951f 100644
--- a/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLCtxAccessToSessCtx.java
+++ b/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLCtxAccessToSessCtx.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, 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
@@ -35,6 +35,7 @@
 import java.net.*;
 import javax.net.ssl.*;
 import java.util.*;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.security.KeyStore;
 
 public class SSLCtxAccessToSessCtx  {
@@ -63,7 +64,7 @@
     /*
      * Is the server ready to serve?
      */
-    volatile static boolean serverReady = false;
+    AtomicInteger serverReady = new AtomicInteger(1);   // only one port now
 
     /*
      * Turn on SSL debugging?
@@ -89,12 +90,13 @@
 
         SSLServerSocket sslServerSocket =
             (SSLServerSocket) sslssf.createServerSocket(serverPort);
-        serverPorts[createdPorts++] = sslServerSocket.getLocalPort();
+        int slot = createdPorts.getAndIncrement();
+        serverPorts[slot] = sslServerSocket.getLocalPort();
 
         /*
          * Signal Client, we're ready for his connect.
          */
-        serverReady = true;
+        serverReady.getAndDecrement();
         int read = 0;
         SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
         InputStream sslIS = sslSocket.getInputStream();
@@ -121,7 +123,7 @@
         /*
          * Wait for server to get started.
          */
-        while (!serverReady) {
+        while (serverReady.get() > 0) {
             Thread.sleep(50);
         }
         /*
@@ -151,8 +153,8 @@
      * The remainder is just support stuff
      */
 
-    volatile int serverPorts[] = new int[]{0};
-    volatile int createdPorts = 0;
+    int serverPorts[] = new int[]{0};           // only one port at present
+    AtomicInteger createdPorts = new AtomicInteger(0);
     static SSLServerSocketFactory sslssf;
     static SSLSocketFactory sslsf;
     static SSLContext sslctx;
@@ -255,14 +257,20 @@
                          */
                         System.err.println("Server died...");
                         e.printStackTrace();
-                        serverReady = true;
+                        serverReady.set(0);
                         serverException = e;
                     }
                 }
             };
             serverThread.start();
         } else {
-            doServerSide(port);
+            try {
+                doServerSide(port);
+            } catch (Exception e) {
+                serverException = e;
+            } finally {
+                serverReady.set(0);
+            }
         }
     }
 
@@ -284,7 +292,11 @@
             };
             clientThread.start();
         } else {
-            doClientSide();
+            try {
+                doClientSide();
+            } catch (Exception e) {
+                clientException = e;
+            }
         }
     }
 }
diff --git a/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SessionCacheSizeTests.java b/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SessionCacheSizeTests.java
index d4e0085..72faf59 100644
--- a/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SessionCacheSizeTests.java
+++ b/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SessionCacheSizeTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2013, 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
@@ -28,7 +28,7 @@
 
 /*
  * @test
- * @bug   4366807
+ * @bug 4366807
  * @summary Need new APIs to get/set session timeout and session cache size.
  * @run main/othervm SessionCacheSizeTests
  */
@@ -108,36 +108,47 @@
 
     void doServerSide(int serverPort, int serverConns) throws Exception {
 
-        SSLServerSocket sslServerSocket =
-            (SSLServerSocket) sslssf.createServerSocket(serverPort);
-        serverPorts[createdPorts++] = sslServerSocket.getLocalPort();
+        try (SSLServerSocket sslServerSocket =
+                (SSLServerSocket) sslssf.createServerSocket(serverPort)) {
 
-        /*
-         * Signal Client, we're ready for his connect.
-         */
-        if (createdPorts == serverPorts.length) {
-            serverReady = true;
-        }
-        int read = 0;
-        int nConnections = 0;
-        /*
-         * Divide the max connections among the available server ports.
-         * The use of more than one server port ensures creation of more
-         * than one session.
-         */
-        SSLSession sessions [] = new SSLSession [serverConns];
-        SSLSessionContext sessCtx = sslctx.getServerSessionContext();
+            // timeout to accept a connection
+            sslServerSocket.setSoTimeout(45000);
 
-        while (nConnections < serverConns) {
-            SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
-            InputStream sslIS = sslSocket.getInputStream();
-            OutputStream sslOS = sslSocket.getOutputStream();
-            read = sslIS.read();
-            sessions[nConnections] = sslSocket.getSession();
-            sslOS.write(85);
-            sslOS.flush();
-            sslSocket.close();
-            nConnections++;
+            // make sure createdPorts++ is atomic
+            synchronized(serverPorts) {
+                serverPorts[createdPorts++] = sslServerSocket.getLocalPort();
+
+                /*
+                 * Signal Client, we're ready for his connect.
+                 */
+                if (createdPorts == serverPorts.length) {
+                    serverReady = true;
+                }
+            }
+            int read = 0;
+            int nConnections = 0;
+
+            /*
+             * Divide the max connections among the available server ports.
+             * The use of more than one server port ensures creation of more
+             * than one session.
+             */
+            SSLSession sessions [] = new SSLSession [serverConns];
+            SSLSessionContext sessCtx = sslctx.getServerSessionContext();
+
+            while (nConnections < serverConns) {
+                try (SSLSocket sslSocket =
+                        (SSLSocket)sslServerSocket.accept()) {
+                    sslSocket.setSoTimeout(90000);      // timeout to read
+                    InputStream sslIS = sslSocket.getInputStream();
+                    OutputStream sslOS = sslSocket.getOutputStream();
+                    read = sslIS.read();
+                    sessions[nConnections] = sslSocket.getSession();
+                    sslOS.write(85);
+                    sslOS.flush();
+                    nConnections++;
+                }
+            }
         }
     }
 
@@ -263,8 +274,8 @@
      * Using four ports (one per each connection), we are able to create
      * alteast four sessions.
      */
-    volatile int serverPorts[] = new int[]{0, 0, 0, 0};
-    volatile int createdPorts = 0;
+    int serverPorts[] = new int[]{0, 0, 0, 0};  // MAX_ACTIVE_CONNECTIONS: 4
+    int createdPorts = 0;
     static SSLServerSocketFactory sslssf;
     static SSLSocketFactory sslsf;
     static SSLContext sslctx;
diff --git a/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SessionTimeOutTests.java b/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SessionTimeOutTests.java
index 9264cb0..0c88722 100644
--- a/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SessionTimeOutTests.java
+++ b/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SessionTimeOutTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2013, 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
@@ -36,6 +36,7 @@
 import javax.net.ssl.*;
 import java.util.*;
 import java.security.*;
+import java.util.concurrent.atomic.AtomicInteger;
 
 /**
  * Session reuse time-out tests cover the cases below:
@@ -79,7 +80,7 @@
     /*
      * Is the server ready to serve?
      */
-    volatile static int serverReady = PORTS;
+    AtomicInteger serverReady = new AtomicInteger(PORTS);
 
     /*
      * Turn on SSL debugging?
@@ -98,7 +99,7 @@
     /*
      * Define the server side of the test.
      *
-     * If the server prematurely exits, serverReady will be set to true
+     * If the server prematurely exits, serverReady will be set to zero
      * to avoid infinite hangs.
      */
 
@@ -111,12 +112,13 @@
 
         SSLServerSocket sslServerSocket =
             (SSLServerSocket) sslssf.createServerSocket(serverPort);
-        serverPorts[createdPorts++] = sslServerSocket.getLocalPort();
+        int slot = createdPorts.getAndIncrement();
+        serverPorts[slot] = sslServerSocket.getLocalPort();
 
         /*
          * Signal Client, we're ready for his connect.
          */
-        serverReady--;
+        serverReady.getAndDecrement();
         int read = 0;
         int nConnections = 0;
         SSLSession sessions [] = new SSLSession [serverConns];
@@ -137,7 +139,7 @@
     /*
      * Define the client side of the test.
      *
-     * If the server prematurely exits, serverReady will be set to true
+     * If the server prematurely exits, serverReady will be set to zero
      * to avoid infinite hangs.
      */
     void doClientSide() throws Exception {
@@ -145,7 +147,7 @@
         /*
          * Wait for server to get started.
          */
-        while (serverReady > 0) {
+        while (serverReady.get() > 0) {
             Thread.sleep(50);
         }
 
@@ -287,8 +289,8 @@
      * The remainder is just support stuff
      */
 
-    volatile int serverPorts[] = new int[PORTS];
-    volatile int createdPorts = 0;
+    int serverPorts[] = new int[PORTS];
+    AtomicInteger createdPorts = new AtomicInteger(0);
     static SSLServerSocketFactory sslssf;
     static SSLSocketFactory sslsf;
     static SSLContext sslctx;
@@ -447,7 +449,7 @@
                          */
                         System.err.println("Server died...");
                         e.printStackTrace();
-                        serverReady = 0;
+                        serverReady.set(0);
                         serverException = e;
                     }
                 }
@@ -459,7 +461,7 @@
             } catch (Exception e) {
                 serverException = e;
             } finally {
-                serverReady = 0;
+                serverReady.set(0);
             }
         }
     }
diff --git a/jdk/test/sun/security/ssl/rsa/SignatureOffsets.java b/jdk/test/sun/security/ssl/rsa/SignatureOffsets.java
new file mode 100644
index 0000000..618dde7
--- /dev/null
+++ b/jdk/test/sun/security/ssl/rsa/SignatureOffsets.java
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.SignatureException;
+
+/*
+ * @test
+ * @bug 8050374
+ * @key randomness
+ * @summary This test validates signature verification
+ *          Signature.verify(byte[], int, int). The test uses RandomFactory to
+ *          get random set of clear text data to sign. After the signature
+ *          generation, the test tries to verify signature with the above API
+ *          and passing in different signature offset (0, 33, 66, 99).
+ * @library /lib/testlibrary
+ * @compile ../../../../java/security/Signature/Offsets.java
+ * @run main SignatureOffsets SunJSSE MD2withRSA
+ * @run main SignatureOffsets SunJSSE MD5withRSA
+ * @run main SignatureOffsets SunJSSE SHA1withRSA
+ * @run main SignatureOffsets SunJSSE MD5andSHA1withRSA
+ */
+public class SignatureOffsets {
+
+    public static void main(String[] args) throws NoSuchAlgorithmException,
+            InvalidKeyException, SignatureException {
+        Offsets.main(args);
+    }
+}
\ No newline at end of file
diff --git a/jdk/test/sun/security/ssl/rsa/SignedObjectChain.java b/jdk/test/sun/security/ssl/rsa/SignedObjectChain.java
new file mode 100644
index 0000000..ba4b00c
--- /dev/null
+++ b/jdk/test/sun/security/ssl/rsa/SignedObjectChain.java
@@ -0,0 +1,56 @@
+/*
+ * 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 8050374
+ * @compile ../../../../java/security/SignedObject/Chain.java
+ * @summary Verify a chain of signed objects
+ */
+public class SignedObjectChain {
+
+    private static class Test extends Chain.Test {
+
+        public Test(Chain.SigAlg sigAlg) {
+            super(sigAlg, Chain.KeyAlg.RSA, Chain.Provider.SunJSSE);
+        }
+    }
+
+    private static final Test[] tests = {
+        new Test(Chain.SigAlg.MD2withRSA),
+        new Test(Chain.SigAlg.MD5withRSA),
+        new Test(Chain.SigAlg.SHA1withRSA),
+        new Test(Chain.SigAlg.MD5andSHA1withRSA),
+    };
+
+    public static void main(String argv[]) {
+        boolean resutl = java.util.Arrays.stream(tests).allMatch(
+                (test) -> Chain.runTest(test));
+
+        if(resutl) {
+            System.out.println("All tests passed");
+        } else {
+            throw new RuntimeException("Some tests failed");
+        }
+    }
+}
diff --git a/jdk/test/sun/security/x509/X509CertImpl/V3Certificate.java b/jdk/test/sun/security/x509/X509CertImpl/V3Certificate.java
new file mode 100644
index 0000000..57e96de
--- /dev/null
+++ b/jdk/test/sun/security/x509/X509CertImpl/V3Certificate.java
@@ -0,0 +1,259 @@
+/*
+ * 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.
+ */
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import static java.lang.System.out;
+import java.security.InvalidKeyException;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.Signature;
+import java.security.SignatureException;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.TimeZone;
+import sun.misc.BASE64Encoder;
+import sun.security.util.BitArray;
+import sun.security.util.ObjectIdentifier;
+import sun.security.x509.*;
+
+/**
+ * @test
+ * @bug 8049237
+ * @summary This test generates V3 certificate with all the supported
+ * extensions. Writes back the generated certificate in to a file and checks for
+ * equality with the original certificate.
+ */
+public class V3Certificate {
+
+    public static final String V3_FILE = "certV3";
+    public static final String V3_B64_FILE = "certV3.b64";
+
+    public static void main(String[] args) throws IOException,
+            NoSuchAlgorithmException, InvalidKeyException, CertificateException,
+            NoSuchProviderException, SignatureException {
+
+        boolean success = true;
+
+        success &= test("RSA", "SHA256withRSA", 2048);
+        success &= test("DSA", "SHA256withDSA", 2048);
+        success &= test("EC", "SHA256withECDSA", 384);
+
+        if (!success) {
+            throw new RuntimeException("At least one test case failed");
+        }
+    }
+
+    public static boolean test(String algorithm, String sigAlg, int keyLength)
+            throws IOException,
+            NoSuchAlgorithmException,
+            InvalidKeyException,
+            CertificateException,
+            NoSuchProviderException,
+            SignatureException {
+
+        byte[] issuerId = {1, 2, 3, 4, 5};
+        byte[] subjectId = {6, 7, 8, 9, 10};
+        boolean testResult = true;
+
+        // Subject and Issuer
+        X500Name subject = new X500Name("test", "Oracle", "Santa Clara",
+                "US");
+        X500Name issuer = subject;
+
+        // Generate keys and sign
+        KeyPairGenerator keyGen = KeyPairGenerator.getInstance(algorithm);
+        keyGen.initialize(keyLength);
+        KeyPair pair = keyGen.generateKeyPair();
+        PublicKey publicKey = pair.getPublic();
+        PrivateKey privateKey = pair.getPrivate();
+        MessageDigest md = MessageDigest.getInstance("SHA");
+        byte[] keyId = md.digest(publicKey.getEncoded());
+
+        Signature signature = Signature.getInstance(sigAlg);
+        signature.initSign(privateKey);
+
+        // Validity interval
+        Date firstDate = new Date();
+        Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("PST"));
+        cal.set(2014, 03, 10, 12, 30, 30);
+        Date lastDate = cal.getTime();
+        CertificateValidity interval = new CertificateValidity(firstDate,
+                lastDate);
+
+        // Certificate Info
+        X509CertInfo cert = new X509CertInfo();
+
+        cert.set(X509CertInfo.VERSION,
+                new CertificateVersion(CertificateVersion.V3));
+        cert.set(X509CertInfo.SERIAL_NUMBER,
+                new CertificateSerialNumber((int) (firstDate.getTime() / 1000)));
+        cert.set(X509CertInfo.ALGORITHM_ID,
+                new CertificateAlgorithmId(AlgorithmId.get(sigAlg)));
+        cert.set(X509CertInfo.SUBJECT, subject);
+        cert.set(X509CertInfo.KEY, new CertificateX509Key(publicKey));
+        cert.set(X509CertInfo.VALIDITY, interval);
+        cert.set(X509CertInfo.ISSUER, issuer);
+
+        cert.set(X509CertInfo.ISSUER_ID,
+                new UniqueIdentity(
+                        new BitArray(issuerId.length * 8 - 2, issuerId)));
+        cert.set(X509CertInfo.SUBJECT_ID, new UniqueIdentity(subjectId));
+
+        // Create Extensions
+        CertificateExtensions exts = new CertificateExtensions();
+
+        GeneralNameInterface mailInf = new RFC822Name("test@Oracle.com");
+        GeneralName mail = new GeneralName(mailInf);
+        GeneralNameInterface dnsInf = new DNSName("Oracle.com");
+        GeneralName dns = new GeneralName(dnsInf);
+        GeneralNameInterface uriInf = new URIName("http://www.Oracle.com");
+        GeneralName uri = new GeneralName(uriInf);
+
+        // localhost
+        byte[] address = new byte[]{127, 0, 0, 1};
+
+        GeneralNameInterface ipInf = new IPAddressName(address);
+        GeneralName ip = new GeneralName(ipInf);
+        int[] oidData = new int[]{1, 2, 3, 4};
+
+        GeneralNameInterface oidInf = new OIDName(new ObjectIdentifier(oidData));
+        GeneralName oid = new GeneralName(oidInf);
+
+        SubjectAlternativeNameExtension subjectName
+                = new SubjectAlternativeNameExtension();
+        IssuerAlternativeNameExtension issuerName
+                = new IssuerAlternativeNameExtension();
+
+        GeneralNames subjectNames
+                = (GeneralNames) subjectName.
+                get(SubjectAlternativeNameExtension.SUBJECT_NAME);
+
+        GeneralNames issuerNames
+                = (GeneralNames) issuerName.
+                get(IssuerAlternativeNameExtension.ISSUER_NAME);
+
+        subjectNames.add(mail);
+        subjectNames.add(dns);
+        subjectNames.add(uri);
+
+        issuerNames.add(ip);
+        issuerNames.add(oid);
+
+        cal.set(2000, 11, 15, 12, 30, 30);
+        lastDate = cal.getTime();
+        PrivateKeyUsageExtension pkusage
+                = new PrivateKeyUsageExtension(firstDate, lastDate);
+
+        KeyUsageExtension usage = new KeyUsageExtension();
+        usage.set(KeyUsageExtension.CRL_SIGN, true);
+        usage.set(KeyUsageExtension.DIGITAL_SIGNATURE, true);
+        usage.set(KeyUsageExtension.NON_REPUDIATION, true);
+
+        KeyIdentifier kid = new KeyIdentifier(keyId);
+        SerialNumber sn = new SerialNumber(42);
+        AuthorityKeyIdentifierExtension aki
+                = new AuthorityKeyIdentifierExtension(kid, subjectNames, sn);
+
+        SubjectKeyIdentifierExtension ski
+                = new SubjectKeyIdentifierExtension(keyId);
+
+        BasicConstraintsExtension cons
+                = new BasicConstraintsExtension(true, 10);
+
+        PolicyConstraintsExtension pce = new PolicyConstraintsExtension(2, 4);
+
+        exts.set(SubjectAlternativeNameExtension.NAME, subjectName);
+        exts.set(IssuerAlternativeNameExtension.NAME, issuerName);
+        exts.set(PrivateKeyUsageExtension.NAME, pkusage);
+        exts.set(KeyUsageExtension.NAME, usage);
+        exts.set(AuthorityKeyIdentifierExtension.NAME, aki);
+        exts.set(SubjectKeyIdentifierExtension.NAME, ski);
+        exts.set(BasicConstraintsExtension.NAME, cons);
+        exts.set(PolicyConstraintsExtension.NAME, pce);
+        cert.set(X509CertInfo.EXTENSIONS, exts);
+
+        // Generate and sign X509CertImpl
+        X509CertImpl crt = new X509CertImpl(cert);
+        crt.sign(privateKey, sigAlg);
+        crt.verify(publicKey);
+
+        try (FileOutputStream fos = new FileOutputStream(new File(V3_FILE));
+                FileOutputStream fos_b64
+                = new FileOutputStream(new File(V3_B64_FILE));
+                PrintWriter pw = new PrintWriter(fos_b64)) {
+            crt.encode((OutputStream) fos);
+            fos.flush();
+
+            // Certificate boundaries/
+            pw.println("-----BEGIN CERTIFICATE-----");
+            pw.flush();
+            new BASE64Encoder().encodeBuffer(crt.getEncoded(), fos_b64);
+            fos_b64.flush();
+            pw.println("-----END CERTIFICATE-----");
+        }
+
+        out.println("*** Certificate ***");
+        out.println(crt);
+        out.println("*** End Certificate ***");
+
+        X509Certificate x2 = generateCertificate(V3_FILE);
+        if (!x2.equals(crt)) {
+            out.println("*** Certificate mismatch ***");
+            testResult = false;
+        }
+
+        X509Certificate x3 = generateCertificate(V3_B64_FILE);
+        if (!x3.equals(crt)) {
+            out.println("*** Certificate mismatch ***");
+            testResult = false;
+        }
+
+        return testResult;
+    }
+
+    static X509Certificate generateCertificate(String certFile) {
+        try (InputStream inStrm = new FileInputStream(certFile)) {
+            CertificateFactory cf = CertificateFactory.getInstance("X509");
+            X509Certificate x2
+                    = (X509Certificate) cf.generateCertificate(inStrm);
+            return x2;
+        } catch (CertificateException | IOException e) {
+            throw new RuntimeException("Exception while "
+                    + "genrating certificate for " + certFile, e);
+        }
+    }
+}
diff --git a/jdk/test/sun/tools/jcmd/TestJcmdDefaults.java b/jdk/test/sun/tools/jcmd/TestJcmdDefaults.java
new file mode 100644
index 0000000..a531086
--- /dev/null
+++ b/jdk/test/sun/tools/jcmd/TestJcmdDefaults.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2011, 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.
+ *
+ * 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 static jdk.testlibrary.Asserts.*;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+import jdk.testlibrary.JcmdBase;
+import jdk.testlibrary.OutputAnalyzer;
+import jdk.testlibrary.Utils;
+
+/**
+ * Unit test for jcmd utility. Tests jcmd options which do not send
+ * requests to a specific JVM process.
+ */
+/*
+ * @test
+ * @bug 7104647
+ * @library /lib/testlibrary
+ * @run main TestJcmdDefaults
+ */
+public class TestJcmdDefaults {
+
+    private static final String TEST_SRC = System.getProperty("test.src").trim();
+    private static final String[] VM_ARGS = new String[] { "-XX:+UsePerfData" };
+    private static final String JCMD_LIST_REGEX = "^\\d+\\s*.*";
+
+    public static void main(String[] args) throws Exception {
+        testJcmdUsage("-h");
+        testJcmdUsage("-help");
+        testJcmdDefaults();
+        testJcmdDefaults("-l");
+    }
+
+    /**
+     * jcmd -J-XX:+UsePerfData -h
+     * jcmd -J-XX:+UsePerfData -help
+     */
+    private static void testJcmdUsage(String... jcmdArgs) throws Exception {
+        OutputAnalyzer output = JcmdBase.jcmdNoPid(VM_ARGS, jcmdArgs);
+
+        assertNotEquals(output.getExitValue(), 0);
+        verifyOutputAgainstFile(output);
+    }
+
+    /**
+     * jcmd -J-XX:+UsePerfData
+     * jcmd -J-XX:+UsePerfData -l
+     */
+    private static void testJcmdDefaults(String... jcmdArgs) throws Exception {
+        OutputAnalyzer output = JcmdBase.jcmdNoPid(VM_ARGS, jcmdArgs);
+
+        output.shouldHaveExitValue(0);
+        output.shouldContain("sun.tools.jcmd.JCmd");
+        matchListedProcesses(output);
+    }
+
+    /**
+     * Verifies the listed processes match a certain pattern.
+     *
+     * The output should look like:
+     * 12246 sun.tools.jcmd.JCmd
+     * 24428 com.sun.javatest.regtest.MainWrapper /tmp/jtreg/jtreg-workdir/classes/sun/tools/jcmd/TestJcmdDefaults.jta
+     *
+     * @param output The generated output from the jcmd.
+     * @throws Exception
+     */
+    private static void matchListedProcesses(OutputAnalyzer output) throws Exception {
+        int matchedCount = output.shouldMatchByLine(JCMD_LIST_REGEX);
+        assertGreaterThan(matchedCount , 0,
+                "Found no lines matching pattern: " + JCMD_LIST_REGEX);
+    }
+
+    private static void verifyOutputAgainstFile(OutputAnalyzer output) throws IOException {
+        File file = new File(TEST_SRC, "usage.out");
+        List<String> fileOutput = Utils.fileAsList(file);
+        List<String> outputAsLines = output.asLines();
+        assertTrue(outputAsLines.containsAll(fileOutput),
+                "The ouput should contain all content of " + file.getAbsolutePath());
+    }
+
+}
diff --git a/jdk/test/sun/tools/jcmd/TestJcmdSanity.java b/jdk/test/sun/tools/jcmd/TestJcmdSanity.java
new file mode 100644
index 0000000..b25c4c5
--- /dev/null
+++ b/jdk/test/sun/tools/jcmd/TestJcmdSanity.java
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2011, 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.
+ *
+ * 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 static jdk.testlibrary.Asserts.*;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+import jdk.testlibrary.JcmdBase;
+import jdk.testlibrary.OutputAnalyzer;
+import jdk.testlibrary.ProcessTools;
+import jdk.testlibrary.Utils;
+
+/**
+ * Unit test for jcmd utility. The test will send different diagnostic command
+ * requests to the current java process.
+ */
+/*
+ * @test
+ * @bug 7104647 7154822
+ * @library /lib/testlibrary
+ * @run main TestJcmdSanity
+ */
+public class TestJcmdSanity {
+
+    private static final String TEST_SRC = System.getProperty("test.src").trim();
+    private static final String[] VM_ARGS = new String[] { "-XX:+UsePerfData" };
+    private static final String JCMD_COMMAND_REGEX = "(\\w|\\.)*";
+    private static final String PERF_COUNTER_REGEX = "(\\w|\\.)*\\=.*";
+
+    public static void main(String[] args) throws Exception {
+        testJcmdPidHelp();
+        testJcmdPidHelpHelp();
+        testJcmdPid_f();
+        testJcmdPidPerfCounterPrint();
+        testJcmdPidBigScript();
+    }
+
+    /**
+     * jcmd -J-XX:+UsePerfData pid help
+     */
+    private static void testJcmdPidHelp() throws Exception {
+        OutputAnalyzer output = JcmdBase.jcmd(VM_ARGS,
+                new String[] {"help"});
+        output.shouldHaveExitValue(0);
+        output.shouldNotContain("Exception");
+        output.shouldContain(Integer.toString(ProcessTools.getProcessId()) + ":");
+        matchJcmdCommands(output);
+        output.shouldContain("For more information about a specific command use 'help <command>'.");
+    }
+
+    /**
+     * jcmd -J-XX:+UsePerfData pid help help
+     */
+    private static void testJcmdPidHelpHelp() throws Exception {
+        OutputAnalyzer output = JcmdBase.jcmd(VM_ARGS,
+                new String[] {"help", "help"});
+
+        output.shouldHaveExitValue(0);
+        verifyOutputAgainstFile(output);
+    }
+
+    /**
+     * jcmd -J-XX:+UsePerfData pid PerfCounter.print
+     */
+    private static void testJcmdPidPerfCounterPrint() throws Exception {
+        OutputAnalyzer output = JcmdBase.jcmd(VM_ARGS,
+                new String[] {"PerfCounter.print"});
+
+        output.shouldHaveExitValue(0);
+        matchPerfCounters(output);
+    }
+
+    /**
+     * jcmd -J-XX:+UsePerfData pid -f dcmd-script.txt
+     */
+    private static void testJcmdPid_f() throws Exception {
+        File scrpitFile = new File(TEST_SRC, "dcmd-script.txt");
+        OutputAnalyzer output = JcmdBase.jcmd(VM_ARGS,
+                new String[] {"-f", scrpitFile.getAbsolutePath()});
+
+        output.shouldHaveExitValue(0);
+        verifyOutputAgainstFile(output);
+    }
+
+    /**
+     * Tests that it possible send a file over 1024 bytes large via jcmd -f.
+     *
+     * jcmd -J-XX:+UsePerfData pid -f dcmd-big-script.txt
+     */
+    private static void testJcmdPidBigScript() throws Exception {
+        File scrpitFile = new File(TEST_SRC, "dcmd-big-script.txt");
+        OutputAnalyzer output = JcmdBase.jcmd(VM_ARGS,
+                new String[] {"-f", scrpitFile.getAbsolutePath()});
+
+        output.shouldHaveExitValue(0);
+        output.shouldNotContain("Exception");
+        output.shouldContain(System.getProperty("java.vm.name").trim());
+    }
+
+    /**
+     * Verifies the listed jcmd commands match a certain pattern.
+     *
+     * The output of the jcmd commands should look like:
+     * VM.uptime
+     * VM.flags
+     * VM.system_properties
+     *
+     * @param output The generated output from the jcmd.
+     * @throws Exception
+     */
+    private static void matchJcmdCommands(OutputAnalyzer output) throws Exception {
+        int matchedCount = output.shouldMatchByLine(JCMD_COMMAND_REGEX,
+                "help",
+                JCMD_COMMAND_REGEX);
+        assertGreaterThan(matchedCount , 0,
+                "Found no lines matching pattern: " + JCMD_COMMAND_REGEX);
+    }
+
+    /**
+     * Verifies the generated output from the PerfCounter.print command
+     * matches a certain pattern.
+     *
+     * The output of perf counters should look like:
+     * java.property.java.vm.name="Java HotSpot(TM) 64-Bit Server VM"
+     * java.threads.daemon=7
+     * sun.rt.javaCommand="com.sun.javatest.regtest.MainWrapper /tmp/jtreg/jtreg-workdir/classes/sun/tools/jcmd/TestJcmdSanity.jta"
+     *
+     * @param output The generated output from the PerfCounter.print command.
+     * @throws Exception
+     */
+    private static void matchPerfCounters(OutputAnalyzer output) throws Exception {
+        int matchedCount = output.shouldMatchByLineFrom(PERF_COUNTER_REGEX,
+                PERF_COUNTER_REGEX);
+        assertGreaterThan(matchedCount , 0,
+                "Found no lines matching pattern: " + PERF_COUNTER_REGEX);
+    }
+
+    private static void verifyOutputAgainstFile(OutputAnalyzer output) throws IOException {
+        File file = new File(TEST_SRC, "help_help.out");
+        List<String> fileOutput = Utils.fileAsList(file);
+        List<String> outputAsLines = output.asLines();
+        assertTrue(outputAsLines.containsAll(fileOutput),
+                "The ouput should contain all content of " + file.getAbsolutePath());
+    }
+
+}
diff --git a/jdk/test/sun/tools/jcmd/help_help.out b/jdk/test/sun/tools/jcmd/help_help.out
index beaf0f3..3f151b9 100644
--- a/jdk/test/sun/tools/jcmd/help_help.out
+++ b/jdk/test/sun/tools/jcmd/help_help.out
@@ -1,7 +1,7 @@
 help
 For more information about a specific command use 'help <command>'. With no argument this will show a list of available commands. 'help all' will show help for all commands.
 
-Impact: Low 
+Impact: Low
 
 Syntax : help [options] [<command name>]
 
diff --git a/jdk/test/sun/tools/jcmd/jcmd-Defaults.sh b/jdk/test/sun/tools/jcmd/jcmd-Defaults.sh
deleted file mode 100644
index 2d6aa2e..0000000
--- a/jdk/test/sun/tools/jcmd/jcmd-Defaults.sh
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 7104647
-# @run shell jcmd-Defaults.sh
-# @summary Test that output of 'jcmd' and 'jcmd -l' match a specific pattern
-
-JCMD="${TESTJAVA}/bin/jcmd"
-
-${JCMD} -J-XX:+UsePerfData 2>&1 | awk -f ${TESTSRC}/jcmd_Output1.awk
-
-${JCMD} -J-XX:+UsePerfData -l 2>&1 | awk -f ${TESTSRC}/jcmd_Output1.awk
diff --git a/jdk/test/sun/tools/jcmd/jcmd-big-script.sh b/jdk/test/sun/tools/jcmd/jcmd-big-script.sh
deleted file mode 100644
index a101c8c..0000000
--- a/jdk/test/sun/tools/jcmd/jcmd-big-script.sh
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-
-# @test
-# @bug 7154822
-# @summary test if we can send a file over 1024 bytes large via jcmd -f
-# @author David Buck
-#
-# @library ../common
-# @build SimpleApplication ShutdownSimpleApplication
-# @run shell jcmd-big-script.sh
-
-. ${TESTSRC}/../common/CommonSetup.sh
-. ${TESTSRC}/../common/ApplicationSetup.sh
-
-# Start application and use PORTFILE for coordination
-PORTFILE="${TESTCLASSES}"/shutdown.port
-startApplication SimpleApplication "${PORTFILE}"
-
-failed=0;
-
-# -f <script>
-rm -f jcmd.out 2>/dev/null
-set +e # even if jcmd fails, we do not want abort the script yet.
-${JCMD} -J-XX:+UsePerfData $appJavaPid -f ${TESTSRC}/dcmd-big-script.txt > jcmd.out 2>&1
-status="$?"
-set -e
-if [ "$status" != 0 ]; then
-  echo "jcmd command returned non-zero exit code (status=$status). Failed."
-  failed=1;
-fi
-cat jcmd.out
-set +e # if the test passes, grep will "fail" with an exit code of 1
-grep Exception jcmd.out > /dev/null 2>&1
-status="$?"
-set -e
-if [ "$status" = 0 ]; then
-  echo "Output of \"jcmd [pid] -f dcmd-big-script.txt\" contains string \"Exception\". Failed."
-  failed=1;
-fi
-
-# clean up
-rm -f jcmd.out 2>/dev/null
-stopApplication "${PORTFILE}"
-waitForApplication
-
-exit $failed
diff --git a/jdk/test/sun/tools/jcmd/jcmd-f.sh b/jdk/test/sun/tools/jcmd/jcmd-f.sh
deleted file mode 100644
index ad73bc7..0000000
--- a/jdk/test/sun/tools/jcmd/jcmd-f.sh
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-
-# @test
-# @bug 7104647
-# @summary Unit test for jcmd utility
-#
-# @library ../common
-# @build SimpleApplication ShutdownSimpleApplication
-# @run shell jcmd-f.sh
-
-. ${TESTSRC}/../common/CommonSetup.sh
-. ${TESTSRC}/../common/ApplicationSetup.sh
-
-# Start application and use PORTFILE for coordination
-PORTFILE="${TESTCLASSES}"/shutdown.port
-startApplication SimpleApplication "${PORTFILE}"
-
-# all return statuses are checked in this test
-set +e
-
-failed=0
-
-# -f <script>
-rm -f jcmd.out 2>/dev/null
-${JCMD} -J-XX:+UsePerfData $appJavaPid -f ${TESTSRC}/dcmd-script.txt | awk '{ if (NR>1) print $0;}' > jcmd.out 2>&1
-echo jcmd.out
-diff -w jcmd.out ${TESTSRC}/help_help.out
-if [ $? != 0 ]; then
-  echo "Output of jcmd [pid] -f dcmd-script.txt  differ from expected output. Failed."
-  rm -f jcmd.out 2>/dev/null
-  failed=1;
-fi
-
-set -e
-
-stopApplication "${PORTFILE}"
-waitForApplication
-
-exit $failed
diff --git a/jdk/test/sun/tools/jcmd/jcmd-help-help.sh b/jdk/test/sun/tools/jcmd/jcmd-help-help.sh
deleted file mode 100644
index 2f99b6f..0000000
--- a/jdk/test/sun/tools/jcmd/jcmd-help-help.sh
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-
-# @test
-# @bug 7104647
-# @summary Unit test for jcmd utility
-#
-# @library ../common
-# @build SimpleApplication ShutdownSimpleApplication
-# @run shell jcmd-help-help.sh
-
-. ${TESTSRC}/../common/CommonSetup.sh
-. ${TESTSRC}/../common/ApplicationSetup.sh
-
-# Start application and use PORTFILE for coordination
-PORTFILE="${TESTCLASSES}"/shutdown.port
-startApplication SimpleApplication "${PORTFILE}"
-
-# all return statuses are checked in this test
-set +e
-
-failed=0
-
-# help help
-rm -f jcmd.out 2>/dev/null
-${JCMD} -J-XX:+UsePerfData $appJavaPid help help | awk '{ if (NR>1) print $0;}' > jcmd.out 2>&1
-echo jcmd.out
-diff -w jcmd.out ${TESTSRC}/help_help.out
-if [ $? != 0 ]; then
-  echo "Output of jcmd [pid] help help differ from expected output. Failed."
-  rm -f jcmd.out 2>/dev/null
-  failed=1;
-fi
-
-set -e
-
-stopApplication "${PORTFILE}"
-waitForApplication
-
-exit $failed
diff --git a/jdk/test/sun/tools/jcmd/jcmd-help.sh b/jdk/test/sun/tools/jcmd/jcmd-help.sh
deleted file mode 100644
index b640776..0000000
--- a/jdk/test/sun/tools/jcmd/jcmd-help.sh
+++ /dev/null
@@ -1,54 +0,0 @@
-#
-# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 7104647
-# @run shell jcmd-help.sh
-# @summary Test that output of 'jcmd -h' matches the usage.out file
-
-JCMD="${TESTJAVA}/bin/jcmd"
-
-rm -f jcmd.out 2>/dev/null
-${JCMD} -J-XX:+UsePerfData -h > jcmd.out 2>&1
-
-diff -w jcmd.out ${TESTSRC}/usage.out
-if [ $? != 0 ]
-then
-  echo "Output of jcmd -h differ from expected output. Failed."
-  rm -f jcmd.out 2>/dev/null
-  exit 1
-fi
-
-rm -f jcmd.out 2>/dev/null
-${JCMD} -J-XX:+UsePerfData -help > jcmd.out 2>&1
-
-diff -w jcmd.out ${TESTSRC}/usage.out
-if [ $? != 0 ]
-then
-  echo "Output of jcmd -help differ from expected output. Failed."
-  rm -f jcmd.out 2>/dev/null
-  exit 1
-fi
-
-rm -f jcmd.out 2>/dev/null
-exit 0
diff --git a/jdk/test/sun/tools/jcmd/jcmd-pid.sh b/jdk/test/sun/tools/jcmd/jcmd-pid.sh
deleted file mode 100644
index df39733..0000000
--- a/jdk/test/sun/tools/jcmd/jcmd-pid.sh
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-
-# @test
-# @bug 7104647
-# @summary Unit test for jcmd utility
-#
-# @library ../common
-# @build SimpleApplication ShutdownSimpleApplication
-# @run shell jcmd-pid.sh
-
-. ${TESTSRC}/../common/CommonSetup.sh
-. ${TESTSRC}/../common/ApplicationSetup.sh
-
-# Start application and use PORTFILE for coordination
-PORTFILE="${TESTCLASSES}"/shutdown.port
-startApplication SimpleApplication "${PORTFILE}"
-
-# all return statuses are checked in this test
-set +e
-
-failed=0
-
-# help command 
-${JCMD} -J-XX:+UsePerfData $appJavaPid help 2>&1 | awk -f ${TESTSRC}/jcmd_pid_Output1.awk
-if [ $? != 0 ]; then failed=1; fi
-
-# PerfCounter.list option
-${JCMD} -J-XX:+UsePerfData $appJavaPid PerfCounter.print 2>&1 | awk -f ${TESTSRC}/jcmd_pid_Output2.awk
-if [ $? != 0 ]; then failed=1; fi
-
-set -e
-
-stopApplication "${PORTFILE}"
-waitForApplication
-
-exit $failed
diff --git a/jdk/test/sun/tools/jcmd/jcmd_Output1.awk b/jdk/test/sun/tools/jcmd/jcmd_Output1.awk
deleted file mode 100644
index 5bf0403..0000000
--- a/jdk/test/sun/tools/jcmd/jcmd_Output1.awk
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-BEGIN	{
-            totallines=0; matched=0; current=0
-	}
-
-# match on a main class name followed by arbitrary arguments
-/^[0-9]+ [a-z|A-Z][a-z|A-Z|0-9|\.]*($| .*$)/	{
-	    current=1;
-	}
-
-# or match on a path name to a jar or war file followed by arbitraty arguments
-# - note, jar files ending with ".jar" is only a convention, not a requirement.
-#Theoretically, any valid file name could occur here.
-/^[0-9]+ .*\.(jar|war)($| .*$)/	{
-	    current=1;
-}
-
-# or match on the condition that the class name is not available
-/^[0-9]+ -- .*$/	{
-	    current=1;
-	}
-
-# or match an empty class name
-/^[0-9]+ $/	{
-	    current=1;
-	}
-
-	{ totallines++; matched+=current; current=0; print $0 }
-
-END	{
-	    if ((totallines > 0) && (matched == totallines)) {
-	        exit 0
-	    }
-	    else {
-	        exit 1
-	    }
-	}
diff --git a/jdk/test/sun/tools/jcmd/jcmd_pid_Output1.awk b/jdk/test/sun/tools/jcmd/jcmd_pid_Output1.awk
deleted file mode 100644
index 8ee49f0..0000000
--- a/jdk/test/sun/tools/jcmd/jcmd_pid_Output1.awk
+++ /dev/null
@@ -1,58 +0,0 @@
-#
-
-# section 0 = [PID]:
-# section 1 = "The following commands are available:"
-# section 2 = <list of commands, one command per line>
-# section 3 = blank line
-# section 4 = "For more information about a specific command use 'help <command>'."
-
-BEGIN	{
-    totallines=0; matched=0; section=0;
-}
-
-# match the first line (PID of the JVM followed by ':')
-/^[0-9]+:/{
-    if(section==0) {
-	matched++;
-	section=1;
-    }
-}
-
-/^The following commands are available:$/{
-    if(section==1) {
-	matched++;
-	section=2;
-    }
-}
-
-# match a command name
-/^[a-z|A-Z][a-z|A-Z|0-9|\.|_]*$/{
-    if(section==2) {
-	matched++;
-    }
-}
-
-/^$/{
-    if(section==2) {
-	matched++;
-	section=4;
-    }
-}
-
-/^For more information about a specific command use 'help <command>'\.$/{
-    if(section==4) {
-	matched++;
-	section=5;
-    }
-}
-
-{ totallines++; print $0 }
-
-END {
-    if ((totallines > 0) && (matched == totallines)) {
-	exit 0
-    }
-    else {
-	exit 1
-    }
-}
diff --git a/jdk/test/sun/tools/jcmd/jcmd_pid_Output2.awk b/jdk/test/sun/tools/jcmd/jcmd_pid_Output2.awk
deleted file mode 100644
index 49f0632..0000000
--- a/jdk/test/sun/tools/jcmd/jcmd_pid_Output2.awk
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-BEGIN	{
-	    totallines=0; matched=0
-	}
-
-# match on counter name followed '=' and an arbitrary value
-/^[a-z|A-Z][a-z|A-Z|0-9|\.|_]*=.*$/	{
-	    matched++;
-	}
-
-# or match the first line (PID of the JVM followed by ':')
-/^[0-9]+:/	{
-	    matched++;
-	}
-
-	{ totallines++; print $0 }
-
-END	{
-    if ((totallines > 0) && (matched == totallines)) {
-	exit 0
-    }
-    else {
-	exit 1
-    }
-}
diff --git a/jdk/test/sun/tools/jcmd/usage.out b/jdk/test/sun/tools/jcmd/usage.out
index 78ac0f3..48efa40 100644
--- a/jdk/test/sun/tools/jcmd/usage.out
+++ b/jdk/test/sun/tools/jcmd/usage.out
@@ -1,15 +1,15 @@
 Usage: jcmd <pid | main class> <command ...|PerfCounter.print|-f file>
-   or: jcmd -l                                                       
-   or: jcmd -h                                                       
+   or: jcmd -l                                                    
+   or: jcmd -h                                                    
                                                                   
-  command must be a valid jcmd command for the selected jvm.    
+  command must be a valid jcmd command for the selected jvm.      
   Use the command "help" to see which commands are available.   
   If the pid is 0, commands will be sent to all Java processes.   
   The main class argument will be used to match (either partially 
   or fully) the class used to start Java.                         
   If no options are given, lists Java processes (same as -p).     
                                                                   
-  PerfCounter.print display the counters exposed by this process   
+  PerfCounter.print display the counters exposed by this process  
   -f  read and execute commands from the file                     
   -l  list JVM processes on the local machine                     
   -h  this help                                                   
diff --git a/jdk/test/sun/tools/jps/JpsBase.java b/jdk/test/sun/tools/jps/JpsBase.java
new file mode 100644
index 0000000..59b293b
--- /dev/null
+++ b/jdk/test/sun/tools/jps/JpsBase.java
@@ -0,0 +1,144 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.File;
+import java.net.URL;
+import java.util.List;
+
+import jdk.testlibrary.OutputAnalyzer;
+import jdk.testlibrary.ProcessTools;
+
+/**
+ * The base class for testing the jps utility.
+ * The test sequence is to start jps with different combinations of arguments
+ * and verify the output contains proper values.
+ */
+public final class JpsBase {
+
+    private static final String shortProcessName;
+    private static final String fullProcessName;
+
+    /**
+     * The jps output should contain processes' names
+     * (except when jps is started in quite mode).
+     * The expected name of the test process is prepared here.
+     */
+    static {
+        URL url = JpsBase.class.getResource("JpsBase.class");
+        boolean isJar = url.getProtocol().equals("jar");
+
+        if (isJar) {
+            shortProcessName = JpsBase.class.getSimpleName() + ".jar";
+            String urlPath = url.getPath();
+            File jar = new File(urlPath.substring(urlPath.indexOf("file:") + 5, urlPath.indexOf("jar!") + 3));
+            fullProcessName = jar.getAbsolutePath();
+        } else {
+            shortProcessName = JpsBase.class.getSimpleName();
+            fullProcessName = JpsBase.class.getName();
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        int pid = ProcessTools.getProcessId();
+
+        List<List<JpsHelper.JpsArg>> combinations = JpsHelper.JpsArg.generateCombinations();
+        for (List<JpsHelper.JpsArg> combination : combinations) {
+            OutputAnalyzer output = JpsHelper.jps(JpsHelper.JpsArg.asCmdArray(combination));
+            output.shouldHaveExitValue(0);
+
+            boolean isQuiet = false;
+            boolean isFull = false;
+            String pattern;
+            for (JpsHelper.JpsArg jpsArg : combination) {
+                switch (jpsArg) {
+                case q:
+                    // If '-q' is specified output should contain only a list of local VM identifiers:
+                    // 30673
+                    isQuiet = true;
+                    JpsHelper.verifyJpsOutput(output, "^\\d+$");
+                    output.shouldContain(Integer.toString(pid));
+                    break;
+                case l:
+                    // If '-l' is specified output should contain the full package name for the application's main class
+                    // or the full path name to the application's JAR file:
+                    // 30673 /tmp/jtreg/jtreg-workdir/scratch/JpsBase.jar ...
+                    isFull = true;
+                    pattern = "^" + pid + "\\s+" + replaceSpecialChars(fullProcessName) + ".*";
+                    output.shouldMatch(pattern);
+                    break;
+                case m:
+                    // If '-m' is specified output should contain the arguments passed to the main method:
+                    // 30673 JpsBase monkey ...
+                    for (String arg : args) {
+                        pattern = "^" + pid + ".*" + replaceSpecialChars(arg) + ".*";
+                        output.shouldMatch(pattern);
+                    }
+                    break;
+                case v:
+                    // If '-v' is specified output should contain VM arguments:
+                    // 30673 JpsBase -Xmx512m -XX:+UseParallelGC -XX:Flags=/tmp/jtreg/jtreg-workdir/scratch/vmflags ...
+                    for (String vmArg : JpsHelper.getVmArgs()) {
+                        pattern = "^" + pid + ".*" + replaceSpecialChars(vmArg) + ".*";
+                        output.shouldMatch(pattern);
+                    }
+                    break;
+                case V:
+                    // If '-V' is specified output should contain VM flags:
+                    // 30673 JpsBase +DisableExplicitGC ...
+                    pattern = "^" + pid + ".*" + replaceSpecialChars(JpsHelper.VM_FLAG) + ".*";
+                    output.shouldMatch(pattern);
+                    break;
+                }
+
+                if (isQuiet) {
+                    break;
+                }
+            }
+
+            if (!isQuiet) {
+                // Verify output line by line.
+                // Output should only contain lines with pids after the first line with pid.
+                JpsHelper.verifyJpsOutput(output, "^\\d+\\s+.*");
+                if (!isFull) {
+                    pattern = "^" + pid + "\\s+" + replaceSpecialChars(shortProcessName);
+                    if (combination.isEmpty()) {
+                        // If no arguments are specified output should only contain
+                        // pid and process name
+                        pattern += "$";
+                    } else {
+                        pattern += ".*";
+                    }
+                    output.shouldMatch(pattern);
+                }
+            }
+        }
+    }
+
+    private static String replaceSpecialChars(String str) {
+        String tmp = str.replace("\\", "\\\\");
+        tmp = tmp.replace("+", "\\+");
+        tmp = tmp.replace(".", "\\.");
+        return tmp;
+    }
+
+}
diff --git a/jdk/test/sun/tools/jps/JpsHelper.java b/jdk/test/sun/tools/jps/JpsHelper.java
new file mode 100644
index 0000000..eaa965d
--- /dev/null
+++ b/jdk/test/sun/tools/jps/JpsHelper.java
@@ -0,0 +1,238 @@
+/*
+ * 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.
+ *
+ * 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 static jdk.testlibrary.Asserts.assertGreaterThan;
+import static jdk.testlibrary.Asserts.assertTrue;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import jdk.testlibrary.Asserts;
+import jdk.testlibrary.JDKToolLauncher;
+import jdk.testlibrary.OutputAnalyzer;
+import jdk.testlibrary.Utils;
+
+/**
+ * The helper class for running jps utility and verifying output from it
+ */
+public final class JpsHelper {
+
+    /**
+     * Helper class for handling jps arguments
+     */
+    public enum JpsArg {
+        q,
+        l,
+        m,
+        v,
+        V;
+
+        /**
+         * Generate all possible combinations of {@link JpsArg}
+         * (31 argument combinations and no arguments case)
+         */
+        public static List<List<JpsArg>> generateCombinations() {
+            final int argCount = JpsArg.values().length;
+            // If there are more than 30 args this algorithm will overflow.
+            Asserts.assertLessThan(argCount, 31, "Too many args");
+
+            List<List<JpsArg>> combinations = new ArrayList<>();
+            int combinationCount = (int) Math.pow(2, argCount);
+            for (int currCombo = 0; currCombo < combinationCount; ++currCombo) {
+                List<JpsArg> combination = new ArrayList<>();
+                for (int position = 0; position < argCount; ++position) {
+                    int bit = 1 << position;
+                    if ((bit & currCombo) != 0) {
+                        combination.add(JpsArg.values()[position]);
+                    }
+                }
+                combinations.add(combination);
+            }
+            return combinations;
+        }
+
+        /**
+         *  Return combination of {@link JpsArg} as a String array
+         */
+        public static String[] asCmdArray(List<JpsArg> jpsArgs) {
+            List<String> list = new ArrayList<>();
+            for (JpsArg jpsArg : jpsArgs) {
+                list.add("-" + jpsArg.toString());
+            }
+            return list.toArray(new String[list.size()]);
+        }
+
+    }
+
+    /**
+     * VM arguments to start test application with
+     */
+    public static final String[] VM_ARGS = {"-Xmx512m", "-XX:+PrintGCDetails"};
+    /**
+     * VM flag to start test application with
+     */
+    public static final String VM_FLAG = "+DisableExplicitGC";
+
+    private static File vmFlagsFile = null;
+    private static List<String> testVmArgs = null;
+    private static File manifestFile = null;
+
+    /**
+     * Create a file containing VM_FLAG in the working directory
+     */
+    public static File getVmFlagsFile() throws IOException {
+        if (vmFlagsFile == null) {
+            vmFlagsFile = new File("vmflags");
+            try (BufferedWriter output = new BufferedWriter(new FileWriter(vmFlagsFile))) {
+                output.write(VM_FLAG);
+            }
+            vmFlagsFile.deleteOnExit();
+        }
+        return vmFlagsFile;
+    }
+
+    /**
+     * Return a list of VM arguments
+     */
+    public static List<String> getVmArgs() throws IOException {
+        if (testVmArgs == null) {
+            testVmArgs = new ArrayList<>();
+            testVmArgs.addAll(Arrays.asList(VM_ARGS));
+            testVmArgs.add("-XX:Flags=" + getVmFlagsFile().getAbsolutePath());
+        }
+        return testVmArgs;
+    }
+
+    /**
+     * Start jps utility without any arguments
+     */
+    public static OutputAnalyzer jps() throws Exception {
+        return jps(null, null);
+    }
+
+    /**
+     * Start jps utility with tool arguments
+     */
+    public static OutputAnalyzer jps(String... toolArgs) throws Exception {
+        return jps(null, Arrays.asList(toolArgs));
+    }
+
+    /**
+     * Start jps utility with VM args and tool arguments
+     */
+    public static OutputAnalyzer jps(List<String> vmArgs, List<String> toolArgs) throws Exception {
+        JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jps");
+        if (vmArgs != null) {
+            for (String vmArg : vmArgs) {
+                launcher.addVMArg(vmArg);
+            }
+        }
+        if (toolArgs != null) {
+            for (String toolArg : toolArgs) {
+                launcher.addToolArg(toolArg);
+            }
+        }
+
+        ProcessBuilder processBuilder = new ProcessBuilder(launcher.getCommand());
+        System.out.println(Arrays.toString(processBuilder.command().toArray()).replace(",", ""));
+        OutputAnalyzer output = new OutputAnalyzer(processBuilder.start());
+        System.out.println(output.getOutput());
+
+        return output;
+    }
+
+    /**
+     * Verify jps output contains pids and programs' name information.
+     * The function will discard any lines that come before the first line with pid.
+     * This can happen if the JVM outputs a warning message for some reason
+     * before running jps.
+     *
+     * The output can look like:
+     * 35536 Jps
+     * 35417 Main
+     * 31103 org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
+     */
+    public static void verifyJpsOutput(OutputAnalyzer output, String regex) throws Exception {
+        output.shouldHaveExitValue(0);
+        int matchedCount = output.shouldMatchByLineFrom(regex, regex);
+        assertGreaterThan(matchedCount , 0, "Found no lines matching pattern: " + regex);
+    }
+
+    /**
+     * Compare jps output with a content in a file line by line
+     */
+    public static void verifyOutputAgainstFile(OutputAnalyzer output) throws IOException {
+        String testSrc = System.getProperty("test.src", "?");
+        File file = new File(testSrc, "usage.out");
+        List<String> fileOutput = Utils.fileAsList(file);
+        List<String> outputAsLines = output.asLines();
+        assertTrue(outputAsLines.containsAll(fileOutput),
+                "The ouput should contain all content of " + file.getAbsolutePath());
+    }
+
+    private static File getManifest(String className) throws IOException {
+        if (manifestFile == null) {
+            manifestFile = new File(className + ".mf");
+            try (BufferedWriter output = new BufferedWriter(new FileWriter(manifestFile))) {
+                output.write("Main-Class: " + className + Utils.NEW_LINE);
+            }
+        }
+        return manifestFile;
+    }
+
+    /**
+     * Build a jar of test classes in runtime
+     */
+    public static File buildJar(String className) throws Exception {
+        File jar = new File(className + ".jar");
+
+        List<String> jarArgs = new ArrayList<>();
+        jarArgs.add("-cfm");
+        jarArgs.add(jar.getAbsolutePath());
+        File manifestFile = getManifest(className);
+        jarArgs.add(manifestFile.getAbsolutePath());
+        String testClassPath = System.getProperty("test.class.path", "?");
+        for (String path : testClassPath.split(File.pathSeparator)) {
+            jarArgs.add("-C");
+            jarArgs.add(path);
+            jarArgs.add(".");
+        }
+
+        System.out.println("Running jar " + jarArgs.toString());
+        sun.tools.jar.Main jarTool = new sun.tools.jar.Main(System.out, System.err, "jar");
+        if (!jarTool.run(jarArgs.toArray(new String[jarArgs.size()]))) {
+            throw new Exception("jar failed: args=" + jarArgs.toString());
+        }
+
+        manifestFile.delete();
+        jar.deleteOnExit();
+
+        return jar;
+    }
+
+}
diff --git a/jdk/test/sun/tools/jps/TestJpsClass.java b/jdk/test/sun/tools/jps/TestJpsClass.java
new file mode 100644
index 0000000..0133e9c
--- /dev/null
+++ b/jdk/test/sun/tools/jps/TestJpsClass.java
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ *
+ * 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.util.ArrayList;
+import java.util.List;
+
+import jdk.testlibrary.OutputAnalyzer;
+import jdk.testlibrary.ProcessTools;
+
+/*
+ * @test
+ * @summary The test application will be started with java class:
+ *          java JpsBase
+ *          For all possible combinations of jps arguments a jps process
+ *          will be started from within the test application.
+ *          The output should contain proper values.
+ * @library /lib/testlibrary
+ * @build jdk.testlibrary.* JpsHelper JpsBase
+ * @run driver TestJpsClass
+ */
+public class TestJpsClass {
+
+    public static void main(String[] args) throws Throwable {
+        String testJdk = System.getProperty("test.jdk", "?");
+        String testSrc = System.getProperty("test.src", "?");
+        String testClassPath = System.getProperty("test.class.path", "?");
+
+        List<String> cmd = new ArrayList<>();
+        cmd.addAll(JpsHelper.getVmArgs());
+        cmd.add("-Dtest.jdk=" + testJdk);
+        cmd.add("-Dtest.src=" + testSrc);
+        cmd.add("-cp");
+        cmd.add(testClassPath);
+        cmd.add("JpsBase");
+        cmd.add("monkey");
+
+        ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(cmd.toArray(new String[cmd.size()]));
+        OutputAnalyzer output = new OutputAnalyzer(processBuilder.start());
+        System.out.println(output.getOutput());
+        output.shouldHaveExitValue(0);
+    }
+
+}
diff --git a/jdk/test/sun/tools/jps/TestJpsJar.java b/jdk/test/sun/tools/jps/TestJpsJar.java
new file mode 100644
index 0000000..37230ae
--- /dev/null
+++ b/jdk/test/sun/tools/jps/TestJpsJar.java
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import jdk.testlibrary.OutputAnalyzer;
+import jdk.testlibrary.ProcessTools;
+
+/*
+ * @test
+ * @summary The test application will be started with absolute jar:
+ *          java -jar /tmp/jtreg/jtreg-workdir/scratch/JpsBase.jar
+ *          For all possible combinations of jps arguments a jps process
+ *          will be started from within the test application.
+ *          The output should contain proper values.
+ * @library /lib/testlibrary
+ * @build jdk.testlibrary.* JpsHelper JpsBase
+ * @run driver TestJpsJar
+ */
+public class TestJpsJar {
+
+    public static void main(String[] args) throws Throwable {
+        String testJdk = System.getProperty("test.jdk", "?");
+        String testSrc = System.getProperty("test.src", "?");
+        File jar = JpsHelper.buildJar("JpsBase");
+
+        List<String> cmd = new ArrayList<>();
+        cmd.addAll(JpsHelper.getVmArgs());
+        cmd.add("-Dtest.jdk=" + testJdk);
+        cmd.add("-Dtest.src=" + testSrc);
+        cmd.add("-jar");
+        cmd.add(jar.getAbsolutePath());
+        cmd.add("monkey");
+
+        ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(cmd.toArray(new String[cmd.size()]));
+        OutputAnalyzer output = new OutputAnalyzer(processBuilder.start());
+        System.out.println(output.getOutput());
+        output.shouldHaveExitValue(0);
+    }
+
+}
diff --git a/jdk/test/sun/tools/jps/TestJpsJarRelative.java b/jdk/test/sun/tools/jps/TestJpsJarRelative.java
new file mode 100644
index 0000000..8b7def5
--- /dev/null
+++ b/jdk/test/sun/tools/jps/TestJpsJarRelative.java
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import jdk.testlibrary.OutputAnalyzer;
+import jdk.testlibrary.ProcessTools;
+
+/*
+ * @test
+ * @summary The test application will be started with relative jar:
+ *          java -jar ./JpsBase.jar
+ *          For all possible combinations of jps arguments a jps process
+ *          will be started from within the test application.
+ *          The output should contain proper values.
+ * @library /lib/testlibrary
+ * @build jdk.testlibrary.* JpsHelper JpsBase
+ * @run driver TestJpsJarRelative
+ */
+public class TestJpsJarRelative {
+
+    public static void main(String[] args) throws Throwable {
+        String testJdk = System.getProperty("test.jdk", "?");
+        String testSrc = System.getProperty("test.src", "?");
+        File jar = JpsHelper.buildJar("JpsBase");
+
+        List<String> cmd = new ArrayList<>();
+        cmd.addAll(JpsHelper.getVmArgs());
+        cmd.add("-Dtest.jdk=" + testJdk);
+        cmd.add("-Dtest.src=" + testSrc);
+        cmd.add("-jar");
+        cmd.add("." + File.separator + jar.getName());
+        cmd.add("monkey");
+
+        ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(cmd.toArray(new String[cmd.size()]));
+        OutputAnalyzer output = new OutputAnalyzer(processBuilder.start());
+        System.out.println(output.getOutput());
+        output.shouldHaveExitValue(0);
+    }
+
+}
diff --git a/jdk/test/sun/tools/jps/TestJpsSanity.java b/jdk/test/sun/tools/jps/TestJpsSanity.java
new file mode 100644
index 0000000..5a0868a
--- /dev/null
+++ b/jdk/test/sun/tools/jps/TestJpsSanity.java
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ *
+ * 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.Asserts;
+import jdk.testlibrary.OutputAnalyzer;
+
+/*
+ * @test
+ * @summary This test verifies jps usage and checks that appropriate error message is shown
+ *          when running jps with illegal arguments.
+ * @library /lib/testlibrary
+ * @build jdk.testlibrary.* JpsHelper
+ * @run driver TestJpsSanity
+ */
+public class TestJpsSanity {
+
+    public static void main(String[] args) throws Throwable {
+        testJpsUsage();
+        testJpsVersion();
+        testJpsUnknownHost();
+    }
+
+    private static void testJpsUsage() throws Exception {
+        OutputAnalyzer output = JpsHelper.jps("-?");
+        JpsHelper.verifyOutputAgainstFile(output);
+
+        output = JpsHelper.jps("-help");
+        JpsHelper.verifyOutputAgainstFile(output);
+    }
+
+    private static void testJpsVersion() throws Exception {
+        OutputAnalyzer output = JpsHelper.jps("-version");
+        Asserts.assertNotEquals(output.getExitValue(), 0, "Exit code shouldn't be 0");
+        Asserts.assertFalse(output.getStderr().isEmpty(), "Error output should not be empty");
+        output.shouldContain("illegal argument: -version");
+    }
+
+    private static void testJpsUnknownHost() throws Exception {
+        String invalidHostName = "Oja781nh2ev7vcvbajdg-Sda1-C";
+        OutputAnalyzer output = JpsHelper.jps(invalidHostName);
+        Asserts.assertNotEquals(output.getExitValue(), 0, "Exit code shouldn't be 0");
+        Asserts.assertFalse(output.getStderr().isEmpty(), "Error output should not be empty");
+        output.shouldContain("Unknown host: " + invalidHostName);
+    }
+
+}
diff --git a/jdk/test/sun/tools/jps/jps-Defaults.sh b/jdk/test/sun/tools/jps/jps-Defaults.sh
deleted file mode 100644
index a8cd1ad..0000000
--- a/jdk/test/sun/tools/jps/jps-Defaults.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Copyright (c) 2004, 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.
-#
-# 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 4990825
-# @run shell jps-Defaults.sh
-# @summary Test that output of 'jps' matches a specific pattern
-
-. ${TESTSRC-.}/../../jvmstat/testlibrary/utils.sh
-
-setup
-verify_os
-
-JPS="${TESTJAVA}/bin/jps"
-
-${JPS} -J-XX:+UsePerfData 2>&1 | awk -f ${TESTSRC}/jps_Output1.awk
diff --git a/jdk/test/sun/tools/jps/jps-V_2.sh b/jdk/test/sun/tools/jps/jps-V_2.sh
deleted file mode 100644
index 2ab10ee..0000000
--- a/jdk/test/sun/tools/jps/jps-V_2.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# 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 4990825
-# @run shell jps-V_2.sh
-# @summary Test that output of 'jps -V' shows JVM flags
-
-. ${TESTSRC-.}/../../jvmstat/testlibrary/utils.sh
-
-setup
-verify_os
-
-JPS="${TESTJAVA}/bin/jps"
-
-${JPS} -J-XX:+UsePerfData -J-XX:Flags=${TESTSRC}/vmflags -V | awk -f ${TESTSRC}/jps-V_Output2.awk
diff --git a/jdk/test/sun/tools/jps/jps-V_Output2.awk b/jdk/test/sun/tools/jps/jps-V_Output2.awk
deleted file mode 100644
index 3f1be04..0000000
--- a/jdk/test/sun/tools/jps/jps-V_Output2.awk
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-BEGIN	{
-	    totallines=0; matched=0
-	}
-
-/^[0-9]+ Jps.* \+DisableExplicitGC$/	{
-	    matched++;
-	}
-
-	{ totallines++; print $0 }
-
-END	{
-	    if ((totallines > 0) && (matched >= 1)) {
-	        exit 0
-	    }
-	    else {
-	        exit 1
-	    }
-	}
diff --git a/jdk/test/sun/tools/jps/jps-Vm_2.sh b/jdk/test/sun/tools/jps/jps-Vm_2.sh
deleted file mode 100644
index ba9fa0f..0000000
--- a/jdk/test/sun/tools/jps/jps-Vm_2.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Copyright (c) 2004, 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.
-#
-# 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 4990825
-# @run shell jps-Vm_2.sh
-# @summary Test that output of 'jps -Vm' shows JVM flags and main args
-
-. ${TESTSRC-.}/../../jvmstat/testlibrary/utils.sh
-
-setup
-verify_os
-
-JPS="${TESTJAVA}/bin/jps"
-
-${JPS} -J-XX:+UsePerfData -J-XX:Flags=${TESTSRC}/vmflags -Vm | awk -f ${TESTSRC}/jps-Vm_Output2.awk
diff --git a/jdk/test/sun/tools/jps/jps-Vm_Output2.awk b/jdk/test/sun/tools/jps/jps-Vm_Output2.awk
deleted file mode 100644
index 65f358b..0000000
--- a/jdk/test/sun/tools/jps/jps-Vm_Output2.awk
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-BEGIN	{
-	    totallines=0; matched=0
-	}
-
-/^[0-9]+ Jps -Vm.* \+DisableExplicitGC$/	{
-	    matched++;
-	}
-
-	{ totallines++; print $0 }
-
-END	{
-	    if ((totallines > 0) && (matched >= 1)) {
-	        exit 0
-	    }
-	    else {
-	        exit 1
-	    }
-	}
diff --git a/jdk/test/sun/tools/jps/jps-Vvm.sh b/jdk/test/sun/tools/jps/jps-Vvm.sh
deleted file mode 100644
index d60896a..0000000
--- a/jdk/test/sun/tools/jps/jps-Vvm.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Copyright (c) 2004, 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.
-#
-# 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 4990825
-# @run shell jps-Vvm.sh
-# @summary Test that output of 'jps -Vvm' shows JVM flags, arguments and main args
-
-. ${TESTSRC-.}/../../jvmstat/testlibrary/utils.sh
-
-setup
-verify_os
-
-JPS="${TESTJAVA}/bin/jps"
-
-${JPS} -J-XX:+UsePerfData -J-XX:Flags=${TESTSRC}/vmflags -Vvm | awk -f ${TESTSRC}/jps-Vvm_Output1.awk
diff --git a/jdk/test/sun/tools/jps/jps-Vvm_Output1.awk b/jdk/test/sun/tools/jps/jps-Vvm_Output1.awk
deleted file mode 100644
index 99187dc..0000000
--- a/jdk/test/sun/tools/jps/jps-Vvm_Output1.awk
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-BEGIN	{
-	    totallines=0; matched=0
-	}
-
-/^[0-9]+ Jps -Vvm.*-XX:Flags=.*vmflags.* \+DisableExplicitGC$/	{
-	    matched++;
-	}
-
-	{ totallines++; print $0 }
-
-END	{
-	    if ((totallines > 0) && (matched >= 1)) {
-	        exit 0
-	    }
-	    else {
-	        exit 1
-	    }
-	}
diff --git a/jdk/test/sun/tools/jps/jps-Vvml.sh b/jdk/test/sun/tools/jps/jps-Vvml.sh
deleted file mode 100644
index f8d5fa3..0000000
--- a/jdk/test/sun/tools/jps/jps-Vvml.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Copyright (c) 2004, 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.
-#
-# 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 4990825
-# @run shell jps-Vvml.sh
-# @summary Test that output of 'jps -Vvml' shows JVM arguments, flags, and main args with long class names
-
-. ${TESTSRC-.}/../../jvmstat/testlibrary/utils.sh
-
-setup
-verify_os
-
-JPS="${TESTJAVA}/bin/jps"
-
-${JPS} -J-XX:+UsePerfData -J-XX:Flags=${TESTSRC}/vmflags -Vvml | awk -f ${TESTSRC}/jps-Vvml_Output1.awk
diff --git a/jdk/test/sun/tools/jps/jps-Vvml_2.sh b/jdk/test/sun/tools/jps/jps-Vvml_2.sh
deleted file mode 100644
index 6fc88a3..0000000
--- a/jdk/test/sun/tools/jps/jps-Vvml_2.sh
+++ /dev/null
@@ -1,63 +0,0 @@
-#
-# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# 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 5009652
-# @library ../../jvmstat/testlibrary
-# @build Sleeper
-# @run shell jps-Vvml_2.sh
-# @summary Test that output of 'jps -Vvml' shows proper output when no JVM arguments, flags, or main args are present
-
-. ${TESTSRC-.}/../../jvmstat/testlibrary/utils.sh
-
-setup
-verify_os
-
-cleanup() {
-  kill_proc ${SLEEPER_PID}
-}
-
-trap 'cleanup' 0 HUP INT QUIT TERM
-
-JPS="${TESTJAVA}/bin/jps"
-
-JAVA="${TESTJAVA}/bin/java"
-
-# fire up a Sleeper that block indefinitely - but don't pass
-# any args to Sleeper.main() or any jvm flags or options, as we
-# need to inspect jps output for the no args condition.
-#
-# Note: this test can not pass on a VM with UsePerfData disabled by default,
-# and we can not set -XX:+UsePerfData as that invalidates the test premise of
-# there being no jvm flags
-
-${JAVA} -cp ${TESTCLASSPATH:-${TESTCLASSES}} Sleeper &
-SLEEPER_PID=$!
-
-${JPS} -J-XX:Flags=${TESTSRC}/vmflags -Vvml | awk -f ${TESTSRC}/jps-Vvml_Output2.awk
-RC=$?
-
-cleanup
-
-exit ${RC}
-
diff --git a/jdk/test/sun/tools/jps/jps-Vvml_Output1.awk b/jdk/test/sun/tools/jps/jps-Vvml_Output1.awk
deleted file mode 100644
index b4d4191..0000000
--- a/jdk/test/sun/tools/jps/jps-Vvml_Output1.awk
+++ /dev/null
@@ -1,20 +0,0 @@
-#
-
-BEGIN	{
-	    totallines=0; matched=0
-	}
-
-/^[0-9]+ sun.tools.jps.Jps -Vvml.*-XX:Flags=.*vmflags.* \+DisableExplicitGC$/	{
-	    matched++;
-	}
-
-	{ totallines++; print $0 }
-
-END	{
-	    if ((totallines > 0) && (matched >= 1)) {
-	        exit 0
-	    }
-	    else {
-	        exit 1
-	    }
-	}
diff --git a/jdk/test/sun/tools/jps/jps-Vvml_Output2.awk b/jdk/test/sun/tools/jps/jps-Vvml_Output2.awk
deleted file mode 100644
index e7cad75..0000000
--- a/jdk/test/sun/tools/jps/jps-Vvml_Output2.awk
+++ /dev/null
@@ -1,24 +0,0 @@
-# 1.1 04/03/08
-
-BEGIN	{
-	    totallines=0; matched=0
-	}
-
-/^[0-9]+ Sleeper$/	{
-	    matched++;
-	}
-
-/^[0-9]+ sun.tools.jps.Jps -Vvml.*-XX:Flags=.*vmflags.* \+DisableExplicitGC$/	{
-	    matched++;
-	}
-
-	{ totallines++; print $0 }
-
-END	{
-	    if ((totallines > 0) && (matched >= 2)) {
-	        exit 0
-	    }
-	    else {
-	        exit 1
-	    }
-	}
diff --git a/jdk/test/sun/tools/jps/jps-help.sh b/jdk/test/sun/tools/jps/jps-help.sh
deleted file mode 100644
index c6c1cbd..0000000
--- a/jdk/test/sun/tools/jps/jps-help.sh
+++ /dev/null
@@ -1,57 +0,0 @@
-#
-# Copyright (c) 2004, 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.
-#
-# 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 4990825
-# @run shell jps-help.sh
-# @summary Test that output of 'jps -?' matches the usage.out file
-
-. ${TESTSRC-.}/../../jvmstat/testlibrary/utils.sh
-
-setup
-
-JPS="${TESTJAVA}/bin/jps"
-
-rm -f jps.out 2>/dev/null
-${JPS} -J-XX:+UsePerfData -? > jps.out 2>&1
-
-diff -w jps.out ${TESTSRC}/usage.out
-if [ $? != 0 ]
-then
-  echo "Output of jps -? differ from expected output. Failed."
-  rm -f jps.out 2>/dev/null
-  exit 1
-fi
-
-rm -f jps.out 2>/dev/null
-${JPS} -J-XX:+UsePerfData -help > jps.out 2>&1
-
-diff -w jps.out ${TESTSRC}/usage.out
-if [ $? != 0 ]
-then
-  echo "Output of jps -help differ from expected output. Failed."
-  rm -f jps.out 2>/dev/null
-  exit 1
-fi
-
-exit 0
diff --git a/jdk/test/sun/tools/jps/jps-l_1.sh b/jdk/test/sun/tools/jps/jps-l_1.sh
deleted file mode 100644
index 4cb65ea..0000000
--- a/jdk/test/sun/tools/jps/jps-l_1.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Copyright (c) 2004, 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.
-#
-# 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 4990825
-# @run shell jps-l_1.sh
-# @summary Test that output of 'jps -l' matches a specific pattern
-
-. ${TESTSRC-.}/../../jvmstat/testlibrary/utils.sh
-
-setup
-verify_os
-
-JPS="${TESTJAVA}/bin/jps"
-
-${JPS} -J-XX:+UsePerfData -l 2>&1 | awk -f ${TESTSRC}/jps-l_Output1.awk
diff --git a/jdk/test/sun/tools/jps/jps-l_2.sh b/jdk/test/sun/tools/jps/jps-l_2.sh
deleted file mode 100644
index 95784db..0000000
--- a/jdk/test/sun/tools/jps/jps-l_2.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Copyright (c) 2004, 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.
-#
-# 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 4990825
-# @run shell jps-l_2.sh
-# @summary Test that output of 'jps -l' shows the long class name
-
-. ${TESTSRC-.}/../../jvmstat/testlibrary/utils.sh
-
-setup
-verify_os
-
-JPS="${TESTJAVA}/bin/jps"
-
-${JPS} -J-XX:+UsePerfData -l | awk -f ${TESTSRC}/jps-l_Output2.awk
diff --git a/jdk/test/sun/tools/jps/jps-l_Output1.awk b/jdk/test/sun/tools/jps/jps-l_Output1.awk
deleted file mode 100644
index 08a48c1..0000000
--- a/jdk/test/sun/tools/jps/jps-l_Output1.awk
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-BEGIN	{
-	    totallines=0; matched=0
-	}
-
-# match on a fully qualified class name
-/^[0-9]+ [a-z|A-Z][a-z|A-Z|0-9|\.|\$|\+]*$/	{
-	    matched++;
-	}
-
-# or match on a jar or war file name - note, jar files ending with
-# ".jar" is only a convention , not a requirement. Theoretically,
-# any valid file name could occur here.
-/^[0-9]+ .*\.(jar|war)$/	{
-	    matched++;
-}
-
-# or match on the condition that the class name is not available
-/^[0-9]+ -- .*$/	{
-	    matched++;
-	}
-
-# or match an empty class name
-/^[0-9]+ $/	{
-	    matched++;
-	}
-
-	{ totallines++; print $0 }
-
-END	{
-	    if ((totallines > 0) && (matched == totallines)) {
-	        exit 0
-	    }
-	    else {
-	        exit 1
-	    }
-	}
diff --git a/jdk/test/sun/tools/jps/jps-l_Output2.awk b/jdk/test/sun/tools/jps/jps-l_Output2.awk
deleted file mode 100644
index 4df71f0..0000000
--- a/jdk/test/sun/tools/jps/jps-l_Output2.awk
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-BEGIN	{
-	    totallines=0; matched=0
-	}
-
-/^[0-9]+ sun.tools.jps.Jps$/	{
-	    matched++;
-	}
-
-	{ totallines++; print $0 }
-
-END	{
-	    if ((totallines > 0) && (matched >= 1)) {
-	        exit 0
-	    }
-	    else {
-	        exit 1
-	    }
-	}
diff --git a/jdk/test/sun/tools/jps/jps-lm.sh b/jdk/test/sun/tools/jps/jps-lm.sh
deleted file mode 100644
index 4a45512..0000000
--- a/jdk/test/sun/tools/jps/jps-lm.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Copyright (c) 2004, 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.
-#
-# 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 4990825
-# @run shell jps-lm.sh
-# @summary Test that output of 'jps -lm' shows the long class name and main args
-
-. ${TESTSRC-.}/../../jvmstat/testlibrary/utils.sh
-
-setup
-verify_os
-
-JPS="${TESTJAVA}/bin/jps"
-
-${JPS} -J-XX:+UsePerfData -lm | awk -f ${TESTSRC}/jps-lm_Output1.awk
diff --git a/jdk/test/sun/tools/jps/jps-lm_Output1.awk b/jdk/test/sun/tools/jps/jps-lm_Output1.awk
deleted file mode 100644
index e3fcbee..0000000
--- a/jdk/test/sun/tools/jps/jps-lm_Output1.awk
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-BEGIN	{
-	    totallines=0; matched=0
-	}
-
-/^[0-9]+ sun.tools.jps.Jps -lm$/	{
-	    matched++;
-	}
-
-	{ totallines++; print $0 }
-
-END	{
-	    if ((totallines > 0) && (matched >= 1)) {
-	        exit 0
-	    }
-	    else {
-	        exit 1
-	    }
-	}
diff --git a/jdk/test/sun/tools/jps/jps-m.sh b/jdk/test/sun/tools/jps/jps-m.sh
deleted file mode 100644
index f900b9f..0000000
--- a/jdk/test/sun/tools/jps/jps-m.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Copyright (c) 2004, 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.
-#
-# 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 4990825
-# @run shell jps-m.sh
-# @summary Test that output of 'jps -m' shows args to main
-
-. ${TESTSRC-.}/../../jvmstat/testlibrary/utils.sh
-
-setup
-verify_os
-
-JPS="${TESTJAVA}/bin/jps"
-
-${JPS} -J-XX:+UsePerfData -m | awk -f ${TESTSRC}/jps-m_Output1.awk
diff --git a/jdk/test/sun/tools/jps/jps-m_2.sh b/jdk/test/sun/tools/jps/jps-m_2.sh
deleted file mode 100644
index b881c35..0000000
--- a/jdk/test/sun/tools/jps/jps-m_2.sh
+++ /dev/null
@@ -1,58 +0,0 @@
-#
-# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# 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 5009652
-# @library ../../jvmstat/testlibrary
-# @build Sleeper
-# @run shell jps-m_2.sh
-# @summary Test that output of 'jps -m' shows proper output for main with no args.
-
-. ${TESTSRC-.}/../../jvmstat/testlibrary/utils.sh
-
-setup
-verify_os
-
-cleanup() {
-  kill_proc ${SLEEPER_PID}
-}
-
-trap 'cleanup' 0 HUP INT QUIT TERM
-
-JPS="${TESTJAVA}/bin/jps"
-JAVA="${TESTJAVA}/bin/java"
-
-# fire up a Sleeper that blocks indefinitely - but don't pass
-# any args to Sleeper.main(), as we need to inspect jps output
-# for the no args condition.
-#
-${JAVA} -XX:+UsePerfData -cp ${TESTCLASSPATH:-${TESTCLASSES}} Sleeper &
-SLEEPER_PID=$!
-
-${JPS} -J-XX:+UsePerfData -m | awk -f ${TESTSRC}/jps-m_Output2.awk
-RC=$?
-
-cleanup
-
-exit ${RC}
-
diff --git a/jdk/test/sun/tools/jps/jps-m_Output1.awk b/jdk/test/sun/tools/jps/jps-m_Output1.awk
deleted file mode 100644
index 560f6e8..0000000
--- a/jdk/test/sun/tools/jps/jps-m_Output1.awk
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-BEGIN	{
-	    totallines=0; matched=0
-	}
-
-/^[0-9]+ Jps -m$/	{
-	    matched++;
-	}
-
-	{ totallines++; print $0 }
-
-END	{
-	    if ((totallines > 0) && (matched >= 1)) {
-	        exit 0
-	    }
-	    else {
-	        exit 1
-	    }
-	}
diff --git a/jdk/test/sun/tools/jps/jps-m_Output2.awk b/jdk/test/sun/tools/jps/jps-m_Output2.awk
deleted file mode 100644
index 0ba09ad..0000000
--- a/jdk/test/sun/tools/jps/jps-m_Output2.awk
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-BEGIN	{
-	    totallines=0; matched=0
-	}
-
-/^[0-9]+ Sleeper$/	{
-	    matched++;
-	}
-
-/^[0-9]+ Jps -m$/	{
-	    matched++;
-	}
-
-	{ totallines++; print $0 }
-
-END	{
-	    if ((totallines > 0) && (matched >= 2)) {
-	        exit 0
-	    }
-	    else {
-	        exit 1
-	    }
-	}
diff --git a/jdk/test/sun/tools/jps/jps-q.sh b/jdk/test/sun/tools/jps/jps-q.sh
deleted file mode 100644
index cd6a4ac..0000000
--- a/jdk/test/sun/tools/jps/jps-q.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Copyright (c) 2004, 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.
-#
-# 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 4990825
-# @run shell jps-q.sh
-# @summary Test that output of 'jps -q' shows only the process ids
-
-. ${TESTSRC-.}/../../jvmstat/testlibrary/utils.sh
-
-setup
-verify_os
-
-JPS="${TESTJAVA}/bin/jps"
-
-${JPS} -J-XX:+UsePerfData -q | awk -f ${TESTSRC}/jps-q_Output1.awk
diff --git a/jdk/test/sun/tools/jps/jps-q_Output1.awk b/jdk/test/sun/tools/jps/jps-q_Output1.awk
deleted file mode 100644
index 53ae3a8..0000000
--- a/jdk/test/sun/tools/jps/jps-q_Output1.awk
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-BEGIN	{
-	    totallines=0; matched=0
-	}
-
-/^[0-9]+$/	{
-	    matched++;
-	}
-
-	{ totallines++; print $0 }
-
-END	{
-	    if ((totallines > 0) && (matched >= 1)) {
-	        exit 0
-	    }
-	    else {
-	        exit 1
-	    }
-	}
diff --git a/jdk/test/sun/tools/jps/jps-v_1.sh b/jdk/test/sun/tools/jps/jps-v_1.sh
deleted file mode 100644
index 21d0852..0000000
--- a/jdk/test/sun/tools/jps/jps-v_1.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Copyright (c) 2004, 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.
-#
-# 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 4990825
-# @run shell jps-v_1.sh
-# @summary Test that output of 'jps -v' shows JVM arguments
-
-. ${TESTSRC-.}/../../jvmstat/testlibrary/utils.sh
-
-setup
-verify_os
-
-JPS="${TESTJAVA}/bin/jps"
-
-${JPS} -J-XX:+UsePerfData -J-XX:+UseParallelGC -v | awk -f ${TESTSRC}/jps-v_Output1.awk
diff --git a/jdk/test/sun/tools/jps/jps-v_Output1.awk b/jdk/test/sun/tools/jps/jps-v_Output1.awk
deleted file mode 100644
index 02ad298..0000000
--- a/jdk/test/sun/tools/jps/jps-v_Output1.awk
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-BEGIN	{
-	    totallines=0; matched=0
-	}
-
-/^[0-9]+ Jps.* -XX:\+UseParallelGC$/	{
-	    matched++;
-	}
-
-	{ totallines++; print $0 }
-
-END	{
-	    if ((totallines > 0) && (matched >= 1)) {
-	        exit 0
-	    }
-	    else {
-	        exit 1
-	    }
-	}
diff --git a/jdk/test/sun/tools/jps/jps-vm_1.sh b/jdk/test/sun/tools/jps/jps-vm_1.sh
deleted file mode 100644
index 80bb62e..0000000
--- a/jdk/test/sun/tools/jps/jps-vm_1.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Copyright (c) 2004, 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.
-#
-# 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 4990825
-# @run shell jps-vm_1.sh
-# @summary Test that output of 'jps -vm' shows JVM arguments and main args
-
-. ${TESTSRC-.}/../../jvmstat/testlibrary/utils.sh
-
-setup
-verify_os
-
-JPS="${TESTJAVA}/bin/jps"
-
-${JPS} -J-XX:+UsePerfData -J-XX:+UseParallelGC -vm | awk -f ${TESTSRC}/jps-vm_Output1.awk
diff --git a/jdk/test/sun/tools/jps/jps-vm_Output1.awk b/jdk/test/sun/tools/jps/jps-vm_Output1.awk
deleted file mode 100644
index 0cda3ca..0000000
--- a/jdk/test/sun/tools/jps/jps-vm_Output1.awk
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-BEGIN	{
-	    totallines=0; matched=0
-	}
-
-/^[0-9]+ Jps -vm.* -XX:\+UseParallelGC$/	{
-	    matched++;
-	}
-
-	{ totallines++; print $0 }
-
-END	{
-	    if ((totallines > 0) && (matched >= 1)) {
-	        exit 0
-	    }
-	    else {
-	        exit 1
-	    }
-	}
diff --git a/jdk/test/sun/tools/jps/jps_Output1.awk b/jdk/test/sun/tools/jps/jps_Output1.awk
deleted file mode 100644
index c64b0f1..0000000
--- a/jdk/test/sun/tools/jps/jps_Output1.awk
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-BEGIN	{
-	    totallines=0; matched=0
-	}
-
-# match on a main class name
-/^[0-9]+ [a-z|A-Z][a-z|A-Z|0-9|\$|\+]*$/	{
-	    matched++;
-	}
-
-# or match on a path name to a jar or war file - note, jar files ending with
-# ".jar" is only a convention, not a requirement. Theoretically,
-# any valid file name could occur here.
-/^[0-9]+ .*\.(jar|war)$/	{
-	    matched++;
-}
-
-# or match on the condition that the class name is not available
-/^[0-9]+ -- .*$/	{
-	    matched++;
-	}
-
-# or match an empty class name
-/^[0-9]+ $/	{
-	    matched++;
-	}
-
-	{ totallines++; print $0 }
-
-END	{
-	    if ((totallines > 0) && (matched == totallines)) {
-	        exit 0
-	    }
-	    else {
-	        exit 1
-	    }
-	}
diff --git a/jdk/test/sun/tools/jps/vmflags b/jdk/test/sun/tools/jps/vmflags
deleted file mode 100644
index be0e23c..0000000
--- a/jdk/test/sun/tools/jps/vmflags
+++ /dev/null
@@ -1 +0,0 @@
-+DisableExplicitGC
diff --git a/jdk/test/sun/tools/native2ascii/NativeErrors.java b/jdk/test/sun/tools/native2ascii/NativeErrors.java
index 00493b8..02ca853 100644
--- a/jdk/test/sun/tools/native2ascii/NativeErrors.java
+++ b/jdk/test/sun/tools/native2ascii/NativeErrors.java
@@ -75,7 +75,14 @@
             throw new Error("Output file cannot be made read only: " + path2);
         }
         f2.deleteOnExit();
-        checkResult(executeCmd(path1, path2), "err.cannot.write");
+        if ( f2.canWrite() ) {
+            String msg = "Output file is still writable. " +
+                    "Probably because test is run as root. Read-only test skipped.";
+            System.out.println(msg);
+        } else {
+            // Test write to a read-only file.
+            checkResult(executeCmd(path1, path2), "err.cannot.write");
+        }
     }
 
     private static String executeCmd(String... toolArgs) throws Throwable {
diff --git a/jdk/test/sun/util/calendar/zi/TestZoneInfo310.java b/jdk/test/sun/util/calendar/zi/TestZoneInfo310.java
index 8bf07f6..f6fc60e 100644
--- a/jdk/test/sun/util/calendar/zi/TestZoneInfo310.java
+++ b/jdk/test/sun/util/calendar/zi/TestZoneInfo310.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, 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
@@ -163,6 +163,10 @@
         }
 
         for (String zid : zids_new) {
+            if (zid.equals("Asia/Oral") || zid.equals("Asia/Qyzylorda")) {
+                // JDK-8157792 tracking this issue
+                continue;
+            }
             ZoneInfoOld zi = toZoneInfoOld(TimeZone.getTimeZone(zid));
             ZoneInfoOld ziOLD = (ZoneInfoOld)ZoneInfoOld.getTimeZone(zid);
             if (! zi.equalsTo(ziOLD)) {
diff --git a/jdk/test/sun/util/calendar/zi/tzdata/VERSION b/jdk/test/sun/util/calendar/zi/tzdata/VERSION
index 55966f2..5aaf0c5 100644
--- a/jdk/test/sun/util/calendar/zi/tzdata/VERSION
+++ b/jdk/test/sun/util/calendar/zi/tzdata/VERSION
@@ -21,4 +21,4 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
-tzdata2016a
+tzdata2016d
diff --git a/jdk/test/sun/util/calendar/zi/tzdata/asia b/jdk/test/sun/util/calendar/zi/tzdata/asia
index 056a5f9..58b43e9 100644
--- a/jdk/test/sun/util/calendar/zi/tzdata/asia
+++ b/jdk/test/sun/util/calendar/zi/tzdata/asia
@@ -102,13 +102,9 @@
 Rule E-EurAsia	1996	max	-	Oct	lastSun	 0:00	0	-
 Rule RussiaAsia	1981	1984	-	Apr	1	 0:00	1:00	S
 Rule RussiaAsia	1981	1983	-	Oct	1	 0:00	0	-
-Rule RussiaAsia	1984	1991	-	Sep	lastSun	 2:00s	0	-
-Rule RussiaAsia	1985	1991	-	Mar	lastSun	 2:00s	1:00	S
-Rule RussiaAsia	1992	only	-	Mar	lastSat	23:00	1:00	S
-Rule RussiaAsia	1992	only	-	Sep	lastSat	23:00	0	-
-Rule RussiaAsia	1993	max	-	Mar	lastSun	 2:00s	1:00	S
-Rule RussiaAsia	1993	1995	-	Sep	lastSun	 2:00s	0	-
-Rule RussiaAsia	1996	max	-	Oct	lastSun	 2:00s	0	-
+Rule RussiaAsia	1984	1995	-	Sep	lastSun	 2:00s	0	-
+Rule RussiaAsia	1985	2011	-	Mar	lastSun	 2:00s	1:00	S
+Rule RussiaAsia	1996	2011	-	Oct	lastSun	 2:00s	0	-
 
 # Afghanistan
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
@@ -148,17 +144,26 @@
 			3:00	1:00	YERST	1991 Sep 23 # independence
 			3:00 RussiaAsia	AM%sT	1995 Sep 24  2:00s
 			4:00	-	AMT	1997
-			4:00 RussiaAsia	AM%sT	2012 Mar 25  2:00s
+			4:00 RussiaAsia	AM%sT	2012 Feb  9
 			4:00	-	AMT
 
 # Azerbaijan
+
 # From Rustam Aliyev of the Azerbaijan Internet Forum (2005-10-23):
 # According to the resolution of Cabinet of Ministers, 1997
 # From Paul Eggert (2015-09-17): It was Resolution No. 21 (1997-03-17).
 # http://code.az/files/daylight_res.pdf
+
+# From Steffen Thorsen (2016-03-17):
+# ... the Azerbaijani Cabinet of Ministers has cancelled switching to
+# daylight saving time....
+# http://www.azernews.az/azerbaijan/94137.html
+# http://vestnikkavkaza.net/news/Azerbaijani-Cabinet-of-Ministers-cancels-daylight-saving-time.html
+# http://en.apa.az/xeber_azerbaijan_abolishes_daylight_savings_ti_240862.html
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
-Rule	Azer	1997	max	-	Mar	lastSun	 4:00	1:00	S
-Rule	Azer	1997	max	-	Oct	lastSun	 5:00	0	-
+Rule	Azer	1997	2015	-	Mar	lastSun	 4:00	1:00	S
+Rule	Azer	1997	2015	-	Oct	lastSun	 5:00	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Baku	3:19:24 -	LMT	1924 May  2
 			3:00	-	BAKT	1957 Mar    # Baku Time
@@ -1581,23 +1586,6 @@
 
 # Kazakhstan
 
-# From Paul Eggert (1996-11-22):
-# Andrew Evtichov (1996-04-13) writes that Kazakhstan
-# stayed in sync with Moscow after 1990, and that Aqtobe (formerly Aktyubinsk)
-# and Aqtau (formerly Shevchenko) are the largest cities in their zones.
-# Guess that Aqtau and Aqtobe diverged in 1995, since that's the first time
-# IATA SSIM mentions a third time zone in Kazakhstan.
-
-# From Paul Eggert (2006-03-22):
-# German Iofis, ELSI, Almaty (2001-10-09) reports that Kazakhstan uses
-# RussiaAsia rules, instead of switching at 00:00 as the IATA has it.
-# Go with Shanks & Pottenger, who have them always using RussiaAsia rules.
-# Also go with the following claims of Shanks & Pottenger:
-#
-# - Kazakhstan did not observe DST in 1991.
-# - Qyzylorda switched from +5:00 to +6:00 on 1992-01-19 02:00.
-# - Oral switched from +5:00 to +4:00 in spring 1989.
-
 # From Kazakhstan Embassy's News Bulletin No. 11
 # <http://www.kazsociety.org.uk/news/2005/03/30.htm> (2005-03-21):
 # The Government of Kazakhstan passed a resolution March 15 abolishing
@@ -1614,61 +1602,232 @@
 # everything else....  I guess that would make Kazakhstan time zones
 # de jure UTC+5 and UTC+6 respectively.
 
+# From Stepan Golosunov (2016-03-27) ([*] means see later comments below):
+# Review of the linked documents from http://adilet.zan.kz/
+# produced the following data for post-1991 Kazakhstan:
+#
+# 0. Act of the Cabinet of Ministers of the USSR
+# from 1991-02-04 No. 20
+# http://pravo.gov.ru/proxy/ips/?docbody=&nd=102010545
+# removed the extra hour ("decree time") on the territory of the USSR
+# starting with the last Sunday of March 1991.
+# It also allowed (but not mandated) Kazakh SSR, Kirghiz SSR, Tajik SSR,
+# Turkmen SSR and Uzbek SSR to not have "summer" time.
+#
+# The 1992-01-13 act also refers to the act of the Cabinet of Ministers
+# of the Kazakh SSR from 1991-03-20 No. 170 "About the act of the Cabinet
+# of Ministers of the USSR from 1991-02-04 No. 20" but I didn't found its
+# text.
+#
+# According to Izvestia newspaper No. 68 (23334) from 1991-03-20
+# (page 6; available at http://libinfo.org/newsr/newsr2574.djvu via
+# http://libinfo.org/index.php?id=58564) on 1991-03-31 at 2:00 during
+# transition to "summer" time:
+# Republic of Georgia, Latvian SSR, Lithuanian SSR, SSR Moldova,
+# Estonian SSR; Komi ASSR; Kaliningrad oblast; Nenets autonomous okrug
+# were to move clocks 1 hour forward.
+# Kazakh SSR (excluding Uralsk oblast); Republic of Kyrgyzstan, Tajik
+# SSR; Andijan, Jizzakh, Namangan, Sirdarya, Tashkent, Fergana oblasts
+# of the Uzbek SSR were to move clocks 1 hour backwards.
+# Other territories were to not move clocks.
+# When the "summer" time would end on 1991-09-29, clocks were to be
+# moved 1 hour backwards on the territory of the USSR excluding
+# Kazakhstan, Kirghizia, Uzbekistan, Turkmenia, Tajikistan.
+#
+# Apparently there were last minute changes. Apparently Kazakh act No. 170
+# was one of such changes.
+#
+# https://ru.wikipedia.org/wiki/Декретное время
+# claims that Sovetskaya Rossiya newspaper on 1991-03-29 published that
+# Nenets autonomous okrug, Komi and Kazakhstan (excluding Uralsk oblast)
+# were to not move clocks and Uralsk oblast was to move clocks
+# forward; on 1991-09-29 Kazakhstan was to move clocks backwards.
+# (Probably there were changes even after that publication. There is an
+# article claiming that Kaliningrad oblast decided on 1991-03-29 to not
+# move clocks.)
+#
+# This implies that on 1991-03-31 Asia/Oral remained on +04/+05 while
+# the rest of Kazakhstan switched from +06/+07 to +05/06 or from +05/06
+# to +04/+05. It's unclear how Kzyl-Orda oblast moved into the fifth
+# time belt. (By switching from +04/+05 to +05/+06 on 1991-09-29?) ...
+#
+# 1. Act of the Cabinet of Ministers of the Republic of Kazakhstan
+# from 1992-01-13 No. 28
+# http://adilet.zan.kz/rus/docs/P920000028_
+# (text includes modification from the 1996 act)
+# introduced new rules for calculation of time, mirroring Russian
+# 1992-01-08 act.  It specified that time would be calculated
+# according to time belts plus extra hour ("decree time"), moved clocks
+# on the whole territory of Kazakhstan 1 hour forward on 1992-01-19 at
+# 2:00, specified DST rules.  It acknowledged that Kazakhstan was
+# located in the fourth and the fifth time belts and specified the
+# border between them to be located east of Kustanay and Aktyubinsk
+# oblasts (notably including Turgai and Kzyl-Orda oblasts into the fifth
+# time belt).
+#
+# This means switch on 1992-01-19 at 2:00 from +04/+05 to +05/+06 for
+# Asia/Aqtau, Asia/Aqtobe, Asia/Oral, Atyrau and Kustanay oblasts; from
+# +05/+06 to +06/+07 for Asia/Almaty and Asia/Qyzylorda (and Arkalyk) [*]....
+#
+# 2. Act of the Cabinet of Ministers of the Republic of Kazakhstan
+# from 1992-03-27 No. 284
+# http://adilet.zan.kz/rus/docs/P920000284_
+# cancels extra hour ("decree time") for Uralsk and Kzyl-Orda oblasts
+# since the last Sunday of March 1992, while keeping them in the fourth
+# and the fifth time belts respectively.
+#
+# 3. Order of the Prime Minister of the Republic of Kazakhstan
+# from 1994-09-23 No. 384
+# http://adilet.zan.kz/rus/docs/R940000384_
+# cancels the extra hour ("decree time") on the territory of Mangystau
+# oblast since the last Sunday of September 1994 (saying that time on
+# the territory would correspond to the third time belt as a
+# result)....
+#
+# 4. Act of the Government of the Republic of Kazakhstan
+# from 1996-05-08 No. 575
+# http://adilet.zan.kz/rus/docs/P960000575_
+# amends the 1992-01-13 act to end summer time in October instead
+# of September, mirroring identical Russian change from 1996-04-23 act.
+#
+# 5. Act of the Government of the Republic of Kazakhstan
+# from 1999-03-26 No. 305
+# http://adilet.zan.kz/rus/docs/P990000305_
+# cancels the extra hour ("decree time") for Atyrau oblast since the
+# last Sunday of March 1999 while retaining the oblast in the fourth
+# time belt.
+#
+# This means change from +05/+06 to +04/+05.
+#
+# There is no zone for Atyrau currently (listed under Asia/Aqtau in
+# zone1970.tab).[*]
+#
+# 6. Act of the Government of the Republic of Kazakhstan
+# from 2000-11-23 No. 1749
+# http://adilet.zan.kz/rus/archive/docs/P000001749_/23.11.2000
+# replaces the previous five documents.
+#
+# The only changes I noticed are in definition of the border between the
+# fourth and the fifth time belts.  They account for changes in spelling
+# and administrative division (splitting of Turgai oblast in 1997
+# probably changed time in territories incorporated into Kostanay oblast
+# (including Arkalyk) from +06/+07 to +05/+06) and move Kyzylorda oblast
+# from being in the fifth time belt and not using decree time into the
+# fourth time belt (no change in practice).[*]
+#
+# 7. Act of the Government of the Republic of Kazakhstan
+# from 2003-12-29 No. 1342
+# http://adilet.zan.kz/rus/docs/P030001342_
+# modified the 2000-11-23 act.  No relevant changes, apparently.
+#
+# 8. Act of the Government of the Republic of Kazakhstan
+# from 2004-07-20 No. 775
+# http://adilet.zan.kz/rus/archive/docs/P040000775_/20.07.2004
+# modified the 2000-11-23 act to move Kostanay and Kyzylorda oblasts into
+# the fifth time belt and add Aktobe oblast to the list of regions not
+# using extra hour ("decree time"), leaving Kazakhstan with only 2 time
+# zones (+04/+05 and +06/+07).  The changes were to be implemented
+# during DST transitions in 2004 and 2005 but the acts got radically
+# amended before implementation happened.
+#
+# 9. Act of the Government of the Republic of Kazakhstan
+# from 2004-09-15 No. 1059
+# http://adilet.zan.kz/rus/docs/P040001059_
+# modified the 2000-11-23 act to remove exceptions from the "decree time"
+# (leaving Kazakhstan in +05/+06 and +06/+07 zones), amended the
+# 2004-07-20 act to implement changes for Atyrau, West Kazakhstan,
+# Kostanay, Kyzylorda and Mangystau oblasts by not moving clocks
+# during the 2014 transition to "winter" time.
+#
+# This means transition from +04/+05 to +05/+06 for Atyrau oblast (no
+# zone currently), Asia/Oral, Asia/Aqtau and transition from +05/+06 to
+# +06/+07 for Kostanay oblast (Kostanay and Arkalyk, no zones currently)
+# and Asia/Qyzylorda on 2004-10-31 at 3:00....[*]
+#
+# 10. Act of the Government of the Republic of Kazakhstan
+# from 2005-03-15 No. 231
+# http://adilet.zan.kz/rus/docs/P050000231_
+# removes DST provisions from the 2000-11-23 act, removes most of the
+# (already implemented) provisions from the 2004-07-20 and 2004-09-15
+# acts, comes into effect 10 days after official publication.
+# The only practical effect seems to be the abolition of the summer
+# time.
+#
+# Unamended version of the act of the Government of the Russian Federation
+# No. 23 from 1992-01-08 [See 'europe' file for details].
+# Kazakh 1992-01-13 act appears to provide the same rules and 1992-03-27
+# act was to be enacted on the last Sunday of March 1992.
+
+# From Paul Eggert (2016-04-15):
+# The tables below should reflect Stepan Golosunov's remarks above,
+# except for the items marked "[*]" which I haven't gotten to yet.
+# It looks like we will need new zones Asia/Atyrau and Asia/Qostanay
+# to handle changes from 1992 through 2004 that we did not previously
+# know about.
+
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 #
 # Almaty (formerly Alma-Ata), representing most locations in Kazakhstan
+# This includes KZ-AKM, KZ-ALA, KZ-ALM, KZ-AST, KZ-BAY, KZ-VOS, KZ-ZHA,
+# KZ-KAR, KZ-SEV, KZ-PAV, and KZ-YUZ.
 Zone	Asia/Almaty	5:07:48 -	LMT	1924 May  2 # or Alma-Ata
-			5:00	-	ALMT	1930 Jun 21 # Alma-Ata Time
-			6:00 RussiaAsia ALM%sT	1991
-			6:00	-	ALMT	1992
-			6:00 RussiaAsia	ALM%sT	2005 Mar 15
-			6:00	-	ALMT
-# Qyzylorda (aka Kyzylorda, Kizilorda, Kzyl-Orda, etc.)
+			5:00	-	+05	1930 Jun 21
+			6:00 RussiaAsia +06/+07	1991 Mar 31  2:00s
+			5:00 RussiaAsia	+05/+06	1992 Jan 19  2:00s
+			6:00 RussiaAsia	+06/+07	2004 Oct 31  2:00s
+			6:00	-	+06
+# Qyzylorda (aka Kyzylorda, Kizilorda, Kzyl-Orda, etc.) (KZ-KZY)
 Zone	Asia/Qyzylorda	4:21:52 -	LMT	1924 May  2
-			4:00	-	KIZT	1930 Jun 21 # Kizilorda Time
-			5:00	-	KIZT	1981 Apr  1
-			5:00	1:00	KIZST	1981 Oct  1
-			6:00	-	KIZT	1982 Apr  1
-			5:00 RussiaAsia	KIZ%sT	1991
-			5:00	-	KIZT	1991 Dec 16 # independence
-			5:00	-	QYZT	1992 Jan 19  2:00
-			6:00 RussiaAsia	QYZ%sT	2005 Mar 15
-			6:00	-	QYZT
-# Aqtobe (aka Aktobe, formerly Aktyubinsk)
+			4:00	-	+04	1930 Jun 21
+			5:00	-	+05	1981 Apr  1
+			5:00	1:00	+06	1981 Oct  1
+			6:00	-	+06	1982 Apr  1
+			5:00 RussiaAsia	+05/+06	1991 Mar 31  2:00s
+			4:00 RussiaAsia	+04/+05	1991 Sep 29  2:00s
+			5:00 RussiaAsia	+05/+06	1992 Jan 19  2:00s
+			6:00 RussiaAsia	+06/+07	1992 Mar 29  2:00s
+			5:00 RussiaAsia	+05/+06	2004 Oct 31  2:00s
+			6:00	-	+06
+# Aqtobe (aka Aktobe, formerly Aktyubinsk) (KZ-AKT)
 Zone	Asia/Aqtobe	3:48:40	-	LMT	1924 May  2
-			4:00	-	AKTT	1930 Jun 21 # Aktyubinsk Time
-			5:00	-	AKTT	1981 Apr  1
-			5:00	1:00	AKTST	1981 Oct  1
-			6:00	-	AKTT	1982 Apr  1
-			5:00 RussiaAsia	AKT%sT	1991
-			5:00	-	AKTT	1991 Dec 16 # independence
-			5:00 RussiaAsia	AQT%sT	2005 Mar 15 # Aqtobe Time
-			5:00	-	AQTT
-# Mangghystau
+			4:00	-	+04	1930 Jun 21
+			5:00	-	+05	1981 Apr  1
+			5:00	1:00	+06	1981 Oct  1
+			6:00	-	+06	1982 Apr  1
+			5:00 RussiaAsia	+05/+06	1991 Mar 31  2:00s
+			4:00 RussiaAsia	+04/+05	1992 Jan 19  2:00s
+			5:00 RussiaAsia	+05/+06	2004 Oct 31  2:00s
+			5:00	-	+05
+# Qostanay (KZ-KUS)
+
+# Mangghystau (KZ-MAN)
 # Aqtau was not founded until 1963, but it represents an inhabited region,
 # so include time stamps before 1963.
 Zone	Asia/Aqtau	3:21:04	-	LMT	1924 May  2
-			4:00	-	FORT	1930 Jun 21 # Fort Shevchenko T
-			5:00	-	FORT	1963
-			5:00	-	SHET	1981 Oct  1 # Shevchenko Time
-			6:00	-	SHET	1982 Apr  1
-			5:00 RussiaAsia	SHE%sT	1991
-			5:00	-	SHET	1991 Dec 16 # independence
-			5:00 RussiaAsia	AQT%sT	1995 Mar lastSun  2:00 # Aqtau Time
-			4:00 RussiaAsia	AQT%sT	2005 Mar 15
-			5:00	-	AQTT
-# West Kazakhstan
+			4:00	-	+04	1930 Jun 21
+			5:00	-	+05	1963
+			5:00	-	+05	1981 Oct  1
+			6:00	-	+06	1982 Apr  1
+			5:00 RussiaAsia	+05/+06	1991 Mar 31  2:00s
+			4:00 RussiaAsia	+04/+05	1992 Jan 19  2:00s
+			5:00 RussiaAsia	+05/+06	1994 Sep 25  2:00s
+			4:00 RussiaAsia	+04/+05	2004 Oct 31  2:00s
+			5:00	-	+05
+
+# West Kazakhstan (KZ-ZAP)
+# From Paul Eggert (2016-03-18):
+# The 1989 transition is from USSR act No. 227 (1989-03-14).
 Zone	Asia/Oral	3:25:24	-	LMT	1924 May  2 # or Ural'sk
-			4:00	-	URAT	1930 Jun 21 # Ural'sk time
-			5:00	-	URAT	1981 Apr  1
-			5:00	1:00	URAST	1981 Oct  1
-			6:00	-	URAT	1982 Apr  1
-			5:00 RussiaAsia	URA%sT	1989 Mar 26  2:00
-			4:00 RussiaAsia	URA%sT	1991
-			4:00	-	URAT	1991 Dec 16 # independence
-			4:00 RussiaAsia	ORA%sT	2005 Mar 15 # Oral Time
-			5:00	-	ORAT
+			4:00	-	+04	1930 Jun 21
+			5:00	-	+05	1981 Apr  1
+			5:00	1:00	+06	1981 Oct  1
+			6:00	-	+06	1982 Apr  1
+			5:00 RussiaAsia	+05/+06	1989 Mar 26  2:00s
+			4:00 RussiaAsia	+04/+05	1992 Jan 19  2:00s
+			5:00 RussiaAsia	+05/+06	1992 Mar 29  2:00s
+			4:00 RussiaAsia	+04/+05	2004 Oct 31  2:00s
+			5:00	-	+05
 
 # Kyrgyzstan (Kirgizstan)
 # Transitions through 1991 are from Shanks & Pottenger.
@@ -2419,6 +2578,16 @@
 # http://www.timeanddate.com/time/change/gaza-strip/gaza
 # http://www.timeanddate.com/time/change/west-bank/hebron
 
+# From Hannah Kreitem (2016-03-09):
+# http://www.palestinecabinet.gov.ps/WebSite/ar/ViewDetails?ID=31728
+# [Google translation]: "The Council also decided to start daylight
+# saving in Palestine as of one o'clock on Saturday morning,
+# 2016-03-26, to provide the clock 60 minutes ahead."
+#
+# From Paul Eggert (2016-03-12):
+# Predict spring transitions on March's last Saturday at 01:00 from now on.
+# Leave fall predictions alone for now.
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule EgyptAsia	1957	only	-	May	10	0:00	1:00	S
 Rule EgyptAsia	1957	1958	-	Oct	 1	0:00	0	-
@@ -2447,7 +2616,8 @@
 Rule Palestine	2012	only	-	Sep	21	1:00	0	-
 Rule Palestine	2013	only	-	Sep	Fri>=21	0:00	0	-
 Rule Palestine	2014	max	-	Oct	Fri>=21	0:00	0	-
-Rule Palestine	2015	max	-	Mar	lastFri	24:00	1:00	S
+Rule Palestine	2015	only	-	Mar	lastFri	24:00	1:00	S
+Rule Palestine	2016	max	-	Mar	lastSat	1:00	1:00	S
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Gaza	2:17:52	-	LMT	1900 Oct
diff --git a/jdk/test/sun/util/calendar/zi/tzdata/australasia b/jdk/test/sun/util/calendar/zi/tzdata/australasia
index 09afef2..929124c 100644
--- a/jdk/test/sun/util/calendar/zi/tzdata/australasia
+++ b/jdk/test/sun/util/calendar/zi/tzdata/australasia
@@ -83,6 +83,14 @@
 # Hamilton is the largest, but there is also a Hamilton in Victoria,
 # so use Lindeman.
 #
+# From J William Piggott (2016-02-20):
+# There is no location named Holiday Islands in Queensland Australia; holiday
+# islands is a colloquial term used globally.  Hayman and Lindeman are at the
+# north and south extremes of the Whitsunday Islands archipelago, and
+# Hamilton is in between; it is reasonable to believe that this time zone
+# applies to all of the Whitsundays.
+# http://www.australia.gov.au/about-australia/australian-story/austn-islands
+#
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	AQ	1971	only	-	Oct	lastSun	2:00s	1:00	D
 Rule	AQ	1972	only	-	Feb	lastSun	2:00s	0	S
diff --git a/jdk/test/sun/util/calendar/zi/tzdata/europe b/jdk/test/sun/util/calendar/zi/tzdata/europe
index 2679921..00a9fff 100644
--- a/jdk/test/sun/util/calendar/zi/tzdata/europe
+++ b/jdk/test/sun/util/calendar/zi/tzdata/europe
@@ -623,16 +623,40 @@
 Rule	Russia	1981	1983	-	Oct	 1	 0:00	0	-
 # Act No. 967 of the Council of Ministers of the USSR (1984-09-13), repeated in
 # Act No. 227 of the Council of Ministers of the USSR (1989-03-14):
-Rule	Russia	1984	1991	-	Sep	lastSun	 2:00s	0	-
-Rule	Russia	1985	1991	-	Mar	lastSun	 2:00s	1:00	S
+Rule	Russia	1984	1995	-	Sep	lastSun	 2:00s	0	-
+Rule	Russia	1985	2010	-	Mar	lastSun	 2:00s	1:00	S
 #
-Rule	Russia	1992	only	-	Mar	lastSat	 23:00	1:00	S
-Rule	Russia	1992	only	-	Sep	lastSat	 23:00	0	-
-Rule	Russia	1993	2010	-	Mar	lastSun	 2:00s	1:00	S
-Rule	Russia	1993	1995	-	Sep	lastSun	 2:00s	0	-
 Rule	Russia	1996	2010	-	Oct	lastSun	 2:00s	0	-
 # As described below, Russia's 2014 change affects Zone data, not Rule data.
 
+# From Stepan Golosunov (2016-03-07):
+# Wikipedia and other sources refer to the Act of the Council of
+# Ministers of the USSR from 1988-01-04 No. 5 and the Act of the
+# Council of Ministers of the USSR from 1989-03-14 No. 227.
+#
+# I did not find full texts of these acts.  For the 1989 one we have
+# title at http://base.garant.ru/70754136/ :
+# "About change in calculation of time on the territories of
+# Lithuanian SSR, Latvian SSR and Estonian SSR, Astrakhan,
+# Kaliningrad, Kirov, Kuybyshev, Ulyanovsk and Uralsk oblasts".
+# And http://astrozet.net/files/Zones/DOC/RU/1980-925.txt appears to
+# contain quotes from both acts: Since last Sunday of March 1988 rules
+# of the second time belt are installed in Volgograd and Saratov
+# oblasts.  Since last Sunday of March 1989:
+# a) Lithuanian SSR, Latvian SSR, Estonian SSR, Kaliningrad oblast:
+# second time belt rules without extra hour (Moscow-1);
+# b) Astrakhan, Kirov, Kuybyshev, Ulyanovsk oblasts: second time belt
+# rules (Moscow time)
+# c) Uralsk oblast: third time belt rules (Moscow+1).
+
+# From Stepan Golosunov (2016-03-27):
+# Unamended version of the act of the
+# Government of the Russian Federation No. 23 from 08.01.1992
+# http://pravo.gov.ru/proxy/ips/?docbody=&nd=102014034&rdk=0
+# says that every year clocks were to be moved forward on last Sunday
+# of March at 2 hours and moved backwards on last Sunday of September
+# at 3 hours.  It was amended in 1996 to replace September with October.
+
 # From Alexander Krivenyshev (2011-06-14):
 # According to Kremlin press service, Russian President Dmitry Medvedev
 # signed a federal law "On calculation of time" on June 9, 2011.
@@ -1028,6 +1052,12 @@
 # startkart.no says Thule does not observe DST, but this is clearly an error,
 # so go with Shanks & Pottenger for Thule transitions until this year.
 # For 2007 on assume Thule will stay in sync with US DST rules.
+
+# From J William Piggott (2016-02-20):
+# "Greenland north of the community of Scoresbysund" is officially named
+# "National Park" by Executive Order:
+# http://naalakkersuisut.gl/~/media/Nanoq/Files/Attached%20Files/Engelske-tekster/Legislation/Executive%20Order%20National%20Park.rtf
+# It is their only National Park.
 #
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Thule	1991	1992	-	Mar	lastSun	2:00	1:00	D
@@ -1053,6 +1083,10 @@
 			-4:00	Thule	A%sT
 
 # Estonia
+#
+# From Paul Eggert (2016-03-18):
+# The 1989 transition is from USSR act No. 227 (1989-03-14).
+#
 # From Peter Ilieve (1994-10-15):
 # A relative in Tallinn confirms the accuracy of the data for 1989 onwards
 # [through 1994] and gives the legal authority for it,
@@ -1646,6 +1680,9 @@
 
 # Lithuania
 
+# From Paul Eggert (2016-03-18):
+# The 1989 transition is from USSR act No. 227 (1989-03-14).
+
 # From Paul Eggert (1996-11-22):
 # IATA SSIM (1992/1996) says Lithuania uses W-Eur rules, but since it is
 # known to be wrong about Estonia and Latvia, assume it's wrong here too.
@@ -1685,8 +1722,8 @@
 			1:00	-	CET	1940 Aug  3
 			3:00	-	MSK	1941 Jun 24
 			1:00	C-Eur	CE%sT	1944 Aug
-			3:00	Russia	MSK/MSD	1991 Mar 31  2:00s
-			2:00	1:00	EEST	1991 Sep 29  2:00s
+			3:00	Russia	MSK/MSD	1989 Mar 26  2:00s
+			2:00	Russia	EE%sT	1991 Sep 29  2:00s
 			2:00	C-Eur	EE%sT	1998
 			2:00	-	EET	1998 Mar 29  1:00u
 			1:00	EU	CE%sT	1999 Oct 31  1:00u
@@ -1751,6 +1788,16 @@
 
 # Moldova
 
+# From Stepan Golosunov (2016-03-07):
+# the act of the government of the Republic of Moldova Nr. 132 from 1990-05-04
+# http://lex.justice.md/viewdoc.php?action=view&view=doc&id=298782&lang=2
+# ... says that since 1990-05-06 on the territory of the Moldavian SSR
+# time would be calculated as the standard time of the second time belt
+# plus one hour of the "summer" time. To implement that clocks would be
+# adjusted one hour backwards at 1990-05-06 2:00. After that "summer"
+# time would be cancelled last Sunday of September at 3:00 and
+# reintroduced last Sunday of March at 2:00.
+
 # From Paul Eggert (2006-03-22):
 # A previous version of this database followed Shanks & Pottenger, who write
 # that Tiraspol switched to Moscow time on 1992-01-19 at 02:00.
@@ -1809,9 +1856,7 @@
 			2:00	Romania	EE%sT	1940 Aug 15
 			2:00	1:00	EEST	1941 Jul 17
 			1:00	C-Eur	CE%sT	1944 Aug 24
-			3:00	Russia	MSK/MSD	1990
-			3:00	-	MSK	1990 May 6
-			2:00	-	EET	1991
+			3:00	Russia	MSK/MSD	1990 May  6  2:00
 			2:00	Russia	EE%sT	1992
 			2:00	E-Eur	EE%sT	1997
 # See Romania commentary for the guessed 1997 transition to EU rules.
@@ -2289,16 +2334,32 @@
 # Europe/Kaliningrad covers...
 # 39	RU-KGD	Kaliningrad Oblast
 
+# From Paul Eggert (2016-03-18):
+# The 1989 transition is from USSR act No. 227 (1989-03-14).
+
+# From Stepan Golosunov (2016-03-07):
+# http://www.rgo.ru/ru/kaliningradskoe-oblastnoe-otdelenie/ob-otdelenii/publikacii/kak-nam-zhilos-bez-letnego-vremeni
+# confirms that the 1989 change to Moscow-1 was implemented.
+# (The article, though, is misattributed to 1990 while saying that
+# summer->winter transition would be done on the 24 of September. But
+# 1990-09-24 was Monday, while 1989-09-24 was Sunday as expected.)
+# ...
+# http://www.kaliningradka.ru/site_pc/cherez/index.php?ELEMENT_ID=40091
+# says that Kaliningrad switched to Moscow-1 on 1989-03-26, avoided
+# at the last moment switch to Moscow-1 on 1991-03-31, switched to
+# Moscow on 1991-11-03, switched to Moscow-1 on 1992-01-19.
+
 Zone Europe/Kaliningrad	 1:22:00 -	LMT	1893 Apr
 			 1:00	C-Eur	CE%sT	1945
 			 2:00	Poland	CE%sT	1946
-			 3:00	Russia	MSK/MSD	1991 Mar 31  2:00s
+			 3:00	Russia	MSK/MSD	1989 Mar 26  2:00s
 			 2:00	Russia	EE%sT	2011 Mar 27  2:00s
 			 3:00	-	FET	2014 Oct 26  2:00s
 			 2:00	-	EET
 
 
-# From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2001-08-25):
+# From Paul Eggert (2016-02-21), per Tim Parenti (2014-07-03) and
+# Oscar van Vlijmen (2001-08-25):
 # Europe/Moscow covers...
 # 01	RU-AD	Adygea, Republic of
 # 05	RU-DA	Dagestan, Republic of
@@ -2341,12 +2402,92 @@
 # 68	RU-TAM	Tambov Oblast
 # 69	RU-TVE	Tver Oblast
 # 71	RU-TUL	Tula Oblast
-# 73	RU-ULY	Ulyanovsk Oblast
 # 76	RU-YAR	Yaroslavl Oblast
 # 77	RU-MOW	Moscow
 # 78	RU-SPE	Saint Petersburg
 # 83	RU-NEN	Nenets Autonomous Okrug
 
+# From Stepan Golosunov (2016-03-07):
+# 11. Regions-violators, 1981-1982.
+# Wikipedia refers to
+# http://maps.monetonos.ru/maps/raznoe/Old_Maps/Old_Maps/Articles/022/3_1981.html
+# http://besp.narod.ru/nauka_1981_3.htm
+#
+# The second link provides two articles scanned from the Nauka i Zhizn
+# magazine No. 3, 1981 and a scan of the short article attributed to
+# the Trud newspaper from February 1982.  The first link provides the
+# same Nauka i Zhizn articles converted to the text form (but misses
+# time belt changes map).
+#
+# The second Nauka i Zhizn article says that in addition to
+# introduction of summer time on 1981-04-01 there are some time belt
+# border changes on 1981-10-01, mostly affecting Nenets Autonomous
+# Okrug, Krasnoyarsk Krai, Yakutia, Magadan Oblast and Chukotka
+# according to the provided map (colored one).  In addition to that
+# "time violators" (regions which were not using rules of the time
+# belts in which they were located) would not be moving off the DST on
+# 1981-10-01 to restore the decree time usage.  (Komi ASSR was
+# supposed to repeat that move in October 1982 to account for the 2
+# hour difference.)  Map depicting "time violators" before 1981-10-01
+# is also provided.
+#
+# The article from Trud says that 1981-10-01 changes caused problems
+# and some territories would be moved to pre-1981-10-01 time by not
+# moving to summer time on 1982-04-01.  Namely: Dagestan,
+# Kabardino-Balkar, Kalmyk, Komi, Mari, Mordovian, North Ossetian,
+# Tatar, Chechen-Ingush and Chuvash ASSR, Krasnodar and Stavropol
+# krais, Arkhangelsk, Vladimir, Vologda, Voronezh, Gorky, Ivanovo,
+# Kostroma, Lipetsk, Penza, Rostov, Ryazan, Tambov, Tyumen and
+# Yaroslavl oblasts, Nenets and Evenk autonomous okrugs, Khatangsky
+# district of Taymyr Autonomous Okrug.  As a result Evenk Autonomous
+# Okrug and Khatangsky district of Taymyr Autonomous Okrug would end
+# up on Moscow+4, Tyumen Oblast on Moscow+2 and the rest on Moscow
+# time.
+#
+# http://astrozet.net/files/Zones/DOC/RU/1980-925.txt
+# attributes the 1982 changes to the Act of the Council of Ministers
+# of the USSR No. 126 from 18.02.1982.  1980-925.txt also adds
+# Udmurtia to the list of affected territories and lists Khatangsky
+# district separately from Taymyr Autonomous Okurg.  Probably erroneously.
+#
+# The affected territories are currently listed under Europe/Moscow,
+# Asia/Yekaterinburg and Asia/Krasnoyarsk.
+#
+# 12. Udmurtia
+# The fact that Udmurtia is depicted as a violator in the Nauka i
+# Zhizn article hints at Izhevsk being on different time from
+# Kuybyshev before 1981-10-01. Udmurtia is not mentioned in the 1989 act.
+# http://astrozet.net/files/Zones/DOC/RU/1980-925.txt
+# implies Udmurtia was on Moscow time after 1982-04-01.
+# Wikipedia implies Udmurtia being on Moscow+1 until 1991.
+#
+# ...
+#
+# All Russian zones are supposed to have by default a -1 change at
+# 1991-03-31 2:00 (cancellation of the decree time in the USSR) and a +1
+# change at 1992-01-19 2:00 (restoration of the decree time in Russia).
+#
+# There were some exceptions, though.
+# Wikipedia says newspapers listed Astrakhan, Saratov, Kirov, Volgograd,
+# Izhevsk, Grozny, Kazan and Samara as such exceptions for the 1992
+# change. (Different newspapers providing different lists. And some
+# lists found in the internet are quite wild.)
+#
+# And apparently some exceptions were reverted in the last moment.
+# http://www.kaliningradka.ru/site_pc/cherez/index.php?ELEMENT_ID=40091
+# says that Kaliningrad decided not to be an exception 2 days before the
+# 1991-03-31 switch and one person at
+# http://izhevsk.ru/forum_light_message/50/682597-m8369040.html
+# says he remembers that Samara opted out of the 1992-01-19 exception
+# 2 days before the switch.
+#
+#
+# From Paul Eggert (2016-03-18):
+# Given the above, we appear to be missing some Zone entries for the
+# chaotic early 1980s in Russia.  It's not clear what these entries
+# should be.  For now, sweep this under the rug and just document the
+# time in Moscow.
+
 # From Vladimir Karpinsky (2014-07-08):
 # LMT in Moscow (before Jul 3, 1916) is 2:30:17, that was defined by Moscow
 # Observatory (coordinates: 55 deg. 45'29.70", 37 deg. 34'05.30")....
@@ -2420,47 +2561,102 @@
 			 3:00	-	MSK
 
 
-# From Tim Parenti (2014-07-03):
-# Europe/Volgograd covers...
+# From Paul Eggert (2016-03-18):
+# Europe/Astrakhan covers:
 # 30	RU-AST	Astrakhan Oblast
-# 34	RU-VGG	Volgograd Oblast
-# 43	RU-KIR	Kirov Oblast
-# 64	RU-SAR	Saratov Oblast
+#
+# The 1989 transition is from USSR act No. 227 (1989-03-14).
 
-# From Paul Eggert (2006-05-09):
-# Shanks & Pottenger say Kirov is still at +0400 but Wikipedia says +0300.
-# Perhaps it switched after the others?  But we have no data.
+# From Alexander Krivenyshev (2016-01-12):
+# On February 10, 2016 Astrakhan Oblast got approval by the Federation
+# Council to change its time zone to UTC+4 (from current UTC+3 Moscow time)....
+# This Federal Law shall enter into force on 27 March 2016 at 02:00.
+# From Matt Johnson (2016-03-09):
+# http://publication.pravo.gov.ru/Document/View/0001201602150056
+
+Zone Europe/Astrakhan	 3:12:12 -	LMT	1924 May
+			 3:00	-	+03	1930 Jun 21
+			 4:00	Russia	+04/+05	1989 Mar 26  2:00s
+			 3:00	Russia	+03/+04	1991 Mar 31  2:00s
+			 4:00	-	+04	1992 Mar 29  2:00s
+			 3:00	Russia	+03/+04	2011 Mar 27  2:00s
+			 4:00	-	+04	2014 Oct 26  2:00s
+			 3:00	-	+03	2016 Mar 27  2:00s
+			 4:00	-	+04
+
+# From Paul Eggert (2016-03-18):
+# Europe/Volgograd covers:
+# 34	RU-VGG	Volgograd Oblast
+# 64	RU-SAR	Saratov Oblast
+# The 1988 transition is from USSR act No. 5 (1988-01-04).
 
 Zone Europe/Volgograd	 2:57:40 -	LMT	1920 Jan  3
 			 3:00	-	TSAT	1925 Apr  6 # Tsaritsyn Time
 			 3:00	-	STAT	1930 Jun 21 # Stalingrad Time
 			 4:00	-	STAT	1961 Nov 11
-			 4:00	Russia	VOL%sT	1989 Mar 26  2:00s # Volgograd T
+			 4:00	Russia	VOL%sT	1988 Mar 27  2:00s # Volgograd T
 			 3:00	Russia	VOL%sT	1991 Mar 31  2:00s
 			 4:00	-	VOLT	1992 Mar 29  2:00s
 			 3:00	Russia	MSK/MSD	2011 Mar 27  2:00s
 			 4:00	-	MSK	2014 Oct 26  2:00s
 			 3:00	-	MSK
 
+# From Paul Eggert (2016-03-18):
+# Europe/Kirov covers:
+# 43	RU-KIR	Kirov Oblast
+# The 1989 transition is from USSR act No. 227 (1989-03-14).
+#
+Zone Europe/Kirov	 3:18:48 -	LMT	1919 Jul  1  2:00
+			 3:00	-	+03	1930 Jun 21
+			 4:00	Russia	+04/+05	1989 Mar 26  2:00s
+			 3:00	Russia	+03/+04	1991 Mar 31  2:00s
+			 4:00	-	+04	1992 Mar 29  2:00s
+			 3:00	Russia	+03/+04	2011 Mar 27  2:00s
+			 4:00	-	+04	2014 Oct 26  2:00s
+			 3:00	-	+03
 
 # From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2001-08-25):
 # Europe/Samara covers...
 # 18	RU-UD	Udmurt Republic
 # 63	RU-SAM	Samara Oblast
 
+# From Paul Eggert (2016-03-18):
 # Byalokoz 1919 says Samara was 3:20:20.
+# The 1989 transition is from USSR act No. 227 (1989-03-14).
 
 Zone Europe/Samara	 3:20:20 -	LMT	1919 Jul  1  2:00
-			 3:00	-	SAMT	1930 Jun 21
+			 3:00	-	SAMT	1930 Jun 21 # Samara Time
 			 4:00	-	SAMT	1935 Jan 27
 			 4:00	Russia	KUY%sT	1989 Mar 26  2:00s # Kuybyshev
 			 3:00	Russia	MSK/MSD	1991 Mar 31  2:00s
 			 2:00	Russia	EE%sT	1991 Sep 29  2:00s
-			 3:00	-	KUYT	1991 Oct 20  3:00
-			 4:00	Russia	SAM%sT	2010 Mar 28  2:00s # Samara Time
+			 3:00	-	SAMT	1991 Oct 20  3:00
+			 4:00	Russia	SAM%sT	2010 Mar 28  2:00s
 			 3:00	Russia	SAM%sT	2011 Mar 27  2:00s
 			 4:00	-	SAMT
 
+# From Paul Eggert (2016-03-18):
+# Europe/Ulyanovsk covers:
+# 73	RU-ULY	Ulyanovsk Oblast
+
+# The 1989 transition is from USSR act No. 227 (1989-03-14).
+
+# From Alexander Krivenyshev (2016-02-17):
+# Ulyanovsk ... on their way to change time zones by March 27, 2016 at 2am.
+# Ulyanovsk Oblast ... from MSK to MSK+1 (UTC+3 to UTC+4) ...
+# 920582-6 ... 02/17/2016 The State Duma passed the bill in the first reading.
+# From Matt Johnson (2016-03-09):
+# http://publication.pravo.gov.ru/Document/View/0001201603090051
+
+Zone Europe/Ulyanovsk	 3:13:36 -	LMT	1919 Jul  1  2:00
+			 3:00	-	+03	1930 Jun 21
+			 4:00	Russia	+04/+05	1989 Mar 26  2:00s
+			 3:00	Russia	+03/+04	1991 Mar 31  2:00s
+			 2:00	Russia	+02/+03	1992 Jan 19  2:00s
+			 3:00	Russia	+03/+04	2011 Mar 27  2:00s
+			 4:00	-	+04	2014 Oct 26  2:00s
+			 3:00	-	+03	2016 Mar 27  2:00s
+			 4:00	-	+04
 
 # From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2001-08-25):
 # Asia/Yekaterinburg covers...
@@ -2494,8 +2690,6 @@
 
 # From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2001-08-25):
 # Asia/Omsk covers...
-# 04	RU-AL	Altai Republic
-# 22	RU-ALT	Altai Krai
 # 55	RU-OMS	Omsk Oblast
 
 # Byalokoz 1919 says Omsk was 4:53:30.
@@ -2508,14 +2702,49 @@
 			 7:00	-	OMST	2014 Oct 26  2:00s
 			 6:00	-	OMST
 
+# From Paul Eggert (2016-02-22):
+# Asia/Barnaul covers:
+# 04	RU-AL	Altai Republic
+# 22	RU-ALT	Altai Krai
 
-# From Tim Parenti (2014-07-03):
-# Asia/Novosibirsk covers...
+# Data before 1991 are from Shanks & Pottenger.
+
+# From Stepan Golosunov (2016-03-07):
+# Letter of Bank of Russia from 1995-05-25
+# http://www.bestpravo.ru/rossijskoje/lj-akty/y3a.htm
+# suggests that Altai Republic transitioned to Moscow+3 on
+# 1995-05-28.
+#
+# http://regnum.ru/news/society/1957270.html
+# has some historical data for Altai Krai:
+# before 1957: west part on UTC+6, east on UTC+7
+# after 1957: UTC+7
+# since 1995: UTC+6
+# http://barnaul.rusplt.ru/index/pochemu_altajskij_kraj_okazalsja_v_neprivychnom_chasovom_pojase-17648.html
+# confirms that and provides more details including 1995-05-28 transition date.
+
+# From Alexander Krivenyshev (2016-02-17):
+# Altai Krai and Altai Republic on their way to change time zones
+# by March 27, 2016 at 2am....
+# Altai Republic / Gorno-Altaysk MSK+3 to MSK+4 (UTC+6 to UTC+7) ...
+# Altai Krai / Barnaul MSK+3 to MSK+4 (UTC+6 to UTC+7)
+# From Matt Johnson (2016-03-09):
+# http://publication.pravo.gov.ru/Document/View/0001201603090043
+# http://publication.pravo.gov.ru/Document/View/0001201603090038
+
+Zone Asia/Barnaul	 5:35:00 -	LMT	1919 Dec 10
+			 6:00	-	+06	1930 Jun 21
+			 7:00	Russia	+07/+08	1991 Mar 31  2:00s
+			 6:00	Russia	+06/+07	1992 Jan 19  2:00s
+			 7:00	Russia	+07/+08	1995 May 28
+			 6:00	Russia	+06/+07	2011 Mar 27  2:00s
+			 7:00	-	+07	2014 Oct 26  2:00s
+			 6:00	-	+06	2016 Mar 27  2:00s
+			 7:00	-	+07
+
+# From Paul Eggert (2016-03-18):
+# Asia/Novosibirsk covers:
 # 54	RU-NVS	Novosibirsk Oblast
-# 70	RU-TOM	Tomsk Oblast
-
-# From Paul Eggert (2006-08-19): I'm guessing about Tomsk here; it's
-# not clear when it switched from +7 to +6.
 
 Zone Asia/Novosibirsk	 5:31:40 -	LMT	1919 Dec 14  6:00
 			 6:00	-	NOVT	1930 Jun 21 # Novosibirsk Time
@@ -2526,6 +2755,55 @@
 			 7:00	-	NOVT	2014 Oct 26  2:00s
 			 6:00	-	NOVT
 
+# From Paul Eggert (2016-03-18):
+# Asia/Tomsk covers:
+# 70	RU-TOM	Tomsk Oblast
+
+# From Stepan Golosunov (2016-03-24):
+# Byalokoz listed Tomsk at 5:39:51.
+
+# From Stanislaw A. Kuzikowski (1994-06-29):
+# Tomsk is still 4 hours ahead of Moscow.
+
+# From Stepan Golosunov (2016-03-19):
+# http://pravo.gov.ru/proxy/ips/?docbody=&nd=102075743
+# (fifth time belt being UTC+5+1(decree time)
+# / UTC+5+1(decree time)+1(summer time)) ...
+# Note that time belts (numbered from 2 (Moscow) to 12 according to their
+# GMT/UTC offset and having too many exceptions like regions formally
+# belonging to one belt but using time from another) were replaced
+# with time zones in 2011 with different numberings (there was a
+# 2-hour gap between second and third zones in 2011-2014).
+
+# From Stepan Golosunov (2016-04-12):
+# http://asozd2.duma.gov.ru/main.nsf/(SpravkaNew)?OpenAgent&RN=1006865-6
+# This bill was approved in the first reading today.  It moves Tomsk oblast
+# from UTC+6 to UTC+7 and is supposed to come into effect on 2016-05-29 at
+# 2:00.  The bill needs to be approved in the second and the third readings by
+# the State Duma, approved by the Federation Council, signed by the President
+# and published to become a law.  Minor changes in the text are to be expected
+# before the second reading (references need to be updated to account for the
+# recent changes).
+#
+# Judging by the ultra-short one-day amendments period, recent similar laws,
+# the State Duma schedule and the Federation Council schedule
+# http://www.duma.gov.ru/legislative/planning/day-shedule/por_vesna_2016/
+# http://council.gov.ru/activity/meetings/schedule/63303
+# I speculate that the final text of the bill will be proposed tomorrow, the
+# bill will be approved in the second and the third readings on Friday,
+# approved by the Federation Council on 2016-04-20, signed by the President and
+# published as a law around 2016-04-26.
+
+Zone	Asia/Tomsk	 5:39:51 -	LMT	1919 Dec 22
+			 6:00	-	+06	1930 Jun 21
+			 7:00	Russia	+07/+08	1991 Mar 31  2:00s
+			 6:00	Russia	+06/+07	1992 Jan 19  2:00s
+			 7:00	Russia	+07/+08	2002 May  1  3:00
+			 6:00	Russia	+06/+07	2011 Mar 27  2:00s
+			 7:00	-	+07	2014 Oct 26  2:00s
+			 6:00	-	+06	2016 May 29  2:00s
+			 7:00	-	+07
+
 
 # From Tim Parenti (2014-07-03):
 # Asia/Novokuznetsk covers...
@@ -2549,9 +2827,6 @@
 #
 # Thus, when Russia will switch to DST on the night of March 28, 2010
 # Kemerovo region (Kemerovo oblast') will not change the clock.
-#
-# As a result, Kemerovo oblast' will be in the same time zone as
-# Novosibirsk, Omsk, Tomsk, Barnaul and Altai Republic.
 
 # From Tim Parenti (2014-07-02), per Alexander Krivenyshev (2014-07-02):
 # The Kemerovo region will remain at UTC+7 through the 2014-10-26 change, thus
@@ -2620,7 +2895,7 @@
 # [The] time zone in the Trans-Baikal Territory (Zabaykalsky Krai) -
 # Asia/Chita [is changing] from UTC+8 to UTC+9.  Effective date will
 # be March 27, 2016 at 2:00am....
-# http://publication.pravo.gov.ru/Document/View/000120151230010
+# http://publication.pravo.gov.ru/Document/View/0001201512300107
 
 Zone Asia/Chita	 7:33:52 -	LMT	1919 Dec 15
 			 8:00	-	YAKT	1930 Jun 21 # Yakutsk Time
@@ -2731,6 +3006,11 @@
 # ...with the exception of:
 # 65-11	****	Severo-Kurilsky District (North Kuril Islands)
 
+# From Matt Johnson (2016-02-22):
+# Asia/Sakhalin is moving (in entirety) from UTC+10 to UTC+11 ...
+# (2016-03-09):
+# http://publication.pravo.gov.ru/Document/View/0001201603090044
+
 # The Zone name should be Asia/Yuzhno-Sakhalinsk, but that's too long.
 Zone Asia/Sakhalin	 9:30:48 -	LMT	1905 Aug 23
 			 9:00	-	JCST	1937 Oct  1
@@ -2740,7 +3020,8 @@
 			11:00	Russia	SAK%sT	1997 Mar lastSun  2:00s
 			10:00	Russia	SAK%sT	2011 Mar 27  2:00s
 			11:00	-	SAKT	2014 Oct 26  2:00s
-			10:00	-	SAKT
+			10:00	-	SAKT	2016 Mar 27  2:00s
+			11:00	-	SAKT
 
 
 # From Tim Parenti (2014-07-03), per Oscar van Vlijmen (2009-11-29):
@@ -2754,13 +3035,22 @@
 # until now by Asia/Magadan, will instead move to UTC+11.  These regions will
 # need their own zone.
 
+# From Alexander Krivenyshev (2016-03-27):
+# ... draft bill 948300-6 to change its time zone from UTC+10 to UTC+11 ...
+# will take ... effect ... on April 24, 2016 at 2 o'clock
+#
+# From Matt Johnson (2016-04-05):
+# ... signed by the President today ...
+# http://publication.pravo.gov.ru/Document/View/0001201604050038
+
 Zone Asia/Magadan	10:03:12 -	LMT	1924 May  2
 			10:00	-	MAGT	1930 Jun 21 # Magadan Time
 			11:00	Russia	MAG%sT	1991 Mar 31  2:00s
 			10:00	Russia	MAG%sT	1992 Jan 19  2:00s
 			11:00	Russia	MAG%sT	2011 Mar 27  2:00s
 			12:00	-	MAGT	2014 Oct 26  2:00s
-			10:00	-	MAGT
+			10:00	-	MAGT	2016 Apr 24  2:00s
+			11:00	-	MAGT
 
 
 # From Tim Parenti (2014-07-06):
diff --git a/jdk/test/sun/util/calendar/zi/tzdata/iso3166.tab b/jdk/test/sun/util/calendar/zi/tzdata/iso3166.tab
index 7fb3073..e47eefe 100644
--- a/jdk/test/sun/util/calendar/zi/tzdata/iso3166.tab
+++ b/jdk/test/sun/util/calendar/zi/tzdata/iso3166.tab
@@ -75,7 +75,7 @@
 BM	Bermuda
 BN	Brunei
 BO	Bolivia
-BQ	Caribbean Netherlands
+BQ	Caribbean NL
 BR	Brazil
 BS	Bahamas
 BT	Bhutan
@@ -186,7 +186,7 @@
 MC	Monaco
 MD	Moldova
 ME	Montenegro
-MF	St Martin (French part)
+MF	St Martin (French)
 MG	Madagascar
 MH	Marshall Islands
 MK	Macedonia
@@ -256,7 +256,7 @@
 SS	South Sudan
 ST	Sao Tome & Principe
 SV	El Salvador
-SX	St Maarten (Dutch part)
+SX	St Maarten (Dutch)
 SY	Syria
 SZ	Swaziland
 TC	Turks & Caicos Is
diff --git a/jdk/test/sun/util/calendar/zi/tzdata/leapseconds b/jdk/test/sun/util/calendar/zi/tzdata/leapseconds
index de698ea..a08fbc7 100644
--- a/jdk/test/sun/util/calendar/zi/tzdata/leapseconds
+++ b/jdk/test/sun/util/calendar/zi/tzdata/leapseconds
@@ -29,6 +29,7 @@
 # leap-seconds.list file available from most NIST time servers.
 # If the URL <ftp://time.nist.gov/pub/leap-seconds.list> does not work,
 # you should be able to pick up leap-seconds.list from a secondary NIST server.
+# See <http://tf.nist.gov/tf-cgi/servers.cgi> for a list of secondary servers.
 # For more about leap-seconds.list, please see
 # The NTP Timescale and Leap Seconds
 # http://www.eecis.udel.edu/~mills/leap.html
@@ -79,5 +80,5 @@
 Leap	2012	Jun	30	23:59:60	+	S
 Leap	2015	Jun	30	23:59:60	+	S
 
-#	Updated through IERS Bulletin C50
-#	File expires on:  28 June 2016
+#	Updated through IERS Bulletin C51
+#	File expires on:  28 December 2016
diff --git a/jdk/test/sun/util/calendar/zi/tzdata/northamerica b/jdk/test/sun/util/calendar/zi/tzdata/northamerica
index e56fd89..2124401 100644
--- a/jdk/test/sun/util/calendar/zi/tzdata/northamerica
+++ b/jdk/test/sun/util/calendar/zi/tzdata/northamerica
@@ -2498,13 +2498,22 @@
 			-6:00	-	CST	1981 Dec 23
 			-5:00	-	EST	1982 Dec  2
 			-6:00	Mexico	C%sT
-# Coahuila, Durango, Nuevo León, Tamaulipas (near US border)
+# Coahuila, Nuevo León, Tamaulipas (near US border)
+# This includes the following municipalities:
+#   in Coahuila: Ocampo, Acuña, Zaragoza, Jiménez, Piedras Negras, Nava,
+#     Guerrero, Hidalgo.
+#   in Nuevo León: Anáhuac, Los Aldama.
+#   in Tamaulipas: Nuevo Laredo, Guerrero, Mier, Miguel Alemán, Camargo,
+#     Gustavo Díaz Ordaz, Reynosa, Río Bravo, Valle Hermoso, Matamoros.
+# See: Inicia mañana Horario de Verano en zona fronteriza, El Universal,
+# 2016-03-12
+# http://www.eluniversal.com.mx/articulo/estados/2016/03/12/inicia-manana-horario-de-verano-en-zona-fronteriza
 Zone America/Matamoros	-6:40:00 -	LMT	1921 Dec 31 23:20:00
 			-6:00	-	CST	1988
 			-6:00	US	C%sT	1989
 			-6:00	Mexico	C%sT	2010
 			-6:00	US	C%sT
-# Coahuila, Durango, Nuevo León, Tamaulipas (away from US border)
+# Durango; Coahuila, Nuevo León, Tamaulipas (away from US border)
 Zone America/Monterrey	-6:41:16 -	LMT	1921 Dec 31 23:18:44
 			-6:00	-	CST	1988
 			-6:00	US	C%sT	1989
@@ -2520,6 +2529,9 @@
 			-6:00	-	CST	2002 Feb 20
 			-6:00	Mexico	C%sT
 # Chihuahua (near US border)
+# This includes the municipalities of Janos, Ascensión, Juárez, Guadalupe,
+# Práxedis G Guerrero, Coyame del Sotol, Ojinaga, and Manuel Benavides.
+# (See the 2016-03-12 El Universal source mentioned above.)
 Zone America/Ojinaga	-6:57:40 -	LMT	1922 Jan  1  0:02:20
 			-7:00	-	MST	1927 Jun 10 23:00
 			-6:00	-	CST	1930 Nov 15
@@ -2607,7 +2619,7 @@
 			-7:00	Mexico	M%sT	2010 Apr  4  2:00
 			-6:00	Mexico	C%sT
 
-# Baja California (near US border)
+# Baja California
 Zone America/Tijuana	-7:48:04 -	LMT	1922 Jan  1  0:11:56
 			-7:00	-	MST	1924
 			-8:00	-	PST	1927 Jun 10 23:00
@@ -3083,6 +3095,13 @@
 # http://radiovision2000haiti.net/public/haiti-avis-changement-dheure-dimanche/
 # http://www.canalplushaiti.net/?p=6714
 
+# From Steffen Thorsen (2016-03-12):
+# Jean Antoine, editor of www.haiti-reference.com informed us that Haiti
+# are not going on DST this year.  Several other resources confirm this: ...
+# http://www.radiotelevisioncaraibes.com/presse/heure_d_t_pas_de_changement_d_heure_pr_vu_pour_cet_ann_e.html
+# http://www.vantbefinfo.com/changement-dheure-pas-pour-haiti/
+# http://news.anmwe.com/haiti-lheure-nationale-ne-sera-ni-avancee-ni-reculee-cette-annee/
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Haiti	1983	only	-	May	8	0:00	1:00	D
 Rule	Haiti	1984	1987	-	Apr	lastSun	0:00	1:00	D
@@ -3093,8 +3112,8 @@
 Rule	Haiti	1988	1997	-	Oct	lastSun	1:00s	0	S
 Rule	Haiti	2005	2006	-	Apr	Sun>=1	0:00	1:00	D
 Rule	Haiti	2005	2006	-	Oct	lastSun	0:00	0	S
-Rule	Haiti	2012	max	-	Mar	Sun>=8	2:00	1:00	D
-Rule	Haiti	2012	max	-	Nov	Sun>=1	2:00	0	S
+Rule	Haiti	2012	2015	-	Mar	Sun>=8	2:00	1:00	D
+Rule	Haiti	2012	2015	-	Nov	Sun>=1	2:00	0	S
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone America/Port-au-Prince -4:49:20 -	LMT	1890
 			-4:49	-	PPMT	1917 Jan 24 12:00 # P-a-P MT
diff --git a/jdk/test/sun/util/calendar/zi/tzdata/southamerica b/jdk/test/sun/util/calendar/zi/tzdata/southamerica
index 0820186..b909089 100644
--- a/jdk/test/sun/util/calendar/zi/tzdata/southamerica
+++ b/jdk/test/sun/util/calendar/zi/tzdata/southamerica
@@ -1244,6 +1244,20 @@
 # From Paul Eggert (2015-03-03):
 # For now, assume that the extension will persist indefinitely.
 
+# From Juan Correa (2016-03-18):
+# The decree regarding DST has been published in today's Official Gazette:
+# http://www.diariooficial.interior.gob.cl/versiones-anteriores/do/20160318/
+# http://www.leychile.cl/Navegar?idNorma=1088502
+# It does consider the second Saturday of May and August as the dates
+# for the transition; and it lists DST dates until 2019, but I think
+# this scheme will stick.
+#
+# From Paul Eggert (2016-03-18):
+# For now, assume the pattern holds for the indefinite future.
+# The decree says transitions occur at 24:00; in practice this appears
+# to mean 24:00 mainland time, not 24:00 local time, so that Easter
+# Island is always two hours behind the mainland.
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Chile	1927	1931	-	Sep	 1	0:00	1:00	S
 Rule	Chile	1928	1932	-	Apr	 1	0:00	0	-
@@ -1275,8 +1289,10 @@
 Rule	Chile	2010	only	-	Apr	Sun>=1	3:00u	0	-
 Rule	Chile	2011	only	-	May	Sun>=2	3:00u	0	-
 Rule	Chile	2011	only	-	Aug	Sun>=16	4:00u	1:00	S
-Rule	Chile	2012	2015	-	Apr	Sun>=23	3:00u	0	-
+Rule	Chile	2012	2014	-	Apr	Sun>=23	3:00u	0	-
 Rule	Chile	2012	2014	-	Sep	Sun>=2	4:00u	1:00	S
+Rule	Chile	2016	max	-	May	Sun>=9	3:00u	0	-
+Rule	Chile	2016	max	-	Aug	Sun>=9	4:00u	1:00	S
 # IATA SSIM anomalies: (1992-02) says 1992-03-14;
 # (1996-09) says 1998-03-08.  Ignore these.
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
@@ -1293,13 +1309,11 @@
 			-4:00	1:00	CLST	1946 Sep  1 # central Chile
 			-4:00	-	CLT	1947 Apr  1
 			-5:00	-	CLT	1947 May 21 23:00
-			-4:00	Chile	CL%sT	2015 Apr 26  3:00u
-			-3:00	-	CLT
+			-4:00	Chile	CL%sT
 Zone Pacific/Easter	-7:17:28 -	LMT	1890
 			-7:17:28 -	EMT	1932 Sep    # Easter Mean Time
 			-7:00	Chile	EAS%sT	1982 Mar 14 3:00u # Easter Time
-			-6:00	Chile	EAS%sT	2015 Apr 26 3:00u
-			-5:00	-	EAST
+			-6:00	Chile	EAS%sT
 #
 # Salas y Gómez Island is uninhabited.
 # Other Chilean locations, including Juan Fernández Is, Desventuradas Is,
@@ -1321,8 +1335,7 @@
 Zone Antarctica/Palmer	0	-	zzz	1965
 			-4:00	Arg	AR%sT	1969 Oct  5
 			-3:00	Arg	AR%sT	1982 May
-			-4:00	Chile	CL%sT	2015 Apr 26 3:00u
-			-3:00	-	CLT
+			-4:00	Chile	CL%sT
 
 # Colombia
 
@@ -1765,9 +1778,25 @@
 # resolution publication)
 # http://www.globovision.com/news.php?nid=72208
 
+# From Alexander Krivenyshev (2016-04-15):
+# https://actualidad.rt.com/actualidad/204758-venezuela-modificar-huso-horario-sequia-elnino
+#
+# From Paul Eggert (2016-04-15):
+# Clocks advance 30 minutes on 2016-05-01 at 02:30. See:
+# Barboza AD. Huso horario en Venezuela volverá a 4 horas menos con
+# respecto al "Greenwich". Panorama 2016-04-15 12:20 -0430.
+# http://www.panorama.com.ve/ciudad/Huso-horario-en-Venezuela-volvera-a-4-horas-menos-con-respecto-al-Greenwich-20160415-0032.html
+#
+# "'Venezuela's new time-zone: hours without light, hours without water,
+# hours of presidential broadcasts, hours of lines," quipped comedian
+# Jean Mary Curro ...". See: Cawthorne A, Kai D. Venezuela scraps
+# half-hour time difference set by Chavez. Reuters 2016-04-15 14:50 -0400
+# http://www.reuters.com/article/us-venezuela-timezone-idUSKCN0XC2BE
+
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	America/Caracas	-4:27:44 -	LMT	1890
 			-4:27:40 -	CMT	1912 Feb 12 # Caracas Mean Time?
 			-4:30	-	VET	1965 Jan  1  0:00 # Venezuela T.
 			-4:00	-	VET	2007 Dec  9  3:00
-			-4:30	-	VET
+			-4:30	-	VET	2016 May  1  2:30
+			-4:00	-	VET
diff --git a/jdk/test/sun/util/calendar/zi/tzdata/zone.tab b/jdk/test/sun/util/calendar/zi/tzdata/zone.tab
index 51aaf77..5649691 100644
--- a/jdk/test/sun/util/calendar/zi/tzdata/zone.tab
+++ b/jdk/test/sun/util/calendar/zi/tzdata/zone.tab
@@ -53,22 +53,22 @@
 AL	+4120+01950	Europe/Tirane
 AM	+4011+04430	Asia/Yerevan
 AO	-0848+01314	Africa/Luanda
-AQ	-7750+16636	Antarctica/McMurdo	McMurdo, South Pole, Scott (New Zealand time)
-AQ	-6734-06808	Antarctica/Rothera	Rothera Station, Adelaide Island
-AQ	-6448-06406	Antarctica/Palmer	Palmer Station, Anvers Island
-AQ	-6736+06253	Antarctica/Mawson	Mawson Station, Holme Bay
-AQ	-6835+07758	Antarctica/Davis	Davis Station, Vestfold Hills
-AQ	-6617+11031	Antarctica/Casey	Casey Station, Bailey Peninsula
-AQ	-7824+10654	Antarctica/Vostok	Vostok Station, Lake Vostok
-AQ	-6640+14001	Antarctica/DumontDUrville	Dumont-d'Urville Station, Adelie Land
-AQ	-690022+0393524	Antarctica/Syowa	Syowa Station, E Ongul I
-AQ	-720041+0023206	Antarctica/Troll	Troll Station, Queen Maud Land
+AQ	-7750+16636	Antarctica/McMurdo	New Zealand time - McMurdo, South Pole
+AQ	-6617+11031	Antarctica/Casey	Casey
+AQ	-6835+07758	Antarctica/Davis	Davis
+AQ	-6640+14001	Antarctica/DumontDUrville	Dumont-d'Urville
+AQ	-6736+06253	Antarctica/Mawson	Mawson
+AQ	-6448-06406	Antarctica/Palmer	Palmer
+AQ	-6734-06808	Antarctica/Rothera	Rothera
+AQ	-690022+0393524	Antarctica/Syowa	Syowa
+AQ	-720041+0023206	Antarctica/Troll	Troll
+AQ	-7824+10654	Antarctica/Vostok	Vostok
 AR	-3436-05827	America/Argentina/Buenos_Aires	Buenos Aires (BA, CF)
-AR	-3124-06411	America/Argentina/Cordoba	most locations (CB, CC, CN, ER, FM, MN, SE, SF)
-AR	-2447-06525	America/Argentina/Salta	(SA, LP, NQ, RN)
+AR	-3124-06411	America/Argentina/Cordoba	Argentina (most areas: CB, CC, CN, ER, FM, MN, SE, SF)
+AR	-2447-06525	America/Argentina/Salta	Salta (SA, LP, NQ, RN)
 AR	-2411-06518	America/Argentina/Jujuy	Jujuy (JY)
 AR	-2649-06513	America/Argentina/Tucuman	Tucuman (TM)
-AR	-2828-06547	America/Argentina/Catamarca	Catamarca (CT), Chubut (CH)
+AR	-2828-06547	America/Argentina/Catamarca	Catamarca (CT); Chubut (CH)
 AR	-2926-06651	America/Argentina/La_Rioja	La Rioja (LR)
 AR	-3132-06831	America/Argentina/San_Juan	San Juan (SJ)
 AR	-3253-06849	America/Argentina/Mendoza	Mendoza (MZ)
@@ -79,17 +79,17 @@
 AT	+4813+01620	Europe/Vienna
 AU	-3133+15905	Australia/Lord_Howe	Lord Howe Island
 AU	-5430+15857	Antarctica/Macquarie	Macquarie Island
-AU	-4253+14719	Australia/Hobart	Tasmania - most locations
-AU	-3956+14352	Australia/Currie	Tasmania - King Island
+AU	-4253+14719	Australia/Hobart	Tasmania (most areas)
+AU	-3956+14352	Australia/Currie	Tasmania (King Island)
 AU	-3749+14458	Australia/Melbourne	Victoria
-AU	-3352+15113	Australia/Sydney	New South Wales - most locations
-AU	-3157+14127	Australia/Broken_Hill	New South Wales - Yancowinna
-AU	-2728+15302	Australia/Brisbane	Queensland - most locations
-AU	-2016+14900	Australia/Lindeman	Queensland - Holiday Islands
+AU	-3352+15113	Australia/Sydney	New South Wales (most areas)
+AU	-3157+14127	Australia/Broken_Hill	New South Wales (Yancowinna)
+AU	-2728+15302	Australia/Brisbane	Queensland (most areas)
+AU	-2016+14900	Australia/Lindeman	Queensland (Whitsunday Islands)
 AU	-3455+13835	Australia/Adelaide	South Australia
 AU	-1228+13050	Australia/Darwin	Northern Territory
-AU	-3157+11551	Australia/Perth	Western Australia - most locations
-AU	-3143+12852	Australia/Eucla	Western Australia - Eucla area
+AU	-3157+11551	Australia/Perth	Western Australia (most areas)
+AU	-3143+12852	Australia/Eucla	Western Australia (Eucla)
 AW	+1230-06958	America/Aruba
 AX	+6006+01957	Europe/Mariehamn
 AZ	+4023+04951	Asia/Baku
@@ -108,63 +108,63 @@
 BO	-1630-06809	America/La_Paz
 BQ	+120903-0681636	America/Kralendijk
 BR	-0351-03225	America/Noronha	Atlantic islands
-BR	-0127-04829	America/Belem	Amapa, E Para
-BR	-0343-03830	America/Fortaleza	NE Brazil (MA, PI, CE, RN, PB)
+BR	-0127-04829	America/Belem	Para (east); Amapa
+BR	-0343-03830	America/Fortaleza	Brazil (northeast: MA, PI, CE, RN, PB)
 BR	-0803-03454	America/Recife	Pernambuco
 BR	-0712-04812	America/Araguaina	Tocantins
 BR	-0940-03543	America/Maceio	Alagoas, Sergipe
 BR	-1259-03831	America/Bahia	Bahia
-BR	-2332-04637	America/Sao_Paulo	S & SE Brazil (GO, DF, MG, ES, RJ, SP, PR, SC, RS)
+BR	-2332-04637	America/Sao_Paulo	Brazil (southeast: GO, DF, MG, ES, RJ, SP, PR, SC, RS)
 BR	-2027-05437	America/Campo_Grande	Mato Grosso do Sul
 BR	-1535-05605	America/Cuiaba	Mato Grosso
-BR	-0226-05452	America/Santarem	W Para
+BR	-0226-05452	America/Santarem	Para (west)
 BR	-0846-06354	America/Porto_Velho	Rondonia
 BR	+0249-06040	America/Boa_Vista	Roraima
-BR	-0308-06001	America/Manaus	E Amazonas
-BR	-0640-06952	America/Eirunepe	W Amazonas
+BR	-0308-06001	America/Manaus	Amazonas (east)
+BR	-0640-06952	America/Eirunepe	Amazonas (west)
 BR	-0958-06748	America/Rio_Branco	Acre
 BS	+2505-07721	America/Nassau
 BT	+2728+08939	Asia/Thimphu
 BW	-2439+02555	Africa/Gaborone
 BY	+5354+02734	Europe/Minsk
 BZ	+1730-08812	America/Belize
-CA	+4734-05243	America/St_Johns	Newfoundland Time, including SE Labrador
-CA	+4439-06336	America/Halifax	Atlantic Time - Nova Scotia (peninsula), PEI
-CA	+4612-05957	America/Glace_Bay	Atlantic Time - Nova Scotia (Cape Breton)
-CA	+4606-06447	America/Moncton	Atlantic Time - New Brunswick
-CA	+5320-06025	America/Goose_Bay	Atlantic Time - Labrador - most locations
-CA	+5125-05707	America/Blanc-Sablon	Atlantic Standard Time - Quebec - Lower North Shore
-CA	+4339-07923	America/Toronto	Eastern Time - Ontario & Quebec - most locations
-CA	+4901-08816	America/Nipigon	Eastern Time - Ontario & Quebec - places that did not observe DST 1967-1973
-CA	+4823-08915	America/Thunder_Bay	Eastern Time - Thunder Bay, Ontario
-CA	+6344-06828	America/Iqaluit	Eastern Time - east Nunavut - most locations
-CA	+6608-06544	America/Pangnirtung	Eastern Time - Pangnirtung, Nunavut
-CA	+744144-0944945	America/Resolute	Central Time - Resolute, Nunavut
-CA	+484531-0913718	America/Atikokan	Eastern Standard Time - Atikokan, Ontario and Southampton I, Nunavut
-CA	+624900-0920459	America/Rankin_Inlet	Central Time - central Nunavut
-CA	+4953-09709	America/Winnipeg	Central Time - Manitoba & west Ontario
-CA	+4843-09434	America/Rainy_River	Central Time - Rainy River & Fort Frances, Ontario
-CA	+5024-10439	America/Regina	Central Standard Time - Saskatchewan - most locations
-CA	+5017-10750	America/Swift_Current	Central Standard Time - Saskatchewan - midwest
-CA	+5333-11328	America/Edmonton	Mountain Time - Alberta, east British Columbia & west Saskatchewan
-CA	+690650-1050310	America/Cambridge_Bay	Mountain Time - west Nunavut
-CA	+6227-11421	America/Yellowknife	Mountain Time - central Northwest Territories
-CA	+682059-1334300	America/Inuvik	Mountain Time - west Northwest Territories
-CA	+4906-11631	America/Creston	Mountain Standard Time - Creston, British Columbia
-CA	+5946-12014	America/Dawson_Creek	Mountain Standard Time - Dawson Creek & Fort Saint John, British Columbia
-CA	+5848-12242	America/Fort_Nelson	Mountain Standard Time - Fort Nelson, British Columbia
-CA	+4916-12307	America/Vancouver	Pacific Time - west British Columbia
-CA	+6043-13503	America/Whitehorse	Pacific Time - south Yukon
-CA	+6404-13925	America/Dawson	Pacific Time - north Yukon
+CA	+4734-05243	America/St_Johns	Newfoundland; Labrador (southeast)
+CA	+4439-06336	America/Halifax	Atlantic - NS (most areas); PE
+CA	+4612-05957	America/Glace_Bay	Atlantic - NS (Cape Breton)
+CA	+4606-06447	America/Moncton	Atlantic - New Brunswick
+CA	+5320-06025	America/Goose_Bay	Atlantic - Labrador (most areas)
+CA	+5125-05707	America/Blanc-Sablon	AST - QC (Lower North Shore)
+CA	+4339-07923	America/Toronto	Eastern - ON, QC (most areas)
+CA	+4901-08816	America/Nipigon	Eastern - ON, QC (no DST 1967-73)
+CA	+4823-08915	America/Thunder_Bay	Eastern - ON (Thunder Bay)
+CA	+6344-06828	America/Iqaluit	Eastern - NU (most east areas)
+CA	+6608-06544	America/Pangnirtung	Eastern - NU (Pangnirtung)
+CA	+484531-0913718	America/Atikokan	EST - ON (Atikokan); NU (Coral H)
+CA	+4953-09709	America/Winnipeg	Central - ON (west); Manitoba
+CA	+4843-09434	America/Rainy_River	Central - ON (Rainy R, Ft Frances)
+CA	+744144-0944945	America/Resolute	Central - NU (Resolute)
+CA	+624900-0920459	America/Rankin_Inlet	Central - NU (central)
+CA	+5024-10439	America/Regina	CST - SK (most areas)
+CA	+5017-10750	America/Swift_Current	CST - SK (midwest)
+CA	+5333-11328	America/Edmonton	Mountain - AB; BC (E); SK (W)
+CA	+690650-1050310	America/Cambridge_Bay	Mountain - NU (west)
+CA	+6227-11421	America/Yellowknife	Mountain - NT (central)
+CA	+682059-1334300	America/Inuvik	Mountain - NT (west)
+CA	+4906-11631	America/Creston	MST - BC (Creston)
+CA	+5946-12014	America/Dawson_Creek	MST - BC (Dawson Cr, Ft St John)
+CA	+5848-12242	America/Fort_Nelson	MST - BC (Ft Nelson)
+CA	+4916-12307	America/Vancouver	Pacific - BC (most areas)
+CA	+6043-13503	America/Whitehorse	Pacific - Yukon (south)
+CA	+6404-13925	America/Dawson	Pacific - Yukon (north)
 CC	-1210+09655	Indian/Cocos
-CD	-0418+01518	Africa/Kinshasa	west Dem. Rep. of Congo
-CD	-1140+02728	Africa/Lubumbashi	east Dem. Rep. of Congo
+CD	-0418+01518	Africa/Kinshasa	Dem. Rep. of Congo (west)
+CD	-1140+02728	Africa/Lubumbashi	Dem. Rep. of Congo (east)
 CF	+0422+01835	Africa/Bangui
 CG	-0416+01517	Africa/Brazzaville
 CH	+4723+00832	Europe/Zurich
 CI	+0519-00402	Africa/Abidjan
 CK	-2114-15946	Pacific/Rarotonga
-CL	-3327-07040	America/Santiago	most locations
+CL	-3327-07040	America/Santiago	Chile (most areas)
 CL	-2709-10926	Pacific/Easter	Easter Island
 CM	+0403+00942	Africa/Douala
 CN	+3114+12128	Asia/Shanghai	Beijing Time
@@ -177,28 +177,28 @@
 CX	-1025+10543	Indian/Christmas
 CY	+3510+03322	Asia/Nicosia
 CZ	+5005+01426	Europe/Prague
-DE	+5230+01322	Europe/Berlin	most locations
+DE	+5230+01322	Europe/Berlin	Germany (most areas)
 DE	+4742+00841	Europe/Busingen	Busingen
 DJ	+1136+04309	Africa/Djibouti
 DK	+5540+01235	Europe/Copenhagen
 DM	+1518-06124	America/Dominica
 DO	+1828-06954	America/Santo_Domingo
 DZ	+3647+00303	Africa/Algiers
-EC	-0210-07950	America/Guayaquil	mainland
+EC	-0210-07950	America/Guayaquil	Ecuador (mainland)
 EC	-0054-08936	Pacific/Galapagos	Galapagos Islands
 EE	+5925+02445	Europe/Tallinn
 EG	+3003+03115	Africa/Cairo
 EH	+2709-01312	Africa/El_Aaiun
 ER	+1520+03853	Africa/Asmara
-ES	+4024-00341	Europe/Madrid	mainland
-ES	+3553-00519	Africa/Ceuta	Ceuta & Melilla
+ES	+4024-00341	Europe/Madrid	Spain (mainland)
+ES	+3553-00519	Africa/Ceuta	Ceuta, Melilla
 ES	+2806-01524	Atlantic/Canary	Canary Islands
 ET	+0902+03842	Africa/Addis_Ababa
 FI	+6010+02458	Europe/Helsinki
 FJ	-1808+17825	Pacific/Fiji
 FK	-5142-05751	Atlantic/Stanley
-FM	+0725+15147	Pacific/Chuuk	Chuuk (Truk) and Yap
-FM	+0658+15813	Pacific/Pohnpei	Pohnpei (Ponape)
+FM	+0725+15147	Pacific/Chuuk	Chuuk/Truk, Yap
+FM	+0658+15813	Pacific/Pohnpei	Pohnpei/Ponape
 FM	+0519+16259	Pacific/Kosrae	Kosrae
 FO	+6201-00646	Atlantic/Faroe
 FR	+4852+00220	Europe/Paris
@@ -210,10 +210,10 @@
 GG	+4927-00232	Europe/Guernsey
 GH	+0533-00013	Africa/Accra
 GI	+3608-00521	Europe/Gibraltar
-GL	+6411-05144	America/Godthab	most locations
-GL	+7646-01840	America/Danmarkshavn	east coast, north of Scoresbysund
-GL	+7029-02158	America/Scoresbysund	Scoresbysund / Ittoqqortoormiit
-GL	+7634-06847	America/Thule	Thule / Pituffik
+GL	+6411-05144	America/Godthab	Greenland (most areas)
+GL	+7646-01840	America/Danmarkshavn	National Park (east coast)
+GL	+7029-02158	America/Scoresbysund	Scoresbysund/Ittoqqortoormiit
+GL	+7634-06847	America/Thule	Thule/Pituffik
 GM	+1328-01639	Africa/Banjul
 GN	+0931-01343	Africa/Conakry
 GP	+1614-06132	America/Guadeloupe
@@ -229,10 +229,10 @@
 HR	+4548+01558	Europe/Zagreb
 HT	+1832-07220	America/Port-au-Prince
 HU	+4730+01905	Europe/Budapest
-ID	-0610+10648	Asia/Jakarta	Java & Sumatra
-ID	-0002+10920	Asia/Pontianak	west & central Borneo
-ID	-0507+11924	Asia/Makassar	east & south Borneo, Sulawesi (Celebes), Bali, Nusa Tengarra, west Timor
-ID	-0232+14042	Asia/Jayapura	west New Guinea (Irian Jaya) & Malukus (Moluccas)
+ID	-0610+10648	Asia/Jakarta	Java, Sumatra
+ID	-0002+10920	Asia/Pontianak	Borneo (west, central)
+ID	-0507+11924	Asia/Makassar	Borneo (east, south); Sulawesi/Celebes, Bali, Nusa Tengarra; Timor (west)
+ID	-0232+14042	Asia/Jayapura	New Guinea (West Papua / Irian Jaya); Malukus/Moluccas
 IE	+5320-00615	Europe/Dublin
 IL	+314650+0351326	Asia/Jerusalem
 IM	+5409-00428	Europe/Isle_of_Man
@@ -258,10 +258,10 @@
 KR	+3733+12658	Asia/Seoul
 KW	+2920+04759	Asia/Kuwait
 KY	+1918-08123	America/Cayman
-KZ	+4315+07657	Asia/Almaty	most locations
-KZ	+4448+06528	Asia/Qyzylorda	Qyzylorda (Kyzylorda, Kzyl-Orda)
-KZ	+5017+05710	Asia/Aqtobe	Aqtobe (Aktobe)
-KZ	+4431+05016	Asia/Aqtau	Atyrau (Atirau, Gur'yev), Mangghystau (Mankistau)
+KZ	+4315+07657	Asia/Almaty	Kazakhstan (most areas)
+KZ	+4448+06528	Asia/Qyzylorda	Qyzylorda/Kyzylorda/Kzyl-Orda
+KZ	+5017+05710	Asia/Aqtobe	Aqtobe/Aktobe
+KZ	+4431+05016	Asia/Aqtau	Atyrau/Atirau/Gur'yev, Mangghystau/Mankistau
 KZ	+5113+05121	Asia/Oral	West Kazakhstan
 LA	+1758+10236	Asia/Vientiane
 LB	+3353+03530	Asia/Beirut
@@ -280,12 +280,12 @@
 ME	+4226+01916	Europe/Podgorica
 MF	+1804-06305	America/Marigot
 MG	-1855+04731	Indian/Antananarivo
-MH	+0709+17112	Pacific/Majuro	most locations
+MH	+0709+17112	Pacific/Majuro	Marshall Islands (most areas)
 MH	+0905+16720	Pacific/Kwajalein	Kwajalein
 MK	+4159+02126	Europe/Skopje
 ML	+1239-00800	Africa/Bamako
 MM	+1647+09610	Asia/Rangoon
-MN	+4755+10653	Asia/Ulaanbaatar	most locations
+MN	+4755+10653	Asia/Ulaanbaatar	Mongolia (most areas)
 MN	+4801+09139	Asia/Hovd	Bayan-Olgiy, Govi-Altai, Hovd, Uvs, Zavkhan
 MN	+4804+11430	Asia/Choibalsan	Dornod, Sukhbaatar
 MO	+2214+11335	Asia/Macau
@@ -297,19 +297,19 @@
 MU	-2010+05730	Indian/Mauritius
 MV	+0410+07330	Indian/Maldives
 MW	-1547+03500	Africa/Blantyre
-MX	+1924-09909	America/Mexico_City	Central Time - most locations
+MX	+1924-09909	America/Mexico_City	Central Time
 MX	+2105-08646	America/Cancun	Eastern Standard Time - Quintana Roo
 MX	+2058-08937	America/Merida	Central Time - Campeche, Yucatan
-MX	+2540-10019	America/Monterrey	Mexican Central Time - Coahuila, Durango, Nuevo Leon, Tamaulipas away from US border
-MX	+2550-09730	America/Matamoros	US Central Time - Coahuila, Durango, Nuevo Leon, Tamaulipas near US border
-MX	+2313-10625	America/Mazatlan	Mountain Time - S Baja, Nayarit, Sinaloa
-MX	+2838-10605	America/Chihuahua	Mexican Mountain Time - Chihuahua away from US border
-MX	+2934-10425	America/Ojinaga	US Mountain Time - Chihuahua near US border
+MX	+2540-10019	America/Monterrey	Central Time - Durango; Coahuila, Nuevo Leon, Tamaulipas (most areas)
+MX	+2550-09730	America/Matamoros	Central Time US - Coahuila, Nuevo Leon, Tamaulipas (US border)
+MX	+2313-10625	America/Mazatlan	Mountain Time - Baja California Sur, Nayarit, Sinaloa
+MX	+2838-10605	America/Chihuahua	Mountain Time - Chihuahua (most areas)
+MX	+2934-10425	America/Ojinaga	Mountain Time US - Chihuahua (US border)
 MX	+2904-11058	America/Hermosillo	Mountain Standard Time - Sonora
-MX	+3232-11701	America/Tijuana	US Pacific Time - Baja California state
-MX	+2048-10515	America/Bahia_Banderas	Mexican Central Time - Bahia de Banderas
-MY	+0310+10142	Asia/Kuala_Lumpur	peninsular Malaysia
-MY	+0133+11020	Asia/Kuching	Sabah & Sarawak
+MX	+3232-11701	America/Tijuana	Pacific Time US - Baja California
+MX	+2048-10515	America/Bahia_Banderas	Central Time - Bahia de Banderas
+MY	+0310+10142	Asia/Kuala_Lumpur	Malaysia (peninsula)
+MY	+0133+11020	Asia/Kuching	Sabah, Sarawak
 MZ	-2558+03235	Africa/Maputo
 NA	-2234+01706	Africa/Windhoek
 NC	-2216+16627	Pacific/Noumea
@@ -322,7 +322,7 @@
 NP	+2743+08519	Asia/Kathmandu
 NR	-0031+16655	Pacific/Nauru
 NU	-1901-16955	Pacific/Niue
-NZ	-3652+17446	Pacific/Auckland	most locations
+NZ	-3652+17446	Pacific/Auckland	New Zealand (most areas)
 NZ	-4357-17633	Pacific/Chatham	Chatham Islands
 OM	+2336+05835	Asia/Muscat
 PA	+0858-07932	America/Panama
@@ -330,7 +330,7 @@
 PF	-1732-14934	Pacific/Tahiti	Society Islands
 PF	-0900-13930	Pacific/Marquesas	Marquesas Islands
 PF	-2308-13457	Pacific/Gambier	Gambier Islands
-PG	-0930+14710	Pacific/Port_Moresby	most locations
+PG	-0930+14710	Pacific/Port_Moresby	Papua New Guinea (most areas)
 PG	-0613+15534	Pacific/Bougainville	Bougainville
 PH	+1435+12100	Asia/Manila
 PK	+2452+06703	Asia/Karachi
@@ -340,7 +340,7 @@
 PR	+182806-0660622	America/Puerto_Rico
 PS	+3130+03428	Asia/Gaza	Gaza Strip
 PS	+313200+0350542	Asia/Hebron	West Bank
-PT	+3843-00908	Europe/Lisbon	mainland
+PT	+3843-00908	Europe/Lisbon	Portugal (mainland)
 PT	+3238-01654	Atlantic/Madeira	Madeira Islands
 PT	+3744-02540	Atlantic/Azores	Azores
 PW	+0720+13429	Pacific/Palau
@@ -349,27 +349,32 @@
 RE	-2052+05528	Indian/Reunion
 RO	+4426+02606	Europe/Bucharest
 RS	+4450+02030	Europe/Belgrade
-RU	+5443+02030	Europe/Kaliningrad	Moscow-01 - Kaliningrad
-RU	+554521+0373704	Europe/Moscow	Moscow+00 - west Russia
-RU	+4457+03406	Europe/Simferopol	Moscow+00 - Crimea
-RU	+4844+04425	Europe/Volgograd	Moscow+00 - Caspian Sea
-RU	+5312+05009	Europe/Samara	Moscow+00 (Moscow+01 after 2014-10-26) - Samara, Udmurtia
-RU	+5651+06036	Asia/Yekaterinburg	Moscow+02 - Urals
-RU	+5500+07324	Asia/Omsk	Moscow+03 - west Siberia
-RU	+5502+08255	Asia/Novosibirsk	Moscow+03 - Novosibirsk
-RU	+5345+08707	Asia/Novokuznetsk	Moscow+03 (Moscow+04 after 2014-10-26) - Kemerovo
-RU	+5601+09250	Asia/Krasnoyarsk	Moscow+04 - Yenisei River
-RU	+5216+10420	Asia/Irkutsk	Moscow+05 - Lake Baikal
-RU	+5203+11328	Asia/Chita	Moscow+06 (Moscow+05 after 2014-10-26) - Zabaykalsky
-RU	+6200+12940	Asia/Yakutsk	Moscow+06 - Lena River
-RU	+623923+1353314	Asia/Khandyga	Moscow+06 - Tomponsky, Ust-Maysky
-RU	+4310+13156	Asia/Vladivostok	Moscow+07 - Amur River
-RU	+4658+14242	Asia/Sakhalin	Moscow+07 - Sakhalin Island
-RU	+643337+1431336	Asia/Ust-Nera	Moscow+07 - Oymyakonsky
-RU	+5934+15048	Asia/Magadan	Moscow+08 (Moscow+07 after 2014-10-26) - Magadan
-RU	+6728+15343	Asia/Srednekolymsk	Moscow+08 - E Sakha, N Kuril Is
-RU	+5301+15839	Asia/Kamchatka	Moscow+08 (Moscow+09 after 2014-10-26) - Kamchatka
-RU	+6445+17729	Asia/Anadyr	Moscow+08 (Moscow+09 after 2014-10-26) - Bering Sea
+RU	+5443+02030	Europe/Kaliningrad	MSK-01 - Kaliningrad
+RU	+554521+0373704	Europe/Moscow	MSK+00 - Moscow area
+RU	+4457+03406	Europe/Simferopol	MSK+00 - Crimea
+RU	+4844+04425	Europe/Volgograd	MSK+00 - Volgograd, Saratov
+RU	+5836+04939	Europe/Kirov	MSK+00 - Kirov
+RU	+4621+04803	Europe/Astrakhan	MSK+01 - Astrakhan
+RU	+5312+05009	Europe/Samara	MSK+01 - Samara, Udmurtia
+RU	+5420+04824	Europe/Ulyanovsk	MSK+01 - Ulyanovsk
+RU	+5651+06036	Asia/Yekaterinburg	MSK+02 - Urals
+RU	+5500+07324	Asia/Omsk	MSK+03 - Omsk
+RU	+5502+08255	Asia/Novosibirsk	MSK+03 - Novosibirsk
+RU	+5322+08345	Asia/Barnaul	MSK+04 - Altai
+RU	+5630+08458	Asia/Tomsk	MSK+04 - Tomsk
+RU	+5345+08707	Asia/Novokuznetsk	MSK+04 - Kemerovo
+RU	+5601+09250	Asia/Krasnoyarsk	MSK+04 - Krasnoyarsk area
+RU	+5216+10420	Asia/Irkutsk	MSK+05 - Irkutsk, Buryatia
+RU	+5203+11328	Asia/Chita	MSK+06 - Zabaykalsky
+RU	+6200+12940	Asia/Yakutsk	MSK+06 - Lena River
+RU	+623923+1353314	Asia/Khandyga	MSK+06 - Tomponsky, Ust-Maysky
+RU	+4310+13156	Asia/Vladivostok	MSK+07 - Amur River
+RU	+643337+1431336	Asia/Ust-Nera	MSK+07 - Oymyakonsky
+RU	+5934+15048	Asia/Magadan	MSK+08 - Magadan
+RU	+4658+14242	Asia/Sakhalin	MSK+08 - Sakhalin Island
+RU	+6728+15343	Asia/Srednekolymsk	MSK+08 - Sakha (E); North Kuril Is
+RU	+5301+15839	Asia/Kamchatka	MSK+09 - Kamchatka
+RU	+6445+17729	Asia/Anadyr	MSK+09 - Bering Sea
 RW	-0157+03004	Africa/Kigali
 SA	+2438+04643	Asia/Riyadh
 SB	-0932+16012	Pacific/Guadalcanal
@@ -408,45 +413,45 @@
 TV	-0831+17913	Pacific/Funafuti
 TW	+2503+12130	Asia/Taipei
 TZ	-0648+03917	Africa/Dar_es_Salaam
-UA	+5026+03031	Europe/Kiev	most locations
+UA	+5026+03031	Europe/Kiev	Ukraine (most areas)
 UA	+4837+02218	Europe/Uzhgorod	Ruthenia
-UA	+4750+03510	Europe/Zaporozhye	Zaporozh'ye, E Lugansk / Zaporizhia, E Luhansk
+UA	+4750+03510	Europe/Zaporozhye	Zaporozh'ye/Zaporizhia; Lugansk/Luhansk (east)
 UG	+0019+03225	Africa/Kampala
 UM	+1645-16931	Pacific/Johnston	Johnston Atoll
 UM	+2813-17722	Pacific/Midway	Midway Islands
 UM	+1917+16637	Pacific/Wake	Wake Island
-US	+404251-0740023	America/New_York	Eastern Time
-US	+421953-0830245	America/Detroit	Eastern Time - Michigan - most locations
-US	+381515-0854534	America/Kentucky/Louisville	Eastern Time - Kentucky - Louisville area
-US	+364947-0845057	America/Kentucky/Monticello	Eastern Time - Kentucky - Wayne County
-US	+394606-0860929	America/Indiana/Indianapolis	Eastern Time - Indiana - most locations
-US	+384038-0873143	America/Indiana/Vincennes	Eastern Time - Indiana - Daviess, Dubois, Knox & Martin Counties
-US	+410305-0863611	America/Indiana/Winamac	Eastern Time - Indiana - Pulaski County
-US	+382232-0862041	America/Indiana/Marengo	Eastern Time - Indiana - Crawford County
-US	+382931-0871643	America/Indiana/Petersburg	Eastern Time - Indiana - Pike County
-US	+384452-0850402	America/Indiana/Vevay	Eastern Time - Indiana - Switzerland County
-US	+415100-0873900	America/Chicago	Central Time
-US	+375711-0864541	America/Indiana/Tell_City	Central Time - Indiana - Perry County
-US	+411745-0863730	America/Indiana/Knox	Central Time - Indiana - Starke County
-US	+450628-0873651	America/Menominee	Central Time - Michigan - Dickinson, Gogebic, Iron & Menominee Counties
-US	+470659-1011757	America/North_Dakota/Center	Central Time - North Dakota - Oliver County
-US	+465042-1012439	America/North_Dakota/New_Salem	Central Time - North Dakota - Morton County (except Mandan area)
-US	+471551-1014640	America/North_Dakota/Beulah	Central Time - North Dakota - Mercer County
-US	+394421-1045903	America/Denver	Mountain Time
-US	+433649-1161209	America/Boise	Mountain Time - south Idaho & east Oregon
-US	+332654-1120424	America/Phoenix	Mountain Standard Time - Arizona (except Navajo)
-US	+340308-1181434	America/Los_Angeles	Pacific Time
-US	+611305-1495401	America/Anchorage	Alaska Time
-US	+581807-1342511	America/Juneau	Alaska Time - Alaska panhandle
-US	+571035-1351807	America/Sitka	Alaska Time - southeast Alaska panhandle
-US	+550737-1313435	America/Metlakatla	Alaska Time - Annette Island
-US	+593249-1394338	America/Yakutat	Alaska Time - Alaska panhandle neck
-US	+643004-1652423	America/Nome	Alaska Time - west Alaska
+US	+404251-0740023	America/New_York	Eastern (most areas)
+US	+421953-0830245	America/Detroit	Eastern - MI (most areas)
+US	+381515-0854534	America/Kentucky/Louisville	Eastern - KY (Louisville area)
+US	+364947-0845057	America/Kentucky/Monticello	Eastern - KY (Wayne)
+US	+394606-0860929	America/Indiana/Indianapolis	Eastern - IN (most areas)
+US	+384038-0873143	America/Indiana/Vincennes	Eastern - IN (Da, Du, K, Mn)
+US	+410305-0863611	America/Indiana/Winamac	Eastern - IN (Pulaski)
+US	+382232-0862041	America/Indiana/Marengo	Eastern - IN (Crawford)
+US	+382931-0871643	America/Indiana/Petersburg	Eastern - IN (Pike)
+US	+384452-0850402	America/Indiana/Vevay	Eastern - IN (Switzerland)
+US	+415100-0873900	America/Chicago	Central (most areas)
+US	+375711-0864541	America/Indiana/Tell_City	Central - IN (Perry)
+US	+411745-0863730	America/Indiana/Knox	Central - IN (Starke)
+US	+450628-0873651	America/Menominee	Central - MI (Wisconsin border)
+US	+470659-1011757	America/North_Dakota/Center	Central - ND (Oliver)
+US	+465042-1012439	America/North_Dakota/New_Salem	Central - ND (Morton rural)
+US	+471551-1014640	America/North_Dakota/Beulah	Central - ND (Mercer)
+US	+394421-1045903	America/Denver	Mountain (most areas)
+US	+433649-1161209	America/Boise	Mountain - ID (south); OR (east)
+US	+332654-1120424	America/Phoenix	MST - Arizona (except Navajo)
+US	+340308-1181434	America/Los_Angeles	Pacific
+US	+611305-1495401	America/Anchorage	Alaska (most areas)
+US	+581807-1342511	America/Juneau	Alaska - Juneau area
+US	+571035-1351807	America/Sitka	Alaska - Sitka area
+US	+550737-1313435	America/Metlakatla	Alaska - Annette Island
+US	+593249-1394338	America/Yakutat	Alaska - Yakutat
+US	+643004-1652423	America/Nome	Alaska (west)
 US	+515248-1763929	America/Adak	Aleutian Islands
 US	+211825-1575130	Pacific/Honolulu	Hawaii
 UY	-3453-05611	America/Montevideo
-UZ	+3940+06648	Asia/Samarkand	west Uzbekistan
-UZ	+4120+06918	Asia/Tashkent	east Uzbekistan
+UZ	+3940+06648	Asia/Samarkand	Uzbekistan (west)
+UZ	+4120+06918	Asia/Tashkent	Uzbekistan (east)
 VA	+415408+0122711	Europe/Vatican
 VC	+1309-06114	America/St_Vincent
 VE	+1030-06656	America/Caracas
diff --git a/langtools/.hgtags b/langtools/.hgtags
index b831e13..bca4109 100644
--- a/langtools/.hgtags
+++ b/langtools/.hgtags
@@ -384,6 +384,7 @@
 83eca922346e27ec42645e9630c04fbaec5eaf0f jdk8u40-b27
 d727ca30ce3c1b97ed9acd7380f8e4cf41813ffa jdk8u40-b31
 cc9fc1abb5aeffe2b6123c392a5c602a0ba75368 jdk8u40-b32
+6906fc8bc514aafdeccc242b0d22fc47769dc6cc jdk8u40-b33
 dbae37f50c43453f7d6f22d96adc8b5b6cd1e90d jdk8u45-b00
 244e6dc772877dfae6286530f58e11a210a48a3c jdk8u45-b01
 401ec76887623a29d3f868f9f9b18b42838d2e92 jdk8u45-b02
@@ -552,10 +553,12 @@
 4b10a2b486a9a950302de55e2495ac59bddae61a jdk8u74-b01
 55934388691bbbd9c53299cc6f2bdceb6af8860c jdk8u74-b02
 c5b33f88707967dc3b9ddb628e4efb57c0abc2db jdk8u74-b31
+d2cb84222adf21d60921ef467f14272a05e0ee5d jdk8u74-b32
 90b497af2ba5329448da3a46a185687ae17f7098 jdk8u75-b00
 374719365422fa4867bc68f4edb00403289cd862 jdk8u75-b01
 58a3f185c67cefee5ebf63fcc9c6da5e609c3705 jdk8u75-b02
 400115d04e6eac9af5a7ee7ab8b1c570e2a3803b jdk8u75-b03
+580f87c4d91aa8cc493dbbd84a1be9671fd733f3 jdk8u101-b00
 580f87c4d91aa8cc493dbbd84a1be9671fd733f3 jdk8u75-b04
 4fd1c0d25a9cb847d9a0f6fe2be011eed6910a7f jdk8u75-b05
 494f23cf6614142b0138fadccd2252506b2aa7f8 jdk8u75-b06
@@ -572,6 +575,7 @@
 4cbd08688ff5a39f936edf16dd765d1efa13d030 jdk8u91-b00
 5fa11675dbe55f49663a45d1d5a6c1a2d3b2ec28 jdk8u91-b13
 8921667c26ba5a83132c81ad8014d95a99631332 jdk8u91-b14
+15723e9dcff3db02d0726972fa1447a54977c2e3 jdk8u91-b15
 10ffafaf53404de7fd23784aa3ff6016d107b9c8 jdk8u76-b00
 0caab0d65a04d8cce71976a6bdc1ca0841bcbcf0 jdk8u76-b01
 78f0aa6199150e10f387989b9bd5997f72cdc4e1 jdk8u76-b02
@@ -591,3 +595,39 @@
 71176efa69475fc737d1245a28e739ddf105fd1c jdk8u92-b31
 4e8ce6c84e4ca9dd385012c10e059c15dbfcc468 jdk8u92-b32
 18568fe46895af6a7b562ffe6334a24fb5d9ee50 jdk8u92-b33
+3ca74ce54c351db2ac551e495a8b7ee65fb09e64 jdk8u92-b34
+580f87c4d91aa8cc493dbbd84a1be9671fd733f3 jdk8u81-b00
+a93c1e57407944362e05c79d756425e8c1274d9a jdk8u101-b01
+86a9d99ffadaf26b3d8417666a3600ea1ce7560f jdk8u101-b02
+6a0df041e6c9b0756f1cbc9e1fcb6f519b80d767 jdk8u101-b03
+90f493bfe1faca0573844fdd2497070c8b224d76 jdk8u101-b04
+52b1aad7837180baa6555b0b6a5e43e96aea2e19 jdk8u101-b05
+f29205468e32e848d8d5c93a6a150e72196c9714 jdk8u101-b06
+c48f57c9fd3a0cba272493de0a0830811b837bf7 jdk8u101-b07
+6d535f9f4d91edae7c53bd318d211e4ed0b99346 jdk8u101-b08
+0de58fd081950e211d4c2dcedec25dbb875cbf6d jdk8u101-b09
+20f3856902a522f01b28aa2aa38701606af83ab8 jdk8u101-b10
+5cc23fe55ff4c64838e2335644b674bdd0888340 jdk8u101-b11
+0cef544b9eee7042001a2b7f5f9e8a48ef20d779 jdk8u101-b12
+8dc8f71216bf40c259bb4127270922fb6a6ca293 jdk8u101-b13
+10ffafaf53404de7fd23784aa3ff6016d107b9c8 jdk8u76-b00
+0caab0d65a04d8cce71976a6bdc1ca0841bcbcf0 jdk8u76-b01
+78f0aa6199150e10f387989b9bd5997f72cdc4e1 jdk8u76-b02
+8969d6096fe123922bb3ac0c8f6f7b18c1c7668e jdk8u76-b03
+f8173fa5db9ba23e7cd935600f56a8a53157eb6e jdk8u76-b04
+dad1f3dd4a906542a656b3f07142f90c1630320e jdk8u102-b00
+dad1f3dd4a906542a656b3f07142f90c1630320e jdk8u82-b00
+6adcc437e39d4e16803ea2ec2f77c7b2b014512f jdk8u102-b01
+8a650e6924641eff6398fa8cda6e9fd6bd486e71 jdk8u102-b02
+8a8745bff8d5d6dbe64563e051cfd228d2e4d917 jdk8u102-b03
+614dc9771517839b3ed68b6b549bef1c370651c9 jdk8u102-b04
+7750594d9ceba010e36349bc20ee011edbb7c577 jdk8u102-b05
+12d34c63fb1f4191efee852148758c7af67659da jdk8u102-b06
+e6bb6f4d7b7d5179dbf902b6ada968a873b0c58b jdk8u102-b07
+87b26b3123355302fa8d16cbdcfcdfac60ba0275 jdk8u102-b08
+b0bfb7878d4aa8bedcd1c572449ed7c4109fc71b jdk8u102-b09
+0b35a6329ffb892ab8d99a67dcfda1dbc26be91c jdk8u102-b10
+592d155cc1332eba606900a7273863c74ef082a4 jdk8u102-b11
+16c58d7af5a4937e46bccd58114a56a7ffcd685c jdk8u102-b12
+56b0df415b570e31dc0b97d4a1c8f28b85240089 jdk8u102-b13
+0549bf2f507dae59bfcd7d11e038cdc62376fee7 jdk8u102-b14
diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
index a88b6a0..96148f0 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2014, 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
@@ -249,6 +249,7 @@
      *  are correct.
      *
      *  @param tree     The tree whose kind and type is checked
+     *  @param found    The computed type of the tree
      *  @param ownkind  The computed kind of the tree
      *  @param resultInfo  The expected result of the tree
      */
diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java b/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java
index 8733711..e50d192 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java
@@ -860,7 +860,7 @@
         private JCExpression makeReceiver(VarSymbol rcvr) {
             if (rcvr == null) return null;
             JCExpression rcvrExpr = make.Ident(rcvr);
-            Type rcvrType = tree.sym.enclClass().type;
+            Type rcvrType = tree.ownerAccessible ? tree.sym.enclClass().type : tree.expr.type;
             if (rcvrType == syms.arrayClass.type) {
                 // Map the receiver type to the actually type, not just "array"
                 rcvrType = tree.getQualifierExpression().type;
diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java
index eace107..064b3bb 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2014, 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
@@ -1007,7 +1007,7 @@
                 DeferredType dt = (DeferredType)found;
                 return dt.check(this);
             } else {
-                Type uResult = U(found.baseType());
+                Type uResult = U(found);
                 Type capturedType = pos == null || pos.getTree() == null ?
                         types.capture(uResult) :
                         checkContext.inferenceContext()
diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/GraphUtils.java b/langtools/src/share/classes/com/sun/tools/javac/util/GraphUtils.java
index f1be519..730336c 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/util/GraphUtils.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/GraphUtils.java
@@ -103,34 +103,60 @@
      * directed graph in linear time. Works on TarjanNode.
      */
     public static <D, N extends TarjanNode<D>> List<? extends List<? extends N>> tarjan(Iterable<? extends N> nodes) {
-        ListBuffer<List<N>> cycles = new ListBuffer<>();
-        ListBuffer<N> stack = new ListBuffer<>();
-        int index = 0;
-        for (N node: nodes) {
-            if (node.index == -1) {
-                index += tarjan(node, index, stack, cycles);
-            }
-        }
-        return cycles.toList();
+        Tarjan<D, N> tarjan = new Tarjan<>();
+        return tarjan.findSCC(nodes);
     }
 
-    private static <D, N extends TarjanNode<D>> int tarjan(N v, int index, ListBuffer<N> stack, ListBuffer<List<N>> cycles) {
-        v.index = index;
-        v.lowlink = index;
-        index++;
-        stack.prepend(v);
-        v.active = true;
-        for (TarjanNode<D> nd: v.getAllDependencies()) {
-            @SuppressWarnings("unchecked")
-            N n = (N)nd;
-            if (n.index == -1) {
-                tarjan(n, index, stack, cycles);
-                v.lowlink = Math.min(v.lowlink, n.lowlink);
-            } else if (stack.contains(n)) {
-                v.lowlink = Math.min(v.lowlink, n.index);
+    //where
+    private static class Tarjan<D, N extends TarjanNode<D>> {
+
+        /** Unique node identifier. */
+        int index = 0;
+
+        /** List of SCCs found so far. */
+        ListBuffer<List<N>> sccs = new ListBuffer<>();
+
+        /** Stack of all reacheable nodes from given root. */
+        ListBuffer<N> stack = new ListBuffer<>();
+
+        private List<? extends List<? extends N>> findSCC(Iterable<? extends N> nodes) {
+            for (N node : nodes) {
+                if (node.index == -1) {
+                    findSCC(node);
+                }
+            }
+            return sccs.toList();
+        }
+
+        private void findSCC(N v) {
+            visitNode(v);
+            for (TarjanNode<D> tn : v.getAllDependencies()) {
+                @SuppressWarnings("unchecked")
+                N n = (N)tn;
+                if (n.index == -1) {
+                    //it's the first time we see this node
+                    findSCC(n);
+                    v.lowlink = Math.min(v.lowlink, n.lowlink);
+                } else if (stack.contains(n)) {
+                    //this node is already reachable from current root
+                    v.lowlink = Math.min(v.lowlink, n.index);
+                }
+            }
+            if (v.lowlink == v.index) {
+                //v is the root of a SCC
+                addSCC(v);
             }
         }
-        if (v.lowlink == v.index) {
+
+        private void visitNode(N n) {
+            n.index = index;
+            n.lowlink = index;
+            index++;
+            stack.prepend(n);
+            n.active = true;
+        }
+
+        private void addSCC(N v) {
             N n;
             ListBuffer<N> cycle = new ListBuffer<>();
             do {
@@ -138,9 +164,8 @@
                 n.active = false;
                 cycle.add(n);
             } while (n != v);
-            cycles.add(cycle.toList());
+            sccs.add(cycle.toList());
         }
-        return index;
     }
 
     /**
diff --git a/langtools/test/tools/javac/conditional/ConditionalWithFinalStrings.java b/langtools/test/tools/javac/conditional/ConditionalWithFinalStrings.java
new file mode 100644
index 0000000..a9dbdf5
--- /dev/null
+++ b/langtools/test/tools/javac/conditional/ConditionalWithFinalStrings.java
@@ -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.
+ */
+
+/*
+ * @test
+ * @bug 8066871
+ * @summary java.lang.VerifyError: Bad local variable type - local final String
+ * @author Srikanth Sankaran
+ *
+ * @compile -g:none ConditionalWithFinalStrings.java
+ * @run main ConditionalWithFinalStrings
+ */
+
+public class ConditionalWithFinalStrings {
+
+        interface I {
+            String foo();
+        }
+
+        static class Tmp {
+                private String value;
+                public void setValue(String tmpStr) {
+                        this.value = tmpStr;
+                        if (!this.value.equals("YES"))
+                            throw new AssertionError();
+                }
+        }
+
+        void goo(I i) {
+            if (!i.foo().equals("YES"))
+                throw new AssertionError();
+        }
+
+        public void test() {
+                final String y = "YES";
+                final String n = "NO";
+                Tmp tmp = new Tmp();
+                tmp.setValue(true ? y : n);
+                goo (() -> y);
+
+        }
+        public static void main(String[] args) {
+                new ConditionalWithFinalStrings().test();
+                if (!id("Hello!").equals("Hello!"))
+                    throw new AssertionError();
+
+        }
+        static <Z> Z id(Z z) { return z; }
+}
diff --git a/langtools/test/tools/javac/generics/inference/8130304/T8130304.java b/langtools/test/tools/javac/generics/inference/8130304/T8130304.java
new file mode 100644
index 0000000..935648a
--- /dev/null
+++ b/langtools/test/tools/javac/generics/inference/8130304/T8130304.java
@@ -0,0 +1,74 @@
+/*
+ * 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
+ * @bug 8130304
+ * @summary Inference: NodeNotFoundException thrown with deep generic method call chain
+ * @compile T8130304.java
+ */
+class T8130304 {
+
+    void test() {
+        outer(
+            inner(),
+            inner(),
+            inner(),
+            inner(),
+            inner(),
+            inner(),
+            inner(),
+            inner(),
+            inner(),
+            inner(),
+            inner(),
+            inner(),
+            inner(),
+            inner(),
+            inner(),
+            inner(),
+            inner(),
+            inner(),
+            inner(),
+            inner(),
+            inner(),
+            inner(),
+            inner(),
+            inner(),
+            inner(),
+            inner(),
+            inner(),
+            inner(),
+            inner(),
+            inner(),
+            inner());
+    }
+
+    <T> void outer(T... ts) { }
+
+    <T,V,W extends V> T inner() {
+        return null;
+    }
+}
diff --git a/jdk/src/share/classes/sun/invoke/anon/InvalidConstantPoolFormatException.java b/langtools/test/tools/javac/generics/inference/8130304/T8130304b.java
similarity index 61%
copy from jdk/src/share/classes/sun/invoke/anon/InvalidConstantPoolFormatException.java
copy to langtools/test/tools/javac/generics/inference/8130304/T8130304b.java
index d420d34..8d7ba15 100644
--- a/jdk/src/share/classes/sun/invoke/anon/InvalidConstantPoolFormatException.java
+++ b/langtools/test/tools/javac/generics/inference/8130304/T8130304b.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2011, 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
@@ -23,23 +23,26 @@
  * questions.
  */
 
-package sun.invoke.anon;
-
-/** Exception used when there is an error in the constant pool
- *  format.
+/**
+ * @test
+ * @bug 8130304
+ * @summary Inference: NodeNotFoundException thrown with deep generic method call chain
+ * @compile T8130304b.java
  */
-public class InvalidConstantPoolFormatException extends Exception {
-    private static final long serialVersionUID=-6103888330523770949L;
+class T8130304b {
 
-    public InvalidConstantPoolFormatException(String message,Throwable cause) {
-        super(message,cause);
+    void test() {
+        TestZ r = null;
+        Crazy<String, String> x = r.m3("X");
+        r.m1(r.m4(r.m2(x, r.m3("a")), t -> "x"), r.m3("a"));
     }
 
-    public InvalidConstantPoolFormatException(String message) {
-        super(message);
-    }
+    interface Crazy<A, B> { }
 
-    public InvalidConstantPoolFormatException(Throwable cause) {
-        super(cause);
+    interface TestZ {
+        public <A, B> Crazy<A, B> m1(Crazy<A, ? extends B>... d);
+        public <A, B, C> Crazy<A, Crazy<B, C>> m2(Crazy<A, B> e, Crazy<A, C> f);
+        public <A> Crazy<A, A> m3(A g);
+        public <A, B, C> Crazy<A, C> m4(Crazy<A, B> h, java.util.function.Function<B, C> i);
     }
 }
diff --git a/langtools/test/tools/javac/lambda/MethodReference75.java b/langtools/test/tools/javac/lambda/MethodReference75.java
new file mode 100644
index 0000000..07bf748
--- /dev/null
+++ b/langtools/test/tools/javac/lambda/MethodReference75.java
@@ -0,0 +1,46 @@
+/*
+ * 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 8143647
+ * @summary Javac compiles method reference that allows results in an IllegalAccessError
+ * @run main MethodReference75
+ */
+
+import pkg.PublicDerived8143647;
+
+public class MethodReference75 {
+    public static void main(String[] args) {
+        if (java.util.Arrays
+                .asList(new PublicDerived8143647())
+                .stream()
+                .map(PublicDerived8143647::getX)
+                .findFirst()
+                .get()
+                .equals("PackagePrivateBase"))
+            System.out.println("OK");
+        else
+            throw new AssertionError("Unexpected output");
+    }
+}
diff --git a/hotspot/test/gc/8000311/Test8000311.java b/langtools/test/tools/javac/lambda/pkg/PublicDerived8143647.java
similarity index 65%
rename from hotspot/test/gc/8000311/Test8000311.java
rename to langtools/test/tools/javac/lambda/pkg/PublicDerived8143647.java
index 2c33191..f194afd 100644
--- a/hotspot/test/gc/8000311/Test8000311.java
+++ b/langtools/test/tools/javac/lambda/pkg/PublicDerived8143647.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -21,22 +21,13 @@
  * questions.
  */
 
-/**
- * @test Test8000311
- * @key gc
- * @bug 8000311
- * @summary G1: ParallelGCThreads==0 broken
- * @run main/othervm -XX:+UseG1GC -XX:ParallelGCThreads=0 -XX:+ResizePLAB -XX:+ExplicitGCInvokesConcurrent Test8000311
- * @author filipp.zhinkin@oracle.com
- */
+package pkg;
 
-import java.util.*;
-
-public class Test8000311 {
-  public static void main(String args[]) {
-    for(int i = 0; i<100; i++) {
-      byte[] garbage = new byte[1000];
-      System.gc();
+abstract class PackagePrivateBase8143647 {
+    public String getX() {
+        return "PackagePrivateBase";
     }
-  }
+}
+
+public class PublicDerived8143647 extends PackagePrivateBase8143647 {
 }
diff --git a/nashorn/.hgignore b/nashorn/.hgignore
index 6d68c1d..f00bef9 100644
--- a/nashorn/.hgignore
+++ b/nashorn/.hgignore
@@ -22,6 +22,6 @@
 CC/*
 jcov2/*
 .idea/*
-test/lib/testng.jar
+test/lib/*.jar
 test/script/external/*
 .project
diff --git a/nashorn/.hgtags b/nashorn/.hgtags
index fab1343..985e9ff 100644
--- a/nashorn/.hgtags
+++ b/nashorn/.hgtags
@@ -372,6 +372,7 @@
 c2dd88e89edc85b1bcb731d3296d0fcec1b78447 jdk8u40-b27
 e05552220ba82e465a1abfee90224b5b247e37bc jdk8u40-b31
 e1cc0fe0fd50fc4582e729897d7095ffce0f97ad jdk8u40-b32
+0130b5cb16e009195127cc13f828d6cf899fc4c7 jdk8u40-b33
 05a3614ed5276e5db2a73cce918be04b1a2922fb jdk8u45-b00
 21ec16eb7e6346c78b4fa67ccd6d2a9c58f0b696 jdk8u45-b01
 37b3ef9a07323afd2556d6837824db154cccc874 jdk8u45-b02
@@ -538,6 +539,7 @@
 69fa156c1ebe6a8d6587147967e8e27f6de37d99 jdk8u75-b01
 9cce1ba325c4bd8e922380c911d1a9ace79d6717 jdk8u75-b02
 541de42b57098a5009055cc92f1139473e32f19d jdk8u75-b03
+16d657d6cb22e832139a1cbc2ec23a5cf9db8985 jdk8u101-b00
 16d657d6cb22e832139a1cbc2ec23a5cf9db8985 jdk8u75-b04
 dfa12474455fa6f4c48a6dee986c24db257161ad jdk8u75-b05
 1f85973e9533f7c9b1bae1e00b76a2184c5eed4c jdk8u75-b06
@@ -553,6 +555,11 @@
 a2c005a7b33abed886cfb4309a846dd80c87bd4e jdk8u91-b00
 22925b345dffe4ba96fe2f429c4185cda1b30239 jdk8u91-b13
 6296644a2c9c30db0062117fc776341e937ca1f9 jdk8u91-b14
+32b80df71ca2a6ae827ba7042cea868f40e0a0dd jdk8u91-b15
+7bce03d47545e6a5341a2722168cd6bf697c4132 jdk8u77-b00
+678b645aa10aaf27895c87872c399c15daa026a1 jdk8u77-b01
+09abd795d1d143933224bcb3f12f5d4686b65373 jdk8u77-b02
+b6ee21a35619ce4d3b46a9b825438a3bc9bb63cd jdk8u77-b03
 9ff5c21813330147bf08389b3992534780c93247 jdk8u76-b00
 b7bbed8b05dd50c27050c7e10e20d25329dcd32b jdk8u76-b01
 4c1aa7b8c43c6fd38f9c13a6df2264378dd6a873 jdk8u76-b02
@@ -572,3 +579,34 @@
 ff47e8b14690edada1d0a4386e63bb4bc2f38ab4 jdk8u92-b31
 895bb16c7f9fe0c74317afef671a0d5ccde58afa jdk8u92-b32
 6c3f8e359668ec22e9c577d875cdb5a918534498 jdk8u92-b33
+59d90c3cc2bfdfda7664877d0e2529ef6c558558 jdk8u92-b34
+16d657d6cb22e832139a1cbc2ec23a5cf9db8985 jdk8u81-b00
+793156da7cc9c74489ab5fa5f5598bba172846e2 jdk8u101-b01
+79fc469a68bbe03f69919f4cebe0381df1b1d2a3 jdk8u101-b02
+d93088bdd15d507b35bc4ced85c6c748705511fc jdk8u101-b03
+9bd5aadd8e739d4ad4bb2e30741cdbe9ae2bae66 jdk8u101-b04
+a347853dbf17605c650532c4291bb9117d80f568 jdk8u101-b05
+3bc08e0d23a3965937e634d00e84ea69505e2653 jdk8u101-b06
+313c90baea02c1c8c162bea894c7adf6dc33a05b jdk8u101-b07
+926025d895a459bec2031a17e674c4aa5ebe6fe1 jdk8u101-b08
+47209e0bae1d65243158b3d8c2f6602cc265832c jdk8u101-b09
+740d8d604c0ef2b12d9835d2842f60dcc08fee0d jdk8u101-b10
+de5fdc537134ec505958a66d79c0ff68282520d2 jdk8u101-b11
+2f506194a131597352bbe1a08492266a8aed13f8 jdk8u101-b12
+44e4e6cbe15bf1674cfd7a03acfb962dd4339767 jdk8u101-b13
+120c1b8b458170ed017d2ee60cc9d63896eeb4b9 jdk8u102-b00
+120c1b8b458170ed017d2ee60cc9d63896eeb4b9 jdk8u82-b00
+79dcbdb92a8c39de6d1417557af9e6c2c03f806d jdk8u102-b01
+17416ae62bd720ebb53d20bb24272991084633bd jdk8u102-b02
+75728277aeee30f31c9418f37faf8f4216c539d7 jdk8u102-b03
+8ebcaf17bc745aa581aa8eff807da97f2f74058e jdk8u102-b04
+676a870491e5934e88d40cf2c68bef646c63b4ea jdk8u102-b05
+114e7557d33ce9e5f1bf982f45977a630c44d8a5 jdk8u102-b06
+13a10967cff181a71933a4f1508691553f43304b jdk8u102-b07
+31c898437a15f4feef6c1502d3f1eaf8a3d9de48 jdk8u102-b08
+e4f74a337545a0283f9b7bb6a85ce1b2c4a5fdd6 jdk8u102-b09
+3b84415442d7b4eaa4a7da75b9d428e81e8be575 jdk8u102-b10
+7bd6f4f266f66d32e4ce743928d7c4021c23c477 jdk8u102-b11
+e3db6994bbbd654be3ebd677b2cc80469f7133a3 jdk8u102-b12
+a010893ca6ee93c1a4832d1c484be6a119ca7ae4 jdk8u102-b13
+0948e61a3722ea7519323dffcce4f26430fe2881 jdk8u102-b14
diff --git a/nashorn/make/build.xml b/nashorn/make/build.xml
index 9e62722..e4ca328 100644
--- a/nashorn/make/build.xml
+++ b/nashorn/make/build.xml
@@ -49,9 +49,17 @@
     <condition property="git.executable" value="/usr/local/bin/git" else="git">
       <available file="/usr/local/bin/git"/>
     </condition>
-    <!-- check if testng.jar is avaiable -->
-    <available property="testng.available" file="${file.reference.testng.jar}"/>
-    <!-- check if Jemmy ang testng.jar are avaiable -->
+    <!-- check if TestNG and dependencies are available, and download them if they aren't -->
+    <antcall target="get-testng"/>
+    <condition property="testng.available" value="true">
+      <and>
+        <available file="${file.reference.testng.jar}"/>
+        <available file="${file.reference.jcommander.jar}"/>
+        <available file="${file.reference.bsh.jar}"/>
+        <available file="${file.reference.snakeyaml.jar}"/>
+      </and>
+    </condition>
+    <!-- check if Jemmy ang TestNG are avaiable -->
     <condition property="jemmy.jfx.testng.available" value="true">
       <and>
         <available file="${file.reference.jemmyfx.jar}"/>
@@ -214,6 +222,7 @@
     <javadoc destdir="${dist.javadoc.dir}" use="yes" overview="${src.dir}/overview.html" 
         extdirs="${nashorn.ext.path}" windowtitle="${nashorn.product.name} ${nashorn.version}"
         additionalparam="-quiet" failonerror="true" useexternalfile="true">
+      <arg value="${javadoc.option}"/>
       <classpath>
         <pathelement location="${build.classes.dir}"/>
       </classpath>
@@ -232,6 +241,7 @@
     <javadoc destdir="${dist.javadoc.dir}" use="yes" overview="${src.dir}/overview.html"
         extdirs="${nashorn.ext.path}" windowtitle="${nashorn.product.name} ${nashorn.version}"
         additionalparam="-quiet" failonerror="true" useexternalfile="true">
+      <arg value="${javadoc.option}"/>
       <classpath>
         <pathelement location="${build.classes.dir}"/>
       </classpath>
@@ -244,6 +254,7 @@
   <target name="javadocapi" depends="jar">
     <javadoc destdir="${dist.javadoc.dir}" use="yes" extdirs="${nashorn.ext.path}" 
         windowtitle="${nashorn.product.name}" additionalparam="-quiet" failonerror="true" useexternalfile="true">
+      <arg value="${javadoc.option}"/>
       <classpath>
         <pathelement location="${build.classes.dir}"/>
       </classpath>
@@ -275,7 +286,7 @@
   <target name="compile-test" depends="compile, run-nasgen" if="testng.available">
     <!-- testng task -->
     <taskdef name="testng" classname="org.testng.TestNGAntTask"
-        classpath="${file.reference.testng.jar}"/>
+        classpath="${testng.ant.classpath}"/>
 
     <javac srcdir="${test.src.dir}"
            destdir="${build.test.classes.dir}"
@@ -331,6 +342,15 @@
 grant codeBase "file:/${basedir}/${file.reference.testng.jar}" {
     permission java.security.AllPermission;
 };
+grant codeBase "file:/${basedir}/${file.reference.jcommander.jar}" {
+    permission java.security.AllPermission;
+};
+grant codeBase "file:/${basedir}/${file.reference.bsh.jar}" {
+    permission java.security.AllPermission;
+};
+grant codeBase "file:/${basedir}/${file.reference.snakeyaml.jar}" {
+    permission java.security.AllPermission;
+};
 //// in case of absolute path:
 grant codeBase "file:/${nashorn.internal.tests.jar}" {
     permission java.security.AllPermission;
@@ -339,6 +359,16 @@
 grant codeBase "file:/${file.reference.testng.jar}" {
     permission java.security.AllPermission;
 };
+grant codeBase "file:/${file.reference.jcommander.jar}" {
+    permission java.security.AllPermission;
+};
+grant codeBase "file:/${file.reference.bsh.jar}" {
+    permission java.security.AllPermission;
+};
+grant codeBase "file:/${file.reference.snakeyaml.jar}" {
+    permission java.security.AllPermission;
+};
+
 
 grant codeBase "file:/${basedir}/test/script/trusted/*" {
     permission java.security.AllPermission;
@@ -408,7 +438,7 @@
   </target>
 
   <target name="check-testng" unless="testng.available">
-    <echo message="WARNING: TestNG not available, will not run tests. Please copy testng.jar under ${test.lib} directory."/>
+    <echo message="WARNING: TestNG not available, will not run tests. Please copy TestNG and dependency JARs to the ${test.lib} directory."/>
   </target>
 
   <!-- only to be invoked as dependency of "test" target -->
@@ -480,7 +510,7 @@
     </testng>
   </target>
 
-  <target name="test" depends="get-testng, javadocnh, test-pessimistic, test-optimistic"/>
+  <target name="test" depends="prepare, javadocnh, test-pessimistic, test-optimistic"/>
 
   <target name="test-optimistic" depends="jar, -test-classes-all,-test-classes-single, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
     <echo message="Running test suite in OPTIMISTIC mode..."/>
@@ -507,7 +537,7 @@
   </target>
 
   <target name="check-jemmy.jfx.testng" unless="jemmy.jfx.testng.available">
-    <echo message="WARNING: Jemmy or JavaFX or TestNG not available, will not run tests. Please copy testng.jar, JemmyCore.jar, JemmyFX.jar, JemmyAWTInput.jar under test${file.separator}lib directory. And make sure you have jfxrt.jar in ${java.home}${file.separator}lib${file.separator}ext dir."/>
+    <echo message="WARNING: Jemmy or JavaFX or TestNG not available, will not run tests. Please copy TestNG and dependency JARs, JemmyCore.jar, JemmyFX.jar, JemmyAWTInput.jar to the test${file.separator}lib directory. And make sure you have jfxrt.jar in ${java.home}${file.separator}lib${file.separator}ext dir."/>
   </target>
 
   <target name="testjfx" depends="jar, get-testng, check-jemmy.jfx.testng, compile-test" if="jemmy.jfx.testng.available">
@@ -742,15 +772,13 @@
   <target name="perf" depends="externals, update-externals, sunspider, octane"/>
 
   <!-- download and install testng.jar -->
-  <target name="get-testng" depends="prepare" unless="testng.available">
-    <get src="http://testng.org/testng-6.8.zip" dest="${test.lib}" skipexisting="true" ignoreerrors="true"/>
-    <unzip src="${test.lib}${file.separator}testng-6.8.zip" dest="${test.lib}">
-      <patternset>
-        <include name="testng-6.8/testng-6.8.jar"/>
-      </patternset>
-    </unzip>
-    <move file="${test.lib}${file.separator}testng-6.8${file.separator}testng-6.8.jar" tofile="${test.lib}${file.separator}testng.jar"/>
-    <delete dir="${test.lib}${file.separator}testng-6.8"/>
+  <target name="get-testng">
+    <get dest="${test.lib}" skipexisting="true">
+      <url url="http://central.maven.org/maven2/org/testng/testng/6.8/testng-6.8.jar"/>
+      <url url="http://central.maven.org/maven2/com/beust/jcommander/1.27/jcommander-1.27.jar"/>
+      <url url="http://central.maven.org/maven2/org/beanshell/bsh/2.0b4/bsh-2.0b4.jar"/>
+      <url url="http://central.maven.org/maven2/org/yaml/snakeyaml/1.6/snakeyaml-1.6.jar"/>
+    </get>
   </target>
 
   <!-- run all tests -->
diff --git a/nashorn/make/project.properties b/nashorn/make/project.properties
index 1632f2c..b147b6c 100644
--- a/nashorn/make/project.properties
+++ b/nashorn/make/project.properties
@@ -33,6 +33,8 @@
 test.javac.source=1.8
 test.javac.target=1.8
 
+javadoc.option=-tag "implSpec:a:Implementation Requirements:"
+
 # nashorn version information
 nashorn.version=0.1
 nashorn.fullversion=0.1
@@ -83,7 +85,17 @@
 test.lib=${basedir}${file.separator}test${file.separator}lib
 
 # jars refererred
-file.reference.testng.jar=${test.lib}${file.separator}testng.jar
+file.reference.testng.jar=${test.lib}${file.separator}testng-6.8.jar
+file.reference.jcommander.jar=${test.lib}${file.separator}jcommander-1.27.jar
+file.reference.bsh.jar=${test.lib}${file.separator}bsh-2.0b4.jar
+file.reference.snakeyaml.jar=${test.lib}${file.separator}snakeyaml-1.6.jar
+
+# TestNG ant task classpath
+testng.ant.classpath=\
+    ${file.reference.testng.jar}${path.separator}\
+    ${file.reference.jcommander.jar}${path.separator}\
+    ${file.reference.bsh.jar}${path.separator}\
+    ${file.reference.snakeyaml.jar}${path.separator}
 
 # Set testng verbose level
 # From TestNG docs: "the verbosity level (0 to 10 where 10 is most detailed) 
@@ -112,7 +124,10 @@
 javac.test.classpath=\
     ${build.classes.dir}${path.separator}\
     ${build.test.classes.dir}${path.separator}\
-    ${file.reference.testng.jar}
+    ${file.reference.testng.jar}${path.separator}\
+    ${file.reference.jcommander.jar}${path.separator}\
+    ${file.reference.bsh.jar}${path.separator}\
+    ${file.reference.snakeyaml.jar}
 
 meta.inf.dir=${src.dir}/META-INF
 
@@ -251,6 +266,9 @@
     ${file.reference.jemmycore.jar}${path.separator}\
     ${file.reference.jemmyawtinput.jar}${path.separator}\
     ${file.reference.testng.jar}${path.separator}\
+    ${file.reference.jcommander.jar}${path.separator}\
+    ${file.reference.bsh.jar}${path.separator}\
+    ${file.reference.snakeyaml.jar}${path.separator}\
     ${nashorn.internal.tests.jar}${path.separator}\
     ${nashorn.api.tests.jar}
 
@@ -259,6 +277,9 @@
 
 run.test.classpath=\
     ${file.reference.testng.jar}${path.separator}\
+    ${file.reference.jcommander.jar}${path.separator}\
+    ${file.reference.bsh.jar}${path.separator}\
+    ${file.reference.snakeyaml.jar}${path.separator}\
     ${nashorn.internal.tests.jar}${path.separator}\
     ${nashorn.api.tests.jar}
 
diff --git a/nashorn/samples/lines.js b/nashorn/samples/lines.js
new file mode 100644
index 0000000..18b432d
--- /dev/null
+++ b/nashorn/samples/lines.js
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle 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.
+ */
+
+var Files = java.nio.file.Files;
+var File = java.io.File;
+var d = arguments.length == 0? "." : arguments[0];
+
+// print total number of lines in all .java files under a
+// given directory (recursively)
+
+print(Files.walk(new File(d).toPath()).
+  filter(function(p) p.toString().endsWith(".java")).
+  mapToInt(function(p) Files.lines(p).count()).sum())
diff --git a/nashorn/src/jdk/nashorn/api/scripting/AbstractJSObject.java b/nashorn/src/jdk/nashorn/api/scripting/AbstractJSObject.java
index 680198d..48e936b 100644
--- a/nashorn/src/jdk/nashorn/api/scripting/AbstractJSObject.java
+++ b/nashorn/src/jdk/nashorn/api/scripting/AbstractJSObject.java
@@ -27,6 +27,7 @@
 
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Objects;
 import java.util.Set;
 import jdk.nashorn.internal.runtime.JSONListAdapter;
 import jdk.nashorn.internal.runtime.JSType;
@@ -36,7 +37,7 @@
  *
  * This class can also be subclassed by an arbitrary Java class. Nashorn will
  * treat objects of such classes just like nashorn script objects. Usual nashorn
- * operations like obj[i], obj.foo, obj.func(), delete obj.foo will be glued
+ * operations like obj[i], obj.foo, obj.func(), delete obj.foo will be delegated
  * to appropriate method call of this class.
  *
  * @since 1.8u40
@@ -44,12 +45,12 @@
 @jdk.Exported
 public abstract class AbstractJSObject implements JSObject {
     /**
-     * Call this object as a JavaScript function. This is equivalent to
-     * 'func.apply(thiz, args)' in JavaScript.
-     *
-     * @param thiz 'this' object to be passed to the function
-     * @param args arguments to method
-     * @return result of call
+     * The default constructor.
+     */
+    public AbstractJSObject() {}
+
+    /**
+     * @implSpec This implementation always throws UnsupportedOperationException
      */
     @Override
     public Object call(final Object thiz, final Object... args) {
@@ -57,11 +58,7 @@
     }
 
     /**
-     * Call this 'constructor' JavaScript function to create a new object.
-     * This is equivalent to 'new func(arg1, arg2...)' in JavaScript.
-     *
-     * @param args arguments to method
-     * @return result of constructor call
+     * @implSpec This implementation always throws UnsupportedOperationException
      */
     @Override
     public Object newObject(final Object... args) {
@@ -69,10 +66,7 @@
     }
 
     /**
-     * Evaluate a JavaScript expression.
-     *
-     * @param s JavaScript expression to evaluate
-     * @return evaluation result
+     * @implSpec This imlementation always throws UnsupportedOperationException
      */
     @Override
     public Object eval(final String s) {
@@ -80,21 +74,16 @@
     }
 
     /**
-     * Retrieves a named member of this JavaScript object.
-     *
-     * @param name of member
-     * @return member
+     * @implSpec This implementation always returns null
      */
     @Override
     public Object getMember(final String name) {
+        Objects.requireNonNull(name);
         return null;
     }
 
     /**
-     * Retrieves an indexed member of this JavaScript object.
-     *
-     * @param index index slot to retrieve
-     * @return member
+     * @implSpec This implementation always returns null
      */
     @Override
     public Object getSlot(final int index) {
@@ -102,21 +91,16 @@
     }
 
     /**
-     * Does this object have a named member?
-     *
-     * @param name name of member
-     * @return true if this object has a member of the given name
+     * @implSpec This implementation always returns false
      */
     @Override
     public boolean hasMember(final String name) {
+        Objects.requireNonNull(name);
         return false;
     }
 
     /**
-     * Does this object have a indexed property?
-     *
-     * @param slot index to check
-     * @return true if this object has a slot
+     * @implSpec This implementation always returns false
      */
     @Override
     public boolean hasSlot(final int slot) {
@@ -124,31 +108,25 @@
     }
 
     /**
-     * Remove a named member from this JavaScript object
-     *
-     * @param name name of the member
+     * @implSpec This implementation is a no-op
      */
     @Override
     public void removeMember(final String name) {
+        Objects.requireNonNull(name);
         //empty
     }
 
     /**
-     * Set a named member in this JavaScript object
-     *
-     * @param name  name of the member
-     * @param value value of the member
+     * @implSpec This implementation is a no-op
      */
     @Override
     public void setMember(final String name, final Object value) {
+        Objects.requireNonNull(name);
         //empty
     }
 
     /**
-     * Set an indexed member in this JavaScript object
-     *
-     * @param index index of the member slot
-     * @param value value of the member
+     * @implSpec This implementation is a no-op
      */
     @Override
     public void setSlot(final int index, final Object value) {
@@ -158,9 +136,7 @@
     // property and value iteration
 
     /**
-     * Returns the set of all property names of this object.
-     *
-     * @return set of property names
+     * @implSpec This implementation returns empty set
      */
     @Override
     public Set<String> keySet() {
@@ -168,9 +144,7 @@
     }
 
     /**
-     * Returns the set of all property values of this object.
-     *
-     * @return set of property values.
+     * @implSpec This implementation returns empty set
      */
     @Override
     public Collection<Object> values() {
@@ -180,22 +154,13 @@
     // JavaScript instanceof check
 
     /**
-     * Checking whether the given object is an instance of 'this' object.
-     *
-     * @param instance instance to check
-     * @return true if the given 'instance' is an instance of this 'function' object
+     * @implSpec This implementation always returns false
      */
     @Override
     public boolean isInstance(final Object instance) {
         return false;
     }
 
-    /**
-     * Checking whether this object is an instance of the given 'clazz' object.
-     *
-     * @param clazz clazz to check
-     * @return true if this object is an instance of the given 'clazz'
-     */
     @Override
     public boolean isInstanceOf(final Object clazz) {
         if (clazz instanceof JSObject) {
@@ -205,20 +170,13 @@
         return false;
     }
 
-    /**
-     * ECMA [[Class]] property
-     *
-     * @return ECMA [[Class]] property value of this object
-     */
     @Override
     public String getClassName() {
         return getClass().getName();
     }
 
     /**
-     * Is this a function object?
-     *
-     * @return if this mirror wraps a ECMAScript function instance
+     * @implSpec This implementation always returns false
      */
     @Override
     public boolean isFunction() {
@@ -226,9 +184,7 @@
     }
 
     /**
-     * Is this a 'use strict' function object?
-     *
-     * @return true if this mirror represents a ECMAScript 'use strict' function
+     * @implSpec This implementation always returns false
      */
     @Override
     public boolean isStrictFunction() {
@@ -236,9 +192,7 @@
     }
 
     /**
-     * Is this an array object?
-     *
-     * @return if this mirror wraps a ECMAScript array object
+     * @implSpec This implementation always returns false
      */
     @Override
     public boolean isArray() {
diff --git a/nashorn/src/jdk/nashorn/api/scripting/JSObject.java b/nashorn/src/jdk/nashorn/api/scripting/JSObject.java
index 3c4484a..8850b53 100644
--- a/nashorn/src/jdk/nashorn/api/scripting/JSObject.java
+++ b/nashorn/src/jdk/nashorn/api/scripting/JSObject.java
@@ -31,7 +31,7 @@
 /**
  * This interface can be implemented by an arbitrary Java class. Nashorn will
  * treat objects of such classes just like nashorn script objects. Usual nashorn
- * operations like obj[i], obj.foo, obj.func(), delete obj.foo will be glued
+ * operations like obj[i], obj.foo, obj.func(), delete obj.foo will be delegated
  * to appropriate method call of this interface.
  *
  * @since 1.8u40
@@ -42,7 +42,7 @@
      * Call this object as a JavaScript function. This is equivalent to
      * 'func.apply(thiz, args)' in JavaScript.
      *
-     * @param thiz 'this' object to be passed to the function
+     * @param thiz 'this' object to be passed to the function. This may be null.
      * @param args arguments to method
      * @return result of call
      */
@@ -70,6 +70,7 @@
      *
      * @param name of member
      * @return member
+     * @throws NullPointerException if name is null
      */
     public Object getMember(final String name);
 
@@ -101,6 +102,7 @@
      * Remove a named member from this JavaScript object
      *
      * @param name name of the member
+     * @throws NullPointerException if name is null
      */
     public void removeMember(final String name);
 
@@ -109,6 +111,7 @@
      *
      * @param name  name of the member
      * @param value value of the member
+     * @throws NullPointerException if name is null
      */
     public void setMember(final String name, final Object value);
 
diff --git a/nashorn/src/jdk/nashorn/api/scripting/NashornException.java b/nashorn/src/jdk/nashorn/api/scripting/NashornException.java
index 1509a7d..4fe461c 100644
--- a/nashorn/src/jdk/nashorn/api/scripting/NashornException.java
+++ b/nashorn/src/jdk/nashorn/api/scripting/NashornException.java
@@ -47,6 +47,8 @@
 @jdk.Exported
 @SuppressWarnings("serial")
 public abstract class NashornException extends RuntimeException {
+    private static final long serialVersionUID = 1L;
+
     // script file name
     private String fileName;
     // script line number
@@ -59,7 +61,7 @@
     private Object ecmaError;
 
     /**
-     * Constructor
+     * Constructor to initialize error message, file name, line and column numbers.
      *
      * @param msg       exception message
      * @param fileName  file name
@@ -71,7 +73,7 @@
     }
 
     /**
-     * Constructor
+     * Constructor to initialize error message, cause exception, file name, line and column numbers.
      *
      * @param msg       exception message
      * @param cause     exception cause
@@ -87,7 +89,7 @@
     }
 
     /**
-     * Constructor
+     * Constructor to initialize error message and cause exception.
      *
      * @param msg       exception message
      * @param cause     exception cause
diff --git a/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngineFactory.java b/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngineFactory.java
index f38244c..4d28f74 100644
--- a/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngineFactory.java
+++ b/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngineFactory.java
@@ -155,7 +155,7 @@
     }
 
     /**
-     * Create a new Script engine initialized by given class loader.
+     * Create a new Script engine initialized with the given class loader.
      *
      * @param appLoader class loader to be used as script "app" class loader.
      * @return newly created script engine.
@@ -168,7 +168,7 @@
     }
 
     /**
-     * Create a new Script engine initialized by given class filter.
+     * Create a new Script engine initialized with the given class filter.
      *
      * @param classFilter class filter to use.
      * @return newly created script engine.
@@ -182,7 +182,7 @@
     }
 
     /**
-     * Create a new Script engine initialized by given arguments.
+     * Create a new Script engine initialized with the given arguments.
      *
      * @param args arguments array passed to script engine.
      * @return newly created script engine.
@@ -196,7 +196,7 @@
     }
 
     /**
-     * Create a new Script engine initialized by given arguments.
+     * Create a new Script engine initialized with the given arguments and the given class loader.
      *
      * @param args arguments array passed to script engine.
      * @param appLoader class loader to be used as script "app" class loader.
@@ -211,7 +211,7 @@
     }
 
     /**
-     * Create a new Script engine initialized by given arguments.
+     * Create a new Script engine initialized with the given arguments, class loader and class filter.
      *
      * @param args arguments array passed to script engine.
      * @param appLoader class loader to be used as script "app" class loader.
diff --git a/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java b/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java
index e3bd9c2..02e228e 100644
--- a/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java
+++ b/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java
@@ -288,22 +288,21 @@
         });
     }
 
-
     @Override
-    public boolean isInstance(final Object obj) {
-        if (! (obj instanceof ScriptObjectMirror)) {
+    public boolean isInstance(final Object instance) {
+        if (! (instance instanceof ScriptObjectMirror)) {
             return false;
         }
 
-        final ScriptObjectMirror instance = (ScriptObjectMirror)obj;
+        final ScriptObjectMirror mirror = (ScriptObjectMirror)instance;
         // if not belongs to my global scope, return false
-        if (global != instance.global) {
+        if (global != mirror.global) {
             return false;
         }
 
         return inGlobal(new Callable<Boolean>() {
             @Override public Boolean call() {
-                return sobj.isInstance(instance.sobj);
+                return sobj.isInstance(mirror.sobj);
             }
         });
     }
@@ -654,10 +653,10 @@
     }
 
     /**
-     * Make a script object mirror on given object if needed. Also converts ConsString instances to Strings.
+     * Make a script object mirror on given object if needed.
      *
      * @param obj object to be wrapped/converted
-     * @param homeGlobal global to which this object belongs. Not used for ConsStrings.
+     * @param homeGlobal global to which this object belongs.
      * @return wrapped/converted object
      */
     public static Object wrap(final Object obj, final Object homeGlobal) {
@@ -665,13 +664,13 @@
     }
 
     /**
-     * Make a script object mirror on given object if needed. Also converts ConsString instances to Strings. The
-     * created wrapper will implement the Java {@code List} interface if {@code obj} is a JavaScript
-     * {@code Array} object; this is compatible with Java JSON libraries expectations. Arrays retrieved through its
+     * Make a script object mirror on given object if needed. The created wrapper will implement
+     * the Java {@code List} interface if {@code obj} is a JavaScript {@code Array} object;
+     * this is compatible with Java JSON libraries expectations. Arrays retrieved through its
      * properties (transitively) will also implement the list interface.
      *
      * @param obj object to be wrapped/converted
-     * @param homeGlobal global to which this object belongs. Not used for ConsStrings.
+     * @param homeGlobal global to which this object belongs.
      * @return wrapped/converted object
      */
     public static Object wrapAsJSONCompatible(final Object obj, final Object homeGlobal) {
@@ -679,10 +678,10 @@
     }
 
     /**
-     * Make a script object mirror on given object if needed. Also converts ConsString instances to Strings.
+     * Make a script object mirror on given object if needed.
      *
      * @param obj object to be wrapped/converted
-     * @param homeGlobal global to which this object belongs. Not used for ConsStrings.
+     * @param homeGlobal global to which this object belongs.
      * @param jsonCompatible if true, the created wrapper will implement the Java {@code List} interface if
      * {@code obj} is a JavaScript {@code Array} object. Arrays retrieved through its properties (transitively)
      * will also implement the list interface.
diff --git a/nashorn/src/jdk/nashorn/api/scripting/ScriptUtils.java b/nashorn/src/jdk/nashorn/api/scripting/ScriptUtils.java
index 0d5d676..60178f7 100644
--- a/nashorn/src/jdk/nashorn/api/scripting/ScriptUtils.java
+++ b/nashorn/src/jdk/nashorn/api/scripting/ScriptUtils.java
@@ -77,9 +77,15 @@
      * @param func the function to wrap
      * @param sync the object to synchronize on
      * @return a synchronizing wrapper function
+     * @throws IllegalArgumentException if func does not represent a script function
      */
-    public static Object makeSynchronizedFunction(final ScriptFunction func, final Object sync) {
-        return func.createSynchronized(unwrap(sync));
+    public static Object makeSynchronizedFunction(final Object func, final Object sync) {
+        final Object unwrapped = unwrap(func);
+        if (unwrapped instanceof ScriptFunction) {
+            return ((ScriptFunction)unwrapped).createSynchronized(unwrap(sync));
+        }
+
+        throw new IllegalArgumentException();
     }
 
     /**
@@ -87,9 +93,19 @@
      *
      * @param obj object to be wrapped
      * @return wrapped object
+     * @throws IllegalArgumentException if obj cannot be wrapped
      */
-    public static ScriptObjectMirror wrap(final ScriptObject obj) {
-        return (ScriptObjectMirror) ScriptObjectMirror.wrap(obj, Context.getGlobal());
+    public static ScriptObjectMirror wrap(final Object obj) {
+        if (obj instanceof ScriptObjectMirror) {
+            return (ScriptObjectMirror)obj;
+        }
+
+        if (obj instanceof ScriptObject) {
+            final ScriptObject sobj = (ScriptObject)obj;
+            return (ScriptObjectMirror) ScriptObjectMirror.wrap(sobj, Context.getGlobal());
+        }
+
+        throw new IllegalArgumentException();
     }
 
     /**
@@ -138,7 +154,8 @@
      * Convert the given object to the given type.
      *
      * @param obj object to be converted
-     * @param type destination type to convert to
+     * @param type destination type to convert to. type is either a Class
+     * or nashorn representation of a Java type returned by Java.type() call in script.
      * @return converted object
      */
     public static Object convert(final Object obj, final Object type) {
diff --git a/nashorn/src/jdk/nashorn/internal/runtime/PropertyListeners.java b/nashorn/src/jdk/nashorn/internal/runtime/PropertyListeners.java
index e4ecad7..3a46bc3 100644
--- a/nashorn/src/jdk/nashorn/internal/runtime/PropertyListeners.java
+++ b/nashorn/src/jdk/nashorn/internal/runtime/PropertyListeners.java
@@ -54,7 +54,13 @@
      */
     PropertyListeners(final PropertyListeners listener) {
         if (listener != null && listener.listeners != null) {
-            this.listeners = new WeakHashMap<>(listener.listeners);
+            this.listeners = new WeakHashMap<>();
+            // We need to copy the nested weak sets in order to avoid concurrent modification issues, see JDK-8146274
+            synchronized (listener) {
+                for (final Map.Entry<String, WeakPropertyMapSet> entry : listener.listeners.entrySet()) {
+                    this.listeners.put(entry.getKey(), new WeakPropertyMapSet(entry.getValue()));
+                }
+            }
         }
     }
 
@@ -228,7 +234,15 @@
 
     private static class WeakPropertyMapSet {
 
-        private final WeakHashMap<PropertyMap, Boolean> map = new WeakHashMap<>();
+        private final WeakHashMap<PropertyMap, Boolean> map;
+
+        WeakPropertyMapSet() {
+            this.map = new WeakHashMap<>();
+        }
+
+        WeakPropertyMapSet(final WeakPropertyMapSet set) {
+            this.map = new WeakHashMap<>(set.map);
+        }
 
         void add(final PropertyMap propertyMap) {
             map.put(propertyMap, Boolean.TRUE);
diff --git a/nashorn/src/jdk/nashorn/internal/runtime/arrays/ArrayData.java b/nashorn/src/jdk/nashorn/internal/runtime/arrays/ArrayData.java
index e21603c..331a8f5 100644
--- a/nashorn/src/jdk/nashorn/internal/runtime/arrays/ArrayData.java
+++ b/nashorn/src/jdk/nashorn/internal/runtime/arrays/ArrayData.java
@@ -81,14 +81,11 @@
         }
 
         private ArrayData toRealArrayData() {
-            return toRealArrayData(0);
+            return new IntArrayData(0);
         }
 
         private ArrayData toRealArrayData(final int index) {
             final IntArrayData newData = new IntArrayData(index + 1);
-            if (index == 0) {
-                return newData;
-            }
             return new DeletedRangeArrayFilter(newData, 0, index);
         }
 
@@ -122,7 +119,7 @@
 
         @Override
         public ArrayData convert(final Class<?> type) {
-            return toRealArrayData(0).convert(type);
+            return toRealArrayData().convert(type);
         }
 
         @Override
diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/LinkerCallSite.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/LinkerCallSite.java
index 10dbf01..bce3466 100644
--- a/nashorn/src/jdk/nashorn/internal/runtime/linker/LinkerCallSite.java
+++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/LinkerCallSite.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, 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
@@ -238,8 +238,18 @@
         public void setTarget(final MethodHandle newTarget) {
             final MethodType type   = type();
             final boolean    isVoid = type.returnType() == void.class;
+            final Class<?> newSelfType = newTarget.type().parameterType(0);
 
-            MethodHandle methodHandle = MH.filterArguments(newTarget, 0, MH.bindTo(PROFILEENTRY, this));
+            MethodHandle selfFilter = MH.bindTo(PROFILEENTRY, this);
+            if (newSelfType != Object.class) {
+                // new target uses a more precise 'self' type than Object.class. We need to
+                // convert the filter type. Note that the profileEntry method returns "self"
+                // argument "as is" and so the cast introduced will succeed for any type.
+                MethodType selfFilterType = MethodType.methodType(newSelfType, newSelfType);
+                selfFilter = selfFilter.asType(selfFilterType);
+            }
+
+            MethodHandle methodHandle = MH.filterArguments(newTarget, 0, selfFilter);
 
             if (isVoid) {
                 methodHandle = MH.filterReturnValue(methodHandle, MH.bindTo(PROFILEVOIDEXIT, this));
diff --git a/nashorn/test/script/basic/JDK-8026367.js b/nashorn/test/script/basic/JDK-8026367.js
index 0b14ecf..6d498c1 100644
--- a/nashorn/test/script/basic/JDK-8026367.js
+++ b/nashorn/test/script/basic/JDK-8026367.js
@@ -37,10 +37,12 @@
     // Sync called with one argument will synchronize on this-object of invocation
     inc: sync(function(d) {
         this.count += d;
+        Assert.assertTrue(java.lang.Thread.holdsLock(this));
     }),
     // Pass explicit object to synchronize on as second argument
     dec: sync(function(d) {
         this.count -= d;
+        Assert.assertTrue(java.lang.Thread.holdsLock(obj));
     }, obj)
 };
 
diff --git a/nashorn/test/script/basic/JDK-8134488.js b/nashorn/test/script/basic/JDK-8134488.js
index 928961a..68b3ebb 100644
--- a/nashorn/test/script/basic/JDK-8134488.js
+++ b/nashorn/test/script/basic/JDK-8134488.js
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
+ * 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
diff --git a/nashorn/test/script/basic/JDK-8134490.js b/nashorn/test/script/basic/JDK-8134490.js
index d7c10fd..2a2a012 100644
--- a/nashorn/test/script/basic/JDK-8134490.js
+++ b/nashorn/test/script/basic/JDK-8134490.js
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
+ * 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
diff --git a/nashorn/test/script/basic/JDK-8134939.js b/nashorn/test/script/basic/JDK-8134939.js
index 67990d1..963bb16 100644
--- a/nashorn/test/script/basic/JDK-8134939.js
+++ b/nashorn/test/script/basic/JDK-8134939.js
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
+ * 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
diff --git a/hotspot/test/gc/8000311/Test8000311.java b/nashorn/test/script/nosecurity/JDK-8148926.js
similarity index 65%
copy from hotspot/test/gc/8000311/Test8000311.java
copy to nashorn/test/script/nosecurity/JDK-8148926.js
index 2c33191..e59b467 100644
--- a/hotspot/test/gc/8000311/Test8000311.java
+++ b/nashorn/test/script/nosecurity/JDK-8148926.js
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 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
@@ -22,21 +22,13 @@
  */
 
 /**
- * @test Test8000311
- * @key gc
- * @bug 8000311
- * @summary G1: ParallelGCThreads==0 broken
- * @run main/othervm -XX:+UseG1GC -XX:ParallelGCThreads=0 -XX:+ResizePLAB -XX:+ExplicitGCInvokesConcurrent Test8000311
- * @author filipp.zhinkin@oracle.com
+ * JDK-8148926: Call site profiling fails on braces-wrapped anonymous function
+ *
+ * @test
+ * @option -pcs
+ * @run
  */
 
-import java.util.*;
+(function() {})() 
 
-public class Test8000311 {
-  public static void main(String args[]) {
-    for(int i = 0; i<100; i++) {
-      byte[] garbage = new byte[1000];
-      System.gc();
-    }
-  }
-}
+var i = (function() { return 2 })()
diff --git a/hotspot/test/gc/8000311/Test8000311.java b/nashorn/test/script/nosecurity/JDK-8149334.js
similarity index 65%
copy from hotspot/test/gc/8000311/Test8000311.java
copy to nashorn/test/script/nosecurity/JDK-8149334.js
index 2c33191..14d723f 100644
--- a/hotspot/test/gc/8000311/Test8000311.java
+++ b/nashorn/test/script/nosecurity/JDK-8149334.js
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 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
@@ -22,21 +22,20 @@
  */
 
 /**
- * @test Test8000311
- * @key gc
- * @bug 8000311
- * @summary G1: ParallelGCThreads==0 broken
- * @run main/othervm -XX:+UseG1GC -XX:ParallelGCThreads=0 -XX:+ResizePLAB -XX:+ExplicitGCInvokesConcurrent Test8000311
- * @author filipp.zhinkin@oracle.com
+ * JDK-8149334: JSON.parse(JSON.stringify([])).push(10) creates an array containing two elements
+ *
+ * @test
+ * @run
  */
 
-import java.util.*;
+var a = JSON.parse(JSON.stringify([]))
+print(a.length)
+a.push(10)
+print(a.length)
+print(a)
 
-public class Test8000311 {
-  public static void main(String args[]) {
-    for(int i = 0; i<100; i++) {
-      byte[] garbage = new byte[1000];
-      System.gc();
-    }
-  }
-}
+var b = JSON.parse(JSON.stringify([]))
+print(b.length)
+b.push('ieps')
+print(b.length)
+print(b)
diff --git a/nashorn/test/script/nosecurity/JDK-8149334.js.EXPECTED b/nashorn/test/script/nosecurity/JDK-8149334.js.EXPECTED
new file mode 100644
index 0000000..510fc06
--- /dev/null
+++ b/nashorn/test/script/nosecurity/JDK-8149334.js.EXPECTED
@@ -0,0 +1,6 @@
+0
+1
+10
+0
+1
+ieps