diff --git a/.hgtags b/.hgtags index 6f9d8ca74e05ebbc559bc1dfb94565ddfec03a80..7446718d0afe7e0587e98bdaaee0a54fba51f039 100644 --- a/.hgtags +++ b/.hgtags @@ -536,8 +536,26 @@ d841d3fdae44f120883dab0a3a809a054cd0274b jdk8u72-b13 f6d24d424cd2af4d2612f7737d3d9a25f58b882d jdk8u72-b14 f3e86cc607260bae368b52d88d7bc8883ee767e3 jdk8u72-b15 1d4b343084874b1afa1cdd504b9b1e50bab7f121 jdk8u72-b31 +892eb9ab179650b89b7bab6bc42f079391c98624 jdk8u73-b00 +9b77d3ca0d66a117c3cc0e0a74b8059545b22f0e jdk8u73-b01 +2ab13901d6f14bab0dcf4823d5e378a421fba7e2 jdk8u73-b02 +9a843dc6f959f62c61014a3a71ec9aa329f1daf1 jdk8u74-b00 +e829ab80dfd828803aa8837411900faeaa1254a5 jdk8u74-b01 +32c49f4a16599e376e4e46bb33c7bcc486e52ff3 jdk8u74-b02 +9c828e688240362b6f1b761b619cdaa070462c4e jdk8u74-b31 +1d4b343084874b1afa1cdd504b9b1e50bab7f121 jdk8u72-b31 7cfd2c51c501df909833aa0fb6e40c50c61621ed jdk8u75-b00 9e00a43602f87930c2318b2567002871ad9c59dd jdk8u75-b01 9de301db625bb1b462aad3ebd8347118b94bb728 jdk8u75-b02 dcacefa73649a2d821267b6bff1d70aa10a06801 jdk8u75-b03 +de91f05824c5398cb2d2f666ff404aaa165498de jdk8u75-b04 +4138b3f27ffea524185a604c3f4f149c7e5ba780 jdk8u75-b05 +32f64c19b5fba8beeae5236ca6e480bd8e99698a jdk8u75-b06 +39baa472e20c13c0eb1243eb5dce589e82f78143 jdk8u76-b00 +6ea3aea950d19d803475b3f4d704a2942e71b302 jdk8u76-b01 +4de4cffb5988cd68959ce4bbd14c6d4547078c91 jdk8u76-b02 +8bef978e2374604f449b4d1d7f90cb26618540d7 jdk8u76-b03 +e057622070e5415c13b6d8511b97dce8bd2e398d jdk8u76-b04 +b3128c272f8d1684303975795687fd2e9cb87ddf jdk8u76-b05 +06c922a192a822b6a76516d114bfb6979fab03bf jdk8u76-b06 f6cc9dbb5db5883385c91bb71ca02081220aaf3d jdk8u81-b00 diff --git a/make/CompileDemos.gmk b/make/CompileDemos.gmk index 36829b3d3fd3c4c2a2474a4ec20dada253b955c3..97bb0602e57cc80826e1eb09b72af8a3387c736e 100644 --- a/make/CompileDemos.gmk +++ b/make/CompileDemos.gmk @@ -229,7 +229,7 @@ define SetupJVMTIDemo BUILD_DEMO_JVMTI_$1_LANG := $4 endif ifeq (C++, $4) - $1_EXTRA_CXX := $(LDFLAGS_CXX_JDK) $(LIBCXX) + $1_EXTRA_CXX := $$(LDFLAGS_CXX_JDK) $(LIBCXX) endif $1_CXXFLAGS := $(CXXFLAGS_JDKLIB) -I$(JDK_TOPDIR)/src/share/demo/jvmti/$1 \ @@ -251,8 +251,8 @@ define SetupJVMTIDemo LANG := $$(BUILD_DEMO_JVMTI_$1_LANG), \ OPTIMIZATION := LOW, \ CXXFLAGS := $$($1_CXXFLAGS), \ - LDFLAGS := $(filter-out -incremental:no -opt:ref, $(LDFLAGS_JDKLIB)), \ - LDFLAGS_macosx := $(call SET_EXECUTABLE_ORIGIN), \ + LDFLAGS := $(filter-out -incremental:no -opt:ref, $$(LDFLAGS_JDKLIB)), \ + LDFLAGS_macosx := $$(call SET_EXECUTABLE_ORIGIN), \ LDFLAGS_SUFFIX := $$($1_EXTRA_CXX), \ LDFLAGS_SUFFIX_posix := $5, \ LDFLAGS_SUFFIX_windows := $6, \ diff --git a/make/CompileLaunchers.gmk b/make/CompileLaunchers.gmk index b69b5b40ff08f3257bf24200b883fdad8a4b7c6e..6a04e29dc594fcaf0b9d6ccbe1d7e7f6d24c8007 100644 --- a/make/CompileLaunchers.gmk +++ b/make/CompileLaunchers.gmk @@ -443,11 +443,6 @@ else endif -ifeq ($(OPENJDK_TARGET_CPU_ARCH), sparc) - UNPACKEXE_CFLAGS += -xregs=no%appl - UNPACKEXE_LDFLAGS_solaris += -xmemalign=4s -endif - UNPACKEXE_LANG := C ifeq ($(OPENJDK_TARGET_OS), solaris) UNPACKEXE_LANG := C++ diff --git a/src/macosx/bin/java_md_macosx.c b/src/macosx/bin/java_md_macosx.c index f9e05c8f471199caeeec49e5ad30a88b41db234a..87e632b921ff1b0c87f9ed5ee7a67b94f874a85b 100644 --- a/src/macosx/bin/java_md_macosx.c +++ b/src/macosx/bin/java_md_macosx.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -1068,6 +1068,7 @@ JVMInit(InvocationFunctions* ifn, jlong threadStackSize, void PostJVMInit(JNIEnv *env, jstring mainClass, JavaVM *vm) { jvmInstance = vm; SetMainClassForAWT(env, mainClass); + CHECK_EXCEPTION_RETURN(); ShowSplashScreen(); } diff --git a/src/macosx/native/sun/awt/AWTView.m b/src/macosx/native/sun/awt/AWTView.m index 0cba2ededfc94b48c8901b3c25674a7b93c8e903..66ad5146d52e0883513b3b2f52c9b8025c81b8d2 100644 --- a/src/macosx/native/sun/awt/AWTView.m +++ b/src/macosx/native/sun/awt/AWTView.m @@ -46,6 +46,7 @@ -(void) deliverResize: (NSRect) rect; -(void) resetTrackingArea; -(void) deliverJavaKeyEventHelper: (NSEvent*) event; +-(BOOL) isCodePointInUnicodeBlockNeedingIMEvent: (unichar) codePoint; @end // Uncomment this line to see fprintfs of each InputMethod API being called on this View @@ -513,6 +514,14 @@ AWT_ASSERT_APPKIT_THREAD; } } +-(BOOL) isCodePointInUnicodeBlockNeedingIMEvent: (unichar) codePoint { + if ((codePoint >= 0x3000) && (codePoint <= 0x303F)) { + // Code point is in 'CJK Symbols and Punctuation' Unicode block. + return YES; + } + return NO; +} + // NSAccessibility support - (jobject)awtComponent:(JNIEnv*)env { @@ -893,8 +902,14 @@ JNF_CLASS_CACHE(jc_CInputMethod, "sun/lwawt/macosx/CInputMethod"); // (i.e., when the user uses the Character palette or Inkwell), or when the string to insert is a complex // Unicode value. NSUInteger utf16Length = [aString lengthOfBytesUsingEncoding:NSUTF16StringEncoding]; + NSUInteger utf8Length = [aString lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; + BOOL aStringIsComplex = NO; + if ((utf16Length > 2) || + ((utf8Length > 1) && [self isCodePointInUnicodeBlockNeedingIMEvent:[aString characterAtIndex:0]])) { + aStringIsComplex = YES; + } - if ([self hasMarkedText] || !fProcessingKeystroke || (utf16Length > 2)) { + if ([self hasMarkedText] || !fProcessingKeystroke || aStringIsComplex) { JNIEnv *env = [ThreadUtilities getJNIEnv]; static JNF_MEMBER_CACHE(jm_selectPreviousGlyph, jc_CInputMethod, "selectPreviousGlyph", "()V"); diff --git a/src/macosx/native/sun/awt/CGraphicsEnv.m b/src/macosx/native/sun/awt/CGraphicsEnv.m index 735e70bc4a21052391e3c057827bab93033c107e..c8044d111444562bc932283cc8c35ba5f3d1f872 100644 --- a/src/macosx/native/sun/awt/CGraphicsEnv.m +++ b/src/macosx/native/sun/awt/CGraphicsEnv.m @@ -26,6 +26,7 @@ #import #import "jni_util.h" +#import "ThreadUtilities.h" #import "LWCToolkit.h" #import "AWT_debug.h" @@ -133,17 +134,20 @@ static void displaycb_handle { if (flags == kCGDisplayBeginConfigurationFlag) return; - JNFPerformEnvBlock(JNFThreadDetachImmediately, ^(JNIEnv *env) { - JNFWeakJObjectWrapper *wrapper = (JNFWeakJObjectWrapper *)userInfo; - - jobject graphicsEnv = [wrapper jObjectWithEnv:env]; - if (graphicsEnv == NULL) return; // ref already GC'd - static JNF_CLASS_CACHE(jc_CGraphicsEnvironment, "sun/awt/CGraphicsEnvironment"); - static JNF_MEMBER_CACHE(jm_displayReconfiguration, jc_CGraphicsEnvironment, "_displayReconfiguration", "(IZ)V"); - JNFCallVoidMethod(env, graphicsEnv, jm_displayReconfiguration, - (jint) display, - (jboolean) flags & kCGDisplayRemoveFlag); - }); + [ThreadUtilities performOnMainThreadWaiting:NO block:^() { + + JNFPerformEnvBlock(JNFThreadDetachImmediately, ^(JNIEnv *env) { + JNFWeakJObjectWrapper *wrapper = (JNFWeakJObjectWrapper *)userInfo; + + jobject graphicsEnv = [wrapper jObjectWithEnv:env]; + if (graphicsEnv == NULL) return; // ref already GC'd + static JNF_CLASS_CACHE(jc_CGraphicsEnvironment, "sun/awt/CGraphicsEnvironment"); + static JNF_MEMBER_CACHE(jm_displayReconfiguration, + jc_CGraphicsEnvironment, "_displayReconfiguration","(IZ)V"); + JNFCallVoidMethod(env, graphicsEnv, jm_displayReconfiguration, + (jint) display, (jboolean) flags & kCGDisplayRemoveFlag); + }); + }]; } /* diff --git a/src/macosx/native/sun/java2d/opengl/CGLGraphicsConfig.m b/src/macosx/native/sun/java2d/opengl/CGLGraphicsConfig.m index 1ad7d042e6a2297db2f663e6f457032d0a13a7cb..5d5fb8f7ea2e921d7eb0a0c1ce74f8d2bf8d50c4 100644 --- a/src/macosx/native/sun/java2d/opengl/CGLGraphicsConfig.m +++ b/src/macosx/native/sun/java2d/opengl/CGLGraphicsConfig.m @@ -236,6 +236,7 @@ Java_sun_java2d_opengl_CGLGraphicsConfig_getCGLConfigInfo } NSOpenGLPixelFormatAttribute attrs[] = { + NSOpenGLPFAAllowOfflineRenderers, NSOpenGLPFAClosestPolicy, NSOpenGLPFAWindow, NSOpenGLPFAPixelBuffer, diff --git a/src/share/bin/java.c b/src/share/bin/java.c index 4b16e8b5c4d823cfe67272d6df63f96d54f9ab32..2c3121d6aec9e38fa2c014c5064ec84c960f005d 100644 --- a/src/share/bin/java.c +++ b/src/share/bin/java.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 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 @@ -459,6 +459,7 @@ JavaMain(void * _args) * of the application class. */ PostJVMInit(env, appClass, vm); + CHECK_EXCEPTION_LEAVE(1); /* * The LoadMainClass not only loads the main class, it will also ensure * that the main method's signature is correct, therefore further checking diff --git a/src/share/bin/java.h b/src/share/bin/java.h index 43450d8f51af87470ed02b1c65b4f85960833532..9dc0e16f6a0838a8d938bd9fb22113579b6dc97f 100644 --- a/src/share/bin/java.h +++ b/src/share/bin/java.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -256,6 +256,13 @@ typedef struct { #define NULL_CHECK(NC_check_pointer) \ NULL_CHECK_RETURN_VALUE(NC_check_pointer, ) +#define CHECK_EXCEPTION_RETURN() \ + do { \ + if ((*env)->ExceptionOccurred(env)) { \ + return; \ + } \ + } while (JNI_FALSE) + /* * For JNI calls : * - check for thrown exceptions diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/JCEMapper.java b/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/JCEMapper.java index 9fc352579595b4b0a4b2f67da41ca1215402e32e..3656f2488482ef4a251a5010b998339ec3066657 100644 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/JCEMapper.java +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/JCEMapper.java @@ -90,6 +90,10 @@ public class JCEMapper { XMLSignature.ALGO_ID_SIGNATURE_DSA, new Algorithm("", "SHA1withDSA", "Signature") ); + algorithmsMap.put( + XMLSignature.ALGO_ID_SIGNATURE_DSA_SHA256, + new Algorithm("", "SHA256withDSA", "Signature") + ); algorithmsMap.put( XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5, new Algorithm("", "MD5withRSA", "Signature") diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java b/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java index ada9ea53d77ba04d452c99369d157d0afa97c8c4..0ea7b162392aafd30d351fc917d38349b415d322 100644 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java @@ -387,7 +387,12 @@ public class SignatureAlgorithm extends Algorithm { * This method registers the default algorithms. */ public static void registerDefaultAlgorithms() { - algorithmHash.put(SignatureDSA.URI, SignatureDSA.class); + algorithmHash.put( + XMLSignature.ALGO_ID_SIGNATURE_DSA, SignatureDSA.class + ); + algorithmHash.put( + XMLSignature.ALGO_ID_SIGNATURE_DSA_SHA256, SignatureDSA.SHA256.class + ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1, SignatureBaseRSA.SignatureRSASHA1.class ); diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureDSA.java b/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureDSA.java index 0c6aca1361a7d251fa3fea8f215b693b893f7946..7a771d71beb2fc806dc201b89de4059e207ffaf3 100644 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureDSA.java +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureDSA.java @@ -31,13 +31,15 @@ import java.security.PublicKey; import java.security.SecureRandom; import java.security.Signature; import java.security.SignatureException; +import java.security.interfaces.DSAKey; import java.security.spec.AlgorithmParameterSpec; import com.sun.org.apache.xml.internal.security.algorithms.JCEMapper; import com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithmSpi; +import com.sun.org.apache.xml.internal.security.signature.XMLSignature; import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException; import com.sun.org.apache.xml.internal.security.utils.Base64; -import com.sun.org.apache.xml.internal.security.utils.Constants; +import com.sun.org.apache.xml.internal.security.utils.JavaUtils; public class SignatureDSA extends SignatureAlgorithmSpi { @@ -45,19 +47,19 @@ public class SignatureDSA extends SignatureAlgorithmSpi { private static java.util.logging.Logger log = java.util.logging.Logger.getLogger(SignatureDSA.class.getName()); - /** Field URI */ - public static final String URI = Constants.SignatureSpecNS + "dsa-sha1"; - /** Field algorithm */ private java.security.Signature signatureAlgorithm = null; + /** size of Q */ + private int size; + /** * Method engineGetURI * * @inheritDoc */ protected String engineGetURI() { - return SignatureDSA.URI; + return XMLSignature.ALGO_ID_SIGNATURE_DSA; } /** @@ -66,7 +68,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi { * @throws XMLSignatureException */ public SignatureDSA() throws XMLSignatureException { - String algorithmID = JCEMapper.translateURItoJCEID(SignatureDSA.URI); + String algorithmID = JCEMapper.translateURItoJCEID(engineGetURI()); if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "Created SignatureDSA using " + algorithmID); } @@ -110,7 +112,8 @@ public class SignatureDSA extends SignatureAlgorithmSpi { log.log(java.util.logging.Level.FINE, "Called DSA.verify() on " + Base64.encode(signature)); } - byte[] jcebytes = SignatureDSA.convertXMLDSIGtoASN1(signature); + byte[] jcebytes = JavaUtils.convertDsaXMLDSIGtoASN1(signature, + size/8); return this.signatureAlgorithm.verify(jcebytes); } catch (SignatureException ex) { @@ -150,6 +153,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi { } throw new XMLSignatureException("empty", ex); } + size = ((DSAKey)publicKey).getParams().getQ().bitLength(); } /** @@ -159,7 +163,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi { try { byte jcebytes[] = this.signatureAlgorithm.sign(); - return SignatureDSA.convertASN1toXMLDSIG(jcebytes); + return JavaUtils.convertDsaASN1toXMLDSIG(jcebytes, size/8); } catch (IOException ex) { throw new XMLSignatureException("empty", ex); } catch (SignatureException ex) { @@ -185,6 +189,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi { } catch (InvalidKeyException ex) { throw new XMLSignatureException("empty", ex); } + size = ((DSAKey)privateKey).getParams().getQ().bitLength(); } /** @@ -204,6 +209,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi { } catch (InvalidKeyException ex) { throw new XMLSignatureException("empty", ex); } + size = ((DSAKey)privateKey).getParams().getQ().bitLength(); } /** @@ -257,100 +263,6 @@ public class SignatureDSA extends SignatureAlgorithmSpi { return this.signatureAlgorithm.getProvider().getName(); } - /** - * Converts an ASN.1 DSA value to a XML Signature DSA Value. - * - * The JAVA JCE DSA Signature algorithm creates ASN.1 encoded (r,s) value - * pairs; the XML Signature requires the core BigInteger values. - * - * @param asn1Bytes - * @return the decode bytes - * - * @throws IOException - * @see 6.4.1 DSA - */ - private static byte[] convertASN1toXMLDSIG(byte asn1Bytes[]) throws IOException { - - byte rLength = asn1Bytes[3]; - int i; - - for (i = rLength; (i > 0) && (asn1Bytes[(4 + rLength) - i] == 0); i--); - - byte sLength = asn1Bytes[5 + rLength]; - int j; - - for (j = sLength; - (j > 0) && (asn1Bytes[(6 + rLength + sLength) - j] == 0); j--); - - if ((asn1Bytes[0] != 48) || (asn1Bytes[1] != asn1Bytes.length - 2) - || (asn1Bytes[2] != 2) || (i > 20) - || (asn1Bytes[4 + rLength] != 2) || (j > 20)) { - throw new IOException("Invalid ASN.1 format of DSA signature"); - } - byte xmldsigBytes[] = new byte[40]; - - System.arraycopy(asn1Bytes, (4 + rLength) - i, xmldsigBytes, 20 - i, i); - System.arraycopy(asn1Bytes, (6 + rLength + sLength) - j, xmldsigBytes, - 40 - j, j); - - return xmldsigBytes; - } - - /** - * Converts a XML Signature DSA Value to an ASN.1 DSA value. - * - * The JAVA JCE DSA Signature algorithm creates ASN.1 encoded (r,s) value - * pairs; the XML Signature requires the core BigInteger values. - * - * @param xmldsigBytes - * @return the encoded ASN.1 bytes - * - * @throws IOException - * @see 6.4.1 DSA - */ - private static byte[] convertXMLDSIGtoASN1(byte xmldsigBytes[]) throws IOException { - - if (xmldsigBytes.length != 40) { - throw new IOException("Invalid XMLDSIG format of DSA signature"); - } - - int i; - - for (i = 20; (i > 0) && (xmldsigBytes[20 - i] == 0); i--); - - int j = i; - - if (xmldsigBytes[20 - i] < 0) { - j += 1; - } - - int k; - - for (k = 20; (k > 0) && (xmldsigBytes[40 - k] == 0); k--); - - int l = k; - - if (xmldsigBytes[40 - k] < 0) { - l += 1; - } - - byte asn1Bytes[] = new byte[6 + j + l]; - - asn1Bytes[0] = 48; - asn1Bytes[1] = (byte) (4 + j + l); - asn1Bytes[2] = 2; - asn1Bytes[3] = (byte) j; - - System.arraycopy(xmldsigBytes, 20 - i, asn1Bytes, (4 + j) - i, i); - - asn1Bytes[4 + j] = 2; - asn1Bytes[5 + j] = (byte) l; - - System.arraycopy(xmldsigBytes, 40 - k, asn1Bytes, (6 + j + l) - k, k); - - return asn1Bytes; - } - /** * Method engineSetHMACOutputLength * @@ -373,4 +285,15 @@ public class SignatureDSA extends SignatureAlgorithmSpi { ) throws XMLSignatureException { throw new XMLSignatureException("algorithms.CannotUseAlgorithmParameterSpecOnDSA"); } + + public static class SHA256 extends SignatureDSA { + + public SHA256() throws XMLSignatureException { + super(); + } + + public String engineGetURI() { + return XMLSignature.ALGO_ID_SIGNATURE_DSA_SHA256; + } + } } diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignature.java b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignature.java index bb7cc03778c8624e9dfa5dbb119cd6a8bef07ae4..6ea1443af3a4c1090437a78c6db93223f737b44f 100644 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignature.java +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignature.java @@ -85,6 +85,10 @@ public final class XMLSignature extends SignatureElementProxy { public static final String ALGO_ID_SIGNATURE_DSA = Constants.SignatureSpecNS + "dsa-sha1"; + /** Signature - Optional DSAwithSHA256 */ + public static final String ALGO_ID_SIGNATURE_DSA_SHA256 = + Constants.SignatureSpec11NS + "dsa-sha256"; + /** Signature - Recommended RSAwithSHA1 */ public static final String ALGO_ID_SIGNATURE_RSA = Constants.SignatureSpecNS + "rsa-sha1"; diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/JavaUtils.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/JavaUtils.java index ee3dfbe63534d60c37d1a115d6e8b655f8304a7f..d9cce88d14170a60773633ac052feee4b594fbae 100644 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/JavaUtils.java +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/JavaUtils.java @@ -151,6 +151,100 @@ public class JavaUtils { return retBytes; } + /** + * Converts an ASN.1 DSA value to a XML Signature DSA Value. + * + * The JCE DSA Signature algorithm creates ASN.1 encoded (r,s) value + * pairs (see section 2.2.2 of RFC 3279); the XML Signature requires the + * core BigInteger values. + * + * @param asn1Bytes the ASN.1 encoded bytes + * @param size size of r and s in bytes + * @return the XML Signature encoded bytes + * @throws IOException if the bytes are not encoded correctly + * @see 6.4.1 DSA + */ + public static byte[] convertDsaASN1toXMLDSIG(byte[] asn1Bytes, int size) + throws IOException + { + if (asn1Bytes[0] != 48 || asn1Bytes[1] != asn1Bytes.length - 2 + || asn1Bytes[2] != 2) { + throw new IOException("Invalid ASN.1 format of DSA signature"); + } + + byte rLength = asn1Bytes[3]; + int i; + for (i = rLength; i > 0 && asn1Bytes[4 + rLength - i] == 0; i--); + + byte sLength = asn1Bytes[5 + rLength]; + int j; + for (j = sLength; + j > 0 && asn1Bytes[6 + rLength + sLength - j] == 0; j--); + + if (i > size || asn1Bytes[4 + rLength] != 2 || j > size) { + throw new IOException("Invalid ASN.1 format of DSA signature"); + } else { + byte[] xmldsigBytes = new byte[size * 2]; + System.arraycopy(asn1Bytes, 4 + rLength - i, xmldsigBytes, + size - i, i); + System.arraycopy(asn1Bytes, 6 + rLength + sLength - j, + xmldsigBytes, size * 2 - j, j); + return xmldsigBytes; + } + } + + /** + * Converts an XML Signature DSA Value to a ASN.1 DSA value. + * + * The JCE DSA Signature algorithm creates ASN.1 encoded (r,s) value + * pairs (see section 2.2.2 of RFC 3279); the XML Signature requires the + * core BigInteger values. + * + * @param xmldsigBytes the XML Signature encoded bytes + * @param size size of r and s in bytes + * @return the ASN.1 encoded bytes + * @throws IOException if the bytes are not encoded correctly + * @see 6.4.1 DSA + */ + public static byte[] convertDsaXMLDSIGtoASN1(byte[] xmldsigBytes, int size) + throws IOException + { + int totalSize = size * 2; + if (xmldsigBytes.length != totalSize) { + throw new IOException("Invalid XMLDSIG format of DSA signature"); + } + + int i; + for (i = size; i > 0 && xmldsigBytes[size - i] == 0; i--); + + int j = i; + if (xmldsigBytes[size - i] < 0) { + j++; + } + + int k; + for (k = size; k > 0 && xmldsigBytes[totalSize - k] == 0; k--); + + int l = k; + if (xmldsigBytes[totalSize - k] < 0) { + l++; + } + + byte[] asn1Bytes = new byte[6 + j + l]; + asn1Bytes[0] = 48; + asn1Bytes[1] = (byte)(4 + j + l); + asn1Bytes[2] = 2; + asn1Bytes[3] = (byte)j; + System.arraycopy(xmldsigBytes, size - i, asn1Bytes, 4 + j - i, i); + + asn1Bytes[4 + j] = 2; + asn1Bytes[5 + j] = (byte) l; + System.arraycopy(xmldsigBytes, totalSize - k, asn1Bytes, + 6 + j + l - k, k); + + return asn1Bytes; + } + /** * Throws a {@code SecurityException} if a security manager is installed * and the caller is not allowed to register an implementation of an diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java index 585f7f62495175e4607429ed93194478b9e63672..3463dc75fec3b5c9eef474f37c9dd2354bff0900 100644 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java @@ -934,7 +934,7 @@ public class XMLUtils { Element foundElement = null; String id = value.trim(); - if (id.charAt(0) == '#') { + if (!id.isEmpty() && id.charAt(0) == '#') { id = id.substring(1); } @@ -994,7 +994,7 @@ public class XMLUtils { Node processedNode = null; String id = value.trim(); - if (id.charAt(0) == '#') { + if (!id.isEmpty() && id.charAt(0) == '#') { id = id.substring(1); } diff --git a/src/share/classes/com/sun/tools/jdi/InvokableTypeImpl.java b/src/share/classes/com/sun/tools/jdi/InvokableTypeImpl.java index 61a23301861f8531ed702a88667dd07d53135c66..3672435273ab7fdbdaf2f1ed0b417a496aa5bb8e 100644 --- a/src/share/classes/com/sun/tools/jdi/InvokableTypeImpl.java +++ b/src/share/classes/com/sun/tools/jdi/InvokableTypeImpl.java @@ -236,6 +236,15 @@ abstract class InvokableTypeImpl extends ReferenceTypeImpl { final MethodImpl method, final ValueImpl[] args, final int options) { + /* + * Cache the values of args when TRACE_SENDS is enabled, for later printing. + * If not cached, printing causes a remote call while synchronized, and deadlock. + */ + if ((vm.traceFlags & VirtualMachineImpl.TRACE_SENDS) != 0) { + for (ValueImpl arg: args) { + arg.toString(); + } + } CommandSender sender = getInvokeMethodSender(thread, method, args, options); PacketStream stream; if ((options & ClassType.INVOKE_SINGLE_THREADED) != 0) { diff --git a/src/share/classes/java/awt/Component.java b/src/share/classes/java/awt/Component.java index e826787316f91062b7093c630a7028c3f8b4bbbd..516c6fd0d6c8b3cd4a70eb26dbb1a938f883dd06 100644 --- a/src/share/classes/java/awt/Component.java +++ b/src/share/classes/java/awt/Component.java @@ -312,7 +312,7 @@ public abstract class Component implements ImageObserver, MenuContainer, * @see GraphicsConfiguration * @see #getGraphicsConfiguration */ - private transient GraphicsConfiguration graphicsConfig = null; + private transient volatile GraphicsConfiguration graphicsConfig; /** * A reference to a BufferStrategy object @@ -1141,9 +1141,7 @@ public abstract class Component implements ImageObserver, MenuContainer, * @since 1.3 */ public GraphicsConfiguration getGraphicsConfiguration() { - synchronized(getTreeLock()) { - return getGraphicsConfiguration_NoClientCode(); - } + return getGraphicsConfiguration_NoClientCode(); } final GraphicsConfiguration getGraphicsConfiguration_NoClientCode() { diff --git a/src/share/classes/java/awt/Window.java b/src/share/classes/java/awt/Window.java index 1052a200c7d7517113f901833cf85655fefdbc68..810168c159259abc02433c1f86b9851534cf82b5 100644 --- a/src/share/classes/java/awt/Window.java +++ b/src/share/classes/java/awt/Window.java @@ -348,7 +348,7 @@ public class Window extends Container implements Accessible { * @see #getOpacity() * @since 1.7 */ - private float opacity = 1.0f; + private volatile float opacity = 1.0f; /** * The shape assigned to this window. This field is set to {@code null} if @@ -1040,9 +1040,7 @@ public class Window extends Container implements Accessible { closeSplashScreen(); Dialog.checkShouldBeBlocked(this); super.show(); - synchronized (getTreeLock()) { - this.locationByPlatform = false; - } + locationByPlatform = false; for (int i = 0; i < ownedWindowList.size(); i++) { Window child = ownedWindowList.elementAt(i).get(); if ((child != null) && child.showWithParent) { @@ -1115,9 +1113,7 @@ public class Window extends Container implements Accessible { modalBlocker.unblockWindow(this); } super.hide(); - synchronized (getTreeLock()) { - this.locationByPlatform = false; - } + locationByPlatform = false; } final void clearMostRecentFocusOwnerOnHide() { @@ -3398,7 +3394,7 @@ public class Window extends Container implements Accessible { return super.canContainFocusOwner(focusOwnerCandidate) && isFocusableWindow(); } - private boolean locationByPlatform = locationByPlatformProp; + private volatile boolean locationByPlatform = locationByPlatformProp; /** @@ -3469,9 +3465,7 @@ public class Window extends Container implements Accessible { * @since 1.5 */ public boolean isLocationByPlatform() { - synchronized (getTreeLock()) { - return locationByPlatform; - } + return locationByPlatform; } /** @@ -3560,9 +3554,7 @@ public class Window extends Container implements Accessible { * @since 1.7 */ public float getOpacity() { - synchronized (getTreeLock()) { - return opacity; - } + return opacity; } /** diff --git a/src/share/classes/java/lang/invoke/BoundMethodHandle.java b/src/share/classes/java/lang/invoke/BoundMethodHandle.java index 74f53e47906188490ee5fa0d38ed3d053d5c9da5..6596403cfa61b6885f7fd178b75d4a1302cfb875 100644 --- a/src/share/classes/java/lang/invoke/BoundMethodHandle.java +++ b/src/share/classes/java/lang/invoke/BoundMethodHandle.java @@ -34,14 +34,16 @@ import java.lang.invoke.LambdaForm.NamedFunction; import java.lang.invoke.MethodHandles.Lookup; import java.lang.reflect.Field; import java.util.Arrays; -import java.util.HashMap; +import java.util.function.Function; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.ConcurrentHashMap; +import jdk.internal.org.objectweb.asm.FieldVisitor; import sun.invoke.util.ValueConversions; import sun.invoke.util.Wrapper; import jdk.internal.org.objectweb.asm.ClassWriter; import jdk.internal.org.objectweb.asm.MethodVisitor; -import jdk.internal.org.objectweb.asm.Type; /** * The flavor of method handle which emulates an invoke instruction @@ -217,7 +219,7 @@ import jdk.internal.org.objectweb.asm.Type; /*non-public*/ int fieldCount() { return 1; } - /*non-public*/ static final SpeciesData SPECIES_DATA = SpeciesData.getForClass("L", Species_L.class); + /*non-public*/ static final SpeciesData SPECIES_DATA = new SpeciesData("L", Species_L.class); /*non-public*/ static BoundMethodHandle make(MethodType mt, LambdaForm lf, Object argL0) { return new Species_L(mt, lf, argL0); } @@ -335,7 +337,7 @@ import jdk.internal.org.objectweb.asm.Type; static final SpeciesData EMPTY = new SpeciesData("", BoundMethodHandle.class); - private SpeciesData(String types, Class clazz) { + SpeciesData(String types, Class clazz) { this.typeChars = types; this.typeCodes = basicTypes(types); this.clazz = clazz; @@ -355,26 +357,14 @@ import jdk.internal.org.objectweb.asm.Type; assert(!INIT_DONE); if (constructor() == null) { String types = typeChars; + CACHE.put(types, this); Factory.makeCtors(clazz, types, this.constructor); Factory.makeGetters(clazz, types, this.getters); Factory.makeNominalGetters(types, this.nominalGetters, this.getters); } } - private SpeciesData(String typeChars) { - // Placeholder only. - this.typeChars = typeChars; - this.typeCodes = basicTypes(typeChars); - this.clazz = null; - this.constructor = null; - this.getters = null; - this.nominalGetters = null; - this.extensions = null; - } - private boolean isPlaceholder() { return clazz == null; } - - private static final HashMap CACHE = new HashMap<>(); - static { CACHE.put("", EMPTY); } // make bootstrap predictable + private static final ConcurrentMap CACHE = new ConcurrentHashMap<>(); private static final boolean INIT_DONE; // set after finishes... SpeciesData extendWith(byte type) { @@ -390,62 +380,52 @@ import jdk.internal.org.objectweb.asm.Type; } private static SpeciesData get(String types) { - // Acquire cache lock for query. - SpeciesData d = lookupCache(types); - if (!d.isPlaceholder()) - return d; - synchronized (d) { - // Use synch. on the placeholder to prevent multiple instantiation of one species. - // Creating this class forces a recursive call to getForClass. - if (lookupCache(types).isPlaceholder()) - Factory.generateConcreteBMHClass(types); - } - // Reacquire cache lock. - d = lookupCache(types); - // Class loading must have upgraded the cache. - assert(d != null && !d.isPlaceholder()); - return d; - } - static SpeciesData getForClass(String types, Class clazz) { - // clazz is a new class which is initializing its SPECIES_DATA field - return updateCache(types, new SpeciesData(types, clazz)); - } - private static synchronized SpeciesData lookupCache(String types) { - SpeciesData d = CACHE.get(types); - if (d != null) return d; - d = new SpeciesData(types); - assert(d.isPlaceholder()); - CACHE.put(types, d); - return d; - } - private static synchronized SpeciesData updateCache(String types, SpeciesData d) { - SpeciesData d2; - assert((d2 = CACHE.get(types)) == null || d2.isPlaceholder()); - assert(!d.isPlaceholder()); - CACHE.put(types, d); - return d; + return CACHE.computeIfAbsent(types, new Function() { + @Override + public SpeciesData apply(String types) { + Class bmhcl = Factory.getConcreteBMHClass(types); + // SpeciesData instantiation may throw VirtualMachineError because of + // code cache overflow... + SpeciesData speciesData = new SpeciesData(types, bmhcl); + // CHM.computeIfAbsent ensures only one SpeciesData will be set + // successfully on the concrete BMH class if ever + Factory.setSpeciesDataToConcreteBMHClass(bmhcl, speciesData); + // the concrete BMH class is published via SpeciesData instance + // returned here only after it's SPECIES_DATA field is set + return speciesData; + } + }); } - static { - // pre-fill the BMH speciesdata cache with BMH's inner classes - final Class rootCls = BoundMethodHandle.class; + /** + * This is to be called when assertions are enabled. It checks whether SpeciesData for all of the statically + * defined species subclasses of BoundMethodHandle has been added to the SpeciesData cache. See below in the + * static initializer for + */ + static boolean speciesDataCachePopulated() { + Class rootCls = BoundMethodHandle.class; try { for (Class c : rootCls.getDeclaredClasses()) { if (rootCls.isAssignableFrom(c)) { final Class cbmh = c.asSubclass(BoundMethodHandle.class); - SpeciesData d = Factory.speciesDataFromConcreteBMHClass(cbmh); + SpeciesData d = Factory.getSpeciesDataFromConcreteBMHClass(cbmh); assert(d != null) : cbmh.getName(); assert(d.clazz == cbmh); - assert(d == lookupCache(d.typeChars)); + assert(CACHE.get(d.typeChars) == d); } } } catch (Throwable e) { throw newInternalError(e); } + return true; + } - for (SpeciesData d : CACHE.values()) { - d.initForBootstrap(); - } + static { + // Pre-fill the BMH species-data cache with EMPTY and all BMH's inner subclasses. + EMPTY.initForBootstrap(); + Species_L.SPECIES_DATA.initForBootstrap(); + // check that all static SpeciesData instances have been initialized + assert speciesDataCachePopulated(); // Note: Do not simplify this, because INIT_DONE must not be // a compile-time constant during bootstrapping. INIT_DONE = Boolean.TRUE; @@ -479,6 +459,7 @@ import jdk.internal.org.objectweb.asm.Type; static final String BMH_SIG = "L"+BMH+";"; static final String SPECIES_DATA = "java/lang/invoke/BoundMethodHandle$SpeciesData"; static final String SPECIES_DATA_SIG = "L"+SPECIES_DATA+";"; + static final String STABLE_SIG = "Ljava/lang/invoke/Stable;"; static final String SPECIES_PREFIX_NAME = "Species_"; static final String SPECIES_PREFIX_PATH = BMH + "$" + SPECIES_PREFIX_NAME; @@ -493,6 +474,26 @@ import jdk.internal.org.objectweb.asm.Type; static final String[] E_THROWABLE = new String[] { "java/lang/Throwable" }; + static final ConcurrentMap> CLASS_CACHE = new ConcurrentHashMap<>(); + + /** + * Get a concrete subclass of BMH for a given combination of bound types. + * + * @param types the type signature, wherein reference types are erased to 'L' + * @return the concrete BMH class + */ + static Class getConcreteBMHClass(String types) { + // CHM.computeIfAbsent ensures generateConcreteBMHClass is called + // only once per key. + return CLASS_CACHE.computeIfAbsent( + types, new Function>() { + @Override + public Class apply(String types) { + return generateConcreteBMHClass(types); + } + }); + } + /** * Generate a concrete subclass of BMH for a given combination of bound types. * @@ -529,7 +530,7 @@ import jdk.internal.org.objectweb.asm.Type; * } * final SpeciesData speciesData() { return SPECIES_DATA; } * final int fieldCount() { return 3; } - * static final SpeciesData SPECIES_DATA = SpeciesData.getForClass("LLI", Species_LLI.class); + * @Stable static SpeciesData SPECIES_DATA; // injected afterwards * static BoundMethodHandle make(MethodType mt, LambdaForm lf, Object argL0, Object argL1, int argI2) { * return new Species_LLI(mt, lf, argL0, argL1, argI2); * } @@ -568,7 +569,9 @@ import jdk.internal.org.objectweb.asm.Type; cw.visitSource(sourceFile, null); // emit static types and SPECIES_DATA fields - cw.visitField(NOT_ACC_PUBLIC + ACC_STATIC, "SPECIES_DATA", SPECIES_DATA_SIG, null, null).visitEnd(); + FieldVisitor fw = cw.visitField(NOT_ACC_PUBLIC + ACC_STATIC, "SPECIES_DATA", SPECIES_DATA_SIG, null, null); + fw.visitAnnotation(STABLE_SIG, true); + fw.visitEnd(); // emit bound argument fields for (int i = 0; i < types.length(); ++i) { @@ -694,17 +697,6 @@ import jdk.internal.org.objectweb.asm.Type; mv.visitEnd(); } - // emit class initializer - mv = cw.visitMethod(NOT_ACC_PUBLIC | ACC_STATIC, "", VOID_SIG, null, null); - mv.visitCode(); - mv.visitLdcInsn(types); - mv.visitLdcInsn(Type.getObjectType(className)); - mv.visitMethodInsn(INVOKESTATIC, SPECIES_DATA, "getForClass", BMHSPECIES_DATA_GFC_SIG, false); - mv.visitFieldInsn(PUTSTATIC, className, "SPECIES_DATA", SPECIES_DATA_SIG); - mv.visitInsn(RETURN); - mv.visitMaxs(0, 0); - mv.visitEnd(); - cw.visitEnd(); // load class @@ -715,7 +707,6 @@ import jdk.internal.org.objectweb.asm.Type; UNSAFE.defineClass(className, classFile, 0, classFile.length, BoundMethodHandle.class.getClassLoader(), null) .asSubclass(BoundMethodHandle.class); - UNSAFE.ensureClassInitialized(bmhClass); return bmhClass; } @@ -785,7 +776,7 @@ import jdk.internal.org.objectweb.asm.Type; // Auxiliary methods. // - static SpeciesData speciesDataFromConcreteBMHClass(Class cbmh) { + static SpeciesData getSpeciesDataFromConcreteBMHClass(Class cbmh) { try { Field F_SPECIES_DATA = cbmh.getDeclaredField("SPECIES_DATA"); return (SpeciesData) F_SPECIES_DATA.get(null); @@ -794,6 +785,16 @@ import jdk.internal.org.objectweb.asm.Type; } } + static void setSpeciesDataToConcreteBMHClass(Class cbmh, SpeciesData speciesData) { + try { + Field F_SPECIES_DATA = cbmh.getDeclaredField("SPECIES_DATA"); + assert F_SPECIES_DATA.getDeclaredAnnotation(Stable.class) != null; + F_SPECIES_DATA.set(null, speciesData); + } catch (ReflectiveOperationException ex) { + throw newInternalError(ex); + } + } + /** * Field names in concrete BMHs adhere to this pattern: * arg + type + index diff --git a/src/share/classes/java/security/ProtectionDomain.java b/src/share/classes/java/security/ProtectionDomain.java index ffd2def18d108dcbd33819f34ea5cf70d90e6ad4..b1778490f5a6dacc18e2250ff5e9999472bf5f7c 100644 --- a/src/share/classes/java/security/ProtectionDomain.java +++ b/src/share/classes/java/security/ProtectionDomain.java @@ -475,11 +475,6 @@ public class ProtectionDomain { } }; } - - @Override - public boolean getStaticPermissionsField(ProtectionDomain pd) { - return pd.staticPermissions; - } }); } } diff --git a/src/share/classes/java/time/chrono/HijrahChronology.java b/src/share/classes/java/time/chrono/HijrahChronology.java index 6291b9ce5108ec09040c7d8cac84220765fb4517..602409f758bcb691a60c28437e9d985c6e8b4644 100644 --- a/src/share/classes/java/time/chrono/HijrahChronology.java +++ b/src/share/classes/java/time/chrono/HijrahChronology.java @@ -545,9 +545,8 @@ public final class HijrahChronology extends AbstractChronology implements Serial @Override public boolean isLeapYear(long prolepticYear) { checkCalendarInit(); - int epochMonth = yearToEpochMonth((int) prolepticYear); - if (epochMonth < 0 || epochMonth > maxEpochDay) { - throw new DateTimeException("Hijrah date out of range"); + if (prolepticYear < getMinimumYear() || prolepticYear > getMaximumYear()) { + return false; } int len = getYearLength((int) prolepticYear); return (len > 354); diff --git a/src/share/classes/java/util/AbstractMap.java b/src/share/classes/java/util/AbstractMap.java index 1067394cb589275aacdefb4e79d5db77a777fc97..948bf519a0c067e1556f615bed5f621be6ffc2c4 100644 --- a/src/share/classes/java/util/AbstractMap.java +++ b/src/share/classes/java/util/AbstractMap.java @@ -304,9 +304,28 @@ public abstract class AbstractMap implements Map { * Each of these fields are initialized to contain an instance of the * appropriate view the first time this view is requested. The views are * stateless, so there's no reason to create more than one of each. + * + *

Since there is no synchronization performed while accessing these fields, + * it is expected that java.util.Map view classes using these fields have + * no non-final fields (or any fields at all except for outer-this). Adhering + * to this rule would make the races on these fields benign. + * + *

It is also imperative that implementations read the field only once, + * as in: + * + *

 {@code
+     * public Set keySet() {
+     *   Set ks = keySet;  // single racy read
+     *   if (ks == null) {
+     *     ks = new KeySet();
+     *     keySet = ks;
+     *   }
+     *   return ks;
+     * }
+     *}
*/ - transient volatile Set keySet; - transient volatile Collection values; + transient Set keySet; + transient Collection values; /** * {@inheritDoc} @@ -325,8 +344,9 @@ public abstract class AbstractMap implements Map { * method will not all return the same set. */ public Set keySet() { - if (keySet == null) { - keySet = new AbstractSet() { + Set ks = keySet; + if (ks == null) { + ks = new AbstractSet() { public Iterator iterator() { return new Iterator() { private Iterator> i = entrySet().iterator(); @@ -361,8 +381,9 @@ public abstract class AbstractMap implements Map { return AbstractMap.this.containsKey(k); } }; + keySet = ks; } - return keySet; + return ks; } /** @@ -382,8 +403,9 @@ public abstract class AbstractMap implements Map { * method will not all return the same collection. */ public Collection values() { - if (values == null) { - values = new AbstractCollection() { + Collection vals = values; + if (vals == null) { + vals = new AbstractCollection() { public Iterator iterator() { return new Iterator() { private Iterator> i = entrySet().iterator(); @@ -418,8 +440,9 @@ public abstract class AbstractMap implements Map { return AbstractMap.this.containsValue(v); } }; + values = vals; } - return values; + return vals; } public abstract Set> entrySet(); diff --git a/src/share/classes/java/util/EnumMap.java b/src/share/classes/java/util/EnumMap.java index 7357ee381f3f8fa45589dd9b516173cd158572b8..934f809839ea84cb1eae355f8b8f0884da38cf62 100644 --- a/src/share/classes/java/util/EnumMap.java +++ b/src/share/classes/java/util/EnumMap.java @@ -380,10 +380,11 @@ public class EnumMap, V> extends AbstractMap */ public Set keySet() { Set ks = keySet; - if (ks != null) - return ks; - else - return keySet = new KeySet(); + if (ks == null) { + ks = new KeySet(); + keySet = ks; + } + return ks; } private class KeySet extends AbstractSet { @@ -418,10 +419,11 @@ public class EnumMap, V> extends AbstractMap */ public Collection values() { Collection vs = values; - if (vs != null) - return vs; - else - return values = new Values(); + if (vs == null) { + vs = new Values(); + values = vs; + } + return vs; } private class Values extends AbstractCollection { diff --git a/src/share/classes/java/util/HashMap.java b/src/share/classes/java/util/HashMap.java index 46a59a7963c6ab2fcbe26d57d65793dba1a5075d..eeb11f03c1c46037c1d8fd67ad4730964c1a16b2 100644 --- a/src/share/classes/java/util/HashMap.java +++ b/src/share/classes/java/util/HashMap.java @@ -902,8 +902,12 @@ public class HashMap extends AbstractMap * @return a set view of the keys contained in this map */ public Set keySet() { - Set ks; - return (ks = keySet) == null ? (keySet = new KeySet()) : ks; + Set ks = keySet; + if (ks == null) { + ks = new KeySet(); + keySet = ks; + } + return ks; } final class KeySet extends AbstractSet { @@ -949,8 +953,12 @@ public class HashMap extends AbstractMap * @return a view of the values contained in this map */ public Collection values() { - Collection vs; - return (vs = values) == null ? (values = new Values()) : vs; + Collection vs = values; + if (vs == null) { + vs = new Values(); + values = vs; + } + return vs; } final class Values extends AbstractCollection { diff --git a/src/share/classes/java/util/IdentityHashMap.java b/src/share/classes/java/util/IdentityHashMap.java index d40ad341b8588396d57906b8a0ae9f881d2c74f5..9dc0c26c13f7ed56032129bbef91691899f7b8c1 100644 --- a/src/share/classes/java/util/IdentityHashMap.java +++ b/src/share/classes/java/util/IdentityHashMap.java @@ -964,10 +964,11 @@ public class IdentityHashMap */ public Set keySet() { Set ks = keySet; - if (ks != null) - return ks; - else - return keySet = new KeySet(); + if (ks == null) { + ks = new KeySet(); + keySet = ks; + } + return ks; } private class KeySet extends AbstractSet { @@ -1069,10 +1070,11 @@ public class IdentityHashMap */ public Collection values() { Collection vs = values; - if (vs != null) - return vs; - else - return values = new Values(); + if (vs == null) { + vs = new Values(); + values = vs; + } + return vs; } private class Values extends AbstractCollection { diff --git a/src/share/classes/java/util/LinkedHashMap.java b/src/share/classes/java/util/LinkedHashMap.java index ba4fcd8de1c10b100c96751b57e302800dbba421..256a7c3e88fa6b51f4a966a74fea0d63427e6c72 100644 --- a/src/share/classes/java/util/LinkedHashMap.java +++ b/src/share/classes/java/util/LinkedHashMap.java @@ -528,8 +528,12 @@ public class LinkedHashMap * @return a set view of the keys contained in this map */ public Set keySet() { - Set ks; - return (ks = keySet) == null ? (keySet = new LinkedKeySet()) : ks; + Set ks = keySet; + if (ks == null) { + ks = new LinkedKeySet(); + keySet = ks; + } + return ks; } final class LinkedKeySet extends AbstractSet { @@ -577,8 +581,12 @@ public class LinkedHashMap * @return a view of the values contained in this map */ public Collection values() { - Collection vs; - return (vs = values) == null ? (values = new LinkedValues()) : vs; + Collection vs = values; + if (vs == null) { + vs = new LinkedValues(); + values = vs; + } + return vs; } final class LinkedValues extends AbstractCollection { diff --git a/src/share/classes/java/util/Spliterator.java b/src/share/classes/java/util/Spliterator.java index 18cb082cf38afe5dc26f7b34fc1c58156cc5871a..35322b3c4ef408483f0a7400aab4996898f6aa66 100644 --- a/src/share/classes/java/util/Spliterator.java +++ b/src/share/classes/java/util/Spliterator.java @@ -125,7 +125,7 @@ import java.util.function.LongConsumer; * are encountered. * * @apiNote - *

Spliterators, like {@code Iterators}s, are for traversing the elements of + *

Spliterators, like {@code Iterator}s, are for traversing the elements of * a source. The {@code Spliterator} API was designed to support efficient * parallel traversal in addition to sequential traversal, by supporting * decomposition as well as single-element iteration. In addition, the diff --git a/src/share/classes/java/util/TreeMap.java b/src/share/classes/java/util/TreeMap.java index 1cb8f89232fe0c71f483f121e39549e7f38f194a..575ccca752823e4a64ccfc9239720f78d0d07f98 100644 --- a/src/share/classes/java/util/TreeMap.java +++ b/src/share/classes/java/util/TreeMap.java @@ -855,7 +855,11 @@ public class TreeMap */ public Collection values() { Collection vs = values; - return (vs != null) ? vs : (values = new Values()); + if (vs == null) { + vs = new Values(); + values = vs; + } + return vs; } /** diff --git a/src/share/classes/java/util/WeakHashMap.java b/src/share/classes/java/util/WeakHashMap.java index 9805f83ce7571166175f66b53261727bc8d956d7..7352391ac3789dfbb303aca538eb990c6d43e777 100644 --- a/src/share/classes/java/util/WeakHashMap.java +++ b/src/share/classes/java/util/WeakHashMap.java @@ -865,7 +865,11 @@ public class WeakHashMap */ public Set keySet() { Set ks = keySet; - return (ks != null ? ks : (keySet = new KeySet())); + if (ks == null) { + ks = new KeySet(); + keySet = ks; + } + return ks; } private class KeySet extends AbstractSet { @@ -914,7 +918,11 @@ public class WeakHashMap */ public Collection values() { Collection vs = values; - return (vs != null) ? vs : (values = new Values()); + if (vs == null) { + vs = new Values(); + values = vs; + } + return vs; } private class Values extends AbstractCollection { diff --git a/src/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java b/src/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java index a60b7ce621b350a59e6237ac09585c65ec399c1d..c10abcc72e660a3de1565e0b3dcd9144df449328 100644 --- a/src/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java +++ b/src/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java @@ -34,14 +34,14 @@ */ package java.util.concurrent.atomic; -import java.util.function.IntUnaryOperator; -import java.util.function.IntBinaryOperator; -import sun.misc.Unsafe; + import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.security.AccessController; -import java.security.PrivilegedExceptionAction; import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; +import java.util.function.IntBinaryOperator; +import java.util.function.IntUnaryOperator; import sun.reflect.CallerSensitive; import sun.reflect.Reflection; @@ -363,14 +363,19 @@ public abstract class AtomicIntegerFieldUpdater { } /** - * Standard hotspot implementation using intrinsics + * Standard hotspot implementation using intrinsics. */ - private static class AtomicIntegerFieldUpdaterImpl - extends AtomicIntegerFieldUpdater { - private static final Unsafe unsafe = Unsafe.getUnsafe(); + private static final class AtomicIntegerFieldUpdaterImpl + extends AtomicIntegerFieldUpdater { + private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe(); private final long offset; - private final Class tclass; + /** + * if field is protected, the subclass constructing updater, else + * the same as tclass + */ private final Class cclass; + /** class holding the field */ + private final Class tclass; AtomicIntegerFieldUpdaterImpl(final Class tclass, final String fieldName, @@ -391,7 +396,7 @@ public abstract class AtomicIntegerFieldUpdater { ClassLoader ccl = caller.getClassLoader(); if ((ccl != null) && (ccl != cl) && ((cl == null) || !isAncestor(cl, ccl))) { - sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass); + sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass); } } catch (PrivilegedActionException pae) { throw new RuntimeException(pae.getException()); @@ -399,17 +404,15 @@ public abstract class AtomicIntegerFieldUpdater { throw new RuntimeException(ex); } - Class fieldt = field.getType(); - if (fieldt != int.class) + if (field.getType() != int.class) throw new IllegalArgumentException("Must be integer type"); if (!Modifier.isVolatile(modifiers)) throw new IllegalArgumentException("Must be volatile type"); - this.cclass = (Modifier.isProtected(modifiers) && - caller != tclass) ? caller : null; + this.cclass = (Modifier.isProtected(modifiers)) ? caller : tclass; this.tclass = tclass; - offset = unsafe.objectFieldOffset(field); + this.offset = U.objectFieldOffset(field); } /** @@ -428,81 +431,87 @@ public abstract class AtomicIntegerFieldUpdater { return false; } - private void fullCheck(T obj) { - if (!tclass.isInstance(obj)) + /** + * Checks that target argument is instance of cclass. On + * failure, throws cause. + */ + private final void accessCheck(T obj) { + if (!cclass.isInstance(obj)) + throwAccessCheckException(obj); + } + + /** + * Throws access exception if accessCheck failed due to + * protected access, else ClassCastException. + */ + private final void throwAccessCheckException(T obj) { + if (cclass == tclass) throw new ClassCastException(); - if (cclass != null) - ensureProtectedAccess(obj); + else + throw new RuntimeException( + new IllegalAccessException( + "Class " + + cclass.getName() + + " can not access a protected member of class " + + tclass.getName() + + " using an instance of " + + obj.getClass().getName())); } - public boolean compareAndSet(T obj, int expect, int update) { - if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); - return unsafe.compareAndSwapInt(obj, offset, expect, update); + public final boolean compareAndSet(T obj, int expect, int update) { + accessCheck(obj); + return U.compareAndSwapInt(obj, offset, expect, update); } - public boolean weakCompareAndSet(T obj, int expect, int update) { - if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); - return unsafe.compareAndSwapInt(obj, offset, expect, update); + public final boolean weakCompareAndSet(T obj, int expect, int update) { + accessCheck(obj); + return U.compareAndSwapInt(obj, offset, expect, update); } - public void set(T obj, int newValue) { - if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); - unsafe.putIntVolatile(obj, offset, newValue); + public final void set(T obj, int newValue) { + accessCheck(obj); + U.putIntVolatile(obj, offset, newValue); } - public void lazySet(T obj, int newValue) { - if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); - unsafe.putOrderedInt(obj, offset, newValue); + public final void lazySet(T obj, int newValue) { + accessCheck(obj); + U.putOrderedInt(obj, offset, newValue); } public final int get(T obj) { - if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); - return unsafe.getIntVolatile(obj, offset); + accessCheck(obj); + return U.getIntVolatile(obj, offset); } - public int getAndSet(T obj, int newValue) { - if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); - return unsafe.getAndSetInt(obj, offset, newValue); + public final int getAndSet(T obj, int newValue) { + accessCheck(obj); + return U.getAndSetInt(obj, offset, newValue); } - public int getAndIncrement(T obj) { - return getAndAdd(obj, 1); + public final int getAndAdd(T obj, int delta) { + accessCheck(obj); + return U.getAndAddInt(obj, offset, delta); } - public int getAndDecrement(T obj) { - return getAndAdd(obj, -1); + public final int getAndIncrement(T obj) { + return getAndAdd(obj, 1); } - public int getAndAdd(T obj, int delta) { - if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); - return unsafe.getAndAddInt(obj, offset, delta); + public final int getAndDecrement(T obj) { + return getAndAdd(obj, -1); } - public int incrementAndGet(T obj) { + public final int incrementAndGet(T obj) { return getAndAdd(obj, 1) + 1; } - public int decrementAndGet(T obj) { - return getAndAdd(obj, -1) - 1; + public final int decrementAndGet(T obj) { + return getAndAdd(obj, -1) - 1; } - public int addAndGet(T obj, int delta) { + public final int addAndGet(T obj, int delta) { return getAndAdd(obj, delta) + delta; } - private void ensureProtectedAccess(T obj) { - if (cclass.isInstance(obj)) { - return; - } - throw new RuntimeException( - new IllegalAccessException("Class " + - cclass.getName() + - " can not access a protected member of class " + - tclass.getName() + - " using an instance of " + - obj.getClass().getName() - ) - ); - } } } diff --git a/src/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java b/src/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java index aae2b248a124ad70f9422c45020e392e36d4ebed..e701c67005f92466a114fca959fb33ed3af4174e 100644 --- a/src/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java +++ b/src/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java @@ -34,14 +34,14 @@ */ package java.util.concurrent.atomic; -import java.util.function.LongUnaryOperator; -import java.util.function.LongBinaryOperator; -import sun.misc.Unsafe; + import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.security.AccessController; -import java.security.PrivilegedExceptionAction; import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; +import java.util.function.LongBinaryOperator; +import java.util.function.LongUnaryOperator; import sun.reflect.CallerSensitive; import sun.reflect.Reflection; @@ -365,11 +365,16 @@ public abstract class AtomicLongFieldUpdater { return next; } - private static class CASUpdater extends AtomicLongFieldUpdater { - private static final Unsafe unsafe = Unsafe.getUnsafe(); + private static final class CASUpdater extends AtomicLongFieldUpdater { + private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe(); private final long offset; - private final Class tclass; + /** + * if field is protected, the subclass constructing updater, else + * the same as tclass + */ private final Class cclass; + /** class holding the field */ + private final Class tclass; CASUpdater(final Class tclass, final String fieldName, final Class caller) { @@ -389,7 +394,7 @@ public abstract class AtomicLongFieldUpdater { ClassLoader ccl = caller.getClassLoader(); if ((ccl != null) && (ccl != cl) && ((cl == null) || !isAncestor(cl, ccl))) { - sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass); + sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass); } } catch (PrivilegedActionException pae) { throw new RuntimeException(pae.getException()); @@ -397,103 +402,110 @@ public abstract class AtomicLongFieldUpdater { throw new RuntimeException(ex); } - Class fieldt = field.getType(); - if (fieldt != long.class) + if (field.getType() != long.class) throw new IllegalArgumentException("Must be long type"); if (!Modifier.isVolatile(modifiers)) throw new IllegalArgumentException("Must be volatile type"); - this.cclass = (Modifier.isProtected(modifiers) && - caller != tclass) ? caller : null; + this.cclass = (Modifier.isProtected(modifiers)) ? caller : tclass; this.tclass = tclass; - offset = unsafe.objectFieldOffset(field); + this.offset = U.objectFieldOffset(field); + } + + /** + * Checks that target argument is instance of cclass. On + * failure, throws cause. + */ + private final void accessCheck(T obj) { + if (!cclass.isInstance(obj)) + throwAccessCheckException(obj); } - private void fullCheck(T obj) { - if (!tclass.isInstance(obj)) + /** + * Throws access exception if accessCheck failed due to + * protected access, else ClassCastException. + */ + private final void throwAccessCheckException(T obj) { + if (cclass == tclass) throw new ClassCastException(); - if (cclass != null) - ensureProtectedAccess(obj); + else + throw new RuntimeException( + new IllegalAccessException( + "Class " + + cclass.getName() + + " can not access a protected member of class " + + tclass.getName() + + " using an instance of " + + obj.getClass().getName())); } - public boolean compareAndSet(T obj, long expect, long update) { - if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); - return unsafe.compareAndSwapLong(obj, offset, expect, update); + public final boolean compareAndSet(T obj, long expect, long update) { + accessCheck(obj); + return U.compareAndSwapLong(obj, offset, expect, update); } - public boolean weakCompareAndSet(T obj, long expect, long update) { - if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); - return unsafe.compareAndSwapLong(obj, offset, expect, update); + public final boolean weakCompareAndSet(T obj, long expect, long update) { + accessCheck(obj); + return U.compareAndSwapLong(obj, offset, expect, update); } - public void set(T obj, long newValue) { - if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); - unsafe.putLongVolatile(obj, offset, newValue); + public final void set(T obj, long newValue) { + accessCheck(obj); + U.putLongVolatile(obj, offset, newValue); } - public void lazySet(T obj, long newValue) { - if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); - unsafe.putOrderedLong(obj, offset, newValue); + public final void lazySet(T obj, long newValue) { + accessCheck(obj); + U.putOrderedLong(obj, offset, newValue); } - public long get(T obj) { - if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); - return unsafe.getLongVolatile(obj, offset); + public final long get(T obj) { + accessCheck(obj); + return U.getLongVolatile(obj, offset); } - public long getAndSet(T obj, long newValue) { - if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); - return unsafe.getAndSetLong(obj, offset, newValue); + public final long getAndSet(T obj, long newValue) { + accessCheck(obj); + return U.getAndSetLong(obj, offset, newValue); } - public long getAndIncrement(T obj) { - return getAndAdd(obj, 1); + public final long getAndAdd(T obj, long delta) { + accessCheck(obj); + return U.getAndAddLong(obj, offset, delta); } - public long getAndDecrement(T obj) { - return getAndAdd(obj, -1); + public final long getAndIncrement(T obj) { + return getAndAdd(obj, 1); } - public long getAndAdd(T obj, long delta) { - if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); - return unsafe.getAndAddLong(obj, offset, delta); + public final long getAndDecrement(T obj) { + return getAndAdd(obj, -1); } - public long incrementAndGet(T obj) { + public final long incrementAndGet(T obj) { return getAndAdd(obj, 1) + 1; } - public long decrementAndGet(T obj) { - return getAndAdd(obj, -1) - 1; + public final long decrementAndGet(T obj) { + return getAndAdd(obj, -1) - 1; } - public long addAndGet(T obj, long delta) { + public final long addAndGet(T obj, long delta) { return getAndAdd(obj, delta) + delta; } - - private void ensureProtectedAccess(T obj) { - if (cclass.isInstance(obj)) { - return; - } - throw new RuntimeException( - new IllegalAccessException("Class " + - cclass.getName() + - " can not access a protected member of class " + - tclass.getName() + - " using an instance of " + - obj.getClass().getName() - ) - ); - } } - - private static class LockedUpdater extends AtomicLongFieldUpdater { - private static final Unsafe unsafe = Unsafe.getUnsafe(); + private static final class LockedUpdater extends AtomicLongFieldUpdater { + private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe(); private final long offset; - private final Class tclass; + /** + * if field is protected, the subclass constructing updater, else + * the same as tclass + */ private final Class cclass; + /** class holding the field */ + private final Class tclass; LockedUpdater(final Class tclass, final String fieldName, final Class caller) { @@ -513,7 +525,7 @@ public abstract class AtomicLongFieldUpdater { ClassLoader ccl = caller.getClassLoader(); if ((ccl != null) && (ccl != cl) && ((cl == null) || !isAncestor(cl, ccl))) { - sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass); + sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass); } } catch (PrivilegedActionException pae) { throw new RuntimeException(pae.getException()); @@ -521,72 +533,75 @@ public abstract class AtomicLongFieldUpdater { throw new RuntimeException(ex); } - Class fieldt = field.getType(); - if (fieldt != long.class) + if (field.getType() != long.class) throw new IllegalArgumentException("Must be long type"); if (!Modifier.isVolatile(modifiers)) throw new IllegalArgumentException("Must be volatile type"); - this.cclass = (Modifier.isProtected(modifiers) && - caller != tclass) ? caller : null; + this.cclass = (Modifier.isProtected(modifiers)) ? caller : tclass; this.tclass = tclass; - offset = unsafe.objectFieldOffset(field); + this.offset = U.objectFieldOffset(field); } - private void fullCheck(T obj) { - if (!tclass.isInstance(obj)) - throw new ClassCastException(); - if (cclass != null) - ensureProtectedAccess(obj); + /** + * Checks that target argument is instance of cclass. On + * failure, throws cause. + */ + private final void accessCheck(T obj) { + if (!cclass.isInstance(obj)) + throw accessCheckException(obj); + } + + /** + * Returns access exception if accessCheck failed due to + * protected access, else ClassCastException. + */ + private final RuntimeException accessCheckException(T obj) { + if (cclass == tclass) + return new ClassCastException(); + else + return new RuntimeException( + new IllegalAccessException( + "Class " + + cclass.getName() + + " can not access a protected member of class " + + tclass.getName() + + " using an instance of " + + obj.getClass().getName())); } - public boolean compareAndSet(T obj, long expect, long update) { - if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); + public final boolean compareAndSet(T obj, long expect, long update) { + accessCheck(obj); synchronized (this) { - long v = unsafe.getLong(obj, offset); + long v = U.getLong(obj, offset); if (v != expect) return false; - unsafe.putLong(obj, offset, update); + U.putLong(obj, offset, update); return true; } } - public boolean weakCompareAndSet(T obj, long expect, long update) { + public final boolean weakCompareAndSet(T obj, long expect, long update) { return compareAndSet(obj, expect, update); } - public void set(T obj, long newValue) { - if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); + public final void set(T obj, long newValue) { + accessCheck(obj); synchronized (this) { - unsafe.putLong(obj, offset, newValue); + U.putLong(obj, offset, newValue); } } - public void lazySet(T obj, long newValue) { + public final void lazySet(T obj, long newValue) { set(obj, newValue); } - public long get(T obj) { - if (obj == null || obj.getClass() != tclass || cclass != null) fullCheck(obj); + public final long get(T obj) { + accessCheck(obj); synchronized (this) { - return unsafe.getLong(obj, offset); - } - } - - private void ensureProtectedAccess(T obj) { - if (cclass.isInstance(obj)) { - return; + return U.getLong(obj, offset); } - throw new RuntimeException( - new IllegalAccessException("Class " + - cclass.getName() + - " can not access a protected member of class " + - tclass.getName() + - " using an instance of " + - obj.getClass().getName() - ) - ); } } @@ -595,7 +610,7 @@ public abstract class AtomicLongFieldUpdater { * classloader's delegation chain. * Equivalent to the inaccessible: first.isAncestor(second). */ - private static boolean isAncestor(ClassLoader first, ClassLoader second) { + static boolean isAncestor(ClassLoader first, ClassLoader second) { ClassLoader acl = first; do { acl = acl.getParent(); diff --git a/src/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java b/src/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java index 4408ff3b1d755c2f9ce6dc5d4e1be3ef43e88a02..76fa0a761c7538bd4c88d9940cea98d8daf0378d 100644 --- a/src/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java +++ b/src/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java @@ -34,14 +34,14 @@ */ package java.util.concurrent.atomic; -import java.util.function.UnaryOperator; -import java.util.function.BinaryOperator; -import sun.misc.Unsafe; + import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.security.AccessController; -import java.security.PrivilegedExceptionAction; import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; +import java.util.function.BinaryOperator; +import java.util.function.UnaryOperator; import sun.reflect.CallerSensitive; import sun.reflect.Reflection; @@ -53,7 +53,7 @@ import sun.reflect.Reflection; * independently subject to atomic updates. For example, a tree node * might be declared as * - *

 {@code
+ * 
 {@code
  * class Node {
  *   private volatile Node left, right;
  *
@@ -62,7 +62,7 @@ import sun.reflect.Reflection;
  *   private static AtomicReferenceFieldUpdater rightUpdater =
  *     AtomicReferenceFieldUpdater.newUpdater(Node.class, Node.class, "right");
  *
- *   Node getLeft() { return left;  }
+ *   Node getLeft() { return left; }
  *   boolean compareAndSetLeft(Node expect, Node update) {
  *     return leftUpdater.compareAndSet(this, expect, update);
  *   }
@@ -284,11 +284,17 @@ public abstract class AtomicReferenceFieldUpdater {
 
     private static final class AtomicReferenceFieldUpdaterImpl
         extends AtomicReferenceFieldUpdater {
-        private static final Unsafe unsafe = Unsafe.getUnsafe();
+        private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
         private final long offset;
+        /**
+         * if field is protected, the subclass constructing updater, else
+         * the same as tclass
+         */
+        private final Class cclass;
+        /** class holding the field */
         private final Class tclass;
+        /** field value type */
         private final Class vclass;
-        private final Class cclass;
 
         /*
          * Internal type checks within all update methods contain
@@ -323,7 +329,7 @@ public abstract class AtomicReferenceFieldUpdater {
                 ClassLoader ccl = caller.getClassLoader();
                 if ((ccl != null) && (ccl != cl) &&
                     ((cl == null) || !isAncestor(cl, ccl))) {
-                  sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass);
+                    sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass);
                 }
                 fieldClass = field.getType();
             } catch (PrivilegedActionException pae) {
@@ -340,14 +346,10 @@ public abstract class AtomicReferenceFieldUpdater {
             if (!Modifier.isVolatile(modifiers))
                 throw new IllegalArgumentException("Must be volatile type");
 
-            this.cclass = (Modifier.isProtected(modifiers) &&
-                           caller != tclass) ? caller : null;
+            this.cclass = (Modifier.isProtected(modifiers)) ? caller : tclass;
             this.tclass = tclass;
-            if (vclass == Object.class)
-                this.vclass = null;
-            else
-                this.vclass = vclass;
-            offset = unsafe.objectFieldOffset(field);
+            this.vclass = vclass;
+            this.offset = U.objectFieldOffset(field);
         }
 
         /**
@@ -366,83 +368,78 @@ public abstract class AtomicReferenceFieldUpdater {
             return false;
         }
 
-        void targetCheck(T obj) {
-            if (!tclass.isInstance(obj))
-                throw new ClassCastException();
-            if (cclass != null)
-                ensureProtectedAccess(obj);
+        /**
+         * Checks that target argument is instance of cclass.  On
+         * failure, throws cause.
+         */
+        private final void accessCheck(T obj) {
+            if (!cclass.isInstance(obj))
+                throwAccessCheckException(obj);
         }
 
-        void updateCheck(T obj, V update) {
-            if (!tclass.isInstance(obj) ||
-                (update != null && vclass != null && !vclass.isInstance(update)))
+        /**
+         * Throws access exception if accessCheck failed due to
+         * protected access, else ClassCastException.
+         */
+        private final void throwAccessCheckException(T obj) {
+            if (cclass == tclass)
                 throw new ClassCastException();
-            if (cclass != null)
-                ensureProtectedAccess(obj);
+            else
+                throw new RuntimeException(
+                    new IllegalAccessException(
+                        "Class " +
+                        cclass.getName() +
+                        " can not access a protected member of class " +
+                        tclass.getName() +
+                        " using an instance of " +
+                        obj.getClass().getName()));
         }
 
-        public boolean compareAndSet(T obj, V expect, V update) {
-            if (obj == null || obj.getClass() != tclass || cclass != null ||
-                (update != null && vclass != null &&
-                 vclass != update.getClass()))
-                updateCheck(obj, update);
-            return unsafe.compareAndSwapObject(obj, offset, expect, update);
+        private final void valueCheck(V v) {
+            if (v != null && !(vclass.isInstance(v)))
+                throwCCE();
         }
 
-        public boolean weakCompareAndSet(T obj, V expect, V update) {
-            // same implementation as strong form for now
-            if (obj == null || obj.getClass() != tclass || cclass != null ||
-                (update != null && vclass != null &&
-                 vclass != update.getClass()))
-                updateCheck(obj, update);
-            return unsafe.compareAndSwapObject(obj, offset, expect, update);
+        static void throwCCE() {
+            throw new ClassCastException();
         }
 
-        public void set(T obj, V newValue) {
-            if (obj == null || obj.getClass() != tclass || cclass != null ||
-                (newValue != null && vclass != null &&
-                 vclass != newValue.getClass()))
-                updateCheck(obj, newValue);
-            unsafe.putObjectVolatile(obj, offset, newValue);
+        public final boolean compareAndSet(T obj, V expect, V update) {
+            accessCheck(obj);
+            valueCheck(update);
+            return U.compareAndSwapObject(obj, offset, expect, update);
         }
 
-        public void lazySet(T obj, V newValue) {
-            if (obj == null || obj.getClass() != tclass || cclass != null ||
-                (newValue != null && vclass != null &&
-                 vclass != newValue.getClass()))
-                updateCheck(obj, newValue);
-            unsafe.putOrderedObject(obj, offset, newValue);
+        public final boolean weakCompareAndSet(T obj, V expect, V update) {
+            // same implementation as strong form for now
+            accessCheck(obj);
+            valueCheck(update);
+            return U.compareAndSwapObject(obj, offset, expect, update);
         }
 
-        @SuppressWarnings("unchecked")
-        public V get(T obj) {
-            if (obj == null || obj.getClass() != tclass || cclass != null)
-                targetCheck(obj);
-            return (V)unsafe.getObjectVolatile(obj, offset);
+        public final void set(T obj, V newValue) {
+            accessCheck(obj);
+            valueCheck(newValue);
+            U.putObjectVolatile(obj, offset, newValue);
+        }
+
+        public final void lazySet(T obj, V newValue) {
+            accessCheck(obj);
+            valueCheck(newValue);
+            U.putOrderedObject(obj, offset, newValue);
         }
 
         @SuppressWarnings("unchecked")
-        public V getAndSet(T obj, V newValue) {
-            if (obj == null || obj.getClass() != tclass || cclass != null ||
-                (newValue != null && vclass != null &&
-                 vclass != newValue.getClass()))
-                updateCheck(obj, newValue);
-            return (V)unsafe.getAndSetObject(obj, offset, newValue);
+        public final V get(T obj) {
+            accessCheck(obj);
+            return (V)U.getObjectVolatile(obj, offset);
         }
 
-        private void ensureProtectedAccess(T obj) {
-            if (cclass.isInstance(obj)) {
-                return;
-            }
-            throw new RuntimeException(
-                new IllegalAccessException("Class " +
-                    cclass.getName() +
-                    " can not access a protected member of class " +
-                    tclass.getName() +
-                    " using an instance of " +
-                    obj.getClass().getName()
-                )
-            );
+        @SuppressWarnings("unchecked")
+        public final V getAndSet(T obj, V newValue) {
+            accessCheck(obj);
+            valueCheck(newValue);
+            return (V)U.getAndSetObject(obj, offset, newValue);
         }
     }
 }
diff --git a/src/share/classes/javax/management/remote/rmi/RMIConnector.java b/src/share/classes/javax/management/remote/rmi/RMIConnector.java
index 71f1bc0f77f5944bcd33a2915129bcca722bfda2..8317b9e8b8b541e10cc99490aec1c17cc860d38e 100644
--- a/src/share/classes/javax/management/remote/rmi/RMIConnector.java
+++ b/src/share/classes/javax/management/remote/rmi/RMIConnector.java
@@ -2639,7 +2639,7 @@ public class RMIConnector implements JMXConnector, Serializable, JMXAddressable
         return attributes != null ?
                 attributes.asList().stream()
                         .map(Attribute::getName)
-                        .collect(Collectors.joining("[", ", ", "]"))
+                        .collect(Collectors.joining(", ", "[", "]"))
                 : "[]";
     }
 }
diff --git a/src/share/classes/javax/security/auth/SubjectDomainCombiner.java b/src/share/classes/javax/security/auth/SubjectDomainCombiner.java
index 7c54a32c3784734c180b5a9d9eb315db7a59d4c3..da75d68342506ca3be7584b41d79a70c08b79199 100644
--- a/src/share/classes/javax/security/auth/SubjectDomainCombiner.java
+++ b/src/share/classes/javax/security/auth/SubjectDomainCombiner.java
@@ -37,8 +37,6 @@ import java.security.Security;
 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
@@ -67,9 +65,6 @@ public class SubjectDomainCombiner implements java.security.DomainCombiner {
     private static final boolean allowCaching =
                                         (useJavaxPolicy && cachePolicy());
 
-    private static final JavaSecurityProtectionDomainAccess pdAccess =
-        SharedSecrets.getJavaSecurityProtectionDomainAccess();
-
     /**
      * Associate the provided {@code Subject} with this
      * {@code SubjectDomainCombiner}.
@@ -244,15 +239,10 @@ public class SubjectDomainCombiner implements java.security.DomainCombiner {
                 subjectPd = cachedPDs.getValue(pd);
 
                 if (subjectPd == null) {
-                    if (pdAccess.getStaticPermissionsField(pd)) {
-                        // Need to keep static ProtectionDomain objects static
-                        subjectPd = pd;
-                    } else {
-                        subjectPd = new ProtectionDomain(pd.getCodeSource(),
+                    subjectPd = new ProtectionDomain(pd.getCodeSource(),
                                                 pd.getPermissions(),
                                                 pd.getClassLoader(),
                                                 principals);
-                    }
                     cachedPDs.putValue(pd, subjectPd);
                 } else {
                     allNew = false;
diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java
index e3fb95d3e3adb12026a54f02d8e9bfab5bb11d49..bb615d2b24bdd45b9cd4a22862c67f058dd7289f 100644
--- a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java
+++ b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java
@@ -21,7 +21,7 @@
  * under the License.
  */
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * $Id: DOMSignatureMethod.java 1333415 2012-05-03 12:03:51Z coheigea $
@@ -34,10 +34,12 @@ import javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec;
 
 import java.io.IOException;
 import java.security.*;
+import java.security.interfaces.DSAKey;
 import java.security.spec.AlgorithmParameterSpec;
 import org.w3c.dom.Element;
 
 import com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureECDSA;
+import com.sun.org.apache.xml.internal.security.utils.JavaUtils;
 import org.jcp.xml.dsig.internal.SignerOutputStream;
 
 /**
@@ -68,6 +70,8 @@ public abstract class DOMSignatureMethod extends AbstractDOMSignatureMethod {
         "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha384";
     static final String ECDSA_SHA512 =
         "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha512";
+    static final String DSA_SHA256 =
+        "http://www.w3.org/2009/xmldsig11#dsa-sha256";
 
     /**
      * Creates a DOMSignatureMethod.
@@ -119,6 +123,8 @@ public abstract class DOMSignatureMethod extends AbstractDOMSignatureMethod {
             return new SHA512withRSA(smElem);
         } else if (alg.equals(SignatureMethod.DSA_SHA1)) {
             return new SHA1withDSA(smElem);
+        } else if (alg.equals(DSA_SHA256)) {
+            return new SHA256withDSA(smElem);
         } else if (alg.equals(ECDSA_SHA1)) {
             return new SHA1withECDSA(smElem);
         } else if (alg.equals(ECDSA_SHA256)) {
@@ -178,7 +184,9 @@ public abstract class DOMSignatureMethod extends AbstractDOMSignatureMethod {
         try {
             Type type = getAlgorithmType();
             if (type == Type.DSA) {
-                return signature.verify(convertXMLDSIGtoASN1(sig));
+                int size = ((DSAKey)key).getParams().getQ().bitLength();
+                return signature.verify(JavaUtils.convertDsaXMLDSIGtoASN1(sig,
+                                                                       size/8));
             } else if (type == Type.ECDSA) {
                 return signature.verify(SignatureECDSA.convertXMLDSIGtoASN1(sig));
             } else {
@@ -222,7 +230,9 @@ public abstract class DOMSignatureMethod extends AbstractDOMSignatureMethod {
         try {
             Type type = getAlgorithmType();
             if (type == Type.DSA) {
-                return convertASN1toXMLDSIG(signature.sign());
+                int size = ((DSAKey)key).getParams().getQ().bitLength();
+                return JavaUtils.convertDsaASN1toXMLDSIG(signature.sign(),
+                                                         size/8);
             } else if (type == Type.ECDSA) {
                 return SignatureECDSA.convertASN1toXMLDSIG(signature.sign());
             } else {
@@ -235,101 +245,6 @@ public abstract class DOMSignatureMethod extends AbstractDOMSignatureMethod {
         }
     }
 
-    /**
-     * Converts an ASN.1 DSA value to a XML Signature DSA Value.
-     *
-     * The JAVA JCE DSA Signature algorithm creates ASN.1 encoded (r,s) value
-     * pairs; the XML Signature requires the core BigInteger values.
-     *
-     * @param asn1Bytes
-     *
-     * @throws IOException
-     * @see 6.4.1 DSA
-     */
-    private static byte[] convertASN1toXMLDSIG(byte asn1Bytes[])
-        throws IOException
-    {
-        byte rLength = asn1Bytes[3];
-        int i;
-
-        for (i = rLength; (i > 0) && (asn1Bytes[(4 + rLength) - i] == 0); i--);
-
-        byte sLength = asn1Bytes[5 + rLength];
-        int j;
-
-        for (j = sLength;
-            (j > 0) && (asn1Bytes[(6 + rLength + sLength) - j] == 0); j--);
-
-        if ((asn1Bytes[0] != 48) || (asn1Bytes[1] != asn1Bytes.length - 2)
-            || (asn1Bytes[2] != 2) || (i > 20)
-            || (asn1Bytes[4 + rLength] != 2) || (j > 20)) {
-            throw new IOException("Invalid ASN.1 format of DSA signature");
-        } else {
-            byte xmldsigBytes[] = new byte[40];
-
-            System.arraycopy(asn1Bytes, (4+rLength)-i, xmldsigBytes, 20-i, i);
-            System.arraycopy(asn1Bytes, (6+rLength+sLength)-j, xmldsigBytes,
-                             40 - j, j);
-
-            return xmldsigBytes;
-        }
-    }
-
-    /**
-     * Converts a XML Signature DSA Value to an ASN.1 DSA value.
-     *
-     * The JAVA JCE DSA Signature algorithm creates ASN.1 encoded (r,s) value
-     * pairs; the XML Signature requires the core BigInteger values.
-     *
-     * @param xmldsigBytes
-     *
-     * @throws IOException
-     * @see 6.4.1 DSA
-     */
-    private static byte[] convertXMLDSIGtoASN1(byte xmldsigBytes[])
-        throws IOException
-    {
-        if (xmldsigBytes.length != 40) {
-            throw new IOException("Invalid XMLDSIG format of DSA signature");
-        }
-
-        int i;
-
-        for (i = 20; (i > 0) && (xmldsigBytes[20 - i] == 0); i--);
-
-        int j = i;
-
-        if (xmldsigBytes[20 - i] < 0) {
-            j += 1;
-        }
-
-        int k;
-
-        for (k = 20; (k > 0) && (xmldsigBytes[40 - k] == 0); k--);
-
-        int l = k;
-
-        if (xmldsigBytes[40 - k] < 0) {
-            l += 1;
-        }
-
-        byte asn1Bytes[] = new byte[6 + j + l];
-
-        asn1Bytes[0] = 48;
-        asn1Bytes[1] = (byte)(4 + j + l);
-        asn1Bytes[2] = 2;
-        asn1Bytes[3] = (byte)j;
-
-        System.arraycopy(xmldsigBytes, 20 - i, asn1Bytes, (4 + j) - i, i);
-
-        asn1Bytes[4 + j] = 2;
-        asn1Bytes[5 + j] = (byte) l;
-
-        System.arraycopy(xmldsigBytes, 40 - k, asn1Bytes, (6 + j + l) - k, k);
-
-        return asn1Bytes;
-    }
-
     static final class SHA1withRSA extends DOMSignatureMethod {
         SHA1withRSA(AlgorithmParameterSpec params)
             throws InvalidAlgorithmParameterException {
@@ -425,6 +340,25 @@ public abstract class DOMSignatureMethod extends AbstractDOMSignatureMethod {
         }
     }
 
+    static final class SHA256withDSA extends DOMSignatureMethod {
+        SHA256withDSA(AlgorithmParameterSpec params)
+            throws InvalidAlgorithmParameterException {
+            super(params);
+        }
+        SHA256withDSA(Element dmElem) throws MarshalException {
+            super(dmElem);
+        }
+        public String getAlgorithm() {
+            return DSA_SHA256;
+        }
+        String getJCAAlgorithm() {
+            return "SHA256withDSA";
+        }
+        Type getAlgorithmType() {
+            return Type.DSA;
+        }
+    }
+
     static final class SHA1withECDSA extends DOMSignatureMethod {
         SHA1withECDSA(AlgorithmParameterSpec params)
             throws InvalidAlgorithmParameterException {
diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java
index eb68d70579f0529853a212ea7666896b761e4183..b2ca7ee7d48dff9c589a6072943f4e75cc5a7d38 100644
--- a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java
+++ b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java
@@ -21,7 +21,7 @@
  * under the License.
  */
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * $Id: DOMXMLSignatureFactory.java 1333869 2012-05-04 10:42:44Z coheigea $
@@ -239,6 +239,8 @@ public final class DOMXMLSignatureFactory extends XMLSignatureFactory {
             return new DOMSignatureMethod.SHA512withRSA(params);
         } else if (algorithm.equals(SignatureMethod.DSA_SHA1)) {
             return new DOMSignatureMethod.SHA1withDSA(params);
+        } else if (algorithm.equals(DOMSignatureMethod.DSA_SHA256)) {
+            return new DOMSignatureMethod.SHA256withDSA(params);
         } else if (algorithm.equals(SignatureMethod.HMAC_SHA1)) {
             return new DOMHMACSignatureMethod.SHA1(params);
         } else if (algorithm.equals(DOMHMACSignatureMethod.HMAC_SHA256)) {
diff --git a/src/share/classes/sun/font/FileFontStrike.java b/src/share/classes/sun/font/FileFontStrike.java
index 888be14559a58bbc4282dd96752928e08ff1a7e9..c66bcaf7411fed0c3dbab7b08b74a93c8fe09824 100644
--- a/src/share/classes/sun/font/FileFontStrike.java
+++ b/src/share/classes/sun/font/FileFontStrike.java
@@ -453,6 +453,17 @@ public class FileFontStrike extends PhysicalStrike {
 
     /* Only look in the cache */
     long getCachedGlyphPtr(int glyphCode) {
+        try {
+            return getCachedGlyphPtrInternal(glyphCode);
+        } catch (Exception e) {
+          NullFontScaler nullScaler =
+             (NullFontScaler)FontScaler.getNullScaler();
+          long nullSC = NullFontScaler.getNullScalerContext();
+          return nullScaler.getGlyphImage(nullSC, glyphCode);
+        }
+    }
+
+    private long getCachedGlyphPtrInternal(int glyphCode) {
         switch (glyphCacheFormat) {
             case INTARRAY:
                 return intGlyphImages[glyphCode] & INTMASK;
@@ -480,6 +491,27 @@ public class FileFontStrike extends PhysicalStrike {
     }
 
     private synchronized long setCachedGlyphPtr(int glyphCode, long glyphPtr) {
+        try {
+            return setCachedGlyphPtrInternal(glyphCode, glyphPtr);
+        } catch (Exception e) {
+            switch (glyphCacheFormat) {
+                case INTARRAY:
+                case SEGINTARRAY:
+                    StrikeCache.freeIntPointer((int)glyphPtr);
+                    break;
+                case LONGARRAY:
+                case SEGLONGARRAY:
+                    StrikeCache.freeLongPointer(glyphPtr);
+                    break;
+             }
+             NullFontScaler nullScaler =
+                 (NullFontScaler)FontScaler.getNullScaler();
+             long nullSC = NullFontScaler.getNullScalerContext();
+             return nullScaler.getGlyphImage(nullSC, glyphCode);
+        }
+    }
+
+    private long setCachedGlyphPtrInternal(int glyphCode, long glyphPtr) {
         switch (glyphCacheFormat) {
             case INTARRAY:
                 if (intGlyphImages[glyphCode] == 0) {
diff --git a/src/share/classes/sun/font/TrueTypeGlyphMapper.java b/src/share/classes/sun/font/TrueTypeGlyphMapper.java
index febaf6a5eb723267fbae1f77f837453b25211811..41262146fa6684348c999713987b8cbda6ef6959 100644
--- a/src/share/classes/sun/font/TrueTypeGlyphMapper.java
+++ b/src/share/classes/sun/font/TrueTypeGlyphMapper.java
@@ -59,7 +59,11 @@ public class TrueTypeGlyphMapper extends CharToGlyphMapper {
         }
         missingGlyph = 0; /* standard for TrueType fonts */
         ByteBuffer buffer = font.getTableBuffer(TrueTypeFont.maxpTag);
-        numGlyphs = buffer.getChar(4); // offset 4 bytes in MAXP table.
+        if (buffer != null && buffer.capacity() >= 6) {
+            numGlyphs = buffer.getChar(4); // offset 4 bytes in MAXP table.
+        } else {
+            handleBadCMAP();
+        }
         if (FontUtilities.isSolaris && isJAlocale && font.supportsJA()) {
             needsJAremapping = true;
             if (FontUtilities.isSolaris8 &&
diff --git a/src/share/classes/sun/misc/JavaSecurityProtectionDomainAccess.java b/src/share/classes/sun/misc/JavaSecurityProtectionDomainAccess.java
index 3567f350f23cbc47ddfd5335840d702828db78a8..95560ffab68210ca69a5ddc299b80e2780dc0204 100644
--- a/src/share/classes/sun/misc/JavaSecurityProtectionDomainAccess.java
+++ b/src/share/classes/sun/misc/JavaSecurityProtectionDomainAccess.java
@@ -36,9 +36,4 @@ public interface JavaSecurityProtectionDomainAccess {
      * Returns the ProtectionDomainCache.
      */
     ProtectionDomainCache getProtectionDomainCache();
-
-    /**
-     * Returns the staticPermissions field of the specified object
-     */
-    boolean getStaticPermissionsField(ProtectionDomain pd);
 }
diff --git a/src/share/classes/sun/misc/Version.java.template b/src/share/classes/sun/misc/Version.java.template
index dd47869acbde9baac1082bcf76206923a1ba480c..32e2586e795ee5a90638af54a74a0889b9589948 100644
--- a/src/share/classes/sun/misc/Version.java.template
+++ b/src/share/classes/sun/misc/Version.java.template
@@ -291,15 +291,24 @@ public class Version {
                 jvm_minor_version = Character.digit(cs.charAt(2), 10);
                 jvm_micro_version = Character.digit(cs.charAt(4), 10);
                 cs = cs.subSequence(5, cs.length());
-                if (cs.charAt(0) == '_' && cs.length() >= 3 &&
-                    Character.isDigit(cs.charAt(1)) &&
-                    Character.isDigit(cs.charAt(2))) {
-                    int nextChar = 3;
+                if (cs.charAt(0) == '_' && cs.length() >= 3) {
+                    int nextChar = 0;
+                    if (Character.isDigit(cs.charAt(1)) &&
+                        Character.isDigit(cs.charAt(2)) &&
+                        Character.isDigit(cs.charAt(3)))
+                    {
+                        nextChar = 4;
+                    } else if (Character.isDigit(cs.charAt(1)) &&
+                        Character.isDigit(cs.charAt(2)))
+                    {
+                        nextChar = 3;
+                    }
+
                     try {
-                        String uu = cs.subSequence(1, 3).toString();
+                        String uu = cs.subSequence(1, nextChar).toString();
                         jvm_update_version = Integer.valueOf(uu).intValue();
-                        if (cs.length() >= 4) {
-                            char c = cs.charAt(3);
+                        if (cs.length() >= nextChar + 1) {
+                            char c = cs.charAt(nextChar);
                             if (c >= 'a' && c <= 'z') {
                                 jvm_special_version = Character.toString(c);
                                 nextChar++;
diff --git a/src/share/classes/sun/security/pkcs10/PKCS10.java b/src/share/classes/sun/security/pkcs10/PKCS10.java
index af4e8a4a1786b426baabb0442d9f2398fa82756f..02ed730b9afb51060091669f0795164aa739bca2 100644
--- a/src/share/classes/sun/security/pkcs10/PKCS10.java
+++ b/src/share/classes/sun/security/pkcs10/PKCS10.java
@@ -290,8 +290,9 @@ public class PKCS10 {
             throw new SignatureException("Cert request was not signed");
 
 
+        byte[] CRLF = new byte[] {'\r', '\n'};
         out.println("-----BEGIN NEW CERTIFICATE REQUEST-----");
-        out.println(Base64.getMimeEncoder().encodeToString(encoded));
+        out.println(Base64.getMimeEncoder(64, CRLF).encodeToString(encoded));
         out.println("-----END NEW CERTIFICATE REQUEST-----");
     }
 
diff --git a/src/share/classes/sun/security/provider/X509Factory.java b/src/share/classes/sun/security/provider/X509Factory.java
index 46b1a3c8d7d42ae3c857df7beaf2562bbefb6586..5fa9416e60d89511232ea2c57f625a5b5e718e7b 100644
--- a/src/share/classes/sun/security/provider/X509Factory.java
+++ b/src/share/classes/sun/security/provider/X509Factory.java
@@ -28,6 +28,8 @@ package sun.security.provider;
 import java.io.*;
 import java.util.*;
 import java.security.cert.*;
+
+import sun.security.util.Pem;
 import sun.security.x509.X509CertImpl;
 import sun.security.x509.X509CRLImpl;
 import sun.security.pkcs.PKCS7;
@@ -633,7 +635,7 @@ public class X509Factory extends CertificateFactorySpi {
 
             checkHeaderFooter(header.toString(), footer.toString());
 
-            return Base64.getMimeDecoder().decode(new String(data, 0, pos));
+            return Pem.decode(new String(data, 0, pos));
         }
     }
 
diff --git a/src/share/classes/sun/security/ssl/HandshakeHash.java b/src/share/classes/sun/security/ssl/HandshakeHash.java
index ad4f6fd1a5b249b14616d703ac24f9a395dd5656..c30d4e0eecc9c8f83368d84651e73ea6c6906a84 100644
--- a/src/share/classes/sun/security/ssl/HandshakeHash.java
+++ b/src/share/classes/sun/security/ssl/HandshakeHash.java
@@ -246,7 +246,7 @@ final class HandshakeHash {
         try {
             return cloneDigest(finMD).digest();
         } catch (Exception e) {
-            throw new Error("BAD");
+            throw new Error("Error during hash calculation", e);
         }
     }
 }
diff --git a/src/share/classes/sun/security/ssl/ServerHandshaker.java b/src/share/classes/sun/security/ssl/ServerHandshaker.java
index 5066474238d68c263b7c8077d57fe5dc9b939c60..9caa64a9c486c710fcf79165859f73169c0ba173 100644
--- a/src/share/classes/sun/security/ssl/ServerHandshaker.java
+++ b/src/share/classes/sun/security/ssl/ServerHandshaker.java
@@ -1259,8 +1259,8 @@ final class ServerHandshaker extends Handshaker {
                 }
             }
 
-            // need EC cert signed using EC
-            if (setupPrivateKeyAndChain("EC_EC") == false) {
+            // need EC cert
+            if (setupPrivateKeyAndChain("EC") == false) {
                 return false;
             }
             if (setupEphemeralECDHKeys() == false) {
@@ -1268,15 +1268,15 @@ final class ServerHandshaker extends Handshaker {
             }
             break;
         case K_ECDH_RSA:
-            // need EC cert signed using RSA
-            if (setupPrivateKeyAndChain("EC_RSA") == false) {
+            // need EC cert
+            if (setupPrivateKeyAndChain("EC") == false) {
                 return false;
             }
             setupStaticECDHKeys();
             break;
         case K_ECDH_ECDSA:
-            // need EC cert signed using EC
-            if (setupPrivateKeyAndChain("EC_EC") == false) {
+            // need EC cert
+            if (setupPrivateKeyAndChain("EC") == false) {
                 return false;
             }
             setupStaticECDHKeys();
diff --git a/src/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java b/src/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java
index e64b905a24233f6ff6b562f4fa43d19fff0f2c97..c9b31cdc93a9f8473f42a614c21b006c5bf71ea1 100644
--- a/src/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java
+++ b/src/share/classes/sun/security/ssl/SignatureAndHashAlgorithm.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@ package sun.security.ssl;
 import java.security.AlgorithmConstraints;
 import java.security.CryptoPrimitive;
 import java.security.PrivateKey;
+import java.security.Security;
 
 import java.util.Set;
 import java.util.HashSet;
@@ -152,13 +153,11 @@ final class SignatureAndHashAlgorithm {
             getSupportedAlgorithms(AlgorithmConstraints constraints) {
 
         Collection supported = new ArrayList<>();
-        synchronized (priorityMap) {
-            for (SignatureAndHashAlgorithm sigAlg : priorityMap.values()) {
-                if (sigAlg.priority <= SUPPORTED_ALG_PRIORITY_MAX_NUM &&
-                        constraints.permits(SIGNATURE_PRIMITIVE_SET,
-                                sigAlg.algorithm, null)) {
-                    supported.add(sigAlg);
-                }
+        for (SignatureAndHashAlgorithm sigAlg : priorityMap.values()) {
+            if (sigAlg.priority <= SUPPORTED_ALG_PRIORITY_MAX_NUM &&
+                    constraints.permits(SIGNATURE_PRIMITIVE_SET,
+                            sigAlg.algorithm, null)) {
+                supported.add(sigAlg);
             }
         }
 
@@ -412,10 +411,14 @@ final class SignatureAndHashAlgorithm {
                     "SHA1withRSA",          --p);
             supports(HashAlgorithm.SHA1,        SignatureAlgorithm.ECDSA,
                     "SHA1withECDSA",        --p);
-            supports(HashAlgorithm.SHA224,      SignatureAlgorithm.RSA,
-                    "SHA224withRSA",        --p);
-            supports(HashAlgorithm.SHA224,      SignatureAlgorithm.ECDSA,
-                    "SHA224withECDSA",      --p);
+
+            if (Security.getProvider("SunMSCAPI") == null) {
+                supports(HashAlgorithm.SHA224,      SignatureAlgorithm.RSA,
+                        "SHA224withRSA",        --p);
+                supports(HashAlgorithm.SHA224,      SignatureAlgorithm.ECDSA,
+                        "SHA224withECDSA",      --p);
+            }
+
             supports(HashAlgorithm.SHA256,      SignatureAlgorithm.RSA,
                     "SHA256withRSA",        --p);
             supports(HashAlgorithm.SHA256,      SignatureAlgorithm.ECDSA,
diff --git a/src/share/classes/sun/security/tools/keytool/Main.java b/src/share/classes/sun/security/tools/keytool/Main.java
index efbbf5ba8b0ea9e7f11c8cdeb8238e1ac7e28677..78df17156c1d5260bcce8346d84ef66d9af0ce71 100644
--- a/src/share/classes/sun/security/tools/keytool/Main.java
+++ b/src/share/classes/sun/security/tools/keytool/Main.java
@@ -79,6 +79,7 @@ import sun.security.pkcs.PKCS9Attribute;
 import sun.security.tools.KeyStoreUtil;
 import sun.security.tools.PathList;
 import sun.security.util.DerValue;
+import sun.security.util.Pem;
 import sun.security.x509.*;
 
 import static java.security.KeyStore.*;
@@ -99,6 +100,8 @@ import static sun.security.tools.keytool.Main.Option.*;
  */
 public final class Main {
 
+    private static final byte[] CRLF = new byte[] {'\r', '\n'};
+
     private boolean debug = false;
     private Command command = null;
     private String sigAlgName = null;
@@ -1205,7 +1208,7 @@ public final class Main {
                 sb.append(s);
             }
         }
-        byte[] rawReq = Base64.getMimeDecoder().decode(new String(sb));
+        byte[] rawReq = Pem.decode(new String(sb));
         PKCS10 req = new PKCS10(rawReq);
 
         info.set(X509CertInfo.KEY, new CertificateX509Key(req.getSubjectPublicKeyInfo()));
@@ -1282,7 +1285,7 @@ public final class Main {
         crl.sign(privateKey, sigAlgName);
         if (rfc) {
             out.println("-----BEGIN X509 CRL-----");
-            out.println(Base64.getMimeEncoder().encodeToString(crl.getEncodedInternal()));
+            out.println(Base64.getMimeEncoder(64, CRLF).encodeToString(crl.getEncodedInternal()));
             out.println("-----END X509 CRL-----");
         } else {
             out.write(crl.getEncodedInternal());
@@ -2251,7 +2254,7 @@ public final class Main {
         if (rfc) {
             X509CRL xcrl = (X509CRL)crl;
             out.println("-----BEGIN X509 CRL-----");
-            out.println(Base64.getMimeEncoder().encodeToString(xcrl.getEncoded()));
+            out.println(Base64.getMimeEncoder(64, CRLF).encodeToString(xcrl.getEncoded()));
             out.println("-----END X509 CRL-----");
         } else {
             out.println(crl.toString());
@@ -2278,7 +2281,7 @@ public final class Main {
                 sb.append(s);
             }
         }
-        PKCS10 req = new PKCS10(Base64.getMimeDecoder().decode(new String(sb)));
+        PKCS10 req = new PKCS10(Pem.decode(new String(sb)));
 
         PublicKey pkey = req.getSubjectPublicKeyInfo();
         out.printf(rb.getString("PKCS.10.Certificate.Request.Version.1.0.Subject.s.Public.Key.s.format.s.key."),
@@ -3059,7 +3062,7 @@ public final class Main {
     {
         if (rfc) {
             out.println(X509Factory.BEGIN_CERT);
-            out.println(Base64.getMimeEncoder().encodeToString(cert.getEncoded()));
+            out.println(Base64.getMimeEncoder(64, CRLF).encodeToString(cert.getEncoded()));
             out.println(X509Factory.END_CERT);
         } else {
             out.write(cert.getEncoded()); // binary
diff --git a/src/share/classes/sun/security/util/Pem.java b/src/share/classes/sun/security/util/Pem.java
new file mode 100644
index 0000000000000000000000000000000000000000..7e7a0e6d5fb1ea117594b43debb55fa9fee2dbfb
--- /dev/null
+++ b/src/share/classes/sun/security/util/Pem.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.  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.security.util;
+
+import java.io.IOException;
+import java.util.Base64;
+
+/**
+ * The Length interface defines the length of an object
+ */
+public class Pem {
+
+    /**
+     * Decodes a PEM-encoded block.
+     *
+     * @param input the input string, according to RFC 1421, can only contain
+     *              characters in the base-64 alphabet and whitespaces.
+     * @return the decoded bytes
+     * @throws java.io.IOException if input is invalid
+     */
+    public static byte[] decode(String input) throws IOException {
+        byte[] src = input.replaceAll("\\s+", "").getBytes();
+        try {
+            return Base64.getDecoder().decode(src);
+        } catch (IllegalArgumentException e) {
+            throw new IOException(e);
+        }
+    }
+}
diff --git a/src/share/classes/sun/security/x509/X509CertImpl.java b/src/share/classes/sun/security/x509/X509CertImpl.java
index b473ab840fc7cdad952ae8ea7b3c08d49472657e..fdbdd3c9ff159a61d95b8e8a50c602ad953a4502 100644
--- a/src/share/classes/sun/security/x509/X509CertImpl.java
+++ b/src/share/classes/sun/security/x509/X509CertImpl.java
@@ -271,7 +271,7 @@ public class X509CertImpl extends X509Certificate implements DerEncoder {
                         der = new DerValue(decstream.toByteArray());
                         break;
                     } else {
-                        decstream.write(Base64.getMimeDecoder().decode(line));
+                        decstream.write(Pem.decode(line));
                     }
                 }
             } catch (IOException ioe2) {
diff --git a/src/share/classes/sun/swing/CachedPainter.java b/src/share/classes/sun/swing/CachedPainter.java
index defc35f25432d94697130a5bcdec36d3c3f4e5ed..e49c60ecd393ce7b4da03928bcbd2d3e8ae7aeee 100644
--- a/src/share/classes/sun/swing/CachedPainter.java
+++ b/src/share/classes/sun/swing/CachedPainter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -53,9 +53,7 @@ import java.util.*;
  */
 public abstract class CachedPainter {
     // CacheMap maps from class to ImageCache.
-    private static final Map cacheMap =
-                   new HashMap();
-
+    private static final Map cacheMap = new HashMap<>();
 
     private static ImageCache getCache(Object key) {
         synchronized(CachedPainter.class) {
@@ -96,20 +94,8 @@ public abstract class CachedPainter {
         if (w <= 0 || h <= 0) {
             return;
         }
-        if (c != null) {
-            synchronized(c.getTreeLock()) {
-                synchronized(CachedPainter.class) {
-                    // If c is non-null, synchronize on the tree lock.
-                    // This is necessary because asking for the
-                    // GraphicsConfiguration will grab a tree lock.
-                    paint0(c, g, x, y, w, h, args);
-                }
-            }
-        }
-        else {
-            synchronized(CachedPainter.class) {
-                paint0(c, g, x, y, w, h, args);
-            }
+        synchronized (CachedPainter.class) {
+            paint0(c, g, x, y, w, h, args);
         }
     }
 
diff --git a/src/share/demo/jvmti/hprof/hprof_class.c b/src/share/demo/jvmti/hprof/hprof_class.c
index 3ebe008668575eb6ddaa17dc54346e316a95971c..49a1ced7bb0f463a07ffbea08ec4805e45c2da8d 100644
--- a/src/share/demo/jvmti/hprof/hprof_class.c
+++ b/src/share/demo/jvmti/hprof/hprof_class.c
@@ -529,6 +529,11 @@ class_get_methodID(JNIEnv *env, ClassIndex index, MethodIndex mnum)
     info = get_info(index);
     if (mnum >= info->method_count) {
         jclass newExcCls = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
+        if ((*env)->ExceptionCheck(env)) {
+            (*env)->ExceptionClear(env);
+            HPROF_ERROR(JNI_TRUE,
+                        "Could not find the java/lang/IllegalArgumentException class");
+        }
         (*env)->ThrowNew(env, newExcCls, "Illegal mnum");
 
         return NULL;
@@ -542,6 +547,11 @@ class_get_methodID(JNIEnv *env, ClassIndex index, MethodIndex mnum)
         name  = (char *)string_get(info->method[mnum].name_index);
         if (name==NULL) {
             jclass newExcCls = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
+            if ((*env)->ExceptionCheck(env)) {
+                (*env)->ExceptionClear(env);
+                HPROF_ERROR(JNI_TRUE,
+                            "Could not find the java/lang/IllegalArgumentException class");
+            }
             (*env)->ThrowNew(env, newExcCls, "Name not found");
 
             return NULL;
diff --git a/src/share/demo/jvmti/hprof/hprof_event.c b/src/share/demo/jvmti/hprof/hprof_event.c
index 194ef360e5a0a451c443e75be1334fd648667dc1..3047e0f2bb9cbb63138418d5cfea27201bde3178 100644
--- a/src/share/demo/jvmti/hprof/hprof_event.c
+++ b/src/share/demo/jvmti/hprof/hprof_event.c
@@ -197,6 +197,11 @@ event_call(JNIEnv *env, jthread thread, ClassIndex cnum, MethodIndex mnum)
     HPROF_ASSERT(thread!=NULL);
     if (cnum == 0 || cnum == gdata->tracker_cnum) {
         jclass newExcCls = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
+        if ((*env)->ExceptionCheck(env)) {
+            (*env)->ExceptionClear(env);
+            HPROF_ERROR(JNI_TRUE,
+                        "Could not find the java/lang/IllegalArgumentException class");
+        }
         (*env)->ThrowNew(env, newExcCls, "Illegal cnum.");
 
         return;
@@ -258,6 +263,11 @@ event_return(JNIEnv *env, jthread thread, ClassIndex cnum, MethodIndex mnum)
 
     if (cnum == 0 || cnum == gdata->tracker_cnum) {
         jclass newExcCls = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
+        if ((*env)->ExceptionCheck(env)) {
+            (*env)->ExceptionClear(env);
+            HPROF_ERROR(JNI_TRUE,
+                        "Could not find the java/lang/IllegalArgumentException class");
+        }
         (*env)->ThrowNew(env, newExcCls, "Illegal cnum.");
 
         return;
diff --git a/src/share/demo/jvmti/hprof/hprof_util.c b/src/share/demo/jvmti/hprof/hprof_util.c
index 59ce144e8659b283ba2aadfa94b5bb719da91e01..a5e6564b109f1f7ac6bad0241d3e7a2abf78cc53 100644
--- a/src/share/demo/jvmti/hprof/hprof_util.c
+++ b/src/share/demo/jvmti/hprof/hprof_util.c
@@ -374,7 +374,10 @@ newWeakGlobalReference(JNIEnv *env, jobject object)
 
     HPROF_ASSERT(env!=NULL);
     HPROF_ASSERT(object!=NULL);
-    gref = JNI_FUNC_PTR(env,NewWeakGlobalRef)(env, object);
+    CHECK_EXCEPTIONS (env) {
+      gref = JNI_FUNC_PTR(env,NewWeakGlobalRef)(env, object);
+    } END_CHECK_EXCEPTIONS;
+
     HPROF_ASSERT(gref!=NULL);
     return gref;
 }
diff --git a/src/share/native/common/jdk_util.c b/src/share/native/common/jdk_util.c
index 8fe32bfcfaf341bfd629b601ded18490418417cb..1317ce203bd7aaee567c3d1e93bf9e61aa923b45 100644
--- a/src/share/native/common/jdk_util.c
+++ b/src/share/native/common/jdk_util.c
@@ -52,7 +52,8 @@ JDK_GetVersionInfo0(jdk_version_info* info, size_t info_size) {
 
     const char* jdk_update_string = JDK_UPDATE_VERSION;
     unsigned int jdk_update_version = 0;
-    char update_ver[3];
+    int len_update_ver = 0;
+    char update_ver[5];
     char jdk_special_version = '\0';
 
     /* If the JDK_BUILD_NUMBER is of format bXX and XX is an integer
@@ -78,16 +79,17 @@ JDK_GetVersionInfo0(jdk_version_info* info, size_t info_size) {
 
     assert(jdk_build_number >= 0 && jdk_build_number <= 255);
 
-    if (strlen(jdk_update_string) == 2 || strlen(jdk_update_string) == 3) {
-        if (isdigit(jdk_update_string[0]) && isdigit(jdk_update_string[1])) {
-            update_ver[0] = jdk_update_string[0];
-            update_ver[1] = jdk_update_string[1];
-            update_ver[2] = '\0';
-            jdk_update_version = (unsigned int) atoi(update_ver);
-            if (strlen(jdk_update_string) == 3) {
-                jdk_special_version = jdk_update_string[2];
-            }
+    len_update_ver = strlen(jdk_update_string);
+    if (len_update_ver >= 2 && len_update_ver <= 4) {
+        int update_digits = len_update_ver;
+
+        if (!isdigit(jdk_update_string[len_update_ver - 1])) {
+            jdk_special_version = jdk_update_string[len_update_ver -1];
+            update_digits = len_update_ver - 1;
         }
+        strncpy(update_ver, jdk_update_string, update_digits);
+        update_ver[update_digits] = '\0';
+        jdk_update_version = (unsigned int) atoi(update_ver);
     }
 
     memset(info, 0, info_size);
diff --git a/src/share/native/sun/awt/image/jpeg/imageioJPEG.c b/src/share/native/sun/awt/image/jpeg/imageioJPEG.c
index e7330ab92e8016c46058ef519b4925ef8d28cdab..342fe265de4da42e2e755c22f03554195cdc54f0 100644
--- a/src/share/native/sun/awt/image/jpeg/imageioJPEG.c
+++ b/src/share/native/sun/awt/image/jpeg/imageioJPEG.c
@@ -1610,6 +1610,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImageHeader
     int ret;
     int h_samp0, h_samp1, h_samp2;
     int v_samp0, v_samp1, v_samp2;
+    int cid0, cid1, cid2;
     jboolean retval = JNI_FALSE;
     imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr);
     j_decompress_ptr cinfo;
@@ -1711,17 +1712,15 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImageHeader
                 }
             } else if (!cinfo->saw_JFIF_marker && !IS_EXIF(cinfo)) {
                 /*
-                 * IJG assumes all unidentified 3-channels are YCbCr.
-                 * We assume that only if the second two channels are
-                 * subsampled (either horizontally or vertically).  If not,
-                 * we assume RGB.
-                 *
-                 * 4776576: Some digital cameras output YCbCr JPEG images
-                 * that do not contain a JFIF APP0 marker but are only
-                 * vertically subsampled (no horizontal subsampling).
-                 * We should only assume this is RGB data if the subsampling
-                 * factors for the second two channels are the same as the
-                 * first (check both horizontal and vertical factors).
+                 * In the absence of certain markers, IJG has interpreted
+                 * component id's of [1,2,3] as meaning YCbCr.We follow that
+                 * interpretation, which is additionally described in the Image
+                 * I/O JPEG metadata spec.If that condition is not met here the
+                 * next step will be to examine the subsampling factors, if
+                 * there is any difference in subsampling factors we also assume
+                 * YCbCr, only if both horizontal and vertical subsampling
+                 * is same we assume JPEG color space as RGB.
+                 * This is also described in the Image I/O JPEG metadata spec.
                  */
                 h_samp0 = cinfo->comp_info[0].h_samp_factor;
                 h_samp1 = cinfo->comp_info[1].h_samp_factor;
@@ -1731,8 +1730,13 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImageHeader
                 v_samp1 = cinfo->comp_info[1].v_samp_factor;
                 v_samp2 = cinfo->comp_info[2].v_samp_factor;
 
-                if ((h_samp1 == h_samp0) && (h_samp2 == h_samp0) &&
-                    (v_samp1 == v_samp0) && (v_samp2 == v_samp0))
+                cid0 = cinfo->comp_info[0].component_id;
+                cid1 = cinfo->comp_info[1].component_id;
+                cid2 = cinfo->comp_info[2].component_id;
+
+                if ((!(cid0 == 1 && cid1 == 2 && cid2 == 3)) &&
+                    ((h_samp1 == h_samp0) && (h_samp2 == h_samp0) &&
+                    (v_samp1 == v_samp0) && (v_samp2 == v_samp0)))
                 {
                     cinfo->jpeg_color_space = JCS_RGB;
                     /* output is already RGB, so it stays the same */
diff --git a/src/share/native/sun/misc/URLClassPath.c b/src/share/native/sun/misc/URLClassPath.c
index 16380c9d1255ce8e906048bcf11fdf0101852070..e0ad4f81381e8dc34f866f7ec877019172f13a10 100644
--- a/src/share/native/sun/misc/URLClassPath.c
+++ b/src/share/native/sun/misc/URLClassPath.c
@@ -52,7 +52,7 @@ Java_sun_misc_URLClassPath_knownToNotExist0(JNIEnv *env, jclass cls, jobject loa
 
     clname = getUTF(env, classname, buf, sizeof(buf));
     if (clname == NULL) {
-        JNU_ThrowOutOfMemoryError(env, NULL);
+        // getUTF() throws OOME before returning NULL, no need to throw OOME here
         return result;
     }
     VerifyFixClassname(clname);
@@ -94,7 +94,7 @@ Java_sun_misc_URLClassPath_getLookupCacheForClassLoader(JNIEnv *env, jclass cls,
 
     resname = getUTF(env, resource_name, buf, sizeof(buf));
     if (resname == NULL) {
-        JNU_ThrowOutOfMemoryError(env, NULL);
+        // getUTF() throws OOME before returning NULL, no need to throw OOME here
         return result;
     }
     result = JVM_GetResourceLookupCache(env, loader, resname);
diff --git a/src/windows/classes/sun/security/mscapi/KeyStore.java b/src/windows/classes/sun/security/mscapi/KeyStore.java
index 69298f5fc606a16443c7ee8ad1b2a7040a7d9901..abaa2e30042e35457d30ce8ecd56987bbb897f68 100644
--- a/src/windows/classes/sun/security/mscapi/KeyStore.java
+++ b/src/windows/classes/sun/security/mscapi/KeyStore.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -312,7 +312,7 @@ abstract class KeyStore extends KeyStoreSpi {
             if (alias.equals(entry.getAlias()))
             {
                 X509Certificate[] certChain = entry.getCertificateChain();
-                return certChain[0];
+                return certChain.length == 0 ? null : certChain[0];
             }
         }
 
@@ -842,7 +842,7 @@ abstract class KeyStore extends KeyStoreSpi {
 
             // Obtain certificate factory
             if (certificateFactory == null) {
-                certificateFactory = CertificateFactory.getInstance("X.509");
+                certificateFactory = CertificateFactory.getInstance("X.509", "SUN");
             }
 
             // Generate certificate
diff --git a/src/windows/native/sun/java2d/d3d/D3DBlitLoops.cpp b/src/windows/native/sun/java2d/d3d/D3DBlitLoops.cpp
index ac1acd491dd9736d1aaafe9e1922317e4ac170ba..0b670639783b5320195afab225991ae34b01c3a9 100644
--- a/src/windows/native/sun/java2d/d3d/D3DBlitLoops.cpp
+++ b/src/windows/native/sun/java2d/d3d/D3DBlitLoops.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2008, 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
@@ -508,8 +508,10 @@ D3DBlitTextureToSurface(D3DContext *d3dc,
     RETURN_STATUS_IF_NULL(srcOps->pResource, E_FAIL);
     RETURN_STATUS_IF_NULL(dstOps->pResource, E_FAIL);
 
-    if ((pSrc = srcOps->pResource->GetTexture()) == NULL ||
-        FAILED(res = d3dc->BeginScene(STATE_TEXTUREOP)   ||
+    pSrc = srcOps->pResource->GetTexture();
+    RETURN_STATUS_IF_NULL(pSrc, E_FAIL);
+
+    if (FAILED(res = d3dc->BeginScene(STATE_TEXTUREOP)   ||
         FAILED(res = d3dc->SetTexture(pSrc))))
     {
         J2dRlsTraceLn(J2D_TRACE_ERROR,
diff --git a/src/windows/native/sun/java2d/d3d/D3DTextRenderer.cpp b/src/windows/native/sun/java2d/d3d/D3DTextRenderer.cpp
index 7bd843b93e674628c70536d4bbadcbefbc3ea297..4dde51b98e45eb7f1e38239074ef24e948689e8e 100644
--- a/src/windows/native/sun/java2d/d3d/D3DTextRenderer.cpp
+++ b/src/windows/native/sun/java2d/d3d/D3DTextRenderer.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2013, 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
@@ -355,7 +355,7 @@ D3DTR_UpdateCachedDestination(D3DContext *d3dc, D3DSDOps *dstOps,
     jint dx1, dy1, dx2, dy2;
     D3DResource *pCachedDestTexRes;
     IDirect3DSurface9 *pCachedDestSurface, *pDst;
-    HRESULT res;
+    HRESULT res = S_OK;
 
     if (isCachedDestValid && INSIDE(gx1, gy1, gx2, gy2, cachedDestBounds)) {
         // glyph is already within the cached destination bounds; no need
diff --git a/src/windows/native/sun/windows/ShellFolder2.cpp b/src/windows/native/sun/windows/ShellFolder2.cpp
index cdc60d9ee9ca70797a557f0b9f73385d7b33822e..4f563039750eec0650212a41cc12973c383e8fcf 100644
--- a/src/windows/native/sun/windows/ShellFolder2.cpp
+++ b/src/windows/native/sun/windows/ShellFolder2.cpp
@@ -673,6 +673,9 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_getLinkLocation
       case STRRET_WSTR :
         wstr = strret.pOleStr;
         break;
+
+      default:
+        return NULL;
     }
 
     IShellLinkW* psl;
diff --git a/src/windows/native/sun/windows/awt_Component.cpp b/src/windows/native/sun/windows/awt_Component.cpp
index f51c22e41c9bfffb899f018f6835b9485c1afe93..0128972cb8826a347360d9f0900be81b8ce13828 100644
--- a/src/windows/native/sun/windows/awt_Component.cpp
+++ b/src/windows/native/sun/windows/awt_Component.cpp
@@ -5200,6 +5200,8 @@ void AwtComponent::SynthesizeMouseMessage(JNIEnv *env, jobject mouseEvent)
                 message = WM_MBUTTONDOWN; break;
             case java_awt_event_MouseEvent_BUTTON2:
                 message = WM_RBUTTONDOWN; break;
+            default:
+                return;
           }
           break;
       }
@@ -5211,6 +5213,8 @@ void AwtComponent::SynthesizeMouseMessage(JNIEnv *env, jobject mouseEvent)
                 message = WM_MBUTTONUP; break;
             case java_awt_event_MouseEvent_BUTTON2:
                 message = WM_RBUTTONUP; break;
+            default:
+                return;
           }
           break;
       }
diff --git a/src/windows/native/sun/windows/awt_DesktopProperties.cpp b/src/windows/native/sun/windows/awt_DesktopProperties.cpp
index 21a4b0074ce2c41c1a55b97327f5ec10d9ef8d7b..454a2fe74e47f0db554d9af94b55a3c1819152b0 100644
--- a/src/windows/native/sun/windows/awt_DesktopProperties.cpp
+++ b/src/windows/native/sun/windows/awt_DesktopProperties.cpp
@@ -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
@@ -388,7 +388,7 @@ void CheckFontSmoothingSettings(HWND hWnd) {
     }
 
     BOOL fontSmoothing = FALSE, settingsChanged;
-    UINT fontSmoothingType=0, fontSmoothingContrast=0, subPixelOrder;
+    UINT fontSmoothingType=0, fontSmoothingContrast=0, subPixelOrder=0;
 
     if (firstTime) {
         SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, &fontSmoothing, 0);
diff --git a/src/windows/native/sun/windows/awt_Font.cpp b/src/windows/native/sun/windows/awt_Font.cpp
index dfa4b70a7dc767ed673114c5335c63165a925fd4..a3d59656297d920d18f3d2e5784ac4c3fb2de206 100644
--- a/src/windows/native/sun/windows/awt_Font.cpp
+++ b/src/windows/native/sun/windows/awt_Font.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -270,7 +270,7 @@ AwtFont* AwtFont::Create(JNIEnv *env, jobject font, jint angle, jfloat awScale)
             cfnum = 0;
         }
 
-        LPCWSTR wName;
+        LPCWSTR wName = NULL;
 
         awtFont = new AwtFont(cfnum, env, font);
 
@@ -1168,7 +1168,7 @@ void AwtFontCache::IncRefCount(HFONT hFont){
 }
 
 LONG AwtFontCache::IncRefCount(Item* item){
-    LONG    newVal;
+    LONG    newVal = 0;
 
     if(NULL != item){
         newVal = InterlockedIncrement((long*)&item->refCount);
@@ -1177,7 +1177,7 @@ LONG AwtFontCache::IncRefCount(Item* item){
 }
 
 LONG AwtFontCache::DecRefCount(Item* item){
-    LONG    newVal;
+    LONG    newVal = 0;
 
     if(NULL != item){
         newVal = InterlockedDecrement((long*)&item->refCount);
diff --git a/src/windows/native/sun/windows/awt_Frame.cpp b/src/windows/native/sun/windows/awt_Frame.cpp
index 53f6a50149ee68539b196893242dbab3e1e82ca2..6ff8a950e42887c3ad6619f2e86c9a646ce7a17f 100644
--- a/src/windows/native/sun/windows/awt_Frame.cpp
+++ b/src/windows/native/sun/windows/awt_Frame.cpp
@@ -156,7 +156,7 @@ AwtFrame* AwtFrame::Create(jobject self, jobject parent)
 
     PDATA pData;
     HWND hwndParent = NULL;
-    AwtFrame* frame;
+    AwtFrame* frame = NULL;
     jclass cls = NULL;
     jclass inputMethodWindowCls = NULL;
     jobject target = NULL;
@@ -993,7 +993,9 @@ MsgRouting AwtFrame::WmActivate(UINT nState, BOOL fMinimized, HWND opposite)
         AwtComponent::SetFocusedWindow(GetHWnd());
 
     } else {
-        if (!::IsWindow(AwtWindow::GetModalBlocker(opposite))) {
+        if (::IsWindow(AwtWindow::GetModalBlocker(opposite))) {
+            return mrConsume;
+        } else {
             // If deactivation happens because of press on grabbing
             // window - this is nonsense, since grabbing window is
             // assumed to have focus and watch for deactivation.  But
diff --git a/src/windows/native/sun/windows/awt_Label.cpp b/src/windows/native/sun/windows/awt_Label.cpp
index d755d5fc68da119bc84dc4eaff8813874b307f41..722151cd86461f49b3fdf9e4187f4b5118224b11 100644
--- a/src/windows/native/sun/windows/awt_Label.cpp
+++ b/src/windows/native/sun/windows/awt_Label.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2014, 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
@@ -146,15 +146,16 @@ void AwtLabel::DoPaint(HDC hDC, RECT& r)
 
         jint alignment = env->GetIntField(target, AwtLabel::alignmentID);
         switch (alignment) {
-           case java_awt_Label_LEFT:
-              x = r.left + 2;
-              break;
           case java_awt_Label_CENTER:
               x = (r.left + r.right - size.cx) / 2;
               break;
           case java_awt_Label_RIGHT:
               x = r.right - 2 - size.cx;
               break;
+          case java_awt_Label_LEFT:
+          default:
+              x = r.left + 2;
+              break;
         }
         /* draw string */
         if (isEnabled()) {
diff --git a/src/windows/native/sun/windows/awt_PrintJob.cpp b/src/windows/native/sun/windows/awt_PrintJob.cpp
index 7217f53ed7e8b7a0ab80c4b0ee7bf127a3f90eeb..6899b8dfcbe1fc5ff7aee92a8f70c5f14a10749f 100644
--- a/src/windows/native/sun/windows/awt_PrintJob.cpp
+++ b/src/windows/native/sun/windows/awt_PrintJob.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2014, 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
@@ -1108,7 +1108,7 @@ Java_sun_awt_windows_WPrinterJob_initPrinter(JNIEnv *env, jobject self) {
     // check for collation
     HGLOBAL hDevNames = AwtPrintControl::getPrintHDName(env, self);
     if (hDevNames != NULL) {
-        DWORD dmFields;
+        DWORD dmFields = 0;
         DEVNAMES *devnames = (DEVNAMES *)::GlobalLock(hDevNames);
 
         if (devnames != NULL) {
diff --git a/src/windows/native/sun/windows/awt_TextComponent.cpp b/src/windows/native/sun/windows/awt_TextComponent.cpp
index eaa8bca03d4ecc552634ae74b1cbcb504c333cb5..de60f0ed70294772505438c15507847077c96700 100644
--- a/src/windows/native/sun/windows/awt_TextComponent.cpp
+++ b/src/windows/native/sun/windows/awt_TextComponent.cpp
@@ -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
@@ -129,6 +129,7 @@ AwtTextComponent* AwtTextComponent::Create(jobject peer, jobject parent, BOOL is
                          scroll_style = WS_HSCROLL | ES_AUTOHSCROLL | ES_AUTOVSCROLL;
                          break;
                      case java_awt_TextArea_SCROLLBARS_BOTH:
+                     default:
                          scroll_style = WS_VSCROLL | WS_HSCROLL |
                              ES_AUTOVSCROLL | ES_AUTOHSCROLL;
                          break;
diff --git a/test/TEST.groups b/test/TEST.groups
index d857a4db25914b3629cec5a7ae549fed2d3a0277..a17b16ae78c590c8426c7b3e54f526e276e81dd9 100644
--- a/test/TEST.groups
+++ b/test/TEST.groups
@@ -287,7 +287,7 @@ jdk_desktop = \
 # - compact1, compact2, compact3, full JRE, JDK
 #
 # In addition they support testing of the minimal VM on compact1 and compact2.
-# Essentially this defines groups based around the specified API's and VM 
+# Essentially this defines groups based around the specified API's and VM
 # services available in the runtime.
 #
 # The groups are defined hierarchically in two forms:
@@ -342,13 +342,17 @@ needs_jdk = \
   sun/management/jmxremote/bootstrap/JvmstatCountersTest.java \
   sun/management/jmxremote/bootstrap/LocalManagementTest.java \
   sun/management/jmxremote/bootstrap/CustomLauncherTest.java \
+  sun/management/jmxremote/startstop \
   sun/misc/JarIndex/metaInfFilenames/Basic.java \
   sun/misc/JarIndex/JarIndexMergeForClassLoaderTest.java \
   sun/reflect/CallerSensitive/CallerSensitiveFinder.java \
   sun/reflect/CallerSensitive/MissingCallerSensitive.java \
   sun/security/util/Resources/NewNamesFormat.java \
   vm/verifier/defaultMethods/DefaultMethodRegressionTestsRun.java \
-  javax/xml/ws/clientjar/TestWsImport.java 
+  javax/xml/bind/jxc \
+  javax/xml/ws/8033113 \
+  javax/xml/ws/clientjar/TestWsImport.java \
+  javax/xml/ws/ebcdic
 
 # JRE adds further tests to compact3
 #
@@ -389,8 +393,10 @@ needs_jre = \
   javax/management/mxbean/LeakTest.java \
   javax/management/mxbean/MXBeanTest.java \
   javax/management/mxbean/PropertyNamesTest.java \
+  javax/xml/ws/8043129 \
   jdk/lambda/vm/InterfaceAccessFlagsTest.java \
-  sun/misc/URLClassPath/ClassnameCharTest.java
+  sun/misc/URLClassPath/ClassnameCharTest.java \
+  sun/security/pkcs11/Provider/Login.sh
 
 # Tests dependent on the optional charsets.jar
 # These are isolated for easy exclusions
@@ -517,7 +523,7 @@ compact2 = \
  -:needs_jdk
 
 # Tests that require compact2 API's and a full VM
-#  
+#
 needs_full_vm_compact2 =
 
 # Minimal VM on Compact 2 adds in some compact2 tests
@@ -538,7 +544,9 @@ needs_compact2 = \
   com/sun/net/httpserver \
   java/sql \
   javax/sql \
-  javax/xml \
+  javax/xml/bind \
+  javax/xml/jaxp \
+  javax/xml/ws/xsanymixed \
   jdk/lambda \
   sun/net/www/http \
   sun/net/www/protocol/http \
@@ -601,7 +609,7 @@ needs_compact2 = \
   java/util/zip/ZipFile/DeleteTempJar.java \
   javax/crypto/Cipher/CipherStreamClose.java \
   sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/HttpsCreateSockTest.java \
-  sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/HttpsSocketFacTest.java 
+  sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/HttpsSocketFacTest.java
 
 # Compact 1 adds full VM tests
 #
diff --git a/test/com/sun/jdi/CatchPatternTest.sh b/test/com/sun/jdi/CatchPatternTest.sh
index c2e18fb050059ec53283b35585ce0e1aaab1fe9a..68e7799b82fc5523049fa504ab6d86157f55a451 100644
--- a/test/com/sun/jdi/CatchPatternTest.sh
+++ b/test/com/sun/jdi/CatchPatternTest.sh
@@ -35,44 +35,44 @@ createJavaFile()
     cat < $classname.java.1
 public class $classname {
     public void bark(int i) {
-	System.out.println(" bark: " + i);
-	switch (i) {
-	case 0:
-	    throw new IllegalArgumentException("IllegalArgumentException");
-	case 1:
-	    throw new ArithmeticException("ArithmeticException");
-	case 2:
-	    throw new IllegalMonitorStateException("IllegalMonitorStateException");
-	case 3:
-	    throw new IndexOutOfBoundsException("IndexOutOfBoundsException");
-	default:
-	    throw new Error("should not happen");
-	}
+        System.out.println(" bark: " + i);
+        switch (i) {
+        case 0:
+            throw new IllegalArgumentException("IllegalArgumentException");
+        case 1:
+            throw new ArithmeticException("ArithmeticException");
+        case 2:
+            throw new IllegalMonitorStateException("IllegalMonitorStateException");
+        case 3:
+            throw new IndexOutOfBoundsException("IndexOutOfBoundsException");
+        default:
+            throw new Error("should not happen");
+        }
     }
     public void loop(int max) {
-	for (int i = 0; i <= max; i++) {
-	    try {
-		bark(i);
-	    } catch(RuntimeException re) {
-		System.out.println(" loop: " + re.getMessage() +
-				   " caught and ignored.");
-	    }
-	}
+        for (int i = 0; i <= max; i++) {
+            try {
+                bark(i);
+            } catch(RuntimeException re) {
+                System.out.println(" loop: " + re.getMessage() +
+                       " caught and ignored.");
+            }
+        }
     }
     public void partOne() {
         loop(2);
-	System.out.println("partOne completed");
+        System.out.println("partOne completed");
     }
     public void partTwo() {
         loop(3);
-	System.out.println("partTwo completed");
+        System.out.println("partTwo completed");
     }
     public static void main(String[] args) {
-	System.out.println("Howdy!");
+        System.out.println("Howdy!");
         $classname my = new $classname();
-	my.partOne();
-	my.partTwo();
-	System.out.println("Goodbye from $classname!");
+        my.partOne();
+        my.partTwo();
+        System.out.println("Goodbye from $classname!");
     }
 }
 EOF
diff --git a/test/com/sun/jdi/GetLocalVariables4Test.sh b/test/com/sun/jdi/GetLocalVariables4Test.sh
index 45ae52f691e195701af99006014b72730a528c5b..0eeb421fc7dcea0d1b1cab99f176e341668b2305 100644
--- a/test/com/sun/jdi/GetLocalVariables4Test.sh
+++ b/test/com/sun/jdi/GetLocalVariables4Test.sh
@@ -39,12 +39,12 @@ createJavaFile()
 public class GetLocalVariables4Targ {
     public static void main(String[] args) {
         System.out.println("Howdy!");
-	int i = 0;
-	try {
-	    i = 16 / i;
-	} catch(Exception e) {
-	    System.out.println("e should be visible");    // @1 breakpoint
-	}
+        int i = 0;
+        try {
+            i = 16 / i;
+        } catch(Exception e) {
+            System.out.println("e should be visible");    // @1 breakpoint
+        }
         System.out.println("Goodbye from GetLocalVariables4Targ!");
     }
 }
diff --git a/test/com/sun/jdi/JdbReadTwiceTest.sh b/test/com/sun/jdi/JdbReadTwiceTest.sh
index 58be020422b11f244f89357197135f20982bae51..a166f2c54f13547c9645bb8b36978c7137e4b90c 100644
--- a/test/com/sun/jdi/JdbReadTwiceTest.sh
+++ b/test/com/sun/jdi/JdbReadTwiceTest.sh
@@ -204,22 +204,6 @@ if [ ! -r c:/ ] ; then
     clean
 fi
 
-
-if [ ! -r c:/ ] ; then
-    # Can't make a file unreadable under MKS.
-    echo
-    echo "+++++++++++++++++++++++++++++++++++"
-    echo "Read an unreadable file - verify the read fails."
-    # If the file exists, we try to read it.  The
-    # read will fail.
-    mkFiles $HOME/jdb.ini
-        chmod a-r $HOME/jdb.ini
-        doit
-        failIfNot 1 "open: $HOME/jdb.ini"
-        clean
-fi
-
-
 echo
 echo "+++++++++++++++++++++++++++++++++++"
 echo "Read a directory - verify the read fails"
@@ -239,8 +223,8 @@ echo "read $fred" > $here/jdb.ini
     doit
     failIfNot 1 "from $fred"
 
-    if [ ! -r c:/ ] ; then
-        # Can't make a file unreadable under MKS
+    if [ "$canMakeUnreadable" = "Yes" ]
+    then
         chmod a-r $fred
         doit
         failIfNot 1 "open: $fred"
diff --git a/test/com/sun/jdi/NullLocalVariable.sh b/test/com/sun/jdi/NullLocalVariable.sh
index 63bca9545c44c3a5ad71c5794302520adf399944..39ac84fbd0c25c0dee8d4d8fc13931143934fc21 100644
--- a/test/com/sun/jdi/NullLocalVariable.sh
+++ b/test/com/sun/jdi/NullLocalVariable.sh
@@ -40,10 +40,10 @@ public class badscope {
     public static final void main(String args[]) {
         try {
             System.out.println("hi!");               // @1 breakpoint
-        } catch (Exception e) {         
+        } catch (Exception e) {
             e.printStackTrace();
         } finally {
-            System.out.println("done"); 
+            System.out.println("done");
         }
     }
 }
@@ -54,11 +54,11 @@ EOF
 dojdbCmds()
 {
    #set -x
-   cmd stop at badscope:4	; $sleepcmd
-   runToBkpt			; $sleepcmd
-   cmd next			; $sleepcmd
-   cmd next			; $sleepcmd
-   cmd locals			; $sleepcmd
+   cmd stop at badscope:4   ; $sleepcmd
+   runToBkpt                ; $sleepcmd
+   cmd next                 ; $sleepcmd
+   cmd next                 ; $sleepcmd
+   cmd locals               ; $sleepcmd
    cmd cont
 }
 
@@ -71,7 +71,7 @@ mysetup()
 
     for ii in . $TESTSRC $TESTSRC/.. ; do
         if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh 
+            . $ii/ShellScaffold.sh
             break
         fi
     done
diff --git a/test/com/sun/jdi/PrivateTransportTest.sh b/test/com/sun/jdi/PrivateTransportTest.sh
index ee8051f46ee9e0dd823338bcd1c1384d5c31c73f..7f4b0029f2679c89c72661fc88a3d7d6c12b4ccc 100644
--- a/test/com/sun/jdi/PrivateTransportTest.sh
+++ b/test/com/sun/jdi/PrivateTransportTest.sh
@@ -67,9 +67,9 @@ if [ -z "${TESTJAVA}" ] ; then
    # is given on the command line, tell the user that and use a default.
    # THIS IS THE JDK BEING TESTED.
    if [ -n "$1" ] ; then
-          TESTJAVA=$1
+         TESTJAVA=$1
       else
-	  TESTJAVA=$JAVA_HOME
+         TESTJAVA=$JAVA_HOME
    fi
    TESTSRC=.
    TESTCLASSES=.
diff --git a/test/com/sun/jdi/RedefineFinal.sh b/test/com/sun/jdi/RedefineFinal.sh
index 80ec5254e4a2c4617fd127a481b2882e76c3287d..eb63de3b3c1d5369c0bbf990730f7de854847e53 100644
--- a/test/com/sun/jdi/RedefineFinal.sh
+++ b/test/com/sun/jdi/RedefineFinal.sh
@@ -42,15 +42,15 @@ createJavaFile()
 public final class $1 {
 
     public int m1(int i) {
-	// @1 uncomment System.out.println("I'm here");
-	return m2(i, 1000);
+        // @1 uncomment System.out.println("I'm here");
+        return m2(i, 1000);
     }
 
     public int m2(int i, int j) {
-	if (i < 0 || j < 0) {	// @1 breakpoint
+        if (i < 0 || j < 0) {   // @1 breakpoint
             throw new IllegalArgumentException();
-	}
-	return i+j;
+        }
+        return i+j;
     }
 
     $1() {
@@ -59,7 +59,7 @@ public final class $1 {
     }
 
     public static void main(String args[]) {
-	new $1();
+        new $1();
     }
 }
 EOF
diff --git a/test/com/sun/jdi/RedefineIntConstantToLong.sh b/test/com/sun/jdi/RedefineIntConstantToLong.sh
index ab921c0cd482d2cd691dfac1238bd3d1ca37fa22..990b69e9c88b6ae496479037e9f023920664ae8b 100644
--- a/test/com/sun/jdi/RedefineIntConstantToLong.sh
+++ b/test/com/sun/jdi/RedefineIntConstantToLong.sh
@@ -44,18 +44,18 @@ public final class $1 {
     public long m1(int i) {
         long r=0;
         r = m2(i * 2); // @1 commentout
-	// @1 uncomment      r =m2(i * 2L);
+        // @1 uncomment      r =m2(i * 2L);
         return r;
     }
 
     public long m2(int j) {
-	System.out.println(System.getProperty("line.separator") + 
+        System.out.println(System.getProperty("line.separator") + 
                            "**** public long m2(int j) with value: " + j);
         return j;
     }
 
     public long m2(long j) {
-	System.out.println(System.getProperty("line.separator") + 
+        System.out.println(System.getProperty("line.separator") + 
                            "**** public long m2(long j) with value: " + j);
         return j;
     }
@@ -66,7 +66,7 @@ public final class $1 {
         r1 = m1(1000);
         r2 = 0;         // @1 breakpoint
         r2 = m1(1000);
-        if (r1 != r2) {	// @1 breakpoint
+        if (r1 != r2) { // @1 breakpoint
              throw new Exception("FAILURE: Expected value: " + r1 + " Actual value: " + r2);
         } else {
              System.out.println("SUCCESS: Expected value: " + r1 + " Actual value: " + r2);
@@ -74,7 +74,7 @@ public final class $1 {
     }
 
     public static void main(String args[]) throws Exception {
-	new $1().doit();
+        new $1().doit();
     }
 }
 EOF
diff --git a/test/com/sun/jdi/StringConvertTest.sh b/test/com/sun/jdi/StringConvertTest.sh
index c86ab3dab46fbc50bc8dfe3e713df90fdd094ff7..1d863a28f872314b775c54f6066fb06602c32420 100644
--- a/test/com/sun/jdi/StringConvertTest.sh
+++ b/test/com/sun/jdi/StringConvertTest.sh
@@ -23,7 +23,7 @@
 # questions.
 #
 
-#  @test @(#)StringConvertTest.sh	1.6 03/04/09
+#  @test
 #  @bug 4511950 4843082
 #  @summary 1. jdb's expression evaluation doesn't perform string conversion properly
 #           2. TTY: run on expression evaluation
diff --git a/test/com/sun/jdi/SuspendNoFlagTest.sh b/test/com/sun/jdi/SuspendNoFlagTest.sh
index 7608cb574c941584e3be0278115e95439b0098be..dd4a24e4d76f3d774aaae39307633bf2e0e49200 100644
--- a/test/com/sun/jdi/SuspendNoFlagTest.sh
+++ b/test/com/sun/jdi/SuspendNoFlagTest.sh
@@ -68,9 +68,9 @@ if [ -z "${TESTJAVA}" ] ; then
    # is given on the command line, tell the user that and use a default.
    # THIS IS THE JDK BEING TESTED.
    if [ -n "$1" ] ; then
-          TESTJAVA=$1
+         TESTJAVA=$1
       else
-	  TESTJAVA=$JAVA_HOME
+         TESTJAVA=$JAVA_HOME
    fi
    TESTSRC=.
    TESTCLASSES=.
diff --git a/test/java/awt/Component/TreeLockDeadlock/TreeLockDeadlock.java b/test/java/awt/Component/TreeLockDeadlock/TreeLockDeadlock.java
new file mode 100644
index 0000000000000000000000000000000000000000..91e651cebb90b917b28f7d2055705da4f3734234
--- /dev/null
+++ b/test/java/awt/Component/TreeLockDeadlock/TreeLockDeadlock.java
@@ -0,0 +1,88 @@
+/*
+ * 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.awt.Frame;
+import java.awt.GraphicsConfiguration;
+import java.awt.Window;
+
+import static java.util.concurrent.TimeUnit.MINUTES;
+import static java.util.concurrent.TimeUnit.NANOSECONDS;
+
+/**
+ * @test
+ * @bug 8138764
+ */
+public final class TreeLockDeadlock extends Frame {
+
+    @Override
+    public synchronized GraphicsConfiguration getGraphicsConfiguration() {
+        return super.getGraphicsConfiguration();
+    }
+
+    @Override
+    public synchronized void reshape(int x, int y, int width, int height) {
+        super.reshape(x, y, width, height);
+    }
+
+    @Override
+    public synchronized float getOpacity() {
+        return super.getOpacity();
+    }
+
+    public static void main(final String[] args) throws Exception {
+        final Window window = new TreeLockDeadlock();
+        window.setSize(300, 300);
+        test(window);
+    }
+
+    private static void test(final Window window) throws Exception {
+        final long start = System.nanoTime();
+        final long end = start + NANOSECONDS.convert(1, MINUTES);
+
+        final Runnable r1 = () -> {
+            while (System.nanoTime() < end) {
+                window.setBounds(window.getBounds());
+            }
+        };
+        final Runnable r2 = () -> {
+            while (System.nanoTime() < end) {
+                window.getGraphicsConfiguration();
+                window.getOpacity();
+            }
+        };
+
+        final Thread t1 = new Thread(r1);
+        final Thread t2 = new Thread(r1);
+        final Thread t3 = new Thread(r2);
+        final Thread t4 = new Thread(r2);
+
+        t1.start();
+        t2.start();
+        t3.start();
+        t4.start();
+        t1.join();
+        t2.join();
+        t3.join();
+        t4.join();
+    }
+}
diff --git a/test/java/awt/im/8132503/bug8132503.html b/test/java/awt/im/8132503/bug8132503.html
new file mode 100644
index 0000000000000000000000000000000000000000..ca8c8626461bebe659f69b9118fda84699cf3067
--- /dev/null
+++ b/test/java/awt/im/8132503/bug8132503.html
@@ -0,0 +1,38 @@
+
+
+
+
+Verify that Chinese full stop symbol can be entered in JTextArea with Pinyin input method (IM).
+
+This test is for OS X only. For other platforms please simply press "Pass".
+
+1. Go to "System Preferences -> Keyboard -> Input Sources" and add "Pinyin – Traditional" or "Pinyin – Simplified" IM from Chinese language group.
+2. Set current IM to "Pinyin".
+3. Set focus to the text area of the test and press "dot" character on the keyboard.
+4. Set current IM to the IM used before "Pinyin" was set.
+5. If "。" character is displayed in the text area, press "Pass", if "." character is displayed, press "Fail".
+
+
+
+
diff --git a/test/java/awt/im/8132503/bug8132503.java b/test/java/awt/im/8132503/bug8132503.java
new file mode 100644
index 0000000000000000000000000000000000000000..622a3bae3a207b8c6a9e379728ac2179a8eee94d
--- /dev/null
+++ b/test/java/awt/im/8132503/bug8132503.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.
+ */
+
+/* @test
+   @bug 8132503
+   @summary [macosx] Chinese full stop symbol cannot be entered with Pinyin IM on OS X
+   @author Anton Litvinov
+   @run applet/manual=yesno bug8132503.html
+ */
+
+import javax.swing.JApplet;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.SwingUtilities;
+
+public class bug8132503 extends JApplet {
+    @Override
+    public void init() {
+        SwingUtilities.invokeLater(new Runnable() {
+            @Override
+            public void run() {
+                JTextArea textArea = new JTextArea("Text area of the test.", 40, 40);
+                add(new JScrollPane(textArea));
+            }
+        });
+    }
+}
diff --git a/test/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java b/test/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java
index 9fbe6d1c017db1124f1fbaf89c4b6946a011f252..ff64add432b3758c4054ef51d22cac1b8db8b30f 100644
--- a/test/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java
+++ b/test/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java
@@ -30,6 +30,7 @@ import static java.time.temporal.ChronoField.DAY_OF_YEAR;
 import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
 import static java.time.temporal.ChronoField.YEAR;
 import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertTrue;
 import static org.testng.Assert.fail;
 
@@ -71,6 +72,7 @@ import org.testng.annotations.Test;
 /**
  * Tests for the Umm alQura chronology and data.
  * Note: The dates used for testing are just a sample of calendar data.
+ * @bug 8067800
  */
 @Test
 public class TestUmmAlQuraChronology {
@@ -530,6 +532,24 @@ public class TestUmmAlQuraChronology {
         assertEquals(date.isLeapYear(), leapyear);
     }
 
+    // Data provider to verify that a given hijrah year is outside the range of supported years
+    // The values are dependent on the currently configured UmmAlQura calendar data
+    @DataProvider(name="OutOfRangeLeapYears")
+    Object[][] data_invalid_leapyears() {
+        return new Object[][] {
+                {1299},
+                {1601},
+                {Integer.MAX_VALUE},
+                {Integer.MIN_VALUE},
+        };
+    }
+
+    @Test(dataProvider="OutOfRangeLeapYears")
+    public void test_notLeapYears(int y) {
+        assertFalse(HijrahChronology.INSTANCE.isLeapYear(y), "Out of range leap year");
+    }
+
+
     // Date samples to convert HijrahDate to LocalDate and vice versa
     @DataProvider(name="samples")
     Object[][] data_samples() {
diff --git a/test/javax/imageio/plugins/jpeg/JpegImageColorSpaceTest.java b/test/javax/imageio/plugins/jpeg/JpegImageColorSpaceTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..3229395b9c6402fd9c9c35e85f10a4b4dbf1c355
--- /dev/null
+++ b/test/javax/imageio/plugins/jpeg/JpegImageColorSpaceTest.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     8041501
+ * @summary Test verifies if there is no JFIF & EXIF header
+ *          and sampling factor is same of JPEG image, then
+ *          imageIO should not override colorspace determined
+ *          in IJG library.
+ * @run     main JpegImageColorSpaceTest
+ */
+
+import java.awt.Color;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import javax.imageio.ImageIO;
+
+public class JpegImageColorSpaceTest {
+
+    public static void main(String args[]) throws Exception {
+
+        String fileName = "nomarkers.jpg";
+        String sep = System.getProperty("file.separator");
+        String dir = System.getProperty("test.src", ".");
+        String filePath = dir+sep+fileName;
+        System.out.println("Test file: " + filePath);
+        File imageFile = new File(filePath);
+
+        BufferedImage bufferedImage = ImageIO.read(imageFile);
+        int imageWidth = bufferedImage.getWidth();
+        int imageHeight = bufferedImage.getHeight();
+
+        for (int i = 0; i < imageWidth; i++) {
+            for(int j = 0; j < imageHeight; j++) {
+                /*
+                * Since image is white we check individual pixel values from
+                * BufferedImage to verify if ImageIO.read() is done with proper
+                * color space or not.
+                */
+                if (bufferedImage.getRGB(i, j) != Color.white.getRGB()) {
+                    // color space is not proper
+                    throw new RuntimeException("ColorSpace is not determined "
+                            + "properly by ImageIO");
+               }
+            }
+        }
+    }
+}
diff --git a/test/javax/imageio/plugins/jpeg/nomarkers.jpg b/test/javax/imageio/plugins/jpeg/nomarkers.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..3b08cdd3b02b159411cd54e30c2683be6d8ca6b0
Binary files /dev/null and b/test/javax/imageio/plugins/jpeg/nomarkers.jpg differ
diff --git a/test/javax/management/remote/mandatory/connection/Name.java b/test/javax/management/remote/mandatory/connection/Name.java
new file mode 100644
index 0000000000000000000000000000000000000000..16b8ba0124a310602ea5820345796df872caae14
--- /dev/null
+++ b/test/javax/management/remote/mandatory/connection/Name.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+public class Name implements NameMBean {
+
+    private String firstName;
+    private String lastName;
+
+    @Override
+    public String getFirstName() {
+        return firstName;
+    }
+
+    @Override
+    public void setFirstName(String firstName) {
+        this.firstName = firstName;
+    }
+
+    @Override
+    public String getLastName() {
+        return lastName;
+    }
+
+    @Override
+    public void setLastName(String lastName) {
+        this.lastName = lastName;
+    }
+
+}
diff --git a/test/javax/management/remote/mandatory/connection/NameMBean.java b/test/javax/management/remote/mandatory/connection/NameMBean.java
new file mode 100644
index 0000000000000000000000000000000000000000..0ad8d9533c230051f98f83826de5e515af69d54d
--- /dev/null
+++ b/test/javax/management/remote/mandatory/connection/NameMBean.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+public interface NameMBean {
+
+    String getFirstName();
+    void setFirstName(String firstName);
+
+    String getLastName();
+    void setLastName(String lastName);
+}
diff --git a/test/javax/management/remote/mandatory/connection/RMIConnectorLogAttributesTest.java b/test/javax/management/remote/mandatory/connection/RMIConnectorLogAttributesTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..2284180d95bb879321b4a8be51cdd35c90456b85
--- /dev/null
+++ b/test/javax/management/remote/mandatory/connection/RMIConnectorLogAttributesTest.java
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 2016, 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.lang.management.ManagementFactory;
+import java.net.ServerSocket;
+import java.rmi.registry.LocateRegistry;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.management.Attribute;
+import javax.management.AttributeList;
+import javax.management.AttributeNotFoundException;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.InvalidAttributeValueException;
+import javax.management.MBeanException;
+import javax.management.MBeanRegistrationException;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerConnection;
+import javax.management.MalformedObjectNameException;
+import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXConnectorServer;
+import javax.management.remote.JMXConnectorServerFactory;
+import javax.management.remote.JMXServiceURL;
+
+/**
+ * @test
+ * @bug 8147857
+ * @summary Tests whether RMIConnector logs attribute names correctly.
+ * @author Severin Gehwolf
+ */
+public class RMIConnectorLogAttributesTest {
+
+    private static final String ILLEGAL = ", FirstName[LastName]";
+    private static final Logger logger = Logger.getLogger("javax.management.remote.rmi");
+    private static final String ANY_NAME = "foo";
+    private static final TestLogHandler handler;
+    static {
+        handler = new TestLogHandler(ILLEGAL);
+        handler.setLevel(Level.FINEST);
+        logger.setLevel(Level.ALL);
+        logger.addHandler(handler);
+    }
+
+    private JMXConnectorServer startServer(int rmiPort) throws Exception {
+        System.out.println("DEBUG: Create RMI registry on port " + rmiPort);
+        LocateRegistry.createRegistry(rmiPort);
+
+        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+
+        HashMap env = new HashMap();
+
+        JMXServiceURL url =
+                new JMXServiceURL("service:jmx:rmi:///jndi/rmi://127.0.0.1:" + rmiPort + "/jmxrmi");
+        JMXConnectorServer cs =
+                JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);
+
+        cs.start();
+        System.out.println("DEBUG: Started the RMI connector server");
+        return cs;
+    }
+
+    private int findPort() {
+        for (int i = 13333; i < 13333 + 100; i++) {
+            try {
+                ServerSocket socket = new ServerSocket(i);
+                socket.close();
+                return i;
+            } catch (IOException e) {
+                continue;
+            }
+        }
+        return -1;
+    }
+
+    private void runTest() {
+        int rmiPort = findPort();
+        if (rmiPort == -1) {
+            throw new RuntimeException("Test failed. No available port");
+        }
+        JMXConnectorServer server = null;
+        try {
+            server = startServer(rmiPort);
+            JMXConnector connector = connectToServer(server);
+            doTest(connector);
+        } catch (Exception e) {
+            throw new RuntimeException("Test failed unexpectedly", e);
+        } finally {
+            if (server != null) {
+                try {
+                    server.stop();
+                } catch (IOException e) {
+                    // ignore
+                }
+            }
+        }
+    }
+
+    private JMXConnector connectToServer(JMXConnectorServer server) throws IOException, MalformedObjectNameException, NullPointerException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, ReflectionException, MBeanException {
+        JMXServiceURL url = server.getAddress();
+        Map env = new HashMap();
+        JMXConnector connector = JMXConnectorFactory.connect(url, env);
+
+        System.out.println("DEBUG: Client connected to RMI at: " + url);
+
+        return connector;
+    }
+
+    private void doTest(JMXConnector connector) throws IOException,
+    MalformedObjectNameException, ReflectionException,
+    InstanceAlreadyExistsException, MBeanRegistrationException,
+    MBeanException, NotCompliantMBeanException, InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException {
+        MBeanServerConnection  mbsc = connector.getMBeanServerConnection();
+
+
+        ObjectName objName = new ObjectName("com.redhat.test.jmx:type=NameMBean");
+        System.out.println("DEBUG: Calling createMBean");
+        mbsc.createMBean(Name.class.getName(), objName);
+
+        System.out.println("DEBUG: Calling setAttributes");
+        AttributeList attList = new AttributeList();
+        attList.add(new Attribute("FirstName", ANY_NAME));
+        attList.add(new Attribute("LastName", ANY_NAME));
+        mbsc.setAttributes(objName, attList);
+    }
+
+    public static void main(String[] args) throws Exception {
+        RMIConnectorLogAttributesTest test = new RMIConnectorLogAttributesTest();
+        test.runTest();
+        if (handler.testFailed()) {
+            throw new RuntimeException("Test failed. Logged incorrect: '" + ILLEGAL + "'");
+        }
+        System.out.println("Test passed!");
+    }
+
+}
diff --git a/test/javax/management/remote/mandatory/connection/TestLogHandler.java b/test/javax/management/remote/mandatory/connection/TestLogHandler.java
new file mode 100644
index 0000000000000000000000000000000000000000..2fe48eb1d0c9031b3c62bb9684543907d4969c1a
--- /dev/null
+++ b/test/javax/management/remote/mandatory/connection/TestLogHandler.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2016, 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.util.logging.Handler;
+import java.util.logging.LogRecord;
+
+public class TestLogHandler extends Handler {
+
+    private final String illegal;
+    private boolean testFailed;
+
+    public TestLogHandler(String illegal) {
+        this.illegal = illegal;
+        this.testFailed = false;
+    }
+
+    @Override
+    public void publish(LogRecord record) {
+        String msg = record.getMessage();
+        String method = record.getSourceMethodName();
+        String className = record.getSourceClassName();
+        if (msg.contains(illegal)) {
+            testFailed = true;
+        }
+        if (msg.contains("attribute names=")) {
+            System.err.println("LOG: " + className + "." + method + ": " + msg);
+        }
+    }
+
+    @Override
+    public void flush() {
+        // nothing
+    }
+
+    @Override
+    public void close() throws SecurityException {
+        // nothing
+    }
+
+    public boolean testFailed() {
+        return testFailed;
+    }
+
+}
diff --git a/test/javax/print/PrintSEUmlauts/PrintSEUmlauts.java b/test/javax/print/PrintSEUmlauts/PrintSEUmlauts.java
index f87549747b277d826cface2cba3b632881a5737e..962ef5e8bc09ef6d23637fe7479ff63b47361567 100644
--- a/test/javax/print/PrintSEUmlauts/PrintSEUmlauts.java
+++ b/test/javax/print/PrintSEUmlauts/PrintSEUmlauts.java
@@ -107,14 +107,14 @@ public class PrintSEUmlauts implements Printable {
                 System.err.println("printing content");
                 System.err.println(content);
             }
-            throw new RuntimeException("Expected  to represent 'ä' but not found!");
+            throw new RuntimeException("Expected  to represent '\u00e4' but not found!");
         }
         System.err.println("SUCCESS");
     }
 
     public int print(Graphics g, PageFormat pf, int pg) {
        if (pg > 0) return NO_SUCH_PAGE;
-       g.drawString("ä", 100, 100);
+       g.drawString("\u00e4", 100, 100);
        return PAGE_EXISTS;
    }
 }
diff --git a/test/javax/security/auth/SubjectDomainCombiner/Optimize.java b/test/javax/security/auth/SubjectDomainCombiner/Optimize.java
index 99ec943caafe60fc813d0e5d53bdf19955c4c611..df5adef42a624ec7b6c80452d67c21a740144f55 100644
--- a/test/javax/security/auth/SubjectDomainCombiner/Optimize.java
+++ b/test/javax/security/auth/SubjectDomainCombiner/Optimize.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -37,13 +37,16 @@ public class Optimize {
 
         ProtectionDomain pd1 = new ProtectionDomain(
             new CodeSource(null, (java.security.cert.Certificate[]) null),
-            new Permissions());
+            new Permissions(),
+            null, null);
         ProtectionDomain pd2 = new ProtectionDomain(
             new CodeSource(null, (java.security.cert.Certificate[]) null),
-            new Permissions());
+            new Permissions(),
+            null, null);
         ProtectionDomain pd3 = new ProtectionDomain(
             new CodeSource(null, (java.security.cert.Certificate[]) null),
-            new Permissions());
+            new Permissions(),
+            null, null);
 
         ProtectionDomain[] current = new ProtectionDomain[] {pd1, pd2};
         ProtectionDomain[] assigned = new ProtectionDomain[] {pd3, pd2};
diff --git a/test/javax/xml/crypto/dsig/GenerationTests.java b/test/javax/xml/crypto/dsig/GenerationTests.java
index 62fd8e2536c7fed99160747bb619fa34c6ec9c53..6cc7bbb68653aaec018e15e85e0001d339d80f09 100644
--- a/test/javax/xml/crypto/dsig/GenerationTests.java
+++ b/test/javax/xml/crypto/dsig/GenerationTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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,7 +23,7 @@
 
 /**
  * @test
- * @bug 4635230 6283345 6303830 6824440 6867348 7094155
+ * @bug 4635230 6283345 6303830 6824440 6867348 7094155 8038184 8038349
  * @summary Basic unit tests for generating XML Signatures with JSR 105
  * @compile -XDignore.symbol.file KeySelectors.java SignatureValidator.java
  *     X509KeySelector.java GenerationTests.java
@@ -80,9 +80,10 @@ public class GenerationTests {
     private static KeyInfoFactory kifac;
     private static DocumentBuilder db;
     private static CanonicalizationMethod withoutComments;
-    private static SignatureMethod dsaSha1, rsaSha1, rsaSha256, rsaSha384, rsaSha512;
+    private static SignatureMethod dsaSha1, dsaSha256, rsaSha1,
+                                   rsaSha256, rsaSha384, rsaSha512;
     private static DigestMethod sha1, sha256, sha384, sha512;
-    private static KeyInfo dsa, rsa, rsa1024;
+    private static KeyInfo dsa1024, dsa2048, rsa, rsa1024;
     private static KeySelector kvks = new KeySelectors.KeyValueKeySelector();
     private static KeySelector sks;
     private static Key signingKey;
@@ -106,10 +107,13 @@ public class GenerationTests {
         "http://www.w3.org/TR/xml-stylesheet";
     private final static String STYLESHEET_B64 =
         "http://www.w3.org/Signature/2002/04/xml-stylesheet.b64";
+    private final static String DSA_SHA256 =
+        "http://www.w3.org/2009/xmldsig11#dsa-sha256";
 
     public static void main(String args[]) throws Exception {
         setup();
-        test_create_signature_enveloped_dsa();
+        test_create_signature_enveloped_dsa(1024);
+        test_create_signature_enveloped_dsa(2048);
         test_create_signature_enveloping_b64_dsa();
         test_create_signature_enveloping_dsa();
         test_create_signature_enveloping_hmac_sha1_40();
@@ -135,6 +139,7 @@ public class GenerationTests {
         test_create_signature_enveloping_sha512_rsa_sha512();
         test_create_signature_reference_dependency();
         test_create_signature_with_attr_in_no_namespace();
+        test_create_signature_with_empty_id();
     }
 
     private static void setup() throws Exception {
@@ -156,15 +161,18 @@ public class GenerationTests {
         withoutComments = fac.newCanonicalizationMethod
             (CanonicalizationMethod.INCLUSIVE, (C14NMethodParameterSpec)null);
         dsaSha1 = fac.newSignatureMethod(SignatureMethod.DSA_SHA1, null);
+        dsaSha256 = fac.newSignatureMethod(DSA_SHA256, null);
         sha1 = fac.newDigestMethod(DigestMethod.SHA1, null);
         sha256 = fac.newDigestMethod(DigestMethod.SHA256, null);
         sha384 = fac.newDigestMethod
             ("http://www.w3.org/2001/04/xmldsig-more#sha384", null);
         sha512 = fac.newDigestMethod(DigestMethod.SHA512, null);
-        dsa = kifac.newKeyInfo(Collections.singletonList
+        dsa1024 = kifac.newKeyInfo(Collections.singletonList
             (kifac.newKeyValue(validatingKey)));
+        dsa2048 = kifac.newKeyInfo(Collections.singletonList
+            (kifac.newKeyValue(getPublicKey("DSA", 2048))));
         rsa = kifac.newKeyInfo(Collections.singletonList
-            (kifac.newKeyValue(getPublicKey("RSA"))));
+            (kifac.newKeyValue(getPublicKey("RSA", 512))));
         rsa1024 = kifac.newKeyInfo(Collections.singletonList
             (kifac.newKeyValue(getPublicKey("RSA", 1024))));
         rsaSha1 = fac.newSignatureMethod(SignatureMethod.RSA_SHA1, null);
@@ -179,11 +187,25 @@ public class GenerationTests {
         httpUd = new HttpURIDereferencer();
     }
 
-    static void test_create_signature_enveloped_dsa() throws Exception {
-        System.out.println("* Generating signature-enveloped-dsa.xml");
+    static void test_create_signature_enveloped_dsa(int size) throws Exception {
+        System.out.println("* Generating signature-enveloped-dsa-"
+                           + size + ".xml");
+        SignatureMethod sm = null;
+        KeyInfo ki = null;
+        Key privKey;
+        if (size == 1024) {
+            sm = dsaSha1;
+            ki = dsa1024;
+            privKey = signingKey;
+        } else if (size == 2048) {
+            sm = dsaSha256;
+            ki = dsa2048;
+            privKey = getPrivateKey("DSA", 2048);
+        } else throw new RuntimeException("unsupported keysize:" + size);
+
         // create SignedInfo
         SignedInfo si = fac.newSignedInfo
-            (withoutComments, dsaSha1, Collections.singletonList
+            (withoutComments, sm, Collections.singletonList
                 (fac.newReference
                     ("", sha1, Collections.singletonList
                         (fac.newTransform(Transform.ENVELOPED,
@@ -191,7 +213,7 @@ public class GenerationTests {
                  null, null)));
 
         // create XMLSignature
-        XMLSignature sig = fac.newXMLSignature(si, dsa);
+        XMLSignature sig = fac.newXMLSignature(si, ki);
 
         Document doc = db.newDocument();
         Element envelope = doc.createElementNS
@@ -200,12 +222,12 @@ public class GenerationTests {
             "xmlns", "http://example.org/envelope");
         doc.appendChild(envelope);
 
-        DOMSignContext dsc = new DOMSignContext(signingKey, envelope);
+        DOMSignContext dsc = new DOMSignContext(privKey, envelope);
 
         sig.sign(dsc);
-//      StringWriter sw = new StringWriter();
-//      dumpDocument(doc, sw);
-//      System.out.println(sw.toString());
+//        StringWriter sw = new StringWriter();
+//        dumpDocument(doc, sw);
+//        System.out.println(sw.toString());
 
         DOMValidateContext dvc = new DOMValidateContext
             (kvks, envelope.getFirstChild());
@@ -225,21 +247,21 @@ public class GenerationTests {
     static void test_create_signature_enveloping_b64_dsa() throws Exception {
         System.out.println("* Generating signature-enveloping-b64-dsa.xml");
         test_create_signature_enveloping
-            (sha1, dsaSha1, dsa, signingKey, kvks, true);
+            (sha1, dsaSha1, dsa1024, signingKey, kvks, true);
         System.out.println();
     }
 
     static void test_create_signature_enveloping_dsa() throws Exception {
         System.out.println("* Generating signature-enveloping-dsa.xml");
         test_create_signature_enveloping
-            (sha1, dsaSha1, dsa, signingKey, kvks, false);
+            (sha1, dsaSha1, dsa1024, signingKey, kvks, false);
         System.out.println();
     }
 
     static void test_create_signature_enveloping_sha256_dsa() throws Exception {
         System.out.println("* Generating signature-enveloping-sha256-dsa.xml");
         test_create_signature_enveloping
-            (sha256, dsaSha1, dsa, signingKey, kvks, false);
+            (sha256, dsaSha1, dsa1024, signingKey, kvks, false);
         System.out.println();
     }
 
@@ -292,7 +314,7 @@ public class GenerationTests {
     static void test_create_signature_enveloping_rsa() throws Exception {
         System.out.println("* Generating signature-enveloping-rsa.xml");
         test_create_signature_enveloping(sha1, rsaSha1, rsa,
-            getPrivateKey("RSA"), kvks, false);
+            getPrivateKey("RSA", 512), kvks, false);
         System.out.println();
     }
 
@@ -300,7 +322,7 @@ public class GenerationTests {
         throws Exception {
         System.out.println("* Generating signature-enveloping-sha384-rsa_sha256.xml");
         test_create_signature_enveloping(sha384, rsaSha256, rsa,
-            getPrivateKey("RSA"), kvks, false);
+            getPrivateKey("RSA", 512), kvks, false);
         System.out.println();
     }
 
@@ -322,13 +344,13 @@ public class GenerationTests {
 
     static void test_create_signature_external_b64_dsa() throws Exception {
         System.out.println("* Generating signature-external-b64-dsa.xml");
-        test_create_signature_external(dsaSha1, dsa, signingKey, kvks, true);
+        test_create_signature_external(dsaSha1, dsa1024, signingKey, kvks, true);
         System.out.println();
     }
 
     static void test_create_signature_external_dsa() throws Exception {
         System.out.println("* Generating signature-external-dsa.xml");
-        test_create_signature_external(dsaSha1, dsa, signingKey, kvks, false);
+        test_create_signature_external(dsaSha1, dsa1024, signingKey, kvks, false);
         System.out.println();
     }
 
@@ -440,7 +462,7 @@ public class GenerationTests {
 
         // create XMLSignature
         XMLSignature sig = fac.newXMLSignature(si, rsa, objs, "signature", null);
-        DOMSignContext dsc = new DOMSignContext(getPrivateKey("RSA"), doc);
+        DOMSignContext dsc = new DOMSignContext(getPrivateKey("RSA", 512), doc);
 
         sig.sign(dsc);
 
@@ -486,7 +508,7 @@ public class GenerationTests {
         XMLSignature sig = fac.newXMLSignature(si, rsa,
                                                Collections.singletonList(obj),
                                                "signature", null);
-        DOMSignContext dsc = new DOMSignContext(getPrivateKey("RSA"), doc);
+        DOMSignContext dsc = new DOMSignContext(getPrivateKey("RSA", 512), doc);
         dsc.setIdAttributeNS(nc, null, "Id");
 
         sig.sign(dsc);
@@ -509,6 +531,30 @@ public class GenerationTests {
         System.out.println();
     }
 
+    static void test_create_signature_with_empty_id() throws Exception {
+        System.out.println("* Generating signature-with-empty-id.xml");
+
+        // create references
+        List refs = Collections.singletonList
+            (fac.newReference("#", sha1));
+
+        // create SignedInfo
+        SignedInfo si = fac.newSignedInfo(withoutComments, rsaSha1, refs);
+
+        // create object with empty id
+        Document doc = db.newDocument();
+        XMLObject obj = fac.newXMLObject(Collections.singletonList
+            (new DOMStructure(doc.createTextNode("I am the text."))),
+            "", "text/plain", null);
+
+        // create XMLSignature
+        XMLSignature sig = fac.newXMLSignature(si, rsa,
+                                               Collections.singletonList(obj),
+                                               "signature", null);
+        DOMSignContext dsc = new DOMSignContext(getPrivateKey("RSA", 512), doc);
+        sig.sign(dsc);
+    }
+
     static void test_create_signature() throws Exception {
         System.out.println("* Generating signature.xml");
 
@@ -1091,6 +1137,16 @@ public class GenerationTests {
         "90670890367185141189796";
     private static final String DSA_X =
         "0527140396812450214498055937934275626078768840117";
+    private static final String DSA_2048_Y =
+        "15119007057343785981993995134621348945077524760182795513668325877793414638620983617627033248732235626178802906346261435991040697338468329634416089753032362617771631199351767336660070462291411472735835843440140283101463231807789628656218830720378705090795271104661936237385140354825159080766174663596286149653433914842868551355716015585570827642835307073681358328172009941968323702291677280809277843998510864653406122348712345584706761165794179850728091522094227603562280855104749858249588234915206290448353957550635709520273178475097150818955098638774564910092913714625772708285992586894795017709678223469405896699928";
+    private static final String DSA_2048_P =
+        "18111848663142005571178770624881214696591339256823507023544605891411707081617152319519180201250440615163700426054396403795303435564101919053459832890139496933938670005799610981765220283775567361483662648340339405220348871308593627647076689407931875483406244310337925809427432681864623551598136302441690546585427193224254314088256212718983105131138772434658820375111735710449331518776858786793875865418124429269409118756812841019074631004956409706877081612616347900606555802111224022921017725537417047242635829949739109274666495826205002104010355456981211025738812433088757102520562459649777989718122219159982614304359";
+    private static final String DSA_2048_Q =
+        "19689526866605154788513693571065914024068069442724893395618704484701";
+    private static final String DSA_2048_G =
+        "2859278237642201956931085611015389087970918161297522023542900348087718063098423976428252369340967506010054236052095950169272612831491902295835660747775572934757474194739347115870723217560530672532404847508798651915566434553729839971841903983916294692452760249019857108409189016993380919900231322610083060784269299257074905043636029708121288037909739559605347853174853410208334242027740275688698461842637641566056165699733710043802697192696426360843173620679214131951400148855611740858610821913573088059404459364892373027492936037789337011875710759208498486908611261954026964574111219599568903257472567764789616958430";
+    private static final String DSA_2048_X =
+        "14562787764977288900757387442281559936279834964901963465277698843172";
     private static final String RSA_MOD =
         "010800185049102889923150759252557522305032794699952150943573164381" +
         "936603255999071981574575044810461362008102247767482738822150129277" +
@@ -1113,43 +1169,48 @@ public class GenerationTests {
         "204903524890556839550490384015324575598723478554854070823335021842" +
         "210112348400928769";
 
-    private static PublicKey getPublicKey(String algo) throws Exception {
-        return getPublicKey(algo, 512);
-    }
-
     private static PublicKey getPublicKey(String algo, int keysize)
         throws Exception {
         KeyFactory kf = KeyFactory.getInstance(algo);
         KeySpec kspec;
         if (algo.equalsIgnoreCase("DSA")) {
-            kspec = new DSAPublicKeySpec(new BigInteger(DSA_Y),
-                                         new BigInteger(DSA_P),
-                                         new BigInteger(DSA_Q),
-                                         new BigInteger(DSA_G));
+            if (keysize == 1024) {
+                kspec = new DSAPublicKeySpec(new BigInteger(DSA_Y),
+                                             new BigInteger(DSA_P),
+                                             new BigInteger(DSA_Q),
+                                             new BigInteger(DSA_G));
+            } else if (keysize == 2048) {
+                kspec = new DSAPublicKeySpec(new BigInteger(DSA_2048_Y),
+                                             new BigInteger(DSA_2048_P),
+                                             new BigInteger(DSA_2048_Q),
+                                             new BigInteger(DSA_2048_G));
+            } else throw new RuntimeException("Unsupported keysize:" + keysize);
         } else if (algo.equalsIgnoreCase("RSA")) {
             if (keysize == 512) {
                 kspec = new RSAPublicKeySpec(new BigInteger(RSA_MOD),
                                              new BigInteger(RSA_PUB));
-            } else {
+            } else if (keysize == 1024) {
                 kspec = new RSAPublicKeySpec(new BigInteger(RSA_1024_MOD),
                                              new BigInteger(RSA_PUB));
-            }
+            } else throw new RuntimeException("Unsupported keysize:" + keysize);
         } else throw new RuntimeException("Unsupported key algorithm " + algo);
         return kf.generatePublic(kspec);
     }
 
-    private static PrivateKey getPrivateKey(String algo) throws Exception {
-        return getPrivateKey(algo, 512);
-    }
-
     private static PrivateKey getPrivateKey(String algo, int keysize)
         throws Exception {
         KeyFactory kf = KeyFactory.getInstance(algo);
         KeySpec kspec;
         if (algo.equalsIgnoreCase("DSA")) {
-            kspec = new DSAPrivateKeySpec
-                (new BigInteger(DSA_X), new BigInteger(DSA_P),
-                 new BigInteger(DSA_Q), new BigInteger(DSA_G));
+            if (keysize == 1024) {
+                kspec = new DSAPrivateKeySpec
+                    (new BigInteger(DSA_X), new BigInteger(DSA_P),
+                     new BigInteger(DSA_Q), new BigInteger(DSA_G));
+            } else if (keysize == 2048) {
+                kspec = new DSAPrivateKeySpec
+                    (new BigInteger(DSA_2048_X), new BigInteger(DSA_2048_P),
+                     new BigInteger(DSA_2048_Q), new BigInteger(DSA_2048_G));
+            } else throw new RuntimeException("Unsupported keysize:" + keysize);
         } else if (algo.equalsIgnoreCase("RSA")) {
             if (keysize == 512) {
                 kspec = new RSAPrivateKeySpec
diff --git a/test/javax/xml/crypto/dsig/KeySelectors.java b/test/javax/xml/crypto/dsig/KeySelectors.java
index 2924d991ae36cdc62b3a0302494b3f864ea61ea1..290c55b89dac329f725b39800052d7cd9ed25710 100644
--- a/test/javax/xml/crypto/dsig/KeySelectors.java
+++ b/test/javax/xml/crypto/dsig/KeySelectors.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -175,7 +175,8 @@ class KeySelectors {
         //@@@FIXME: this should also work for key types other than DSA/RSA
         static boolean algEquals(String algURI, String algName) {
             if (algName.equalsIgnoreCase("DSA") &&
-                algURI.equals(SignatureMethod.DSA_SHA1)) {
+                algURI.equals(SignatureMethod.DSA_SHA1) ||
+                algURI.equals("http://www.w3.org/2009/xmldsig11#dsa-sha256")) {
                 return true;
             } else if (algName.equalsIgnoreCase("RSA") &&
                 (algURI.equals(SignatureMethod.RSA_SHA1) ||
diff --git a/test/javax/xml/jaxp/transform/8062518/XSLTFunctionsTest.java b/test/javax/xml/jaxp/transform/8062518/XSLTFunctionsTest.java
index b60a7be3eea6fccec84800c012fc2eed4bb34d3b..767267355cb853c8a9b02cbecd86600e798b4266 100644
--- a/test/javax/xml/jaxp/transform/8062518/XSLTFunctionsTest.java
+++ b/test/javax/xml/jaxp/transform/8062518/XSLTFunctionsTest.java
@@ -22,7 +22,7 @@
  */
 
 /* @test
- * @bug 8062518
+ * @bug 8062518 8133924
  * @summary This class contains tests for XSLT functions
  * @compile DocumentExtFunc.java
  * @run testng/othervm XSLTFunctionsTest
@@ -102,17 +102,34 @@ public class XSLTFunctionsTest {
     @DataProvider(name = "document")
     public static Object[][] documentTestData() {
         return new Object[][] {
+            // 8062518
             {documentTestXml, documentTestXsl, documentTestExternalDoc, documentTesteExpectedResult},
+            // 8133924
+            {documentTestXml, nonExistingNodeXsl, documentTestExternalDoc, nonExistNodeExpectedResult},
         };
     }
 
+    // bug 8133924 xsl: test data to trigger the NPE when non-existing node is specified in xsl
+    static final String nonExistingNodeXsl = ""
+            + ""
+            + " "
+            + " "
+            + ""
+            + "";
+
+    //For bug 8133924 xsl the empty transformation result is expected instead of NPE
+    static final String nonExistNodeExpectedResult = ""
+                                                    + "Doc";
+
     static final String documentTestXml = "Doc";
 
     static final String documentTestExternalDoc = "External Doc";
 
     static final String documentTestXsl = ""
             + ""
             + ""
             + ""
diff --git a/test/sun/jvmstat/perfdata/PrologSanity/PrologSizeSanityCheck.java b/test/sun/jvmstat/perfdata/PrologSanity/PrologSizeSanityCheck.java
index 617ac22503d3aba765291171fde677b0f238f65e..9eb6765fe5403fcf1dc5f3915a530942db5d2aec 100644
--- a/test/sun/jvmstat/perfdata/PrologSanity/PrologSizeSanityCheck.java
+++ b/test/sun/jvmstat/perfdata/PrologSanity/PrologSizeSanityCheck.java
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 4990825
- * @run main/othervm -XX:+UsePerfData  PrologSizeSanityCheck
+ * @run main/othervm -XX:+UsePerfData -XX:PerfDataMemorySize=64k PrologSizeSanityCheck
  * @summary prolog size and overflow sanity checks
  */
 
diff --git a/test/sun/misc/Version/Version.java b/test/sun/misc/Version/Version.java
index 85c8ce2a07100ed6c5fe3e90caae422abb983c2c..10f5c226bbecf00d24d0e879fa95c73ef80bc24f 100644
--- a/test/sun/misc/Version/Version.java
+++ b/test/sun/misc/Version/Version.java
@@ -29,11 +29,13 @@
  * @run main Version
  */
 
+import java.util.regex.*;
 import static sun.misc.Version.*;
+
 public class Version {
 
     public static void main(String[] args) throws Exception {
-        VersionInfo jdk = newVersionInfo(System.getProperty("java.runtime.version"));
+        VersionInfo jdk = jdkVersionInfo(System.getProperty("java.runtime.version"));
         VersionInfo v1 = new VersionInfo(jdkMajorVersion(),
                                          jdkMinorVersion(),
                                          jdkMicroVersion(),
@@ -44,7 +46,7 @@ public class Version {
         if (!jdk.equals(v1)) {
             throw new RuntimeException("Unmatched version: " + jdk + " vs " + v1);
         }
-        VersionInfo jvm = newVersionInfo(System.getProperty("java.vm.version"));
+        VersionInfo jvm = jvmVersionInfo(System.getProperty("java.vm.version"));
         VersionInfo v2 = new VersionInfo(jvmMajorVersion(),
                                          jvmMinorVersion(),
                                          jvmMicroVersion(),
@@ -95,74 +97,73 @@ public class Version {
         }
     }
 
-    private static VersionInfo newVersionInfo(String version) throws Exception {
+    private static VersionInfo jdkVersionInfo(String version) throws Exception {
         // valid format of the version string is:
-        // n.n.n[_uu[c]][-]-bxx
+        // .[.][_uu[c]][-]-bxx
         int major = 0;
         int minor = 0;
         int micro = 0;
         int update = 0;
         String special = "";
         int build = 0;
-        CharSequence cs = version;
-        if (cs.length() >= 5) {
-            if (Character.isDigit(cs.charAt(0)) && cs.charAt(1) == '.' &&
-                Character.isDigit(cs.charAt(2)) && cs.charAt(3) == '.' &&
-                Character.isDigit(cs.charAt(4))) {
-                major = Character.digit(cs.charAt(0), 10);
-                minor = Character.digit(cs.charAt(2), 10);
-                micro = Character.digit(cs.charAt(4), 10);
-                cs = cs.subSequence(5, cs.length());
-            } else if (Character.isDigit(cs.charAt(0)) &&
-                       Character.isDigit(cs.charAt(1)) && cs.charAt(2) == '.' &&
-                       Character.isDigit(cs.charAt(3))) {
-                // HSX has nn.n[n] (major.minor) version
-                major = Integer.valueOf(version.substring(0, 2)).intValue();
-                if (Character.isDigit(cs.charAt(4))) {
-                    minor = Integer.valueOf(version.substring(3, 5)).intValue();
-                    cs = cs.subSequence(5, cs.length());
-                }
-                else {
-                    minor = Character.digit(cs.charAt(3), 10);
-                    cs = cs.subSequence(4, cs.length());
-                }
-            }
-            if (cs.charAt(0) == '_' && cs.length() >= 3 &&
-                Character.isDigit(cs.charAt(1)) &&
-                Character.isDigit(cs.charAt(2))) {
-                int nextChar = 3;
-                String uu = cs.subSequence(1, 3).toString();
-                update = Integer.valueOf(uu).intValue();
-                if (cs.length() >= 4) {
-                    char c = cs.charAt(3);
-                    if (c >= 'a' && c <= 'z') {
-                        special = Character.toString(c);
-                        nextChar++;
-                    }
-                }
-                cs = cs.subSequence(nextChar, cs.length());
-            }
-            if (cs.charAt(0) == '-') {
-                // skip the first character
-                // valid format: -bxx or bxx
-                // non-product VM will have -debug|-release appended
-                cs = cs.subSequence(1, cs.length());
-                String[] res = cs.toString().split("-");
-                for (int i = res.length - 1; i >= 0; i--) {
-                    String s = res[i];
-                    if (s.charAt(0) == 'b') {
-                        try {
-                            build = Integer.parseInt(s.substring(1, s.length()));
-                            break;
-                        } catch (NumberFormatException nfe) {
-                            // ignore
-                        }
-                    }
-                }
-            }
-        }
+
+        String regex = "^([0-9]{1,2})";     // major
+        regex += "\\.";                     // separator
+        regex += "([0-9]{1,2})";            // minor
+        regex += "(\\.";                    // separator
+        regex +=   "([0-9]{1,2})";          // micro
+        regex += ")?";                      // micro is optional
+        regex += "(_";
+        regex +=   "([0-9]{2,3})";          // update
+        regex +=   "([a-z])?";              // special char (optional)
+        regex += ")?";                      // _uu[c] is optional
+        regex += ".*";                      // -
+        regex += "(\\-b([0-9]{1,3}$))";     // JDK -bxx
+
+        Pattern p = Pattern.compile(regex);
+        Matcher m = p.matcher(version);
+        m.matches();
+
+        major = Integer.parseInt(m.group(1));
+        minor = Integer.parseInt(m.group(2));
+        micro = (m.group(4) == null) ? 0 : Integer.parseInt(m.group(4));
+        update = (m.group(6) == null) ? 0 : Integer.parseInt(m.group(6));
+        special = (m.group(7) == null) ? "" : m.group(7);
+        build = Integer.parseInt(m.group(9));
+
         VersionInfo vi = new VersionInfo(major, minor, micro, update, special, build);
-        System.out.printf("newVersionInfo: input=%s output=%s\n", version, vi);
+        System.out.printf("jdkVersionInfo: input=%s output=%s\n", version, vi);
         return vi;
     }
+
+    private static VersionInfo jvmVersionInfo(String version) throws Exception {
+        try {
+            // valid format of the version string is:
+            // .-bxx[-][-]
+            int major = 0;
+            int minor = 0;
+            int build = 0;
+
+            String regex = "^([0-9]{1,2})";     // major
+            regex += "\\.";                     // separator
+            regex += "([0-9]{1,3})";            // minor
+            regex += "(\\-b([0-9]{1,3}))";      // JVM -bxx
+            regex += ".*";
+
+            Pattern p = Pattern.compile(regex);
+            Matcher m = p.matcher(version);
+            m.matches();
+
+            major = Integer.parseInt(m.group(1));
+            minor = Integer.parseInt(m.group(2));
+            build = Integer.parseInt(m.group(4));
+
+            VersionInfo vi = new VersionInfo(major, minor, 0, 0, "", build);
+            System.out.printf("jvmVersionInfo: input=%s output=%s\n", version, vi);
+            return vi;
+        } catch (IllegalStateException e) {
+            // local builds may also follow the jdkVersionInfo format
+            return jdkVersionInfo(version);
+        }
+    }
 }
diff --git a/test/sun/security/mscapi/AccessKeyStore.java b/test/sun/security/mscapi/AccessKeyStore.java
index 357984b8aef94e88816aa0051be8f973ef8135fe..81f0dbcb2ca15ea931f4755c652a157be863af1b 100644
--- a/test/sun/security/mscapi/AccessKeyStore.java
+++ b/test/sun/security/mscapi/AccessKeyStore.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -36,17 +36,6 @@ public class AccessKeyStore {
 
     public static void main(String[] args) throws Exception {
 
-        // Check if the provider is available
-        try {
-            Class.forName("sun.security.mscapi.SunMSCAPI");
-
-        } catch (Exception e) {
-            System.out.println(
-                "The SunMSCAPI provider is not available on this platform: " +
-                e);
-            return;
-        }
-
         // Check that a security manager has been installed
         if (System.getSecurityManager() == null) {
             throw new Exception("A security manager has not been installed");
@@ -86,8 +75,8 @@ public class AccessKeyStore {
         }
 
         int i = 0;
-        for (Enumeration e = keyStore.aliases(); e.hasMoreElements(); ) {
-            String alias = (String) e.nextElement();
+        for (Enumeration e = keyStore.aliases(); e.hasMoreElements(); ) {
+            String alias = e.nextElement();
             displayEntry(keyStore, alias, i++);
         }
     }
diff --git a/test/sun/security/mscapi/AccessKeyStore.sh b/test/sun/security/mscapi/AccessKeyStore.sh
index 0998de4821f6c95ef54b3ab1d3be2ac95d809764..e8250027d43fb101a3de9889304b55db31b56733 100644
--- a/test/sun/security/mscapi/AccessKeyStore.sh
+++ b/test/sun/security/mscapi/AccessKeyStore.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 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
@@ -26,6 +26,7 @@
 
 # @test
 # @bug 6324295 6931562
+# @requires os.family == "windows"
 # @run shell AccessKeyStore.sh
 # @summary Confirm that permission must be granted to access keystores.
 
diff --git a/test/sun/security/mscapi/IsSunMSCAPIAvailable.java b/test/sun/security/mscapi/IsSunMSCAPIAvailable.java
index d48f7855c366f2621f2f42dd7bbaadd6c9192c5b..ac3c2ffcf37ca1883edced3b1e56ce626d11d8aa 100644
--- a/test/sun/security/mscapi/IsSunMSCAPIAvailable.java
+++ b/test/sun/security/mscapi/IsSunMSCAPIAvailable.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -33,16 +33,6 @@ public class IsSunMSCAPIAvailable {
 
     public static void main(String[] args) throws Exception {
 
-        // Check if the provider is available
-        try {
-            Class.forName("sun.security.mscapi.SunMSCAPI");
-
-        } catch (Exception e) {
-            System.out.println(
-                "The SunMSCAPI provider is not available on this platform");
-            return;
-        }
-
         // Dynamically register the SunMSCAPI provider
         Security.addProvider(new sun.security.mscapi.SunMSCAPI());
 
@@ -58,7 +48,6 @@ public class IsSunMSCAPIAvailable {
         /*
          * Secure Random
          */
-
         SecureRandom random = SecureRandom.getInstance("Windows-PRNG", p);
         System.out.println("    Windows-PRNG is implemented by: " +
             random.getClass().getName());
diff --git a/test/sun/security/mscapi/IsSunMSCAPIAvailable.sh b/test/sun/security/mscapi/IsSunMSCAPIAvailable.sh
index 6e7ffa302b0ed6c85b169605bf1ad4b88646e7e6..accf1bf4e43b9443f0745394cfa07019f666f9ee 100644
--- a/test/sun/security/mscapi/IsSunMSCAPIAvailable.sh
+++ b/test/sun/security/mscapi/IsSunMSCAPIAvailable.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 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
@@ -26,6 +26,7 @@
 
 # @test
 # @bug 6318171 6931562
+# @requires os.family == "windows"
 # @run shell IsSunMSCAPIAvailable.sh
 # @summary Basic test of the Microsoft CryptoAPI provider.
 
diff --git a/test/sun/security/mscapi/IterateWindowsRootStore.java b/test/sun/security/mscapi/IterateWindowsRootStore.java
new file mode 100644
index 0000000000000000000000000000000000000000..aea35817371ae19f5748fd9f46b2930e930c61bc
--- /dev/null
+++ b/test/sun/security/mscapi/IterateWindowsRootStore.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.io.InputStream;
+import java.security.KeyStore;
+import java.security.Provider;
+import java.security.Security;
+import java.security.cert.CRL;
+import java.security.cert.CRLException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactorySpi;
+import java.util.Collection;
+import java.util.Enumeration;
+
+/*
+ * @test
+ * @bug 8139436
+ * @summary This test validates an iteration over the Windows-ROOT certificate store
+ *          and retrieving all certificates.
+ *          Bug 8139436 reports an issue when 3rd party JCE providers would throw exceptions
+ *          upon creating Certificate objects.
+ *          This would for instance happen when using IAIK 3.15 and Elliptic Curve certificates
+ *          are contained in the Windows-ROOT certificate store.
+ *          The test uses a simple dummy provider which just throws Exceptions in its CertificateFactory.
+ *          To test an external provider, you can use property sun.security.mscapi.testprovider and
+ *          set it to the provider class name which has to be constructible by a constructor without
+ *          arguments. The provider jar has to be added to the classpath.
+ *          E.g. run jtreg with -javaoption:-Dsun.security.mscapi.testprovider=iaik.security.provider.IAIK and
+ *          -cpa:
+ *
+ * @requires os.family == "windows"
+ * @author Christoph Langer
+ * @run main IterateWindowsRootStore
+ */
+public class IterateWindowsRootStore {
+    public static class TestFactory extends CertificateFactorySpi {
+        @Override
+        public Certificate engineGenerateCertificate(InputStream inStream) throws CertificateException {
+            throw new CertificateException("unimplemented");
+        }
+
+        @Override
+        public Collection engineGenerateCertificates(InputStream inStream) throws CertificateException {
+            throw new CertificateException("unimplemented");
+        }
+
+        @Override
+        public CRL engineGenerateCRL(InputStream inStream) throws CRLException {
+            throw new CRLException("unimplemented");
+        }
+
+        @Override
+        public Collection engineGenerateCRLs(InputStream inStream) throws CRLException {
+            throw new CRLException("unimplemented");
+        }
+    }
+
+    public static class TestProvider extends Provider {
+        private static final long serialVersionUID = 1L;
+
+        public TestProvider() {
+            super("TestProvider", 0.1, "Test provider for IterateWindowsRootStore");
+
+            /*
+             * Certificates
+             */
+            this.put("CertificateFactory.X.509", "IterateWindowsRootStore$TestFactory");
+            this.put("Alg.Alias.CertificateFactory.X509", "X.509");
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        // Try to register a JCE provider from property sun.security.mscapi.testprovider in the first slot
+        // otherwise register a dummy provider which would provoke the issue of bug 8139436
+        boolean providerPrepended = false;
+        String testprovider = System.getProperty("sun.security.mscapi.testprovider");
+        if (testprovider != null && !testprovider.isEmpty()) {
+            try {
+                System.out.println("Trying to prepend external JCE provider " + testprovider);
+                Class providerclass = Class.forName(testprovider);
+                Object provider = providerclass.newInstance();
+                Security.insertProviderAt((Provider)provider, 1);
+            } catch (Exception e) {
+                System.out.println("Could not load JCE provider " + testprovider +". Exception is:");
+                e.printStackTrace(System.out);
+            }
+            providerPrepended = true;
+            System.out.println("Sucessfully prepended JCE provider " + testprovider);
+        }
+        if (!providerPrepended) {
+            System.out.println("Trying to prepend dummy JCE provider");
+            Security.insertProviderAt(new TestProvider(), 1);
+            System.out.println("Sucessfully prepended dummy JCE provider");
+        }
+
+        // load Windows-ROOT KeyStore
+        KeyStore keyStore = KeyStore.getInstance("Windows-ROOT", "SunMSCAPI");
+        keyStore.load(null, null);
+
+        // iterate KeyStore
+        Enumeration aliases = keyStore.aliases();
+        while (aliases.hasMoreElements()) {
+            String alias = aliases.nextElement();
+            System.out.print("Reading certificate for alias: " + alias + "...");
+            keyStore.getCertificate(alias);
+            System.out.println(" done.");
+        }
+    }
+}
diff --git a/test/sun/security/mscapi/KeyStoreCompatibilityMode.java b/test/sun/security/mscapi/KeyStoreCompatibilityMode.java
index 04ce94c782d072ddd204ce3d96db5eeaf4291ac0..b18abca674fbcb97972bf8698209919206f7aa96 100644
--- a/test/sun/security/mscapi/KeyStoreCompatibilityMode.java
+++ b/test/sun/security/mscapi/KeyStoreCompatibilityMode.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -38,17 +38,6 @@ public class KeyStoreCompatibilityMode {
 
     public static void main(String[] args) throws Exception {
 
-        // Check if the provider is available
-        try {
-            Class.forName("sun.security.mscapi.SunMSCAPI");
-
-        } catch (Exception e) {
-            System.out.println(
-                "The SunMSCAPI provider is not available on this platform: " +
-                e);
-            return;
-        }
-
         if (args.length > 0 && "-disable".equals(args[0])) {
             mode = false;
         } else {
diff --git a/test/sun/security/mscapi/KeyStoreCompatibilityMode.sh b/test/sun/security/mscapi/KeyStoreCompatibilityMode.sh
index b6ca1395d7620f66da114383f30f6489007f73a7..80a9d5654200d4a9167be248285577632da24305 100644
--- a/test/sun/security/mscapi/KeyStoreCompatibilityMode.sh
+++ b/test/sun/security/mscapi/KeyStoreCompatibilityMode.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 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
@@ -23,9 +23,9 @@
 # questions.
 #
 
-
 # @test
 # @bug 6324294 6931562
+# @requires os.family == "windows"
 # @run shell KeyStoreCompatibilityMode.sh
 # @summary Confirm that a null stream or password is not permitted when 
 #          compatibility mode is enabled (and vice versa).
diff --git a/test/sun/security/mscapi/KeytoolChangeAlias.sh b/test/sun/security/mscapi/KeytoolChangeAlias.sh
index 0012a93af528a41547f41c86c41113643742c676..c38cf4384e79c4067b87e53734c353088af16f0d 100644
--- a/test/sun/security/mscapi/KeytoolChangeAlias.sh
+++ b/test/sun/security/mscapi/KeytoolChangeAlias.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 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
@@ -26,6 +26,7 @@
 
 # @test
 # @bug 6415696 6931562
+# @requires os.family == "windows"
 # @run shell KeytoolChangeAlias.sh
 # @summary Test "keytool -changealias" using the Microsoft CryptoAPI provider.
 
diff --git a/test/sun/security/mscapi/PrngSlow.java b/test/sun/security/mscapi/PrngSlow.java
index f9001eea80d20750d457546e1075fa5f2a84e74c..80995e17fb7ab580700090617cd4c05256d267cc 100644
--- a/test/sun/security/mscapi/PrngSlow.java
+++ b/test/sun/security/mscapi/PrngSlow.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -24,6 +24,7 @@
 /**
  * @test
  * @bug 6449335
+ * @requires os.family == "windows"
  * @summary MSCAPI's PRNG is too slow
  */
 
@@ -33,23 +34,15 @@ public class PrngSlow {
 
     public static void main(String[] args) throws Exception {
         double t = 0.0;
-        try {
-            SecureRandom sr = null;
-            sr = SecureRandom.getInstance("PRNG", "SunMSCAPI");
-            long start = System.nanoTime();
-            int x = 0;
-            for(int i = 0; i < 10000; i++) {
-                if (i % 100 == 0) System.err.print(".");
-                if (sr.nextBoolean()) x++;
-            };
-            t = (System.nanoTime() - start) / 1000000000.0;
-            System.err.println("\nSpend " + t + " seconds");
-        } catch (Exception e) {
-            // Not supported here, maybe not a Win32
-            System.err.println("Cannot find PRNG for SunMSCAPI or other mysterious bugs");
-            e.printStackTrace();
-            return;
-        }
+        SecureRandom sr = null;
+        sr = SecureRandom.getInstance("Windows-PRNG", "SunMSCAPI");
+        long start = System.nanoTime();
+        for (int i = 0; i < 10000; i++) {
+            if (i % 100 == 0) System.err.print(".");
+            sr.nextBoolean();
+        };
+        t = (System.nanoTime() - start) / 1000000000.0;
+        System.err.println("\nSpend " + t + " seconds");
         if (t > 5)
             throw new RuntimeException("Still too slow");
     }
diff --git a/test/sun/security/mscapi/PublicKeyInterop.java b/test/sun/security/mscapi/PublicKeyInterop.java
index 53d5b0946811dfbf659a1249d946464123b0b369..a7570cdd81883367cbe602d784fa460e194b13ca 100644
--- a/test/sun/security/mscapi/PublicKeyInterop.java
+++ b/test/sun/security/mscapi/PublicKeyInterop.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -38,8 +38,6 @@ import sun.misc.HexDumpEncoder;
 public class PublicKeyInterop {
 
     public static void main(String[] arg) throws Exception {
-        PrivateKey privKey = null;
-        Certificate cert = null;
         KeyStore ks = KeyStore.getInstance("Windows-MY");
         ks.load(null, null);
         System.out.println("Loaded keystore: Windows-MY");
diff --git a/test/sun/security/mscapi/PublicKeyInterop.sh b/test/sun/security/mscapi/PublicKeyInterop.sh
index abdad4c6530ca3eba6b89910e24a2b0148e9442d..dee609bec60bbb267d7fd864ec696ade6d949fe1 100644
--- a/test/sun/security/mscapi/PublicKeyInterop.sh
+++ b/test/sun/security/mscapi/PublicKeyInterop.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 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
@@ -25,6 +25,7 @@
 
 # @test
 # @bug 6888925
+# @requires os.family == "windows"
 # @run shell PublicKeyInterop.sh
 # @summary SunMSCAPI's Cipher can't use RSA public keys obtained from other
 #          sources.
diff --git a/test/sun/security/mscapi/RSAEncryptDecrypt.sh b/test/sun/security/mscapi/RSAEncryptDecrypt.sh
index ed17bd1159e11f0a6030caa215f0fb0d36ae0575..9c5efb656b80bc2830eeaaea4652c9b84c152b40 100644
--- a/test/sun/security/mscapi/RSAEncryptDecrypt.sh
+++ b/test/sun/security/mscapi/RSAEncryptDecrypt.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 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
@@ -25,6 +25,7 @@
 
 # @test
 # @bug 6457422 6931562
+# @requires os.family == "windows"
 # @run shell RSAEncryptDecrypt.sh
 # @summary Confirm that plaintext can be encrypted and then decrypted using the
 #	   RSA cipher in the SunMSCAPI crypto provider. NOTE: The RSA cipher is 
diff --git a/test/sun/security/mscapi/ShortRSAKey1024.sh b/test/sun/security/mscapi/ShortRSAKey1024.sh
index 05db70e1a3ec0f02fe394f9f74c1827528452a01..ab77ba20ad4cbb2647f0010c87162477bc07989b 100644
--- a/test/sun/security/mscapi/ShortRSAKey1024.sh
+++ b/test/sun/security/mscapi/ShortRSAKey1024.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012, 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
@@ -27,6 +27,7 @@
 # @test
 # @bug 7106773
 # @summary 512 bits RSA key cannot work with SHA384 and SHA512
+# @requires os.family == "windows"
 # @run shell ShortRSAKey1024.sh 1024
 # @run shell ShortRSAKey1024.sh 768
 # @run shell ShortRSAKey1024.sh 512
diff --git a/test/sun/security/mscapi/ShortRSAKeyWithinTLS.java b/test/sun/security/mscapi/ShortRSAKeyWithinTLS.java
index 8958718ae7aaf5f39843acc67f3aff918358647b..f2a752599ebcc7bf6979b8aed5b1d3a7b3dd6e5d 100644
--- a/test/sun/security/mscapi/ShortRSAKeyWithinTLS.java
+++ b/test/sun/security/mscapi/ShortRSAKeyWithinTLS.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -22,12 +22,9 @@
  */
 
 import java.io.*;
-import java.net.*;
-import java.util.*;
 import java.security.*;
 import javax.net.*;
 import javax.net.ssl.*;
-import java.lang.reflect.*;
 
 import sun.security.util.KeyUtil;
 
diff --git a/test/sun/security/mscapi/SignUsingNONEwithRSA.java b/test/sun/security/mscapi/SignUsingNONEwithRSA.java
index 02cf4f67c80f3721e3b63fcb1be8e8ca4b867c8c..ec8c0c5f9e1faa161e98fb323c3a03ec70fadb7e 100644
--- a/test/sun/security/mscapi/SignUsingNONEwithRSA.java
+++ b/test/sun/security/mscapi/SignUsingNONEwithRSA.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -118,12 +118,12 @@ public class SignUsingNONEwithRSA {
         ks.load(null, null);
         System.out.println("Loaded keystore: Windows-MY");
 
-        Enumeration e = ks.aliases();
+        Enumeration e = ks.aliases();
         PrivateKey privateKey = null;
         PublicKey publicKey = null;
 
         while (e.hasMoreElements()) {
-            String alias = (String) e.nextElement();
+            String alias = e.nextElement();
             if (alias.equals("6578658")) {
                 System.out.println("Loaded entry: " + alias);
                 privateKey = (PrivateKey) ks.getKey(alias, null);
diff --git a/test/sun/security/mscapi/SignUsingNONEwithRSA.sh b/test/sun/security/mscapi/SignUsingNONEwithRSA.sh
index f794e298d186554fa53445aa6b22021349b044b7..9ad08b2d2652da59ccf1665c945eb60b47b3f079 100644
--- a/test/sun/security/mscapi/SignUsingNONEwithRSA.sh
+++ b/test/sun/security/mscapi/SignUsingNONEwithRSA.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 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
@@ -26,6 +26,7 @@
 
 # @test
 # @bug 6578658
+# @requires os.family == "windows"
 # @run shell SignUsingNONEwithRSA.sh
 # @summary Sign using the NONEwithRSA signature algorithm from SunMSCAPI
 
diff --git a/test/sun/security/mscapi/SignUsingSHA2withRSA.java b/test/sun/security/mscapi/SignUsingSHA2withRSA.java
index 6835bd3f959ac6e951af2a3ad43af0e620239432..90973ecce4d5439d23e6e5f3da287f536d5c4b13 100644
--- a/test/sun/security/mscapi/SignUsingSHA2withRSA.java
+++ b/test/sun/security/mscapi/SignUsingSHA2withRSA.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -58,12 +58,12 @@ public class SignUsingSHA2withRSA {
         ks.load(null, null);
         System.out.println("Loaded keystore: Windows-MY");
 
-        Enumeration e = ks.aliases();
+        Enumeration e = ks.aliases();
         PrivateKey privateKey = null;
         PublicKey publicKey = null;
 
         while (e.hasMoreElements()) {
-            String alias = (String) e.nextElement();
+            String alias = e.nextElement();
             if (alias.equals("6753664")) {
                 System.out.println("Loaded entry: " + alias);
                 privateKey = (PrivateKey) ks.getKey(alias, null);
diff --git a/test/sun/security/mscapi/SignUsingSHA2withRSA.sh b/test/sun/security/mscapi/SignUsingSHA2withRSA.sh
index 2d433f108f015f10c6ffc97232b91ca2f9b943da..8e526aea02d45eebf303a2ace3164f05b0328720 100644
--- a/test/sun/security/mscapi/SignUsingSHA2withRSA.sh
+++ b/test/sun/security/mscapi/SignUsingSHA2withRSA.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 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
@@ -26,6 +26,7 @@
 
 # @test
 # @bug 6753664
+# @requires os.family == "windows"
 # @run shell SignUsingSHA2withRSA.sh
 # @summary Support SHA256 (and higher) in SunMSCAPI
 
diff --git a/test/sun/security/mscapi/SmallPrimeExponentP.java b/test/sun/security/mscapi/SmallPrimeExponentP.java
index 88c3bbeda8d9887c9387d793cc8ec4e348f1716c..3a9eed973cb1b2721e2ae174d8585155b87aef6c 100644
--- a/test/sun/security/mscapi/SmallPrimeExponentP.java
+++ b/test/sun/security/mscapi/SmallPrimeExponentP.java
@@ -28,13 +28,12 @@ import java.security.KeyStore;
 import java.security.SecureRandom;
 import java.security.cert.X509Certificate;
 import java.security.interfaces.RSAPrivateCrtKey;
-import java.util.HashSet;
-import java.util.Set;
 
 /*
  * @test
  * @bug 8023546
  * @summary sun/security/mscapi/ShortRSAKey1024.sh fails intermittently
+ * @requires os.family == "windows"
  */
 public class SmallPrimeExponentP {
 
diff --git a/test/sun/security/provider/X509Factory/BadPem.java b/test/sun/security/provider/X509Factory/BadPem.java
new file mode 100644
index 0000000000000000000000000000000000000000..a2ec873e83cda329fe8bb62671c14a48dc298b42
--- /dev/null
+++ b/test/sun/security/provider/X509Factory/BadPem.java
@@ -0,0 +1,76 @@
+/*
+ * 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 8074935
+ * @summary jdk8 keytool doesn't validate pem files for RFC 1421 correctness, as jdk7 did
+ */
+
+import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.PrintStream;
+import java.security.KeyStore;
+import java.security.cert.CertificateException;
+import java.util.Arrays;
+import java.util.Base64;
+
+import sun.security.provider.X509Factory;
+import java.security.cert.CertificateFactory;
+import java.io.ByteArrayInputStream;
+
+public class BadPem {
+
+    public static void main(String[] args) throws Exception {
+        String ks = System.getProperty("test.src", ".")
+                + "/../../ssl/etc/keystore";
+        String pass = "passphrase";
+        String alias = "dummy";
+
+        KeyStore keyStore = KeyStore.getInstance("JKS");
+        keyStore.load(new FileInputStream(ks), pass.toCharArray());
+        byte[] cert = keyStore.getCertificate(alias).getEncoded();
+
+        ByteArrayOutputStream bout = new ByteArrayOutputStream();
+        PrintStream pout = new PrintStream(bout);
+        byte[] CRLF = new byte[] {'\r', '\n'};
+        pout.println(X509Factory.BEGIN_CERT);
+        for (int i=0; i i + 48) ? 48 : (cert.length - i);
+            pout.println("!" + Base64.getEncoder()
+                    .encodeToString(Arrays.copyOfRange(cert, i, i + blockLen)));
+        }
+        pout.println(X509Factory.END_CERT);
+
+        CertificateFactory cf = CertificateFactory.getInstance("X.509");
+
+        try {
+            cf.generateCertificate(new ByteArrayInputStream(bout.toByteArray()));
+            throw new Exception("Should fail");
+        } catch (CertificateException e) {
+            // Good
+        }
+    }
+}
+
diff --git a/test/sun/security/tools/keytool/KeyToolTest.java b/test/sun/security/tools/keytool/KeyToolTest.java
index e86af93ea24dd7e97fb2598252015a3175043fb8..3a088ba9d02e878293bee0570365f98bf5ba9b66 100644
--- a/test/sun/security/tools/keytool/KeyToolTest.java
+++ b/test/sun/security/tools/keytool/KeyToolTest.java
@@ -55,6 +55,8 @@
  * NSS PKCS11 config file are changed, DSA not supported now.
  */
 
+import java.nio.file.Files;
+import java.nio.file.Paths;
 import java.security.KeyStore;
 import sun.security.x509.*;
 import java.io.*;
@@ -844,6 +846,24 @@ public class KeyToolTest {
         remove("mykey.cert");
     }
 
+    // 8074935: jdk8 keytool doesn't validate pem files for RFC 1421 correctness
+    static void checkPem(String file) throws Exception {
+        boolean maybeLast = false;
+        for (String s: Files.readAllLines(Paths.get(file))) {
+            if (s.isEmpty()) continue;
+            if (s.startsWith("---")) continue;
+            if (maybeLast) {
+                throw new Exception("Last line already seen");
+            }
+            if (s.length() > 64) {
+                throw new Exception(s);
+            }
+            if (s.length() < 64) {
+                maybeLast = true;
+            }
+        }
+    }
+
     void v3extTest(String keyAlg) throws Exception {
         KeyStore ks;
         remove("x.jks");
@@ -1153,11 +1173,14 @@ public class KeyToolTest {
                 "-rfc -file test.req");
         // printcertreq
         testOK("", "-printcertreq -file test.req");
-        // issue: deny KU, change criticality of 1.2.3 and 1.2.4, change content of BC, add 2.3.4
+        checkPem("test.req");
+        // issue: deny KU, change criticality of 1.2.3 and 1.2.4,
+        // change content of BC, add 2.3.4
         testOK("", simple+"-gencert -alias ca -infile test.req -ext " +
                 "honored=all,-KU,1.2.3:critical,1.2.4:non-critical " +
                 "-ext BC=2 -ext 2.3.4=01020304 " +
                 "-debug -rfc -outfile test.cert");
+        checkPem("test.cert");
         testOK("", simple+"-importcert -file test.cert -alias a");
         ks = loadStore("x.jks", "changeit", "JKS");
         X509CertImpl a = (X509CertImpl)ks.getCertificate("a");