Mercurial > hg > release > icedtea7-forest-2.6 > jdk
changeset 6969:9fb20c70c89d
Merge
author | mullan |
---|---|
date | Wed, 01 May 2013 17:25:18 -0400 |
parents | 5872319f9adf (current diff) 3095097842e1 (diff) |
children | 63bf3f0ba262 |
files | |
diffstat | 26 files changed, 898 insertions(+), 172 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgtags Wed May 01 17:19:04 2013 -0400 +++ b/.hgtags Wed May 01 17:25:18 2013 -0400 @@ -272,3 +272,4 @@ 5748526c96f0d3fd5771b72a81fcd61f4e23b0d8 jdk7u25-b06 fe514475bc17355f5f0a8dc7dd423d0043ed5326 jdk7u25-b07 f8373784a79eba32b47e655cc5880f594a12423c jdk7u25-b08 +023297d5b047c0b6c54869d6514fa3c1427c206c jdk7u25-b09
--- a/src/macosx/lib/flavormap.properties Wed May 01 17:19:04 2013 -0400 +++ b/src/macosx/lib/flavormap.properties Wed May 01 17:25:18 2013 -0400 @@ -1,7 +1,7 @@ # # This properties file is used to initialize the default -# java.awt.datatransfer.SystemFlavorMap. It contains the X11 platform-specific, -# default mappings between common X11 selection atoms and platform-independent +# java.awt.datatransfer.SystemFlavorMap. It contains the Mac OS X platform-specific, +# default mappings between common Mac OS X selection atoms and platform-independent # MIME type strings, which will be converted into # java.awt.datatransfer.DataFlavors. # @@ -76,3 +76,5 @@ text/uri-list=application/x-java-file-list;class=java.util.List PNG=image/x-java-image;class=java.awt.Image JFIF=image/x-java-image;class=java.awt.Image +RICH_TEXT=text/rtf +HTML=text/html;charset=utf-8;eoln="\r\n";terminators=1
--- a/src/share/classes/java/awt/image/BufferedImage.java Wed May 01 17:19:04 2013 -0400 +++ b/src/share/classes/java/awt/image/BufferedImage.java Wed May 01 17:25:18 2013 -0400 @@ -654,17 +654,19 @@ int csType = cs.getType(); if (csType != ColorSpace.TYPE_RGB) { if (csType == ColorSpace.TYPE_GRAY - && cm instanceof ComponentColorModel) { + && ComponentColorModel.class.equals(cm.getClass())) { // Check if this might be a child raster (fix for bug 4240596) if (sm instanceof ComponentSampleModel && ((ComponentSampleModel)sm).getPixelStride() != numBands) { imageType = TYPE_CUSTOM; } else if (raster instanceof ByteComponentRaster && + PixelInterleavedSampleModel.class.equals(sm.getClass()) && raster.getNumBands() == 1 && cm.getComponentSize(0) == 8 && ((ByteComponentRaster)raster).getPixelStride() == 1) { imageType = TYPE_BYTE_GRAY; } else if (raster instanceof ShortComponentRaster && + PixelInterleavedSampleModel.class.equals(sm.getClass()) && raster.getNumBands() == 1 && cm.getComponentSize(0) == 16 && ((ShortComponentRaster)raster).getPixelStride() == 1) { @@ -684,7 +686,8 @@ // are correct int pixSize = cm.getPixelSize(); if (iraster.getPixelStride() == 1 && - cm instanceof DirectColorModel && + DirectColorModel.class.equals(cm.getClass()) && + SinglePixelPackedSampleModel.class.equals(sm.getClass()) && (pixSize == 32 || pixSize == 24)) { // Now check on the DirectColorModel params @@ -715,16 +718,21 @@ } // if (rmask == DCM_BGR_RED_MASK && } // if (iraster.getPixelStride() == 1 } // ((raster instanceof IntegerComponentRaster) && - else if ((cm instanceof IndexColorModel) && (numBands == 1) && + else if ((IndexColorModel.class.equals(cm.getClass())) && + (numBands == 1) && (!cm.hasAlpha() || !isAlphaPre)) { IndexColorModel icm = (IndexColorModel) cm; int pixSize = icm.getPixelSize(); - if (raster instanceof BytePackedRaster) { + if (raster instanceof BytePackedRaster && + MultiPixelPackedSampleModel.class.equals(sm.getClass())) + { imageType = TYPE_BYTE_BINARY; } // if (raster instanceof BytePackedRaster) - else if (raster instanceof ByteComponentRaster) { + else if (raster instanceof ByteComponentRaster && + PixelInterleavedSampleModel.class.equals(sm.getClass())) + { ByteComponentRaster braster = (ByteComponentRaster) raster; if (braster.getPixelStride() == 1 && pixSize <= 8) { imageType = TYPE_BYTE_INDEXED; @@ -732,7 +740,8 @@ } } // else if (cm instanceof IndexColorModel) && (numBands == 1)) else if ((raster instanceof ShortComponentRaster) - && (cm instanceof DirectColorModel) + && (DirectColorModel.class.equals(cm.getClass())) + && (SinglePixelPackedSampleModel.class.equals(sm.getClass())) && (numBands == 3) && !cm.hasAlpha()) { @@ -779,12 +788,14 @@ braster.getPixelStride() == numBands && offs[0] == numBands-1 && offs[1] == numBands-2 && - offs[2] == numBands-3) + offs[2] == numBands-3 && + ComponentColorModel.class.equals(ccm.getClass()) && + PixelInterleavedSampleModel.class.equals(csm.getClass())) { - if (numBands == 3) { + if (numBands == 3 && !ccm.hasAlpha()) { imageType = TYPE_3BYTE_BGR; } - else if (offs[3] == 0) { + else if (offs[3] == 0 && ccm.hasAlpha()) { imageType = (isAlphaPre ? TYPE_4BYTE_ABGR_PRE : TYPE_4BYTE_ABGR);
--- a/src/share/classes/java/io/ObjectStreamClass.java Wed May 01 17:19:04 2013 -0400 +++ b/src/share/classes/java/io/ObjectStreamClass.java Wed May 01 17:25:18 2013 -0400 @@ -266,9 +266,11 @@ if (cl == null) { return null; } - Class<?> caller = Reflection.getCallerClass(); - if (ReflectUtil.needsPackageAccessCheck(caller.getClassLoader(), cl.getClassLoader())) { - ReflectUtil.checkPackageAccess(cl); + if (System.getSecurityManager() != null) { + Class<?> caller = Reflection.getCallerClass(); + if (ReflectUtil.needsPackageAccessCheck(caller.getClassLoader(), cl.getClassLoader())) { + ReflectUtil.checkPackageAccess(cl); + } } return cl; }
--- a/src/share/classes/java/io/ObjectStreamField.java Wed May 01 17:19:04 2013 -0400 +++ b/src/share/classes/java/io/ObjectStreamField.java Wed May 01 17:25:18 2013 -0400 @@ -162,9 +162,11 @@ */ @CallerSensitive public Class<?> getType() { - Class<?> caller = Reflection.getCallerClass(); - if (ReflectUtil.needsPackageAccessCheck(caller.getClassLoader(), type.getClassLoader())) { - ReflectUtil.checkPackageAccess(type); + if (System.getSecurityManager() != null) { + Class<?> caller = Reflection.getCallerClass(); + if (ReflectUtil.needsPackageAccessCheck(caller.getClassLoader(), type.getClassLoader())) { + ReflectUtil.checkPackageAccess(type); + } } return type; }
--- a/src/share/classes/sun/awt/AppContext.java Wed May 01 17:19:04 2013 -0400 +++ b/src/share/classes/sun/awt/AppContext.java Wed May 01 17:25:18 2013 -0400 @@ -801,16 +801,24 @@ static { sun.misc.SharedSecrets.setJavaAWTAccess(new sun.misc.JavaAWTAccess() { public Object get(Object key) { - return getAppContext().get(key); + AppContext ac = getAppContext(); + return (ac == null) ? null : ac.get(key); } public void put(Object key, Object value) { - getAppContext().put(key, value); + AppContext ac = getAppContext(); + if (ac != null) { + ac.put(key, value); + } } public void remove(Object key) { - getAppContext().remove(key); + AppContext ac = getAppContext(); + if (ac != null) { + ac.remove(key); + } } public boolean isDisposed() { - return getAppContext().isDisposed(); + AppContext ac = getAppContext(); + return (ac == null) ? true : ac.isDisposed(); } public boolean isMainAppContext() { return (numAppContexts.get() == 1 && mainAppContext != null);
--- a/src/share/classes/sun/misc/SharedSecrets.java Wed May 01 17:19:04 2013 -0400 +++ b/src/share/classes/sun/misc/SharedSecrets.java Wed May 01 17:25:18 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -197,6 +197,9 @@ public static JavaAWTAccess getJavaAWTAccess() { // this may return null in which case calling code needs to // provision for. + if (javaAWTAccess == null || javaAWTAccess.getContext() == null) { + return null; + } return javaAWTAccess; } }
--- a/src/share/classes/sun/security/provider/certpath/CertPathHelper.java Wed May 01 17:19:04 2013 -0400 +++ b/src/share/classes/sun/security/provider/certpath/CertPathHelper.java Wed May 01 17:25:18 2013 -0400 @@ -64,7 +64,7 @@ instance.implSetPathToNames(sel, names); } - static void setDateAndTime(X509CRLSelector sel, Date date, long skew) { + public static void setDateAndTime(X509CRLSelector sel, Date date, long skew) { instance.implSetDateAndTime(sel, date, skew); } }
--- a/src/share/classes/sun/security/provider/certpath/CrlRevocationChecker.java Wed May 01 17:19:04 2013 -0400 +++ b/src/share/classes/sun/security/provider/certpath/CrlRevocationChecker.java Wed May 01 17:25:18 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -308,11 +308,9 @@ mPossibleCRLs.add((X509CRL)crl); } } - DistributionPointFetcher store = - DistributionPointFetcher.getInstance(); // all CRLs returned by the DP Fetcher have also been verified - mApprovedCRLs.addAll(store.getCRLs(sel, signFlag, prevKey, - mSigProvider, mStores, reasonsMask, trustAnchors, + mApprovedCRLs.addAll(DistributionPointFetcher.getCRLs(sel, signFlag, + prevKey, mSigProvider, mStores, reasonsMask, trustAnchors, mParams.getDate())); } catch (Exception e) { if (debug != null) { @@ -762,14 +760,12 @@ CRLDistributionPointsExtension.POINTS); } Set<X509CRL> results = new HashSet<X509CRL>(); - DistributionPointFetcher dpf = - DistributionPointFetcher.getInstance(); for (Iterator<DistributionPoint> t = points.iterator(); t.hasNext() && !Arrays.equals(reasonsMask, ALL_REASONS); ) { DistributionPoint point = t.next(); for (X509CRL crl : crls) { - if (dpf.verifyCRL(certImpl, point, crl, reasonsMask, - signFlag, prevKey, mSigProvider, + if (DistributionPointFetcher.verifyCRL(certImpl, point, crl, + reasonsMask, signFlag, prevKey, mSigProvider, trustAnchors, mStores, mParams.getDate())) { results.add(crl); }
--- a/src/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java Wed May 01 17:19:04 2013 -0400 +++ b/src/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java Wed May 01 17:25:18 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,7 @@ * @author Sean Mullan * @since 1.4.2 */ -class DistributionPointFetcher { +public class DistributionPointFetcher { private static final Debug debug = Debug.getInstance("certpath"); @@ -65,34 +65,28 @@ private final static boolean USE_CRLDP = AccessController.doPrivileged (new GetBooleanAction("com.sun.security.enableCRLDP")); - // singleton instance - private static final DistributionPointFetcher INSTANCE = - new DistributionPointFetcher(); - /** * Private instantiation only. */ private DistributionPointFetcher() {} /** - * Return a DistributionPointFetcher instance. - */ - static DistributionPointFetcher getInstance() { - return INSTANCE; - } - - /** * Return the X509CRLs matching this selector. The selector must be * an X509CRLSelector with certificateChecking set. * * If CRLDP support is disabled, this method always returns an * empty set. */ - Collection<X509CRL> getCRLs(X509CRLSelector selector, boolean signFlag, - PublicKey prevKey, String provider, List<CertStore> certStores, - boolean[] reasonsMask, Set<TrustAnchor> trustAnchors, - Date validity) throws CertStoreException { - + public static Collection<X509CRL> getCRLs(X509CRLSelector selector, + boolean signFlag, + PublicKey prevKey, + String provider, + List<CertStore> certStores, + boolean[] reasonsMask, + Set<TrustAnchor> trustAnchors, + Date validity) + throws CertStoreException + { if (USE_CRLDP == false) { return Collections.emptySet(); } @@ -140,7 +134,7 @@ * Download CRLs from the given distribution point, verify and return them. * See the top of the class for current limitations. */ - private Collection<X509CRL> getCRLs(X509CRLSelector selector, + private static Collection<X509CRL> getCRLs(X509CRLSelector selector, X509CertImpl certImpl, DistributionPoint point, boolean[] reasonsMask, boolean signFlag, PublicKey prevKey, String provider, List<CertStore> certStores, Set<TrustAnchor> trustAnchors, @@ -214,7 +208,7 @@ /** * Download CRL from given URI. */ - private X509CRL getCRL(URIName name) { + private static X509CRL getCRL(URIName name) { URI uri = name.getURI(); if (debug != null) { debug.println("Trying to fetch CRL from DP " + uri); @@ -240,7 +234,7 @@ /** * Fetch CRLs from certStores. */ - private Collection<X509CRL> getCRLs(X500Name name, + private static Collection<X509CRL> getCRLs(X500Name name, X500Principal certIssuer, List<CertStore> certStores) { if (debug != null) { @@ -285,7 +279,7 @@ * certification path should be determined * @return true if ok, false if not */ - boolean verifyCRL(X509CertImpl certImpl, DistributionPoint point, + static boolean verifyCRL(X509CertImpl certImpl, DistributionPoint point, X509CRL crl, boolean[] reasonsMask, boolean signFlag, PublicKey prevKey, String provider, Set<TrustAnchor> trustAnchors, List<CertStore> certStores, @@ -670,7 +664,7 @@ * Append relative name to the issuer name and return a new * GeneralNames object. */ - private GeneralNames getFullNames(X500Name issuer, RDN rdn) + private static GeneralNames getFullNames(X500Name issuer, RDN rdn) throws IOException { List<RDN> rdns = new ArrayList<RDN>(issuer.rdns()); rdns.add(rdn);
--- a/src/share/classes/sun/security/provider/certpath/OCSP.java Wed May 01 17:19:04 2013 -0400 +++ b/src/share/classes/sun/security/provider/certpath/OCSP.java Wed May 01 17:25:18 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,6 +42,7 @@ import java.util.Map; import static sun.security.provider.certpath.OCSPResponse.*; +import sun.security.action.GetIntegerAction; import sun.security.util.Debug; import sun.security.x509.AccessDescription; import sun.security.x509.AuthorityInfoAccessExtension; @@ -64,7 +65,30 @@ private static final Debug debug = Debug.getInstance("certpath"); - private static final int CONNECT_TIMEOUT = 15000; // 15 seconds + private static final int DEFAULT_CONNECT_TIMEOUT = 15000; + + /** + * Integer value indicating the timeout length, in seconds, to be + * used for the OCSP check. A timeout of zero is interpreted as + * an infinite timeout. + */ + private static final int CONNECT_TIMEOUT = initializeTimeout(); + + /** + * Initialize the timeout length by getting the OCSP timeout + * system property. If the property has not been set, or if its + * value is negative, set the timeout length to the default. + */ + private static int initializeTimeout() { + Integer tmp = java.security.AccessController.doPrivileged( + new GetIntegerAction("com.sun.security.ocsp.timeout")); + if (tmp == null || tmp < 0) { + tmp = DEFAULT_CONNECT_TIMEOUT; + } + // Convert to milliseconds, as the system property will be + // specified in seconds + return tmp * 1000; + } private OCSP() {}
--- a/src/share/classes/sun/security/provider/certpath/OCSPResponse.java Wed May 01 17:19:04 2013 -0400 +++ b/src/share/classes/sun/security/provider/certpath/OCSPResponse.java Wed May 01 17:25:18 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,6 +41,7 @@ import java.util.List; import java.util.Map; import sun.misc.HexDumpEncoder; +import sun.security.action.GetIntegerAction; import sun.security.x509.*; import sun.security.util.*; @@ -148,9 +149,31 @@ private final ResponseStatus responseStatus; private final Map<CertId, SingleResponse> singleResponseMap; - // Maximum clock skew in milliseconds (15 minutes) allowed when checking - // validity of OCSP responses - private static final long MAX_CLOCK_SKEW = 900000; + // Default maximum clock skew in milliseconds (15 minutes) + // allowed when checking validity of OCSP responses + private static final int DEFAULT_MAX_CLOCK_SKEW = 900000; + + /** + * Integer value indicating the maximum allowable clock skew, in seconds, + * to be used for the OCSP check. + */ + private static final int MAX_CLOCK_SKEW = initializeClockSkew(); + + /** + * Initialize the maximum allowable clock skew by getting the OCSP + * clock skew system property. If the property has not been set, or if its + * value is negative, set the skew to the default. + */ + private static int initializeClockSkew() { + Integer tmp = java.security.AccessController.doPrivileged( + new GetIntegerAction("com.sun.security.ocsp.clockSkew")); + if (tmp == null || tmp < 0) { + return DEFAULT_MAX_CLOCK_SKEW; + } + // Convert to milliseconds, as the system property will be + // specified in seconds + return tmp * 1000; + } // an array of all of the CRLReasons (used in SingleResponse) private static CRLReason[] values = CRLReason.values();
--- a/src/share/classes/sun/security/provider/certpath/URICertStore.java Wed May 01 17:19:04 2013 -0400 +++ b/src/share/classes/sun/security/provider/certpath/URICertStore.java Wed May 01 17:25:18 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,6 +53,7 @@ import java.util.Collections; import java.util.List; import java.util.Locale; +import sun.security.action.GetIntegerAction; import sun.security.x509.AccessDescription; import sun.security.x509.GeneralNameInterface; import sun.security.x509.URIName; @@ -149,6 +150,33 @@ } } + // Default maximum connect timeout in milliseconds (15 seconds) + // allowed when downloading CRLs + private static final int DEFAULT_CRL_CONNECT_TIMEOUT = 15000; + + /** + * Integer value indicating the connect timeout, in seconds, to be + * used for the CRL download. A timeout of zero is interpreted as + * an infinite timeout. + */ + private static final int CRL_CONNECT_TIMEOUT = initializeTimeout(); + + /** + * Initialize the timeout length by getting the CRL timeout + * system property. If the property has not been set, or if its + * value is negative, set the timeout length to the default. + */ + private static int initializeTimeout() { + Integer tmp = java.security.AccessController.doPrivileged( + new GetIntegerAction("com.sun.security.crl.timeout")); + if (tmp == null || tmp < 0) { + return DEFAULT_CRL_CONNECT_TIMEOUT; + } + // Convert to milliseconds, as the system property will be + // specified in seconds + return tmp * 1000; + } + /** * Creates a URICertStore. * @@ -395,6 +423,7 @@ if (lastModified != 0) { connection.setIfModifiedSince(lastModified); } + connection.setConnectTimeout(CRL_CONNECT_TIMEOUT); in = connection.getInputStream(); long oldLastModified = lastModified; lastModified = connection.getLastModified();
--- a/src/share/native/sun/awt/image/awt_parseImage.c Wed May 01 17:19:04 2013 -0400 +++ b/src/share/native/sun/awt/image/awt_parseImage.c Wed May 01 17:25:18 2013 -0400 @@ -396,10 +396,39 @@ return 1; } +static int getColorModelType(JNIEnv *env, jobject jcmodel) { + int type = UNKNOWN_CM_TYPE; + + if ((*env)->IsInstanceOf(env, jcmodel, + (*env)->FindClass(env, "java/awt/image/IndexColorModel"))) + { + type = INDEX_CM_TYPE; + } else if ((*env)->IsInstanceOf(env, jcmodel, + (*env)->FindClass(env, "java/awt/image/PackedColorModel"))) + { + if ((*env)->IsInstanceOf(env, jcmodel, + (*env)->FindClass(env, "java/awt/image/DirectColorModel"))) { + type = DIRECT_CM_TYPE; + } + else { + type = PACKED_CM_TYPE; + } + } + else if ((*env)->IsInstanceOf(env, jcmodel, + (*env)->FindClass(env, "java/awt/image/ComponentColorModel"))) + { + type = COMPONENT_CM_TYPE; + } + + return type; +} + int awt_parseColorModel (JNIEnv *env, jobject jcmodel, int imageType, ColorModelS_t *cmP) { /*jmethodID jID; */ jobject jnBits; + jsize nBitsLength; + int i; static jobject s_jdefCM = NULL; @@ -421,15 +450,55 @@ cmP->transparency = (*env)->GetIntField(env, jcmodel, g_CMtransparencyID); + jnBits = (*env)->GetObjectField(env, jcmodel, g_CMnBitsID); + if (jnBits == NULL) { + JNU_ThrowNullPointerException(env, "null nBits structure in CModel"); + return -1; + } + + nBitsLength = (*env)->GetArrayLength(env, jnBits); + if (nBitsLength != cmP->numComponents) { + // invalid number of components? + return -1; + } + + cmP->nBits = NULL; + if (SAFE_TO_ALLOC_2(cmP->numComponents, sizeof(jint))) { + cmP->nBits = (jint *)malloc(cmP->numComponents * sizeof(jint)); + } + + if (cmP->nBits == NULL){ + JNU_ThrowOutOfMemoryError(env, "Out of memory"); + return -1; + } + (*env)->GetIntArrayRegion(env, jnBits, 0, cmP->numComponents, + cmP->nBits); + cmP->maxNbits = 0; + for (i=0; i < cmP->numComponents; i++) { + if (cmP->maxNbits < cmP->nBits[i]) { + cmP->maxNbits = cmP->nBits[i]; + } + } + + cmP->is_sRGB = (*env)->GetBooleanField(env, cmP->jcmodel, g_CMis_sRGBID); + + cmP->csType = (*env)->GetIntField(env, cmP->jcmodel, g_CMcsTypeID); + + cmP->cmType = getColorModelType(env, jcmodel); + + cmP->isDefaultCM = FALSE; + cmP->isDefaultCompatCM = FALSE; + + /* look for standard cases */ if (imageType == java_awt_image_BufferedImage_TYPE_INT_ARGB) { cmP->isDefaultCM = TRUE; cmP->isDefaultCompatCM = TRUE; } else if (imageType == java_awt_image_BufferedImage_TYPE_INT_ARGB_PRE || - imageType == java_awt_image_BufferedImage_TYPE_INT_RGB) { - cmP->isDefaultCompatCM = TRUE; - } else if (imageType == java_awt_image_BufferedImage_TYPE_INT_BGR || + imageType == java_awt_image_BufferedImage_TYPE_INT_RGB || + imageType == java_awt_image_BufferedImage_TYPE_INT_BGR || imageType == java_awt_image_BufferedImage_TYPE_4BYTE_ABGR || - imageType == java_awt_image_BufferedImage_TYPE_4BYTE_ABGR_PRE){ + imageType == java_awt_image_BufferedImage_TYPE_4BYTE_ABGR_PRE) + { cmP->isDefaultCompatCM = TRUE; } else { @@ -450,50 +519,25 @@ cmP->isDefaultCompatCM = cmP->isDefaultCM; } + /* check whether image attributes correspond to default cm */ if (cmP->isDefaultCompatCM) { - cmP->cmType = DIRECT_CM_TYPE; - cmP->nBits = (jint *) malloc(sizeof(jint)*4); - cmP->nBits[0] = cmP->nBits[1] = cmP->nBits[2] = cmP->nBits[3] = 8; - cmP->maxNbits = 8; - cmP->is_sRGB = TRUE; - cmP->csType = java_awt_color_ColorSpace_TYPE_RGB; - - return 1; - } + if (cmP->csType != java_awt_color_ColorSpace_TYPE_RGB || + !cmP->is_sRGB) + { + return -1; + } - jnBits = (*env)->GetObjectField(env, jcmodel, g_CMnBitsID); - if (jnBits == NULL) { - JNU_ThrowNullPointerException(env, "null nBits structure in CModel"); - return -1; - } - - cmP->nBits = NULL; - if (SAFE_TO_ALLOC_2(cmP->numComponents, sizeof(jint))) { - cmP->nBits = (jint *)malloc(cmP->numComponents * sizeof(jint)); - } - if (cmP->nBits == NULL){ - JNU_ThrowOutOfMemoryError(env, "Out of memory"); - return -1; - } - (*env)->GetIntArrayRegion(env, jnBits, 0, cmP->numComponents, - cmP->nBits); - cmP->maxNbits = 0; - for (i=0; i < cmP->numComponents; i++) { - if (cmP->maxNbits < cmP->nBits[i]) { - cmP->maxNbits = cmP->nBits[i]; + for (i = 0; i < cmP->numComponents; i++) { + if (cmP->nBits[i] != 8) { + return -1; + } } } - cmP->is_sRGB = (*env)->GetBooleanField(env, cmP->jcmodel, g_CMis_sRGBID); - - cmP->csType = (*env)->GetIntField(env, cmP->jcmodel, g_CMcsTypeID); - - /* Find out what type of colol model */ + /* Get index color model attributes */ if (imageType == java_awt_image_BufferedImage_TYPE_BYTE_INDEXED || - (*env)->IsInstanceOf(env, jcmodel, - (*env)->FindClass(env, "java/awt/image/IndexColorModel"))) + cmP->cmType == INDEX_CM_TYPE) { - cmP->cmType = INDEX_CM_TYPE; cmP->transIdx = (*env)->GetIntField(env, jcmodel, g_ICMtransIdxID); cmP->mapSize = (*env)->GetIntField(env, jcmodel, g_ICMmapSizeID); cmP->jrgb = (*env)->GetObjectField(env, jcmodel, g_ICMrgbID); @@ -519,31 +563,6 @@ } } } - else if ((*env)->IsInstanceOf(env, jcmodel, - (*env)->FindClass(env, "java/awt/image/PackedColorModel"))) - { - if ((*env)->IsInstanceOf(env, jcmodel, - (*env)->FindClass(env, "java/awt/image/DirectColorModel"))){ - cmP->cmType = DIRECT_CM_TYPE; - } - else { - cmP->cmType = PACKED_CM_TYPE; - } - } - else if ((*env)->IsInstanceOf(env, jcmodel, - (*env)->FindClass(env, "java/awt/image/ComponentColorModel"))) - { - cmP->cmType = COMPONENT_CM_TYPE; - } - else if ((*env)->IsInstanceOf(env, jcmodel, - (*env)->FindClass(env, "java/awt/image/PackedColorModel"))) - { - cmP->cmType = PACKED_CM_TYPE; - } - else { - cmP->cmType = UNKNOWN_CM_TYPE; - } - return 1; } @@ -583,6 +602,13 @@ ColorModelS_t *cmodelP = &imageP->cmodel; int imageType = imageP->imageType; + // check whether raster and color model are compatible + if (cmodelP->numComponents != rasterP->numBands) { + if (cmodelP->cmType != INDEX_CM_TYPE) { + return -1; + } + } + hintP->numChans = imageP->cmodel.numComponents; hintP->colorOrder = NULL; if (SAFE_TO_ALLOC_2(hintP->numChans, sizeof(int))) { @@ -1074,6 +1100,10 @@ jsm = (*env)->GetObjectField(env, rasterP->jraster, g_RasterSampleModelID); jdatabuffer = (*env)->GetObjectField(env, rasterP->jraster, g_RasterDataBufferID); + if (band >= numBands) { + JNU_ThrowInternalError(env, "Band out of range."); + return -1; + } /* Here is the generic code */ jdata = (*env)->NewIntArray(env, maxBytes*rasterP->numBands*maxLines); if (JNU_IsNull(env, jdata)) { @@ -1082,11 +1112,6 @@ } if (band >= 0) { int dOff; - if (band >= numBands) { - (*env)->DeleteLocalRef(env, jdata); - JNU_ThrowInternalError(env, "Band out of range."); - return -1; - } off = 0; for (y=0; y < h; y+=maxLines) { if (y+maxLines > h) {
--- a/src/share/native/sun/awt/medialib/awt_ImagingLib.c Wed May 01 17:19:04 2013 -0400 +++ b/src/share/native/sun/awt/medialib/awt_ImagingLib.c Wed May 01 17:25:18 2013 -0400 @@ -2604,6 +2604,41 @@ return 0; } +#define ERR_BAD_IMAGE_LAYOUT (-2) + +#define CHECK_DST_ARRAY(start_offset, elements_per_pixel) \ + do { \ + int offset = (start_offset); \ + int lastScanOffset; \ + \ + if (!SAFE_TO_MULT(rasterP->scanlineStride, \ + (rasterP->height - 1))) \ + { \ + return ERR_BAD_IMAGE_LAYOUT; \ + } \ + lastScanOffset = rasterP->scanlineStride * \ + (rasterP->height - 1); \ + \ + if (!SAFE_TO_ADD(offset, lastScanOffset)) { \ + return ERR_BAD_IMAGE_LAYOUT; \ + } \ + lastScanOffset += offset; \ + \ + if (!SAFE_TO_MULT((elements_per_pixel), rasterP->width)) { \ + return ERR_BAD_IMAGE_LAYOUT; \ + } \ + offset = (elements_per_pixel) * rasterP->width; \ + \ + if (!SAFE_TO_ADD(offset, lastScanOffset)) { \ + return ERR_BAD_IMAGE_LAYOUT; \ + } \ + lastScanOffset += offset; \ + \ + if (dataArrayLength < lastScanOffset) { \ + return ERR_BAD_IMAGE_LAYOUT; \ + } \ + } while(0); \ + static int storeImageArray(JNIEnv *env, BufImageS_t *srcP, BufImageS_t *dstP, mlib_image *mlibImP) { @@ -2611,6 +2646,7 @@ unsigned char *cmDataP, *dataP, *cDataP; HintS_t *hintP = &dstP->hints; RasterS_t *rasterP = &dstP->raster; + jsize dataArrayLength = (*env)->GetArrayLength(env, rasterP->jdata); int y; /* REMIND: Store mlib data type? */ @@ -2629,14 +2665,15 @@ if (hintP->packing == BYTE_INTERLEAVED) { /* Write it back to the destination */ + CHECK_DST_ARRAY(hintP->channelOffset, hintP->numChans); cmDataP = (unsigned char *) mlib_ImageGetData(mlibImP); mStride = mlib_ImageGetStride(mlibImP); dataP = (unsigned char *)(*env)->GetPrimitiveArrayCritical(env, rasterP->jdata, NULL); if (dataP == NULL) return 0; - cDataP = dataP + hintP->dataOffset; + cDataP = dataP + hintP->channelOffset; for (y=0; y < rasterP->height; - y++, cmDataP += mStride, cDataP += hintP->sStride) + y++, cmDataP += mStride, cDataP += rasterP->scanlineStride) { memcpy(cDataP, cmDataP, rasterP->width*hintP->numChans); } @@ -2647,13 +2684,14 @@ /* Write it back to the destination */ unsigned short *sdataP, *sDataP; unsigned short *smDataP = (unsigned short *)mlib_ImageGetData(mlibImP); + CHECK_DST_ARRAY(hintP->channelOffset, hintP->numChans); mStride = mlib_ImageGetStride(mlibImP); sdataP = (unsigned short *)(*env)->GetPrimitiveArrayCritical(env, rasterP->jdata, NULL); if (sdataP == NULL) return -1; - sDataP = sdataP + hintP->dataOffset; + sDataP = sdataP + hintP->channelOffset; for (y=0; y < rasterP->height; - y++, smDataP += mStride, sDataP += hintP->sStride) + y++, smDataP += mStride, sDataP += rasterP->scanlineStride) { memcpy(sDataP, smDataP, rasterP->width*hintP->numChans); } @@ -3446,7 +3484,8 @@ unsigned char *inP = inDataP; unsigned char *lineOutP, *outP; jarray jOutDataP; - jint *outDataP; + jsize dataArrayLength; + unsigned char *outDataP; int loff[MAX_NUMBANDS], roff[MAX_NUMBANDS]; if (rasterP->numBands > MAX_NUMBANDS) { @@ -3455,11 +3494,18 @@ /* Grab data ptr, strides, offsets from raster */ jOutDataP = (*env)->GetObjectField(env, rasterP->jraster, g_BCRdataID); + if (JNU_IsNull(env, jOutDataP)) { + return -1; + } + + dataArrayLength = (*env)->GetArrayLength(env, jOutDataP); + CHECK_DST_ARRAY(rasterP->chanOffsets[0], 1); + outDataP = (*env)->GetPrimitiveArrayCritical(env, jOutDataP, 0); if (outDataP == NULL) { return -1; } - lineOutP = (unsigned char *)outDataP + rasterP->chanOffsets[0]; + lineOutP = outDataP + rasterP->chanOffsets[0]; if (component < 0) { for (c=0; c < rasterP->numBands; c++) { @@ -3514,7 +3560,8 @@ unsigned char *inP = inDataP; unsigned short *lineOutP, *outP; jarray jOutDataP; - jint *outDataP; + jsize dataArrayLength; + unsigned short *outDataP; int loff[MAX_NUMBANDS], roff[MAX_NUMBANDS]; if (rasterP->numBands > MAX_NUMBANDS) { @@ -3523,11 +3570,18 @@ /* Grab data ptr, strides, offsets from raster */ jOutDataP = (*env)->GetObjectField(env, rasterP->jraster, g_SCRdataID); + if (JNU_IsNull(env, jOutDataP)) { + return -1; + } + + dataArrayLength = (*env)->GetArrayLength(env, jOutDataP); + CHECK_DST_ARRAY(rasterP->chanOffsets[0], 1); + outDataP = (*env)->GetPrimitiveArrayCritical(env, jOutDataP, 0); if (outDataP == NULL) { return -1; } - lineOutP = (unsigned short *)outDataP + rasterP->chanOffsets[0]; + lineOutP = outDataP + rasterP->chanOffsets[0]; if (component < 0) { for (c=0; c < rasterP->numBands; c++) { @@ -3582,7 +3636,8 @@ unsigned char *inP = inDataP; unsigned int *lineOutP, *outP; jarray jOutDataP; - jint *outDataP; + jsize dataArrayLength; + unsigned int *outDataP; int loff[MAX_NUMBANDS], roff[MAX_NUMBANDS]; if (rasterP->numBands > MAX_NUMBANDS) { @@ -3591,11 +3646,18 @@ /* Grab data ptr, strides, offsets from raster */ jOutDataP = (*env)->GetObjectField(env, rasterP->jraster, g_ICRdataID); + if (JNU_IsNull(env, jOutDataP)) { + return -1; + } + + dataArrayLength = (*env)->GetArrayLength(env, jOutDataP); + CHECK_DST_ARRAY(rasterP->chanOffsets[0], 1); + outDataP = (*env)->GetPrimitiveArrayCritical(env, jOutDataP, 0); if (outDataP == NULL) { return -1; } - lineOutP = (unsigned int *)outDataP + rasterP->chanOffsets[0]; + lineOutP = outDataP + rasterP->chanOffsets[0]; if (component < 0) { for (c=0; c < rasterP->numBands; c++) { @@ -3652,7 +3714,8 @@ unsigned char *inP = inDataP; unsigned char *lineOutP, *outP; jarray jOutDataP; - jint *outDataP; + jsize dataArrayLength; + unsigned char *outDataP; int loff[MAX_NUMBANDS], roff[MAX_NUMBANDS]; int a = rasterP->numBands - 1; @@ -3662,11 +3725,18 @@ /* Grab data ptr, strides, offsets from raster */ jOutDataP = (*env)->GetObjectField(env, rasterP->jraster, g_BCRdataID); + if (JNU_IsNull(env, jOutDataP)) { + return -1; + } + + dataArrayLength = (*env)->GetArrayLength(env, jOutDataP); + CHECK_DST_ARRAY(rasterP->chanOffsets[0], 1); + outDataP = (*env)->GetPrimitiveArrayCritical(env, jOutDataP, 0); if (outDataP == NULL) { return -1; } - lineOutP = (unsigned char *)outDataP + rasterP->chanOffsets[0]; + lineOutP = outDataP + rasterP->chanOffsets[0]; if (component < 0) { for (c=0; c < rasterP->numBands; c++) { @@ -3742,7 +3812,8 @@ unsigned char *inP = inDataP; unsigned short *lineOutP, *outP; jarray jOutDataP; - jint *outDataP; + jsize dataArrayLength; + unsigned short *outDataP; int loff[MAX_NUMBANDS], roff[MAX_NUMBANDS]; int a = rasterP->numBands - 1; @@ -3752,11 +3823,17 @@ /* Grab data ptr, strides, offsets from raster */ jOutDataP = (*env)->GetObjectField(env, rasterP->jraster, g_SCRdataID); + if (JNU_IsNull(env, jOutDataP)) { + return -1; + } + dataArrayLength = (*env)->GetArrayLength(env, jOutDataP); + CHECK_DST_ARRAY(rasterP->chanOffsets[0], 1); + outDataP = (*env)->GetPrimitiveArrayCritical(env, jOutDataP, 0); if (outDataP == NULL) { return -1; } - lineOutP = (unsigned short *)outDataP + rasterP->chanOffsets[0]; + lineOutP = outDataP + rasterP->chanOffsets[0]; if (component < 0) { for (c=0; c < rasterP->numBands; c++) { @@ -3832,7 +3909,8 @@ unsigned char *inP = inDataP; unsigned int *lineOutP, *outP; jarray jOutDataP; - jint *outDataP; + jsize dataArrayLength; + unsigned int *outDataP; int loff[MAX_NUMBANDS], roff[MAX_NUMBANDS]; int a = rasterP->numBands - 1; @@ -3842,11 +3920,18 @@ /* Grab data ptr, strides, offsets from raster */ jOutDataP = (*env)->GetObjectField(env, rasterP->jraster, g_ICRdataID); + if (JNU_IsNull(env, jOutDataP)) { + return -1; + } + + dataArrayLength = (*env)->GetArrayLength(env, jOutDataP); + CHECK_DST_ARRAY(rasterP->chanOffsets[0], 1); + outDataP = (*env)->GetPrimitiveArrayCritical(env, jOutDataP, 0); if (outDataP == NULL) { return -1; } - lineOutP = (unsigned int *)outDataP + rasterP->chanOffsets[0]; + lineOutP = outDataP + rasterP->chanOffsets[0]; if (component < 0) { for (c=0; c < rasterP->numBands; c++) {
--- a/test/com/sun/org/apache/xml/internal/security/transforms/ClassLoaderTest.java Wed May 01 17:19:04 2013 -0400 +++ b/test/com/sun/org/apache/xml/internal/security/transforms/ClassLoaderTest.java Wed May 01 17:25:18 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /** * @test * @author Sean Mullan - * @bug 6461674 + * @bug 6461674 8009217 * @compile -XDignore.symbol.file ClassLoaderTest.java MyTransform.java * @run main ClassLoaderTest * @summary Ensure Transform.register works with transform implementations @@ -43,13 +43,12 @@ public static void main(String[] args) throws Exception { - Transform.init(); File file = new File(BASE); URL[] urls = new URL[1]; urls[0] = file.toURI().toURL(); URLClassLoader ucl = new URLClassLoader(urls); - Class c = ucl.loadClass("MyTransform"); - Constructor cons = c.getConstructor(); + Class<?> c = ucl.loadClass("MyTransform"); + Constructor<?> cons = c.getConstructor(new Class[] {}); Object o = cons.newInstance(); // Apache code swallows the ClassNotFoundExc, so we need to // check if the Transform has already been registered by registering
--- a/test/com/sun/org/apache/xml/internal/security/transforms/MyTransform.java Wed May 01 17:19:04 2013 -0400 +++ b/test/com/sun/org/apache/xml/internal/security/transforms/MyTransform.java Wed May 01 17:25:18 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,13 +21,8 @@ * questions. */ -import java.io.IOException; -import javax.xml.parsers.ParserConfigurationException; -import org.xml.sax.SAXException; -import com.sun.org.apache.xml.internal.security.c14n.*; -import com.sun.org.apache.xml.internal.security.exceptions.*; -import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput; -import com.sun.org.apache.xml.internal.security.transforms.*; +import com.sun.org.apache.xml.internal.security.transforms.Transform; +import com.sun.org.apache.xml.internal.security.transforms.TransformSpi; public class MyTransform extends TransformSpi { @@ -37,21 +32,13 @@ public MyTransform() { try { System.out.println("Registering Transform"); - Transform.init(); Transform.register(URI, "MyTransform"); - } catch (AlgorithmAlreadyRegisteredException e) { - // should not occur, so ignore + } catch (Exception e) { + e.printStackTrace(); } } protected String engineGetURI() { return URI; } - - protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input) - throws IOException, CanonicalizationException, - InvalidCanonicalizerException, TransformationException, - ParserConfigurationException, SAXException { - throw new TransformationException("Unsupported Operation"); - } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/AbsoluteComponentCenterCalculator.java Wed May 01 17:25:18 2013 -0400 @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +class AbsoluteComponentCenterCalculator { + private AbsoluteComponentCenterCalculator() { + } + + public static int calculateXCenterCoordinate(Component component) { + return (int) component.getLocationOnScreen().getX() + (component.getWidth() / 2); + } + + public static int calculateYCenterCoordinate(Component component) { + return (int) component.getLocationOnScreen().getY() + (component.getHeight() / 2); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/DataFlavorSearcher.java Wed May 01 17:25:18 2013 -0400 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.FlavorTable; +import java.awt.datatransfer.SystemFlavorMap; +import java.util.Arrays; + +public class DataFlavorSearcher { + static public String[] HTML_NAMES = new String[]{"HTML", "HTML Format"}; + static public String[] RICH_TEXT_NAMES = new String[]{"RICH_TEXT", "Rich Text Format"}; + + static public DataFlavor getByteDataFlavorForNative(String[] nats) { + FlavorTable flavorTable = (FlavorTable) SystemFlavorMap.getDefaultFlavorMap(); + + for (String nat : nats) { + java.util.List<DataFlavor> flavors = flavorTable.getFlavorsForNative(nat); + for (DataFlavor flavor : flavors) { + if (flavor != null + && flavor.getRepresentationClass().equals(byte[].class)) { + return flavor; + } + } + } + throw new RuntimeException("No data flavor was found for natives: " + Arrays.toString(nats)); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/InterprocessMessages.java Wed May 01 17:25:18 2013 -0400 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +interface InterprocessMessages { + final static int EXECUTION_IS_SUCCESSFULL = 0; + final static int DATA_IS_CORRUPTED = 212; +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.html Wed May 01 17:25:18 2013 -0400 @@ -0,0 +1,27 @@ +<html> +<!-- + + @test + @bug 8005932 + @summary Java 7 on mac os x only provides text clipboard formats + @author mikhail.cherkasov@oracle.com + @library ../../regtesthelpers + @library ../../regtesthelpers/process + @build Util + @build ProcessResults ProcessCommunicator + + + @run applet/othervm MissedHtmlAndRtfBug.html +*/> +<head> + <title>Java 7 on mac os x only provides text clipboard formats</title> +</head> +<body> + +<h1> MissedHtmlAndRtfBug <br>Bug ID: 8005932 </h1> + +<p> This is an AUTOMATIC test, simply wait for completion </p> + +<APPLET CODE="MissedHtmlAndRtfBug.class" WIDTH=200 HEIGHT=200></APPLET> +</body> +</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.java Wed May 01 17:25:18 2013 -0400 @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + @test + @bug 8005932 + @summary Java 7 on mac os x only provides text clipboard formats + @author mikhail.cherkasov@oracle.com + @library ../../regtesthelpers + @library ../../regtesthelpers/process + @build Util + @build ProcessResults ProcessCommunicator + + + @run applet/othervm MissedHtmlAndRtfBug.html +*/ +import java.awt.*; +import java.awt.datatransfer.DataFlavor; +import java.awt.event.*; +import java.applet.Applet; +import java.io.File; +import java.util.ArrayList; + +import test.java.awt.regtesthelpers.process.ProcessCommunicator; +import test.java.awt.regtesthelpers.process.ProcessResults; +import test.java.awt.regtesthelpers.Util; +import sun.awt.OSInfo; + +import static java.lang.Thread.sleep; + +public class MissedHtmlAndRtfBug extends Applet { + public void init() { + setLayout(new BorderLayout()); + }//End init() + + public void start() { + if (OSInfo.getOSType() != OSInfo.OSType.MACOSX + && OSInfo.getOSType() != OSInfo.OSType.WINDOWS) { + System.out.println("This test is for Windows and Mac only. Passed."); + return; + } + + final Frame sourceFrame = new Frame("Source frame"); + final SourcePanel sourcePanel = new SourcePanel(); + sourceFrame.add(sourcePanel); + sourceFrame.pack(); + sourceFrame.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + sourceFrame.dispose(); + } + }); + sourceFrame.setVisible(true); + + Util.waitForIdle(null); + + NextFramePositionCalculator positionCalculator = new NextFramePositionCalculator(sourceFrame); + + ArrayList<String> args = new ArrayList<String>(5); + args.add(String.valueOf(positionCalculator.getNextLocationX())); + args.add(String.valueOf(positionCalculator.getNextLocationY())); + args.add(String.valueOf(AbsoluteComponentCenterCalculator.calculateXCenterCoordinate(sourcePanel))); + args.add(String.valueOf(AbsoluteComponentCenterCalculator.calculateYCenterCoordinate(sourcePanel))); + args.add(concatStrings(DataFlavorSearcher.RICH_TEXT_NAMES)); + + ProcessResults processResults = +// ProcessCommunicator.executeChildProcess(this.getClass(), "/Users/mcherkasov/ws/clipboard/DataFlover/out/production/DataFlover" + +// " -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005 ", +// args.toArray(new String[0])); + ProcessCommunicator.executeChildProcess(this.getClass(), + "." + File.separator + System.getProperty("java.class.path"), args.toArray(new String[]{})); + + verifyTestResults(processResults); + + args.set(args.size() - 1, concatStrings(DataFlavorSearcher.HTML_NAMES)); + + ProcessCommunicator.executeChildProcess(this.getClass(), + "." + File.separator + System.getProperty("java.class.path"), args.toArray(new String[]{})); + verifyTestResults(processResults); + + + }// start() + + private String concatStrings(String[] strings) { + StringBuffer result = new StringBuffer("\""); + for (int i = 0; i < strings.length; i++) { + result.append(strings[i]); + result.append(","); + } + result.append("\""); + return result.toString(); + } + + + private static void verifyTestResults(ProcessResults processResults) { + if (InterprocessMessages.DATA_IS_CORRUPTED == + processResults.getExitValue()) { + processResults.printProcessErrorOutput(System.err); + throw new RuntimeException("TEST IS FAILED: Target has received" + + " corrupted data."); + } + processResults.verifyStdErr(System.err); + processResults.verifyProcessExitValue(System.err); + processResults.printProcessStandartOutput(System.out); + } + + //We cannot make an instance of the applet without the default constructor + public MissedHtmlAndRtfBug() { + super(); + } + + //We need in this constructor to pass frame position between JVMs + public MissedHtmlAndRtfBug(Point targetFrameLocation, Point dragSourcePoint, DataFlavor df) + throws InterruptedException { + final Frame targetFrame = new Frame("Target frame"); + final TargetPanel targetPanel = new TargetPanel(targetFrame, df); + targetFrame.add(targetPanel); + targetFrame.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + targetFrame.dispose(); + } + }); + targetFrame.setLocation(targetFrameLocation); + targetFrame.pack(); + targetFrame.setVisible(true); + + doTest(dragSourcePoint, targetPanel); + } + + private void doTest(Point dragSourcePoint, TargetPanel targetPanel) { + Util.waitForIdle(null); + + final Robot robot = Util.createRobot(); + + robot.mouseMove((int) dragSourcePoint.getX(), (int) dragSourcePoint.getY()); + try { + sleep(100); + robot.mousePress(InputEvent.BUTTON1_MASK); + sleep(100); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + sleep(100); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + Util.drag(robot, dragSourcePoint, new Point(AbsoluteComponentCenterCalculator.calculateXCenterCoordinate(targetPanel), + AbsoluteComponentCenterCalculator.calculateYCenterCoordinate(targetPanel)), + InputEvent.BUTTON1_MASK); + } + + + enum InterprocessArguments { + TARGET_FRAME_X_POSITION_ARGUMENT, + TARGET_FRAME_Y_POSITION_ARGUMENT, + DRAG_SOURCE_POINT_X_ARGUMENT, + DRAG_SOURCE_POINT_Y_ARGUMENT, + DATA_FLAVOR_NAMES; + + int extractInt(String[] args) { + return Integer.parseInt(args[this.ordinal()]); + } + + String[] extractStringArray(String[] args) { + return args[this.ordinal()].replaceAll("\"", "").split(","); + } + } + + public static void main(String[] args) { + Point dragSourcePoint = new Point(InterprocessArguments.DRAG_SOURCE_POINT_X_ARGUMENT.extractInt(args), + InterprocessArguments.DRAG_SOURCE_POINT_Y_ARGUMENT.extractInt(args)); + Point targetFrameLocation = new Point(InterprocessArguments.TARGET_FRAME_X_POSITION_ARGUMENT.extractInt(args), + InterprocessArguments.TARGET_FRAME_Y_POSITION_ARGUMENT.extractInt(args)); + String[] names = InterprocessArguments.DATA_FLAVOR_NAMES.extractStringArray(args); + + DataFlavor df = DataFlavorSearcher.getByteDataFlavorForNative(names); + try { + new MissedHtmlAndRtfBug(targetFrameLocation, dragSourcePoint, df); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/MyTransferable.java Wed May 01 17:25:18 2013 -0400 @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.datatransfer.*; +import java.io.IOException; + +class MyTransferable implements Transferable { + + public static final String TEST_DATA = "<b>Test</b>"; + private DataFlavor[] dataFlavors; + + public MyTransferable() { + dataFlavors = new DataFlavor[]{DataFlavorSearcher.getByteDataFlavorForNative(DataFlavorSearcher.HTML_NAMES), + DataFlavorSearcher.getByteDataFlavorForNative(DataFlavorSearcher.RICH_TEXT_NAMES)}; + } + + + @Override + public DataFlavor[] getTransferDataFlavors() { + return dataFlavors; + } + + @Override + public boolean isDataFlavorSupported(DataFlavor flavor) { + for (DataFlavor f : dataFlavors) { + if (f.equals(flavor)) { + return true; + } + } + return false; + } + + @Override + public Object getTransferData(DataFlavor flavor) + throws UnsupportedFlavorException, IOException { + if (isDataFlavorSupported(flavor)) { + return TEST_DATA.getBytes("UTF-16"); + } else { + throw new UnsupportedFlavorException(flavor); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/NextFramePositionCalculator.java Wed May 01 17:25:18 2013 -0400 @@ -0,0 +1,20 @@ +import java.awt.*; + + +class NextFramePositionCalculator { + + private final Frame currentFrame; + + public NextFramePositionCalculator(Frame currentFrame) { + this.currentFrame = currentFrame; + } + + public int getNextLocationX() { + return currentFrame.getX() + currentFrame.getWidth(); + } + + public int getNextLocationY() { + return currentFrame.getY(); + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/SourcePanel.java Wed May 01 17:25:18 2013 -0400 @@ -0,0 +1,26 @@ +import java.awt.dnd.DragSource; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.*; + +public class SourcePanel extends Panel { + + private final MyDragGestureListener dragGestureListener = + new MyDragGestureListener(); + + public SourcePanel() { + setPreferredSize(new Dimension(200, 200)); + DragSource defaultDragSource = + DragSource.getDefaultDragSource(); + defaultDragSource.createDefaultDragGestureRecognizer(this, + DnDConstants.ACTION_COPY_OR_MOVE, dragGestureListener); + setBackground(Color.RED); + } + + private class MyDragGestureListener implements DragGestureListener { + public void dragGestureRecognized(DragGestureEvent dge) { + dge.startDrag(null, new MyTransferable()); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/DataFlavor/MissedHtmlAndRtfBug/TargetPanel.java Wed May 01 17:25:18 2013 -0400 @@ -0,0 +1,83 @@ +import java.awt.datatransfer.Transferable; +import java.awt.dnd.*; +import java.awt.*; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.io.IOException; +import java.util.Timer; +import java.util.TimerTask; + +public class TargetPanel extends Panel implements DropTargetListener { + + + //private final CustomDropTargetListener dropTargetListener = new CustomDropTargetListener(); + + private Frame frame; + DataFlavor dataFlavor; + + public TargetPanel(Frame frame, DataFlavor dataFlavor) { + this.dataFlavor = dataFlavor; + this.frame = frame; + setBackground(Color.DARK_GRAY); + setPreferredSize(new Dimension(200, 200)); + setDropTarget(new DropTarget(this, this)); + } + + public void dragEnter(DropTargetDragEvent dtde) { + if (dtde.isDataFlavorSupported(dataFlavor)) { + dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE); + } + } + + public void dragOver(DropTargetDragEvent dtde) { + if (dtde.isDataFlavorSupported(dataFlavor)) { + dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE); + } + } + + public void dropActionChanged(DropTargetDragEvent dtde) { + if (dtde.isDataFlavorSupported(dataFlavor)) { + dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE); + } + } + + public void dragExit(DropTargetEvent dte) { + + } + + public void drop(DropTargetDropEvent dtde) { + dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); + if (dtde.isDataFlavorSupported(dataFlavor)) { + String result = null; + try { + Transferable t = dtde.getTransferable(); + byte[] data = (byte[]) dtde.getTransferable().getTransferData(dataFlavor); + result = new String(data, "UTF-16"); + repaint(); + } catch (UnsupportedFlavorException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + dtde.dropComplete(true); + + + if (result != null && result.contains(MyTransferable.TEST_DATA)) { + System.err.println(InterprocessMessages.EXECUTION_IS_SUCCESSFULL); + Timer t = new Timer(); + t.schedule(new TimerTask() { + @Override + public void run() { + System.exit(0); + } + }, 2000); + return; + + } + } + dtde.rejectDrop(); + System.err.println(InterprocessMessages.DATA_IS_CORRUPTED); + System.exit(InterprocessMessages.DATA_IS_CORRUPTED); + } + +}