Mercurial > hg > jdk9-shenandoah > jdk
changeset 12715:18334b51a447
Merge
author | amurillo |
---|---|
date | Tue, 08 Sep 2015 15:39:53 -0700 |
parents | 4e631cc0c9e0 (current diff) cef7f168def1 (diff) |
children | 816559b6e51b |
files | |
diffstat | 76 files changed, 2081 insertions(+), 740 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgtags Thu Sep 03 15:48:24 2015 -0700 +++ b/.hgtags Tue Sep 08 15:39:53 2015 -0700 @@ -322,3 +322,4 @@ 7fd081100f48828431e7c1bff65c906ee759069b jdk9-b77 0940ce86c614458f5bdd72278b190abbf36b7b45 jdk9-b78 d99c2ffdd0f15753e69126583688f2f075a0a5e8 jdk9-b79 +4947810137ae53abba3028cc366af953d90fa81a jdk9-b80
--- a/make/mapfiles/libj2ucrypto/mapfile-vers Thu Sep 03 15:48:24 2015 -0700 +++ b/make/mapfiles/libj2ucrypto/mapfile-vers Tue Sep 08 15:39:53 2015 -0700 @@ -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 @@ -39,6 +39,7 @@ Java_com_oracle_security_ucrypto_NativeCipher_nativeUpdate; Java_com_oracle_security_ucrypto_NativeCipher_nativeFinal; Java_com_oracle_security_ucrypto_NativeKey_nativeFree; + Java_com_oracle_security_ucrypto_NativeKey_00024RSAPrivate_nativeInit; Java_com_oracle_security_ucrypto_NativeKey_00024RSAPrivateCrt_nativeInit; Java_com_oracle_security_ucrypto_NativeKey_00024RSAPublic_nativeInit; Java_com_oracle_security_ucrypto_NativeRSASignature_nativeInit; @@ -56,6 +57,7 @@ JavaCritical_com_oracle_security_ucrypto_NativeCipher_nativeUpdate; JavaCritical_com_oracle_security_ucrypto_NativeCipher_nativeFinal; JavaCritical_com_oracle_security_ucrypto_NativeKey_nativeFree; + JavaCritical_com_oracle_security_ucrypto_NativeKey_00024RSAPrivate_nativeInit; JavaCritical_com_oracle_security_ucrypto_NativeKey_00024RSAPrivateCrt_nativeInit; JavaCritical_com_oracle_security_ucrypto_NativeKey_00024RSAPublic_nativeInit; JavaCritical_com_oracle_security_ucrypto_NativeRSASignature_nativeInit;
--- a/src/java.base/share/classes/sun/security/provider/certpath/OCSPNonceExtension.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.base/share/classes/sun/security/provider/certpath/OCSPNonceExtension.java Tue Sep 08 15:39:53 2015 -0700 @@ -26,15 +26,13 @@ package sun.security.provider.certpath; import java.io.IOException; -import java.io.OutputStream; -import java.util.Enumeration; +import java.util.Objects; import java.security.SecureRandom; -import sun.security.x509.AttributeNameEnumeration; -import sun.security.x509.CertAttrSet; import sun.security.x509.Extension; import sun.security.x509.PKIXExtensions; -import sun.security.util.*; +import sun.security.util.Debug; +import sun.security.util.DerValue; /** * Represent the OCSP Nonce Extension. @@ -43,252 +41,139 @@ * and help to prevent replay attacks (see RFC 6960, section 4.4.1). * * @see Extension - * @see CertAttrSet */ -public class OCSPNonceExtension extends Extension -implements CertAttrSet<String> { +public final class OCSPNonceExtension extends Extension { /** * Attribute name. */ - public static final String NAME = "OCSPNonce"; - public static final String NONCE = "nonce"; - + private static final String EXTENSION_NAME = "OCSPNonce"; private byte[] nonceData = null; - private String extensionName; - - /** - * Encode this extension value to DER and assign it to the - * {@code extensionName} data member. - * - * @throws IOException if any errors occur during DER encoding - */ - private void encodeInternal() throws IOException { - if (nonceData == null) { - this.extensionValue = null; - return; - } - DerOutputStream os = new DerOutputStream(); - os.putOctetString(this.nonceData); - this.extensionValue = os.toByteArray(); - } /** * Create a {@code OCSPNonceExtension} by providing the nonce length. - * The criticality is set to false. The random bytes will be generated - * using the SUN provider. + * The criticality is set to false, and the OID for the extension will + * be the value defined by "id-pkix-ocsp-nonce" from RFC 6960. * * @param length the number of random bytes composing the nonce * * @throws IOException if any errors happen during encoding of the * extension. + * @throws IllegalArgumentException if length is not a positive integer. */ public OCSPNonceExtension(int length) throws IOException { - this(PKIXExtensions.OCSPNonce_Id, false, length, NAME); - } - - /** - * Creates the extension (also called by the subclass). - * - * @param extensionId the {@code ObjectIdentifier} for the OCSP Nonce - * extension - * @param isCritical a boolean flag indicating if the criticality bit - * is to be set for this extension - * @param length the length of the nonce in bytes - * @param extensionName the name of the extension - * - * @throws IOException if any errors happen during encoding of the - * extension. - */ - protected OCSPNonceExtension(ObjectIdentifier extensionId, - boolean isCritical, int length, String extensionName) - throws IOException { - SecureRandom rng = new SecureRandom(); - this.nonceData = new byte[length]; - rng.nextBytes(nonceData); - this.extensionId = extensionId; - this.critical = isCritical; - this.extensionName = extensionName; - encodeInternal(); - } - - /** - * Create the extension using the provided criticality bit setting and - * DER encoding. - * - * @param critical true if the extension is to be treated as critical. - * @param value an array of DER encoded bytes of the extnValue for the - * extension. It must not include the encapsulating OCTET STRING - * tag and length. For an {@code OCSPNonceExtension} the data value - * should be a simple OCTET STRING containing random bytes - * (see RFC 6960, section 4.4.1). - * - * @throws ClassCastException if value is not an array of bytes - * @throws IOException if any errors happen during encoding of the - * extension - */ - public OCSPNonceExtension(Boolean critical, Object value) - throws IOException { - this(PKIXExtensions.OCSPNonce_Id, critical, value, NAME); + this(false, length); } /** - * Creates the extension (also called by the subclass). - * - * @param extensionId the {@code ObjectIdentifier} for the OCSP Nonce - * extension - * @param critical a boolean flag indicating if the criticality bit - * is to be set for this extension - * @param value an array of DER encoded bytes of the extnValue for the - * extension. It must not include the encapsulating OCTET STRING - * tag and length. For an {@code OCSPNonceExtension} the data value - * should be a simple OCTET STRING containing random bytes - * (see RFC 6960, section 4.4.1). - * @param extensionName the name of the extension + * Create a {@code OCSPNonceExtension} by providing the nonce length and + * criticality setting. The OID for the extension will + * be the value defined by "id-pkix-ocsp-nonce" from RFC 6960. * - * @throws ClassCastException if value is not an array of bytes - * @throws IOException if any errors happen during encoding of the - * extension - */ - protected OCSPNonceExtension(ObjectIdentifier extensionId, - Boolean critical, Object value, String extensionName) - throws IOException { - this.extensionId = extensionId; - this.critical = critical; - this.extensionValue = (byte[]) value; - DerValue val = new DerValue(this.extensionValue); - this.nonceData = val.getOctetString(); - this.extensionName = extensionName; - } - - /** - * Set the attribute value. - * - * @param name the name of the attribute. - * @param obj an array of nonce bytes for the extension. It must not - * contain any DER tags or length. + * @param isCritical a boolean flag indicating whether the criticality bit + * is set for this extension + * @param length the number of random bytes composing the nonce * - * @throws IOException if an unsupported name is provided or the supplied - * {@code obj} is not a byte array + * @throws IOException if any errors happen during encoding of the + * extension. + * @throws IllegalArgumentException if length is not a positive integer. */ - @Override - public void set(String name, Object obj) throws IOException { - if (name.equalsIgnoreCase(NONCE)) { - if (!(obj instanceof byte[])) { - throw new IOException("Attribute must be of type byte[]."); - } - nonceData = (byte[])obj; - } else { - throw new IOException("Attribute name not recognized by" - + " CertAttrSet:" + extensionName + "."); - } - encodeInternal(); - } + public OCSPNonceExtension(boolean isCritical, int length) + throws IOException { + this.extensionId = PKIXExtensions.OCSPNonce_Id; + this.critical = isCritical; - /** - * Get the attribute value. - * - * @param name the name of the attribute to retrieve. Only "OCSPNonce" - * is currently supported. - * - * @return an array of bytes that are the nonce data. It will not contain - * any DER tags or length, only the random nonce bytes. - * - * @throws IOException if an unsupported name is provided. - */ - @Override - public Object get(String name) throws IOException { - if (name.equalsIgnoreCase(NONCE)) { - return nonceData; + if (length > 0) { + SecureRandom rng = new SecureRandom(); + this.nonceData = new byte[length]; + rng.nextBytes(nonceData); + this.extensionValue = new DerValue(DerValue.tag_OctetString, + nonceData).toByteArray(); } else { - throw new IOException("Attribute name not recognized by" - + " CertAttrSet:" + extensionName + "."); + throw new IllegalArgumentException( + "Length must be a positive integer"); } } /** - * Delete the attribute value. + * Create a {@code OCSPNonceExtension} by providing a nonce value. + * The criticality is set to false, and the OID for the extension will + * be the value defined by "id-pkix-ocsp-nonce" from RFC 6960. * - * @param name the name of the attribute to retrieve. Only "OCSPNonce" - * is currently supported. + * @param incomingNonce The nonce data to be set for the extension. This + * must be a non-null array of at least one byte long. * - * @throws IOException if an unsupported name is provided or an error - * occurs during re-encoding of the extension. + * @throws IOException if any errors happen during encoding of the + * extension. + * @throws IllegalArgumentException if the incomingNonce length is not a + * positive integer. + * @throws NullPointerException if the incomingNonce is null. */ - @Override - public void delete(String name) throws IOException { - if (name.equalsIgnoreCase(NONCE)) { - nonceData = null; + public OCSPNonceExtension(byte[] incomingNonce) throws IOException { + this(false, incomingNonce); + } + + /** + * Create a {@code OCSPNonceExtension} by providing a nonce value and + * criticality setting. The OID for the extension will + * be the value defined by "id-pkix-ocsp-nonce" from RFC 6960. + * + * @param isCritical a boolean flag indicating whether the criticality bit + * is set for this extension + * @param incomingNonce The nonce data to be set for the extension. This + * must be a non-null array of at least one byte long. + * + * @throws IOException if any errors happen during encoding of the + * extension. + * @throws IllegalArgumentException if the incomingNonce length is not a + * positive integer. + * @throws NullPointerException if the incomingNonce is null. + */ + public OCSPNonceExtension(boolean isCritical, byte[] incomingNonce) + throws IOException { + this.extensionId = PKIXExtensions.OCSPNonce_Id; + this.critical = isCritical; + + Objects.requireNonNull(incomingNonce, "Nonce data must be non-null"); + if (incomingNonce.length > 0) { + this.nonceData = incomingNonce.clone(); + this.extensionValue = new DerValue(DerValue.tag_OctetString, + nonceData).toByteArray(); } else { - throw new IOException("Attribute name not recognized by" - + " CertAttrSet:" + extensionName + "."); + throw new IllegalArgumentException( + "Nonce data must be at least 1 byte in length"); } - encodeInternal(); + } + + /** + * Return the nonce bytes themselves, without any DER encoding. + * + * @return A copy of the underlying nonce bytes + */ + public byte[] getNonceValue() { + return nonceData.clone(); } /** * Returns a printable representation of the {@code OCSPNonceExtension}. + * + * @return a string representation of the extension. */ @Override public String toString() { - String s = super.toString() + extensionName + ": " + - ((nonceData == null) ? "" : Debug.toString(nonceData)) - + "\n"; - return (s); - } - - /** - * Write the extension to an {@code OutputStream} - * - * @param out the {@code OutputStream} to write the extension to. - * - * @throws IOException on encoding errors. - */ - @Override - public void encode(OutputStream out) throws IOException { - encode(out, PKIXExtensions.OCSPNonce_Id, this.critical); + StringBuilder sb = new StringBuilder(); + sb.append(super.toString()).append(EXTENSION_NAME).append(": "); + sb.append((nonceData == null) ? "" : Debug.toString(nonceData)); + sb.append("\n"); + return sb.toString(); } /** - * Write the extension to the DerOutputStream. + * Return the name of the extension as a {@code String} * - * @param out the {@code OutputStream} to write the extension to. - * @param extensionId the {@code ObjectIdentifier} used for this extension - * @param isCritical a flag indicating if the criticality bit is set for - * this extension. - * - * @throws IOException on encoding errors. + * @return the name of the extension */ - protected void encode(OutputStream out, ObjectIdentifier extensionId, - boolean isCritical) throws IOException { - - DerOutputStream tmp = new DerOutputStream(); - - if (this.extensionValue == null) { - this.extensionId = extensionId; - this.critical = isCritical; - encodeInternal(); - } - super.encode(tmp); - out.write(tmp.toByteArray()); - } - - /** - * Return an enumeration of names of attributes existing within this - * attribute. - */ - @Override - public Enumeration<String> getElements() { - AttributeNameEnumeration elements = new AttributeNameEnumeration(); - elements.addElement(NONCE); - return (elements.elements()); - } - - /** - * Return the name of this attribute. - */ - @Override public String getName() { - return (extensionName); + return EXTENSION_NAME; } }
--- a/src/java.base/share/native/libnet/InetAddress.c Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.base/share/native/libnet/InetAddress.c Tue Sep 08 15:39:53 2015 -0700 @@ -57,6 +57,7 @@ c = (*env)->FindClass(env,"java/net/InetAddress$InetAddressHolder"); CHECK_NULL(c); iac_class = (*env)->NewGlobalRef(env, c); + CHECK_NULL(iac_class); ia_holderID = (*env)->GetFieldID(env, ia_class, "holder", "Ljava/net/InetAddress$InetAddressHolder;"); CHECK_NULL(ia_holderID); ia_preferIPv6AddressID = (*env)->GetStaticFieldID(env, ia_class, "preferIPv6Address", "Z");
--- a/src/java.base/windows/native/libnet/DualStackPlainSocketImpl.c Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.base/windows/native/libnet/DualStackPlainSocketImpl.c Tue Sep 08 15:39:53 2015 -0700 @@ -45,9 +45,10 @@ jclass cls = (*env)->FindClass(env, "java/net/InetSocketAddress"); CHECK_NULL(cls); isa_class = (*env)->NewGlobalRef(env, cls); + CHECK_NULL(isa_class); isa_ctorID = (*env)->GetMethodID(env, cls, "<init>", "(Ljava/net/InetAddress;I)V"); - + CHECK_NULL(isa_ctorID); initInetAddressIDs(env); // implement read timeout with select.
--- a/src/java.datatransfer/share/classes/java/awt/datatransfer/MimeType.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.datatransfer/share/classes/java/awt/datatransfer/MimeType.java Tue Sep 08 15:39:53 2015 -0700 @@ -224,7 +224,7 @@ * Set the value to be associated with the given name, replacing * any previous association. * - * @throw IllegalArgumentException if parameter or value is illegal + * @throws IllegalArgumentException if parameter or value is illegal */ public void setParameter(String name, String value) { parameters.set(name, value); @@ -233,7 +233,7 @@ /** * Remove any value associated with the given name. * - * @throw IllegalArgumentException if parameter may not be deleted + * @throws IllegalArgumentException if parameter may not be deleted */ public void removeParameter(String name) { parameters.remove(name);
--- a/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxButton.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxButton.java Tue Sep 08 15:39:53 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, 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,6 +58,7 @@ this.list = list; setModel(new DefaultButtonModel() { + @Override public void setArmed(final boolean armed) { super.setArmed(isPressed() ? true : armed); } @@ -66,12 +67,13 @@ setEnabled(comboBox.isEnabled()); } + @Override public boolean isEnabled() { return comboBox == null ? true : comboBox.isEnabled(); } - @SuppressWarnings("deprecation") - public boolean isFocusTraversable() { + @Override + public boolean isFocusable() { return false; } @@ -92,6 +94,7 @@ return State.ACTIVE; } + @Override public void paintComponent(final Graphics g) { // Don't Paint the button as usual // super.paintComponent( g );
--- a/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameDockIconUI.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameDockIconUI.java Tue Sep 08 15:39:53 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, 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 @@ -303,7 +303,7 @@ } } - @SuppressWarnings("deprecation") + @Deprecated public void hide() { final Container parent = getParent(); final Rectangle r = this.getBounds();
--- a/src/java.desktop/macosx/classes/com/apple/laf/AquaLookAndFeel.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaLookAndFeel.java Tue Sep 08 15:39:53 2015 -0700 @@ -991,9 +991,7 @@ "Tree.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[]{"ESCAPE", "cancel"}),}; table.putDefaults(defaults); - - Object aaTextInfo = SwingUtilities2.AATextInfo.getAATextInfo(true); - table.put(SwingUtilities2.AA_TEXT_PROPERTY_KEY, aaTextInfo); + SwingUtilities2.putAATextInfo(true, table); } protected void initSystemColorDefaults(final UIDefaults table) {
--- a/src/java.desktop/macosx/classes/sun/java2d/OSXSurfaceData.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/macosx/classes/sun/java2d/OSXSurfaceData.java Tue Sep 08 15:39:53 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, 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 @@ -125,9 +125,8 @@ return fConfig; } - @SuppressWarnings("deprecation") protected void setBounds(int x, int y, int w, int h) { - fBounds.reshape(x, y, w, y + h); + fBounds.setBounds(x, y, w, y + h); } // START compositing support API
--- a/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLLayer.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/macosx/classes/sun/java2d/opengl/CGLLayer.java Tue Sep 08 15:39:53 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, 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 @@ -77,7 +77,7 @@ } public Object getDestination() { - return peer; + return peer.getTarget(); } public SurfaceData replaceSurfaceData() {
--- a/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java Tue Sep 08 15:39:53 2015 -0700 @@ -576,6 +576,14 @@ : getDefaultMaximizedBounds()); } + public Rectangle getMaximizedBounds() { + synchronized (getStateLock()) { + return (maximizedBounds == null) + ? getDefaultMaximizedBounds() + : maximizedBounds; + } + } + private void setPlatformMaximizedBounds(Rectangle bounds) { platformWindow.setMaximizedBounds( bounds.x, bounds.y,
--- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Tue Sep 08 15:39:53 2015 -0700 @@ -498,14 +498,9 @@ // to be sure that there are no setBounds requests in the queue. LWCToolkit.flushNativeSelectors(); this.normalBounds = peer.getBounds(); - - GraphicsConfiguration config = getPeer().getGraphicsConfiguration(); - Insets i = ((CGraphicsDevice)config.getDevice()).getScreenInsets(); - Rectangle toBounds = config.getBounds(); - setBounds(toBounds.x + i.left, - toBounds.y + i.top, - toBounds.width - i.left - i.right, - toBounds.height - i.top - i.bottom); + Rectangle maximizedBounds = peer.getMaximizedBounds(); + setBounds(maximizedBounds.x, maximizedBounds.y, + maximizedBounds.width, maximizedBounds.height); } }
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java Tue Sep 08 15:39:53 2015 -0700 @@ -26,7 +26,6 @@ package com.sun.java.swing.plaf.gtk; import java.awt.*; -import java.awt.event.*; import java.beans.*; import java.io.File; import java.lang.ref.*; @@ -41,6 +40,8 @@ import com.sun.java.swing.plaf.gtk.GTKConstants.PositionType; import com.sun.java.swing.plaf.gtk.GTKConstants.StateType; +import java.util.HashMap; +import java.util.Map; import sun.awt.SunToolkit; import sun.awt.UNIXToolkit; import sun.awt.OSInfo; @@ -61,7 +62,7 @@ * We should assume ON - or some variation of ON as no GTK desktop * ships with it OFF. */ - static Object aaTextInfo; + static Map<Object, Object> aaTextInfo; /** * Solaris, or Linux with Sun JDS in a CJK Locale. @@ -1337,7 +1338,9 @@ if (fallbackFont != null) { table.put("TitledBorder.font", fallbackFont); } - table.put(SwingUtilities2.AA_TEXT_PROPERTY_KEY, aaTextInfo); + if (aaTextInfo != null) { + table.putAll(aaTextInfo); + } } protected void initSystemColorDefaults(UIDefaults table) { @@ -1477,7 +1480,8 @@ * XRender. */ gtkAAFontSettingsCond = !isSunCJK && SwingUtilities2.isLocalDisplay(); - aaTextInfo = SwingUtilities2.AATextInfo.getAATextInfo(gtkAAFontSettingsCond); + aaTextInfo = new HashMap<>(2); + SwingUtilities2.putAATextInfo(gtkAAFontSettingsCond, aaTextInfo); } static ReferenceQueue<GTKLookAndFeel> queue = new ReferenceQueue<GTKLookAndFeel>();
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java Tue Sep 08 15:39:53 2015 -0700 @@ -39,6 +39,8 @@ import sun.swing.plaf.synth.SynthIcon; import com.sun.java.swing.plaf.gtk.GTKEngine.WidgetType; +import static java.awt.RenderingHints.KEY_TEXT_ANTIALIASING; +import static java.awt.RenderingHints.KEY_TEXT_LCD_CONTRAST; /** * @@ -115,10 +117,12 @@ @Override public void installDefaults(SynthContext context) { super.installDefaults(context); - if (!context.getRegion().isSubregion()) { - context.getComponent().putClientProperty( - SwingUtilities2.AA_TEXT_PROPERTY_KEY, - GTKLookAndFeel.aaTextInfo); + Map<Object, Object> aaTextInfo = GTKLookAndFeel.aaTextInfo; + if (aaTextInfo != null && !context.getRegion().isSubregion()) { + context.getComponent().putClientProperty(KEY_TEXT_ANTIALIASING, + aaTextInfo.get(KEY_TEXT_ANTIALIASING)); + context.getComponent().putClientProperty(KEY_TEXT_LCD_CONTRAST, + aaTextInfo.get(KEY_TEXT_LCD_CONTRAST)); } }
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java Tue Sep 08 15:39:53 2015 -0700 @@ -556,8 +556,7 @@ * for both client property and UIDefaults. * Also need to set up listeners for changes in these settings. */ - Object aaTextInfo = SwingUtilities2.AATextInfo.getAATextInfo(true); - table.put(SwingUtilities2.AA_TEXT_PROPERTY_KEY, aaTextInfo); + SwingUtilities2.putAATextInfo(true, table); this.aaSettings = new FontDesktopProperty(SunToolkit.DESKTOPFONTHINTS); } @@ -835,12 +834,12 @@ "InternalFrame.closeIcon", WindowsIconFactory.createFrameCloseIcon(), "InternalFrame.icon", - (LazyValue) t -> new Object[]{ + (LazyValue) t -> new WindowsInternalFrameTitlePane.ScalableIconUIResource(new Object[]{ // The constructor takes one arg: an array of UIDefaults.LazyValue // representing the icons SwingUtilities2.makeIcon(getClass(), BasicLookAndFeel.class, "icons/JavaCup16.png"), SwingUtilities2.makeIcon(getClass(), WindowsLookAndFeel.class, "icons/JavaCup32.png") - }, + }), // Internal Frame Auditory Cue Mappings "InternalFrame.closeSound", "win.sound.close", "InternalFrame.maximizeSound", "win.sound.maximize", @@ -2402,9 +2401,8 @@ } protected void updateUI() { - Object aaTextInfo = SwingUtilities2.AATextInfo.getAATextInfo(true); UIDefaults defaults = UIManager.getLookAndFeelDefaults(); - defaults.put(SwingUtilities2.AA_TEXT_PROPERTY_KEY, aaTextInfo); + SwingUtilities2.putAATextInfo(true, defaults); super.updateUI(); } }
--- a/src/java.desktop/share/classes/java/awt/MultipleGradientPaintContext.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/share/classes/java/awt/MultipleGradientPaintContext.java Tue Sep 08 15:39:53 2015 -0700 @@ -517,7 +517,7 @@ * * @param position the unmanipulated position, which will be mapped * into the range 0 to 1 - * @returns integer color to display + * @return integer color to display */ protected final int indexIntoGradientsArrays(float position) { // first, manipulate position value depending on the cycle method
--- a/src/java.desktop/share/classes/java/awt/Robot.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/share/classes/java/awt/Robot.java Tue Sep 08 15:39:53 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,13 +33,10 @@ import java.awt.image.Raster; import java.awt.image.WritableRaster; import java.awt.peer.RobotPeer; -import java.lang.reflect.InvocationTargetException; -import java.security.AccessController; import sun.awt.AWTPermissions; import sun.awt.ComponentFactory; import sun.awt.SunToolkit; -import sun.awt.OSInfo; import sun.awt.image.SunWritableRaster; /** @@ -558,28 +555,8 @@ */ public synchronized void waitForIdle() { checkNotDispatchThread(); - - try { - SunToolkit.flushPendingEvents(); - // 7185258: realSync() call blocks all DnD tests on OS X - if (AccessController.doPrivileged(OSInfo.getOSTypeAction()) == OSInfo.OSType.MACOSX) { - // post a dummy event to the queue so we know when - // all the events before it have been processed - EventQueue.invokeAndWait( new Runnable() { - public void run() { - // dummy implementation - } - } ); - } else { - ((SunToolkit) Toolkit.getDefaultToolkit()).realSync(); - } - } catch(InterruptedException ite) { - System.err.println("Robot.waitForIdle, non-fatal exception caught:"); - ite.printStackTrace(); - } catch(InvocationTargetException ine) { - System.err.println("Robot.waitForIdle, non-fatal exception caught:"); - ine.printStackTrace(); - } + SunToolkit.flushPendingEvents(); + ((SunToolkit) Toolkit.getDefaultToolkit()).realSync(); } private void checkNotDispatchThread() { @@ -593,6 +570,7 @@ * * @return the string representation. */ + @Override public synchronized String toString() { String params = "autoDelay = "+getAutoDelay()+", "+"autoWaitForIdle = "+isAutoWaitForIdle(); return getClass().getName() + "[ " + params + " ]";
--- a/src/java.desktop/share/classes/java/awt/Toolkit.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/share/classes/java/awt/Toolkit.java Tue Sep 08 15:39:53 2015 -0700 @@ -448,7 +448,7 @@ * * @param s the error message * @param e the original exception - * @throw the new AWTError including the cause (the original exception) + * @throws the new AWTError including the cause (the original exception) */ private static void newAWTError(Throwable e, String s) { AWTError newAWTError = new AWTError(s);
--- a/src/java.desktop/share/classes/javax/swing/JColorChooser.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/share/classes/javax/swing/JColorChooser.java Tue Sep 08 15:39:53 2015 -0700 @@ -133,13 +133,42 @@ * returns true. * @see java.awt.GraphicsEnvironment#isHeadless */ + public static Color showDialog(Component component, + String title, Color initialColor) throws HeadlessException { + return showDialog(component, title, initialColor, true); + } + + /** + * Shows a modal color-chooser dialog and blocks until the + * dialog is hidden. If the user presses the "OK" button, then + * this method hides/disposes the dialog and returns the selected color. + * If the user presses the "Cancel" button or closes the dialog without + * pressing "OK", then this method hides/disposes the dialog and returns + * <code>null</code>. + * + * @param component the parent <code>Component</code> for the dialog + * @param title the String containing the dialog's title + * @param initialColor the initial Color set when the color-chooser is shown + * @param colorTransparencySelectionEnabled true if the transparency of + * a color can be selected + * @return the selected color or <code>null</code> if the user opted out + * @exception HeadlessException if GraphicsEnvironment.isHeadless() + * returns true. + * @see java.awt.GraphicsEnvironment#isHeadless + */ @SuppressWarnings("deprecation") - public static Color showDialog(Component component, - String title, Color initialColor) throws HeadlessException { + public static Color showDialog(Component component, String title, + Color initialColor, boolean colorTransparencySelectionEnabled) + throws HeadlessException { final JColorChooser pane = new JColorChooser(initialColor != null? initialColor : Color.white); + for (AbstractColorChooserPanel ccPanel : pane.getChooserPanels()) { + ccPanel.setColorTransparencySelectionEnabled( + colorTransparencySelectionEnabled); + } + ColorTracker ok = new ColorTracker(pane); JDialog dialog = createDialog(component, title, true, pane, ok, null); @@ -150,7 +179,6 @@ return ok.getColor(); } - /** * Creates and returns a new dialog containing the specified * <code>ColorChooser</code> pane along with "OK", "Cancel", and "Reset"
--- a/src/java.desktop/share/classes/javax/swing/JComponent.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/share/classes/javax/swing/JComponent.java Tue Sep 08 15:39:53 2015 -0700 @@ -377,7 +377,8 @@ /** * AA text hints. */ - transient private Object aaTextInfo; + transient private Object aaHint; + transient private Object lcdRenderingHint; static Graphics safelyGetGraphics(Component c) { return safelyGetGraphics(c, SwingUtilities.getRoot(c)); @@ -616,6 +617,15 @@ */ public void updateUI() {} + /** + * Returns the look and feel delegate that renders this component. + * + * @return the {@code ComponentUI} object that renders this component + * @since 1.9 + */ + public ComponentUI getUI() { + return ui; + } /** * Sets the look and feel delegate for this component. @@ -655,8 +665,10 @@ uninstallUIAndProperties(); // aaText shouldn't persist between look and feels, reset it. - aaTextInfo = - UIManager.getDefaults().get(SwingUtilities2.AA_TEXT_PROPERTY_KEY); + aaHint = UIManager.getDefaults().get( + RenderingHints.KEY_TEXT_ANTIALIASING); + lcdRenderingHint = UIManager.getDefaults().get( + RenderingHints.KEY_TEXT_LCD_CONTRAST); ComponentUI oldUI = ui; ui = newUI; if (ui != null) { @@ -4048,8 +4060,10 @@ * @see #putClientProperty */ public final Object getClientProperty(Object key) { - if (key == SwingUtilities2.AA_TEXT_PROPERTY_KEY) { - return aaTextInfo; + if (key == RenderingHints.KEY_TEXT_ANTIALIASING) { + return aaHint; + } else if (key == RenderingHints.KEY_TEXT_LCD_CONTRAST) { + return lcdRenderingHint; } else if (key == SwingUtilities2.COMPONENT_UI_PROPERTY_KEY) { return ui; } @@ -4091,8 +4105,11 @@ * @see #addPropertyChangeListener */ public final void putClientProperty(Object key, Object value) { - if (key == SwingUtilities2.AA_TEXT_PROPERTY_KEY) { - aaTextInfo = value; + if (key == RenderingHints.KEY_TEXT_ANTIALIASING) { + aaHint = value; + return; + } else if (key == RenderingHints.KEY_TEXT_LCD_CONTRAST) { + lcdRenderingHint = value; return; } if (value == null && clientProperties == null) {
--- a/src/java.desktop/share/classes/javax/swing/JTabbedPane.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/share/classes/javax/swing/JTabbedPane.java Tue Sep 08 15:39:53 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -2304,8 +2304,10 @@ } public Rectangle getBounds() { - return parent.getUI().getTabBounds(parent, - parent.indexOfTab(title)); + int i = parent.indexOfTab(title); + // Check for no title. Even though that's a bug in the app we should + // inhibit an ArrayIndexOutOfBoundsException from getTabBounds. + return (i == -1) ? null : parent.getUI().getTabBounds(parent, i); } public void setBounds(Rectangle r) {
--- a/src/java.desktop/share/classes/javax/swing/colorchooser/AbstractColorChooserPanel.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/share/classes/javax/swing/colorchooser/AbstractColorChooserPanel.java Tue Sep 08 15:39:53 2015 -0700 @@ -50,6 +50,14 @@ @SuppressWarnings("serial") // Same-version serialization only public abstract class AbstractColorChooserPanel extends JPanel { + + /** + * Identifies that the transparency of the color (alpha value) can be + * selected + */ + public static final String TRANSPARENCY_ENABLED_PROPERTY + = "TransparencyEnabled"; + private final PropertyChangeListener enabledListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { Object value = event.getNewValue(); @@ -202,6 +210,40 @@ } /** + * Sets whether color chooser panel allows to select the transparency + * (alpha value) of a color. + * This method fires a property-changed event, using the string value of + * {@code TRANSPARENCY_ENABLED_PROPERTY} as the name + * of the property. + * + * <p>The value is a hint and may not be applicable to all types of chooser + * panel. + * + * <p>The default value is {@code true}. + * + * @param b true if the transparency of a color can be selected + * + * @beaninfo + * bound: true + * description: Sets the transparency of a color selection on or off. + * + * @see #isColorTransparencySelectionEnabled() + */ + public void setColorTransparencySelectionEnabled(boolean b){ + } + + /** + * Gets whether color chooser panel allows to select the transparency + * (alpha value) of a color. + * + * @return true if the transparency of a color can be selected + * @see #setColorTransparencySelectionEnabled(boolean) + */ + public boolean isColorTransparencySelectionEnabled(){ + return true; + } + + /** * Draws the panel. * @param g the <code>Graphics</code> object */
--- a/src/java.desktop/share/classes/javax/swing/colorchooser/ColorChooserPanel.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/share/classes/javax/swing/colorchooser/ColorChooserPanel.java Tue Sep 08 15:39:53 2015 -0700 @@ -176,6 +176,21 @@ return null; } + @Override + public void setColorTransparencySelectionEnabled(boolean b){ + boolean oldValue = isColorTransparencySelectionEnabled(); + if (b != oldValue) { + panel.setColorTransparencySelectionEnabled(b); + firePropertyChange(TRANSPARENCY_ENABLED_PROPERTY, + oldValue, b); + } + } + + @Override + public boolean isColorTransparencySelectionEnabled(){ + return panel.isColorTransparencySelectionEnabled(); + } + public void propertyChange(PropertyChangeEvent event) { ColorSelectionModel model = getColorSelectionModel(); if (model != null) {
--- a/src/java.desktop/share/classes/javax/swing/colorchooser/ColorPanel.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/share/classes/javax/swing/colorchooser/ColorPanel.java Tue Sep 08 15:39:53 2015 -0700 @@ -145,7 +145,7 @@ } void colorChanged() { - this.color = new Color(getColor(0), true); + this.color = new Color(getColor(0), isColorTransparencySelectionEnabled()); Object parent = getParent(); if (parent instanceof ColorChooserPanel) { ColorChooserPanel chooser = (ColorChooserPanel) parent; @@ -208,6 +208,17 @@ return this.model.getColor(this.values); } + void setColorTransparencySelectionEnabled(boolean b) { + if (spinners[model.getCount() - 1].isVisible() != b) { + spinners[model.getCount() - 1].setVisible(b); + colorChanged(); + } + } + + boolean isColorTransparencySelectionEnabled() { + return spinners[model.getCount() - 1].isVisible(); + } + private void setValue(int index) { this.values[index] = this.spinners[index].getValue(); }
--- a/src/java.desktop/share/classes/javax/swing/colorchooser/SlidingSpinner.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/share/classes/javax/swing/colorchooser/SlidingSpinner.java Tue Sep 08 15:39:53 2015 -0700 @@ -95,6 +95,10 @@ this.spinner.setVisible(visible); } + boolean isVisible() { + return this.slider.isVisible(); + } + public void stateChanged(ChangeEvent event) { if (!this.internal) { if (this.spinner == event.getSource()) {
--- a/src/java.desktop/share/classes/javax/swing/plaf/LayerUI.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/share/classes/javax/swing/plaf/LayerUI.java Tue Sep 08 15:39:53 2015 -0700 @@ -90,7 +90,7 @@ * and set the layer event mask to {@code 0} * in {@link #uninstallUI(javax.swing.JComponent)} after that. * By default this method calls the appropriate - * {@code process<event type>Event} + * {@code process<event} {@code type>Event} * method for the given class of event. * <p> * <b>Note:</b> Events are processed only for displayable {@code JLayer}s.
--- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java Tue Sep 08 15:39:53 2015 -0700 @@ -35,11 +35,11 @@ import java.beans.PropertyChangeListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyVetoException; +import static java.awt.RenderingHints.KEY_TEXT_ANTIALIASING; +import static java.awt.RenderingHints.KEY_TEXT_LCD_CONTRAST; import sun.swing.DefaultLookup; -import static sun.swing.SwingUtilities2.AA_TEXT_PROPERTY_KEY; - /** * The class that manages a basic title bar * <p> @@ -217,8 +217,10 @@ } private void updateProperties() { - final Object aaTextInfo = frame.getClientProperty(AA_TEXT_PROPERTY_KEY); - putClientProperty(AA_TEXT_PROPERTY_KEY, aaTextInfo); + putClientProperty(KEY_TEXT_ANTIALIASING, + frame.getClientProperty(KEY_TEXT_ANTIALIASING)); + putClientProperty(KEY_TEXT_LCD_CONTRAST, + frame.getClientProperty(KEY_TEXT_LCD_CONTRAST)); } /**
--- a/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java Tue Sep 08 15:39:53 2015 -0700 @@ -1514,8 +1514,7 @@ flushUnreferenced(); // Remove old listeners boolean lafCond = SwingUtilities2.isLocalDisplay(); - Object aaTextInfo = SwingUtilities2.AATextInfo.getAATextInfo(lafCond); - table.put(SwingUtilities2.AA_TEXT_PROPERTY_KEY, aaTextInfo); + SwingUtilities2.putAATextInfo(lafCond, table); new AATextListener(this); } @@ -2204,9 +2203,7 @@ } UIDefaults defaults = UIManager.getLookAndFeelDefaults(); boolean lafCond = SwingUtilities2.isLocalDisplay(); - Object aaTextInfo = - SwingUtilities2.AATextInfo.getAATextInfo(lafCond); - defaults.put(SwingUtilities2.AA_TEXT_PROPERTY_KEY, aaTextInfo); + SwingUtilities2.putAATextInfo(lafCond, defaults); updateUI(); }
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java Tue Sep 08 15:39:53 2015 -0700 @@ -688,8 +688,7 @@ // enabled antialiasing depending on desktop settings flushUnreferenced(); - Object aaTextInfo = getAATextInfo(); - table.put(SwingUtilities2.AA_TEXT_PROPERTY_KEY, aaTextInfo); + SwingUtilities2.putAATextInfo(useLAFConditions(), table); new AATextListener(this); if (defaultsMap != null) { @@ -794,7 +793,7 @@ * * @return the text antialiasing information associated to the desktop */ - private static Object getAATextInfo() { + private static boolean useLAFConditions() { String language = Locale.getDefault().getLanguage(); String desktop = AccessController.doPrivileged(new GetPropertyAction("sun.desktop")); @@ -805,10 +804,7 @@ boolean isGnome = "gnome".equals(desktop); boolean isLocal = SwingUtilities2.isLocalDisplay(); - boolean setAA = isLocal && (!isGnome || !isCjkLocale); - - Object aaTextInfo = SwingUtilities2.AATextInfo.getAATextInfo(setAA); - return aaTextInfo; + return isLocal && (!isGnome || !isCjkLocale); } private static ReferenceQueue<LookAndFeel> queue = new ReferenceQueue<LookAndFeel>(); @@ -844,8 +840,7 @@ return; } - Object aaTextInfo = getAATextInfo(); - defaults.put(SwingUtilities2.AA_TEXT_PROPERTY_KEY, aaTextInfo); + SwingUtilities2.putAATextInfo(useLAFConditions(), defaults); updateUI(); }
--- a/src/java.desktop/share/classes/javax/swing/text/rtf/RTFReader.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/share/classes/javax/swing/text/rtf/RTFReader.java Tue Sep 08 15:39:53 2015 -0700 @@ -298,8 +298,8 @@ * Handles a parameterless RTF keyword. This is called by the superclass * (RTFParser) when a keyword is found in the input stream. * - * @returns <code>true</code> if the keyword is recognized and handled; - * <code>false</code> otherwise + * @return true if the keyword is recognized and handled; + * false otherwise * @see RTFParser#handleKeyword */ public boolean handleKeyword(String keyword) @@ -444,8 +444,8 @@ * This is called by the superclass * (RTFParser) when a keyword is found in the input stream. * - * @returns <code>true</code> if the keyword is recognized and handled; - * <code>false</code> otherwise + * @return true if the keyword is recognized and handled; + * false otherwise * @see RTFParser#handleKeyword */ public boolean handleKeyword(String keyword, int parameter) @@ -553,7 +553,7 @@ * array of characters, mapping unsigned byte values to their Unicode * equivalents. The character set is loaded if necessary. * - * @returns the character set + * @return the character set */ public static Object getCharacterSet(final String name) @@ -577,7 +577,7 @@ * must contain 256 decimal integers, separated by whitespace, with * no punctuation. B- and C- style comments are allowed. * - * @returns the newly read character set + * @return the newly read character set */ static char[] readCharset(InputStream strm) throws IOException @@ -1349,7 +1349,7 @@ * Calculates the current text (character) attributes in a form suitable * for SwingText from the current parser state. * - * @returns a new MutableAttributeSet containing the text attributes. + * @return a new MutableAttributeSet containing the text attributes. */ MutableAttributeSet currentTextAttributes() { @@ -1410,7 +1410,7 @@ * Calculates the current paragraph attributes (with keys * as given in StyleConstants) from the current parser state. * - * @returns a newly created MutableAttributeSet. + * @return a newly created MutableAttributeSet. * @see StyleConstants */ MutableAttributeSet currentParagraphAttributes() @@ -1449,7 +1449,7 @@ * Calculates the current section attributes * from the current parser state. * - * @returns a newly created MutableAttributeSet. + * @return a newly created MutableAttributeSet. */ public AttributeSet currentSectionAttributes() {
--- a/src/java.desktop/share/classes/sun/awt/SunToolkit.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/share/classes/sun/awt/SunToolkit.java Tue Sep 08 15:39:53 2015 -0700 @@ -124,18 +124,7 @@ * @param appContext AppContext to associate with the event queue */ private static void initEQ(AppContext appContext) { - EventQueue eventQueue; - - String eqName = System.getProperty("AWT.EventQueueClass", - "java.awt.EventQueue"); - - try { - eventQueue = (EventQueue)Class.forName(eqName).newInstance(); - } catch (Exception e) { - e.printStackTrace(); - System.err.println("Failed loading " + eqName + ": " + e); - eventQueue = new EventQueue(); - } + EventQueue eventQueue = new EventQueue(); appContext.put(AppContext.EVENT_QUEUE_KEY, eventQueue); PostEventQueue postEventQueue = new PostEventQueue(eventQueue);
--- a/src/java.desktop/share/classes/sun/awt/shell/DefaultShellFolder.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/share/classes/sun/awt/shell/DefaultShellFolder.java Tue Sep 08 15:39:53 2015 -0700 @@ -50,7 +50,7 @@ * this default implementation can always be represented with a * <code>java.io.File</code> object instead. * - * @returns a <code>java.io.File</code> replacement object. + * @return a java.io.File replacement object. */ protected Object writeReplace() throws java.io.ObjectStreamException { return new File(getPath());
--- a/src/java.desktop/share/classes/sun/awt/shell/ShellFolder.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/share/classes/sun/awt/shell/ShellFolder.java Tue Sep 08 15:39:53 2015 -0700 @@ -67,8 +67,8 @@ * <code>java.io.File</code> instead. If not, then the object is most likely * depending on some internal (native) state and cannot be serialized. * - * @returns a <code>java.io.File</code> replacement object, or <code>null</code> - * if no suitable replacement can be found. + * @return a java.io.File replacement object, or null + * if no suitable replacement can be found. */ protected abstract Object writeReplace() throws java.io.ObjectStreamException;
--- a/src/java.desktop/share/classes/sun/print/PSPrinterJob.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/share/classes/sun/print/PSPrinterJob.java Tue Sep 08 15:39:53 2015 -0700 @@ -419,8 +419,8 @@ /** * Presents the user a dialog for changing properties of the * print job interactively. - * @returns false if the user cancels the dialog and - * true otherwise. + * @return false if the user cancels the dialog and + * true otherwise. * @exception HeadlessException if GraphicsEnvironment.isHeadless() * returns true. * @see java.awt.GraphicsEnvironment#isHeadless
--- a/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java Tue Sep 08 15:39:53 2015 -0700 @@ -964,8 +964,8 @@ /** * Presents the user a dialog for changing properties of the * print job interactively. - * @returns false if the user cancels the dialog and - * true otherwise. + * @return false if the user cancels the dialog and + * true otherwise. * @exception HeadlessException if GraphicsEnvironment.isHeadless() * returns true. * @see java.awt.GraphicsEnvironment#isHeadless
--- a/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java Tue Sep 08 15:39:53 2015 -0700 @@ -103,14 +103,6 @@ new FontRenderContext(null, false, false); /** - * A JComponent client property is used to determine text aa settings. - * To avoid having this property persist between look and feels changes - * the value of the property is set to null in JComponent.setUI - */ - public static final Object AA_TEXT_PROPERTY_KEY = - new StringBuffer("AATextInfoPropertyKey"); - - /** * Attribute key for the content elements. If it is set on an element, the * element is considered to be a line break. */ @@ -123,58 +115,23 @@ private static final StringBuilder SKIP_CLICK_COUNT = new StringBuilder("skipClickCount"); - /* Presently this class assumes default fractional metrics. - * This may need to change to emulate future platform L&Fs. - */ - public static class AATextInfo { - - private static AATextInfo getAATextInfoFromMap(Map<java.awt.RenderingHints.Key, Object> hints) { - - Object aaHint = hints.get(KEY_TEXT_ANTIALIASING); - Object contHint = hints.get(KEY_TEXT_LCD_CONTRAST); - - if (aaHint == null || - aaHint == VALUE_TEXT_ANTIALIAS_OFF || - aaHint == VALUE_TEXT_ANTIALIAS_DEFAULT) { - return null; - } else { - return new AATextInfo(aaHint, (Integer)contHint); - } - } + @SuppressWarnings("unchecked") + public static void putAATextInfo(boolean lafCondition, + Map<Object, Object> map) { + SunToolkit.setAAFontSettingsCondition(lafCondition); + Toolkit tk = Toolkit.getDefaultToolkit(); + Object desktopHints = tk.getDesktopProperty(SunToolkit.DESKTOPFONTHINTS); - @SuppressWarnings("unchecked") - public static AATextInfo getAATextInfo(boolean lafCondition) { - SunToolkit.setAAFontSettingsCondition(lafCondition); - Toolkit tk = Toolkit.getDefaultToolkit(); - Object map = tk.getDesktopProperty(SunToolkit.DESKTOPFONTHINTS); - if (map instanceof Map) { - return getAATextInfoFromMap((Map<java.awt.RenderingHints.Key, Object>)map); - } else { - return null; + if (desktopHints instanceof Map) { + Map<Object, Object> hints = (Map<Object, Object>) desktopHints; + Object aaHint = hints.get(KEY_TEXT_ANTIALIASING); + if (aaHint == null + || aaHint == VALUE_TEXT_ANTIALIAS_OFF + || aaHint == VALUE_TEXT_ANTIALIAS_DEFAULT) { + return; } - } - - Object aaHint; - Integer lcdContrastHint; - FontRenderContext frc; - - /* These are rarely constructed objects, and only when a complete - * UI is being updated, so the cost of the tests here is minimal - * and saves tests elsewhere. - * We test that the values are ones we support/expect. - */ - public AATextInfo(Object aaHint, Integer lcdContrastHint) { - if (aaHint == null) { - throw new InternalError("null not allowed here"); - } - if (aaHint == VALUE_TEXT_ANTIALIAS_OFF || - aaHint == VALUE_TEXT_ANTIALIAS_DEFAULT) { - throw new InternalError("AA must be on"); - } - this.aaHint = aaHint; - this.lcdContrastHint = lcdContrastHint; - this.frc = new FontRenderContext(null, aaHint, - VALUE_FRACTIONALMETRICS_DEFAULT); + map.put(KEY_TEXT_ANTIALIASING, aaHint); + map.put(KEY_TEXT_LCD_CONTRAST, hints.get(KEY_TEXT_LCD_CONTRAST)); } } @@ -241,22 +198,6 @@ // /** - * Returns whether or not text should be drawn antialiased. - * - * @param c JComponent to test. - * @return Whether or not text should be drawn antialiased for the - * specified component. - */ - public static AATextInfo drawTextAntialiased(JComponent c) { - if (c != null) { - /* a non-null property implies some form of AA requested */ - return (AATextInfo)c.getClientProperty(AA_TEXT_PROPERTY_KEY); - } - // No component, assume aa is off - return null; - } - - /** * Returns the left side bearing of the first character of string. The * left side bearing is calculated from the passed in * FontMetrics. If the passed in String is less than one @@ -530,7 +471,6 @@ // If we get here we're not printing if (g instanceof Graphics2D) { - AATextInfo info = drawTextAntialiased(c); Graphics2D g2 = (Graphics2D)g; boolean needsTextLayout = ((c != null) && @@ -543,21 +483,27 @@ } } - if (info != null) { + Object aaHint = (c == null) + ? null + : c.getClientProperty(KEY_TEXT_ANTIALIASING); + if (aaHint != null) { Object oldContrast = null; Object oldAAValue = g2.getRenderingHint(KEY_TEXT_ANTIALIASING); - if (info.aaHint != oldAAValue) { - g2.setRenderingHint(KEY_TEXT_ANTIALIASING, info.aaHint); + if (aaHint != oldAAValue) { + g2.setRenderingHint(KEY_TEXT_ANTIALIASING, aaHint); } else { oldAAValue = null; } - if (info.lcdContrastHint != null) { + + Object lcdContrastHint = c.getClientProperty( + KEY_TEXT_LCD_CONTRAST); + if (lcdContrastHint != null) { oldContrast = g2.getRenderingHint(KEY_TEXT_LCD_CONTRAST); - if (info.lcdContrastHint.equals(oldContrast)) { + if (lcdContrastHint.equals(oldContrast)) { oldContrast = null; } else { g2.setRenderingHint(KEY_TEXT_LCD_CONTRAST, - info.lcdContrastHint); + lcdContrastHint); } } @@ -821,24 +767,28 @@ } // Assume we're not printing if we get here, or that we are invoked // via Swing text printing which is laid out for the printer. - AATextInfo info = drawTextAntialiased(c); - if (info != null && (g instanceof Graphics2D)) { + Object aaHint = (c == null) + ? null + : c.getClientProperty(KEY_TEXT_ANTIALIASING); + if (aaHint != null && (g instanceof Graphics2D)) { Graphics2D g2 = (Graphics2D)g; Object oldContrast = null; Object oldAAValue = g2.getRenderingHint(KEY_TEXT_ANTIALIASING); - if (info.aaHint != null && info.aaHint != oldAAValue) { - g2.setRenderingHint(KEY_TEXT_ANTIALIASING, info.aaHint); + if (aaHint != null && aaHint != oldAAValue) { + g2.setRenderingHint(KEY_TEXT_ANTIALIASING, aaHint); } else { oldAAValue = null; } - if (info.lcdContrastHint != null) { + + Object lcdContrastHint = c.getClientProperty(KEY_TEXT_LCD_CONTRAST); + if (lcdContrastHint != null) { oldContrast = g2.getRenderingHint(KEY_TEXT_LCD_CONTRAST); - if (info.lcdContrastHint.equals(oldContrast)) { + if (lcdContrastHint.equals(oldContrast)) { oldContrast = null; } else { g2.setRenderingHint(KEY_TEXT_LCD_CONTRAST, - info.lcdContrastHint); + lcdContrastHint); } } @@ -1117,15 +1067,35 @@ */ private static FontRenderContext getFRCProperty(JComponent c) { if (c != null) { - AATextInfo info = - (AATextInfo)c.getClientProperty(AA_TEXT_PROPERTY_KEY); - if (info != null) { - return info.frc; + Object aaHint = c.getClientProperty(KEY_TEXT_ANTIALIASING); + if (aaHint != null) { + return getFRCFromCache(aaHint); } } return null; } + private static final Object APP_CONTEXT_FRC_CACHE_KEY = new Object(); + + private static FontRenderContext getFRCFromCache(Object aaHint) { + @SuppressWarnings("unchecked") + Map<Object, FontRenderContext> cache = (Map<Object, FontRenderContext>) + AppContext.getAppContext().get(APP_CONTEXT_FRC_CACHE_KEY); + + if (cache == null) { + cache = new HashMap<>(); + AppContext.getAppContext().put(APP_CONTEXT_FRC_CACHE_KEY, cache); + } + + FontRenderContext frc = cache.get(aaHint); + if (frc == null) { + frc = new FontRenderContext(null, aaHint, + VALUE_FRACTIONALMETRICS_DEFAULT); + cache.put(aaHint, frc); + } + return frc; + } + /* * returns true if the Graphics is print Graphics * false otherwise
--- a/src/java.desktop/unix/classes/sun/awt/X11/MotifDnDDragSourceProtocol.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/unix/classes/sun/awt/X11/MotifDnDDragSourceProtocol.java Tue Sep 08 15:39:53 2015 -0700 @@ -96,7 +96,7 @@ /** * Processes the specified client message event. * - * @returns true if the event was successfully processed. + * @return true if the event was successfully processed. */ public boolean processClientMessage(XClientMessageEvent xclient) { if (xclient.get_message_type() !=
--- a/src/java.desktop/unix/classes/sun/awt/X11/XDnDDragSourceProtocol.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/unix/classes/sun/awt/X11/XDnDDragSourceProtocol.java Tue Sep 08 15:39:53 2015 -0700 @@ -68,7 +68,7 @@ /** * Performs protocol-specific drag initialization. * - * @returns true if the initialized successfully. + * @return true if the initialized successfully. */ protected void initializeDragImpl(int actions, Transferable contents, Map<Long, DataFlavor> formatMap, long[] formats)
--- a/src/java.desktop/unix/classes/sun/awt/X11/XDragSourceContextPeer.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/unix/classes/sun/awt/X11/XDragSourceContextPeer.java Tue Sep 08 15:39:53 2015 -0700 @@ -379,7 +379,7 @@ /** * Updates the source action according to the specified state. * - * @returns true if the source + * @return true if the source */ private boolean updateSourceAction(int state) { int action = SunDragSourceContextPeer.convertModifiersToDropAction(XWindow.getModifiers(state, 0, 0), @@ -570,7 +570,7 @@ /** * The caller must own awtLock. * - * @returns true if the even was processed and shouldn't be passed along. + * @return true if the event was processed and shouldn't be passed along. */ private boolean doProcessEvent(XEvent ev) { assert XToolkit.isAWTLockHeldByCurrentThread();
--- a/src/java.desktop/unix/classes/sun/awt/X11/XDragSourceProtocol.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/unix/classes/sun/awt/X11/XDragSourceProtocol.java Tue Sep 08 15:39:53 2015 -0700 @@ -140,7 +140,7 @@ /** * Processes the specified client message event. * - * @returns true if the event was successfully processed. + * @return true if the event was successfully processed. */ public abstract boolean processClientMessage(XClientMessageEvent xclient) throws XException;
--- a/src/java.desktop/unix/classes/sun/awt/X11InputMethod.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/unix/classes/sun/awt/X11InputMethod.java Tue Sep 08 15:39:53 2015 -0700 @@ -293,7 +293,7 @@ /** * Query and then return the current composition state. - * @returns the composition state if isCompositionEnabled call + * @return the composition state if isCompositionEnabled call * is successful. Otherwise, it returns false. */ private boolean getCompositionState() {
--- a/src/java.desktop/windows/classes/sun/awt/Win32GraphicsEnvironment.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/windows/classes/sun/awt/Win32GraphicsEnvironment.java Tue Sep 08 15:39:53 2015 -0700 @@ -97,14 +97,14 @@ * Returns the number of pixels per logical inch along the screen width. * In a system with multiple display monitors, this value is the same for * all monitors. - * @returns number of pixels per logical inch in X direction + * @return number of pixels per logical inch in X direction */ public native int getXResolution(); /** * Returns the number of pixels per logical inch along the screen height. * In a system with multiple display monitors, this value is the same for * all monitors. - * @returns number of pixels per logical inch in Y direction + * @return number of pixels per logical inch in Y direction */ public native int getYResolution();
--- a/src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java Tue Sep 08 15:39:53 2015 -0700 @@ -556,8 +556,8 @@ /** * Presents the user a dialog for changing properties of the * print job interactively. - * @returns false if the user cancels the dialog and - * true otherwise. + * @return false if the user cancels the dialog and + * true otherwise. * @exception HeadlessException if GraphicsEnvironment.isHeadless() * returns true. * @see java.awt.GraphicsEnvironment#isHeadless
--- a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DScreenUpdateManager.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DScreenUpdateManager.java Tue Sep 08 15:39:53 2015 -0700 @@ -201,8 +201,8 @@ * - it's one of the classes likely to have custom rendering worth * accelerating * - * @returns true if we can use a d3d surface for this peer's onscreen - * rendering + * @return true if we can use a d3d surface for this peer's onscreen + * rendering */ public static boolean canUseD3DOnScreen(final WComponentPeer peer, final Win32GraphicsConfig gc,
--- a/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeKey.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeKey.java Tue Sep 08 15:39:53 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,19 +31,9 @@ import java.lang.ref.*; import java.math.BigInteger; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.security.Key; -import java.security.PublicKey; -import java.security.PrivateKey; -import java.security.KeyFactorySpi; -import java.security.interfaces.RSAPrivateCrtKey; -import java.security.interfaces.RSAPublicKey; - -import java.security.spec.InvalidKeySpecException; -import java.security.spec.KeySpec; -import java.security.spec.RSAPrivateCrtKeySpec; -import java.security.spec.RSAPublicKeySpec; +import java.security.*; +import java.security.interfaces.*; +import java.security.spec.*; /** * Wrapper class for native keys needed for using ucrypto APIs. @@ -87,6 +77,41 @@ return b; } + static final class RSAPrivate extends NativeKey implements RSAPrivateKey { + + private static final long serialVersionUID = 1622705588904302831L; + + private final RSAPrivateKeySpec keySpec; + private final long keyId; + + RSAPrivate(KeySpec keySpec) throws InvalidKeySpecException { + super(2); + long pKey = 0L; + if (keySpec instanceof RSAPrivateKeySpec) { + RSAPrivateKeySpec ks = (RSAPrivateKeySpec) keySpec; + BigInteger mod = ks.getModulus(); + BigInteger privateExp = ks.getPrivateExponent(); + pKey = nativeInit(NativeKey.getMagnitude(mod), + NativeKey.getMagnitude(privateExp)); + } else { + throw new InvalidKeySpecException("Only supports RSAPrivateKeySpec"); + } + if (pKey == 0L) { + throw new UcryptoException("Error constructing RSA PrivateKey"); + } + // track native resource clean up + new KeyRef(this, pKey); + this.keySpec = (RSAPrivateKeySpec) keySpec; + this.keyId = pKey; + } + + long value() { return keyId; } + public BigInteger getModulus() { return keySpec.getModulus(); }; + public BigInteger getPrivateExponent() { return keySpec.getPrivateExponent(); }; + + private native static long nativeInit(byte[] mod, byte[] privExp); + } + static final class RSAPrivateCrt extends NativeKey implements RSAPrivateCrtKey { private static final long serialVersionUID = 6812507588904302831L; @@ -119,7 +144,7 @@ throw new InvalidKeySpecException("Only supports RSAPrivateCrtKeySpec"); } if (pKey == 0L) { - throw new UcryptoException("Error constructing RSA PrivateKey"); + throw new UcryptoException("Error constructing RSA PrivateCrtKey"); } // track native resource clean up new KeyRef(this, pKey);
--- a/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSACipher.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSACipher.java Tue Sep 08 15:39:53 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,9 +37,11 @@ import java.security.PublicKey; import java.security.PrivateKey; import java.security.spec.RSAPrivateCrtKeySpec; +import java.security.spec.RSAPrivateKeySpec; import java.security.spec.RSAPublicKeySpec; import java.security.interfaces.RSAKey; import java.security.interfaces.RSAPrivateCrtKey; +import java.security.interfaces.RSAPrivateKey; import java.security.interfaces.RSAPublicKey; import java.security.KeyFactory; @@ -205,8 +207,8 @@ // Make sure the proper opmode uses the proper key if (doEncrypt && (!(newKey instanceof RSAPublicKey))) { throw new InvalidKeyException("RSAPublicKey required for encryption"); - } else if (!doEncrypt && (!(newKey instanceof RSAPrivateCrtKey))) { - throw new InvalidKeyException("RSAPrivateCrtKey required for decryption"); + } else if (!doEncrypt && (!(newKey instanceof RSAPrivateKey))) { + throw new InvalidKeyException("RSAPrivateKey required for decryption"); } NativeKey nativeKey = null; @@ -223,17 +225,26 @@ throw new InvalidKeyException(ikse); } } else { - RSAPrivateCrtKey privateKey = (RSAPrivateCrtKey) newKey; try { - nativeKey = (NativeKey) keyFactory.engineGeneratePrivate - (new RSAPrivateCrtKeySpec(privateKey.getModulus(), - privateKey.getPublicExponent(), - privateKey.getPrivateExponent(), - privateKey.getPrimeP(), - privateKey.getPrimeQ(), - privateKey.getPrimeExponentP(), - privateKey.getPrimeExponentQ(), - privateKey.getCrtCoefficient())); + if (newKey instanceof RSAPrivateCrtKey) { + RSAPrivateCrtKey privateKey = (RSAPrivateCrtKey) newKey; + nativeKey = (NativeKey) keyFactory.engineGeneratePrivate + (new RSAPrivateCrtKeySpec(privateKey.getModulus(), + privateKey.getPublicExponent(), + privateKey.getPrivateExponent(), + privateKey.getPrimeP(), + privateKey.getPrimeQ(), + privateKey.getPrimeExponentP(), + privateKey.getPrimeExponentQ(), + privateKey.getCrtCoefficient())); + } else if (newKey instanceof RSAPrivateKey) { + RSAPrivateKey privateKey = (RSAPrivateKey) newKey; + nativeKey = (NativeKey) keyFactory.engineGeneratePrivate + (new RSAPrivateKeySpec(privateKey.getModulus(), + privateKey.getPrivateExponent())); + } else { + throw new InvalidKeyException("Unsupported type of RSAPrivateKey"); + } } catch (InvalidKeySpecException ikse) { throw new InvalidKeyException(ikse); }
--- a/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSAKeyFactory.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSAKeyFactory.java Tue Sep 08 15:39:53 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,16 +38,11 @@ import java.security.PrivateKey; import java.security.KeyFactorySpi; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.KeySpec; -import java.security.spec.RSAPrivateCrtKeySpec; -import java.security.spec.RSAPublicKeySpec; +import java.security.spec.*; /** * Ucrypto-private KeyFactory class for generating native keys - * needed for using ucrypto APIs. Given that it's not used - * externally, it only needs to support RSAPrivateCrtKeySpec - * and RSAPublicKeySpec objects. + * needed for using ucrypto APIs. * * @since 1.9 */ @@ -56,7 +51,13 @@ @Override protected PrivateKey engineGeneratePrivate(KeySpec keySpec) throws InvalidKeySpecException { - return new NativeKey.RSAPrivateCrt(keySpec); + if (keySpec instanceof RSAPrivateCrtKeySpec) { + return new NativeKey.RSAPrivateCrt(keySpec); + } else if (keySpec instanceof RSAPrivateKeySpec) { + return new NativeKey.RSAPrivate(keySpec); + } else { + throw new InvalidKeySpecException("Unsupported key spec"); + } } @Override
--- a/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSASignature.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSASignature.java Tue Sep 08 15:39:53 2015 -0700 @@ -43,9 +43,8 @@ import java.security.*; import java.security.interfaces.*; -import java.security.spec.RSAPrivateCrtKeySpec; -import java.security.spec.RSAPublicKeySpec; -import java.security.spec.InvalidKeySpecException; +import java.security.spec.*; + import sun.nio.ch.DirectBuffer; import java.nio.ByteBuffer; @@ -192,25 +191,31 @@ int newSigLength = sigLength; // Need to check RSA key length whenever a new private key is set if (privateKey != key) { - if (privateKey instanceof RSAPrivateCrtKey) { - RSAPrivateCrtKey rsaPrivKey = (RSAPrivateCrtKey) privateKey; - BigInteger mod = rsaPrivKey.getModulus(); - newSigLength = checkRSAKeyLength(mod); - try { + if (!(privateKey instanceof RSAPrivateKey)) { + throw new InvalidKeyException("RSAPrivateKey required"); + } + RSAPrivateKey rsaPrivKey = (RSAPrivateKey) privateKey; + BigInteger mod = rsaPrivKey.getModulus(); + newSigLength = checkRSAKeyLength(mod); + BigInteger pe = rsaPrivKey.getPrivateExponent(); + try { + if (rsaPrivKey instanceof RSAPrivateCrtKey) { + RSAPrivateCrtKey rsaPrivCrtKey = (RSAPrivateCrtKey) rsaPrivKey; newKey = (NativeKey) keyFactory.engineGeneratePrivate (new RSAPrivateCrtKeySpec(mod, - rsaPrivKey.getPublicExponent(), - rsaPrivKey.getPrivateExponent(), - rsaPrivKey.getPrimeP(), - rsaPrivKey.getPrimeQ(), - rsaPrivKey.getPrimeExponentP(), - rsaPrivKey.getPrimeExponentQ(), - rsaPrivKey.getCrtCoefficient())); - } catch (InvalidKeySpecException ikse) { - throw new InvalidKeyException(ikse); + rsaPrivCrtKey.getPublicExponent(), + pe, + rsaPrivCrtKey.getPrimeP(), + rsaPrivCrtKey.getPrimeQ(), + rsaPrivCrtKey.getPrimeExponentP(), + rsaPrivCrtKey.getPrimeExponentQ(), + rsaPrivCrtKey.getCrtCoefficient())); + } else { + newKey = (NativeKey) keyFactory.engineGeneratePrivate + (new RSAPrivateKeySpec(mod, pe)); } - } else { - throw new InvalidKeyException("RSAPrivateCrtKey required"); + } catch (InvalidKeySpecException ikse) { + throw new InvalidKeyException(ikse); } } init(true, newKey, newSigLength);
--- a/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/nativeCrypto.c Thu Sep 03 15:48:24 2015 -0700 +++ b/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/nativeCrypto.c Tue Sep 08 15:39:53 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -430,12 +430,18 @@ * Signature: (JZ[BI)I */ jint JavaCritical_com_oracle_security_ucrypto_NativeCipher_nativeFinal - (jlong pContext, jboolean encrypt, int outLen, jbyte* bufOut, jint outOfs) { + (jlong pContext, jboolean encrypt, int outLen, jbyte* out, jint outOfs) { crypto_ctx_t *context; int rv = 0; + unsigned char* bufOut = (unsigned char*) out; context = (crypto_ctx_t *) pContext; - rv = CipherFinal(context, encrypt, (unsigned char*)bufOut, outOfs, &outLen); + // Avoid null output buffer to workaround Solaris bug21481818 (fixed in S12) + if (bufOut == NULL) { + bufOut = (unsigned char*)(&outLen); + outLen = 0; + } + rv = CipherFinal(context, encrypt, bufOut, outOfs, &outLen); free(context); if (rv) { return -rv; // use negative value to indicate error! @@ -648,7 +654,8 @@ // out is null when nativeFinal() is called solely for resource clean up if (out == NULL) { - bufOut = NULL; + // Avoid null output buffer to workaround Solaris bug21481818 (fixed in S12) + bufOut = (unsigned char *)(&outLen); outLen = 0; } else { outLen = (*env)->GetArrayLength(env, out) - outOfs; @@ -661,10 +668,12 @@ rv = CipherFinal(context, encrypt, bufOut, 0, &outLen); if (rv) { free(context); - free(bufOut); + if (outLen != 0) { + free(bufOut); + } return -rv; } else { - if (bufOut != NULL) { + if (bufOut != NULL && outLen != 0) { (*env)->SetByteArrayRegion(env, out, outOfs, outLen, (jbyte *)bufOut); free(bufOut); } @@ -697,6 +706,86 @@ } /* + * Class: com_oracle_security_ucrypto_NativeKey_RSAPrivate + * Method: nativeInit + * Signature: ([B[B)J + */ +jlong JavaCritical_com_oracle_security_ucrypto_NativeKey_00024RSAPrivate_nativeInit +(int modLen, jbyte* jMod, int privLen, jbyte* jPriv) { + + unsigned char *mod, *priv; + crypto_object_attribute_t* pKey = NULL; + + pKey = calloc(2, sizeof(crypto_object_attribute_t)); + if (pKey == NULL) { + return 0L; + } + mod = priv = NULL; + mod = malloc(modLen); + priv = malloc(privLen); + if (mod == NULL || priv == NULL) { + free(pKey); + free(mod); + free(priv); + return 0L; + } else { + memcpy(mod, jMod, modLen); + memcpy(priv, jPriv, privLen); + } + + // NOTE: numOfComponents should be 2 + pKey[0].oa_type = SUN_CKA_MODULUS; + pKey[0].oa_value = (char*) mod; + pKey[0].oa_value_len = (size_t) modLen; + pKey[1].oa_type = SUN_CKA_PRIVATE_EXPONENT; + pKey[1].oa_value = (char*) priv; + pKey[1].oa_value_len = (size_t) privLen; + + return (jlong) pKey; +} + +JNIEXPORT jlong JNICALL +Java_com_oracle_security_ucrypto_NativeKey_00024RSAPrivate_nativeInit + (JNIEnv *env, jclass jCls, jbyteArray jMod, jbyteArray jPriv) { + + int modLen, privLen; + jbyte *bufMod, *bufPriv; + crypto_object_attribute_t* pKey = NULL; + + bufMod = bufPriv = NULL; + + modLen = (*env)->GetArrayLength(env, jMod); + bufMod = getBytes(env, jMod, 0, modLen); + if ((*env)->ExceptionCheck(env)) goto cleanup; + + privLen = (*env)->GetArrayLength(env, jPriv); + bufPriv = getBytes(env, jPriv, 0, privLen); + if ((*env)->ExceptionCheck(env)) goto cleanup; + + // proceed if no error; otherwise free allocated memory + pKey = calloc(2, sizeof(crypto_object_attribute_t)); + if (pKey == NULL) { + throwOutOfMemoryError(env, NULL); + goto cleanup; + } + + // NOTE: numOfComponents should be 2 + pKey[0].oa_type = SUN_CKA_MODULUS; + pKey[0].oa_value = (char*) bufMod; + pKey[0].oa_value_len = (size_t) modLen; + pKey[1].oa_type = SUN_CKA_PRIVATE_EXPONENT; + pKey[1].oa_value = (char*) bufPriv; + pKey[1].oa_value_len = (size_t) privLen; + return (jlong) pKey; + +cleanup: + free(bufMod); + free(bufPriv); + + return 0L; +} + +/* * Class: com_oracle_security_ucrypto_NativeKey_RSAPrivateCrt * Method: nativeInit * Signature: ([B[B[B[B[B[B[B[B)J
--- a/src/jdk.jcmd/share/classes/sun/tools/jps/Jps.java Thu Sep 03 15:48:24 2015 -0700 +++ b/src/jdk.jcmd/share/classes/sun/tools/jps/Jps.java Tue Sep 08 15:39:53 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2013, 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 @@ -106,7 +106,11 @@ errorString = " -- jvm args information unavailable"; String jvmArgs = MonitoredVmUtil.jvmArgs(vm); if (jvmArgs != null && jvmArgs.length() > 0) { - output.append(' ').append(jvmArgs); + output.append(' ') + .append( + // multi-line args are permitted + jvmArgs.replace("\n", "\\n").replace("\r", "\\r") + ); } } if (arguments.showVmFlags()) {
--- a/test/ProblemList.txt Thu Sep 03 15:48:24 2015 -0700 +++ b/test/ProblemList.txt Tue Sep 08 15:39:53 2015 -0700 @@ -387,11 +387,6 @@ # 6456333 sun/tools/jps/TestJpsJarRelative.java generic-all -# 8134420 -sun/tools/jps/TestJpsClass.java generic-all -sun/tools/jps/TestJpsJar.java generic-all -sun/tools/jps/TestJpsSanity.java generic-all - # 6734748 sun/tools/jinfo/JInfoRunningProcessFlagTest.java generic-all
--- a/test/com/apple/eawt/DefaultMenuBar/DefaultMenuBarTest.java Thu Sep 03 15:48:24 2015 -0700 +++ b/test/com/apple/eawt/DefaultMenuBar/DefaultMenuBarTest.java Tue Sep 08 15:39:53 2015 -0700 @@ -25,6 +25,7 @@ * @test * @bug 8007267 * @summary [macosx] com.apple.eawt.Application.setDefaultMenuBar is not working + * @requires (os.family == "mac") * @author leonid.romanov@oracle.com * @modules java.desktop/sun.awt * java.desktop/com.apple.eawt @@ -34,7 +35,6 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; -import sun.awt.*; import java.lang.reflect.Method; @@ -43,7 +43,7 @@ static volatile int listenerCallCounter = 0; public static void main(String[] args) throws Exception { - if (sun.awt.OSInfo.getOSType() != sun.awt.OSInfo.OSType.MACOSX) { + if (!System.getProperty("os.name").contains("OS X")) { System.out.println("This test is for MacOS only. Automatically passed on other platforms."); return; } @@ -55,7 +55,6 @@ } }); - SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); Robot robot = new Robot(); robot.setAutoDelay(100); @@ -64,7 +63,7 @@ robot.keyRelease(ks.getKeyCode()); robot.keyRelease(KeyEvent.VK_META); - toolkit.realSync(); + robot.waitForIdle(); if (listenerCallCounter != 1) { throw new Exception("Test failed: ActionListener either wasn't called or was called more than once");
--- a/test/com/oracle/security/ucrypto/CipherSignNotSupported.java Thu Sep 03 15:48:24 2015 -0700 +++ b/test/com/oracle/security/ucrypto/CipherSignNotSupported.java Tue Sep 08 15:39:53 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /** * @test - * @bug 8029849 + * @bug 8029849 8132082 * @summary Make sure signing via encrypt and verifying via decrypt are not * supported by OracleUcrypto provider. * @author Anthony Scarpino @@ -31,12 +31,10 @@ */ import java.util.Random; -import java.security.KeyPairGenerator; -import java.security.KeyPair; +import java.security.*; +import java.security.interfaces.*; +import java.security.spec.RSAPrivateKeySpec; import javax.crypto.Cipher; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.security.Provider; public class CipherSignNotSupported extends UcryptoTest { @@ -69,27 +67,43 @@ c.init(Cipher.ENCRYPT_MODE, kp.getPublic()); ct = c.doFinal(pt); // Decryption - c.init(Cipher.DECRYPT_MODE, kp.getPrivate()); - c.doFinal(ct); - // Sign - try { - c.init(Cipher.ENCRYPT_MODE, kp.getPrivate()); - ct = c.doFinal(pt); - throw new RuntimeException("Encrypt operation should have failed."); - } catch (InvalidKeyException e) { - if (e.getMessage().compareTo("RSAPublicKey required for " + - "encryption") != 0) { - System.out.println("Wrong exception thrown."); - throw e; + PrivateKey[] privKeys = new PrivateKey[2]; + privKeys[0] = kp.getPrivate(); + if (privKeys[0] instanceof RSAPrivateCrtKey) { + RSAPrivateCrtKey k = (RSAPrivateCrtKey) privKeys[0]; + KeyFactory kf = KeyFactory.getInstance("RSA"); + privKeys[1] = kf.generatePrivate + (new RSAPrivateKeySpec(k.getModulus(), k.getPrivateExponent())); + } else { + privKeys = new PrivateKey[] {privKeys[0]}; + } + + for (PrivateKey pk : privKeys) { + System.out.println("Testing " + pk); + c.init(Cipher.DECRYPT_MODE, pk); + c.doFinal(ct); + + // Sign + try { + c.init(Cipher.ENCRYPT_MODE, pk); + ct = c.doFinal(pt); + throw new RuntimeException("Encrypt operation should have failed."); + } catch (InvalidKeyException e) { + if (e.getMessage().compareTo("RSAPublicKey required for " + + "encryption") != 0) { + System.out.println("Wrong exception thrown."); + throw e; + } } } + // Verify try { c.init(Cipher.DECRYPT_MODE, kp.getPublic()); c.doFinal(ct); throw new RuntimeException("Decrypt operation should have failed."); } catch (InvalidKeyException e) { - if (e.getMessage().compareTo("RSAPrivateCrtKey required for " + + if (e.getMessage().compareTo("RSAPrivateKey required for " + "decryption") != 0) { System.out.println("Wrong exception thrown."); throw e;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/Component/GetScreenLocTest/GetScreenLocTest.java Tue Sep 08 15:39:53 2015 -0700 @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2002, 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.AWTException; +import java.awt.BorderLayout; +import java.awt.Canvas; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.Toolkit; +import java.awt.event.InputEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/** + * @test + * @bug 4356202 + * @summary Tests that getLocationOnScreen returns valid value(WindowMaker + * only). + * @author dom@sparc.spb.su: + */ +public class GetScreenLocTest { + //Declare things used in the test, like buttons and labels here + static Robot robot = null; + private static class MyCanvas extends Canvas { + public Dimension getPreferredSize() { + return new Dimension(100, 100); + } + public void paint(Graphics g) { + super.paint(g); + g.setColor(Color.blue); + Rectangle r = getBounds(); + g.fillRect(0, 0, r.width, r.height); + } + } + static int state = 0; // there are three states - (-1,-1),(0,0),(1,1) + + static void bigPause() { + Toolkit.getDefaultToolkit().sync(); + robot.waitForIdle(); + robot.delay(1000); + } + + static void doPress(Point p) { + robot.mouseMove(p.x, p.y); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + } + + public static void main(final String[] args) throws AWTException { + robot = new Robot(); + Frame bigOne = new Frame(); + bigOne.setSize(200, 200); + bigOne.setLocationRelativeTo(null); + bigOne.setVisible(true); + Frame f = new Frame(); + f.setLayout(new BorderLayout()); + f.setSize(120, 150); + f.setLocationRelativeTo(null); + Canvas c = new MyCanvas(); + f.add(c, BorderLayout.CENTER); + c.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent e) { + switch(state) { + case 0: // the first event should be (0,0) + if (e.getX() != 0 || e.getY() != 0) { + System.out.println("state 0: wrong location" + e); + break; + } + state++; + break; + case 1: // the second event should be (1,1) + if (e.getX() != 1 || e.getY() != 1) { + System.out.println("state 1: wrong location " + e); + break; + } + state++; + break; + case 2: // this should never happen + System.out.println("state 2: wrong location " + e); + } + } + }); + f.pack(); + f.setVisible(true); + bigPause(); + + Point p = c.getLocationOnScreen(); + doPress(p); + p.x += 1; + p.y += 1; + doPress(p); + p.x -= 2; + p.y -= 2; + doPress(p); + bigPause(); + + f.dispose(); + bigOne.dispose(); + + // ...and at the end the state should be 2 + if (state != 2) { + throw new RuntimeException("wrong state: " + state); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/EmbeddedFrame/DisplayChangedTest/DisplayChangedTest.java Tue Sep 08 15:39:53 2015 -0700 @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2013, 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 4980592 + @summary switching user in XP causes an NPE in + sun.awt.windows.WWindowPeer.displayChanged + @requires (os.family == "windows") + @modules java.desktop/java.awt.peer + @modules java.desktop/sun.awt.windows + @modules java.desktop/sun.awt + @author son@sparc.spb.su: area=embedded + @run main DisplayChangedTest + */ +/** + * DisplayChangedTest.java + * + * summary: switching user in XP causes an NPE in + * sun.awt.windows.WWindowPeer.displayChanged + */ +import java.awt.Frame; +import java.awt.Dialog; +import java.awt.TextArea; +import java.awt.peer.ComponentPeer; +import java.awt.peer.FramePeer; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Field; + +import sun.awt.AWTAccessor; + +public class DisplayChangedTest { + + /** + * Test fails if it throws any exception. + * + * @throws Exception + */ + private void init() throws Exception { + + if (!System.getProperty("os.name").startsWith("Windows")) { + System.out.println("This is Windows only test."); + return; + } + + Frame frame = new Frame("AWT Frame"); + frame.pack(); + + FramePeer frame_peer = AWTAccessor.getComponentAccessor() + .getPeer(frame); + Class comp_peer_class = Class.forName("sun.awt.windows.WComponentPeer"); + Field hwnd_field = comp_peer_class.getDeclaredField("hwnd"); + hwnd_field.setAccessible(true); + long hwnd = hwnd_field.getLong(frame_peer); + + Class clazz = Class.forName("sun.awt.windows.WEmbeddedFrame"); + Constructor constructor = clazz + .getConstructor(new Class[]{long.class}); + Frame embedded_frame = (Frame) constructor + .newInstance(new Object[]{new Long(hwnd)}); + frame.setVisible(true); + + ComponentPeer peer = AWTAccessor.getComponentAccessor().getPeer( + embedded_frame); + Class peerClass = peer.getClass(); + Method displayChangedM = peerClass.getMethod("displayChanged", + new Class[0]); + displayChangedM.invoke(peer, null); + embedded_frame.dispose(); + frame.dispose(); + + } + + public static void main(String args[]) throws Exception { + new DisplayChangedTest().init(); + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/EmbeddedFrame/EmbeddedFrameGrabTest/EmbeddedFrameGrabTest.java Tue Sep 08 15:39:53 2015 -0700 @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2013, 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 6345002 + @summary grab problems with EmbeddedFrame + @requires (os.family == "windows") + @modules java.desktop/java.awt.peer + @modules java.desktop/sun.awt + @modules java.desktop/sun.awt.windows + @author Oleg.Semenov@sun.com area=EmbeddedFrame + @run main EmbeddedFrameGrabTest + */ +/** + * EmbeddedFrameGrabTest.java + * + * summary: grab problems with EmbeddedFrame + */ +import java.awt.Frame; +import java.awt.peer.FramePeer; +import javax.swing.JComboBox; +import java.awt.Panel; +import java.awt.BorderLayout; +import java.awt.Robot; +import java.awt.event.InputEvent; +import java.awt.Rectangle; +import java.awt.TextArea; +import java.awt.Dialog; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; + +import sun.awt.AWTAccessor; + +public class EmbeddedFrameGrabTest { + + /** + * Test fails if it throws any exception. + * + * @throws Exception + */ + private void init() throws Exception { + + if (!System.getProperty("os.name").startsWith("Windows")) { + System.out.println("This is Windows only test."); + return; + } + + final Frame frame = new Frame("AWT Frame"); + frame.pack(); + frame.setSize(200, 200); + FramePeer frame_peer = AWTAccessor.getComponentAccessor() + .getPeer(frame); + Class comp_peer_class + = Class.forName("sun.awt.windows.WComponentPeer"); + Field hwnd_field = comp_peer_class.getDeclaredField("hwnd"); + hwnd_field.setAccessible(true); + long hwnd = hwnd_field.getLong(frame_peer); + + Class clazz = Class.forName("sun.awt.windows.WEmbeddedFrame"); + Constructor constructor + = clazz.getConstructor(new Class[]{long.class}); + final Frame embedded_frame + = (Frame) constructor.newInstance(new Object[]{ + new Long(hwnd)});; + final JComboBox<String> combo = new JComboBox<>(new String[]{ + "Item 1", "Item 2" + }); + combo.setSelectedIndex(1); + final Panel p = new Panel(); + p.setLayout(new BorderLayout()); + embedded_frame.add(p, BorderLayout.CENTER); + embedded_frame.validate(); + p.add(combo); + p.validate(); + frame.setVisible(true); + Robot robot = new Robot(); + robot.delay(2000); + Rectangle clos = new Rectangle( + combo.getLocationOnScreen(), combo.getSize()); + robot.mouseMove(clos.x + clos.width / 2, clos.y + clos.height / 2); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + robot.delay(1000); + if (!combo.isPopupVisible()) { + throw new RuntimeException("Combobox popup is not visible!"); + } + robot.mouseMove(clos.x + clos.width / 2, clos.y + clos.height + 3); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + robot.delay(1000); + if (combo.getSelectedIndex() != 0) { + throw new RuntimeException("Combobox selection has not changed!"); + } + embedded_frame.remove(p); + embedded_frame.dispose(); + frame.dispose(); + + } + + public static void main(String args[]) throws Exception { + new EmbeddedFrameGrabTest().init(); + } + +}
--- a/test/java/awt/Frame/SetMaximizedBounds/SetMaximizedBounds.java Thu Sep 03 15:48:24 2015 -0700 +++ b/test/java/awt/Frame/SetMaximizedBounds/SetMaximizedBounds.java Tue Sep 08 15:39:53 2015 -0700 @@ -24,6 +24,7 @@ import java.awt.*; /* * @test + * @bug 8065739 8131339 * @summary When Frame.setExtendedState(Frame.MAXIMIZED_BOTH) * is called for a Frame after been called setMaximizedBounds() with * certain value, Frame bounds must equal to this value. @@ -55,12 +56,14 @@ for (GraphicsDevice gd : ge.getScreenDevices()) { for (GraphicsConfiguration gc : gd.getConfigurations()) { - testMaximizedBounds(gc); + testMaximizedBounds(gc, false); + testMaximizedBounds(gc, true); } } } - static void testMaximizedBounds(GraphicsConfiguration gc) throws Exception { + static void testMaximizedBounds(GraphicsConfiguration gc, boolean undecorated) + throws Exception { Frame frame = null; try { @@ -71,6 +74,7 @@ robot.setAutoDelay(50); frame = new Frame(); + frame.setUndecorated(undecorated); Rectangle maximizedBounds = new Rectangle( maxArea.x + maxArea.width / 6, maxArea.y + maxArea.height / 6,
--- a/test/java/awt/Mouse/EnterExitEvents/FullscreenEnterEventTest.java Thu Sep 03 15:48:24 2015 -0700 +++ b/test/java/awt/Mouse/EnterExitEvents/FullscreenEnterEventTest.java Tue Sep 08 15:39:53 2015 -0700 @@ -37,6 +37,8 @@ * @bug 8013468 * @summary Cursor does not update properly when in fullscreen mode on Mac * The core reason of the issue was the lack of a mouse entered event in fullscreen + * @requires (os.family == "mac") + * @modules java.desktop/com.apple.eawt * @library ../../regtesthelpers * @build Util * @modules java.desktop/com.apple.eawt
--- a/test/java/awt/SplashScreen/FullscreenAfterSplash/FullScreenAfterSplash.java Thu Sep 03 15:48:24 2015 -0700 +++ b/test/java/awt/SplashScreen/FullscreenAfterSplash/FullScreenAfterSplash.java Tue Sep 08 15:39:53 2015 -0700 @@ -36,6 +36,7 @@ * @test * @bug 8024185 * @summary Native Mac OS X full screen does not work after showing the splash + * @requires (os.family == "mac") * @library ../ * @library ../../../../lib/testlibrary * @modules java.desktop/sun.awt
--- a/test/java/beans/Introspector/4058433/TestBeanProperty.java Thu Sep 03 15:48:24 2015 -0700 +++ b/test/java/beans/Introspector/4058433/TestBeanProperty.java Tue Sep 08 15:39:53 2015 -0700 @@ -39,7 +39,7 @@ Class<?>[] types = {B.class, BL.class, BLF.class, E.class, H.class, P.class, VU.class, D.class, EVD.class, EVE.class, EV.class, EVL.class, - EVX.class}; + EVX.class, R.class}; for (Class<?> type : types) { PropertyDescriptor pd = BeanUtils.getPropertyDescriptor(type, "value"); if (((B.class == type) || (BLF.class == type)) && pd.isBound()) { @@ -66,6 +66,10 @@ BeanUtils.reportPropertyDescriptor(pd); throw new Error("required"); } + if ((D.class == type) == !"getter".equals(pd.getShortDescription())) { + BeanUtils.reportPropertyDescriptor(pd); + throw new Error("shortDescription"); + } if ((VU.class == type) == !Boolean.TRUE.equals(pd.getValue("visualUpdate"))) { BeanUtils.reportPropertyDescriptor(pd); throw new Error("visualUpdate");
--- a/test/java/nio/file/Files/StreamLinesTest.java Thu Sep 03 15:48:24 2015 -0700 +++ b/test/java/nio/file/Files/StreamLinesTest.java Tue Sep 08 15:39:53 2015 -0700 @@ -138,18 +138,25 @@ StandardCharsets.ISO_8859_1, StandardCharsets.UTF_16); String[] lines = {"", "A", "AB", "ABC", "ABCD"}; - int[] linesSizes = {1, 2, 3, 4, 16, 256, 1024}; + int[] linesSizes = {0, 1, 2, 3, 4, 16, 256, 1024}; for (Charset charset : charsets) { - for (String line : lines) { - for (int linesSize : linesSizes) { - for (LineSeparator ls : EnumSet.complementOf(EnumSet.of(LineSeparator.NONE))) { - String description = String.format("%d lines of \"%s\" with separator %s", linesSize, line, ls); - l.add(of(description, - i -> line, - i -> ls, - linesSize, charset)); + for (int linesSize : linesSizes) { + if (linesSize > 0) { + for (String line : lines) { + for (LineSeparator ls : EnumSet.complementOf(EnumSet.of(LineSeparator.NONE))) { + String description = String.format("%d lines of \"%s\" with separator %s", linesSize, line, ls); + l.add(of(description, + i -> line, + i -> ls, + linesSize, charset)); + } } + } else { + l.add(of("Empty file: 0 lines", + i -> "", + i -> LineSeparator.NONE, + 0, charset)); } } }
--- a/test/javax/sound/midi/Gervill/SoftProvider/GetDevice.java Thu Sep 03 15:48:24 2015 -0700 +++ b/test/javax/sound/midi/Gervill/SoftProvider/GetDevice.java Tue Sep 08 15:39:53 2015 -0700 @@ -27,9 +27,6 @@ */ import javax.sound.midi.MidiDevice; -import javax.sound.midi.MidiUnavailableException; -import javax.sound.midi.Patch; -import javax.sound.sampled.*; import javax.sound.midi.MidiDevice.Info; import com.sun.media.sound.*; @@ -48,13 +45,6 @@ throw new RuntimeException("assertTrue fails!"); } - - private static class FakeInfo extends Info { - public FakeInfo() { - super("a", "b", "c", "d"); - } - } - public static void main(String[] args) throws Exception { SoftProvider provider = new SoftProvider(); Info[] infos = provider.getDeviceInfo(); @@ -64,7 +54,5 @@ MidiDevice d = provider.getDevice(infos[i]); assertTrue(d instanceof SoftSynthesizer); } - assertTrue(provider.getDevice(new FakeInfo()) == null); - } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/sound/midi/MidiDeviceProvider/FakeInfo.java Tue Sep 08 15:39:53 2015 -0700 @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.util.Collection; +import java.util.HashSet; + +import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiDevice.Info; +import javax.sound.midi.MidiSystem; +import javax.sound.midi.MidiUnavailableException; +import javax.sound.midi.spi.MidiDeviceProvider; + +import static java.util.ServiceLoader.load; + +/** + * @test + * @bug 8059743 + * @summary MidiDeviceProvider shouldn't returns incorrect results in case of + * some unknown MidiDevice.Info + * @author Sergey Bylokhov + */ +public final class FakeInfo { + + private static final class Fake extends Info { + + Fake() { + super("a", "b", "c", "d"); + } + } + + public static void main(final String[] args) { + final Info fake = new Fake(); + // MidiSystem API + try { + MidiSystem.getMidiDevice(fake); + throw new RuntimeException("IllegalArgumentException expected"); + } catch (final MidiUnavailableException e) { + throw new RuntimeException("IllegalArgumentException expected", e); + } catch (final IllegalArgumentException ignored) { + // expected + } + // MidiDeviceProvider API + final Collection<String> errors = new HashSet<>(); + for (final MidiDeviceProvider mdp : load(MidiDeviceProvider.class)) { + try { + if (mdp.isDeviceSupported(fake)) { + throw new RuntimeException("fake is supported"); + } + final MidiDevice device = mdp.getDevice(fake); + System.err.println("MidiDevice: " + device); + throw new RuntimeException("IllegalArgumentException expected"); + } catch (final IllegalArgumentException e) { + errors.add(e.getMessage()); + } + } + if (errors.size() != 1) { + throw new RuntimeException("Wrong number of messages:" + errors); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/swing/JColorChooser/Test8051548.java Tue Sep 08 15:39:53 2015 -0700 @@ -0,0 +1,228 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Frame; +import java.awt.Robot; +import java.awt.event.KeyEvent; +import java.util.function.Predicate; +import javax.swing.JColorChooser; +import javax.swing.JFormattedTextField; +import javax.swing.JFrame; +import javax.swing.JTabbedPane; +import javax.swing.SwingUtilities; +import javax.swing.colorchooser.AbstractColorChooserPanel; + +/* + * @test + * @bug 8051548 + * @summary JColorChooser should have a way to disable transparency controls + * @author Alexandr Scherbatiy + * @run main Test8051548 + */ + +public class Test8051548 { + + private static final String[][] TABS = { + {"HSV", "0"}, + {"HSL", "0"}, + {"RGB", "255"}, + {"CMYK", "255"} + }; + + private static JColorChooser colorChooser; + private static boolean propertyChangeListenerInvoked; + private static volatile Color color; + + public static void main(String[] args) throws Exception { + testColorPanels(); + testShowDialog(true); + testShowDialog(false); + } + + private static void testColorPanels() throws Exception { + SwingUtilities.invokeAndWait(() -> createAndShowGUI()); + + Robot robot = new Robot(); + robot.setAutoDelay(50); + robot.waitForIdle(); + + for (String[] tabs : TABS) { + final String tab = tabs[0]; + final String initialValue = tabs[1]; + + SwingUtilities.invokeAndWait(() -> { + + colorChooser.setColor(new Color(50, 100, 85)); + JTabbedPane tabbedPane = + (JTabbedPane) findComponent(colorChooser, "JTabbedPane"); + int index = tabbedPane.indexOfTab(tab); + tabbedPane.setSelectedIndex(index); + + AbstractColorChooserPanel colorChooserPanel + = (AbstractColorChooserPanel) findComponent( + tabbedPane.getComponent(index), "ColorChooserPanel"); + + propertyChangeListenerInvoked = false; + colorChooserPanel.addPropertyChangeListener((e) -> { + if (AbstractColorChooserPanel.TRANSPARENCY_ENABLED_PROPERTY. + equals(e.getPropertyName())) { + propertyChangeListenerInvoked = true; + if(!(Boolean)e.getOldValue()){ + throw new RuntimeException("Old color transparency" + + " selection property should be true!"); + } + if((Boolean)e.getNewValue()){ + throw new RuntimeException("New color transparency" + + " selection property should be false!"); + } + } + }); + + if (!colorChooserPanel.isColorTransparencySelectionEnabled()) { + throw new RuntimeException("Color transparency selection" + + " should be enabled by default"); + } + + JFormattedTextField transparencyTextField = (JFormattedTextField) + findTextField(colorChooserPanel, initialValue); + + if (!transparencyTextField.isEnabled()) { + throw new RuntimeException("Transparency controls are" + + " disabled by default!"); + } + + transparencyTextField.setValue(50); + + if(!colorHasAlpha()){ + throw new RuntimeException("Transparency selection should" + + " be enabled!"); + } + + colorChooserPanel.setColorTransparencySelectionEnabled(false); + + if (colorChooserPanel.isColorTransparencySelectionEnabled()) { + throw new RuntimeException("Color transparency selection" + + " should be disabled!"); + } + + if(!propertyChangeListenerInvoked){ + throw new RuntimeException("Property change listener is not" + + " invoked!"); + } + + if(colorHasAlpha()){ + throw new RuntimeException("Transparency selection should" + + " be disabled!"); + } + }); + + robot.waitForIdle(); + } + + } + + static void testShowDialog(boolean colorTransparencySelectionEnabled) throws Exception { + int alphaValue = 123; + Robot robot = new Robot(); + robot.setAutoDelay(50); + + SwingUtilities.invokeLater(() -> { + color = JColorChooser.showDialog(null, "Change Color", + new Color(10, 20, 30, alphaValue), + colorTransparencySelectionEnabled); + }); + + SwingUtilities.invokeAndWait(() -> { + // wait for dialog is shown + }); + + robot.waitForIdle(); + + robot.keyPress(KeyEvent.VK_ENTER); + robot.keyRelease(KeyEvent.VK_ENTER); + robot.waitForIdle(); + + if (colorTransparencySelectionEnabled) { + if (color.getAlpha() != alphaValue) { + throw new RuntimeException("Color alpha has not bee reseted!"); + } + } else { + if (color.getAlpha() != 255) { + throw new RuntimeException("Color alpha has not bee reseted!"); + } + } + } + + private static boolean colorHasAlpha(){ + return colorChooser.getColor().getAlpha() != 255; + } + + private static void createAndShowGUI() { + JFrame frame = new JFrame(); + frame.setSize(700, 500); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + colorChooser = new JColorChooser(); + frame.getContentPane().add(colorChooser); + frame.setVisible(true); + } + + private static Component findComponent(Component component, String name) { + return findComponent(component, + (comp) -> comp.getClass().getName().contains(name)); + } + + private static Component findTextField(Component component, String value) { + return findComponent(component, (comp) -> { + + if (comp instanceof JFormattedTextField) { + JFormattedTextField textField = (JFormattedTextField) comp; + return value.equals(textField.getText()); + } + return false; + }); + } + + private static Component findComponent(Component component, + Predicate<Component> predicate) { + + if (predicate.test(component)) { + return component; + } + + if (component instanceof Container) { + Container container = (Container) component; + for (int i = 0; i < container.getComponentCount(); i++) { + Component child = findComponent(container.getComponent(i), + predicate); + if (child != null) { + return child; + } + } + } + + return null; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/swing/JComponent/4339584/GetUI.java Tue Sep 08 15:39:53 2015 -0700 @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.JComponent; +import javax.swing.plaf.ComponentUI; + +/** + * @test + * @bug 4339584 + */ +public final class GetUI { + + public static void main(final String[] args) { + CustomJComponent component = new CustomJComponent(); + ComponentUI ui = new ComponentUI() { + }; + component.setUI(ui); + ComponentUI actual = component.getUI(); + if (actual != ui) { + System.err.println("Expected: " + ui); + System.err.println("Actual: " + actual); + throw new RuntimeException("Test failed"); + } + } + + private static class CustomJComponent extends JComponent { + + @Override + public ComponentUI getUI() { + return super.getUI(); + } + + @Override + public void setUI(ComponentUI ui) { + super.setUI(ui); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/swing/JMenu/4213634/bug4213634.java Tue Sep 08 15:39:53 2015 -0700 @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.AWTException; +import java.awt.Robot; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.lang.reflect.InvocationTargetException; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JTextArea; +import javax.swing.SwingUtilities; + +/* @test + * @bug 4213634 8017187 + * @author Scott Violet + * @library ../../regtesthelpers + * @build Util + * @run main bug4213634 + */ + + +public class bug4213634 { + + private JMenu menu; + + private JFrame frame; + + public static void main(String[] args) throws Throwable { + new bug4213634(); + } + + bug4213634() throws AWTException, InterruptedException, InvocationTargetException { + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + createAndShowGUI(); + } + }); + + test(); + } + + public void createAndShowGUI() { + frame = new JFrame("TEST"); + JMenuBar mb = new JMenuBar(); + menu = mb.add(createMenu("1 - First Menu", true)); + mb.add(createMenu("2 - Second Menu", false)); + frame.setJMenuBar(mb); + JTextArea ta = new JTextArea("This test dedicated to Nancy and Kathleen, testers and bowlers extraordinaire\n\n\nNo exception means pass."); + frame.getContentPane().add("Center", ta); + JButton button = new JButton("Test"); + frame.getContentPane().add("South", button); + frame.setBounds(100, 100, 400, 400); + frame.setVisible(true); + button.requestFocusInWindow(); + } + + private void test() throws AWTException, InterruptedException, InvocationTargetException { + Robot robot = new Robot(); + robot.setAutoDelay(50); + robot.waitForIdle(); + + Util.hitMnemonics(robot, KeyEvent.VK_1); + robot.waitForIdle(); + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + if (!menu.isSelected()) { + throw new RuntimeException( + "Failed: Menu didn't remain posted at end of test"); + } else { + System.out.println("Test passed!"); + frame.dispose(); + } + } + }); + } + private JMenu createMenu(String str, boolean bFlag) { + JMenuItem menuitem; + JMenu menu = new JMenu(str); + menu.setMnemonic(str.charAt(0)); + + for(int i = 0; i < 10; i ++) { + menuitem = new JMenuItem("JMenuItem" + i); + menuitem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + throw new RuntimeException( + "Failed: Mnemonic activated"); + } + }); + if(bFlag) + menuitem.setMnemonic('0' + i); + menu.add(menuitem); + } + return menu; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/swing/UIDefaults/6302464/bug6302464.java Tue Sep 08 15:39:53 2015 -0700 @@ -0,0 +1,283 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.util.Map; +import java.util.HashSet; +import java.awt.Color; +import java.awt.Toolkit; +import java.awt.Graphics2D; +import java.awt.font.FontRenderContext; +import java.awt.image.BufferedImage; +import javax.swing.JLabel; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.UIDefaults; +import javax.swing.UIManager.LookAndFeelInfo; +import javax.swing.plaf.basic.BasicLookAndFeel; +import static java.awt.RenderingHints.KEY_TEXT_ANTIALIASING; +import static java.awt.RenderingHints.KEY_TEXT_LCD_CONTRAST; +import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_GASP; +import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HBGR; +import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB; +import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_VBGR; +import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_VRGB; +import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_OFF; + +/** + * @test + * @bug 6302464 + * @author Alexandr Scherbatiy + * @summary Allow programmatic enabling of subpixel anti-aliasing in Swing + */ +public class bug6302464 { + + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(bug6302464::testAntialiasingProperties); + } + + private static void testAntialiasingProperties() { + testCustomLAF(); + testFontRenderingContext(); + testAntialiasingHints(); + testLAFAAHints(); + } + + private static void testCustomLAF() { + try { + testCustomLAF(false); + testCustomLAF(true); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + private static void testCustomLAF(boolean useAAHints) throws Exception { + CustomLookAndFeel customLAF = new CustomLookAndFeel(useAAHints); + UIManager.setLookAndFeel(customLAF); + + JLabel label = new JLabel(); + Object aaHint = label.getClientProperty(KEY_TEXT_ANTIALIASING); + Object lcdContrastHint = label.getClientProperty(KEY_TEXT_LCD_CONTRAST); + + if (aaHint != customLAF.getAAHint()) { + throw new RuntimeException("AA hint from custom L&F is not set"); + } + + if (lcdContrastHint != customLAF.getLCDContarstHint()) { + throw new RuntimeException("AA hint from custom L&F is not set"); + } + } + + private static final Object[] ANTIALIASING_HINTS = { + VALUE_TEXT_ANTIALIAS_GASP, + VALUE_TEXT_ANTIALIAS_LCD_HRGB, + VALUE_TEXT_ANTIALIAS_LCD_HBGR, + VALUE_TEXT_ANTIALIAS_LCD_VRGB, + VALUE_TEXT_ANTIALIAS_LCD_VBGR + }; + + private static void testFontRenderingContext() { + for (Object aaHint : ANTIALIASING_HINTS) { + testFontRenderingContext(aaHint); + } + } + + private static void testFontRenderingContext(Object aaHint) { + + JLabel label = new JLabel("Test"); + label.putClientProperty(KEY_TEXT_ANTIALIASING, aaHint); + FontRenderContext frc = label.getFontMetrics( + label.getFont()).getFontRenderContext(); + + if (!aaHint.equals(frc.getAntiAliasingHint())) { + throw new RuntimeException("Wrong aa hint in FontRenderContext"); + } + } + + private static void testAntialiasingHints() { + setMetalLookAndFeel(); + + HashSet colorsAAOff = getAntialiasedColors(VALUE_TEXT_ANTIALIAS_OFF, 100); + + if (colorsAAOff.size() > 2) { + throw new RuntimeException("Wrong number of antialiased colors."); + } + + HashSet colorsAAOnLCD100 = getAntialiasedColors( + VALUE_TEXT_ANTIALIAS_LCD_HRGB, 100); + + if (colorsAAOnLCD100.size() <= 2) { + throw new RuntimeException("Wrong number of antialiased colors."); + } + + HashSet colorsAAOnLCD250 = getAntialiasedColors( + VALUE_TEXT_ANTIALIAS_LCD_HRGB, 250); + + if (colorsAAOnLCD250.size() <= 2) { + throw new RuntimeException("Wrong number of antialiased colors."); + } + + if (colorsAAOnLCD100.equals(colorsAAOnLCD250)) { + throw new RuntimeException("LCD contarst is not used."); + } + } + + private static HashSet getAntialiasedColors(Object aaHint, int lcdContrast) { + + JLabel label = new JLabel("ABCD"); + label.setSize(label.getPreferredSize()); + label.putClientProperty(KEY_TEXT_ANTIALIASING, aaHint); + label.putClientProperty(KEY_TEXT_LCD_CONTRAST, lcdContrast); + + int w = label.getWidth(); + int h = label.getHeight(); + + BufferedImage buffImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); + Graphics2D g = buffImage.createGraphics(); + g.setColor(Color.WHITE); + g.fillRect(0, 0, w, h); + label.paint(g); + g.dispose(); + + HashSet<Color> colors = new HashSet<>(); + + for (int i = 0; i < w; i++) { + for (int j = 0; j < h; j++) { + Color color = new Color(buffImage.getRGB(i, j)); + colors.add(color); + } + } + + return colors; + } + + private static void setMetalLookAndFeel() { + setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); + } + + private static void setLookAndFeel(String lafClass) { + try { + UIManager.setLookAndFeel(lafClass); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + private static void testLAFAAHints() { + + for (LookAndFeelInfo lafInfo : UIManager.getInstalledLookAndFeels()) { + testLAFAAHints(lafInfo); + } + } + + private static final String[] EXCLUDED_LAFS = {"CDE/Motif"}; + + private static boolean isExcludedLAF(LookAndFeelInfo lafInfo) { + for (String excludedLaf : EXCLUDED_LAFS) { + if (lafInfo.getName().equals(excludedLaf)) { + return true; + } + } + return false; + } + + private static void testLAFAAHints(LookAndFeelInfo lafInfo) { + setLookAndFeel(lafInfo.getClassName()); + + Object uiAAHint = UIManager.getDefaults().get(KEY_TEXT_ANTIALIASING); + Object uiLCDContrastHint = UIManager.getDefaults().get( + KEY_TEXT_LCD_CONTRAST); + + Object aaHints = Toolkit.getDefaultToolkit(). + getDesktopProperty("awt.font.desktophints"); + + if (isExcludedLAF(lafInfo)) { + if (uiAAHint != null || uiLCDContrastHint != null) { + throw new RuntimeException("Rendering hints set for excluded L&F"); + } + } else if (aaHints instanceof Map) { + Map map = (Map) aaHints; + + if (uiAAHint != map.get(KEY_TEXT_ANTIALIASING)) { + throw new RuntimeException("UI defaults contains wrong aa hint"); + } + + if (uiLCDContrastHint != map.get(KEY_TEXT_LCD_CONTRAST)) { + throw new RuntimeException("UI defaults contains wrong" + + "lcd contrast hint"); + } + } else if (uiAAHint != null || uiLCDContrastHint != null) { + throw new RuntimeException("Rendering hints set for empty desktop" + + "properties"); + } + } + + private static class CustomLookAndFeel extends BasicLookAndFeel { + + private final boolean useAAHints; + + public CustomLookAndFeel(boolean useAAHints) { + this.useAAHints = useAAHints; + } + + @Override + public String getDescription() { + return getName(); + } + + @Override + public String getName() { + return "Custom L&F"; + } + + @Override + public String getID() { + return getName(); + } + + @Override + public boolean isNativeLookAndFeel() { + return false; + } + + @Override + public boolean isSupportedLookAndFeel() { + return true; + } + + @Override + protected void initClassDefaults(UIDefaults table) { + super.initClassDefaults(table); + table.put(KEY_TEXT_ANTIALIASING, getAAHint()); + table.put(KEY_TEXT_LCD_CONTRAST, getLCDContarstHint()); + } + + private Object getAAHint() { + return useAAHints ? VALUE_TEXT_ANTIALIAS_GASP : null; + } + + private Object getLCDContarstHint() { + return useAAHints ? 115 : null; + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/swing/UIDefaults/8133926/InternalFrameIcon.java Tue Sep 08 15:39:53 2015 -0700 @@ -0,0 +1,61 @@ +/* + * 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 javax.swing.Icon; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; + +import static javax.swing.UIManager.getInstalledLookAndFeels; + +/** + * @test + * @bug 8133926 + */ +public final class InternalFrameIcon implements Runnable { + + public static void main(final String[] args) throws Exception { + for (final UIManager.LookAndFeelInfo laf : getInstalledLookAndFeels()) { + SwingUtilities.invokeAndWait(() -> setLookAndFeel(laf)); + SwingUtilities.invokeAndWait(new InternalFrameIcon()); + } + } + + private static void setLookAndFeel(final UIManager.LookAndFeelInfo laf) { + try { + UIManager.setLookAndFeel(laf.getClassName()); + System.out.println("LookAndFeel: " + laf.getClassName()); + } catch (ClassNotFoundException | InstantiationException | + UnsupportedLookAndFeelException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + + @Override + public void run() { + Object o = UIManager.getDefaults().get("InternalFrame.icon"); + if (o != null && !(o instanceof Icon)) { + throw new RuntimeException("Wrong object: " + o); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/swing/text/Utilities/8134721/bug8134721.java Tue Sep 08 15:39:53 2015 -0700 @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Graphics; +import java.awt.image.BufferedImage; +import javax.swing.SwingUtilities; +import javax.swing.text.Segment; +import javax.swing.text.Utilities; + +/** + * @test + * @bug 8134721 + * @author Alexandr Scherbatiy + * @summary NPE in SwingUtilities2.drawChars after JDK-6302464 + */ +public class bug8134721 { + + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(bug8134721::testNPE); + } + + private static void testNPE() { + + Graphics g = null; + try { + String test = "\ttest\ttest2"; + BufferedImage buffImage = new BufferedImage( + 100, 100, BufferedImage.TYPE_INT_RGB); + g = buffImage.createGraphics(); + Segment segment = new Segment(test.toCharArray(), 0, test.length()); + Utilities.drawTabbedText(segment, 0, 0, g, null, 0); + } finally { + if (g != null) { + g.dispose(); + } + } + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sun/java2d/SunGraphics2D/SurfaceDestination/SurfaceDestination.java Tue Sep 08 15:39:53 2015 -0700 @@ -0,0 +1,84 @@ +/* + * 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.Component; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.Image; +import java.awt.Window; +import java.awt.image.BufferedImage; + +import sun.java2d.SunGraphics2D; + +import static java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment; +import static java.awt.Transparency.BITMASK; +import static java.awt.Transparency.OPAQUE; +import static java.awt.Transparency.TRANSLUCENT; +import static java.awt.image.BufferedImage.TYPE_INT_ARGB; + +/** + * @test + * @bug 8134603 + * @modules java.desktop/sun.java2d + * @run main/othervm SurfaceDestination + */ +public final class SurfaceDestination { + + public static void main(final String[] args) { + final GraphicsEnvironment lge = getLocalGraphicsEnvironment(); + final GraphicsDevice dev = lge.getDefaultScreenDevice(); + final GraphicsConfiguration config = dev.getDefaultConfiguration(); + + test(config.createCompatibleImage(10, 10).getGraphics()); + test(config.createCompatibleImage(10, 10, OPAQUE).getGraphics()); + test(config.createCompatibleImage(10, 10, BITMASK).getGraphics()); + test(config.createCompatibleImage(10, 10, TRANSLUCENT).getGraphics()); + + test(new BufferedImage(10, 10, TYPE_INT_ARGB).getGraphics()); + + final Window frame = new Frame(); + frame.pack(); + try { + test(frame.getGraphics()); + test(frame.createImage(10, 10).getGraphics()); + } finally { + frame.dispose(); + } + } + + private static void test(final Graphics graphics) { + try { + if (graphics instanceof SunGraphics2D) { + final Object dst = ((SunGraphics2D) graphics).getDestination(); + if (!(dst instanceof Image) && !(dst instanceof Component)) { + throw new RuntimeException("Wrong type:" + dst); + } + } + } finally { + graphics.dispose(); + } + } +}
--- a/test/sun/security/provider/certpath/Extensions/OCSPNonceExtensionTests.java Thu Sep 03 15:48:24 2015 -0700 +++ b/test/sun/security/provider/certpath/Extensions/OCSPNonceExtensionTests.java Tue Sep 08 15:39:53 2015 -0700 @@ -79,14 +79,11 @@ Map<String, TestCase> testList = new LinkedHashMap<String, TestCase>() {{ put("CTOR Test (provide length)", testCtorByLength); + put("CTOR Test (provide nonce bytes)", testCtorByValue); + put("CTOR Test (set criticality forms)", testCtorCritForms); put("CTOR Test (provide extension DER encoding)", testCtorSuperByDerValue); - put("Use set() call to provide random data", testResetValue); - put("Test get() method", testGet); - put("test set() method", testSet); - put("Test getElements() method", testGetElements); put("Test getName() method", testGetName); - put("Test delete() method", testDelete); }}; System.out.println("============ Tests ============"); @@ -179,6 +176,20 @@ Boolean pass = Boolean.FALSE; String message = null; try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { + // Try sending in a negative length + try { + Extension negLenNonce = new OCSPNonceExtension(-8); + throw new RuntimeException( + "Accepted a negative length nonce"); + } catch (IllegalArgumentException iae) { } + + // How about a zero length? + try { + Extension zeroLenNonce = new OCSPNonceExtension(0); + throw new RuntimeException("Accepted a zero length nonce"); + } catch (IllegalArgumentException iae) { } + + // Valid input to constructor Extension nonceByLen = new OCSPNonceExtension(32); // Verify overall encoded extension structure @@ -216,6 +227,82 @@ } }; + public static final TestCase testCtorByValue = new TestCase() { + @Override + public Map.Entry<Boolean, String> runTest() { + Boolean pass = Boolean.FALSE; + String message = null; + try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { + + // Try giving a null value for the nonce + try { + Extension nullNonce = new OCSPNonceExtension(null); + throw new RuntimeException("Accepted a null nonce"); + } catch (NullPointerException npe) { } + + // How about a zero-length byte array? + try { + Extension zeroLenNonce = + new OCSPNonceExtension(new byte[0]); + throw new RuntimeException("Accepted a zero length nonce"); + } catch (IllegalArgumentException iae) { } + + OCSPNonceExtension nonceByValue = + new OCSPNonceExtension(DEADBEEF_16); + + // Verify overall encoded extension structure + nonceByValue.encode(baos); + verifyExtStructure(baos.toByteArray()); + + // Verify the name, elements, and data conform to + // expected values for this specific object. + boolean crit = nonceByValue.isCritical(); + String oid = nonceByValue.getId(); + byte[] nonceData = nonceByValue.getNonceValue(); + + if (crit) { + message = "Extension incorrectly marked critical"; + } else if (!oid.equals(OCSP_NONCE_OID)) { + message = "Incorrect OID (Got " + oid + ", Expected " + + OCSP_NONCE_OID + ")"; + } else if (!Arrays.equals(nonceData, DEADBEEF_16)) { + message = "Returned nonce value did not match input"; + } else { + pass = Boolean.TRUE; + } + } catch (Exception e) { + e.printStackTrace(System.out); + message = e.getClass().getName(); + } + + return new AbstractMap.SimpleEntry<>(pass, message); + } + }; + + public static final TestCase testCtorCritForms = new TestCase() { + @Override + public Map.Entry<Boolean, String> runTest() { + Boolean pass = Boolean.FALSE; + String message = null; + try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { + Extension nonceByLength = new OCSPNonceExtension(true, 32); + Extension nonceByValue = + new OCSPNonceExtension(true, DEADBEEF_16); + pass = nonceByLength.isCritical() && nonceByValue.isCritical(); + if (!pass) { + message = "nonceByLength or nonceByValue was not marked " + + "critical as expected"; + } + } catch (Exception e) { + e.printStackTrace(System.out); + message = e.getClass().getName(); + } + + return new AbstractMap.SimpleEntry<>(pass, message); + } + }; + + public static final TestCase testCtorSuperByDerValue = new TestCase() { @Override public Map.Entry<Boolean, String> runTest() { @@ -260,145 +347,6 @@ } }; - public static final TestCase testResetValue = new TestCase() { - @Override - public Map.Entry<Boolean, String> runTest() { - Boolean pass = Boolean.FALSE; - String message = null; - try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { - OCSPNonceExtension nonce = new OCSPNonceExtension(32); - - // Reset the nonce data to reflect 16 bytes of DEADBEEF - nonce.set(OCSPNonceExtension.NONCE, (Object)DEADBEEF_16); - - // Verify overall encoded extension content - nonce.encode(baos); - dumpHexBytes(OCSP_NONCE_DB16); - System.out.println(); - dumpHexBytes(baos.toByteArray()); - - pass = Arrays.equals(baos.toByteArray(), OCSP_NONCE_DB16); - } catch (Exception e) { - e.printStackTrace(System.out); - message = e.getClass().getName(); - } - - return new AbstractMap.SimpleEntry<>(pass, message); - } - }; - - public static final TestCase testSet = new TestCase() { - @Override - public Map.Entry<Boolean, String> runTest() { - Boolean pass = Boolean.FALSE; - String message = null; - try { - OCSPNonceExtension nonceByLen = new OCSPNonceExtension(32); - - // Set the nonce data to 16 bytes of DEADBEEF - nonceByLen.set(ELEMENT_NONCE, DEADBEEF_16); - byte[] nonceData = (byte[])nonceByLen.get(ELEMENT_NONCE); - if (!Arrays.equals(nonceData, DEADBEEF_16)) { - throw new RuntimeException("Retuned nonce data does not " + - "match expected result"); - } - - // Now try to set a value using an object that is not a byte - // array - int[] INT_DB_16 = { - 0xDEADBEEF, 0xDEADBEEF, 0xDEADBEEF, 0xDEADBEEF - }; - try { - nonceByLen.set(ELEMENT_NONCE, INT_DB_16); - throw new RuntimeException("Accepted get() for " + - "unsupported element name"); - } catch (IOException ioe) { } // Expected result - - // And try setting a value using an unknown element name - try { - nonceByLen.set("FOO", DEADBEEF_16); - throw new RuntimeException("Accepted get() for " + - "unsupported element name"); - } catch (IOException ioe) { } // Expected result - - pass = Boolean.TRUE; - } catch (Exception e) { - e.printStackTrace(System.out); - message = e.getClass().getName(); - } - - return new AbstractMap.SimpleEntry<>(pass, message); - } - }; - - public static final TestCase testGet = new TestCase() { - @Override - public Map.Entry<Boolean, String> runTest() { - Boolean pass = Boolean.FALSE; - String message = null; - try { - OCSPNonceExtension nonceByLen = new OCSPNonceExtension(32); - - // Grab the nonce data by its correct element name - byte[] nonceData = (byte[])nonceByLen.get(ELEMENT_NONCE); - if (nonceData == null || nonceData.length != 32) { - throw new RuntimeException("Unexpected return value from " + - "get() method: either null or incorrect length"); - } - - // Now try to get any kind of data using an element name that - // doesn't exist for this extension. - try { - nonceByLen.get("FOO"); - throw new RuntimeException("Accepted get() for " + - "unsupported element name"); - } catch (IOException ioe) { } // Expected result - - pass = Boolean.TRUE; - } catch (Exception e) { - e.printStackTrace(System.out); - message = e.getClass().getName(); - } - - return new AbstractMap.SimpleEntry<>(pass, message); - } - }; - - public static final TestCase testGetElements = new TestCase() { - @Override - public Map.Entry<Boolean, String> runTest() { - Boolean pass = Boolean.FALSE; - String message = null; - try { - OCSPNonceExtension nonceByLen = new OCSPNonceExtension(32); - - int elementCount = 0; - boolean foundElement = false; - - // There should be exactly one element and its name should - // be "nonce" - for (Enumeration<String> elements = nonceByLen.getElements(); - elements.hasMoreElements(); elementCount++) { - if (elements.nextElement().equals(ELEMENT_NONCE)) { - foundElement = true; - } - } - - if (!foundElement || elementCount != 1) { - throw new RuntimeException("Unexpected or missing " + - "Enumeration element"); - } - - pass = Boolean.TRUE; - } catch (Exception e) { - e.printStackTrace(System.out); - message = e.getClass().getName(); - } - - return new AbstractMap.SimpleEntry<>(pass, message); - } - }; - public static final TestCase testGetName = new TestCase() { @Override public Map.Entry<Boolean, String> runTest() { @@ -415,44 +363,4 @@ return new AbstractMap.SimpleEntry<>(pass, message); } }; - - public static final TestCase testDelete = new TestCase() { - @Override - public Map.Entry<Boolean, String> runTest() { - Boolean pass = Boolean.FALSE; - String message = null; - try { - OCSPNonceExtension nonceByLen = new OCSPNonceExtension(32); - - // First verify that there's data to begin with - byte[] nonceData = (byte[])nonceByLen.get(ELEMENT_NONCE); - if (nonceData == null || nonceData.length != 32) { - throw new RuntimeException("Unexpected return value from " + - "get() method: either null or incorrect length"); - } - - // Attempt to delete using an element name that doesn't exist - // for this extension. - try { - nonceByLen.delete("FOO"); - throw new RuntimeException("Accepted delete() for " + - "unsupported element name"); - } catch (IOException ioe) { } // Expected result - - // Now attempt to properly delete the extension data - nonceByLen.delete(ELEMENT_NONCE); - nonceData = (byte[])nonceByLen.get(ELEMENT_NONCE); - if (nonceData != null) { - throw new RuntimeException("Unexpected non-null return"); - } - - pass = Boolean.TRUE; - } catch (Exception e) { - e.printStackTrace(System.out); - message = e.getClass().getName(); - } - - return new AbstractMap.SimpleEntry<>(pass, message); - } - }; }
--- a/test/sun/tools/jps/JpsBase.java Thu Sep 03 15:48:24 2015 -0700 +++ b/test/sun/tools/jps/JpsBase.java Tue Sep 08 15:39:53 2015 -0700 @@ -138,6 +138,8 @@ String tmp = str.replace("\\", "\\\\"); tmp = tmp.replace("+", "\\+"); tmp = tmp.replace(".", "\\."); + tmp = tmp.replace("\n", "\\\\n"); + tmp = tmp.replace("\r", "\\\\r"); return tmp; }
--- a/test/sun/tools/jps/JpsHelper.java Thu Sep 03 15:48:24 2015 -0700 +++ b/test/sun/tools/jps/JpsHelper.java Tue Sep 08 15:39:53 2015 -0700 @@ -97,7 +97,10 @@ * VM arguments to start test application with. * -XX:+UsePerfData is required for running the tests on embedded platforms. */ - public static final String[] VM_ARGS = {"-XX:+UsePerfData", "-Xmx512m", "-XX:+PrintGCDetails"}; + public static final String[] VM_ARGS = { + "-XX:+UsePerfData", "-Xmx512m", "-XX:+PrintGCDetails", + "-Dmultiline.prop=value1\nvalue2\r\nvalue3" + }; /** * VM flag to start test application with */