From 87a408a8466134c9c329871d921a8d8a8a76b126 Mon Sep 17 00:00:00 2001
From: Bradford Wetmore
Date: Fri, 22 Aug 2008 18:48:00 -0700
Subject: [PATCH 001/292] 6497740: Limit the size of RSA public keys
Reviewed-by: andreas, valeriep, vinnie
---
.../security/pkcs11/P11KeyPairGenerator.java | 59 +++++---
.../sun/security/pkcs11/P11KeyStore.java | 11 ++
.../sun/security/pkcs11/P11RSAKeyFactory.java | 20 ++-
.../sun/security/pkcs11/SunPKCS11.java | 89 ++++++++----
.../sun/security/rsa/RSAKeyFactory.java | 135 +++++++++++-------
.../sun/security/rsa/RSAKeyPairGenerator.java | 59 ++++----
.../security/rsa/RSAPrivateCrtKeyImpl.java | 7 +-
.../sun/security/rsa/RSAPrivateKeyImpl.java | 4 +-
.../sun/security/rsa/RSAPublicKeyImpl.java | 9 +-
.../security/mscapi/RSAKeyPairGenerator.java | 44 +++---
.../sun/security/mscapi/RSASignature.java | 30 ++--
11 files changed, 299 insertions(+), 168 deletions(-)
diff --git a/jdk/src/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java b/jdk/src/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java
index 701e104d529..1027df9ddb7 100644
--- a/jdk/src/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java
+++ b/jdk/src/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -38,6 +38,8 @@ import static sun.security.pkcs11.TemplateManager.*;
import sun.security.pkcs11.wrapper.*;
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
+import sun.security.rsa.RSAKeyFactory;
+
/**
* KeyPairGenerator implementation class. This class currently supports
* RSA, DSA, DH, and EC.
@@ -66,7 +68,7 @@ final class P11KeyPairGenerator extends KeyPairGeneratorSpi {
private AlgorithmParameterSpec params;
// for RSA, selected or default value of public exponent, always valid
- private BigInteger rsaPublicExponent;
+ private BigInteger rsaPublicExponent = RSAKeyGenParameterSpec.F4;
// SecureRandom instance, if specified in init
private SecureRandom random;
@@ -88,19 +90,19 @@ final class P11KeyPairGenerator extends KeyPairGeneratorSpi {
public void initialize(int keySize, SecureRandom random) {
token.ensureValid();
try {
- checkKeySize(keySize);
+ checkKeySize(keySize, null);
} catch (InvalidAlgorithmParameterException e) {
throw new InvalidParameterException(e.getMessage());
}
this.keySize = keySize;
this.params = null;
this.random = random;
- this.rsaPublicExponent = RSAKeyGenParameterSpec.F4;
if (algorithm.equals("EC")) {
params = P11ECKeyFactory.getECParameterSpec(keySize);
if (params == null) {
- throw new InvalidParameterException
- ("No EC parameters available for key size " + keySize + " bits");
+ throw new InvalidParameterException(
+ "No EC parameters available for key size "
+ + keySize + " bits");
}
}
}
@@ -115,8 +117,10 @@ final class P11KeyPairGenerator extends KeyPairGeneratorSpi {
("DHParameterSpec required for Diffie-Hellman");
}
DHParameterSpec dhParams = (DHParameterSpec)params;
- this.keySize = dhParams.getP().bitLength();
- this.params = params;
+ int tmpKeySize = dhParams.getP().bitLength();
+ checkKeySize(tmpKeySize, dhParams);
+ this.keySize = tmpKeySize;
+ this.params = dhParams;
// XXX sanity check params
} else if (algorithm.equals("RSA")) {
if (params instanceof RSAKeyGenParameterSpec == false) {
@@ -124,7 +128,9 @@ final class P11KeyPairGenerator extends KeyPairGeneratorSpi {
("RSAKeyGenParameterSpec required for RSA");
}
RSAKeyGenParameterSpec rsaParams = (RSAKeyGenParameterSpec)params;
- this.keySize = rsaParams.getKeysize();
+ int tmpKeySize = rsaParams.getKeysize();
+ checkKeySize(tmpKeySize, rsaParams);
+ this.keySize = tmpKeySize;
this.params = null;
this.rsaPublicExponent = rsaParams.getPublicExponent();
// XXX sanity check params
@@ -134,13 +140,16 @@ final class P11KeyPairGenerator extends KeyPairGeneratorSpi {
("DSAParameterSpec required for DSA");
}
DSAParameterSpec dsaParams = (DSAParameterSpec)params;
- this.keySize = dsaParams.getP().bitLength();
- this.params = params;
+ int tmpKeySize = dsaParams.getP().bitLength();
+ checkKeySize(tmpKeySize, dsaParams);
+ this.keySize = tmpKeySize;
+ this.params = dsaParams;
// XXX sanity check params
} else if (algorithm.equals("EC")) {
ECParameterSpec ecParams;
if (params instanceof ECParameterSpec) {
- ecParams = P11ECKeyFactory.getECParameterSpec((ECParameterSpec)params);
+ ecParams = P11ECKeyFactory.getECParameterSpec(
+ (ECParameterSpec)params);
if (ecParams == null) {
throw new InvalidAlgorithmParameterException
("Unsupported curve: " + params);
@@ -156,16 +165,17 @@ final class P11KeyPairGenerator extends KeyPairGeneratorSpi {
throw new InvalidAlgorithmParameterException
("ECParameterSpec or ECGenParameterSpec required for EC");
}
- this.keySize = ecParams.getCurve().getField().getFieldSize();
+ int tmpKeySize = ecParams.getCurve().getField().getFieldSize();
+ checkKeySize(tmpKeySize, ecParams);
+ this.keySize = tmpKeySize;
this.params = ecParams;
} else {
throw new ProviderException("Unknown algorithm: " + algorithm);
}
this.random = random;
- checkKeySize(keySize);
}
- private void checkKeySize(int keySize)
+ private void checkKeySize(int keySize, AlgorithmParameterSpec params)
throws InvalidAlgorithmParameterException {
if (algorithm.equals("EC")) {
if (keySize < 112) {
@@ -178,13 +188,28 @@ final class P11KeyPairGenerator extends KeyPairGeneratorSpi {
("Key size must be at most 2048 bit");
}
return;
+ } else if (algorithm.equals("RSA")) {
+ BigInteger tmpExponent = rsaPublicExponent;
+ if (params != null) {
+ // Already tested for instanceof RSAKeyGenParameterSpec above
+ tmpExponent =
+ ((RSAKeyGenParameterSpec)params).getPublicExponent();
+ }
+ try {
+ // This provider supports 64K or less.
+ RSAKeyFactory.checkKeyLengths(keySize, tmpExponent,
+ 512, 64 * 1024);
+ } catch (InvalidKeyException e) {
+ throw new InvalidAlgorithmParameterException(e.getMessage());
+ }
+ return;
}
+
if (keySize < 512) {
throw new InvalidAlgorithmParameterException
("Key size must be at least 512 bit");
}
- if (algorithm.equals("RSA") ||
- (algorithm.equals("DH") && (params != null))) {
+ if (algorithm.equals("DH") && (params != null)) {
// sanity check, nobody really wants keys this large
if (keySize > 64 * 1024) {
throw new InvalidAlgorithmParameterException
diff --git a/jdk/src/share/classes/sun/security/pkcs11/P11KeyStore.java b/jdk/src/share/classes/sun/security/pkcs11/P11KeyStore.java
index 839a2f3ba64..b0e20711dc8 100644
--- a/jdk/src/share/classes/sun/security/pkcs11/P11KeyStore.java
+++ b/jdk/src/share/classes/sun/security/pkcs11/P11KeyStore.java
@@ -80,6 +80,8 @@ import static sun.security.pkcs11.P11Util.*;
import sun.security.pkcs11.wrapper.*;
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
+import sun.security.rsa.RSAKeyFactory;
+
final class P11KeyStore extends KeyStoreSpi {
private static final CK_ATTRIBUTE ATTR_CLASS_CERT =
@@ -1328,6 +1330,15 @@ final class P11KeyStore extends KeyStoreSpi {
BigInteger modulus = attrs[0].getBigInteger();
keyLength = modulus.bitLength();
+ // This check will combine our "don't care" values here
+ // with the system-wide min/max values.
+ try {
+ RSAKeyFactory.checkKeyLengths(keyLength, null,
+ -1, Integer.MAX_VALUE);
+ } catch (InvalidKeyException e) {
+ throw new KeyStoreException(e.getMessage());
+ }
+
return P11Key.privateKey(session,
oHandle,
keyType,
diff --git a/jdk/src/share/classes/sun/security/pkcs11/P11RSAKeyFactory.java b/jdk/src/share/classes/sun/security/pkcs11/P11RSAKeyFactory.java
index 5f3cbbf93c9..1bd764d326e 100644
--- a/jdk/src/share/classes/sun/security/pkcs11/P11RSAKeyFactory.java
+++ b/jdk/src/share/classes/sun/security/pkcs11/P11RSAKeyFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -35,6 +35,8 @@ import static sun.security.pkcs11.TemplateManager.*;
import sun.security.pkcs11.wrapper.*;
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
+import sun.security.rsa.RSAKeyFactory;
+
/**
* RSA KeyFactory implemenation.
*
@@ -131,6 +133,9 @@ final class P11RSAKeyFactory extends P11KeyFactory {
} catch (PKCS11Exception e) {
throw new InvalidKeySpecException
("Could not create RSA public key", e);
+ } catch (InvalidKeyException e) {
+ throw new InvalidKeySpecException
+ ("Could not create RSA public key", e);
}
}
@@ -175,11 +180,15 @@ final class P11RSAKeyFactory extends P11KeyFactory {
} catch (PKCS11Exception e) {
throw new InvalidKeySpecException
("Could not create RSA private key", e);
+ } catch (InvalidKeyException e) {
+ throw new InvalidKeySpecException
+ ("Could not create RSA private key", e);
}
}
private PublicKey generatePublic(BigInteger n, BigInteger e)
- throws PKCS11Exception {
+ throws PKCS11Exception, InvalidKeyException {
+ RSAKeyFactory.checkKeyLengths(n.bitLength(), e, -1, 64 * 1024);
CK_ATTRIBUTE[] attributes = new CK_ATTRIBUTE[] {
new CK_ATTRIBUTE(CKA_CLASS, CKO_PUBLIC_KEY),
new CK_ATTRIBUTE(CKA_KEY_TYPE, CKK_RSA),
@@ -200,7 +209,8 @@ final class P11RSAKeyFactory extends P11KeyFactory {
}
private PrivateKey generatePrivate(BigInteger n, BigInteger d)
- throws PKCS11Exception {
+ throws PKCS11Exception, InvalidKeyException {
+ RSAKeyFactory.checkKeyLengths(n.bitLength(), null, -1, 64 * 1024);
CK_ATTRIBUTE[] attributes = new CK_ATTRIBUTE[] {
new CK_ATTRIBUTE(CKA_CLASS, CKO_PRIVATE_KEY),
new CK_ATTRIBUTE(CKA_KEY_TYPE, CKK_RSA),
@@ -222,7 +232,9 @@ final class P11RSAKeyFactory extends P11KeyFactory {
private PrivateKey generatePrivate(BigInteger n, BigInteger e,
BigInteger d, BigInteger p, BigInteger q, BigInteger pe,
- BigInteger qe, BigInteger coeff) throws PKCS11Exception {
+ BigInteger qe, BigInteger coeff) throws PKCS11Exception,
+ InvalidKeyException {
+ RSAKeyFactory.checkKeyLengths(n.bitLength(), e, -1, 64 * 1024);
CK_ATTRIBUTE[] attributes = new CK_ATTRIBUTE[] {
new CK_ATTRIBUTE(CKA_CLASS, CKO_PRIVATE_KEY),
new CK_ATTRIBUTE(CKA_KEY_TYPE, CKK_RSA),
diff --git a/jdk/src/share/classes/sun/security/pkcs11/SunPKCS11.java b/jdk/src/share/classes/sun/security/pkcs11/SunPKCS11.java
index b6eb1c258f4..6d0e045f2ee 100644
--- a/jdk/src/share/classes/sun/security/pkcs11/SunPKCS11.java
+++ b/jdk/src/share/classes/sun/security/pkcs11/SunPKCS11.java
@@ -120,11 +120,13 @@ public final class SunPKCS11 extends AuthProvider {
}
/**
- * @deprecated use new SunPKCS11(String) or new SunPKCS11(InputStream) instead
+ * @deprecated use new SunPKCS11(String) or new SunPKCS11(InputStream)
+ * instead
*/
@Deprecated
public SunPKCS11(String configName, InputStream configStream) {
- super("SunPKCS11-" + Config.getConfig(configName, configStream).getName(),
+ super("SunPKCS11-" +
+ Config.getConfig(configName, configStream).getName(),
1.7d, Config.getConfig(configName, configStream).getDescription());
this.configName = configName;
this.config = Config.removeConfig(configName);
@@ -153,7 +155,8 @@ public final class SunPKCS11 extends AuthProvider {
//
// If we are in Secmod mode and configured to use either the
// nssKeyStore or the nssTrustAnchors module, we automatically
- // switch to using the NSS trust attributes for trusted certs (KeyStore).
+ // switch to using the NSS trust attributes for trusted certs
+ // (KeyStore).
//
if (useSecmod) {
@@ -168,33 +171,40 @@ public final class SunPKCS11 extends AuthProvider {
if (secmod.isInitialized()) {
if (nssSecmodDirectory != null) {
String s = secmod.getConfigDir();
- if ((s != null) && (s.equals(nssSecmodDirectory) == false)) {
+ if ((s != null) &&
+ (s.equals(nssSecmodDirectory) == false)) {
throw new ProviderException("Secmod directory "
+ nssSecmodDirectory
- + " invalid, NSS already initialized with " + s);
+ + " invalid, NSS already initialized with "
+ + s);
}
}
if (nssLibraryDirectory != null) {
String s = secmod.getLibDir();
- if ((s != null) && (s.equals(nssLibraryDirectory) == false)) {
+ if ((s != null) &&
+ (s.equals(nssLibraryDirectory) == false)) {
throw new ProviderException("NSS library directory "
+ nssLibraryDirectory
- + " invalid, NSS already initialized with " + s);
+ + " invalid, NSS already initialized with "
+ + s);
}
}
} else {
if (nssDbMode != DbMode.NO_DB) {
if (nssSecmodDirectory == null) {
- throw new ProviderException("Secmod not initialized and "
- + "nssSecmodDirectory not specified");
+ throw new ProviderException(
+ "Secmod not initialized and "
+ + "nssSecmodDirectory not specified");
}
} else {
if (nssSecmodDirectory != null) {
- throw new ProviderException
- ("nssSecmodDirectory must not be specified in noDb mode");
+ throw new ProviderException(
+ "nssSecmodDirectory must not be "
+ + "specified in noDb mode");
}
}
- secmod.initialize(nssDbMode, nssSecmodDirectory, nssLibraryDirectory);
+ secmod.initialize(nssDbMode, nssSecmodDirectory,
+ nssLibraryDirectory);
}
} catch (IOException e) {
// XXX which exception to throw
@@ -211,7 +221,8 @@ public final class SunPKCS11 extends AuthProvider {
if (nssModule != null) {
moduleName = "fips";
} else {
- moduleName = (nssDbMode == DbMode.NO_DB) ? "crypto" : "keystore";
+ moduleName = (nssDbMode == DbMode.NO_DB) ?
+ "crypto" : "keystore";
}
}
if (moduleName.equals("fips")) {
@@ -253,10 +264,12 @@ public final class SunPKCS11 extends AuthProvider {
+ ": only " + k + " external NSS modules available");
}
} else {
- throw new ProviderException("Unknown NSS module: " + moduleName);
+ throw new ProviderException(
+ "Unknown NSS module: " + moduleName);
}
if (nssModule == null) {
- throw new ProviderException("NSS module not available: " + moduleName);
+ throw new ProviderException(
+ "NSS module not available: " + moduleName);
}
if (nssModule.hasInitializedProvider()) {
throw new ProviderException("Secmod module already configured");
@@ -296,8 +309,9 @@ public final class SunPKCS11 extends AuthProvider {
initArgs.flags = CKF_OS_LOCKING_OK;
PKCS11 tmpPKCS11;
try {
- tmpPKCS11 = PKCS11.getInstance
- (library, functionList, initArgs, config.getOmitInitialize());
+ tmpPKCS11 = PKCS11.getInstance(
+ library, functionList, initArgs,
+ config.getOmitInitialize());
} catch (PKCS11Exception e) {
if (debug != null) {
debug.println("Multi-threaded initialization failed: " + e);
@@ -312,8 +326,8 @@ public final class SunPKCS11 extends AuthProvider {
} else {
initArgs.flags = 0;
}
- tmpPKCS11 = PKCS11.getInstance
- (library, functionList, initArgs, config.getOmitInitialize());
+ tmpPKCS11 = PKCS11.getInstance(library,
+ functionList, initArgs, config.getOmitInitialize());
}
p11 = tmpPKCS11;
@@ -336,8 +350,10 @@ public final class SunPKCS11 extends AuthProvider {
System.out.println("Slots with tokens: " + toString(slots));
}
if (slotID < 0) {
- if ((slotListIndex < 0) || (slotListIndex >= slots.length)) {
- throw new ProviderException("slotListIndex is " + slotListIndex
+ if ((slotListIndex < 0)
+ || (slotListIndex >= slots.length)) {
+ throw new ProviderException("slotListIndex is "
+ + slotListIndex
+ " but token only has " + slots.length + " slots");
}
slotID = slots[slotListIndex];
@@ -575,12 +591,15 @@ public final class SunPKCS11 extends AuthProvider {
d(KF, "DH", P11DHKeyFactory, s("DiffieHellman"),
m(CKM_DH_PKCS_KEY_PAIR_GEN, CKM_DH_PKCS_DERIVE));
d(KF, "EC", P11DHKeyFactory,
- m(CKM_EC_KEY_PAIR_GEN, CKM_ECDH1_DERIVE, CKM_ECDSA, CKM_ECDSA_SHA1));
+ m(CKM_EC_KEY_PAIR_GEN, CKM_ECDH1_DERIVE,
+ CKM_ECDSA, CKM_ECDSA_SHA1));
// AlgorithmParameters for EC.
// Only needed until we have an EC implementation in the SUN provider.
- d(AGP, "EC", "sun.security.ec.ECParameters", s("1.2.840.10045.2.1"),
- m(CKM_EC_KEY_PAIR_GEN, CKM_ECDH1_DERIVE, CKM_ECDSA, CKM_ECDSA_SHA1));
+ d(AGP, "EC", "sun.security.ec.ECParameters",
+ s("1.2.840.10045.2.1"),
+ m(CKM_EC_KEY_PAIR_GEN, CKM_ECDH1_DERIVE,
+ CKM_ECDSA, CKM_ECDSA_SHA1));
d(KA, "DH", P11KeyAgreement, s("DiffieHellman"),
m(CKM_DH_PKCS_DERIVE));
@@ -654,12 +673,16 @@ public final class SunPKCS11 extends AuthProvider {
d(SIG, "SHA512withRSA", P11Signature,
m(CKM_SHA512_RSA_PKCS, CKM_RSA_PKCS, CKM_RSA_X_509));
- d(KG, "SunTlsRsaPremasterSecret", "sun.security.pkcs11.P11TlsRsaPremasterSecretGenerator",
+ d(KG, "SunTlsRsaPremasterSecret",
+ "sun.security.pkcs11.P11TlsRsaPremasterSecretGenerator",
m(CKM_SSL3_PRE_MASTER_KEY_GEN, CKM_TLS_PRE_MASTER_KEY_GEN));
- d(KG, "SunTlsMasterSecret", "sun.security.pkcs11.P11TlsMasterSecretGenerator",
+ d(KG, "SunTlsMasterSecret",
+ "sun.security.pkcs11.P11TlsMasterSecretGenerator",
m(CKM_SSL3_MASTER_KEY_DERIVE, CKM_TLS_MASTER_KEY_DERIVE,
- CKM_SSL3_MASTER_KEY_DERIVE_DH, CKM_TLS_MASTER_KEY_DERIVE_DH));
- d(KG, "SunTlsKeyMaterial", "sun.security.pkcs11.P11TlsKeyMaterialGenerator",
+ CKM_SSL3_MASTER_KEY_DERIVE_DH,
+ CKM_TLS_MASTER_KEY_DERIVE_DH));
+ d(KG, "SunTlsKeyMaterial",
+ "sun.security.pkcs11.P11TlsKeyMaterialGenerator",
m(CKM_SSL3_KEY_AND_MAC_DERIVE, CKM_TLS_KEY_AND_MAC_DERIVE));
d(KG, "SunTlsPrf", "sun.security.pkcs11.P11TlsPrfGenerator",
m(CKM_TLS_PRF, CKM_NSS_TLS_PRF_GENERAL));
@@ -773,6 +796,13 @@ public final class SunPKCS11 extends AuthProvider {
System.out.println(token.tokenInfo);
}
long[] supportedMechanisms = p11.C_GetMechanismList(slotID);
+
+ // Create a map from the various Descriptors to the "most
+ // preferred" mechanism that was defined during the
+ // static initialization. For example, DES/CBC/PKCS5Padding
+ // could be mapped to CKM_DES_CBC_PAD or CKM_DES_CBC. Prefer
+ // the earliest entry. When asked for "DES/CBC/PKCS5Padding", we
+ // return a CKM_DES_CBC_PAD.
final Map supportedAlgs =
new HashMap();
for (int i = 0; i < supportedMechanisms.length; i++) {
@@ -807,6 +837,9 @@ public final class SunPKCS11 extends AuthProvider {
supportedAlgs.put(d, integerMech);
continue;
}
+ // See if there is something "more preferred"
+ // than what we currently have in the supportedAlgs
+ // map.
int intOldMech = oldMech.intValue();
for (int j = 0; j < d.mechanisms.length; j++) {
int nextMech = d.mechanisms[j];
diff --git a/jdk/src/share/classes/sun/security/rsa/RSAKeyFactory.java b/jdk/src/share/classes/sun/security/rsa/RSAKeyFactory.java
index 17ce8cde639..d877f28fb54 100644
--- a/jdk/src/share/classes/sun/security/rsa/RSAKeyFactory.java
+++ b/jdk/src/share/classes/sun/security/rsa/RSAKeyFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,8 @@ import java.security.*;
import java.security.interfaces.*;
import java.security.spec.*;
+import sun.security.action.GetPropertyAction;
+
/**
* KeyFactory for RSA keys. Keys must be instances of PublicKey or PrivateKey
* and getAlgorithm() must return "RSA". For such keys, it supports conversion
@@ -68,6 +70,24 @@ public final class RSAKeyFactory extends KeyFactorySpi {
private final static Class> x509KeySpecClass = X509EncodedKeySpec.class;
private final static Class> pkcs8KeySpecClass = PKCS8EncodedKeySpec.class;
+ public final static int MIN_MODLEN = 512;
+ public final static int MAX_MODLEN = 16384;
+
+ /*
+ * If the modulus length is above this value, restrict the size of
+ * the exponent to something that can be reasonably computed. We
+ * could simply hardcode the exp len to something like 64 bits, but
+ * this approach allows flexibility in case impls would like to use
+ * larger module and exponent values.
+ */
+ public final static int MAX_MODLEN_RESTRICT_EXP = 3072;
+ public final static int MAX_RESTRICTED_EXPLEN = 64;
+
+ private static final boolean restrictExpLen =
+ "true".equalsIgnoreCase(AccessController.doPrivileged(
+ new GetPropertyAction(
+ "sun.security.rsa.restrictRSAExponent", "true")));
+
// instance used for static translateKey();
private final static RSAKeyFactory INSTANCE = new RSAKeyFactory();
@@ -76,74 +96,79 @@ public final class RSAKeyFactory extends KeyFactorySpi {
}
/**
- * Static method to convert Key into a useable instance of
- * RSAPublicKey or RSAPrivate(Crt)Key. Check the key and convert it
- * to a SunRsaSign key if necessary. If the key is not an RSA key
- * or cannot be used, throw an InvalidKeyException.
- *
- * The difference between this method and engineTranslateKey() is that
- * we do not convert keys of other providers that are already an
- * instance of RSAPublicKey or RSAPrivate(Crt)Key.
+ * Static method to convert Key into an instance of RSAPublicKeyImpl
+ * or RSAPrivate(Crt)KeyImpl. If the key is not an RSA key or cannot be
+ * used, throw an InvalidKeyException.
*
* Used by RSASignature and RSACipher.
*/
public static RSAKey toRSAKey(Key key) throws InvalidKeyException {
- if (key instanceof RSAKey) {
- RSAKey rsaKey = (RSAKey)key;
- checkKey(rsaKey);
- return rsaKey;
+ if ((key instanceof RSAPrivateKeyImpl) ||
+ (key instanceof RSAPrivateCrtKeyImpl) ||
+ (key instanceof RSAPublicKeyImpl)) {
+ return (RSAKey)key;
} else {
return (RSAKey)INSTANCE.engineTranslateKey(key);
}
}
- /**
- * Check that the given RSA key is valid.
+ /*
+ * Single test entry point for all of the mechanisms in the SunRsaSign
+ * provider (RSA*KeyImpls). All of the tests are the same.
+ *
+ * For compatibility, we round up to the nearest byte here:
+ * some Key impls might pass in a value within a byte of the
+ * real value.
*/
- private static void checkKey(RSAKey key) throws InvalidKeyException {
- // check for subinterfaces, omit additional checks for our keys
- if (key instanceof RSAPublicKey) {
- if (key instanceof RSAPublicKeyImpl) {
- return;
- }
- } else if (key instanceof RSAPrivateKey) {
- if ((key instanceof RSAPrivateCrtKeyImpl)
- || (key instanceof RSAPrivateKeyImpl)) {
- return;
- }
- } else {
- throw new InvalidKeyException("Neither a public nor a private key");
- }
- // RSAKey does not extend Key, so we need to do a cast
- String keyAlg = ((Key)key).getAlgorithm();
- if (keyAlg.equals("RSA") == false) {
- throw new InvalidKeyException("Not an RSA key: " + keyAlg);
- }
- BigInteger modulus;
- // some providers implement RSAKey for keys where the values are
- // not accessible (although they should). Detect those here
- // for a more graceful failure.
- try {
- modulus = key.getModulus();
- if (modulus == null) {
- throw new InvalidKeyException("Modulus is missing");
- }
- } catch (RuntimeException e) {
- throw new InvalidKeyException(e);
- }
- checkKeyLength(modulus);
+ static void checkRSAProviderKeyLengths(int modulusLen, BigInteger exponent)
+ throws InvalidKeyException {
+ checkKeyLengths(((modulusLen + 7) & ~7), exponent,
+ RSAKeyFactory.MIN_MODLEN, Integer.MAX_VALUE);
}
/**
- * Check the length of the modulus of an RSA key. We only support keys
- * at least 505 bits long.
+ * Check the length of an RSA key modulus/exponent to make sure it
+ * is not too short or long. Some impls have their own min and
+ * max key sizes that may or may not match with a system defined value.
+ *
+ * @param modulusLen the bit length of the RSA modulus.
+ * @param exponent the RSA exponent
+ * @param minModulusLen if > 0, check to see if modulusLen is at
+ * least this long, otherwise unused.
+ * @param maxModulusLen caller will allow this max number of bits.
+ * Allow the smaller of the system-defined maximum and this param.
+ *
+ * @throws InvalidKeyException if any of the values are unacceptable.
*/
- static void checkKeyLength(BigInteger modulus) throws InvalidKeyException {
- if (modulus.bitLength() < 505) {
- // some providers may generate slightly shorter keys
- // accept them if the encoding is at least 64 bytes long
- throw new InvalidKeyException
- ("RSA keys must be at least 512 bits long");
+ public static void checkKeyLengths(int modulusLen, BigInteger exponent,
+ int minModulusLen, int maxModulusLen) throws InvalidKeyException {
+
+ if ((minModulusLen > 0) && (modulusLen < (minModulusLen))) {
+ throw new InvalidKeyException( "RSA keys must be at least " +
+ minModulusLen + " bits long");
+ }
+
+ // Even though our policy file may allow this, we don't want
+ // either value (mod/exp) to be too big.
+
+ int maxLen = Math.min(maxModulusLen, MAX_MODLEN);
+
+ // If a RSAPrivateKey/RSAPublicKey, make sure the
+ // modulus len isn't too big.
+ if (modulusLen > maxLen) {
+ throw new InvalidKeyException(
+ "RSA keys must be no longer than " + maxLen + " bits");
+ }
+
+ // If a RSAPublicKey, make sure the exponent isn't too big.
+ if (restrictExpLen && (exponent != null) &&
+ (modulusLen > MAX_MODLEN_RESTRICT_EXP) &&
+ (exponent.bitLength() > MAX_RESTRICTED_EXPLEN)) {
+ throw new InvalidKeyException(
+ "RSA exponents can be no longer than " +
+ MAX_RESTRICTED_EXPLEN + " bits " +
+ " if modulus is greater than " +
+ MAX_MODLEN_RESTRICT_EXP + " bits");
}
}
diff --git a/jdk/src/share/classes/sun/security/rsa/RSAKeyPairGenerator.java b/jdk/src/share/classes/sun/security/rsa/RSAKeyPairGenerator.java
index f800dec543b..2898a3d1f51 100644
--- a/jdk/src/share/classes/sun/security/rsa/RSAKeyPairGenerator.java
+++ b/jdk/src/share/classes/sun/security/rsa/RSAKeyPairGenerator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -47,7 +47,7 @@ public final class RSAKeyPairGenerator extends KeyPairGeneratorSpi {
// public exponent to use
private BigInteger publicExponent;
- // size of the key to generate, >= 512
+ // size of the key to generate, >= RSAKeyFactory.MIN_MODLEN
private int keySize;
// PRNG to use
@@ -60,15 +60,16 @@ public final class RSAKeyPairGenerator extends KeyPairGeneratorSpi {
// initialize the generator. See JCA doc
public void initialize(int keySize, SecureRandom random) {
- if (keySize < 512) {
- throw new InvalidParameterException
- ("Key size must be at least 512 bits");
- }
- if (keySize > 64 * 1024) {
- // do not allow unreasonably large key sizes, probably user error
- throw new InvalidParameterException
- ("Key size must be 65536 bits or less");
+
+ // do not allow unreasonably small or large key sizes,
+ // probably user error
+ try {
+ RSAKeyFactory.checkKeyLengths(keySize, RSAKeyGenParameterSpec.F4,
+ 512, 64 * 1024);
+ } catch (InvalidKeyException e) {
+ throw new InvalidParameterException(e.getMessage());
}
+
this.keySize = keySize;
this.random = random;
this.publicExponent = RSAKeyGenParameterSpec.F4;
@@ -77,35 +78,41 @@ public final class RSAKeyPairGenerator extends KeyPairGeneratorSpi {
// second initialize method. See JCA doc.
public void initialize(AlgorithmParameterSpec params, SecureRandom random)
throws InvalidAlgorithmParameterException {
+
if (params instanceof RSAKeyGenParameterSpec == false) {
throw new InvalidAlgorithmParameterException
("Params must be instance of RSAKeyGenParameterSpec");
}
+
RSAKeyGenParameterSpec rsaSpec = (RSAKeyGenParameterSpec)params;
- keySize = rsaSpec.getKeysize();
- publicExponent = rsaSpec.getPublicExponent();
- this.random = random;
- if (keySize < 512) {
- throw new InvalidAlgorithmParameterException
- ("Key size must be at least 512 bits");
- }
- if (keySize > 64 * 1024) {
- // do not allow unreasonably large key sizes, probably user error
- throw new InvalidAlgorithmParameterException
- ("Key size must be 65536 bits or less");
- }
- if (publicExponent == null) {
- publicExponent = RSAKeyGenParameterSpec.F4;
+ int tmpKeySize = rsaSpec.getKeysize();
+ BigInteger tmpPublicExponent = rsaSpec.getPublicExponent();
+
+ if (tmpPublicExponent == null) {
+ tmpPublicExponent = RSAKeyGenParameterSpec.F4;
} else {
- if (publicExponent.compareTo(RSAKeyGenParameterSpec.F0) < 0) {
+ if (tmpPublicExponent.compareTo(RSAKeyGenParameterSpec.F0) < 0) {
throw new InvalidAlgorithmParameterException
("Public exponent must be 3 or larger");
}
- if (publicExponent.bitLength() > keySize) {
+ if (tmpPublicExponent.bitLength() > tmpKeySize) {
throw new InvalidAlgorithmParameterException
("Public exponent must be smaller than key size");
}
}
+
+ // do not allow unreasonably large key sizes, probably user error
+ try {
+ RSAKeyFactory.checkKeyLengths(tmpKeySize, tmpPublicExponent,
+ 512, 64 * 1024);
+ } catch (InvalidKeyException e) {
+ throw new InvalidAlgorithmParameterException(
+ "Invalid key sizes", e);
+ }
+
+ this.keySize = tmpKeySize;
+ this.publicExponent = tmpPublicExponent;
+ this.random = random;
}
// generate the keypair. See JCA doc
diff --git a/jdk/src/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java b/jdk/src/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java
index ac296b49f60..640972a2495 100644
--- a/jdk/src/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java
+++ b/jdk/src/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -89,7 +89,7 @@ public final class RSAPrivateCrtKeyImpl
*/
RSAPrivateCrtKeyImpl(byte[] encoded) throws InvalidKeyException {
decode(encoded);
- RSAKeyFactory.checkKeyLength(n);
+ RSAKeyFactory.checkRSAProviderKeyLengths(n.bitLength(), e);
}
/**
@@ -107,7 +107,8 @@ public final class RSAPrivateCrtKeyImpl
this.pe = pe;
this.qe = qe;
this.coeff = coeff;
- RSAKeyFactory.checkKeyLength(n);
+ RSAKeyFactory.checkRSAProviderKeyLengths(n.bitLength(), e);
+
// generate the encoding
algid = rsaId;
try {
diff --git a/jdk/src/share/classes/sun/security/rsa/RSAPrivateKeyImpl.java b/jdk/src/share/classes/sun/security/rsa/RSAPrivateKeyImpl.java
index 1f883f4205d..860e7706bc9 100644
--- a/jdk/src/share/classes/sun/security/rsa/RSAPrivateKeyImpl.java
+++ b/jdk/src/share/classes/sun/security/rsa/RSAPrivateKeyImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -61,7 +61,7 @@ public final class RSAPrivateKeyImpl extends PKCS8Key implements RSAPrivateKey {
RSAPrivateKeyImpl(BigInteger n, BigInteger d) throws InvalidKeyException {
this.n = n;
this.d = d;
- RSAKeyFactory.checkKeyLength(n);
+ RSAKeyFactory.checkRSAProviderKeyLengths(n.bitLength(), null);
// generate the encoding
algid = RSAPrivateCrtKeyImpl.rsaId;
try {
diff --git a/jdk/src/share/classes/sun/security/rsa/RSAPublicKeyImpl.java b/jdk/src/share/classes/sun/security/rsa/RSAPublicKeyImpl.java
index c500ca2dee4..6db08f6a393 100644
--- a/jdk/src/share/classes/sun/security/rsa/RSAPublicKeyImpl.java
+++ b/jdk/src/share/classes/sun/security/rsa/RSAPublicKeyImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -56,10 +56,11 @@ public final class RSAPublicKeyImpl extends X509Key implements RSAPublicKey {
* Construct a key from its components. Used by the
* RSAKeyFactory and the RSAKeyPairGenerator.
*/
- public RSAPublicKeyImpl(BigInteger n, BigInteger e) throws InvalidKeyException {
+ public RSAPublicKeyImpl(BigInteger n, BigInteger e)
+ throws InvalidKeyException {
this.n = n;
this.e = e;
- RSAKeyFactory.checkKeyLength(n);
+ RSAKeyFactory.checkRSAProviderKeyLengths(n.bitLength(), e);
// generate the encoding
algid = RSAPrivateCrtKeyImpl.rsaId;
try {
@@ -80,7 +81,7 @@ public final class RSAPublicKeyImpl extends X509Key implements RSAPublicKey {
*/
public RSAPublicKeyImpl(byte[] encoded) throws InvalidKeyException {
decode(encoded);
- RSAKeyFactory.checkKeyLength(n);
+ RSAKeyFactory.checkRSAProviderKeyLengths(n.bitLength(), e);
}
// see JCA doc
diff --git a/jdk/src/windows/classes/sun/security/mscapi/RSAKeyPairGenerator.java b/jdk/src/windows/classes/sun/security/mscapi/RSAKeyPairGenerator.java
index 146d7c1632d..44dd25ab8cd 100644
--- a/jdk/src/windows/classes/sun/security/mscapi/RSAKeyPairGenerator.java
+++ b/jdk/src/windows/classes/sun/security/mscapi/RSAKeyPairGenerator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@ import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.RSAKeyGenParameterSpec;
import sun.security.jca.JCAUtil;
+import sun.security.rsa.RSAKeyFactory;
/**
* RSA keypair generator.
@@ -43,8 +44,8 @@ import sun.security.jca.JCAUtil;
public final class RSAKeyPairGenerator extends KeyPairGeneratorSpi {
// Supported by Microsoft Base, Strong and Enhanced Cryptographic Providers
- private static final int KEY_SIZE_MIN = 512; // disallow MSCAPI min. of 384
- private static final int KEY_SIZE_MAX = 16384;
+ static final int KEY_SIZE_MIN = 512; // disallow MSCAPI min. of 384
+ static final int KEY_SIZE_MAX = 16384;
private static final int KEY_SIZE_DEFAULT = 1024;
// size of the key to generate, KEY_SIZE_MIN <= keySize <= KEY_SIZE_MAX
@@ -59,7 +60,14 @@ public final class RSAKeyPairGenerator extends KeyPairGeneratorSpi {
// random is always ignored
public void initialize(int keySize, SecureRandom random) {
- checkKeySize(keySize);
+ try {
+ RSAKeyFactory.checkKeyLengths(keySize, null,
+ KEY_SIZE_MIN, KEY_SIZE_MAX);
+ } catch (InvalidKeyException e) {
+ throw new InvalidParameterException(e.getMessage());
+ }
+
+ this.keySize = keySize;
}
// second initialize method. See JCA doc
@@ -67,21 +75,31 @@ public final class RSAKeyPairGenerator extends KeyPairGeneratorSpi {
public void initialize(AlgorithmParameterSpec params, SecureRandom random)
throws InvalidAlgorithmParameterException {
+ int tmpSize;
if (params == null) {
- checkKeySize(KEY_SIZE_DEFAULT);
-
+ tmpSize = KEY_SIZE_DEFAULT;
} else if (params instanceof RSAKeyGenParameterSpec) {
if (((RSAKeyGenParameterSpec) params).getPublicExponent() != null) {
throw new InvalidAlgorithmParameterException
("Exponent parameter is not supported");
}
- checkKeySize(((RSAKeyGenParameterSpec) params).getKeysize());
+ tmpSize = ((RSAKeyGenParameterSpec) params).getKeysize();
} else {
throw new InvalidAlgorithmParameterException
("Params must be an instance of RSAKeyGenParameterSpec");
}
+
+ try {
+ RSAKeyFactory.checkKeyLengths(tmpSize, null,
+ KEY_SIZE_MIN, KEY_SIZE_MAX);
+ } catch (InvalidKeyException e) {
+ throw new InvalidAlgorithmParameterException(
+ "Invalid Key sizes", e);
+ }
+
+ this.keySize = tmpSize;
}
// generate the keypair. See JCA doc
@@ -95,18 +113,6 @@ public final class RSAKeyPairGenerator extends KeyPairGeneratorSpi {
return new KeyPair(keys.getPublic(), keys.getPrivate());
}
- private void checkKeySize(int keySize) throws InvalidParameterException {
- if (keySize < KEY_SIZE_MIN) {
- throw new InvalidParameterException
- ("Key size must be at least " + KEY_SIZE_MIN + " bits");
- }
- if (keySize > KEY_SIZE_MAX) {
- throw new InvalidParameterException
- ("Key size must be " + KEY_SIZE_MAX + " bits or less");
- }
- this.keySize = keySize;
- }
-
private static native RSAKeyPair generateRSAKeyPair(int keySize,
String keyContainerName);
}
diff --git a/jdk/src/windows/classes/sun/security/mscapi/RSASignature.java b/jdk/src/windows/classes/sun/security/mscapi/RSASignature.java
index 606423d53a4..982e1836a7d 100644
--- a/jdk/src/windows/classes/sun/security/mscapi/RSASignature.java
+++ b/jdk/src/windows/classes/sun/security/mscapi/RSASignature.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -38,6 +38,9 @@ import java.security.SecureRandom;
import java.security.Signature;
import java.security.SignatureSpi;
import java.security.SignatureException;
+import java.math.BigInteger;
+
+import sun.security.rsa.RSAKeyFactory;
/**
* RSA signature implementation. Supports RSA signing using PKCS#1 v1.5 padding.
@@ -124,7 +127,16 @@ abstract class RSASignature extends java.security.SignatureSpi
// convert key to MSCAPI format
- byte[] modulusBytes = rsaKey.getModulus().toByteArray();
+ BigInteger modulus = rsaKey.getModulus();
+ BigInteger exponent = rsaKey.getPublicExponent();
+
+ // Check against the local and global values to make sure
+ // the sizes are ok. Round up to the nearest byte.
+ RSAKeyFactory.checkKeyLengths(((modulus.bitLength() + 7) & ~7),
+ exponent, -1, RSAKeyPairGenerator.KEY_SIZE_MAX);
+
+ byte[] modulusBytes = modulus.toByteArray();
+ byte[] exponentBytes = exponent.toByteArray();
// Adjust key length due to sign bit
int keyBitLength = (modulusBytes[0] == 0)
@@ -132,8 +144,7 @@ abstract class RSASignature extends java.security.SignatureSpi
: modulusBytes.length * 8;
byte[] keyBlob = generatePublicKeyBlob(
- keyBitLength, modulusBytes,
- rsaKey.getPublicExponent().toByteArray());
+ keyBitLength, modulusBytes, exponentBytes);
publicKey = importPublicKey(keyBlob, keyBitLength);
@@ -166,12 +177,11 @@ abstract class RSASignature extends java.security.SignatureSpi
}
privateKey = (sun.security.mscapi.RSAPrivateKey) key;
- // Determine byte length from bit length
- int keySize = (privateKey.bitLength() + 7) >> 3;
-
- if (keySize < 64)
- throw new InvalidKeyException(
- "RSA keys must be at least 512 bits long");
+ // Check against the local and global values to make sure
+ // the sizes are ok. Round up to nearest byte.
+ RSAKeyFactory.checkKeyLengths(((privateKey.bitLength() + 7) & ~7),
+ null, RSAKeyPairGenerator.KEY_SIZE_MIN,
+ RSAKeyPairGenerator.KEY_SIZE_MAX);
if (needsReset) {
messageDigest.reset();
From 6aab63dd371dfeb79ce7c3a9c70fd1758c7c4a9f Mon Sep 17 00:00:00 2001
From: Weijun Wang
Date: Wed, 1 Oct 2008 10:01:45 +0800
Subject: [PATCH 002/292] 6588160: jaas krb5 client leaks OS-level UDP sockets
(all platforms)
Reviewed-by: jccollet, chegar
---
.../classes/sun/security/krb5/KrbKdcReq.java | 38 ++++++++++---------
.../sun/security/krb5/internal/UDPClient.java | 3 ++
2 files changed, 24 insertions(+), 17 deletions(-)
diff --git a/jdk/src/share/classes/sun/security/krb5/KrbKdcReq.java b/jdk/src/share/classes/sun/security/krb5/KrbKdcReq.java
index e9ff9cc04d5..259aedd66fa 100644
--- a/jdk/src/share/classes/sun/security/krb5/KrbKdcReq.java
+++ b/jdk/src/share/classes/sun/security/krb5/KrbKdcReq.java
@@ -274,27 +274,31 @@ public abstract class KrbKdcReq {
+ ",Attempt =" + i
+ ", #bytes=" + obuf.length);
}
- /*
- * Send the data to the kdc.
- */
+ try {
+ /*
+ * Send the data to the kdc.
+ */
kdcClient.send(obuf);
- /*
- * And get a response.
- */
- try {
- ibuf = kdcClient.receive();
- break;
- } catch (SocketTimeoutException se) {
- if (DEBUG) {
- System.out.println ("SocketTimeOutException with " +
- "attempt: " + i);
- }
- if (i == DEFAULT_KDC_RETRY_LIMIT) {
- ibuf = null;
- throw se;
+ /*
+ * And get a response.
+ */
+ try {
+ ibuf = kdcClient.receive();
+ break;
+ } catch (SocketTimeoutException se) {
+ if (DEBUG) {
+ System.out.println ("SocketTimeOutException with " +
+ "attempt: " + i);
+ }
+ if (i == DEFAULT_KDC_RETRY_LIMIT) {
+ ibuf = null;
+ throw se;
+ }
}
+ } finally {
+ kdcClient.close();
}
}
}
diff --git a/jdk/src/share/classes/sun/security/krb5/internal/UDPClient.java b/jdk/src/share/classes/sun/security/krb5/internal/UDPClient.java
index c9e440f1ef7..670df9210df 100644
--- a/jdk/src/share/classes/sun/security/krb5/internal/UDPClient.java
+++ b/jdk/src/share/classes/sun/security/krb5/internal/UDPClient.java
@@ -93,4 +93,7 @@ public class UDPClient {
return data;
}
+ public void close() {
+ dgSocket.close();
+ }
}
From 3a7a9cc5577bd4ad27ae072ccd9b3bf65c637c02 Mon Sep 17 00:00:00 2001
From: Kumar Srinivasan
Date: Thu, 4 Sep 2008 09:43:32 -0700
Subject: [PATCH 003/292] 6733959: Insufficient checks for "Main-Class"
manifest entry in JAR files
Fixes a buffer overrun problem with a very long Main-Class attribute.
Reviewed-by: darcy
---
jdk/src/share/bin/emessages.h | 1 +
jdk/src/share/bin/java.c | 10 ++-
jdk/test/tools/launcher/MultipleJRE.sh | 82 ++++++++++++++++++-----
jdk/test/tools/launcher/ZipMeUp.java | 91 ++++++++++++++++++++++++++
4 files changed, 164 insertions(+), 20 deletions(-)
create mode 100644 jdk/test/tools/launcher/ZipMeUp.java
diff --git a/jdk/src/share/bin/emessages.h b/jdk/src/share/bin/emessages.h
index 03824bba5d1..6bfb8e16614 100644
--- a/jdk/src/share/bin/emessages.h
+++ b/jdk/src/share/bin/emessages.h
@@ -54,6 +54,7 @@
#define CLS_ERROR2 "Error: Failed to load Main Class: %s\n%s"
#define CLS_ERROR3 "Error: No main method found in specified class.\n" GEN_ERROR
#define CLS_ERROR4 "Error: Main method not public\n" GEN_ERROR
+#define CLS_ERROR5 "Error: main-class: attribute exceeds system limits of %d bytes\n" GEN_ERROR
#define CFG_WARN1 "Warning: %s VM not supported; %s VM will be used"
#define CFG_WARN2 "Warning: No leading - on line %d of `%s'"
diff --git a/jdk/src/share/bin/java.c b/jdk/src/share/bin/java.c
index f7cbcdc95bc..b351fe3aa83 100644
--- a/jdk/src/share/bin/java.c
+++ b/jdk/src/share/bin/java.c
@@ -987,8 +987,14 @@ SelectVersion(int argc, char **argv, char **main_class)
* to avoid locating, expanding and parsing the manifest extra
* times.
*/
- if (info.main_class != NULL)
- (void)JLI_StrCat(env_entry, info.main_class);
+ if (info.main_class != NULL) {
+ if (JLI_StrLen(info.main_class) <= MAXNAMELEN) {
+ (void)JLI_StrCat(env_entry, info.main_class);
+ } else {
+ ReportErrorMessage(CLS_ERROR5, MAXNAMELEN);
+ exit(1);
+ }
+ }
(void)putenv(env_entry);
ExecJRE(jre, new_argv);
JLI_FreeManifest();
diff --git a/jdk/test/tools/launcher/MultipleJRE.sh b/jdk/test/tools/launcher/MultipleJRE.sh
index b3e1cf764ed..a6dfaaa5253 100644
--- a/jdk/test/tools/launcher/MultipleJRE.sh
+++ b/jdk/test/tools/launcher/MultipleJRE.sh
@@ -1,14 +1,14 @@
# @test MultipleJRE.sh
-# @bug 4811102 4953711 4955505 4956301 4991229 4998210 5018605 6387069
+# @bug 4811102 4953711 4955505 4956301 4991229 4998210 5018605 6387069 6733959
# @build PrintVersion
# @build UglyPrintVersion
+# @build ZipMeUp
# @run shell MultipleJRE.sh
# @summary Verify Multiple JRE version support
# @author Joseph E. Kowalski
-
#
-# Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -49,10 +49,25 @@ then
exit 1
fi
+JAVAEXE="$TESTJAVA/bin/java"
JAVA="$TESTJAVA/bin/java -classpath $TESTCLASSES"
JAR="$TESTJAVA/bin/jar"
OS=`uname -s`;
+#
+# Tests whether we are on windows (true) or not.
+#
+IsWindows() {
+ case "$OS" in
+ Windows* | CYGWIN* )
+ printf "true"
+ ;;
+ * )
+ printf "false"
+ ;;
+ esac
+}
+
#
# Shell routine to test for the proper rejection of syntactically incorrect
# version specifications.
@@ -139,7 +154,6 @@ CreateUglyJar() {
$PACKAGE/UglyPrintVersion.class
}
-
#
# Constructs a jar file with a fair number of "zip directory" entries and
# the MANIFEST.MF entry at or near the end of that directory to validate
@@ -262,6 +276,29 @@ LaunchVM() {
fi
}
+# Tests very long Main-Class attribute in the jar
+TestLongMainClass() {
+ JVER=$1
+ if [ "$JVER" = "mklink" ]; then
+ JVER=XX
+ JDKXX=jdk/j2re$JVER
+ rm -rf jdk
+ mkdir jdk
+ ln -s $TESTJAVA $JDKXX
+ JAVA_VERSION_PATH="`pwd`/jdk"
+ export JAVA_VERSION_PATH
+ fi
+ $JAVAEXE -cp $TESTCLASSES ZipMeUp UglyBetty.jar 4097
+ message="`$JAVAEXE -version:$JVER -jar UglyBetty.jar 2>&1`"
+ echo $message | grep "Error: main-class: attribute exceeds system limits" > /dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ printf "Long manifest test did not get expected error"
+ exit 1
+ fi
+ unset JAVA_VERSION_PATH
+ rm -rf jdk
+}
+
#
# Main test sequence starts here
#
@@ -280,14 +317,11 @@ CreateJar "" ""
LaunchVM "" "${RELEASE}"
CreateJar "" "0"
LaunchVM "" "${RELEASE}"
-case "$OS" in
- Windows* | CYGWIN* )
- MAXIMUM_PATH=255;
- ;;
- *)
- MAXIMUM_PATH=1024;
- ;;
-esac
+if [ `IsWindows` = "true" ]; then
+ MAXIMUM_PATH=255;
+else
+ MAXIMUM_PATH=1024;
+fi
PATH_LENGTH=`printf "%s" "$UGLYCLASS" | wc -c`
if [ ${PATH_LENGTH} -lt ${MAXIMUM_PATH} ]; then
@@ -346,7 +380,6 @@ if [ -x /usr/bin/zipnote ]; then
LaunchVM "" "${RELEASE}"
fi
-
#
# Throw some syntactically challenged (illegal) version specifiers at
# the interface. Failure (of the launcher) is success for the test.
@@ -357,15 +390,28 @@ TestSyntax "1.2.3-" # Ends with a separator
TestSyntax "1.2+.3" # Embedded modifier
TestSyntax "1.2.4+&1.2*&1++" # Long and invalid
+# On windows we see if there is another jre installed, usually
+# there is, then we test using that, otherwise links are created
+# to get through to SelectVersion.
+if [ `IsWindows` = "false" ]; then
+ TestLongMainClass "mklink"
+else
+ $JAVAEXE -version:1.0+
+ if [ $? -eq 0 ]; then
+ TestLongMainClass "1.0+"
+ else
+ printf "Warning: TestLongMainClass skipped as there is no"
+ printf "viable MJRE installed.\n"
+ fi
+fi
+
#
# Because scribbling in the registry can be rather destructive, only a
# subset of the tests are run on Windows.
#
-case "$OS" in
- Windows* | CYGWIN* )
- exit 0;
- ;;
-esac
+if [ `IsWindows` = "true" ]; then
+ exit 0;
+fi
#
# Additional version specifiers containing spaces. (Sigh, unable to
diff --git a/jdk/test/tools/launcher/ZipMeUp.java b/jdk/test/tools/launcher/ZipMeUp.java
new file mode 100644
index 00000000000..84d3f186e7e
--- /dev/null
+++ b/jdk/test/tools/launcher/ZipMeUp.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * A simple class to create our erring Jar with a very long Main-Class
+ * attribute in the manifest.
+ */
+import java.io.ByteArrayOutputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.zip.CRC32;
+import java.util.zip.CheckedOutputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+public class ZipMeUp {
+
+ static final CRC32 crc = new CRC32();
+
+ private static String SOME_KLASS = ".Some";
+
+ static byte[] getManifestAsBytes(int nchars) throws IOException {
+ crc.reset();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ CheckedOutputStream cos = new CheckedOutputStream(baos, crc);
+ PrintStream ps = new PrintStream(cos);
+ ps.println("Manifest-Version: 1.0");
+ ps.print("Main-Class: ");
+ for (int i = 0 ; i < nchars - SOME_KLASS.length() ; i++) {
+ ps.print(i%10);
+ }
+ ps.println(SOME_KLASS);
+ cos.flush();
+ cos.close();
+ ps.close();
+ return baos.toByteArray();
+ }
+
+ /**
+ * The arguments are: filename_to_create length
+ * @param args
+ * @throws java.lang.Exception
+ */
+ public static void main(String...args) throws Exception {
+ FileOutputStream fos = new FileOutputStream(args[0]);
+ ZipOutputStream zos = new ZipOutputStream(fos);
+ byte[] manifest = getManifestAsBytes(Integer.parseInt(args[1]));
+ ZipEntry ze = new ZipEntry("META-INF/MANIFEST.MF");
+ ze.setMethod(ZipEntry.STORED);
+ ze.setSize(manifest.length);
+ ze.setCompressedSize(manifest.length);
+ ze.setCrc(crc.getValue());
+ ze.setTime(System.currentTimeMillis());
+ zos.putNextEntry(ze);
+ zos.write(manifest);
+ zos.flush();
+
+ // add a zero length class
+ ze = new ZipEntry(SOME_KLASS + ".class");
+ ze.setMethod(ZipEntry.STORED);
+ ze.setSize(0);
+ ze.setCompressedSize(0);
+ ze.setCrc(0);
+ ze.setTime(System.currentTimeMillis());
+ zos.putNextEntry(ze);
+ zos.flush();
+ zos.closeEntry();
+ zos.close();
+ System.exit(0);
+ }
+}
From 3729356740fb70966397e582528db89a60e0824e Mon Sep 17 00:00:00 2001
From: Masayoshi Okutsu
Date: Thu, 2 Oct 2008 16:49:33 +0900
Subject: [PATCH 004/292] 6734167: Calendar.readObject allows elevation of
privileges
Reviewed-by: peytoia
---
jdk/src/share/classes/java/util/Calendar.java | 54 ++++++++++++++-----
1 file changed, 42 insertions(+), 12 deletions(-)
diff --git a/jdk/src/share/classes/java/util/Calendar.java b/jdk/src/share/classes/java/util/Calendar.java
index e1f65e6a885..072de9e142f 100644
--- a/jdk/src/share/classes/java/util/Calendar.java
+++ b/jdk/src/share/classes/java/util/Calendar.java
@@ -41,9 +41,14 @@ package java.util;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.io.OptionalDataException;
import java.io.Serializable;
+import java.security.AccessControlContext;
import java.security.AccessController;
+import java.security.PermissionCollection;
+import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
+import java.security.ProtectionDomain;
import java.text.DateFormat;
import java.text.DateFormatSymbols;
import sun.util.BuddhistCalendar;
@@ -2626,6 +2631,18 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable() {
+ public ZoneInfo run() throws Exception {
+ return (ZoneInfo) input.readObject();
+ }
+ },
+ CalendarAccessControlContext.INSTANCE);
+ } catch (PrivilegedActionException pae) {
+ Exception e = pae.getException();
+ if (!(e instanceof OptionalDataException)) {
+ if (e instanceof RuntimeException) {
+ throw (RuntimeException) e;
+ } else if (e instanceof IOException) {
+ throw (IOException) e;
+ } else if (e instanceof ClassNotFoundException) {
+ throw (ClassNotFoundException) e;
+ }
+ throw new RuntimeException(e);
}
- } catch (Exception e) {
+ }
+ if (zi != null) {
+ zone = zi;
}
// If the deserialized object has a SimpleTimeZone, try to
@@ -2674,9 +2704,9 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable
Date: Thu, 2 Oct 2008 20:37:43 +0400
Subject: [PATCH 005/292] 6726779: ConvolveOp on USHORT raster can cause the
JVM crash
Reviewed-by: igor, prr
---
.../native/sun/awt/medialib/awt_ImagingLib.c | 38 +++-----
.../awt/image/ConvolveOp/EdgeNoOpCrash.java | 95 +++++++++++++++++++
2 files changed, 107 insertions(+), 26 deletions(-)
create mode 100644 jdk/test/java/awt/image/ConvolveOp/EdgeNoOpCrash.java
diff --git a/jdk/src/share/native/sun/awt/medialib/awt_ImagingLib.c b/jdk/src/share/native/sun/awt/medialib/awt_ImagingLib.c
index 681f26290b8..157827fef29 100644
--- a/jdk/src/share/native/sun/awt/medialib/awt_ImagingLib.c
+++ b/jdk/src/share/native/sun/awt/medialib/awt_ImagingLib.c
@@ -216,6 +216,16 @@ printMedialibError(int status) {
#endif /* ! DEBUG */
+static int
+getMlibEdgeHint(jint edgeHint) {
+ switch (edgeHint) {
+ case java_awt_image_ConvolveOp_EDGE_NO_OP:
+ return MLIB_EDGE_DST_COPY_SRC;
+ case java_awt_image_ConvolveOp_EDGE_ZERO_FILL:
+ default:
+ return MLIB_EDGE_DST_FILL_ZERO;
+ }
+}
/***************************************************************************
* External Functions *
@@ -400,22 +410,10 @@ Java_sun_awt_image_ImagingLib_convolveBI(JNIEnv *env, jobject this,
}
}
- if (edgeHint == java_awt_image_ConvolveOp_EDGE_NO_OP) {
- int kw2 = kwidth>>1;
- int kh2 = kheight>>1;
- int bsize = mlib_ImageGetChannels(src)*
- (mlib_ImageGetType(src) == MLIB_BYTE ? 1 : 2);
-
- void *dstDataP = mlib_ImageGetData(dst);
- void *srcDataP = mlib_ImageGetData(src);
- /* REMIND: Copy a smaller area */
- memcpy(dstDataP, srcDataP, dst->width*dst->height*bsize);
- }
-
cmask = (1<channels)-1;
status = (*sMlibFns[MLIB_CONVMxN].fptr)(dst, src, kdata, w, h,
(w-1)/2, (h-1)/2, scale, cmask,
- MLIB_EDGE_DST_NO_WRITE);
+ getMlibEdgeHint(edgeHint));
if (status != MLIB_SUCCESS) {
printMedialibError(status);
@@ -660,22 +658,10 @@ Java_sun_awt_image_ImagingLib_convolveRaster(JNIEnv *env, jobject this,
}
}
- if (edgeHint == java_awt_image_ConvolveOp_EDGE_NO_OP) {
- int kw2 = kwidth>>1;
- int kh2 = kheight>>1;
- int bsize = mlib_ImageGetChannels(src)*
- (mlib_ImageGetType(src) == MLIB_BYTE ? 1 : 2);
-
- void *dstDataP = mlib_ImageGetData(dst);
- void *srcDataP = mlib_ImageGetData(src);
- /* REMIND: Copy a smaller area */
- memcpy(dstDataP, srcDataP, dst->width*dst->height*bsize);
- }
-
cmask = (1<channels)-1;
status = (*sMlibFns[MLIB_CONVMxN].fptr)(dst, src, kdata, w, h,
(w-1)/2, (h-1)/2, scale, cmask,
- MLIB_EDGE_DST_NO_WRITE);
+ getMlibEdgeHint(edgeHint));
if (status != MLIB_SUCCESS) {
printMedialibError(status);
diff --git a/jdk/test/java/awt/image/ConvolveOp/EdgeNoOpCrash.java b/jdk/test/java/awt/image/ConvolveOp/EdgeNoOpCrash.java
new file mode 100644
index 00000000000..5e1d2eb3f66
--- /dev/null
+++ b/jdk/test/java/awt/image/ConvolveOp/EdgeNoOpCrash.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6726779
+ * @summary Test verifies that ConvolveOp with the EDGE_NO_OP edge condition
+ * does not cause JVM crash if size of source raster elements is
+ * greather than size of the destination raster element.
+ *
+ * @run main EdgeNoOpCrash
+ */
+import java.awt.Point;
+import java.awt.image.ConvolveOp;
+import java.awt.image.DataBuffer;
+import java.awt.image.ImagingOpException;
+import java.awt.image.Kernel;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+import java.util.Arrays;
+
+public class EdgeNoOpCrash {
+ private static final int w = 3000;
+ private static final int h = 200;
+
+ public static void main(String[] args) {
+ crashTest();
+ }
+
+ private static void crashTest() {
+ Raster src = createSrcRaster();
+ WritableRaster dst = createDstRaster();
+ ConvolveOp op = createConvolveOp(ConvolveOp.EDGE_NO_OP);
+ try {
+ op.filter(src, dst);
+ } catch (ImagingOpException e) {
+ /*
+ * The test pair of source and destination rasters
+ * may cause failure of the medialib convolution routine,
+ * so this exception is expected.
+ *
+ * The JVM crash is the only manifestation of this
+ * test failure.
+ */
+ }
+ System.out.println("Test PASSED.");
+ }
+
+ private static Raster createSrcRaster() {
+ WritableRaster r = Raster.createInterleavedRaster(DataBuffer.TYPE_USHORT,
+ w, h, 4, new Point(0, 0));
+
+ return r;
+ }
+
+ private static WritableRaster createDstRaster() {
+ WritableRaster r = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE,
+ w, h, 4, new Point(0, 0));
+
+ return r;
+ }
+
+ private static ConvolveOp createConvolveOp(int edgeHint) {
+ final int kw = 3;
+ final int kh = 3;
+ float[] kdata = new float[kw * kh];
+ float v = 1f / kdata.length;
+ Arrays.fill(kdata, v);
+
+ Kernel k = new Kernel(kw, kh, kdata);
+ ConvolveOp op = new ConvolveOp(k, edgeHint, null);
+
+ return op;
+ }
+}
\ No newline at end of file
From 01bf9872448b93153ab539f370858bf830c3fd7d Mon Sep 17 00:00:00 2001
From: Alan Bateman
Date: Thu, 9 Oct 2008 21:12:56 +0100
Subject: [PATCH 006/292] 6721753: File.createTempFile produces guessable file
names
Reviewed-by: sherman
---
jdk/src/share/classes/java/io/File.java | 54 ++++++++++++-------------
1 file changed, 26 insertions(+), 28 deletions(-)
diff --git a/jdk/src/share/classes/java/io/File.java b/jdk/src/share/classes/java/io/File.java
index 7c58136a44d..8433c75d488 100644
--- a/jdk/src/share/classes/java/io/File.java
+++ b/jdk/src/share/classes/java/io/File.java
@@ -33,9 +33,9 @@ import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Map;
import java.util.Hashtable;
-import java.util.Random;
import java.security.AccessController;
import java.security.AccessControlException;
+import java.security.SecureRandom;
import sun.security.action.GetPropertyAction;
@@ -1678,28 +1678,28 @@ public class File
/* -- Temporary files -- */
- private static final Object tmpFileLock = new Object();
+ // lazy initialization of SecureRandom and temporary file directory
+ private static class LazyInitialization {
+ static final SecureRandom random = new SecureRandom();
- private static int counter = -1; /* Protected by tmpFileLock */
+ static final String temporaryDirectory = temporaryDirectory();
+ static String temporaryDirectory() {
+ return fs.normalize(
+ AccessController.doPrivileged(
+ new GetPropertyAction("java.io.tmpdir")));
+ }
+ }
private static File generateFile(String prefix, String suffix, File dir)
throws IOException
{
- if (counter == -1) {
- counter = new Random().nextInt() & 0xffff;
+ long n = LazyInitialization.random.nextLong();
+ if (n == Long.MIN_VALUE) {
+ n = 0; // corner case
+ } else {
+ n = Math.abs(n);
}
- counter++;
- return new File(dir, prefix + Integer.toString(counter) + suffix);
- }
-
- private static String tmpdir; /* Protected by tmpFileLock */
-
- private static String getTempDir() {
- if (tmpdir == null)
- tmpdir = fs.normalize(
- AccessController.doPrivileged(
- new GetPropertyAction("java.io.tmpdir")));
- return tmpdir;
+ return new File(dir, prefix + Long.toString(n) + suffix);
}
private static boolean checkAndCreate(String filename, SecurityManager sm)
@@ -1795,18 +1795,16 @@ public class File
if (prefix.length() < 3)
throw new IllegalArgumentException("Prefix string too short");
String s = (suffix == null) ? ".tmp" : suffix;
- synchronized (tmpFileLock) {
- if (directory == null) {
- String tmpDir = getTempDir();
- directory = new File(tmpDir, fs.prefixLength(tmpDir));
- }
- SecurityManager sm = System.getSecurityManager();
- File f;
- do {
- f = generateFile(prefix, s, directory);
- } while (!checkAndCreate(f.getPath(), sm));
- return f;
+ if (directory == null) {
+ String tmpDir = LazyInitialization.temporaryDirectory();
+ directory = new File(tmpDir, fs.prefixLength(tmpDir));
}
+ SecurityManager sm = System.getSecurityManager();
+ File f;
+ do {
+ f = generateFile(prefix, s, directory);
+ } while (!checkAndCreate(f.getPath(), sm));
+ return f;
}
/**
From 92992b2e764bc12439d30b28c4161445e86db0bb Mon Sep 17 00:00:00 2001
From: Kumar Srinivasan
Date: Fri, 17 Oct 2008 09:43:30 -0700
Subject: [PATCH 007/292] 6755943: Java JAR Pack200 Decompression should
enforce stricter header checks
Fixes a core dump when fed with a faulty pack file and related malicious take over
Reviewed-by: jrose
---
jdk/make/common/shared/Defs-windows.gmk | 4 +
.../com/sun/java/util/jar/pack/bytes.cpp | 6 +-
.../com/sun/java/util/jar/pack/defines.h | 10 +-
.../com/sun/java/util/jar/pack/main.cpp | 4 +-
.../com/sun/java/util/jar/pack/unpack.cpp | 24 +-
.../com/sun/java/util/jar/pack/unpack.h | 4 +-
.../com/sun/java/util/jar/pack/utils.cpp | 11 +-
.../native/com/sun/java/util/jar/pack/utils.h | 22 +-
.../tools/pack200/MemoryAllocatorTest.java | 369 ++++++++++++++++++
9 files changed, 423 insertions(+), 31 deletions(-)
create mode 100644 jdk/test/tools/pack200/MemoryAllocatorTest.java
diff --git a/jdk/make/common/shared/Defs-windows.gmk b/jdk/make/common/shared/Defs-windows.gmk
index 250604136bc..d829a41853e 100644
--- a/jdk/make/common/shared/Defs-windows.gmk
+++ b/jdk/make/common/shared/Defs-windows.gmk
@@ -539,6 +539,7 @@ else
WSCRIPT :=$(call FileExists,$(_WSCRIPT1),$(_WSCRIPT2))
endif
WSCRIPT:=$(call AltCheckSpaces,WSCRIPT)
+WSCRIPT += -B
# CSCRIPT: path to cscript.exe (used in creating install bundles)
ifdef ALT_CSCRIPT
@@ -561,6 +562,9 @@ else
MSIVAL2 :=$(call FileExists,$(_MSIVAL2_1),$(_MSIVAL2_2))
endif
MSIVAL2:=$(call AltCheckSpaces,MSIVAL2)
+ifdef SKIP_MSIVAL2
+ MSIVAL2 := $(ECHO)
+endif
# LOGOCUB: path to cub file for (used in validating install msi files)
ifdef ALT_LOGOCUB
diff --git a/jdk/src/share/native/com/sun/java/util/jar/pack/bytes.cpp b/jdk/src/share/native/com/sun/java/util/jar/pack/bytes.cpp
index 95c3dde66e9..36843061354 100644
--- a/jdk/src/share/native/com/sun/java/util/jar/pack/bytes.cpp
+++ b/jdk/src/share/native/com/sun/java/util/jar/pack/bytes.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -56,7 +56,7 @@ void bytes::realloc(size_t len_) {
return;
}
byte* oldptr = ptr;
- ptr = (byte*)::realloc(ptr, len_+1);
+ ptr = (len_ >= PSIZE_MAX) ? null : (byte*)::realloc(ptr, len_+1);
if (ptr != null) {
mtrace('r', oldptr, 0);
mtrace('m', ptr, len_+1);
@@ -126,7 +126,7 @@ const char* bytes::string() {
// Make sure there are 'o' bytes beyond the fill pointer,
// advance the fill pointer, and return the old fill pointer.
byte* fillbytes::grow(size_t s) {
- size_t nlen = b.len+s;
+ size_t nlen = add_size(b.len, s);
if (nlen <= allocated) {
b.len = nlen;
return limit()-s;
diff --git a/jdk/src/share/native/com/sun/java/util/jar/pack/defines.h b/jdk/src/share/native/com/sun/java/util/jar/pack/defines.h
index 19f7567e7bc..f780f247b2a 100644
--- a/jdk/src/share/native/com/sun/java/util/jar/pack/defines.h
+++ b/jdk/src/share/native/com/sun/java/util/jar/pack/defines.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2004 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -47,11 +47,13 @@
#define NOT_PRODUCT(xxx)
#define assert(p) (0)
#define printcr false &&
+#define VERSION_STRING "%s version %s\n"
#else
#define IF_PRODUCT(xxx)
#define NOT_PRODUCT(xxx) xxx
#define assert(p) ((p) || (assert_failed(#p), 1))
#define printcr u->verbose && u->printcr_if_verbose
+#define VERSION_STRING "%s version non-product %s\n"
extern "C" void breakpoint();
extern void assert_failed(const char*);
#define BREAK (breakpoint())
@@ -79,9 +81,9 @@ extern void assert_failed(const char*);
#define lengthof(array) (sizeof(array)/sizeof(array[0]))
-#define NEW(T, n) (T*) must_malloc(sizeof(T)*(n))
-#define U_NEW(T, n) (T*) u->alloc(sizeof(T)*(n))
-#define T_NEW(T, n) (T*) u->temp_alloc(sizeof(T)*(n))
+#define NEW(T, n) (T*) must_malloc(scale_size(n, sizeof(T)))
+#define U_NEW(T, n) (T*) u->alloc(scale_size(n, sizeof(T)))
+#define T_NEW(T, n) (T*) u->temp_alloc(scale_size(n, sizeof(T)))
// bytes and byte arrays
diff --git a/jdk/src/share/native/com/sun/java/util/jar/pack/main.cpp b/jdk/src/share/native/com/sun/java/util/jar/pack/main.cpp
index 9e216cd19c7..234a6009da5 100644
--- a/jdk/src/share/native/com/sun/java/util/jar/pack/main.cpp
+++ b/jdk/src/share/native/com/sun/java/util/jar/pack/main.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -300,7 +300,7 @@ int unpacker::run(int argc, char **argv) {
case 'J': argp += 1; break; // skip ignored -Jxxx parameter
case 'V':
- fprintf(u.errstrm, "%s version %s\n", nbasename(argv[0]), sccsver);
+ fprintf(u.errstrm, VERSION_STRING, nbasename(argv[0]), sccsver);
exit(0);
case 'h':
diff --git a/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.cpp b/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.cpp
index 6480da70021..08fbbc2aa4a 100644
--- a/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.cpp
+++ b/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -618,18 +618,17 @@ void unpacker::read_file_header() {
if ((archive_options & AO_HAVE_FILE_HEADERS) != 0) {
uint hi = hdr.getInt();
uint lo = hdr.getInt();
- archive_size = band::makeLong(hi, lo);
+ julong x = band::makeLong(hi, lo);
+ archive_size = (size_t) x;
+ if (archive_size != x) {
+ // Silly size specified; force overflow.
+ archive_size = PSIZE_MAX+1;
+ }
hdrVals += 2;
} else {
hdrValsSkipped += 2;
}
- if (archive_size != (size_t)archive_size) {
- // Silly size specified.
- abort("archive too large");
- return;
- }
-
// Now we can size the whole archive.
// Read everything else into a mega-buffer.
rp = hdr.rp;
@@ -643,8 +642,8 @@ void unpacker::read_file_header() {
abort("EOF reading fixed input buffer");
return;
}
- } else if (archive_size > 0) {
- input.set(U_NEW(byte, (size_t) header_size_0 + archive_size + C_SLOP),
+ } else if (archive_size != 0) {
+ input.set(U_NEW(byte, add_size(header_size_0, archive_size, C_SLOP)),
(size_t) header_size_0 + archive_size);
assert(input.limit()[0] == 0);
// Move all the bytes we read initially into the real buffer.
@@ -654,7 +653,6 @@ void unpacker::read_file_header() {
} else {
// It's more complicated and painful.
// A zero archive_size means that we must read until EOF.
- assert(archive_size == 0);
input.init(CHUNK*2);
CHECK;
input.b.len = input.allocated;
@@ -664,7 +662,7 @@ void unpacker::read_file_header() {
rplimit += header_size;
while (ensure_input(input.limit() - rp)) {
size_t dataSoFar = input_remaining();
- size_t nextSize = dataSoFar + CHUNK;
+ size_t nextSize = add_size(dataSoFar, CHUNK);
input.ensureSize(nextSize);
CHECK;
input.b.len = input.allocated;
@@ -949,10 +947,12 @@ void unpacker::read_Utf8_values(entry* cpMap, int len) {
// First band: Read lengths of shared prefixes.
if (len > PREFIX_SKIP_2)
cp_Utf8_prefix.readData(len - PREFIX_SKIP_2);
+ NOT_PRODUCT(else cp_Utf8_prefix.readData(0)); // for asserts
// Second band: Read lengths of unshared suffixes:
if (len > SUFFIX_SKIP_1)
cp_Utf8_suffix.readData(len - SUFFIX_SKIP_1);
+ NOT_PRODUCT(else cp_Utf8_suffix.readData(0)); // for asserts
bytes* allsuffixes = T_NEW(bytes, len);
CHECK;
diff --git a/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.h b/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.h
index 7ab8e07b2ac..03e2edadcd3 100644
--- a/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.h
+++ b/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -204,7 +204,7 @@ struct unpacker {
// archive header fields
int magic, minver, majver;
- julong archive_size;
+ size_t archive_size;
int archive_next_count, archive_options, archive_modtime;
int band_headers_size;
int file_count, attr_definition_count, ic_count, class_count;
diff --git a/jdk/src/share/native/com/sun/java/util/jar/pack/utils.cpp b/jdk/src/share/native/com/sun/java/util/jar/pack/utils.cpp
index 4f45c84b524..8a88dcd961e 100644
--- a/jdk/src/share/native/com/sun/java/util/jar/pack/utils.cpp
+++ b/jdk/src/share/native/com/sun/java/util/jar/pack/utils.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2004 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -46,14 +46,13 @@
#include "unpack.h"
-void* must_malloc(int size) {
- int msize = size;
- assert(size >= 0);
+void* must_malloc(size_t size) {
+ size_t msize = size;
#ifdef USE_MTRACE
- if (msize < sizeof(int))
+ if (msize >= 0 && msize < sizeof(int))
msize = sizeof(int); // see 0xbaadf00d below
#endif
- void* ptr = malloc(msize);
+ void* ptr = (msize > PSIZE_MAX) ? null : malloc(msize);
if (ptr != null) {
memset(ptr, 0, size);
} else {
diff --git a/jdk/src/share/native/com/sun/java/util/jar/pack/utils.h b/jdk/src/share/native/com/sun/java/util/jar/pack/utils.h
index 6176634bcaf..cc211400eac 100644
--- a/jdk/src/share/native/com/sun/java/util/jar/pack/utils.h
+++ b/jdk/src/share/native/com/sun/java/util/jar/pack/utils.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,13 +25,31 @@
//Definitions of our util functions
-void* must_malloc(int size);
+void* must_malloc(size_t size);
#ifndef USE_MTRACE
#define mtrace(c, ptr, size) (0)
#else
void mtrace(char c, void* ptr, size_t size);
#endif
+// overflow management
+#define OVERFLOW ((size_t)-1)
+#define PSIZE_MAX (OVERFLOW/2) /* normal size limit */
+
+inline size_t scale_size(size_t size, size_t scale) {
+ return (size > PSIZE_MAX / scale) ? OVERFLOW : size * scale;
+}
+
+inline size_t add_size(size_t size1, size_t size2) {
+ return ((size1 | size2 | (size1 + size2)) > PSIZE_MAX)
+ ? OVERFLOW
+ : size1 + size2;
+}
+
+inline size_t add_size(size_t size1, size_t size2, int size3) {
+ return add_size(add_size(size1, size2), size3);
+}
+
// These may be expensive, because they have to go via Java TSD,
// if the optional u argument is missing.
struct unpacker;
diff --git a/jdk/test/tools/pack200/MemoryAllocatorTest.java b/jdk/test/tools/pack200/MemoryAllocatorTest.java
new file mode 100644
index 00000000000..6015a4e470d
--- /dev/null
+++ b/jdk/test/tools/pack200/MemoryAllocatorTest.java
@@ -0,0 +1,369 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6755943
+ * @summary Checks any memory overruns in archive length.
+ * @run main/timeout=1200 MemoryAllocatorTest
+ */
+import java.io.BufferedReader;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.RandomAccessFile;
+import java.nio.MappedByteBuffer;
+import java.nio.channels.FileChannel;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class MemoryAllocatorTest {
+
+ /*
+ * The smallest possible pack file with 1 empty resource
+ */
+ static int[] magic = {
+ 0xCA, 0xFE, 0xD0, 0x0D
+ };
+ static int[] version_info = {
+ 0x07, // minor
+ 0x96 // major
+ };
+ static int[] option = {
+ 0x10
+ };
+ static int[] size_hi = {
+ 0x00
+ };
+ static int[] size_lo_ulong = {
+ 0xFF, 0xFC, 0xFC, 0xFC, 0xFC // ULONG_MAX 0xFFFFFFFF
+ };
+ static int[] size_lo_correct = {
+ 0x17
+ };
+ static int[] data = {
+ 0x00, 0xEC, 0xDA, 0xDE, 0xF8, 0x45, 0x01, 0x02,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01, 0x31, 0x01, 0x00
+ };
+ // End of pack file data
+
+ static final String JAVA_HOME = System.getProperty("java.home");
+
+ static final boolean debug = Boolean.getBoolean("MemoryAllocatorTest.Debug");
+ static final boolean WINDOWS = System.getProperty("os.name").startsWith("Windows");
+ static final boolean LINUX = System.getProperty("os.name").startsWith("Linux");
+ static final boolean SIXTYFOUR_BIT = System.getProperty("sun.arch.data.model", "32").equals("64");
+ static final private int EXPECTED_EXIT_CODE = (WINDOWS) ? -1 : 255;
+
+ static int testExitValue = 0;
+
+ static byte[] bytes(int[] a) {
+ byte[] b = new byte[a.length];
+ for (int i = 0; i < b.length; i++) {
+ b[i] = (byte) a[i];
+ }
+ return b;
+ }
+
+ static void createPackFile(boolean good, File packFile) throws IOException {
+ FileOutputStream fos = new FileOutputStream(packFile);
+ fos.write(bytes(magic));
+ fos.write(bytes(version_info));
+ fos.write(bytes(option));
+ fos.write(bytes(size_hi));
+ if (good) {
+ fos.write(bytes(size_lo_correct));
+ } else {
+ fos.write(bytes(size_lo_ulong));
+ }
+ fos.write(bytes(data));
+ }
+
+ /*
+ * This method modifies the LSB of the size_lo for various wicked
+ * values between MAXINT-0x3F and MAXINT.
+ */
+ static int modifyPackFile(File packFile) throws IOException {
+ RandomAccessFile raf = new RandomAccessFile(packFile, "rws");
+ long len = packFile.length();
+ FileChannel fc = raf.getChannel();
+ MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_WRITE, 0, len);
+ int pos = magic.length + version_info.length + option.length +
+ size_hi.length;
+ byte value = bb.get(pos);
+ value--;
+ bb.position(pos);
+ bb.put(value);
+ bb.force();
+ fc.truncate(len);
+ fc.close();
+ return value & 0xFF;
+ }
+
+ static String getUnpack200Cmd() throws Exception {
+ File binDir = new File(JAVA_HOME, "bin");
+ File unpack200File = WINDOWS
+ ? new File(binDir, "unpack200.exe")
+ : new File(binDir, "unpack200");
+
+ String cmd = unpack200File.getAbsolutePath();
+ if (!unpack200File.canExecute()) {
+ throw new Exception("please check" +
+ cmd + " exists and is executable");
+ }
+ return cmd;
+ }
+
+ static TestResult runUnpacker(File packFile) throws Exception {
+ if (!packFile.exists()) {
+ throw new Exception("please check" + packFile + " exists");
+ }
+ ArrayList alist = new ArrayList();
+ ProcessBuilder pb = new ProcessBuilder(getUnpack200Cmd(),
+ packFile.getName(), "testout.jar");
+ Map env = pb.environment();
+ pb.directory(new File("."));
+ int retval = 0;
+ try {
+ pb.redirectErrorStream(true);
+ Process p = pb.start();
+ BufferedReader rd = new BufferedReader(
+ new InputStreamReader(p.getInputStream()), 8192);
+ String in = rd.readLine();
+ while (in != null) {
+ alist.add(in);
+ System.out.println(in);
+ in = rd.readLine();
+ }
+ retval = p.waitFor();
+ p.destroy();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw new RuntimeException(ex.getMessage());
+ }
+ return new TestResult("", retval, alist);
+ }
+
+ /*
+ * The debug version builds of unpack200 call abort(3) which might set
+ * an unexpected return value, therefore this test is to determine
+ * if we are using a product or non-product build and check the
+ * return value appropriately.
+ */
+ static boolean isNonProductVersion() throws Exception {
+ ArrayList alist = new ArrayList();
+ ProcessBuilder pb = new ProcessBuilder(getUnpack200Cmd(), "--version");
+ Map env = pb.environment();
+ pb.directory(new File("."));
+ int retval = 0;
+ try {
+ pb.redirectErrorStream(true);
+ Process p = pb.start();
+ BufferedReader rd = new BufferedReader(
+ new InputStreamReader(p.getInputStream()), 8192);
+ String in = rd.readLine();
+ while (in != null) {
+ alist.add(in);
+ System.out.println(in);
+ in = rd.readLine();
+ }
+ retval = p.waitFor();
+ p.destroy();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw new RuntimeException(ex.getMessage());
+ }
+ for (String x : alist) {
+ if (x.contains("non-product")) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @param args the command line arguments
+ * @throws java.lang.Exception
+ */
+ public static void main(String[] args) throws Exception {
+
+ File packFile = new File("tiny.pack");
+ boolean isNPVersion = isNonProductVersion();
+
+ // Create a good pack file and test if everything is ok
+ createPackFile(true, packFile);
+ TestResult tr = runUnpacker(packFile);
+ tr.setDescription("a good pack file");
+ tr.checkPositive();
+ tr.isOK();
+ System.out.println(tr);
+
+ /*
+ * jprt systems on windows and linux seem to have abundant memory
+ * therefore can take a very long time to run, and even if it does
+ * the error message is not accurate for us to discern if the test
+ * passess successfully.
+ */
+ if (SIXTYFOUR_BIT && (LINUX || WINDOWS)) {
+ System.out.println("Warning: Windows/Linux 64bit tests passes vacuously");
+ return;
+ }
+
+ /*
+ * debug builds call abort, the exit code under these conditions
+ * are not really relevant.
+ */
+ if (isNPVersion) {
+ System.out.println("Warning: non-product build: exit values not checked");
+ }
+
+ // create a bad pack file
+ createPackFile(false, packFile);
+ tr = runUnpacker(packFile);
+ tr.setDescription("a wicked pack file");
+ tr.contains("Native allocation failed");
+ if(!isNPVersion) {
+ tr.checkValue(EXPECTED_EXIT_CODE);
+ }
+ System.out.println(tr);
+ int value = modifyPackFile(packFile);
+ tr.setDescription("value=" + value);
+
+ // continue creating bad pack files by modifying the specimen pack file.
+ while (value >= 0xc0) {
+ tr = runUnpacker(packFile);
+ tr.contains("Native allocation failed");
+ if (!isNPVersion) {
+ tr.checkValue(EXPECTED_EXIT_CODE);
+ }
+ tr.setDescription("wicked value=0x" +
+ Integer.toHexString(value & 0xFF));
+ System.out.println(tr);
+ value = modifyPackFile(packFile);
+ }
+ if (testExitValue != 0) {
+ throw new Exception("Pack200 archive length tests(" +
+ testExitValue + ") failed ");
+ } else {
+ System.out.println("All tests pass");
+ }
+ }
+
+ /*
+ * A class to encapsulate the test results and stuff, with some ease
+ * of use methods to check the test results.
+ */
+ static class TestResult {
+
+ StringBuilder status;
+ int exitValue;
+ List testOutput;
+ String description;
+
+ public TestResult(String str, int rv, List oList) {
+ status = new StringBuilder(str);
+ exitValue = rv;
+ testOutput = oList;
+ }
+
+ void setDescription(String description) {
+ this.description = description;
+ }
+
+ void checkValue(int value) {
+ if (exitValue != value) {
+ status =
+ status.append(" Error: test expected exit value " +
+ value + "got " + exitValue);
+ testExitValue++;
+ }
+ }
+
+ void checkNegative() {
+ if (exitValue == 0) {
+ status = status.append(
+ " Error: test did not expect 0 exit value");
+
+ testExitValue++;
+ }
+ }
+
+ void checkPositive() {
+ if (exitValue != 0) {
+ status = status.append(
+ " Error: test did not return 0 exit value");
+ testExitValue++;
+ }
+ }
+
+ boolean isOK() {
+ return exitValue == 0;
+ }
+
+ boolean isZeroOutput() {
+ if (!testOutput.isEmpty()) {
+ status = status.append(" Error: No message from cmd please");
+ testExitValue++;
+ return false;
+ }
+ return true;
+ }
+
+ boolean isNotZeroOutput() {
+ if (testOutput.isEmpty()) {
+ status = status.append(" Error: Missing message");
+ testExitValue++;
+ return false;
+ }
+ return true;
+ }
+
+ public String toString() {
+ if (debug) {
+ for (String x : testOutput) {
+ status = status.append(x + "\n");
+ }
+ }
+ if (description != null) {
+ status.insert(0, description);
+ }
+ return status.append("\nexitValue = " + exitValue).toString();
+ }
+
+ boolean contains(String str) {
+ for (String x : testOutput) {
+ if (x.contains(str)) {
+ return true;
+ }
+ }
+ status = status.append(" Error: string <" + str + "> not found ");
+ testExitValue++;
+ return false;
+ }
+ }
+}
From b44236abdf1aea0dbd9fdcf04fe621c5dd7117e3 Mon Sep 17 00:00:00 2001
From: Andrew Brygin
Date: Wed, 3 Dec 2008 13:34:50 +0300
Subject: [PATCH 008/292] 6766136: corrupted gif image may cause crash in java
splashscreen library
Reviewed-by: prr, art
---
.../awt/splashscreen/splashscreen_gfx_impl.h | 2 +-
.../sun/awt/splashscreen/splashscreen_gif.c | 92 +++++++++++++++----
2 files changed, 76 insertions(+), 18 deletions(-)
diff --git a/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gfx_impl.h b/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gfx_impl.h
index 1c55702fe73..32f7d4e2e47 100644
--- a/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gfx_impl.h
+++ b/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gfx_impl.h
@@ -31,7 +31,7 @@
/* here come some very simple macros */
/* advance a pointer p by sizeof(type)*n bytes */
-#define INCPN(type,p,n) ((p) = (type*)(p)+n)
+#define INCPN(type,p,n) ((p) = (type*)(p)+(n))
/* advance a pointer by sizeof(type) */
#define INCP(type,p) INCPN(type,(p),1)
diff --git a/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gif.c b/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gif.c
index f6d9acb0c36..71bc3a3b39d 100644
--- a/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gif.c
+++ b/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gif.c
@@ -53,6 +53,10 @@ static const char szNetscape20ext[11] = "NETSCAPE2.0";
// convert libungif samples to our ones
#define MAKE_QUAD_GIF(c,a) MAKE_QUAD((c).Red, (c).Green, (c).Blue, (a))
+#define SAFE_TO_ALLOC(c, sz) \
+ (((c) > 0) && ((sz) > 0) && \
+ ((0xffffffffu / ((unsigned int)(c))) > (unsigned int)(sz)))
+
/* stdio FILE* and memory input functions for libungif */
int
SplashStreamGifInputFunc(GifFileType * gif, GifByteType * buf, int n)
@@ -62,6 +66,15 @@ SplashStreamGifInputFunc(GifFileType * gif, GifByteType * buf, int n)
return rc;
}
+/* These macro help to ensure that we only take part of frame that fits into
+ logical screen. */
+
+/* Ensure that p belongs to [pmin, pmax) interval. Returns fixed point (if fix is needed) */
+#define FIX_POINT(p, pmin, pmax) ( ((p) < (pmin)) ? (pmin) : (((p) > (pmax)) ? (pmax) : (p)))
+/* Ensures that line starting at point p does not exceed boundary pmax.
+ Returns fixed length (if fix is needed) */
+#define FIX_LENGTH(p, len, pmax) ( ((p) + (len)) > (pmax) ? ((pmax) - (p)) : (len))
+
int
SplashDecodeGif(Splash * splash, GifFileType * gif)
{
@@ -70,6 +83,7 @@ SplashDecodeGif(Splash * splash, GifFileType * gif)
byte_t *pBitmapBits, *pOldBitmapBits;
int i, j;
int imageIndex;
+ int cx, cy, cw, ch; /* clamped coordinates */
const int interlacedOffset[] = { 0, 4, 2, 1, 0 }; /* The way Interlaced image should. */
const int interlacedJumps[] = { 8, 8, 4, 2, 1 }; /* be read - offsets and jumps... */
@@ -79,14 +93,31 @@ SplashDecodeGif(Splash * splash, GifFileType * gif)
SplashCleanup(splash);
+ if (!SAFE_TO_ALLOC(gif->SWidth, splash->imageFormat.depthBytes)) {
+ return 0;
+ }
stride = gif->SWidth * splash->imageFormat.depthBytes;
if (splash->byteAlignment > 1)
stride =
(stride + splash->byteAlignment - 1) & ~(splash->byteAlignment - 1);
+ if (!SAFE_TO_ALLOC(gif->SHeight, stride)) {
+ return 0;
+ }
+
+ if (!SAFE_TO_ALLOC(gif->ImageCount, sizeof(SplashImage*))) {
+ return 0;
+ }
bufferSize = stride * gif->SHeight;
pBitmapBits = (byte_t *) malloc(bufferSize);
+ if (!pBitmapBits) {
+ return 0;
+ }
pOldBitmapBits = (byte_t *) malloc(bufferSize);
+ if (!pOldBitmapBits) {
+ free(pBitmapBits);
+ return 0;
+ }
memset(pBitmapBits, 0, bufferSize);
splash->width = gif->SWidth;
@@ -94,6 +125,11 @@ SplashDecodeGif(Splash * splash, GifFileType * gif)
splash->frameCount = gif->ImageCount;
splash->frames = (SplashImage *)
malloc(sizeof(SplashImage) * gif->ImageCount);
+ if (!splash->frames) {
+ free(pBitmapBits);
+ free(pOldBitmapBits);
+ return 0;
+ }
memset(splash->frames, 0, sizeof(SplashImage) * gif->ImageCount);
splash->loopCount = 1;
@@ -109,6 +145,11 @@ SplashDecodeGif(Splash * splash, GifFileType * gif)
int colorCount = 0;
rgbquad_t colorMapBuf[SPLASH_COLOR_MAP_SIZE];
+ cx = FIX_POINT(desc->Left, 0, gif->SWidth);
+ cy = FIX_POINT(desc->Top, 0, gif->SHeight);
+ cw = FIX_LENGTH(desc->Left, desc->Width, gif->SWidth);
+ ch = FIX_LENGTH(desc->Top, desc->Height, gif->SHeight);
+
if (colorMap) {
if (colorMap->ColorCount <= SPLASH_COLOR_MAP_SIZE) {
colorCount = colorMap->ColorCount;
@@ -195,13 +236,22 @@ SplashDecodeGif(Splash * splash, GifFileType * gif)
for (; pass < npass; ++pass) {
int jump = interlacedJumps[pass];
int ofs = interlacedOffset[pass];
- int numLines = (desc->Height + jump - 1 - ofs) / jump;
+ /* Number of source lines for current pass */
+ int numPassLines = (desc->Height + jump - ofs - 1) / jump;
+ /* Number of lines that fits to dest buffer */
+ int numLines = (ch + jump - ofs - 1) / jump;
initRect(&srcRect, 0, 0, desc->Width, numLines, 1,
desc->Width, pSrc, &srcFormat);
- initRect(&dstRect, desc->Left, desc->Top + ofs, desc->Width,
- numLines, jump, stride, pBitmapBits, &splash->imageFormat);
- pSrc += convertRect(&srcRect, &dstRect, CVT_ALPHATEST);
+
+ if (numLines > 0) {
+ initRect(&dstRect, cx, cy + ofs, cw,
+ numLines , jump, stride, pBitmapBits, &splash->imageFormat);
+
+ pSrc += convertRect(&srcRect, &dstRect, CVT_ALPHATEST);
+ }
+ // skip extra source data
+ pSrc += (numPassLines - numLines) * srcRect.stride;
}
}
@@ -209,6 +259,12 @@ SplashDecodeGif(Splash * splash, GifFileType * gif)
splash->frames[imageIndex].bitmapBits =
(rgbquad_t *) malloc(bufferSize);
+ if (!splash->frames[imageIndex].bitmapBits) {
+ free(pBitmapBits);
+ free(pOldBitmapBits);
+ /* Assuming that callee will take care of splash frames we have already allocated */
+ return 0;
+ }
memcpy(splash->frames[imageIndex].bitmapBits, pBitmapBits, bufferSize);
SplashInitFrameShape(splash, imageIndex);
@@ -224,27 +280,29 @@ SplashDecodeGif(Splash * splash, GifFileType * gif)
{
ImageRect dstRect;
rgbquad_t fillColor = 0; // 0 is transparent
- if (transparentColor < 0) {
+
+ if (transparentColor > 0) {
fillColor= MAKE_QUAD_GIF(
colorMap->Colors[gif->SBackGroundColor], 0xff);
}
- initRect(&dstRect, desc->Left, desc->Top,
- desc->Width, desc->Height, 1, stride,
- pBitmapBits, &splash->imageFormat);
+ initRect(&dstRect,
+ cx, cy, cw, ch,
+ 1, stride,
+ pBitmapBits, &splash->imageFormat);
fillRect(fillColor, &dstRect);
}
break;
case GIF_DISPOSE_RESTORE:
{
-
- int lineSize = desc->Width * splash->imageFormat.depthBytes;
-
- for (j = 0; j < desc->Height; j++) {
- int lineIndex = stride * (j + desc->Top) +
- desc->Left * splash->imageFormat.depthBytes;
-
- memcpy(pBitmapBits + lineIndex, pOldBitmapBits + lineIndex,
- lineSize);
+ int lineSize = cw * splash->imageFormat.depthBytes;
+ if (lineSize > 0) {
+ int lineOffset = cx * splash->imageFormat.depthBytes;
+ int lineIndex = cy * stride + lineOffset;
+ for (j=0; j
Date: Fri, 12 Dec 2008 17:38:14 +0300
Subject: [PATCH 009/292] 5106550: PNG writer merge standard metadata fails for
TextEntry sans #IMPLIED attributes
Reviewed-by: igor, prr
---
.../sun/imageio/plugins/png/PNGMetadata.java | 93 +++++++++++++------
.../plugins/png/MergeStdCommentTest.java | 64 +++++++++++++
2 files changed, 131 insertions(+), 26 deletions(-)
create mode 100644 jdk/test/javax/imageio/plugins/png/MergeStdCommentTest.java
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java
index 5475fc79651..23281fe5330 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java
@@ -1040,7 +1040,7 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
node.setAttribute("language",
iTXt_languageTag.get(i));
if (iTXt_compressionFlag.get(i)) {
- node.setAttribute("compression", "deflate");
+ node.setAttribute("compression", "zip");
} else {
node.setAttribute("compression", "none");
}
@@ -1052,7 +1052,7 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
node = new IIOMetadataNode("TextEntry");
node.setAttribute("keyword", (String)zTXt_keyword.get(i));
node.setAttribute("value", (String)zTXt_text.get(i));
- node.setAttribute("compression", "deflate");
+ node.setAttribute("compression", "zip");
text_node.appendChild(node);
}
@@ -1421,26 +1421,30 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
}
String keyword = getAttribute(iTXt_node, "keyword");
- iTXt_keyword.add(keyword);
+ if (isValidKeyword(keyword)) {
+ iTXt_keyword.add(keyword);
- boolean compressionFlag =
- getBooleanAttribute(iTXt_node, "compressionFlag");
- iTXt_compressionFlag.add(Boolean.valueOf(compressionFlag));
+ boolean compressionFlag =
+ getBooleanAttribute(iTXt_node, "compressionFlag");
+ iTXt_compressionFlag.add(Boolean.valueOf(compressionFlag));
- String compressionMethod =
- getAttribute(iTXt_node, "compressionMethod");
- iTXt_compressionMethod.add(Integer.valueOf(compressionMethod));
+ String compressionMethod =
+ getAttribute(iTXt_node, "compressionMethod");
+ iTXt_compressionMethod.add(Integer.valueOf(compressionMethod));
- String languageTag =
- getAttribute(iTXt_node, "languageTag");
- iTXt_languageTag.add(languageTag);
+ String languageTag =
+ getAttribute(iTXt_node, "languageTag");
+ iTXt_languageTag.add(languageTag);
- String translatedKeyword =
- getAttribute(iTXt_node, "translatedKeyword");
- iTXt_translatedKeyword.add(translatedKeyword);
+ String translatedKeyword =
+ getAttribute(iTXt_node, "translatedKeyword");
+ iTXt_translatedKeyword.add(translatedKeyword);
- String text = getAttribute(iTXt_node, "text");
- iTXt_text.add(text);
+ String text = getAttribute(iTXt_node, "text");
+ iTXt_text.add(text);
+
+ }
+ // silently skip invalid text entry
iTXt_node = iTXt_node.getNextSibling();
}
@@ -1692,11 +1696,45 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
}
}
- private boolean isISOLatin(String s) {
+ /*
+ * Accrding to PNG spec, keywords are restricted to 1 to 79 bytes
+ * in length. Keywords shall contain only printable Latin-1 characters
+ * and spaces; To reduce the chances for human misreading of a keyword,
+ * leading spaces, trailing spaces, and consecutive spaces are not
+ * permitted in keywords.
+ *
+ * See: http://www.w3.org/TR/PNG/#11keywords
+ */
+ private boolean isValidKeyword(String s) {
+ int len = s.length();
+ if (len < 1 || len >= 80) {
+ return false;
+ }
+ if (s.startsWith(" ") || s.endsWith(" ") || s.contains(" ")) {
+ return false;
+ }
+ return isISOLatin(s, false);
+ }
+
+ /*
+ * According to PNG spec, keyword shall contain only printable
+ * Latin-1 [ISO-8859-1] characters and spaces; that is, only
+ * character codes 32-126 and 161-255 decimal are allowed.
+ * For Latin-1 value fields the 0x10 (linefeed) control
+ * character is aloowed too.
+ *
+ * See: http://www.w3.org/TR/PNG/#11keywords
+ */
+ private boolean isISOLatin(String s, boolean isLineFeedAllowed) {
int len = s.length();
for (int i = 0; i < len; i++) {
- if (s.charAt(i) > 255) {
- return false;
+ char c = s.charAt(i);
+ if (c < 32 || c > 255 || (c > 126 && c < 161)) {
+ // not printable. Check whether this is an allowed
+ // control char
+ if (!isLineFeedAllowed || c != 0x10) {
+ return false;
+ }
}
}
return true;
@@ -1929,19 +1967,22 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
while (child != null) {
String childName = child.getNodeName();
if (childName.equals("TextEntry")) {
- String keyword = getAttribute(child, "keyword");
+ String keyword =
+ getAttribute(child, "keyword", "", false);
String value = getAttribute(child, "value");
- String encoding = getAttribute(child, "encoding");
- String language = getAttribute(child, "language");
+ String language =
+ getAttribute(child, "language", "", false);
String compression =
- getAttribute(child, "compression");
+ getAttribute(child, "compression", "none", false);
- if (isISOLatin(value)) {
+ if (!isValidKeyword(keyword)) {
+ // Just ignore this node, PNG requires keywords
+ } else if (isISOLatin(value, true)) {
if (compression.equals("zip")) {
// Use a zTXt node
zTXt_keyword.add(keyword);
zTXt_text.add(value);
- zTXt_compressionMethod.add(new Integer(0));
+ zTXt_compressionMethod.add(Integer.valueOf(0));
} else {
// Use a tEXt node
tEXt_keyword.add(keyword);
diff --git a/jdk/test/javax/imageio/plugins/png/MergeStdCommentTest.java b/jdk/test/javax/imageio/plugins/png/MergeStdCommentTest.java
new file mode 100644
index 00000000000..21a7c5f10d0
--- /dev/null
+++ b/jdk/test/javax/imageio/plugins/png/MergeStdCommentTest.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug 5106550
+ * @summary Merge a comment using the standard metdata format
+ * and only a minimal set of attributes
+ */
+
+import java.awt.image.BufferedImage;
+import javax.imageio.ImageIO;
+import javax.imageio.ImageTypeSpecifier;
+import javax.imageio.ImageWriter;
+import javax.imageio.metadata.IIOMetadata;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.bootstrap.DOMImplementationRegistry;
+
+public class MergeStdCommentTest {
+
+ public static void main(String[] args) throws Exception {
+ String format = "javax_imageio_1.0";
+ BufferedImage img =
+ new BufferedImage(16, 16, BufferedImage.TYPE_INT_RGB);
+ ImageWriter iw = ImageIO.getImageWritersByMIMEType("image/png").next();
+ IIOMetadata meta =
+ iw.getDefaultImageMetadata(new ImageTypeSpecifier(img), null);
+ DOMImplementationRegistry registry;
+ registry = DOMImplementationRegistry.newInstance();
+ DOMImplementation impl = registry.getDOMImplementation("XML 3.0");
+ Document doc = impl.createDocument(null, format, null);
+ Element root, text, entry;
+ root = doc.getDocumentElement();
+ root.appendChild(text = doc.createElement("Text"));
+ text.appendChild(entry = doc.createElement("TextEntry"));
+ // keyword isn't #REQUIRED by the standard metadata format.
+ // However, it is required by the PNG format, so we include it here.
+ entry.setAttribute("keyword", "Comment");
+ entry.setAttribute("value", "Some demo comment");
+ meta.mergeTree(format, root);
+ }
+}
From 8848b3ab632432de85c70173dc26a4bdc2790479 Mon Sep 17 00:00:00 2001
From: Igor Nekrestyanov
Date: Wed, 17 Dec 2008 22:00:37 +0300
Subject: [PATCH 010/292] 6761791: Crash in the FontManager code due to use of
JNIEnv saved by another thread
Reviewed-by: bae, prr
---
.../share/native/sun/font/freetypeScaler.c | 27 ++++++++++++++++---
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/jdk/src/share/native/sun/font/freetypeScaler.c b/jdk/src/share/native/sun/font/freetypeScaler.c
index 59c1a180c29..4028d4d97c4 100644
--- a/jdk/src/share/native/sun/font/freetypeScaler.c
+++ b/jdk/src/share/native/sun/font/freetypeScaler.c
@@ -394,12 +394,14 @@ static int setupFTContext(JNIEnv *env,
scalerInfo->env = env;
scalerInfo->font2D = font2D;
- FT_Set_Transform(scalerInfo->face, &context->transform, NULL);
+ if (context != NULL) {
+ FT_Set_Transform(scalerInfo->face, &context->transform, NULL);
- errCode = FT_Set_Char_Size(scalerInfo->face, 0, context->ptsz, 72, 72);
+ errCode = FT_Set_Char_Size(scalerInfo->face, 0, context->ptsz, 72, 72);
- if (errCode == 0) {
- errCode = FT_Activate_Size(scalerInfo->face->size);
+ if (errCode == 0) {
+ errCode = FT_Activate_Size(scalerInfo->face->size);
+ }
}
return errCode;
@@ -885,6 +887,14 @@ Java_sun_font_FreetypeFontScaler_disposeNativeScaler(
JNIEnv *env, jobject scaler, jlong pScaler) {
FTScalerInfo* scalerInfo = (FTScalerInfo *) jlong_to_ptr(pScaler);
+ /* Freetype functions *may* cause callback to java
+ that can use cached values. Make sure our cache is up to date.
+ NB: scaler context is not important at this point, can use NULL. */
+ int errCode = setupFTContext(env, scaler, scalerInfo, NULL);
+ if (errCode) {
+ return;
+ }
+
freeNativeResources(env, scalerInfo);
}
@@ -932,12 +942,21 @@ Java_sun_font_FreetypeFontScaler_getGlyphCodeNative(
JNIEnv *env, jobject scaler, jlong pScaler, jchar charCode) {
FTScalerInfo* scalerInfo = (FTScalerInfo *) jlong_to_ptr(pScaler);
+ int errCode;
if (scaler == NULL || scalerInfo->face == NULL) { /* bad/null scaler */
invalidateJavaScaler(env, scaler, scalerInfo);
return 0;
}
+ /* Freetype functions *may* cause callback to java
+ that can use cached values. Make sure our cache is up to date.
+ Scaler context is not important here, can use NULL. */
+ errCode = setupFTContext(env, scaler, scalerInfo, NULL);
+ if (errCode) {
+ return 0;
+ }
+
return FT_Get_Char_Index(scalerInfo->face, charCode);
}
From 5b1de891b340083d3bc451e8c56c318634193994 Mon Sep 17 00:00:00 2001
From: Phil Race
Date: Thu, 18 Dec 2008 11:25:09 -0800
Subject: [PATCH 011/292] 6708137: Remove obsolete fontconfig.98.properties
from JDK 7
Reviewed-by: jgodinez, naoto
---
jdk/make/sun/awt/Makefile | 3 +-
.../sun/awt/windows/WFontConfiguration.java | 16 +-
.../sun/awt/windows/fontconfig.98.properties | 241 ------------------
.../sun/awt/windows/fontconfig.Me.properties | 241 ------------------
4 files changed, 5 insertions(+), 496 deletions(-)
delete mode 100644 jdk/src/windows/classes/sun/awt/windows/fontconfig.98.properties
delete mode 100644 jdk/src/windows/classes/sun/awt/windows/fontconfig.Me.properties
diff --git a/jdk/make/sun/awt/Makefile b/jdk/make/sun/awt/Makefile
index ed35dcd2bdf..3f9fa64eb11 100644
--- a/jdk/make/sun/awt/Makefile
+++ b/jdk/make/sun/awt/Makefile
@@ -333,8 +333,7 @@ ifeq ($(PLATFORM), windows)
FONTCONFIGS_SRC = $(PLATFORM_SRC)/classes/sun/awt/windows
_FONTCONFIGS = \
- fontconfig.properties \
- fontconfig.98.properties
+ fontconfig.properties
FONTCONFIGS_SRC_PREFIX =
diff --git a/jdk/src/windows/classes/sun/awt/windows/WFontConfiguration.java b/jdk/src/windows/classes/sun/awt/windows/WFontConfiguration.java
index 4f2f8324ae4..2c7b00124a7 100644
--- a/jdk/src/windows/classes/sun/awt/windows/WFontConfiguration.java
+++ b/jdk/src/windows/classes/sun/awt/windows/WFontConfiguration.java
@@ -61,18 +61,10 @@ public class WFontConfiguration extends FontConfiguration {
* been opened and its fonts loaded.
* Also note this usage is only enabled if a private flag is set.
*/
- if ("98".equals(osName) || "Me".equals(osName)) {
- localeMap.put("dialoginput.plain.japanese", "\uff2d\uff33 \u660e\u671d");
- localeMap.put("dialoginput.bold.japanese", "\uff2d\uff33 \u660e\u671d");
- localeMap.put("dialoginput.italic.japanese", "\uff2d\uff33 \u660e\u671d");
- localeMap.put("dialoginput.bolditalic.japanese", "\uff2d\uff33 \u660e\u671d");
- } else {
-
- localeMap.put("dialoginput.plain.japanese", "MS Mincho");
- localeMap.put("dialoginput.bold.japanese", "MS Mincho");
- localeMap.put("dialoginput.italic.japanese", "MS Mincho");
- localeMap.put("dialoginput.bolditalic.japanese", "MS Mincho");
- }
+ localeMap.put("dialoginput.plain.japanese", "MS Mincho");
+ localeMap.put("dialoginput.bold.japanese", "MS Mincho");
+ localeMap.put("dialoginput.italic.japanese", "MS Mincho");
+ localeMap.put("dialoginput.bolditalic.japanese", "MS Mincho");
}
reorderMap = new HashMap();
reorderMap.put("UTF-8.hi", "devanagari");
diff --git a/jdk/src/windows/classes/sun/awt/windows/fontconfig.98.properties b/jdk/src/windows/classes/sun/awt/windows/fontconfig.98.properties
deleted file mode 100644
index 8d69d410e25..00000000000
--- a/jdk/src/windows/classes/sun/awt/windows/fontconfig.98.properties
+++ /dev/null
@@ -1,241 +0,0 @@
-#
-#
-# Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation. Sun designates this
-# particular file as subject to the "Classpath" exception as provided
-# by Sun in the LICENSE file that accompanied this code.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
-# CA 95054 USA or visit www.sun.com if you need additional information or
-# have any questions.
-#
-
-# Version
-
-version=1
-
-# Component Font Mappings
-
-allfonts.chinese-ms936=SimSun
-allfonts.dingbats=Wingdings
-allfonts.lucida=Lucida Sans Regular
-allfonts.symbol=Symbol
-allfonts.thai=Lucida Sans Regular
-
-serif.plain.alphabetic=Times New Roman
-serif.plain.chinese-ms950=MingLiU
-serif.plain.hebrew=David
-serif.plain.japanese=\uff2d\uff33 \u660e\u671d
-serif.plain.korean=Batang
-
-serif.bold.alphabetic=Times New Roman Bold
-serif.bold.chinese-ms950=PMingLiU
-serif.bold.hebrew=David Bold
-serif.bold.japanese=\uff2d\uff33 \u660e\u671d
-serif.bold.korean=Batang
-
-serif.italic.alphabetic=Times New Roman Italic
-serif.italic.chinese-ms950=PMingLiU
-serif.italic.hebrew=David
-serif.italic.japanese=\uff2d\uff33 \u660e\u671d
-serif.italic.korean=Batang
-
-serif.bolditalic.alphabetic=Times New Roman Bold Italic
-serif.bolditalic.chinese-ms950=PMingLiU
-serif.bolditalic.hebrew=David Bold
-serif.bolditalic.japanese=\uff2d\uff33 \u660e\u671d
-serif.bolditalic.korean=Batang
-
-sansserif.plain.alphabetic=Arial
-sansserif.plain.chinese-ms950=MingLiU
-sansserif.plain.hebrew=David
-sansserif.plain.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-sansserif.plain.korean=Gulim
-
-sansserif.bold.alphabetic=Arial Bold
-sansserif.bold.chinese-ms950=PMingLiU
-sansserif.bold.hebrew=David Bold
-sansserif.bold.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-sansserif.bold.korean=Gulim
-
-sansserif.italic.alphabetic=Arial Italic
-sansserif.italic.chinese-ms950=PMingLiU
-sansserif.italic.hebrew=David
-sansserif.italic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-sansserif.italic.korean=Gulim
-
-sansserif.bolditalic.alphabetic=Arial Bold Italic
-sansserif.bolditalic.chinese-ms950=PMingLiU
-sansserif.bolditalic.hebrew=David Bold
-sansserif.bolditalic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-sansserif.bolditalic.korean=Gulim
-
-monospaced.plain.alphabetic=Courier New
-monospaced.plain.chinese-ms950=MingLiU
-monospaced.plain.hebrew=David
-monospaced.plain.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-monospaced.plain.korean=GulimChe
-
-monospaced.bold.alphabetic=Courier New Bold
-monospaced.bold.chinese-ms950=PMingLiU
-monospaced.bold.hebrew=David Bold
-monospaced.bold.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-monospaced.bold.korean=GulimChe
-
-monospaced.italic.alphabetic=Courier New Italic
-monospaced.italic.chinese-ms950=PMingLiU
-monospaced.italic.hebrew=David
-monospaced.italic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-monospaced.italic.korean=GulimChe
-
-monospaced.bolditalic.alphabetic=Courier New Bold Italic
-monospaced.bolditalic.chinese-ms950=PMingLiU
-monospaced.bolditalic.hebrew=David Bold
-monospaced.bolditalic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-monospaced.bolditalic.korean=GulimChe
-
-dialog.plain.alphabetic=Arial
-dialog.plain.chinese-ms950=MingLiU
-dialog.plain.hebrew=David
-dialog.plain.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialog.plain.korean=Gulim
-
-dialog.bold.alphabetic=Arial Bold
-dialog.bold.chinese-ms950=PMingLiU
-dialog.bold.hebrew=David Bold
-dialog.bold.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialog.bold.korean=Gulim
-
-dialog.italic.alphabetic=Arial Italic
-dialog.italic.chinese-ms950=PMingLiU
-dialog.italic.hebrew=David
-dialog.italic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialog.italic.korean=Gulim
-
-dialog.bolditalic.alphabetic=Arial Bold Italic
-dialog.bolditalic.chinese-ms950=PMingLiU
-dialog.bolditalic.hebrew=David Bold
-dialog.bolditalic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialog.bolditalic.korean=Gulim
-
-dialoginput.plain.alphabetic=Courier New
-dialoginput.plain.chinese-ms950=MingLiU
-dialoginput.plain.hebrew=David
-dialoginput.plain.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialoginput.plain.korean=Gulim
-
-dialoginput.bold.alphabetic=Courier New Bold
-dialoginput.bold.chinese-ms950=PMingLiU
-dialoginput.bold.hebrew=David Bold
-dialoginput.bold.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialoginput.bold.korean=Gulim
-
-dialoginput.italic.alphabetic=Courier New Italic
-dialoginput.italic.chinese-ms950=PMingLiU
-dialoginput.italic.hebrew=David
-dialoginput.italic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialoginput.italic.korean=Gulim
-
-dialoginput.bolditalic.alphabetic=Courier New Bold Italic
-dialoginput.bolditalic.chinese-ms950=PMingLiU
-dialoginput.bolditalic.hebrew=David Bold
-dialoginput.bolditalic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialoginput.bolditalic.korean=Gulim
-
-# Search Sequences
-
-sequence.allfonts=alphabetic/default,dingbats,symbol
-
-sequence.serif.GBK=alphabetic/1252,chinese-ms936,dingbats,symbol
-sequence.sansserif.GBK=alphabetic/1252,chinese-ms936,dingbats,symbol
-sequence.monospaced.GBK=chinese-ms936,alphabetic/1252,dingbats,symbol
-sequence.dialog.GBK=alphabetic/1252,chinese-ms936,dingbats,symbol
-sequence.dialoginput.GBK=alphabetic/1252,chinese-ms936,dingbats,symbol
-
-sequence.serif.x-windows-950=alphabetic/1252,chinese-ms950,dingbats,symbol
-sequence.sansserif.x-windows-950=alphabetic/1252,chinese-ms950,dingbats,symbol
-sequence.monospaced.x-windows-950=chinese-ms950,alphabetic/1252,dingbats,symbol
-sequence.dialog.x-windows-950=alphabetic/1252,chinese-ms950,dingbats,symbol
-sequence.dialoginput.x-windows-950=alphabetic/1252,chinese-ms950,dingbats,symbol
-
-sequence.allfonts.windows-1255=hebrew,alphabetic/1252,dingbats,symbol
-
-sequence.serif.windows-31j=alphabetic/1252,japanese,dingbats,symbol
-sequence.sansserif.windows-31j=alphabetic/1252,japanese,dingbats,symbol
-sequence.monospaced.windows-31j=japanese,alphabetic/1252,dingbats,symbol
-sequence.dialog.windows-31j=alphabetic/1252,japanese,dingbats,symbol
-sequence.dialoginput.windows-31j=alphabetic/1252,japanese,dingbats,symbol
-
-sequence.serif.x-windows-949=alphabetic/1252,korean,dingbats,symbol
-sequence.sansserif.x-windows-949=alphabetic/1252,korean,dingbats,symbol
-sequence.monospaced.x-windows-949=korean,alphabetic/1252,dingbats,symbol
-sequence.dialog.x-windows-949=alphabetic/1252,korean,dingbats,symbol
-sequence.dialoginput.x-windows-949=alphabetic/1252,korean,dingbats,symbol
-
-sequence.allfonts.x-windows-874=alphabetic/1252,thai,dingbats,symbol
-
-sequence.fallback=lucida
-
-# Exclusion Ranges
-
-exclusion.alphabetic=0700-1e9f,1f00-20ab,20ad-f8ff
-exclusion.hebrew=0041-005a,0060-007a,007f-00ff,20ac-20ac
-
-# Monospaced to Proportional width variant mapping
-# (Experimental private syntax)
-proportional.\uff2d\uff33_\u30b4\u30b7\u30c3\u30af=\uff2d\uff33 \uff30\u30b4\u30b7\u30c3\u30af
-proportional.\uff2d\uff33_\u660e\u671d=\uff2d\uff33 \uff30\u660e\u671d
-proportional.MingLiU=PMingLiU
-
-# Font File Names
-
-filename.Arial=ARIAL.TTF
-filename.Arial_Bold=ARIALBD.TTF
-filename.Arial_Italic=ARIALI.TTF
-filename.Arial_Bold_Italic=ARIALBI.TTF
-
-filename.Courier_New=COUR.TTF
-filename.Courier_New_Bold=COURBD.TTF
-filename.Courier_New_Italic=COURI.TTF
-filename.Courier_New_Bold_Italic=COURBI.TTF
-
-filename.Times_New_Roman=TIMES.TTF
-filename.Times_New_Roman_Bold=TIMESBD.TTF
-filename.Times_New_Roman_Italic=TIMESI.TTF
-filename.Times_New_Roman_Bold_Italic=TIMESBI.TTF
-
-filename.SimSun=SIMSUN.TTF
-
-filename.MingLiU=MINGLIU.TTC
-filename.PMingLiU=MINGLIU.TTC
-
-filename.David=DAVID.TTF
-filename.David_Bold=DAVIDBD.TTF
-
-filename.\uff2d\uff33_\u660e\u671d=MSMINCHO.TTC
-filename.\uff2d\uff33_\uff30\u660e\u671d=MSMINCHO.TTC
-filename.\uff2d\uff33_\u30b4\u30b7\u30c3\u30af=MSGOTHIC.TTC
-filename.\uff2d\uff33_\uff30\u30b4\u30b7\u30c3\u30af=MSGOTHIC.TTC
-
-filename.Gulim=gulim.TTC
-filename.Batang=batang.TTC
-filename.GulimChe=gulim.TTC
-
-filename.Lucida_Sans_Regular=LucidaSansRegular.ttf
-filename.Symbol=SYMBOL.TTF
-filename.Wingdings=WINGDING.TTF
-
diff --git a/jdk/src/windows/classes/sun/awt/windows/fontconfig.Me.properties b/jdk/src/windows/classes/sun/awt/windows/fontconfig.Me.properties
deleted file mode 100644
index 8d69d410e25..00000000000
--- a/jdk/src/windows/classes/sun/awt/windows/fontconfig.Me.properties
+++ /dev/null
@@ -1,241 +0,0 @@
-#
-#
-# Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation. Sun designates this
-# particular file as subject to the "Classpath" exception as provided
-# by Sun in the LICENSE file that accompanied this code.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
-# CA 95054 USA or visit www.sun.com if you need additional information or
-# have any questions.
-#
-
-# Version
-
-version=1
-
-# Component Font Mappings
-
-allfonts.chinese-ms936=SimSun
-allfonts.dingbats=Wingdings
-allfonts.lucida=Lucida Sans Regular
-allfonts.symbol=Symbol
-allfonts.thai=Lucida Sans Regular
-
-serif.plain.alphabetic=Times New Roman
-serif.plain.chinese-ms950=MingLiU
-serif.plain.hebrew=David
-serif.plain.japanese=\uff2d\uff33 \u660e\u671d
-serif.plain.korean=Batang
-
-serif.bold.alphabetic=Times New Roman Bold
-serif.bold.chinese-ms950=PMingLiU
-serif.bold.hebrew=David Bold
-serif.bold.japanese=\uff2d\uff33 \u660e\u671d
-serif.bold.korean=Batang
-
-serif.italic.alphabetic=Times New Roman Italic
-serif.italic.chinese-ms950=PMingLiU
-serif.italic.hebrew=David
-serif.italic.japanese=\uff2d\uff33 \u660e\u671d
-serif.italic.korean=Batang
-
-serif.bolditalic.alphabetic=Times New Roman Bold Italic
-serif.bolditalic.chinese-ms950=PMingLiU
-serif.bolditalic.hebrew=David Bold
-serif.bolditalic.japanese=\uff2d\uff33 \u660e\u671d
-serif.bolditalic.korean=Batang
-
-sansserif.plain.alphabetic=Arial
-sansserif.plain.chinese-ms950=MingLiU
-sansserif.plain.hebrew=David
-sansserif.plain.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-sansserif.plain.korean=Gulim
-
-sansserif.bold.alphabetic=Arial Bold
-sansserif.bold.chinese-ms950=PMingLiU
-sansserif.bold.hebrew=David Bold
-sansserif.bold.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-sansserif.bold.korean=Gulim
-
-sansserif.italic.alphabetic=Arial Italic
-sansserif.italic.chinese-ms950=PMingLiU
-sansserif.italic.hebrew=David
-sansserif.italic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-sansserif.italic.korean=Gulim
-
-sansserif.bolditalic.alphabetic=Arial Bold Italic
-sansserif.bolditalic.chinese-ms950=PMingLiU
-sansserif.bolditalic.hebrew=David Bold
-sansserif.bolditalic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-sansserif.bolditalic.korean=Gulim
-
-monospaced.plain.alphabetic=Courier New
-monospaced.plain.chinese-ms950=MingLiU
-monospaced.plain.hebrew=David
-monospaced.plain.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-monospaced.plain.korean=GulimChe
-
-monospaced.bold.alphabetic=Courier New Bold
-monospaced.bold.chinese-ms950=PMingLiU
-monospaced.bold.hebrew=David Bold
-monospaced.bold.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-monospaced.bold.korean=GulimChe
-
-monospaced.italic.alphabetic=Courier New Italic
-monospaced.italic.chinese-ms950=PMingLiU
-monospaced.italic.hebrew=David
-monospaced.italic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-monospaced.italic.korean=GulimChe
-
-monospaced.bolditalic.alphabetic=Courier New Bold Italic
-monospaced.bolditalic.chinese-ms950=PMingLiU
-monospaced.bolditalic.hebrew=David Bold
-monospaced.bolditalic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-monospaced.bolditalic.korean=GulimChe
-
-dialog.plain.alphabetic=Arial
-dialog.plain.chinese-ms950=MingLiU
-dialog.plain.hebrew=David
-dialog.plain.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialog.plain.korean=Gulim
-
-dialog.bold.alphabetic=Arial Bold
-dialog.bold.chinese-ms950=PMingLiU
-dialog.bold.hebrew=David Bold
-dialog.bold.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialog.bold.korean=Gulim
-
-dialog.italic.alphabetic=Arial Italic
-dialog.italic.chinese-ms950=PMingLiU
-dialog.italic.hebrew=David
-dialog.italic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialog.italic.korean=Gulim
-
-dialog.bolditalic.alphabetic=Arial Bold Italic
-dialog.bolditalic.chinese-ms950=PMingLiU
-dialog.bolditalic.hebrew=David Bold
-dialog.bolditalic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialog.bolditalic.korean=Gulim
-
-dialoginput.plain.alphabetic=Courier New
-dialoginput.plain.chinese-ms950=MingLiU
-dialoginput.plain.hebrew=David
-dialoginput.plain.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialoginput.plain.korean=Gulim
-
-dialoginput.bold.alphabetic=Courier New Bold
-dialoginput.bold.chinese-ms950=PMingLiU
-dialoginput.bold.hebrew=David Bold
-dialoginput.bold.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialoginput.bold.korean=Gulim
-
-dialoginput.italic.alphabetic=Courier New Italic
-dialoginput.italic.chinese-ms950=PMingLiU
-dialoginput.italic.hebrew=David
-dialoginput.italic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialoginput.italic.korean=Gulim
-
-dialoginput.bolditalic.alphabetic=Courier New Bold Italic
-dialoginput.bolditalic.chinese-ms950=PMingLiU
-dialoginput.bolditalic.hebrew=David Bold
-dialoginput.bolditalic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialoginput.bolditalic.korean=Gulim
-
-# Search Sequences
-
-sequence.allfonts=alphabetic/default,dingbats,symbol
-
-sequence.serif.GBK=alphabetic/1252,chinese-ms936,dingbats,symbol
-sequence.sansserif.GBK=alphabetic/1252,chinese-ms936,dingbats,symbol
-sequence.monospaced.GBK=chinese-ms936,alphabetic/1252,dingbats,symbol
-sequence.dialog.GBK=alphabetic/1252,chinese-ms936,dingbats,symbol
-sequence.dialoginput.GBK=alphabetic/1252,chinese-ms936,dingbats,symbol
-
-sequence.serif.x-windows-950=alphabetic/1252,chinese-ms950,dingbats,symbol
-sequence.sansserif.x-windows-950=alphabetic/1252,chinese-ms950,dingbats,symbol
-sequence.monospaced.x-windows-950=chinese-ms950,alphabetic/1252,dingbats,symbol
-sequence.dialog.x-windows-950=alphabetic/1252,chinese-ms950,dingbats,symbol
-sequence.dialoginput.x-windows-950=alphabetic/1252,chinese-ms950,dingbats,symbol
-
-sequence.allfonts.windows-1255=hebrew,alphabetic/1252,dingbats,symbol
-
-sequence.serif.windows-31j=alphabetic/1252,japanese,dingbats,symbol
-sequence.sansserif.windows-31j=alphabetic/1252,japanese,dingbats,symbol
-sequence.monospaced.windows-31j=japanese,alphabetic/1252,dingbats,symbol
-sequence.dialog.windows-31j=alphabetic/1252,japanese,dingbats,symbol
-sequence.dialoginput.windows-31j=alphabetic/1252,japanese,dingbats,symbol
-
-sequence.serif.x-windows-949=alphabetic/1252,korean,dingbats,symbol
-sequence.sansserif.x-windows-949=alphabetic/1252,korean,dingbats,symbol
-sequence.monospaced.x-windows-949=korean,alphabetic/1252,dingbats,symbol
-sequence.dialog.x-windows-949=alphabetic/1252,korean,dingbats,symbol
-sequence.dialoginput.x-windows-949=alphabetic/1252,korean,dingbats,symbol
-
-sequence.allfonts.x-windows-874=alphabetic/1252,thai,dingbats,symbol
-
-sequence.fallback=lucida
-
-# Exclusion Ranges
-
-exclusion.alphabetic=0700-1e9f,1f00-20ab,20ad-f8ff
-exclusion.hebrew=0041-005a,0060-007a,007f-00ff,20ac-20ac
-
-# Monospaced to Proportional width variant mapping
-# (Experimental private syntax)
-proportional.\uff2d\uff33_\u30b4\u30b7\u30c3\u30af=\uff2d\uff33 \uff30\u30b4\u30b7\u30c3\u30af
-proportional.\uff2d\uff33_\u660e\u671d=\uff2d\uff33 \uff30\u660e\u671d
-proportional.MingLiU=PMingLiU
-
-# Font File Names
-
-filename.Arial=ARIAL.TTF
-filename.Arial_Bold=ARIALBD.TTF
-filename.Arial_Italic=ARIALI.TTF
-filename.Arial_Bold_Italic=ARIALBI.TTF
-
-filename.Courier_New=COUR.TTF
-filename.Courier_New_Bold=COURBD.TTF
-filename.Courier_New_Italic=COURI.TTF
-filename.Courier_New_Bold_Italic=COURBI.TTF
-
-filename.Times_New_Roman=TIMES.TTF
-filename.Times_New_Roman_Bold=TIMESBD.TTF
-filename.Times_New_Roman_Italic=TIMESI.TTF
-filename.Times_New_Roman_Bold_Italic=TIMESBI.TTF
-
-filename.SimSun=SIMSUN.TTF
-
-filename.MingLiU=MINGLIU.TTC
-filename.PMingLiU=MINGLIU.TTC
-
-filename.David=DAVID.TTF
-filename.David_Bold=DAVIDBD.TTF
-
-filename.\uff2d\uff33_\u660e\u671d=MSMINCHO.TTC
-filename.\uff2d\uff33_\uff30\u660e\u671d=MSMINCHO.TTC
-filename.\uff2d\uff33_\u30b4\u30b7\u30c3\u30af=MSGOTHIC.TTC
-filename.\uff2d\uff33_\uff30\u30b4\u30b7\u30c3\u30af=MSGOTHIC.TTC
-
-filename.Gulim=gulim.TTC
-filename.Batang=batang.TTC
-filename.GulimChe=gulim.TTC
-
-filename.Lucida_Sans_Regular=LucidaSansRegular.ttf
-filename.Symbol=SYMBOL.TTF
-filename.Wingdings=WINGDING.TTF
-
From fa5248c9db8c661b898ff4e9e03433128b2534c4 Mon Sep 17 00:00:00 2001
From: Phil Race
Date: Wed, 24 Dec 2008 09:53:52 -0800
Subject: [PATCH 012/292] 6728838: Native memory leak in StrikeCache.java
Reviewed-by: bae, igor
---
jdk/src/share/classes/sun/font/StrikeCache.java | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/jdk/src/share/classes/sun/font/StrikeCache.java b/jdk/src/share/classes/sun/font/StrikeCache.java
index 560be3af2cd..56539e7489f 100644
--- a/jdk/src/share/classes/sun/font/StrikeCache.java
+++ b/jdk/src/share/classes/sun/font/StrikeCache.java
@@ -232,6 +232,16 @@ public final class StrikeCache {
if (disposer.pScalerContext != 0L) {
freeLongMemory(new long[0], disposer.pScalerContext);
}
+ } else if (disposer.pScalerContext != 0L) {
+ /* Rarely a strike may have been created that never cached
+ * any glyphs. In this case we still want to free the scaler
+ * context.
+ */
+ if (FontManager.longAddresses) {
+ freeLongMemory(new long[0], disposer.pScalerContext);
+ } else {
+ freeIntMemory(new int[0], disposer.pScalerContext);
+ }
}
}
From 6f0de04c8704af289dcfa836939be14c9dc0a365 Mon Sep 17 00:00:00 2001
From: Phil Race
Date: Wed, 24 Dec 2008 09:57:48 -0800
Subject: [PATCH 013/292] 6752638:
java.awt.GraphicsEnvironment.preferLocaleFonts() throws NPE on Linux 6755034:
Legal notice repair:
jdk/src/solaris/classes/sun/font/FcFontConfiguration.java
Reviewed-by: bae, igor
---
.../classes/java/awt/GraphicsEnvironment.java | 6 ++
.../classes/sun/awt/FontConfiguration.java | 6 +-
.../classes/sun/font/FcFontConfiguration.java | 3 +-
.../PreferLocaleFonts.java | 62 +++++++++++++++++++
4 files changed, 75 insertions(+), 2 deletions(-)
create mode 100644 jdk/test/java/awt/GraphicsEnvironment/PreferLocaleFonts.java
diff --git a/jdk/src/share/classes/java/awt/GraphicsEnvironment.java b/jdk/src/share/classes/java/awt/GraphicsEnvironment.java
index 167db051910..cf1852e2fc0 100644
--- a/jdk/src/share/classes/java/awt/GraphicsEnvironment.java
+++ b/jdk/src/share/classes/java/awt/GraphicsEnvironment.java
@@ -356,6 +356,9 @@ public abstract class GraphicsEnvironment {
* @since 1.5
*/
public void preferLocaleFonts() {
+ if (!(this instanceof SunGraphicsEnvironment)) {
+ return;
+ }
sun.font.FontManager.preferLocaleFonts();
}
@@ -376,6 +379,9 @@ public abstract class GraphicsEnvironment {
* @since 1.5
*/
public void preferProportionalFonts() {
+ if (!(this instanceof SunGraphicsEnvironment)) {
+ return;
+ }
sun.font.FontManager.preferProportionalFonts();
}
diff --git a/jdk/src/share/classes/sun/awt/FontConfiguration.java b/jdk/src/share/classes/sun/awt/FontConfiguration.java
index 6349aa778ea..4504af24e9d 100644
--- a/jdk/src/share/classes/sun/awt/FontConfiguration.java
+++ b/jdk/src/share/classes/sun/awt/FontConfiguration.java
@@ -98,7 +98,7 @@ public abstract class FontConfiguration {
if (!inited) {
this.preferLocaleFonts = false;
this.preferPropFonts = false;
- fontConfig = this; /* static initialization */
+ setFontConfiguration();
readFontConfigFile(fontConfigFile);
initFontConfig();
inited = true;
@@ -1244,6 +1244,10 @@ public abstract class FontConfiguration {
return fontConfig;
}
+ protected void setFontConfiguration() {
+ fontConfig = this; /* static initialization */
+ }
+
//////////////////////////////////////////////////////////////////////
// FontConfig data tables and the index constants in binary file //
//////////////////////////////////////////////////////////////////////
diff --git a/jdk/src/solaris/classes/sun/font/FcFontConfiguration.java b/jdk/src/solaris/classes/sun/font/FcFontConfiguration.java
index fe2e5dbf836..95154df0a47 100644
--- a/jdk/src/solaris/classes/sun/font/FcFontConfiguration.java
+++ b/jdk/src/solaris/classes/sun/font/FcFontConfiguration.java
@@ -15,7 +15,7 @@
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
- * along with this work; if not, write to the Free Software Foundation,
+ * 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
@@ -87,6 +87,7 @@ public class FcFontConfiguration extends FontConfiguration {
return true;
}
+ setFontConfiguration();
readFcInfo();
if (fcCompFonts == null) {
fcCompFonts = FontManager.loadFontConfig();
diff --git a/jdk/test/java/awt/GraphicsEnvironment/PreferLocaleFonts.java b/jdk/test/java/awt/GraphicsEnvironment/PreferLocaleFonts.java
new file mode 100644
index 00000000000..3d8cb5934f5
--- /dev/null
+++ b/jdk/test/java/awt/GraphicsEnvironment/PreferLocaleFonts.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6752638
+ * @summary Test no NPE calling preferLocaleFonts() on custom GE.
+ * @run main PreferLocaleFonts
+ */
+
+import java.util.*;
+import java.awt.*;
+import java.awt.image.*;
+
+public class PreferLocaleFonts extends GraphicsEnvironment {
+
+ public static void main(String args[]) {
+(new PreferLocaleFonts()).preferLocaleFonts();
+ }
+ public PreferLocaleFonts() {
+ super();
+ }
+ public Graphics2D createGraphics(BufferedImage image) {
+ return null;
+ }
+ public String[] getAvailableFontFamilyNames(Locale locale) {
+ return null;
+ }
+ public String[] getAvailableFontFamilyNames() {
+ return null;
+ }
+ public Font[] getAllFonts() {
+ return null;
+ }
+ public GraphicsDevice getDefaultScreenDevice() throws HeadlessException {
+ return null;
+ }
+ public GraphicsDevice[] getScreenDevices() throws HeadlessException {
+ return null;
+ }
+}
+
From 14b56dc3a014d3fff31c3f724c37680f12674c0b Mon Sep 17 00:00:00 2001
From: Phil Race
Date: Wed, 24 Dec 2008 15:48:59 -0800
Subject: [PATCH 014/292] 6652463: MediaSize constructors allow to redefine the
mapping of standard MediaSizeName values
Reviewed-by: igor, jgodinez
---
.../print/attribute/standard/MediaSize.java | 12 +++--
.../print/attribute/MediaMappingsTest.java | 48 +++++++++++++++++++
2 files changed, 56 insertions(+), 4 deletions(-)
create mode 100644 jdk/test/javax/print/attribute/MediaMappingsTest.java
diff --git a/jdk/src/share/classes/javax/print/attribute/standard/MediaSize.java b/jdk/src/share/classes/javax/print/attribute/standard/MediaSize.java
index 55cd1aed923..3b6262d2387 100644
--- a/jdk/src/share/classes/javax/print/attribute/standard/MediaSize.java
+++ b/jdk/src/share/classes/javax/print/attribute/standard/MediaSize.java
@@ -123,8 +123,10 @@ public class MediaSize extends Size2DSyntax implements Attribute {
if (x > y) {
throw new IllegalArgumentException("X dimension > Y dimension");
}
- mediaName = media;
- mediaMap.put(mediaName, this);
+ if (media != null && mediaMap.get(media) == null) {
+ mediaName = media;
+ mediaMap.put(mediaName, this);
+ }
sizeVector.add(this);
}
@@ -147,8 +149,10 @@ public class MediaSize extends Size2DSyntax implements Attribute {
if (x > y) {
throw new IllegalArgumentException("X dimension > Y dimension");
}
- mediaName = media;
- mediaMap.put(mediaName, this);
+ if (media != null && mediaMap.get(media) == null) {
+ mediaName = media;
+ mediaMap.put(mediaName, this);
+ }
sizeVector.add(this);
}
diff --git a/jdk/test/javax/print/attribute/MediaMappingsTest.java b/jdk/test/javax/print/attribute/MediaMappingsTest.java
new file mode 100644
index 00000000000..16110d8a49e
--- /dev/null
+++ b/jdk/test/javax/print/attribute/MediaMappingsTest.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6652463
+ * @summary Verify media size-> media mappings can't be altered
+ * @run main MediaMappingsTest
+*/
+
+import javax.print.attribute.standard.MediaSize;
+import javax.print.attribute.standard.MediaSizeName;
+
+public class MediaMappingsTest {
+
+ public static void main(String args[]) {
+ MediaSize sizeA = MediaSize.getMediaSizeForName(MediaSizeName.A);
+ new MediaSize(1.0f, 2.0f, MediaSize.MM, MediaSizeName.A);
+ if (!sizeA.equals(MediaSize.getMediaSizeForName(MediaSizeName.A))) {
+ throw new RuntimeException("mapping changed");
+ }
+ MediaSize sizeB = MediaSize.getMediaSizeForName(MediaSizeName.B);
+ new MediaSize(1, 2, MediaSize.MM, MediaSizeName.B);
+ if (!sizeB.equals(MediaSize.getMediaSizeForName(MediaSizeName.B))) {
+ throw new RuntimeException("mapping changed");
+ }
+ }
+}
From e33cec202fee549a07071d2472b26bc4806908d9 Mon Sep 17 00:00:00 2001
From: Weijun Wang
Date: Tue, 30 Dec 2008 10:42:45 +0800
Subject: [PATCH 015/292] 6717680: LdapCtx does not close the connection if
initialization fails
Reviewed-by: vinnie, xuelei
---
jdk/src/share/classes/com/sun/jndi/ldap/LdapCtx.java | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/LdapCtx.java b/jdk/src/share/classes/com/sun/jndi/ldap/LdapCtx.java
index bec6fd0e761..5f9462c5931 100644
--- a/jdk/src/share/classes/com/sun/jndi/ldap/LdapCtx.java
+++ b/jdk/src/share/classes/com/sun/jndi/ldap/LdapCtx.java
@@ -302,7 +302,16 @@ final public class LdapCtx extends ComponentDirContext
schemaTrees = new Hashtable(11, 0.75f);
initEnv();
- connect(false);
+ try {
+ connect(false);
+ } catch (NamingException e) {
+ try {
+ close();
+ } catch (Exception e2) {
+ // Nothing
+ }
+ throw e;
+ }
}
LdapCtx(LdapCtx existing, String newDN) throws NamingException {
From c357cbe4e01b7eb44b24191232e0fa099796bb73 Mon Sep 17 00:00:00 2001
From: Phil Race
Date: Mon, 5 Jan 2009 11:28:43 -0800
Subject: [PATCH 016/292] 6632886: Font.createFont can be persuaded to leak
temporary files 6522586: Enforce limits on Font creation 6652929:
Font.createFont(int,File) trusts File.getPath
Reviewed-by: igor
---
jdk/src/share/classes/java/awt/Font.java | 177 ++++++++++++------
.../classes/sun/font/CreatedFontTracker.java | 54 ++++++
jdk/src/share/classes/sun/font/FileFont.java | 17 +-
.../share/classes/sun/font/FontManager.java | 11 +-
jdk/test/java/awt/FontClass/CreateFont/A.ttf | Bin 0 -> 2348 bytes
.../awt/FontClass/CreateFont/BigFont.java | 139 ++++++++++++++
.../awt/FontClass/CreateFont/DeleteFont.java | 83 ++++++++
.../awt/FontClass/CreateFont/DeleteFont.sh | 66 +++++++
.../awt/FontClass/CreateFont/bigfont.html | 48 +++++
.../CreateFont/fileaccess/FontFile.java | 83 ++++++++
10 files changed, 616 insertions(+), 62 deletions(-)
create mode 100644 jdk/src/share/classes/sun/font/CreatedFontTracker.java
create mode 100644 jdk/test/java/awt/FontClass/CreateFont/A.ttf
create mode 100644 jdk/test/java/awt/FontClass/CreateFont/BigFont.java
create mode 100644 jdk/test/java/awt/FontClass/CreateFont/DeleteFont.java
create mode 100644 jdk/test/java/awt/FontClass/CreateFont/DeleteFont.sh
create mode 100644 jdk/test/java/awt/FontClass/CreateFont/bigfont.html
create mode 100644 jdk/test/java/awt/FontClass/CreateFont/fileaccess/FontFile.java
diff --git a/jdk/src/share/classes/java/awt/Font.java b/jdk/src/share/classes/java/awt/Font.java
index 8dc5938d411..3ed40325b04 100644
--- a/jdk/src/share/classes/java/awt/Font.java
+++ b/jdk/src/share/classes/java/awt/Font.java
@@ -37,6 +37,8 @@ import java.awt.geom.Rectangle2D;
import java.awt.peer.FontPeer;
import java.io.*;
import java.lang.ref.SoftReference;
+import java.security.AccessController;
+import java.security.PrivilegedExceptionAction;
import java.text.AttributedCharacterIterator.Attribute;
import java.text.CharacterIterator;
import java.text.StringCharacterIterator;
@@ -51,6 +53,7 @@ import sun.font.AttributeMap;
import sun.font.AttributeValues;
import sun.font.EAttribute;
import sun.font.CompositeFont;
+import sun.font.CreatedFontTracker;
import sun.font.Font2D;
import sun.font.Font2DHandle;
import sun.font.FontManager;
@@ -575,14 +578,16 @@ public class Font implements java.io.Serializable
}
/* used to implement Font.createFont */
- private Font(File fontFile, int fontFormat, boolean isCopy)
+ private Font(File fontFile, int fontFormat,
+ boolean isCopy, CreatedFontTracker tracker)
throws FontFormatException {
this.createdFont = true;
/* Font2D instances created by this method track their font file
* so that when the Font2D is GC'd it can also remove the file.
*/
this.font2DHandle =
- FontManager.createFont2D(fontFile, fontFormat, isCopy).handle;
+ FontManager.createFont2D(fontFile, fontFormat,
+ isCopy, tracker).handle;
this.name = this.font2DHandle.font2D.getFontName(Locale.getDefault());
this.style = Font.PLAIN;
this.size = 1;
@@ -787,6 +792,29 @@ public class Font implements java.io.Serializable
return new Font(attributes);
}
+ /**
+ * Used with the byte count tracker for fonts created from streams.
+ * If a thread can create temp files anyway, no point in counting
+ * font bytes.
+ */
+ private static boolean hasTempPermission() {
+
+ if (System.getSecurityManager() == null) {
+ return true;
+ }
+ File f = null;
+ boolean hasPerm = false;
+ try {
+ f = File.createTempFile("+~JT", ".tmp", null);
+ f.delete();
+ f = null;
+ hasPerm = true;
+ } catch (Throwable t) {
+ /* inc. any kind of SecurityException */
+ }
+ return hasPerm;
+ }
+
/**
* Returns a new Font
using the specified font type
* and input data. The new Font
is
@@ -822,58 +850,96 @@ public class Font implements java.io.Serializable
fontFormat != Font.TYPE1_FONT) {
throw new IllegalArgumentException ("font format not recognized");
}
- final InputStream fStream = fontStream;
- Object ret = java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
- public Object run() {
- File tFile = null;
- FileOutputStream outStream = null;
- try {
- tFile = File.createTempFile("+~JF", ".tmp", null);
- /* Temp file deleted by font shutdown hook */
- BufferedInputStream inStream =
- new BufferedInputStream(fStream);
- outStream = new FileOutputStream(tFile);
- int bytesRead = 0;
- int bufSize = 8192;
- byte [] buf = new byte[bufSize];
- while (bytesRead != -1) {
- try {
- bytesRead = inStream.read(buf, 0, bufSize);
- } catch (Throwable t) {
- throw new IOException();
- }
- if (bytesRead != -1) {
- outStream.write(buf, 0, bytesRead);
- }
- }
- /* don't close the input stream */
- outStream.close();
- } catch (IOException e) {
- if (outStream != null) {
- try {
- outStream.close();
- } catch (Exception e1) {
- }
- }
- if (tFile != null) {
- try {
- tFile.delete();
- } catch (Exception e2) {
- }
- }
- return e;
- }
- return tFile;
- }
- });
+ boolean copiedFontData = false;
- if (ret instanceof File) {
- return new Font((File)ret, fontFormat, true);
- } else if (ret instanceof IOException) {
- throw (IOException)ret;
- } else {
- throw new FontFormatException("Couldn't access font stream");
+ try {
+ final File tFile = AccessController.doPrivileged(
+ new PrivilegedExceptionAction() {
+ public File run() throws IOException {
+ return File.createTempFile("+~JF", ".tmp", null);
+ }
+ }
+ );
+
+ int totalSize = 0;
+ CreatedFontTracker tracker = null;
+ try {
+ final OutputStream outStream =
+ AccessController.doPrivileged(
+ new PrivilegedExceptionAction() {
+ public OutputStream run() throws IOException {
+ return new FileOutputStream(tFile);
+ }
+ }
+ );
+ if (!hasTempPermission()) {
+ tracker = CreatedFontTracker.getTracker();
+ }
+ try {
+ byte[] buf = new byte[8192];
+ for (;;) {
+ int bytesRead = fontStream.read(buf);
+ if (bytesRead < 0) {
+ break;
+ }
+ if (tracker != null) {
+ if (totalSize+bytesRead > tracker.MAX_FILE_SIZE) {
+ throw new IOException("File too big.");
+ }
+ if (totalSize+tracker.getNumBytes() >
+ tracker.MAX_TOTAL_BYTES)
+ {
+ throw new IOException("Total files too big.");
+ }
+ totalSize += bytesRead;
+ tracker.addBytes(bytesRead);
+ }
+ outStream.write(buf, 0, bytesRead);
+ }
+ /* don't close the input stream */
+ } finally {
+ outStream.close();
+ }
+ /* After all references to a Font2D are dropped, the file
+ * will be removed. To support long-lived AppContexts,
+ * we need to then decrement the byte count by the size
+ * of the file.
+ * If the data isn't a valid font, the implementation will
+ * delete the tmp file and decrement the byte count
+ * in the tracker object before returning from the
+ * constructor, so we can set 'copiedFontData' to true here
+ * without waiting for the results of that constructor.
+ */
+ copiedFontData = true;
+ Font font = new Font(tFile, fontFormat, true, tracker);
+ return font;
+ } finally {
+ if (!copiedFontData) {
+ if (tracker != null) {
+ tracker.subBytes(totalSize);
+ }
+ AccessController.doPrivileged(
+ new PrivilegedExceptionAction() {
+ public Void run() {
+ tFile.delete();
+ return null;
+ }
+ }
+ );
+ }
+ }
+ } catch (Throwable t) {
+ if (t instanceof FontFormatException) {
+ throw (FontFormatException)t;
+ }
+ if (t instanceof IOException) {
+ throw (IOException)t;
+ }
+ Throwable cause = t.getCause();
+ if (cause instanceof FontFormatException) {
+ throw (FontFormatException)cause;
+ }
+ throw new IOException("Problem reading font data.");
}
}
@@ -913,6 +979,9 @@ public class Font implements java.io.Serializable
*/
public static Font createFont(int fontFormat, File fontFile)
throws java.awt.FontFormatException, java.io.IOException {
+
+ fontFile = new File(fontFile.getPath());
+
if (fontFormat != Font.TRUETYPE_FONT &&
fontFormat != Font.TYPE1_FONT) {
throw new IllegalArgumentException ("font format not recognized");
@@ -926,7 +995,7 @@ public class Font implements java.io.Serializable
if (!fontFile.canRead()) {
throw new IOException("Can't read " + fontFile);
}
- return new Font(fontFile, fontFormat, false);
+ return new Font(fontFile, fontFormat, false, null);
}
/**
diff --git a/jdk/src/share/classes/sun/font/CreatedFontTracker.java b/jdk/src/share/classes/sun/font/CreatedFontTracker.java
new file mode 100644
index 00000000000..741337d5b19
--- /dev/null
+++ b/jdk/src/share/classes/sun/font/CreatedFontTracker.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.font;
+
+public class CreatedFontTracker {
+
+ public static final int MAX_FILE_SIZE = 32 * 1024 * 1024;
+ public static final int MAX_TOTAL_BYTES = 10 * MAX_FILE_SIZE;
+
+ static int numBytes;
+ static CreatedFontTracker tracker;
+
+ public static synchronized CreatedFontTracker getTracker() {
+ if (tracker == null) {
+ tracker = new CreatedFontTracker();
+ }
+ return tracker;
+ }
+
+ public synchronized int getNumBytes() {
+ return numBytes;
+ }
+
+ public synchronized void addBytes(int sz) {
+ numBytes += sz;
+ }
+
+ public synchronized void subBytes(int sz) {
+ numBytes -= sz;
+ }
+}
diff --git a/jdk/src/share/classes/sun/font/FileFont.java b/jdk/src/share/classes/sun/font/FileFont.java
index b6a2099d2a4..5aad11b2acd 100644
--- a/jdk/src/share/classes/sun/font/FileFont.java
+++ b/jdk/src/share/classes/sun/font/FileFont.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
* 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,9 @@ public abstract class FileFont extends PhysicalFont {
return true;
}
- void setFileToRemove(File file) {
+ void setFileToRemove(File file, CreatedFontTracker tracker) {
Disposer.addObjectRecord(this,
- new CreatedFontFileDisposerRecord(file));
+ new CreatedFontFileDisposerRecord(file, tracker));
}
/* This is called when a font scaler is determined to
@@ -246,12 +246,16 @@ public abstract class FileFont extends PhysicalFont {
return getScaler().getUnitsPerEm();
}
- private static class CreatedFontFileDisposerRecord implements DisposerRecord {
+ private static class CreatedFontFileDisposerRecord
+ implements DisposerRecord {
File fontFile = null;
+ CreatedFontTracker tracker;
- private CreatedFontFileDisposerRecord(File file) {
+ private CreatedFontFileDisposerRecord(File file,
+ CreatedFontTracker tracker) {
fontFile = file;
+ this.tracker = tracker;
}
public void dispose() {
@@ -260,6 +264,9 @@ public abstract class FileFont extends PhysicalFont {
public Object run() {
if (fontFile != null) {
try {
+ if (tracker != null) {
+ tracker.subBytes((int)fontFile.length());
+ }
/* REMIND: is it possible that the file is
* still open? It will be closed when the
* font2D is disposed but could this code
diff --git a/jdk/src/share/classes/sun/font/FontManager.java b/jdk/src/share/classes/sun/font/FontManager.java
index 09f181f12c2..29d14047fbd 100644
--- a/jdk/src/share/classes/sun/font/FontManager.java
+++ b/jdk/src/share/classes/sun/font/FontManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -2347,12 +2347,14 @@ public final class FontManager {
static Vector tmpFontFiles = null;
public static Font2D createFont2D(File fontFile, int fontFormat,
- boolean isCopy)
+ boolean isCopy,
+ CreatedFontTracker tracker)
throws FontFormatException {
String fontFilePath = fontFile.getPath();
FileFont font2D = null;
final File fFile = fontFile;
+ final CreatedFontTracker _tracker = tracker;
try {
switch (fontFormat) {
case Font.TRUETYPE_FONT:
@@ -2369,6 +2371,9 @@ public final class FontManager {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() {
public Object run() {
+ if (_tracker != null) {
+ _tracker.subBytes((int)fFile.length());
+ }
fFile.delete();
return null;
}
@@ -2377,7 +2382,7 @@ public final class FontManager {
throw(e);
}
if (isCopy) {
- font2D.setFileToRemove(fontFile);
+ font2D.setFileToRemove(fontFile, tracker);
synchronized (FontManager.class) {
if (tmpFontFiles == null) {
diff --git a/jdk/test/java/awt/FontClass/CreateFont/A.ttf b/jdk/test/java/awt/FontClass/CreateFont/A.ttf
new file mode 100644
index 0000000000000000000000000000000000000000..f80f5c3d569c810493a9fbaf7141a63831733764
GIT binary patch
literal 2348
zcmbVO&2JM&6n``O>5tg!+OZ8Ju*6B67Kmdzu@eZ5A>f26!6qam0n%iX7&}rN8^;NW
z+5=T7qF*Yg66&Fss;9P53qs;ULRDG`Rh4>aFTHT!*gt^wfH3Zx-EDxNwrbyc=KX$e
z-p>4HcXq}=0Kf@tz`=Uzcqo$kYWxcTS;gpybnn3Mz}LUrL%xDMHj~$i@CUsNAl^lO
ze`dL?-W<7o8h~3zUU#OL&A%P}K81V@xhFfndS=h!XE^{~0igZ4+5F0tmS7P;`UKlA
zS4NH^stYxw-~>G5-UMwH8a6;yvys2kN_zyd8_5G-GYpUZ^(_
z0R<*aOu+%mCgz|Y)=kV~4(pYf07p%0~3&8)Wj4dD43Xo
zM)=gkJmy?5u>b)gn^**yoHeo0KL>=jVBbu?ferlzHuM|V&~IQvzkv1~&8?Snt0t
zvydri<;<))y{aY)3*|z#q!n|SlG@%HhCax^0+teJP)0usDon#F)=8Y!0>%oE)mw{@
z)ALk(@U0LYSt!qy=QFb~qG!!v<~+N9D3e{9*Ge#iBnwLz)S&ct$%EQVsgTdi&S@_w
zQ#bAz#2#i)LILu+z&YgqDi1R@3Hzt9Iz!=bsH+S9?@*l(f-qho=z^{d;hO|Ng23+O
z!|FAz>2N^H`2)GBLwj(Y$5HEU*a}V(C2+E2T)=~vut<_95`xR_!`r0#&f(mljo%H9
zCSlhNfyeqfr5L}?^H>9g9?ZYVskoLTIFV3^EGH~f;yD7Mz;RUId5}b&P{OhGoLmmY
z{m|1L>Q*Z3M?&2dB$aLmw~-^cJGe0ABRTC_VrZ<>6~6;=b-i;u>e}gQin;Vq^)!L7tF(X_-gOujyG`qats(Gw%X$A^v$BoDRGDU4xg
z3}YBd4@A5ma{C*&qpxtCazD3!8&x{^-RXYbB5xOJ8u@)5-oKC308vcEJ)w$%moB$L
zLX{B8#!9KQzG(1bsMVaF0@}0F)7bQy#6Ux^xuZQE5G8~R#e7}{#afRy8i~g`+5-&|
zHr9F=^F<^F(eq+auX{W3d41k!EE);Mg3Up1tw##_g1)#Em(T^##c7J~sI}H{({0KA
z-j_R^t}QB0M5S)0XMQ}L=?b^o=;+`MDsekCJE9)TT*aOmpXm`_JF_>RFSMVX1LPrFW4L%88ih_kJsHFRWl@0Y
z8{jd}rdmW!FpKSzO?n$HLEYBO9kGt>fEZcBeHhOvv|h7CCwfIN$1roer%js>>j@8w
zP0{~Oc|0L_JY(@7LeFNP!og}4xe5n#&*mk9h?v6+K_5cFTDAxR2!g;_Mdn4$CSjT=
z@pjYK$P!4B%sUJ(I4v^Bc$Z>j-YU4P7O+^X;!8H>ZKB&|1*_F2dhE>GrP>-B*labD
z*YrMz9qe|8>~}Kn)K49985L1_m%fLJJ~BMH2NAXb;MvY9!=8Img9mztAi-ve-!qy~
z<2(ℜyHe$X3A=a4KE;YvWT*tD?oL)h8oIhlkqO(__Z&$MRa%9hh`>|BkPR{a1h+
zzaGW4_0-c8?qKZQQFBDRhf}MasAB@-4w~9ff>bwAkBE3W81tZb0w=(VZDVi?+sL1^
CwQRot
literal 0
HcmV?d00001
diff --git a/jdk/test/java/awt/FontClass/CreateFont/BigFont.java b/jdk/test/java/awt/FontClass/CreateFont/BigFont.java
new file mode 100644
index 00000000000..c14802485bc
--- /dev/null
+++ b/jdk/test/java/awt/FontClass/CreateFont/BigFont.java
@@ -0,0 +1,139 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+import java.applet.*;
+import java.awt.*;
+import java.io.*;
+import java.net.*;
+
+public class BigFont extends Applet {
+
+ static private class SizedInputStream extends InputStream {
+
+ int size;
+ int cnt = 0;
+
+ SizedInputStream(int size) {
+ this.size = size;
+ }
+
+ public int read() {
+ if (cnt < size) {
+ cnt++;
+ return 0;
+ } else {
+ return -1;
+ }
+ }
+
+ public int getCurrentSize() {
+ return cnt;
+ }
+ }
+
+ String id;
+ String fileName;
+
+ public void init() {
+ id = getParameter("number");
+ fileName = getParameter("font");
+
+ System.out.println("Applet " + id + " "+
+ Thread.currentThread().getThreadGroup());
+ // Larger than size for a single font.
+ int fontSize = 64 * 1000 * 1000;
+ SizedInputStream sis = new SizedInputStream(fontSize);
+ try {
+ Font font = Font.createFont(Font.TRUETYPE_FONT, sis);
+ } catch (Throwable t) {
+ if (t instanceof FontFormatException ||
+ fontSize <= sis.getCurrentSize())
+ {
+ System.out.println(sis.getCurrentSize());
+ System.out.println(t);
+ throw new RuntimeException("Allowed file to be too large.");
+ }
+ }
+ // The following part of the test was verified manually but
+ // is impractical to enable because it requires a fairly large
+ // valid font to be part of the test, and we can't easily include
+ // that, nor dependably reference one from the applet environment.
+ /*
+ if (fileName == null) {
+ return;
+ }
+ int size = getFileSize(fileName);
+ if (size == 0) {
+ return;
+ }
+ int fontCnt = 1000 * 1000 * 1000 / size;
+ loadMany(size, fontCnt, fileName);
+ System.gc(); System.gc();
+ fontCnt = fontCnt / 2;
+ System.out.println("Applet " + id + " load more.");
+ loadMany(size, fontCnt, fileName);
+ */
+ System.out.println("Applet " + id + " finished.");
+ }
+
+ int getFileSize(String fileName) {
+ try {
+ URL url = new URL(getCodeBase(), fileName);
+ InputStream inStream = url.openStream();
+ BufferedInputStream fontStream = new BufferedInputStream(inStream);
+ int size = 0;
+ while (fontStream.read() != -1) {
+ size++;
+ }
+ fontStream.close();
+ return size;
+ } catch (IOException e) {
+ return 0;
+ }
+
+ }
+ void loadMany(int oneFont, int fontCnt, String fileName) {
+ System.out.println("fontcnt= " + fontCnt);
+ Font[] fonts = new Font[fontCnt];
+ int totalSize = 0;
+ boolean gotException = false;
+ for (int i=0; i
+
+
+
+ Test Font Creation Limits
+
+
+
+
+
+
+
+
+
diff --git a/jdk/test/java/awt/FontClass/CreateFont/fileaccess/FontFile.java b/jdk/test/java/awt/FontClass/CreateFont/fileaccess/FontFile.java
new file mode 100644
index 00000000000..44419748903
--- /dev/null
+++ b/jdk/test/java/awt/FontClass/CreateFont/fileaccess/FontFile.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6652929
+ * @summary verify handling of File.getPath()
+ */
+
+import java.awt.*;
+import java.io.*;
+
+public class FontFile {
+ public static void main(String[] args) throws Exception {
+ String sep = System.getProperty("file.separator");
+ String fname = ".." + sep + "A.ttf";
+ String dir = System.getProperty("test.src");
+ if (dir != null) {
+ fname = dir + sep + fname;
+ }
+ final String name = fname;
+ System.out.println("Will try to access " + name);
+ if (!(new File(name)).canRead()) {
+ System.out.println("File not available : can't run test");
+ return;
+ }
+ System.out.println("File is available. Verify no access under SM");
+
+ System.setSecurityManager(new SecurityManager());
+
+
+ // Check cannot read file.
+ try {
+ new FileInputStream(name);
+ throw new Error("Something wrong with test environment");
+ } catch (SecurityException exc) {
+ // Good.
+ }
+
+ try {
+ Font font = Font.createFont(Font.TRUETYPE_FONT,
+ new File("nosuchfile") {
+ private boolean read;
+ @Override public String getPath() {
+ if (read) {
+ return name;
+ } else {
+ read = true;
+ return "somefile";
+ }
+ }
+ @Override public boolean canRead() {
+ return true;
+ }
+ }
+ );
+ System.err.println(font.getFontName());
+ throw new RuntimeException("No expected exception");
+ } catch (IOException e) {
+ System.err.println("Test passed.");
+ }
+ }
+}
From a0930ff4d46ce23e6b298e862857768afd6d9d15 Mon Sep 17 00:00:00 2001
From: Phil Race
Date: Tue, 6 Jan 2009 13:52:03 -0800
Subject: [PATCH 017/292] 6785424: SecurityException locating physical fonts on
Windows Terminal Server
Reviewed-by: campbell, jgodinez
---
.../share/classes/sun/font/FontManager.java | 21 +++++---
jdk/test/java/awt/FontClass/FontAccess.java | 48 +++++++++++++++++++
2 files changed, 63 insertions(+), 6 deletions(-)
create mode 100644 jdk/test/java/awt/FontClass/FontAccess.java
diff --git a/jdk/src/share/classes/sun/font/FontManager.java b/jdk/src/share/classes/sun/font/FontManager.java
index f709f381ada..a8b721daffc 100644
--- a/jdk/src/share/classes/sun/font/FontManager.java
+++ b/jdk/src/share/classes/sun/font/FontManager.java
@@ -1601,18 +1601,27 @@ public final class FontManager {
/* Path may be absolute or a base file name relative to one of
* the platform font directories
*/
- private static String getPathName(String s) {
+ private static String getPathName(final String s) {
File f = new File(s);
if (f.isAbsolute()) {
return s;
} else if (pathDirs.length==1) {
return pathDirs[0] + File.separator + s;
} else {
- for (int p=0; p() {
+ public String run() {
+ for (int p=0; p
Date: Mon, 12 Jan 2009 16:02:47 -0800
Subject: [PATCH 018/292] 6752622: java.awt.Font.getPeer throws
"java.lang.InternalError: Not implemented" on Linux
Reviewed-by: igor, yan
---
jdk/src/solaris/classes/sun/awt/X11/XFontPeer.java | 7 -------
jdk/src/solaris/classes/sun/font/FcFontConfiguration.java | 2 +-
2 files changed, 1 insertion(+), 8 deletions(-)
diff --git a/jdk/src/solaris/classes/sun/awt/X11/XFontPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XFontPeer.java
index 62044ace53e..3d03a2503aa 100644
--- a/jdk/src/solaris/classes/sun/awt/X11/XFontPeer.java
+++ b/jdk/src/solaris/classes/sun/awt/X11/XFontPeer.java
@@ -27,9 +27,6 @@ package sun.awt.X11;
import sun.awt.PlatformFont;
import java.awt.GraphicsEnvironment;
-/* FIX ME */
-import sun.awt.motif.MFontConfiguration;
-
public class XFontPeer extends PlatformFont {
/*
@@ -51,10 +48,6 @@ public class XFontPeer extends PlatformFont {
public XFontPeer(String name, int style){
super(name, style);
-
- if (fontConfig != null){
- xfsname = ((MFontConfiguration) fontConfig).getMotifFontSet(familyName, style);
- }
}
protected char getMissingGlyphCharacter() {
diff --git a/jdk/src/solaris/classes/sun/font/FcFontConfiguration.java b/jdk/src/solaris/classes/sun/font/FcFontConfiguration.java
index 95154df0a47..a34fed02e15 100644
--- a/jdk/src/solaris/classes/sun/font/FcFontConfiguration.java
+++ b/jdk/src/solaris/classes/sun/font/FcFontConfiguration.java
@@ -173,7 +173,7 @@ public class FcFontConfiguration extends FontConfiguration {
@Override
public FontDescriptor[] getFontDescriptors(String fontName, int style) {
- throw new InternalError("Not implemented");
+ return new FontDescriptor[0];
}
@Override
From bf4d190698d0b36f90af28f05ef856b7d03ffd52 Mon Sep 17 00:00:00 2001
From: Martin von Gagern
Date: Tue, 13 Jan 2009 16:55:12 +0300
Subject: [PATCH 019/292] 5082756: Image I/O plug-ins set metadata boolean
attributes to "true" or "false"
Reviewed-by: igor, prr
---
.../imageio/plugins/gif/GIFImageMetadata.java | 6 +-
.../sun/imageio/plugins/gif/GIFMetadata.java | 9 +-
.../plugins/gif/GIFStreamMetadata.java | 2 +-
.../imageio/plugins/jpeg/JPEGMetadata.java | 2 +-
.../sun/imageio/plugins/png/PNGMetadata.java | 13 +-
.../imageio/metadata/IIOMetadataFormat.java | 8 +-
.../imageio/metadata/BooleanAttributes.java | 202 ++++++++++++++++++
.../javax/imageio/plugins/png/ITXtTest.java | 2 +-
8 files changed, 224 insertions(+), 20 deletions(-)
create mode 100644 jdk/test/javax/imageio/metadata/BooleanAttributes.java
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageMetadata.java b/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageMetadata.java
index 08da84856b7..9660d82603a 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageMetadata.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageMetadata.java
@@ -153,7 +153,7 @@ public class GIFImageMetadata extends GIFMetadata {
node.setAttribute("imageWidth", Integer.toString(imageWidth));
node.setAttribute("imageHeight", Integer.toString(imageHeight));
node.setAttribute("interlaceFlag",
- interlaceFlag ? "true" : "false");
+ interlaceFlag ? "TRUE" : "FALSE");
root.appendChild(node);
// Local color table
@@ -185,9 +185,9 @@ public class GIFImageMetadata extends GIFMetadata {
node.setAttribute("disposalMethod",
disposalMethodNames[disposalMethod]);
node.setAttribute("userInputFlag",
- userInputFlag ? "true" : "false");
+ userInputFlag ? "TRUE" : "FALSE");
node.setAttribute("transparentColorFlag",
- transparentColorFlag ? "true" : "false");
+ transparentColorFlag ? "TRUE" : "FALSE");
node.setAttribute("delayTime",
Integer.toString(delayTime));
node.setAttribute("transparentColorIndex",
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFMetadata.java b/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFMetadata.java
index 42dfbd0bed9..8acdaa2db49 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFMetadata.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFMetadata.java
@@ -158,13 +158,10 @@ abstract class GIFMetadata extends IIOMetadata {
}
}
String value = attr.getNodeValue();
- // XXX Should be able to use equals() here instead of
- // equalsIgnoreCase() but some boolean attributes are incorrectly
- // set to "true" or "false" by the J2SE core metadata classes
- // getAsTree() method (which are duplicated above). See bug 5082756.
- if (value.equalsIgnoreCase("TRUE")) {
+ // Allow lower case booleans for backward compatibility, #5082756
+ if (value.equals("TRUE") || value.equals("true")) {
return true;
- } else if (value.equalsIgnoreCase("FALSE")) {
+ } else if (value.equals("FALSE") || value.equals("false")) {
return false;
} else {
fatal(node, "Attribute " + name + " must be 'TRUE' or 'FALSE'!");
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFStreamMetadata.java b/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFStreamMetadata.java
index 0979bf3d849..bc0a784b272 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFStreamMetadata.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFStreamMetadata.java
@@ -202,7 +202,7 @@ public class GIFStreamMetadata extends GIFMetadata {
compression_node.appendChild(node);
node = new IIOMetadataNode("Lossless");
- node.setAttribute("value", "true");
+ node.setAttribute("value", "TRUE");
compression_node.appendChild(node);
// NumProgressiveScans not in stream
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGMetadata.java b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGMetadata.java
index 7f753341c93..c84003c9f22 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGMetadata.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGMetadata.java
@@ -955,7 +955,7 @@ public class JPEGMetadata extends IIOMetadata implements Cloneable {
// Lossless - false
IIOMetadataNode lossless = new IIOMetadataNode("Lossless");
- lossless.setAttribute("value", "false");
+ lossless.setAttribute("value", "FALSE");
compression.appendChild(lossless);
// NumProgressiveScans - count sos segments
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java
index 23281fe5330..1ad78ad165f 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java
@@ -600,7 +600,7 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
IIOMetadataNode iTXt_node = new IIOMetadataNode("iTXtEntry");
iTXt_node.setAttribute("keyword", iTXt_keyword.get(i));
iTXt_node.setAttribute("compressionFlag",
- iTXt_compressionFlag.get(i) ? "1" : "0");
+ iTXt_compressionFlag.get(i) ? "TRUE" : "FALSE");
iTXt_node.setAttribute("compressionMethod",
iTXt_compressionMethod.get(i).toString());
iTXt_node.setAttribute("languageTag",
@@ -832,7 +832,7 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
}
node = new IIOMetadataNode("BlackIsZero");
- node.setAttribute("value", "true");
+ node.setAttribute("value", "TRUE");
chroma_node.appendChild(node);
if (PLTE_present) {
@@ -894,7 +894,7 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
compression_node.appendChild(node);
node = new IIOMetadataNode("Lossless");
- node.setAttribute("value", "true");
+ node.setAttribute("value", "TRUE");
compression_node.appendChild(node);
node = new IIOMetadataNode("NumProgressiveScans");
@@ -1162,12 +1162,13 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
}
}
String value = attr.getNodeValue();
- if (value.equals("true")) {
+ // Allow lower case booleans for backward compatibility, #5082756
+ if (value.equals("TRUE") || value.equals("true")) {
return true;
- } else if (value.equals("false")) {
+ } else if (value.equals("FALSE") || value.equals("false")) {
return false;
} else {
- fatal(node, "Attribute " + name + " must be 'true' or 'false'!");
+ fatal(node, "Attribute " + name + " must be 'TRUE' or 'FALSE'!");
return false;
}
}
diff --git a/jdk/src/share/classes/javax/imageio/metadata/IIOMetadataFormat.java b/jdk/src/share/classes/javax/imageio/metadata/IIOMetadataFormat.java
index 88ea8e98756..cff46177d62 100644
--- a/jdk/src/share/classes/javax/imageio/metadata/IIOMetadataFormat.java
+++ b/jdk/src/share/classes/javax/imageio/metadata/IIOMetadataFormat.java
@@ -242,8 +242,12 @@ public interface IIOMetadataFormat {
/**
* A constant returned by getAttributeDataType
- * indicating that the value of an attribute is one of 'true' or
- * 'false'.
+ * indicating that the value of an attribute is one of the boolean
+ * values 'true' or 'false'.
+ * Attribute values of type DATATYPE_BOOLEAN should be marked as
+ * enumerations, and the permitted values should be the string
+ * literal values "TRUE" or "FALSE", although a plugin may also
+ * recognise lower or mixed case equivalents.
*/
int DATATYPE_BOOLEAN = 1;
diff --git a/jdk/test/javax/imageio/metadata/BooleanAttributes.java b/jdk/test/javax/imageio/metadata/BooleanAttributes.java
new file mode 100644
index 00000000000..104b12432c8
--- /dev/null
+++ b/jdk/test/javax/imageio/metadata/BooleanAttributes.java
@@ -0,0 +1,202 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug 5082756
+ * @summary ensure that boolean attributes follow ( "TRUE" | "FALSE" )
+ * including correct (i.e. upper) case
+ *
+ * @run main BooleanAttributes
+ */
+
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.StringReader;
+import java.util.Arrays;
+import java.util.List;
+import javax.imageio.IIOImage;
+import javax.imageio.ImageIO;
+import javax.imageio.ImageReader;
+import javax.imageio.ImageTypeSpecifier;
+import javax.imageio.ImageWriteParam;
+import javax.imageio.ImageWriter;
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.stream.ImageInputStream;
+import javax.imageio.stream.ImageOutputStream;
+import javax.imageio.stream.MemoryCacheImageInputStream;
+import javax.imageio.stream.MemoryCacheImageOutputStream;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class BooleanAttributes {
+
+ private static TransformerFactory transformerFactory =
+ TransformerFactory.newInstance();
+
+ private static XPath xpathEngine = XPathFactory.newInstance().newXPath();
+
+ public static void main(String[] args) throws Exception {
+ test("image/png", false, "",
+ "Chroma/BlackIsZero/@value",
+ "Compression/Lossless/@value");
+
+ test("image/png", false,
+ "" +
+ "" +
+ "",
+ "iTXt/iTXtEntry/@compressionFlag");
+
+ test("image/png", false,
+ "" +
+ "" +
+ "",
+ "iTXt/iTXtEntry/@compressionFlag");
+
+ test("image/gif", false, "",
+ "Chroma/BlackIsZero/@value",
+ "Compression/Lossless/@value");
+
+ test("image/gif", false,
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "",
+ "ImageDescriptor/@interlaceFlag",
+ "LocalColorTable/@sortFlag",
+ "GraphicControlExtension/@userInputFlag",
+ "GraphicControlExtension/@transparentColorFlag");
+
+ test("image/gif", true,
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "",
+ "GlobalColorTable/@sortFlag");
+
+ test("image/jpeg", false, "",
+ "Compression/Lossless/@value");
+ }
+
+ private static void transform(Source src, Result dst)
+ throws Exception
+ {
+ transformerFactory.newTransformer().transform(src, dst);
+ }
+
+ private static void verify(Node meta, String[] xpaths, boolean required)
+ throws Exception
+ {
+ for (String xpath: xpaths) {
+ NodeList list = (NodeList)
+ xpathEngine.evaluate(xpath, meta, XPathConstants.NODESET);
+ if (list.getLength() == 0 && required)
+ throw new AssertionError("Missing value: " + xpath);
+ for (int i = 0; i < list.getLength(); ++i) {
+ String value = list.item(i).getNodeValue();
+ if (!(value.equals("TRUE") || value.equals("FALSE")))
+ throw new AssertionError(xpath + " has value " + value);
+ }
+ }
+ }
+
+ public static void test(String mimeType, boolean useStreamMeta,
+ String metaXml, String... boolXpaths)
+ throws Exception
+ {
+ BufferedImage img =
+ new BufferedImage(16, 16, BufferedImage.TYPE_INT_RGB);
+ ImageWriter iw = ImageIO.getImageWritersByMIMEType(mimeType).next();
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ ImageOutputStream ios = new MemoryCacheImageOutputStream(os);
+ iw.setOutput(ios);
+ ImageWriteParam param = null;
+ IIOMetadata streamMeta = iw.getDefaultStreamMetadata(param);
+ IIOMetadata imageMeta =
+ iw.getDefaultImageMetadata(new ImageTypeSpecifier(img), param);
+ IIOMetadata meta = useStreamMeta ? streamMeta : imageMeta;
+ Source src = new StreamSource(new StringReader(metaXml));
+ DOMResult dst = new DOMResult();
+ transform(src, dst);
+ Document doc = (Document)dst.getNode();
+ Element node = doc.getDocumentElement();
+ String metaFormat = node.getNodeName();
+
+ // Verify that the default metadata gets formatted correctly.
+ verify(meta.getAsTree(metaFormat), boolXpaths, false);
+
+ meta.mergeTree(metaFormat, node);
+
+ // Verify that the merged metadata gets formatte correctly.
+ verify(meta.getAsTree(metaFormat), boolXpaths, true);
+
+ iw.write(streamMeta, new IIOImage(img, null, imageMeta), param);
+ iw.dispose();
+ ios.close();
+ ImageReader ir = ImageIO.getImageReader(iw);
+ byte[] bytes = os.toByteArray();
+ if (bytes.length == 0)
+ throw new AssertionError("Zero length image file");
+ ByteArrayInputStream is = new ByteArrayInputStream(bytes);
+ ImageInputStream iis = new MemoryCacheImageInputStream(is);
+ ir.setInput(iis);
+ if (useStreamMeta) meta = ir.getStreamMetadata();
+ else meta = ir.getImageMetadata(0);
+
+ // Verify again after writing and re-reading the image
+ verify(meta.getAsTree(metaFormat), boolXpaths, true);
+ }
+
+ public static void xtest(Object... eatAnyArguments) {
+ System.err.println("Disabled test! Change xtest back into test!");
+ }
+
+}
diff --git a/jdk/test/javax/imageio/plugins/png/ITXtTest.java b/jdk/test/javax/imageio/plugins/png/ITXtTest.java
index 9bace746227..ec81bd874ac 100644
--- a/jdk/test/javax/imageio/plugins/png/ITXtTest.java
+++ b/jdk/test/javax/imageio/plugins/png/ITXtTest.java
@@ -123,7 +123,7 @@ public class ITXtTest {
}
t.keyword = e.getAttribute("keyword");
t.isCompressed =
- (Integer.valueOf(e.getAttribute("compressionFlag")).intValue() == 1);
+ Boolean.valueOf(e.getAttribute("compressionFlag")).booleanValue();
t.compression =
Integer.valueOf(e.getAttribute("compressionMethod")).intValue();
t.language = e.getAttribute("languageTag");
From 57a1271b06b6a1cc4548fb353d8c0cf261eb0a38 Mon Sep 17 00:00:00 2001
From: Martin von Gagern
Date: Tue, 13 Jan 2009 18:38:44 +0300
Subject: [PATCH 020/292] 6782079: PNG: reading metadata may cause OOM on
truncated images
Reviewed-by: igor, prr
---
.../imageio/plugins/png/PNGImageReader.java | 45 ++--
.../imageio/plugins/png/PNGImageWriter.java | 9 +-
.../sun/imageio/plugins/png/PNGMetadata.java | 43 ++--
.../imageio/plugins/png/ItxtUtf8Test.java | 241 ++++++++++++++++++
4 files changed, 281 insertions(+), 57 deletions(-)
create mode 100644 jdk/test/javax/imageio/plugins/png/ItxtUtf8Test.java
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java
index 84a593264be..f35165420e9 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java
@@ -37,6 +37,7 @@ import java.awt.image.WritableRaster;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
+import java.io.EOFException;
import java.io.InputStream;
import java.io.IOException;
import java.io.SequenceInputStream;
@@ -59,7 +60,7 @@ import com.sun.imageio.plugins.common.SubImageInputStream;
import java.io.ByteArrayOutputStream;
import sun.awt.image.ByteInterleavedRaster;
-class PNGImageDataEnumeration implements Enumeration {
+class PNGImageDataEnumeration implements Enumeration {
boolean firstTime = true;
ImageInputStream stream;
@@ -72,7 +73,7 @@ class PNGImageDataEnumeration implements Enumeration {
int type = stream.readInt(); // skip chunk type
}
- public Object nextElement() {
+ public InputStream nextElement() {
try {
firstTime = false;
ImageInputStream iis = new SubImageInputStream(stream, length);
@@ -207,25 +208,17 @@ public class PNGImageReader extends ImageReader {
resetStreamSettings();
}
- private String readNullTerminatedString(String charset) throws IOException {
+ private String readNullTerminatedString(String charset, int maxLen) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int b;
- while ((b = stream.read()) != 0) {
+ int count = 0;
+ while ((maxLen > count++) && ((b = stream.read()) != 0)) {
+ if (b == -1) throw new EOFException();
baos.write(b);
}
return new String(baos.toByteArray(), charset);
}
- private String readNullTerminatedString() throws IOException {
- StringBuilder b = new StringBuilder();
- int c;
-
- while ((c = stream.read()) != 0) {
- b.append((char)c);
- }
- return b.toString();
- }
-
private void readHeader() throws IIOException {
if (gotHeader) {
return;
@@ -434,7 +427,7 @@ public class PNGImageReader extends ImageReader {
}
private void parse_iCCP_chunk(int chunkLength) throws IOException {
- String keyword = readNullTerminatedString();
+ String keyword = readNullTerminatedString("ISO-8859-1", 80);
metadata.iCCP_profileName = keyword;
metadata.iCCP_compressionMethod = stream.readUnsignedByte();
@@ -450,7 +443,7 @@ public class PNGImageReader extends ImageReader {
private void parse_iTXt_chunk(int chunkLength) throws IOException {
long chunkStart = stream.getStreamPosition();
- String keyword = readNullTerminatedString();
+ String keyword = readNullTerminatedString("ISO-8859-1", 80);
metadata.iTXt_keyword.add(keyword);
int compressionFlag = stream.readUnsignedByte();
@@ -459,15 +452,17 @@ public class PNGImageReader extends ImageReader {
int compressionMethod = stream.readUnsignedByte();
metadata.iTXt_compressionMethod.add(Integer.valueOf(compressionMethod));
- String languageTag = readNullTerminatedString("UTF8");
+ String languageTag = readNullTerminatedString("UTF8", 80);
metadata.iTXt_languageTag.add(languageTag);
+ long pos = stream.getStreamPosition();
+ int maxLen = (int)(chunkStart + chunkLength - pos);
String translatedKeyword =
- readNullTerminatedString("UTF8");
+ readNullTerminatedString("UTF8", maxLen);
metadata.iTXt_translatedKeyword.add(translatedKeyword);
String text;
- long pos = stream.getStreamPosition();
+ pos = stream.getStreamPosition();
byte[] b = new byte[(int)(chunkStart + chunkLength - pos)];
stream.readFully(b);
@@ -511,7 +506,7 @@ public class PNGImageReader extends ImageReader {
private void parse_sPLT_chunk(int chunkLength)
throws IOException, IIOException {
- metadata.sPLT_paletteName = readNullTerminatedString();
+ metadata.sPLT_paletteName = readNullTerminatedString("ISO-8859-1", 80);
chunkLength -= metadata.sPLT_paletteName.length() + 1;
int sampleDepth = stream.readUnsignedByte();
@@ -554,12 +549,12 @@ public class PNGImageReader extends ImageReader {
}
private void parse_tEXt_chunk(int chunkLength) throws IOException {
- String keyword = readNullTerminatedString();
+ String keyword = readNullTerminatedString("ISO-8859-1", 80);
metadata.tEXt_keyword.add(keyword);
byte[] b = new byte[chunkLength - keyword.length() - 1];
stream.readFully(b);
- metadata.tEXt_text.add(new String(b));
+ metadata.tEXt_text.add(new String(b, "ISO-8859-1"));
}
private void parse_tIME_chunk() throws IOException {
@@ -640,7 +635,7 @@ public class PNGImageReader extends ImageReader {
}
private void parse_zTXt_chunk(int chunkLength) throws IOException {
- String keyword = readNullTerminatedString();
+ String keyword = readNullTerminatedString("ISO-8859-1", 80);
metadata.zTXt_keyword.add(keyword);
int method = stream.readUnsignedByte();
@@ -648,7 +643,7 @@ public class PNGImageReader extends ImageReader {
byte[] b = new byte[chunkLength - keyword.length() - 2];
stream.readFully(b);
- metadata.zTXt_text.add(new String(inflate(b)));
+ metadata.zTXt_text.add(new String(inflate(b), "ISO-8859-1"));
}
private void readMetadata() throws IIOException {
@@ -1263,7 +1258,7 @@ public class PNGImageReader extends ImageReader {
try {
stream.seek(imageStartPosition);
- Enumeration e = new PNGImageDataEnumeration(stream);
+ Enumeration e = new PNGImageDataEnumeration(stream);
InputStream is = new SequenceInputStream(e);
/* InflaterInputStream uses an Inflater instance which consumes
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java
index ea4233a68ea..0f9cc785f92 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java
@@ -674,13 +674,8 @@ public class PNGImageWriter extends ImageWriter {
private byte[] deflate(byte[] b) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DeflaterOutputStream dos = new DeflaterOutputStream(baos);
-
- int len = b.length;
- for (int i = 0; i < len; i++) {
- dos.write((int)(0xff & b[i]));
- }
+ dos.write(b);
dos.close();
-
return baos.toByteArray();
}
@@ -736,7 +731,7 @@ public class PNGImageWriter extends ImageWriter {
cs.writeByte(compressionMethod);
String text = (String)textIter.next();
- cs.write(deflate(text.getBytes()));
+ cs.write(deflate(text.getBytes("ISO-8859-1")));
cs.finish();
}
}
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java
index 1ad78ad165f..9da72298884 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java
@@ -211,8 +211,8 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
public int sRGB_renderingIntent;
// tEXt chunk
- public ArrayList tEXt_keyword = new ArrayList(); // 1-79 char Strings
- public ArrayList tEXt_text = new ArrayList(); // Strings
+ public ArrayList tEXt_keyword = new ArrayList(); // 1-79 characters
+ public ArrayList tEXt_text = new ArrayList();
// tIME chunk
public boolean tIME_present;
@@ -235,13 +235,13 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
public int tRNS_blue;
// zTXt chunk
- public ArrayList zTXt_keyword = new ArrayList(); // Strings
- public ArrayList zTXt_compressionMethod = new ArrayList(); // Integers
- public ArrayList zTXt_text = new ArrayList(); // Strings
+ public ArrayList zTXt_keyword = new ArrayList();
+ public ArrayList zTXt_compressionMethod = new ArrayList();
+ public ArrayList zTXt_text = new ArrayList();
// Unknown chunks
- public ArrayList unknownChunkType = new ArrayList(); // Strings
- public ArrayList unknownChunkData = new ArrayList(); // byte arrays
+ public ArrayList unknownChunkType = new ArrayList();
+ public ArrayList unknownChunkData = new ArrayList();
public PNGMetadata() {
super(true,
@@ -426,21 +426,14 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
return false;
}
- private ArrayList cloneBytesArrayList(ArrayList in) {
+ private ArrayList cloneBytesArrayList(ArrayList in) {
if (in == null) {
return null;
} else {
- ArrayList list = new ArrayList(in.size());
- Iterator iter = in.iterator();
- while (iter.hasNext()) {
- Object o = iter.next();
- if (o == null) {
- list.add(null);
- } else {
- list.add(((byte[])o).clone());
- }
+ ArrayList list = new ArrayList(in.size());
+ for (byte[] b: in) {
+ list.add((b == null) ? null : (byte[])b.clone());
}
-
return list;
}
}
@@ -2040,14 +2033,14 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
sBIT_present = false;
sPLT_present = false;
sRGB_present = false;
- tEXt_keyword = new ArrayList();
- tEXt_text = new ArrayList();
+ tEXt_keyword = new ArrayList();
+ tEXt_text = new ArrayList();
tIME_present = false;
tRNS_present = false;
- zTXt_keyword = new ArrayList();
- zTXt_compressionMethod = new ArrayList();
- zTXt_text = new ArrayList();
- unknownChunkType = new ArrayList();
- unknownChunkData = new ArrayList();
+ zTXt_keyword = new ArrayList();
+ zTXt_compressionMethod = new ArrayList();
+ zTXt_text = new ArrayList();
+ unknownChunkType = new ArrayList();
+ unknownChunkData = new ArrayList();
}
}
diff --git a/jdk/test/javax/imageio/plugins/png/ItxtUtf8Test.java b/jdk/test/javax/imageio/plugins/png/ItxtUtf8Test.java
new file mode 100644
index 00000000000..e35495bdee1
--- /dev/null
+++ b/jdk/test/javax/imageio/plugins/png/ItxtUtf8Test.java
@@ -0,0 +1,241 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug 6541476 6782079
+ * @summary Write and read a PNG file including an non-latin1 iTXt chunk
+ * Test also verifies that trunkated png images does not cause
+ * an OoutOfMemory error.
+ *
+ * @run main ItxtUtf8Test
+ *
+ * @run main/othervm/timeout=10 -Xmx2m ItxtUtf8Test truncate
+ */
+
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStream;
+import java.util.Arrays;
+import java.util.List;
+import javax.imageio.IIOException;
+import javax.imageio.IIOImage;
+import javax.imageio.ImageIO;
+import javax.imageio.ImageReader;
+import javax.imageio.ImageTypeSpecifier;
+import javax.imageio.ImageWriter;
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.stream.ImageInputStream;
+import javax.imageio.stream.ImageOutputStream;
+import javax.imageio.stream.MemoryCacheImageInputStream;
+import javax.imageio.stream.MemoryCacheImageOutputStream;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.bootstrap.DOMImplementationRegistry;
+
+public class ItxtUtf8Test {
+
+ public static final String
+ TEXT = "\u24c9\u24d4\u24e7\u24e3" +
+ "\ud835\udc13\ud835\udc1e\ud835\udc31\ud835\udc2d" +
+ "\u24c9\u24d4\u24e7\u24e3", // a repetition for compression
+ VERBATIM = "\u24e5\u24d4\u24e1\u24d1\u24d0\u24e3\u24d8\u24dc",
+ COMPRESSED = "\u24d2\u24de\u24dc\u24df\u24e1\u24d4\u24e2\u24e2\u24d4\u24d3";
+
+ public static final byte[]
+ VBYTES = {
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x56, // chunk length
+ (byte)0x69, (byte)0x54, (byte)0x58, (byte)0x74, // chunk type "iTXt"
+ (byte)0x76, (byte)0x65, (byte)0x72, (byte)0x62,
+ (byte)0x61, (byte)0x74, (byte)0x69, (byte)0x6d, // keyword "verbatim"
+ (byte)0x00, // separator terminating keyword
+ (byte)0x00, // compression flag
+ (byte)0x00, // compression method, must be zero
+ (byte)0x78, (byte)0x2d, (byte)0x63, (byte)0x69,
+ (byte)0x72, (byte)0x63, (byte)0x6c, (byte)0x65,
+ (byte)0x64, // language tag "x-circled"
+ (byte)0x00, // separator terminating language tag
+ (byte)0xe2, (byte)0x93, (byte)0xa5, // '\u24e5'
+ (byte)0xe2, (byte)0x93, (byte)0x94, // '\u24d4'
+ (byte)0xe2, (byte)0x93, (byte)0xa1, // '\u24e1'
+ (byte)0xe2, (byte)0x93, (byte)0x91, // '\u24d1'
+ (byte)0xe2, (byte)0x93, (byte)0x90, // '\u24d0'
+ (byte)0xe2, (byte)0x93, (byte)0xa3, // '\u24e3'
+ (byte)0xe2, (byte)0x93, (byte)0x98, // '\u24d8'
+ (byte)0xe2, (byte)0x93, (byte)0x9c, // '\u24dc'
+ (byte)0x00, // separator terminating the translated keyword
+ (byte)0xe2, (byte)0x93, (byte)0x89, // '\u24c9'
+ (byte)0xe2, (byte)0x93, (byte)0x94, // '\u24d4'
+ (byte)0xe2, (byte)0x93, (byte)0xa7, // '\u24e7'
+ (byte)0xe2, (byte)0x93, (byte)0xa3, // '\u24e3'
+ (byte)0xf0, (byte)0x9d, (byte)0x90, (byte)0x93, // '\ud835\udc13'
+ (byte)0xf0, (byte)0x9d, (byte)0x90, (byte)0x9e, // '\ud835\udc1e'
+ (byte)0xf0, (byte)0x9d, (byte)0x90, (byte)0xb1, // '\ud835\udc31'
+ (byte)0xf0, (byte)0x9d, (byte)0x90, (byte)0xad, // '\ud835\udc2d'
+ (byte)0xe2, (byte)0x93, (byte)0x89, // '\u24c9'
+ (byte)0xe2, (byte)0x93, (byte)0x94, // '\u24d4'
+ (byte)0xe2, (byte)0x93, (byte)0xa7, // '\u24e7'
+ (byte)0xe2, (byte)0x93, (byte)0xa3, // '\u24e3'
+ (byte)0xb5, (byte)0xcc, (byte)0x97, (byte)0x56 // CRC
+ },
+ CBYTES = {
+ // we don't want to check the chunk length,
+ // as this might depend on implementation.
+ (byte)0x69, (byte)0x54, (byte)0x58, (byte)0x74, // chunk type "iTXt"
+ (byte)0x63, (byte)0x6f, (byte)0x6d, (byte)0x70,
+ (byte)0x72, (byte)0x65, (byte)0x73, (byte)0x73,
+ (byte)0x65, (byte)0x64, // keyword "compressed"
+ (byte)0x00, // separator terminating keyword
+ (byte)0x01, // compression flag
+ (byte)0x00, // compression method, 0=deflate
+ (byte)0x78, (byte)0x2d, (byte)0x63, (byte)0x69,
+ (byte)0x72, (byte)0x63, (byte)0x6c, (byte)0x65,
+ (byte)0x64, // language tag "x-circled"
+ (byte)0x00, // separator terminating language tag
+ // we don't want to check the actual compressed data,
+ // as this might depend on implementation.
+ };
+/*
+*/
+
+ public static void main(String[] args) throws Exception {
+ List argList = Arrays.asList(args);
+ if (argList.contains("truncate")) {
+ try {
+ runTest(false, true);
+ throw new AssertionError("Expect an error for truncated file");
+ }
+ catch (IIOException e) {
+ // expected an error for a truncated image file.
+ }
+ }
+ else {
+ runTest(argList.contains("dump"), false);
+ }
+ }
+
+ public static void runTest(boolean dump, boolean truncate)
+ throws Exception
+ {
+ String format = "javax_imageio_png_1.0";
+ BufferedImage img =
+ new BufferedImage(16, 16, BufferedImage.TYPE_INT_RGB);
+ ImageWriter iw = ImageIO.getImageWritersByMIMEType("image/png").next();
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ ImageOutputStream ios = new MemoryCacheImageOutputStream(os);
+ iw.setOutput(ios);
+ IIOMetadata meta =
+ iw.getDefaultImageMetadata(new ImageTypeSpecifier(img), null);
+ DOMImplementationRegistry registry;
+ registry = DOMImplementationRegistry.newInstance();
+ DOMImplementation impl = registry.getDOMImplementation("XML 3.0");
+ Document doc = impl.createDocument(null, format, null);
+ Element root, itxt, entry;
+ root = doc.getDocumentElement();
+ root.appendChild(itxt = doc.createElement("iTXt"));
+ itxt.appendChild(entry = doc.createElement("iTXtEntry"));
+ entry.setAttribute("keyword", "verbatim");
+ entry.setAttribute("compressionFlag", "false");
+ entry.setAttribute("compressionMethod", "0");
+ entry.setAttribute("languageTag", "x-circled");
+ entry.setAttribute("translatedKeyword", VERBATIM);
+ entry.setAttribute("text", TEXT);
+ itxt.appendChild(entry = doc.createElement("iTXtEntry"));
+ entry.setAttribute("keyword", "compressed");
+ entry.setAttribute("compressionFlag", "true");
+ entry.setAttribute("compressionMethod", "0");
+ entry.setAttribute("languageTag", "x-circled");
+ entry.setAttribute("translatedKeyword", COMPRESSED);
+ entry.setAttribute("text", TEXT);
+ meta.mergeTree(format, root);
+ iw.write(new IIOImage(img, null, meta));
+ iw.dispose();
+
+ byte[] bytes = os.toByteArray();
+ if (dump)
+ System.out.write(bytes);
+ if (findBytes(VBYTES, bytes) < 0)
+ throw new AssertionError("verbatim block not found");
+ if (findBytes(CBYTES, bytes) < 0)
+ throw new AssertionError("compressed block not found");
+ int length = bytes.length;
+ if (truncate)
+ length = findBytes(VBYTES, bytes) + 32;
+
+ ImageReader ir = ImageIO.getImageReader(iw);
+ ByteArrayInputStream is = new ByteArrayInputStream(bytes, 0, length);
+ ImageInputStream iis = new MemoryCacheImageInputStream(is);
+ ir.setInput(iis);
+ meta = ir.getImageMetadata(0);
+ Node node = meta.getAsTree(format);
+ for (node = node.getFirstChild();
+ !"iTXt".equals(node.getNodeName());
+ node = node.getNextSibling());
+ boolean verbatimSeen = false, compressedSeen = false;
+ for (node = node.getFirstChild();
+ node != null;
+ node = node.getNextSibling()) {
+ entry = (Element)node;
+ String keyword = entry.getAttribute("keyword");
+ String translatedKeyword = entry.getAttribute("translatedKeyword");
+ String text = entry.getAttribute("text");
+ if ("verbatim".equals(keyword)) {
+ if (verbatimSeen) throw new AssertionError("Duplicate");
+ verbatimSeen = true;
+ if (!VERBATIM.equals(translatedKeyword))
+ throw new AssertionError("Wrong translated keyword");
+ if (!TEXT.equals(text))
+ throw new AssertionError("Wrong text");
+ }
+ else if ("compressed".equals(keyword)) {
+ if (compressedSeen) throw new AssertionError("Duplicate");
+ compressedSeen = true;
+ if (!COMPRESSED.equals(translatedKeyword))
+ throw new AssertionError("Wrong translated keyword");
+ if (!TEXT.equals(text))
+ throw new AssertionError("Wrong text");
+ }
+ else {
+ throw new AssertionError("Unexpected keyword");
+ }
+ }
+ if (!(verbatimSeen && compressedSeen))
+ throw new AssertionError("Missing chunk");
+ }
+
+ private static final int findBytes(byte[] needle, byte[] haystack) {
+ HAYSTACK: for (int h = 0; h <= haystack.length - needle.length; ++h) {
+ for (int n = 0; n < needle.length; ++n) {
+ if (needle[n] != haystack[h + n]) {
+ continue HAYSTACK;
+ }
+ }
+ return h;
+ }
+ return -1;
+ }
+
+}
From 47a5b98c7f6ad40e66f40caa5d3017a5579870c7 Mon Sep 17 00:00:00 2001
From: Andrew Brygin
Date: Thu, 15 Jan 2009 13:55:30 +0300
Subject: [PATCH 021/292] 6788096: ImageIO SreamCloser causes memory leak in FX
applets
Reviewed-by: igor, prr
---
.../com/sun/imageio/stream/StreamCloser.java | 4 +
.../stream/StreamCloserLeak/run_test.sh | 205 +++++++++++++
.../stream/StreamCloserLeak/test/Main.java | 284 ++++++++++++++++++
.../stream/StreamCloserLeak/testapp/Main.java | 109 +++++++
4 files changed, 602 insertions(+)
create mode 100644 jdk/test/javax/imageio/stream/StreamCloserLeak/run_test.sh
create mode 100644 jdk/test/javax/imageio/stream/StreamCloserLeak/test/Main.java
create mode 100644 jdk/test/javax/imageio/stream/StreamCloserLeak/testapp/Main.java
diff --git a/jdk/src/share/classes/com/sun/imageio/stream/StreamCloser.java b/jdk/src/share/classes/com/sun/imageio/stream/StreamCloser.java
index f39b98eb05d..03c6ce32364 100644
--- a/jdk/src/share/classes/com/sun/imageio/stream/StreamCloser.java
+++ b/jdk/src/share/classes/com/sun/imageio/stream/StreamCloser.java
@@ -94,6 +94,10 @@ public class StreamCloser {
tgn != null;
tg = tgn, tgn = tg.getParent());
streamCloser = new Thread(tg, streamCloserRunnable);
+ /* Set context class loader to null in order to avoid
+ * keeping a strong reference to an application classloader.
+ */
+ streamCloser.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(streamCloser);
return null;
}
diff --git a/jdk/test/javax/imageio/stream/StreamCloserLeak/run_test.sh b/jdk/test/javax/imageio/stream/StreamCloserLeak/run_test.sh
new file mode 100644
index 00000000000..af3e428cb30
--- /dev/null
+++ b/jdk/test/javax/imageio/stream/StreamCloserLeak/run_test.sh
@@ -0,0 +1,205 @@
+#!/bin/ksh -p
+#
+# Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+
+#
+# @test
+# @bug 6788096
+# @summary Test simulates the case of multiple applets executed in
+# the same VM and verifies that ImageIO shutdown hook
+# StreamCloser does not cause a leak of classloaders.
+#
+# @build test.Main
+# @build testapp.Main
+# @run shell run_test.sh
+
+# There are several resources which need to be present before many
+# shell scripts can run. Following are examples of how to check for
+# many common ones.
+#
+# Note that the shell used is the Korn Shell, KSH
+#
+# Also note, it is recommended that make files NOT be used. Rather,
+# put the individual commands directly into this file. That way,
+# it is possible to use command line arguments and other shell tech-
+# niques to find the compiler, etc on different systems. For example,
+# a different path could be used depending on whether this were a
+# Solaris or Win32 machine, which is more difficult (if even possible)
+# in a make file.
+
+
+# Beginning of subroutines:
+status=1
+
+#Call this from anywhere to fail the test with an error message
+# usage: fail "reason why the test failed"
+fail()
+ { echo "The test failed :-("
+ echo "$*" 1>&2
+ echo "exit status was $status"
+ exit $status
+ } #end of fail()
+
+#Call this from anywhere to pass the test with a message
+# usage: pass "reason why the test passed if applicable"
+pass()
+ { echo "The test passed!!!"
+ echo "$*" 1>&2
+ exit 0
+ } #end of pass()
+
+# end of subroutines
+
+
+# The beginning of the script proper
+
+# Checking for proper OS
+OS=`uname -s`
+case "$OS" in
+ SunOS )
+ VAR="One value for Sun"
+ DEFAULT_JDK=/usr/local/java/jdk1.2/solaris
+ FILESEP="/"
+ PATHSEP=":"
+ TMP="/tmp"
+ ;;
+
+ Linux )
+ VAR="A different value for Linux"
+ DEFAULT_JDK=/usr/local/java/jdk1.4/linux-i386
+ FILESEP="/"
+ PATHSEP=":"
+ TMP="/tmp"
+ ;;
+
+ Windows_95 | Windows_98 | Windows_NT | Windows_ME )
+ VAR="A different value for Win32"
+ DEFAULT_JDK=/usr/local/java/jdk1.2/win32
+ FILESEP="\\"
+ PATHSEP=";"
+ TMP=`cd "${SystemRoot}/Temp"; echo ${PWD}`
+ ;;
+
+ # catch all other OSs
+ * )
+ echo "Unrecognized system! $OS"
+ fail "Unrecognized system! $OS"
+ ;;
+esac
+
+# Want this test to run standalone as well as in the harness, so do the
+# following to copy the test's directory into the harness's scratch directory
+# and set all appropriate variables:
+
+if [ -z "${TESTJAVA}" ] ; then
+ # TESTJAVA is not set, so the test is running stand-alone.
+ # TESTJAVA holds the path to the root directory of the build of the JDK
+ # to be tested. That is, any java files run explicitly in this shell
+ # should use TESTJAVA in the path to the java interpreter.
+ # So, we'll set this to the JDK spec'd on the command line. If none
+ # is given on the command line, tell the user that and use a cheesy
+ # default.
+ # THIS IS THE JDK BEING TESTED.
+ if [ -n "$1" ] ;
+ then TESTJAVA=$1
+ else echo "no JDK specified on command line so using default!"
+ TESTJAVA=$DEFAULT_JDK
+ fi
+ TESTSRC=.
+ TESTCLASSES=.
+ STANDALONE=1;
+fi
+echo "JDK under test is: $TESTJAVA"
+
+
+############### YOUR TEST CODE HERE!!!!!!! #############
+
+#All files required for the test should be in the same directory with
+# this file. If converting a standalone test to run with the harness,
+# as long as all files are in the same directory and it returns 0 for
+# pass, you should be able to cut and paste it into here and it will
+# run with the test harness.
+
+# This is an example of running something -- test
+# The stuff below catches the exit status of test then passes or fails
+# this shell test as appropriate ( 0 status is considered a pass here )
+
+echo "Create TestApp.jar..."
+
+if [ -f TestApp.jar ] ; then
+ rm -f TestApp.jar
+fi
+
+${TESTJAVA}/bin/jar -cvf TestApp.jar -C ${TESTCLASSES} testapp
+
+if [ $? -ne "0" ] ; then
+ fail "Failed to create TestApp.jar"
+fi
+
+echo "Create Test.jar..."
+if [ -f Test.jar ] ; then
+ rm -f Test.jar
+fi
+
+${TESTJAVA}/bin/jar -cvf Test.jar -C ${TESTCLASSES} test
+
+if [ $? -ne 0 ] ; then
+ fail "Failed to create Test.jar"
+fi
+
+# Prepare temp dir for cahce files
+mkdir ./tmp
+if [ $? -ne 0 ] ; then
+ fail "Unable to create temp directory."
+fi
+
+# Verify that all classoladers are destroyed
+${TESTJAVA}/bin/java -cp Test.jar test.Main
+if [ $? -ne 0 ] ; then
+ fail "Test FAILED: some classloaders weren't destroyed."
+fi
+
+
+# Verify that ImageIO shutdown hook works correcly
+${TESTJAVA}/bin/java -cp Test.jar -DforgetSomeStreams=true test.Main
+if [ $? -ne 0 ] ; then
+ fail "Test FAILED: some classloaders weren't destroyed of shutdown hook failed."
+fi
+
+# sanity check: verify that all cache files were deleted
+cache_files=`ls tmp`
+
+if [ "x${cache_files}" != "x" ] ; then
+ echo "WARNING: some cache files was not deleted: ${cache_files}"
+fi
+
+echo "Test done."
+
+status=$?
+
+if [ $status -eq "0" ] ; then
+ pass ""
+else
+ fail "Test failed due to test plugin was not found."
+fi
+
diff --git a/jdk/test/javax/imageio/stream/StreamCloserLeak/test/Main.java b/jdk/test/javax/imageio/stream/StreamCloserLeak/test/Main.java
new file mode 100644
index 00000000000..b87299967c6
--- /dev/null
+++ b/jdk/test/javax/imageio/stream/StreamCloserLeak/test/Main.java
@@ -0,0 +1,284 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package test;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.ref.Reference;
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.WeakReference;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.HashMap;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.WeakHashMap;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.CountDownLatch;
+import javax.imageio.stream.ImageInputStream;
+import sun.awt.AppContext;
+import sun.awt.SunToolkit;
+
+public class Main {
+
+ private static ThreadGroup appsThreadGroup;
+
+ private static WeakHashMap refs =
+ new WeakHashMap();
+
+ /** Collection to simulate forgrotten streams **/
+ private static HashMap strongRefs =
+ new HashMap();
+
+ private static ConcurrentLinkedQueue problems =
+ new ConcurrentLinkedQueue();
+
+ private static AppContext mainAppContext = null;
+
+ private static CountDownLatch doneSignal;
+
+ private static final int gcTimeout =
+ Integer.getInteger("gcTimeout", 10).intValue();
+
+ private static boolean forgetSomeStreams =
+ Boolean.getBoolean("forgetSomeStreams");
+
+ public static void main(String[] args) throws IOException {
+ mainAppContext = SunToolkit.createNewAppContext();
+ System.out.println("Current context class loader: " +
+ Thread.currentThread().getContextClassLoader());
+
+ appsThreadGroup = new ThreadGroup("MyAppsThreadGroup");
+
+ File jar = new File("TestApp.jar");
+ if (!jar.exists()) {
+ System.out.println(jar.getAbsolutePath() + " was not found!\n" +
+ "Please install the jar with test application correctly!");
+ throw new RuntimeException("Test failed: no TestApp.jar");
+ }
+
+ URL[] urls = new URL[]{jar.toURL()};
+
+ int numApps = Integer.getInteger("numApps", 20).intValue();
+
+ doneSignal = new CountDownLatch(numApps);
+ int cnt = 0;
+ while (cnt++ < numApps) {
+ launch(urls, "testapp.Main", "launch");
+
+ checkErrors();
+ }
+
+ System.out.println("Wait for apps completion....");
+
+ try {
+ doneSignal.await();
+ } catch (InterruptedException e) {
+ }
+
+ System.out.println("All apps finished.");
+
+ System.gc();
+
+ System.out.flush();
+
+ System.out.println("Enumerate strong refs:");
+ for (String is : strongRefs.keySet()) {
+ System.out.println("-> " + is);
+ }
+
+ System.out.println("=======================");
+
+ // wait few seconds
+ waitAndGC(gcTimeout);
+
+ doneSignal = new CountDownLatch(1);
+
+ Runnable workaround = new Runnable() {
+
+ public void run() {
+ AppContext ctx = null;
+ try {
+ ctx = SunToolkit.createNewAppContext();
+ } catch (Throwable e) {
+ // ignore...
+ } finally {
+ doneSignal.countDown();
+ }
+ }
+ };
+
+ Thread wt = new Thread(appsThreadGroup, workaround, "Workaround");
+ wt.setContextClassLoader(new MyClassLoader(urls, "workaround"));
+ wt.start();
+ wt = null;
+ workaround = null;
+
+ System.out.println("Wait for workaround completion...");
+
+ try {
+ doneSignal.await();
+ } catch (InterruptedException e) {
+ }
+
+ // give a chance to GC
+ waitAndGC(gcTimeout);
+
+ if (!refs.isEmpty()) {
+ System.out.println("Classloaders still alive:");
+
+ for (MyClassLoader l : refs.keySet()) {
+ String val = refs.get(l);
+
+ if (val == null) {
+ throw new RuntimeException("Test FAILED: Invalid classloader name");
+ }
+ System.out.println("->" + val + (strongRefs.get(val) != null ?
+ " (has strong ref)" : ""));
+ if (strongRefs.get(val) == null) {
+ throw new RuntimeException("Test FAILED: exta class loader is detected! ");
+ }
+ }
+ } else {
+ System.out.println("No alive class loaders!!");
+ }
+ System.out.println("Test PASSED.");
+ }
+
+ private static void waitAndGC(int sec) {
+ int cnt = sec;
+ System.out.print("Wait ");
+ while (cnt-- > 0) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ }
+ // do GC every 3 seconds
+ if (cnt % 3 == 2) {
+ System.gc();
+ System.out.print("+");
+ } else {
+ System.out.print(".");
+ }
+ checkErrors();
+ }
+ System.out.println("");
+ }
+
+ private static void checkErrors() {
+ while (!problems.isEmpty()) {
+ Throwable theProblem = problems.poll();
+ System.out.println("Test FAILED!");
+ do {
+ theProblem.printStackTrace(System.out);
+ theProblem = theProblem.getCause();
+ } while (theProblem != null);
+ throw new RuntimeException("Test FAILED");
+ }
+ }
+ static int counter = 0;
+
+ private static void launch(URL[] urls, final String className,
+ final String methodName)
+ {
+ final String uniqClassName = "testapp/Uniq" + counter;
+ final boolean saveStrongRef = forgetSomeStreams ? (counter % 5 == 4) : false;
+
+ System.out.printf("%s: launch the app\n", uniqClassName);
+ Runnable launchIt = new Runnable() {
+ public void run() {
+ AppContext ctx = SunToolkit.createNewAppContext();
+
+ try {
+ Class appMain =
+ ctx.getContextClassLoader().loadClass(className);
+ Method launch = appMain.getDeclaredMethod(methodName,
+ strongRefs.getClass());
+
+ Constructor c = appMain.getConstructor(String.class,
+ problems.getClass());
+
+ Object o = c.newInstance(uniqClassName, problems);
+
+ if (saveStrongRef) {
+ System.out.printf("%s: force strong ref\n",
+ uniqClassName);
+ launch.invoke(o, strongRefs);
+ } else {
+ HashMap empty = null;
+ launch.invoke(o, empty);
+ }
+
+ ctx = null;
+ } catch (Throwable e) {
+ problems.add(e);
+ } finally {
+ doneSignal.countDown();
+ }
+ }
+ };
+
+ MyClassLoader appClassLoader = new MyClassLoader(urls, uniqClassName);
+
+ refs.put(appClassLoader, uniqClassName);
+
+ Thread appThread = new Thread(appsThreadGroup, launchIt,
+ "AppThread" + counter++);
+ appThread.setContextClassLoader(appClassLoader);
+
+ appThread.start();
+ launchIt = null;
+ appThread = null;
+ appClassLoader = null;
+ }
+
+ private static class MyClassLoader extends URLClassLoader {
+
+ private static boolean verbose =
+ Boolean.getBoolean("verboseClassLoading");
+ private String uniqClassName;
+
+ public MyClassLoader(URL[] urls, String uniq) {
+ super(urls);
+
+ uniqClassName = uniq;
+ }
+
+ public Class loadClass(String name) throws ClassNotFoundException {
+ if (verbose) {
+ System.out.printf("%s: load class %s\n", uniqClassName, name);
+ }
+ if (uniqClassName.equals(name)) {
+ return Object.class;
+ }
+ return super.loadClass(name);
+ }
+
+ public String toString() {
+ return "MyClassLoader(" + uniqClassName + ")";
+ }
+ }
+}
diff --git a/jdk/test/javax/imageio/stream/StreamCloserLeak/testapp/Main.java b/jdk/test/javax/imageio/stream/StreamCloserLeak/testapp/Main.java
new file mode 100644
index 00000000000..3c4bb5ec3ff
--- /dev/null
+++ b/jdk/test/javax/imageio/stream/StreamCloserLeak/testapp/Main.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package testapp;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import javax.imageio.stream.FileCacheImageInputStream;
+import javax.imageio.stream.ImageInputStream;
+
+public class Main {
+
+ public static void main(String[] args) {
+ Main o = new Main("testapp.some.class", null);
+ o.launch(null);
+ }
+
+ private final String uniqClassName;
+ private final ConcurrentLinkedQueue problems;
+
+ public Main(String uniq, ConcurrentLinkedQueue p) {
+ uniqClassName = uniq;
+ problems = p;
+ }
+
+ public void launch(HashMap refs) {
+ System.out.printf("%s: current context class loader: %s\n",
+ uniqClassName,
+ Thread.currentThread().getContextClassLoader());
+ try {
+ byte[] data = new byte[1024];
+ ByteArrayInputStream bais = new ByteArrayInputStream(data);
+ MyImageInputStream iis = new MyImageInputStream(bais,
+ uniqClassName,
+ problems);
+ if (refs != null) {
+ System.out.printf("%s: added to strong store\n",
+ uniqClassName);
+ refs.put(uniqClassName, iis);
+ }
+ iis.read();
+ //leave stream open : let's shutdown hook work!
+ } catch (IOException e) {
+ problems.add(e);
+ }
+ }
+
+ private static class MyImageInputStream extends FileCacheImageInputStream {
+ private final String uniqClassName;
+ private ConcurrentLinkedQueue problems;
+ public MyImageInputStream(InputStream is, String uniq,
+ ConcurrentLinkedQueue p) throws IOException
+ {
+ super(is, new File("tmp"));
+ uniqClassName = uniq;
+ problems = p;
+ }
+
+ @Override
+ public void close() throws IOException {
+ Test t = new Test();
+ try {
+ t.doTest(uniqClassName);
+ } catch (Throwable e) {
+ problems.add(e);
+ }
+
+ super.close();
+
+ problems = null;
+ }
+ }
+}
+
+class Test {
+ public void doTest(String uniqClassName) throws ClassNotFoundException {
+ System.out.printf("%s: Current thread: %s\n", uniqClassName,
+ Thread.currentThread());
+
+ ClassLoader thisCL = this.getClass().getClassLoader();
+ Class uniq = thisCL.loadClass(uniqClassName);
+
+ System.out.printf("%s: test is done!\n",uniqClassName);
+ }
+}
From 8c2a336349c8ff82c6ab4484a68ca4b7dc4e11e1 Mon Sep 17 00:00:00 2001
From: Andrew Brygin
Date: Fri, 23 Jan 2009 17:43:29 +0300
Subject: [PATCH 022/292] 6795544: GIFImageWriter does not write the subImage
of BufferedImage to a file correctly
Reviewed-by: igor, prr
---
.../imageio/plugins/gif/GIFImageWriter.java | 16 +-
.../plugins/gif/EncodeSubImageTest.java | 161 ++++++++++++++++++
2 files changed, 175 insertions(+), 2 deletions(-)
create mode 100644 jdk/test/javax/imageio/plugins/gif/EncodeSubImageTest.java
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageWriter.java b/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageWriter.java
index 4c7903bfe84..89f735d8793 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageWriter.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageWriter.java
@@ -55,6 +55,7 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import com.sun.imageio.plugins.common.LZWCompressor;
import com.sun.imageio.plugins.common.PaletteBuilder;
+import sun.awt.image.ByteComponentRaster;
public class GIFImageWriter extends ImageWriter {
private static final boolean DEBUG = false; // XXX false for release!
@@ -905,10 +906,18 @@ public class GIFImageWriter extends ImageWriter {
LZWCompressor compressor =
new LZWCompressor(stream, initCodeSize, false);
+ /* At this moment we know that input image is indexed image.
+ * We can directly copy data iff:
+ * - no subsampling required (periodX = 1, periodY = 0)
+ * - we can access data directly (image is non-tiled,
+ * i.e. image data are in single block)
+ * - we can calculate offset in data buffer (next 3 lines)
+ */
boolean isOptimizedCase =
periodX == 1 && periodY == 1 &&
- sampleModel instanceof ComponentSampleModel &&
image.getNumXTiles() == 1 && image.getNumYTiles() == 1 &&
+ sampleModel instanceof ComponentSampleModel &&
+ image.getTile(0, 0) instanceof ByteComponentRaster &&
image.getTile(0, 0).getDataBuffer() instanceof DataBufferByte;
int numRowsWritten = 0;
@@ -921,11 +930,14 @@ public class GIFImageWriter extends ImageWriter {
if (DEBUG) System.out.println("Writing interlaced");
if (isOptimizedCase) {
- Raster tile = image.getTile(0, 0);
+ ByteComponentRaster tile =
+ (ByteComponentRaster)image.getTile(0, 0);
byte[] data = ((DataBufferByte)tile.getDataBuffer()).getData();
ComponentSampleModel csm =
(ComponentSampleModel)tile.getSampleModel();
int offset = csm.getOffset(sourceXOffset, sourceYOffset, 0);
+ // take into account the raster data offset
+ offset += tile.getDataOffset(0);
int lineStride = csm.getScanlineStride();
writeRowsOpt(data, offset, lineStride, compressor,
diff --git a/jdk/test/javax/imageio/plugins/gif/EncodeSubImageTest.java b/jdk/test/javax/imageio/plugins/gif/EncodeSubImageTest.java
new file mode 100644
index 00000000000..407242161c2
--- /dev/null
+++ b/jdk/test/javax/imageio/plugins/gif/EncodeSubImageTest.java
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug 6795544
+ *
+ * @summary Test verifes that Image I/O gif writer correctly handles
+ * buffered images based on translated reasters (typically
+ * produced by getSubImage() method).
+ *
+ * @run main EncodeSubImageTest gif
+ */
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.image.BufferedImage;
+import java.awt.image.Raster;
+import java.io.File;
+import java.io.IOException;
+import javax.imageio.IIOImage;
+import javax.imageio.ImageIO;
+import javax.imageio.ImageWriteParam;
+import javax.imageio.ImageWriter;
+import javax.imageio.stream.ImageOutputStream;
+
+public class EncodeSubImageTest {
+ private static String format = "gif";
+ private static ImageWriter writer;
+ private static String file_suffix;
+ private static final int subSampleX = 2;
+ private static final int subSampleY = 2;
+
+ public static void main(String[] args) throws IOException {
+ if (args.length > 0) {
+ format = args[0];
+ }
+
+ writer = ImageIO.getImageWritersByFormatName(format).next();
+
+ file_suffix =writer.getOriginatingProvider().getFileSuffixes()[0];
+
+ BufferedImage src = createTestImage();
+ EncodeSubImageTest m1 = new EncodeSubImageTest(src);
+ m1.doTest("test_src");
+
+ BufferedImage sub = src.getSubimage(subImageOffset, subImageOffset,
+ src.getWidth() - 2 * subImageOffset,
+ src.getHeight() - 2 * subImageOffset);
+ EncodeSubImageTest m2 = new EncodeSubImageTest(sub);
+ m2.doTest("test_sub");
+ }
+
+ BufferedImage img;
+
+ public EncodeSubImageTest(BufferedImage img) {
+ this.img = img;
+ }
+
+ public void doTest(String prefix) throws IOException {
+ System.out.println(prefix);
+ File f = new File(prefix + file_suffix);
+ write(f, false);
+ verify(f, false);
+
+ System.out.println(prefix + "_subsampled");
+ f = new File(prefix + "_subsampled");
+ write(f, true);
+ verify(f, true);
+
+ System.out.println(prefix + ": Test PASSED.");
+ }
+
+ private static final int subImageOffset = 10;
+
+ private void verify(File f, boolean isSubsampled) {
+ BufferedImage dst = null;
+ try {
+ dst = ImageIO.read(f);
+ } catch (IOException e) {
+ throw new RuntimeException("Test FAILED: can't readin test image " +
+ f.getAbsolutePath(), e);
+ }
+ if (dst == null) {
+ throw new RuntimeException("Test FAILED: no dst image available.");
+ }
+
+ checkPixel(dst, 0, 0, isSubsampled);
+
+ checkPixel(dst, img.getWidth() / 2, img.getHeight() / 2, isSubsampled);
+ }
+
+ private void checkPixel(BufferedImage dst, int x, int y,
+ boolean isSubsampled)
+ {
+ int dx = isSubsampled ? x / subSampleX : x;
+ int dy = isSubsampled ? y / subSampleY : y;
+ int src_rgb = img.getRGB(x, y);
+ System.out.printf("src_rgb: %x\n", src_rgb);
+
+ int dst_rgb = dst.getRGB(dx, dy);
+ System.out.printf("dst_rgb: %x\n", dst_rgb);
+
+ if (src_rgb != dst_rgb) {
+ throw new RuntimeException("Test FAILED: invalid color in dst");
+ }
+ }
+
+ private static BufferedImage createTestImage() {
+ int w = 100;
+ int h = 100;
+
+ BufferedImage src = new BufferedImage(w, h,
+ BufferedImage.TYPE_BYTE_INDEXED);
+ Graphics g = src.createGraphics();
+ g.setColor(Color.red);
+ g.fillRect(0, 0, w, h);
+ g.setColor(Color.green);
+ g.fillRect(subImageOffset, subImageOffset,
+ w - 2 * subImageOffset, h - 2* subImageOffset);
+ g.setColor(Color.blue);
+ g.fillRect(2 * subImageOffset, 2 * subImageOffset,
+ w - 4 * subImageOffset, h - 4 * subImageOffset);
+ g.dispose();
+
+ return src;
+ }
+
+ private void write(File f, boolean subsample) throws IOException {
+ ImageOutputStream ios = ImageIO.createImageOutputStream(f);
+
+ writer.setOutput(ios);
+ ImageWriteParam p = writer.getDefaultWriteParam();
+ if (subsample) {
+ p.setSourceSubsampling(subSampleX, subSampleY, 0, 0);
+ }
+ writer.write(null, new IIOImage(img, null, null), p);
+ ios.close();
+ writer.reset();
+ }
+}
From 2726f2a3621dd2562d4fb660b4c3d376c65027aa Mon Sep 17 00:00:00 2001
From: Andrew Brygin
Date: Fri, 23 Jan 2009 21:14:31 +0300
Subject: [PATCH 023/292] 6793818: JpegImageReader is too greedy creating color
profiles
Reviewed-by: igor, prr
---
.../classes/java/awt/color/ICC_Profile.java | 78 +++++++++++--------
.../sun/java2d/cmm/ProfileActivator.java | 3 +-
.../sun/java2d/cmm/ProfileDeferralMgr.java | 27 ++++++-
3 files changed, 71 insertions(+), 37 deletions(-)
diff --git a/jdk/src/share/classes/java/awt/color/ICC_Profile.java b/jdk/src/share/classes/java/awt/color/ICC_Profile.java
index 3ef8d437bb4..705d2560e1f 100644
--- a/jdk/src/share/classes/java/awt/color/ICC_Profile.java
+++ b/jdk/src/share/classes/java/awt/color/ICC_Profile.java
@@ -737,7 +737,7 @@ public class ICC_Profile implements Serializable {
ICC_Profile(ProfileDeferralInfo pdi) {
this.deferralInfo = pdi;
this.profileActivator = new ProfileActivator() {
- public void activate() {
+ public void activate() throws ProfileDataException {
activateDeferredProfile();
}
};
@@ -830,20 +830,16 @@ public class ICC_Profile implements Serializable {
case ColorSpace.CS_sRGB:
synchronized(ICC_Profile.class) {
if (sRGBprofile == null) {
- try {
- /*
- * Deferral is only used for standard profiles.
- * Enabling the appropriate access privileges is handled
- * at a lower level.
- */
- sRGBprofile = getDeferredInstance(
- new ProfileDeferralInfo("sRGB.pf",
- ColorSpace.TYPE_RGB,
- 3, CLASS_DISPLAY));
- } catch (IOException e) {
- throw new IllegalArgumentException(
- "Can't load standard profile: sRGB.pf");
- }
+ /*
+ * Deferral is only used for standard profiles.
+ * Enabling the appropriate access privileges is handled
+ * at a lower level.
+ */
+ ProfileDeferralInfo pInfo =
+ new ProfileDeferralInfo("sRGB.pf",
+ ColorSpace.TYPE_RGB, 3,
+ CLASS_DISPLAY);
+ sRGBprofile = getDeferredInstance(pInfo);
}
thisProfile = sRGBprofile;
}
@@ -853,7 +849,11 @@ public class ICC_Profile implements Serializable {
case ColorSpace.CS_CIEXYZ:
synchronized(ICC_Profile.class) {
if (XYZprofile == null) {
- XYZprofile = getStandardProfile("CIEXYZ.pf");
+ ProfileDeferralInfo pInfo =
+ new ProfileDeferralInfo("CIEXYZ.pf",
+ ColorSpace.TYPE_XYZ, 3,
+ CLASS_DISPLAY);
+ XYZprofile = getDeferredInstance(pInfo);
}
thisProfile = XYZprofile;
}
@@ -863,7 +863,11 @@ public class ICC_Profile implements Serializable {
case ColorSpace.CS_PYCC:
synchronized(ICC_Profile.class) {
if (PYCCprofile == null) {
- PYCCprofile = getStandardProfile("PYCC.pf");
+ ProfileDeferralInfo pInfo =
+ new ProfileDeferralInfo("PYCC.pf",
+ ColorSpace.TYPE_3CLR, 3,
+ CLASS_DISPLAY);
+ PYCCprofile = getDeferredInstance(pInfo);
}
thisProfile = PYCCprofile;
}
@@ -873,7 +877,11 @@ public class ICC_Profile implements Serializable {
case ColorSpace.CS_GRAY:
synchronized(ICC_Profile.class) {
if (GRAYprofile == null) {
- GRAYprofile = getStandardProfile("GRAY.pf");
+ ProfileDeferralInfo pInfo =
+ new ProfileDeferralInfo("GRAY.pf",
+ ColorSpace.TYPE_GRAY, 1,
+ CLASS_DISPLAY);
+ GRAYprofile = getDeferredInstance(pInfo);
}
thisProfile = GRAYprofile;
}
@@ -883,7 +891,11 @@ public class ICC_Profile implements Serializable {
case ColorSpace.CS_LINEAR_RGB:
synchronized(ICC_Profile.class) {
if (LINEAR_RGBprofile == null) {
- LINEAR_RGBprofile = getStandardProfile("LINEAR_RGB.pf");
+ ProfileDeferralInfo pInfo =
+ new ProfileDeferralInfo("LINEAR_RGB.pf",
+ ColorSpace.TYPE_RGB, 3,
+ CLASS_DISPLAY);
+ LINEAR_RGBprofile = getDeferredInstance(pInfo);
}
thisProfile = LINEAR_RGBprofile;
}
@@ -1047,9 +1059,7 @@ public class ICC_Profile implements Serializable {
* code will take care of access privileges.
* @see activateDeferredProfile()
*/
- static ICC_Profile getDeferredInstance(ProfileDeferralInfo pdi)
- throws IOException {
-
+ static ICC_Profile getDeferredInstance(ProfileDeferralInfo pdi) {
if (!ProfileDeferralMgr.deferring) {
return getStandardProfile(pdi.filename);
}
@@ -1063,33 +1073,37 @@ public class ICC_Profile implements Serializable {
}
- void activateDeferredProfile() {
- byte profileData[];
- FileInputStream fis;
- String fileName = deferralInfo.filename;
+ void activateDeferredProfile() throws ProfileDataException {
+ byte profileData[];
+ FileInputStream fis;
+ String fileName = deferralInfo.filename;
profileActivator = null;
deferralInfo = null;
if ((fis = openProfile(fileName)) == null) {
- throw new IllegalArgumentException("Cannot open file " + fileName);
+ throw new ProfileDataException("Cannot open file " + fileName);
}
try {
profileData = getProfileDataFromStream(fis);
fis.close(); /* close the file */
}
catch (IOException e) {
- throw new IllegalArgumentException("Invalid ICC Profile Data" +
- fileName);
+ ProfileDataException pde = new
+ ProfileDataException("Invalid ICC Profile Data" + fileName);
+ pde.initCause(e);
+ throw pde;
}
if (profileData == null) {
- throw new IllegalArgumentException("Invalid ICC Profile Data" +
+ throw new ProfileDataException("Invalid ICC Profile Data" +
fileName);
}
try {
ID = CMSManager.getModule().loadProfile(profileData);
} catch (CMMException c) {
- throw new IllegalArgumentException("Invalid ICC Profile Data" +
- fileName);
+ ProfileDataException pde = new
+ ProfileDataException("Invalid ICC Profile Data" + fileName);
+ pde.initCause(c);
+ throw pde;
}
}
diff --git a/jdk/src/share/classes/sun/java2d/cmm/ProfileActivator.java b/jdk/src/share/classes/sun/java2d/cmm/ProfileActivator.java
index 32c4e477fb9..f5a28f84232 100644
--- a/jdk/src/share/classes/sun/java2d/cmm/ProfileActivator.java
+++ b/jdk/src/share/classes/sun/java2d/cmm/ProfileActivator.java
@@ -25,6 +25,7 @@
package sun.java2d.cmm;
+import java.awt.color.ProfileDataException;
/**
* An interface to allow the ProfileDeferralMgr to activate a
@@ -35,6 +36,6 @@ public interface ProfileActivator {
/**
* Activate a previously deferred ICC_Profile object.
*/
- public void activate();
+ public void activate() throws ProfileDataException;
}
diff --git a/jdk/src/share/classes/sun/java2d/cmm/ProfileDeferralMgr.java b/jdk/src/share/classes/sun/java2d/cmm/ProfileDeferralMgr.java
index 41804c3fd9b..116f339da0a 100644
--- a/jdk/src/share/classes/sun/java2d/cmm/ProfileDeferralMgr.java
+++ b/jdk/src/share/classes/sun/java2d/cmm/ProfileDeferralMgr.java
@@ -25,6 +25,7 @@
package sun.java2d.cmm;
+import java.awt.color.ProfileDataException;
import java.util.Vector;
@@ -39,7 +40,7 @@ import java.util.Vector;
public class ProfileDeferralMgr {
public static boolean deferring = true;
- private static Vector aVector;
+ private static Vector aVector;
/**
* Records a ProfileActivator object whose activate method will
@@ -51,7 +52,7 @@ public class ProfileDeferralMgr {
return;
}
if (aVector == null) {
- aVector = new Vector(3, 3);
+ aVector = new Vector(3, 3);
}
aVector.addElement(pa);
return;
@@ -89,8 +90,26 @@ public class ProfileDeferralMgr {
return;
}
n = aVector.size();
- for (i = 0; i < n; i++) {
- ((ProfileActivator) aVector.get(i)).activate();
+ for (ProfileActivator pa : aVector) {
+ try {
+ pa.activate();
+ } catch (ProfileDataException e) {
+ /*
+ * Ignore profile activation error for now:
+ * such exception is pssible due to absence
+ * or corruption of standard color profile.
+ * As for now we expect all profiles should
+ * be shiped with jre and presence of this
+ * exception is indication of some configuration
+ * problem in jre installation.
+ *
+ * NB: we still are greedy loading deferred profiles
+ * and load them all if any of them is needed.
+ * Therefore broken profile (if any) might be never used.
+ * If there will be attempt to use broken profile then
+ * it will result in CMMException.
+ */
+ }
}
aVector.removeAllElements();
aVector = null;
From 55076b2558a836ff91b27c6cee714f39cae75878 Mon Sep 17 00:00:00 2001
From: Red Hat
Date: Wed, 28 Jan 2009 09:38:55 -0800
Subject: [PATCH 024/292] 6793344: BasicStroke's first element dash pattern is
not a dash
Reviewed-by: igor, flar
---
.../classes/sun/java2d/pisces/Dasher.java | 2 +-
jdk/test/sun/pisces/DashStrokeTest.java | 86 +++++++++++++++++++
2 files changed, 87 insertions(+), 1 deletion(-)
create mode 100644 jdk/test/sun/pisces/DashStrokeTest.java
diff --git a/jdk/src/share/classes/sun/java2d/pisces/Dasher.java b/jdk/src/share/classes/sun/java2d/pisces/Dasher.java
index 81c92f44a60..99215e01b8e 100644
--- a/jdk/src/share/classes/sun/java2d/pisces/Dasher.java
+++ b/jdk/src/share/classes/sun/java2d/pisces/Dasher.java
@@ -120,7 +120,7 @@ public class Dasher extends LineSink {
// Normalize so 0 <= phase < dash[0]
int idx = 0;
- dashOn = false;
+ dashOn = true;
int d;
while (phase >= (d = dash[idx])) {
phase -= d;
diff --git a/jdk/test/sun/pisces/DashStrokeTest.java b/jdk/test/sun/pisces/DashStrokeTest.java
new file mode 100644
index 00000000000..f77acbeacfe
--- /dev/null
+++ b/jdk/test/sun/pisces/DashStrokeTest.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+ * @summary verify that first element is a dash
+ * @bug 6793344
+ */
+
+import java.awt.*;
+import java.awt.image.*;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
+import javax.swing.WindowConstants;
+
+public class DashStrokeTest extends Component {
+
+ static BufferedImage bi;
+ static boolean printed = false;
+
+ public Dimension getPreferredSize() {
+ return new Dimension(200,200);
+ }
+
+ public static void drawGui() {
+ bi = new BufferedImage(200, 20, BufferedImage.TYPE_INT_RGB);
+ Graphics2D g2d = bi.createGraphics();
+ BasicStroke dashStroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND,
+ BasicStroke.JOIN_ROUND, 1.0f, new float[] { 0.0f, 200 },
+ 1.0f);
+
+ g2d.setStroke(dashStroke);
+ g2d.setColor(Color.RED);
+ g2d.drawLine(5,10, 100,10);
+ printed =true;
+ }
+
+ public static void main(String[] args) {
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ @Override
+ public void run() {
+ drawGui();
+ }
+
+ });
+ } catch (Exception e) {
+ }
+
+ if (printed) {
+ checkBI(bi, Color.RED);
+ }
+ }
+
+ static void checkBI(BufferedImage bi, Color badColor) {
+ int badrgb = badColor.getRGB();
+
+ int col = bi.getRGB(6, 9);
+ if (col == badrgb) {
+ throw new RuntimeException("A pixel was turned on. ");
+ }
+ }
+}
+
From 2a2bbe287903c73e0de793d2f1c6a2bb88125151 Mon Sep 17 00:00:00 2001
From: Andrew Brygin
Date: Thu, 29 Jan 2009 13:19:34 +0300
Subject: [PATCH 025/292] 6631559: Registration of ImageIO plugins should not
cause loading of jpeg.dlli and cmm.dll
Reviewed-by: igor, prr
---
.../plugins/jpeg/JFIFMarkerSegment.java | 2 +-
.../com/sun/imageio/plugins/jpeg/JPEG.java | 25 +-
.../imageio/plugins/jpeg/JPEGImageReader.java | 26 +-
.../plugins/jpeg/JPEGImageReaderSpi.java | 22 --
.../imageio/plugins/jpeg/JPEGImageWriter.java | 10 +-
.../plugins/jpeg/JPEGImageWriterSpi.java | 19 --
.../imageio/plugins/jpeg/JPEGMetadata.java | 2 +-
.../javax/imageio/ImageTypeSpecifier.java | 247 +++++++++---------
8 files changed, 167 insertions(+), 186 deletions(-)
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JFIFMarkerSegment.java b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JFIFMarkerSegment.java
index 883bd1a7447..d59a8885c9b 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JFIFMarkerSegment.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JFIFMarkerSegment.java
@@ -1003,7 +1003,7 @@ class JFIFMarkerSegment extends MarkerSegment {
3,
new int [] {0, 1, 2},
null);
- ColorModel cm = new ComponentColorModel(JPEG.sRGB,
+ ColorModel cm = new ComponentColorModel(JPEG.JCS.sRGB,
false,
false,
ColorModel.OPAQUE,
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEG.java b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEG.java
index b16669bc089..3ed5c5083c3 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEG.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEG.java
@@ -208,15 +208,24 @@ public class JPEG {
public static final int [] bOffsRGB = { 2, 1, 0 };
- protected static final ColorSpace sRGB =
- ColorSpace.getInstance(ColorSpace.CS_sRGB);
- protected static ColorSpace YCC = null; // Can't be final
+ /* These are kept in the inner class to avoid static initialization
+ * of the CMM class until someone actually needs it.
+ * (e.g. do not init CMM on the request for jpeg mime types)
+ */
+ public static class JCS {
+ public static final ColorSpace sRGB =
+ ColorSpace.getInstance(ColorSpace.CS_sRGB);
+ public static final ColorSpace YCC;
- static {
- try {
- YCC = ColorSpace.getInstance(ColorSpace.CS_PYCC);
- } catch (IllegalArgumentException e) {
- // PYCC.pf may not always be installed
+ static {
+ ColorSpace cs = null;
+ try {
+ cs = ColorSpace.getInstance(ColorSpace.CS_PYCC);
+ } catch (IllegalArgumentException e) {
+ // PYCC.pf may not always be installed
+ } finally {
+ YCC = cs;
+ }
}
}
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java
index 48afd2f354c..faf8261544c 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java
@@ -228,31 +228,31 @@ public class JPEGImageReader extends ImageReader {
(BufferedImage.TYPE_BYTE_GRAY);
defaultTypes[JPEG.JCS_RGB] =
ImageTypeSpecifier.createInterleaved
- (JPEG.sRGB,
+ (JPEG.JCS.sRGB,
JPEG.bOffsRGB,
DataBuffer.TYPE_BYTE,
false,
false);
defaultTypes[JPEG.JCS_RGBA] =
ImageTypeSpecifier.createPacked
- (JPEG.sRGB,
+ (JPEG.JCS.sRGB,
0xff000000,
0x00ff0000,
0x0000ff00,
0x000000ff,
DataBuffer.TYPE_INT,
false);
- if (JPEG.YCC != null) {
+ if (JPEG.JCS.YCC != null) {
defaultTypes[JPEG.JCS_YCC] =
ImageTypeSpecifier.createInterleaved
- (JPEG.YCC,
+ (JPEG.JCS.YCC,
JPEG.bandOffsets[2],
DataBuffer.TYPE_BYTE,
false,
false);
defaultTypes[JPEG.JCS_YCCA] =
ImageTypeSpecifier.createInterleaved
- (JPEG.YCC,
+ (JPEG.JCS.YCC,
JPEG.bandOffsets[3],
DataBuffer.TYPE_BYTE,
true,
@@ -774,7 +774,7 @@ public class JPEGImageReader extends ImageReader {
case JPEG.JCS_RGB:
list.add(raw);
list.add(getImageType(JPEG.JCS_GRAYSCALE));
- if (JPEG.YCC != null) {
+ if (JPEG.JCS.YCC != null) {
list.add(getImageType(JPEG.JCS_YCC));
}
break;
@@ -811,7 +811,7 @@ public class JPEGImageReader extends ImageReader {
}
list.add(getImageType(JPEG.JCS_GRAYSCALE));
- if (JPEG.YCC != null) { // Might be null if PYCC.pf not installed
+ if (JPEG.JCS.YCC != null) { // Might be null if PYCC.pf not installed
list.add(getImageType(JPEG.JCS_YCC));
}
break;
@@ -893,7 +893,7 @@ public class JPEGImageReader extends ImageReader {
(!cs.isCS_sRGB()) &&
(cm.getNumComponents() == numComponents)) {
// Target isn't sRGB, so convert from sRGB to the target
- convert = new ColorConvertOp(JPEG.sRGB, cs, null);
+ convert = new ColorConvertOp(JPEG.JCS.sRGB, cs, null);
} else if (csType != ColorSpace.TYPE_RGB) {
throw new IIOException("Incompatible color conversion");
}
@@ -906,18 +906,18 @@ public class JPEGImageReader extends ImageReader {
}
break;
case JPEG.JCS_YCC:
- if (JPEG.YCC == null) { // We can't do YCC at all
+ if (JPEG.JCS.YCC == null) { // We can't do YCC at all
throw new IIOException("Incompatible color conversion");
}
- if ((cs != JPEG.YCC) &&
+ if ((cs != JPEG.JCS.YCC) &&
(cm.getNumComponents() == numComponents)) {
- convert = new ColorConvertOp(JPEG.YCC, cs, null);
+ convert = new ColorConvertOp(JPEG.JCS.YCC, cs, null);
}
break;
case JPEG.JCS_YCCA:
// No conversions available; image must be YCCA
- if ((JPEG.YCC == null) || // We can't do YCC at all
- (cs != JPEG.YCC) ||
+ if ((JPEG.JCS.YCC == null) || // We can't do YCC at all
+ (cs != JPEG.JCS.YCC) ||
(cm.getNumComponents() != numComponents)) {
throw new IIOException("Incompatible color conversion");
}
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReaderSpi.java b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReaderSpi.java
index 5bed06158af..13327e3ea9c 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReaderSpi.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReaderSpi.java
@@ -39,8 +39,6 @@ public class JPEGImageReaderSpi extends ImageReaderSpi {
private static String [] writerSpiNames =
{"com.sun.imageio.plugins.jpeg.JPEGImageWriterSpi"};
- private boolean registered = false;
-
public JPEGImageReaderSpi() {
super(JPEG.vendor,
JPEG.version,
@@ -61,26 +59,6 @@ public class JPEGImageReaderSpi extends ImageReaderSpi {
);
}
- public void onRegistration(ServiceRegistry registry,
- Class> category) {
- if (registered) {
- return;
- }
- try {
- java.security.AccessController.doPrivileged(
- new sun.security.action.LoadLibraryAction("jpeg"));
- // Stuff it all into one lib for first pass
- //java.security.AccessController.doPrivileged(
- //new sun.security.action.LoadLibraryAction("imageioIJG"));
- } catch (Throwable e) { // Fail on any Throwable
- // if it can't be loaded, deregister and return
- registry.deregisterServiceProvider(this);
- return;
- }
-
- registered = true;
- }
-
public String getDescription(Locale locale) {
return "Standard JPEG Image Reader";
}
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java
index 0fbe8f33945..9c585047faa 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java
@@ -812,13 +812,13 @@ public class JPEGImageWriter extends ImageWriter {
}
break;
case ColorSpace.TYPE_3CLR:
- if (cs == JPEG.YCC) {
+ if (cs == JPEG.JCS.YCC) {
if (!alpha) {
if (jfif != null) {
convertTosRGB = true;
convertOp =
new ColorConvertOp(cs,
- JPEG.sRGB,
+ JPEG.JCS.sRGB,
null);
outCsType = JPEG.JCS_YCbCr;
} else if (adobe != null) {
@@ -1494,7 +1494,7 @@ public class JPEGImageWriter extends ImageWriter {
}
break;
case ColorSpace.TYPE_3CLR:
- if (cs == JPEG.YCC) {
+ if (cs == JPEG.JCS.YCC) {
if (alpha) {
retval = JPEG.JCS_YCCA;
} else {
@@ -1533,7 +1533,7 @@ public class JPEGImageWriter extends ImageWriter {
}
break;
case ColorSpace.TYPE_3CLR:
- if (cs == JPEG.YCC) {
+ if (cs == JPEG.JCS.YCC) {
if (alpha) {
retval = JPEG.JCS_YCCA;
} else {
@@ -1579,7 +1579,7 @@ public class JPEGImageWriter extends ImageWriter {
}
break;
case ColorSpace.TYPE_3CLR:
- if (cs == JPEG.YCC) {
+ if (cs == JPEG.JCS.YCC) {
if (alpha) {
retval = JPEG.JCS_YCCA;
} else {
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriterSpi.java b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriterSpi.java
index 936c65c544f..717b4360794 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriterSpi.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriterSpi.java
@@ -42,8 +42,6 @@ public class JPEGImageWriterSpi extends ImageWriterSpi {
private static String [] readerSpiNames =
{"com.sun.imageio.plugins.jpeg.JPEGImageReaderSpi"};
- private boolean registered = false;
-
public JPEGImageWriterSpi() {
super(JPEG.vendor,
JPEG.version,
@@ -68,23 +66,6 @@ public class JPEGImageWriterSpi extends ImageWriterSpi {
return "Standard JPEG Image Writer";
}
- public void onRegistration(ServiceRegistry registry,
- Class> category) {
- if (registered) {
- return;
- }
- try {
- java.security.AccessController.doPrivileged(
- new sun.security.action.LoadLibraryAction("jpeg"));
- } catch (Throwable e) { // Fail on any Throwable
- // if it can't be loaded, deregister and return
- registry.deregisterServiceProvider(this);
- return;
- }
-
- registered = true;
- }
-
public boolean isFormatLossless() {
return false;
}
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGMetadata.java b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGMetadata.java
index c84003c9f22..044f7d632f6 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGMetadata.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGMetadata.java
@@ -490,7 +490,7 @@ public class JPEGMetadata extends IIOMetadata implements Cloneable {
}
break;
case ColorSpace.TYPE_3CLR:
- if (cs == JPEG.YCC) {
+ if (cs == JPEG.JCS.YCC) {
wantJFIF = false;
componentIDs[0] = (byte) 'Y';
componentIDs[1] = (byte) 'C';
diff --git a/jdk/src/share/classes/javax/imageio/ImageTypeSpecifier.java b/jdk/src/share/classes/javax/imageio/ImageTypeSpecifier.java
index 4ba0c1062d4..184bf8870cc 100644
--- a/jdk/src/share/classes/javax/imageio/ImageTypeSpecifier.java
+++ b/jdk/src/share/classes/javax/imageio/ImageTypeSpecifier.java
@@ -67,126 +67,13 @@ public class ImageTypeSpecifier {
* BufferedImage
types.
*/
private static ImageTypeSpecifier[] BISpecifier;
-
+ private static ColorSpace sRGB;
// Initialize the standard specifiers
static {
- ColorSpace sRGB = ColorSpace.getInstance(ColorSpace.CS_sRGB);
+ sRGB = ColorSpace.getInstance(ColorSpace.CS_sRGB);
BISpecifier =
new ImageTypeSpecifier[BufferedImage.TYPE_BYTE_INDEXED + 1];
-
- BISpecifier[BufferedImage.TYPE_CUSTOM] = null;
-
- BISpecifier[BufferedImage.TYPE_INT_RGB] =
- createPacked(sRGB,
- 0x00ff0000,
- 0x0000ff00,
- 0x000000ff,
- 0x0,
- DataBuffer.TYPE_INT,
- false);
-
- BISpecifier[BufferedImage.TYPE_INT_ARGB] =
- createPacked(sRGB,
- 0x00ff0000,
- 0x0000ff00,
- 0x000000ff,
- 0xff000000,
- DataBuffer.TYPE_INT,
- false);
-
- BISpecifier[BufferedImage.TYPE_INT_ARGB_PRE] =
- createPacked(sRGB,
- 0x00ff0000,
- 0x0000ff00,
- 0x000000ff,
- 0xff000000,
- DataBuffer.TYPE_INT,
- true);
-
- BISpecifier[BufferedImage.TYPE_INT_BGR] =
- createPacked(sRGB,
- 0x000000ff,
- 0x0000ff00,
- 0x00ff0000,
- 0x0,
- DataBuffer.TYPE_INT,
- false);
-
- int[] bOffsRGB = { 2, 1, 0 };
- BISpecifier[BufferedImage.TYPE_3BYTE_BGR] =
- createInterleaved(sRGB,
- bOffsRGB,
- DataBuffer.TYPE_BYTE,
- false,
- false);
-
- int[] bOffsABGR = { 3, 2, 1, 0 };
- BISpecifier[BufferedImage.TYPE_4BYTE_ABGR] =
- createInterleaved(sRGB,
- bOffsABGR,
- DataBuffer.TYPE_BYTE,
- true,
- false);
-
- BISpecifier[BufferedImage.TYPE_4BYTE_ABGR_PRE] =
- createInterleaved(sRGB,
- bOffsABGR,
- DataBuffer.TYPE_BYTE,
- true,
- true);
-
- BISpecifier[BufferedImage.TYPE_USHORT_565_RGB] =
- createPacked(sRGB,
- 0xF800,
- 0x07E0,
- 0x001F,
- 0x0,
- DataBuffer.TYPE_USHORT,
- false);
-
- BISpecifier[BufferedImage.TYPE_USHORT_555_RGB] =
- createPacked(sRGB,
- 0x7C00,
- 0x03E0,
- 0x001F,
- 0x0,
- DataBuffer.TYPE_USHORT,
- false);
-
- BISpecifier[BufferedImage.TYPE_BYTE_GRAY] =
- createGrayscale(8,
- DataBuffer.TYPE_BYTE,
- false);
-
- BISpecifier[BufferedImage.TYPE_USHORT_GRAY] =
- createGrayscale(16,
- DataBuffer.TYPE_USHORT,
- false);
-
- BISpecifier[BufferedImage.TYPE_BYTE_BINARY] =
- createGrayscale(1,
- DataBuffer.TYPE_BYTE,
- false);
-
- BufferedImage bi =
- new BufferedImage(1, 1, BufferedImage.TYPE_BYTE_INDEXED);
- IndexColorModel icm = (IndexColorModel)bi.getColorModel();
- int mapSize = icm.getMapSize();
- byte[] redLUT = new byte[mapSize];
- byte[] greenLUT = new byte[mapSize];
- byte[] blueLUT = new byte[mapSize];
- byte[] alphaLUT = new byte[mapSize];
-
- icm.getReds(redLUT);
- icm.getGreens(greenLUT);
- icm.getBlues(blueLUT);
- icm.getAlphas(alphaLUT);
-
- BISpecifier[BufferedImage.TYPE_BYTE_INDEXED] =
- createIndexed(redLUT, greenLUT, blueLUT, alphaLUT,
- 8,
- DataBuffer.TYPE_BYTE);
}
/**
@@ -1011,7 +898,7 @@ public class ImageTypeSpecifier {
ImageTypeSpecifier createFromBufferedImageType(int bufferedImageType) {
if (bufferedImageType >= BufferedImage.TYPE_INT_RGB &&
bufferedImageType <= BufferedImage.TYPE_BYTE_INDEXED) {
- return BISpecifier[bufferedImageType];
+ return getSpecifier(bufferedImageType);
} else if (bufferedImageType == BufferedImage.TYPE_CUSTOM) {
throw new IllegalArgumentException("Cannot create from TYPE_CUSTOM!");
} else {
@@ -1041,7 +928,7 @@ public class ImageTypeSpecifier {
if (image instanceof BufferedImage) {
int bufferedImageType = ((BufferedImage)image).getType();
if (bufferedImageType != BufferedImage.TYPE_CUSTOM) {
- return BISpecifier[bufferedImageType];
+ return getSpecifier(bufferedImageType);
}
}
@@ -1225,4 +1112,130 @@ public class ImageTypeSpecifier {
public int hashCode() {
return (9 * colorModel.hashCode()) + (14 * sampleModel.hashCode());
}
+
+ private static ImageTypeSpecifier getSpecifier(int type) {
+ if (BISpecifier[type] == null) {
+ BISpecifier[type] = createSpecifier(type);
+ }
+ return BISpecifier[type];
+ }
+
+ private static ImageTypeSpecifier createSpecifier(int type) {
+ switch(type) {
+ case BufferedImage.TYPE_INT_RGB:
+ return createPacked(sRGB,
+ 0x00ff0000,
+ 0x0000ff00,
+ 0x000000ff,
+ 0x0,
+ DataBuffer.TYPE_INT,
+ false);
+
+ case BufferedImage.TYPE_INT_ARGB:
+ return createPacked(sRGB,
+ 0x00ff0000,
+ 0x0000ff00,
+ 0x000000ff,
+ 0xff000000,
+ DataBuffer.TYPE_INT,
+ false);
+
+ case BufferedImage.TYPE_INT_ARGB_PRE:
+ return createPacked(sRGB,
+ 0x00ff0000,
+ 0x0000ff00,
+ 0x000000ff,
+ 0xff000000,
+ DataBuffer.TYPE_INT,
+ true);
+
+ case BufferedImage.TYPE_INT_BGR:
+ return createPacked(sRGB,
+ 0x000000ff,
+ 0x0000ff00,
+ 0x00ff0000,
+ 0x0,
+ DataBuffer.TYPE_INT,
+ false);
+
+ case BufferedImage.TYPE_3BYTE_BGR:
+ return createInterleaved(sRGB,
+ new int[] { 2, 1, 0 },
+ DataBuffer.TYPE_BYTE,
+ false,
+ false);
+
+ case BufferedImage.TYPE_4BYTE_ABGR:
+ return createInterleaved(sRGB,
+ new int[] { 3, 2, 1, 0 },
+ DataBuffer.TYPE_BYTE,
+ true,
+ false);
+
+ case BufferedImage.TYPE_4BYTE_ABGR_PRE:
+ return createInterleaved(sRGB,
+ new int[] { 3, 2, 1, 0 },
+ DataBuffer.TYPE_BYTE,
+ true,
+ true);
+
+ case BufferedImage.TYPE_USHORT_565_RGB:
+ return createPacked(sRGB,
+ 0xF800,
+ 0x07E0,
+ 0x001F,
+ 0x0,
+ DataBuffer.TYPE_USHORT,
+ false);
+
+ case BufferedImage.TYPE_USHORT_555_RGB:
+ return createPacked(sRGB,
+ 0x7C00,
+ 0x03E0,
+ 0x001F,
+ 0x0,
+ DataBuffer.TYPE_USHORT,
+ false);
+
+ case BufferedImage.TYPE_BYTE_GRAY:
+ return createGrayscale(8,
+ DataBuffer.TYPE_BYTE,
+ false);
+
+ case BufferedImage.TYPE_USHORT_GRAY:
+ return createGrayscale(16,
+ DataBuffer.TYPE_USHORT,
+ false);
+
+ case BufferedImage.TYPE_BYTE_BINARY:
+ return createGrayscale(1,
+ DataBuffer.TYPE_BYTE,
+ false);
+
+ case BufferedImage.TYPE_BYTE_INDEXED:
+ {
+
+ BufferedImage bi =
+ new BufferedImage(1, 1, BufferedImage.TYPE_BYTE_INDEXED);
+ IndexColorModel icm = (IndexColorModel)bi.getColorModel();
+ int mapSize = icm.getMapSize();
+ byte[] redLUT = new byte[mapSize];
+ byte[] greenLUT = new byte[mapSize];
+ byte[] blueLUT = new byte[mapSize];
+ byte[] alphaLUT = new byte[mapSize];
+
+ icm.getReds(redLUT);
+ icm.getGreens(greenLUT);
+ icm.getBlues(blueLUT);
+ icm.getAlphas(alphaLUT);
+
+ return createIndexed(redLUT, greenLUT, blueLUT, alphaLUT,
+ 8,
+ DataBuffer.TYPE_BYTE);
+ }
+ default:
+ throw new IllegalArgumentException("Invalid BufferedImage type!");
+ }
+ }
+
}
From 454a7c0732e7b5c5bfd1e45a4ff6ef5e9c394438 Mon Sep 17 00:00:00 2001
From: Andrew Brygin
Date: Fri, 30 Jan 2009 22:30:32 +0300
Subject: [PATCH 026/292] 6791502: IIOException "Invalid icc profile" on jpeg
after update from JDK5 to JDK6
Reviewed-by: igor, prr
---
.../native/sun/awt/image/jpeg/imageioJPEG.c | 112 +++++++++++-------
1 file changed, 70 insertions(+), 42 deletions(-)
diff --git a/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c b/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c
index 8c30b5ce69e..0a99c3fdb93 100644
--- a/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c
+++ b/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c
@@ -396,7 +396,7 @@ static imageIODataPtr initImageioData (JNIEnv *env,
data->jpegObj = cinfo;
cinfo->client_data = data;
-#ifdef DEBUG
+#ifdef DEBUG_IIO_JPEG
printf("new structures: data is %p, cinfo is %p\n", data, cinfo);
#endif
@@ -673,7 +673,7 @@ static int setQTables(JNIEnv *env,
j_decompress_ptr decomp;
qlen = (*env)->GetArrayLength(env, qtables);
-#ifdef DEBUG
+#ifdef DEBUG_IIO_JPEG
printf("in setQTables, qlen = %d, write is %d\n", qlen, write);
#endif
for (i = 0; i < qlen; i++) {
@@ -876,7 +876,7 @@ imageio_fill_input_buffer(j_decompress_ptr cinfo)
return FALSE;
}
-#ifdef DEBUG
+#ifdef DEBUG_IIO_JPEG
printf("Filling input buffer, remaining skip is %ld, ",
sb->remaining_skip);
printf("Buffer length is %d\n", sb->bufferLength);
@@ -906,7 +906,7 @@ imageio_fill_input_buffer(j_decompress_ptr cinfo)
cinfo->err->error_exit((j_common_ptr) cinfo);
}
-#ifdef DEBUG
+#ifdef DEBUG_IIO_JPEG
printf("Buffer filled. ret = %d\n", ret);
#endif
/*
@@ -917,7 +917,7 @@ imageio_fill_input_buffer(j_decompress_ptr cinfo)
*/
if (ret <= 0) {
jobject reader = data->imageIOobj;
-#ifdef DEBUG
+#ifdef DEBUG_IIO_JPEG
printf("YO! Early EOI! ret = %d\n", ret);
#endif
RELEASE_ARRAYS(env, data, src->next_input_byte);
@@ -1216,21 +1216,24 @@ read_icc_profile (JNIEnv *env, j_decompress_ptr cinfo)
{
jpeg_saved_marker_ptr marker;
int num_markers = 0;
+ int num_found_markers = 0;
int seq_no;
JOCTET *icc_data;
+ JOCTET *dst_ptr;
unsigned int total_length;
#define MAX_SEQ_NO 255 // sufficient since marker numbers are bytes
- char marker_present[MAX_SEQ_NO+1]; // 1 if marker found
- unsigned int data_length[MAX_SEQ_NO+1]; // size of profile data in marker
- unsigned int data_offset[MAX_SEQ_NO+1]; // offset for data in marker
+ jpeg_saved_marker_ptr icc_markers[MAX_SEQ_NO + 1];
+ int first; // index of the first marker in the icc_markers array
+ int last; // index of the last marker in the icc_markers array
jbyteArray data = NULL;
/* This first pass over the saved markers discovers whether there are
* any ICC markers and verifies the consistency of the marker numbering.
*/
- for (seq_no = 1; seq_no <= MAX_SEQ_NO; seq_no++)
- marker_present[seq_no] = 0;
+ for (seq_no = 0; seq_no <= MAX_SEQ_NO; seq_no++)
+ icc_markers[seq_no] = NULL;
+
for (marker = cinfo->marker_list; marker != NULL; marker = marker->next) {
if (marker_is_icc(marker)) {
@@ -1242,37 +1245,58 @@ read_icc_profile (JNIEnv *env, j_decompress_ptr cinfo)
return NULL;
}
seq_no = GETJOCTET(marker->data[12]);
- if (seq_no <= 0 || seq_no > num_markers) {
+
+ /* Some third-party tools produce images with profile chunk
+ * numeration started from zero. It is inconsistent with ICC
+ * spec, but seems to be recognized by majority of image
+ * processing tools, so we should be more tolerant to this
+ * departure from the spec.
+ */
+ if (seq_no < 0 || seq_no > num_markers) {
JNU_ThrowByName(env, "javax/imageio/IIOException",
"Invalid icc profile: bad sequence number");
return NULL;
}
- if (marker_present[seq_no]) {
+ if (icc_markers[seq_no] != NULL) {
JNU_ThrowByName(env, "javax/imageio/IIOException",
"Invalid icc profile: duplicate sequence numbers");
return NULL;
}
- marker_present[seq_no] = 1;
- data_length[seq_no] = marker->data_length - ICC_OVERHEAD_LEN;
+ icc_markers[seq_no] = marker;
+ num_found_markers ++;
}
}
if (num_markers == 0)
return NULL; // There is no profile
- /* Check for missing markers, count total space needed,
- * compute offset of each marker's part of the data.
- */
+ if (num_markers != num_found_markers) {
+ JNU_ThrowByName(env, "javax/imageio/IIOException",
+ "Invalid icc profile: invalid number of icc markers");
+ return NULL;
+ }
+ first = icc_markers[0] ? 0 : 1;
+ last = num_found_markers + first;
+
+ /* Check for missing markers, count total space needed.
+ */
total_length = 0;
- for (seq_no = 1; seq_no <= num_markers; seq_no++) {
- if (marker_present[seq_no] == 0) {
+ for (seq_no = first; seq_no < last; seq_no++) {
+ unsigned int length;
+ if (icc_markers[seq_no] == NULL) {
JNU_ThrowByName(env, "javax/imageio/IIOException",
"Invalid icc profile: missing sequence number");
return NULL;
}
- data_offset[seq_no] = total_length;
- total_length += data_length[seq_no];
+ /* check the data length correctness */
+ length = icc_markers[seq_no]->data_length;
+ if (ICC_OVERHEAD_LEN > length || length > MAX_BYTES_IN_MARKER) {
+ JNU_ThrowByName(env, "javax/imageio/IIOException",
+ "Invalid icc profile: invalid data length");
+ return NULL;
+ }
+ total_length += (length - ICC_OVERHEAD_LEN);
}
if (total_length <= 0) {
@@ -1301,19 +1325,14 @@ read_icc_profile (JNIEnv *env, j_decompress_ptr cinfo)
}
/* and fill it in */
- for (marker = cinfo->marker_list; marker != NULL; marker = marker->next) {
- if (marker_is_icc(marker)) {
- JOCTET FAR *src_ptr;
- JOCTET *dst_ptr;
- unsigned int length;
- seq_no = GETJOCTET(marker->data[12]);
- dst_ptr = icc_data + data_offset[seq_no];
- src_ptr = marker->data + ICC_OVERHEAD_LEN;
- length = data_length[seq_no];
- while (length--) {
- *dst_ptr++ = *src_ptr++;
- }
- }
+ dst_ptr = icc_data;
+ for (seq_no = first; seq_no < last; seq_no++) {
+ JOCTET FAR *src_ptr = icc_markers[seq_no]->data + ICC_OVERHEAD_LEN;
+ unsigned int length =
+ icc_markers[seq_no]->data_length - ICC_OVERHEAD_LEN;
+
+ memcpy(dst_ptr, src_ptr, length);
+ dst_ptr += length;
}
/* finally, unpin the array */
@@ -1530,6 +1549,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImageHeader
j_decompress_ptr cinfo;
struct jpeg_source_mgr *src;
sun_jpeg_error_ptr jerr;
+ jbyteArray profileData = NULL;
if (data == NULL) {
JNU_ThrowByName(env,
@@ -1557,7 +1577,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImageHeader
return retval;
}
-#ifdef DEBUG
+#ifdef DEBUG_IIO_JPEG
printf("In readImageHeader, data is %p cinfo is %p\n", data, cinfo);
printf("clearFirst is %d\n", clearFirst);
#endif
@@ -1584,7 +1604,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImageHeader
if (ret == JPEG_HEADER_TABLES_ONLY) {
retval = JNI_TRUE;
imageio_term_source(cinfo); // Pushback remaining buffer contents
-#ifdef DEBUG
+#ifdef DEBUG_IIO_JPEG
printf("just read tables-only image; q table 0 at %p\n",
cinfo->quant_tbl_ptrs[0]);
#endif
@@ -1691,6 +1711,14 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImageHeader
}
}
RELEASE_ARRAYS(env, data, src->next_input_byte);
+
+ /* read icc profile data */
+ profileData = read_icc_profile(env, cinfo);
+
+ if ((*env)->ExceptionCheck(env)) {
+ return retval;
+ }
+
(*env)->CallVoidMethod(env, this,
JPEGImageReader_setImageDataID,
cinfo->image_width,
@@ -1698,7 +1726,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImageHeader
cinfo->jpeg_color_space,
cinfo->out_color_space,
cinfo->num_components,
- read_icc_profile(env, cinfo));
+ profileData);
if (reset) {
jpeg_abort_decompress(cinfo);
}
@@ -1827,7 +1855,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImage
(*env)->ReleaseIntArrayElements(env, srcBands, body, JNI_ABORT);
-#ifdef DEBUG
+#ifdef DEBUG_IIO_JPEG
printf("---- in reader.read ----\n");
printf("numBands is %d\n", numBands);
printf("bands array: ");
@@ -2487,7 +2515,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_writeTables
data->streamBuf.suspendable = FALSE;
if (qtables != NULL) {
-#ifdef DEBUG
+#ifdef DEBUG_IIO_JPEG
printf("in writeTables: qtables not NULL\n");
#endif
setQTables(env, (j_common_ptr) cinfo, qtables, TRUE);
@@ -2763,7 +2791,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_writeImage
cinfo->restart_interval = restartInterval;
-#ifdef DEBUG
+#ifdef DEBUG_IIO_JPEG
printf("writer setup complete, starting compressor\n");
#endif
@@ -2812,13 +2840,13 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_writeImage
for (i = 0; i < numBands; i++) {
if (scale !=NULL && scale[i] != NULL) {
*out++ = scale[i][*(in+i)];
-#ifdef DEBUG
+#ifdef DEBUG_IIO_JPEG
if (in == data->pixelBuf.buf.bp){ // Just the first pixel
printf("in %d -> out %d, ", *(in+i), *(out-i-1));
}
#endif
-#ifdef DEBUG
+#ifdef DEBUG_IIO_JPEG
if (in == data->pixelBuf.buf.bp){ // Just the first pixel
printf("\n");
}
From 614df1958ca812c31f6097489ef348de9f90a5a8 Mon Sep 17 00:00:00 2001
From: Kelly O'Hair
Date: Sat, 31 Jan 2009 15:26:34 -0800
Subject: [PATCH 027/292] 6791649: add "SKIP_MSIVAL2=true" to the Windows
section of make/jprt.config
Reviewed-by: tbell
---
make/jdk-rules.gmk | 2 +-
make/jprt.config | 7 +++++++
make/jprt.gmk | 2 +-
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/make/jdk-rules.gmk b/make/jdk-rules.gmk
index 821f5d739c6..d0ca905ff02 100644
--- a/make/jdk-rules.gmk
+++ b/make/jdk-rules.gmk
@@ -106,7 +106,7 @@ jdk-clobber::
$(MAKE) $(JDK_CLOBBER_TARGETS) $(JDK_BUILD_ARGUMENTS) ; )
jdk-sanity::
- @( $(CD) $(JDK_TOPDIR)/make && \
+ ( $(CD) $(JDK_TOPDIR)/make && \
$(MAKE) sanity HOTSPOT_IMPORT_CHECK=false $(JDK_BUILD_ARGUMENTS) ; )
compare-images: compare-image
diff --git a/make/jprt.config b/make/jprt.config
index f3ff50615ef..895d9432e01 100644
--- a/make/jprt.config
+++ b/make/jprt.config
@@ -358,6 +358,13 @@ else
ALT_SPONSOR2DIR=C:/sponsor_binaries
export ALT_SPONSOR2DIR
+ # JPRT systems can never run msival2.exe, set this to avoid them
+ SKIP_MSIVAL2=true
+ export SKIP_MSIVAL2
+ # Not easy to do
+ SKIP_COMPARE_IMAGES=true
+ export SKIP_COMPARE_IMAGES
+
fi
# Export PATH setting
diff --git a/make/jprt.gmk b/make/jprt.gmk
index fcf67f80b36..32803e06256 100644
--- a/make/jprt.gmk
+++ b/make/jprt.gmk
@@ -36,7 +36,7 @@ DEFAULT_BUILD_FLAVOR=product
JPRT_ARCHIVE_BUNDLE=$(ABS_OUTPUTDIR)/$(DEFAULT_BUILD_FLAVOR)-bundle.zip
JPRT_ARCHIVE_INSTALL_BUNDLE=$(ABS_OUTPUTDIR)/$(DEFAULT_BUILD_FLAVOR)-install-bundle.zip
-jprt_build_product: all_product_build
+jprt_build_product: sanity all_product_build
( $(CD) $(OUTPUTDIR)/j2sdk-image && \
$(ZIPEXE) -q -r $(JPRT_ARCHIVE_BUNDLE) . )
ifdef HAVE_JPRT_SAVE_BUNDLES
From 09010fe0a7622ad2bf5f4b32b43ff4ca9eb846e5 Mon Sep 17 00:00:00 2001
From: Kelly O'Hair
Date: Sat, 31 Jan 2009 17:19:42 -0800
Subject: [PATCH 028/292] 6799141: Build with --hash-style=both so that
binaries can work on SuSE 10
Reviewed-by: tbell
---
hotspot/make/linux/makefiles/gcc.make | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/hotspot/make/linux/makefiles/gcc.make b/hotspot/make/linux/makefiles/gcc.make
index 4a01c29c50e..1a1f1465c81 100644
--- a/hotspot/make/linux/makefiles/gcc.make
+++ b/hotspot/make/linux/makefiles/gcc.make
@@ -131,6 +131,14 @@ endif
# Enable linker optimization
LFLAGS += -Xlinker -O1
+# If this is a --hash-style=gnu system, use --hash-style=both
+# The gnu .hash section won't work on some Linux systems like SuSE 10.
+_HAS_HASH_STYLE_GNU:=$(shell $(CC) -dumpspecs | grep -- '--hash-style=gnu')
+ifneq ($(_HAS_HASH_STYLE_GNU),)
+ LDFLAGS_HASH_STYLE = -Wl,--hash-style=both
+endif
+LFLAGS += $(LDFLAGS_HASH_STYLE)
+
# Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
MAPFLAG = -Xlinker --version-script=FILENAME
From b56f07314820fea8178028ee1b80ea6a924bd2e1 Mon Sep 17 00:00:00 2001
From: Andrew Brygin
Date: Wed, 4 Feb 2009 14:06:18 +0300
Subject: [PATCH 029/292] 6799583: LogManager shutdown hook may cause a memory
leak
Reviewed-by: igor, swamyv
---
.../classes/java/util/logging/LogManager.java | 8 +
.../util/logging/ClassLoaderLeakTest.java | 190 ++++++++++++++++++
2 files changed, 198 insertions(+)
create mode 100644 jdk/test/java/util/logging/ClassLoaderLeakTest.java
diff --git a/jdk/src/share/classes/java/util/logging/LogManager.java b/jdk/src/share/classes/java/util/logging/LogManager.java
index 412f749404d..fc8f080eb71 100644
--- a/jdk/src/share/classes/java/util/logging/LogManager.java
+++ b/jdk/src/share/classes/java/util/logging/LogManager.java
@@ -215,6 +215,14 @@ public class LogManager {
// This private class is used as a shutdown hook.
// It does a "reset" to close all open handlers.
private class Cleaner extends Thread {
+
+ private Cleaner() {
+ /* Set context class loader to null in order to avoid
+ * keeping a strong reference to an application classloader.
+ */
+ this.setContextClassLoader(null);
+ }
+
public void run() {
// This is to ensure the LogManager. is completed
// before synchronized block. Otherwise deadlocks are possible.
diff --git a/jdk/test/java/util/logging/ClassLoaderLeakTest.java b/jdk/test/java/util/logging/ClassLoaderLeakTest.java
new file mode 100644
index 00000000000..988041472fc
--- /dev/null
+++ b/jdk/test/java/util/logging/ClassLoaderLeakTest.java
@@ -0,0 +1,190 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug 6799583
+ *
+ * @summary Test verifes that LogManager shutdown hook does not cause
+ * an application classloader leaks.
+ *
+ * @run main/othervm ClassLoaderLeakTest
+ */
+
+import java.io.File;
+import java.lang.ref.WeakReference;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.concurrent.CountDownLatch;
+import java.util.logging.Logger;
+import java.util.logging.Logger;
+
+public class ClassLoaderLeakTest {
+
+ private static CountDownLatch doneSignal;
+ private static CountDownLatch launchSignal;
+ private static ThreadGroup appsThreadGroup;
+ private static Throwable launchFailure = null;
+
+ public static void main(String[] args) {
+ appsThreadGroup = new ThreadGroup("MyAppsThreadGroup");
+ doneSignal = new CountDownLatch(1);
+ launchSignal = new CountDownLatch(1);
+
+ Runnable launcher = new Runnable() {
+ public void run() {
+ try {
+ ClassLoader cl =
+ Thread.currentThread().getContextClassLoader();
+ Class appMain = cl.loadClass("AppTest");
+ Method launch =
+ appMain.getDeclaredMethod("launch", doneSignal.getClass());
+
+ Constructor c = appMain.getConstructor();
+
+ Object o = c.newInstance();
+
+ launch.invoke(o, doneSignal);
+
+ } catch (Throwable e) {
+ launchFailure = e;
+ } finally {
+ launchSignal.countDown();
+ }
+ }
+ };
+
+ /* prepare test class loader */
+ URL pwd = null;
+ try {
+
+ pwd = new File(System.getProperty("test.classes",".")).toURL();
+ } catch (MalformedURLException e) {
+ throw new RuntimeException("Test failed.", e);
+ }
+ URL[] urls = new URL[] { pwd };
+
+ MyClassLoader appClassLoader = new MyClassLoader(urls, "test0");
+ WeakReference ref =
+ new WeakReference(appClassLoader);
+
+
+ Thread appThread = new Thread(appsThreadGroup, launcher, "AppThread-0");
+ appThread.setContextClassLoader(appClassLoader);
+
+ appThread.start();
+ appClassLoader = null;
+ launcher = null;
+ appThread = null;
+
+ /* wait for laucnh completion */
+ try {
+ launchSignal.await();
+ } catch (InterruptedException e) {
+ }
+
+ /* check if launch failed */
+ if (launchFailure != null) {
+ throw new RuntimeException("Test failed.", launchFailure);
+ }
+
+ /* wait for test app excution completion */
+ try {
+ doneSignal.await();
+ } catch (InterruptedException e) {
+ }
+
+ /* give a chence to GC */
+ waitAndGC(5);
+
+ if (ref.get() != null) {
+ throw new RuntimeException("Test failed: classloader is still alive");
+ }
+
+ System.out.println("Test passed.");
+ }
+
+ private static class MyClassLoader extends URLClassLoader {
+
+ private static boolean verbose =
+ Boolean.getBoolean("verboseClassLoading");
+ private String uniqClassName;
+
+ public MyClassLoader(URL[] urls, String uniq) {
+ super(urls);
+
+ uniqClassName = uniq;
+ }
+
+ public Class loadClass(String name) throws ClassNotFoundException {
+ if (verbose) {
+ System.out.printf("%s: load class %s\n", uniqClassName, name);
+ }
+ if (uniqClassName.equals(name)) {
+ return Object.class;
+ }
+ return super.loadClass(name);
+ }
+
+ public String toString() {
+ return "MyClassLoader(" + uniqClassName + ")";
+ }
+ }
+
+ private static void waitAndGC(int sec) {
+ int cnt = sec;
+ System.out.print("Wait ");
+ while (cnt-- > 0) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ }
+ // do GC every 3 seconds
+ if (cnt % 3 == 2) {
+ System.gc();
+ System.out.print("+");
+ } else {
+ System.out.print(".");
+ }
+ //checkErrors();
+ }
+ System.out.println("");
+ }
+}
+
+
+class AppTest {
+ public AppTest() {
+
+ }
+
+ public void launch(CountDownLatch done) {
+ Logger log = Logger.getLogger("app_test_logger");
+ log.fine("Test app is launched");
+
+ done.countDown();
+ }
+}
From 06d5f1e07f8ba64f7fb29daf7b717e533c93dce1 Mon Sep 17 00:00:00 2001
From: Peter Zhelezniakov
Date: Wed, 4 Feb 2009 18:48:24 +0300
Subject: [PATCH 030/292] 6588003: LayoutQueue shares mutable implementation
across AppContexts
DefaultQueue property is made per-AppContext
Reviewed-by: alexp
---
.../classes/javax/swing/text/LayoutQueue.java | 31 +++++++---
.../swing/text/LayoutQueue/Test6588003.java | 59 +++++++++++++++++++
2 files changed, 81 insertions(+), 9 deletions(-)
create mode 100644 jdk/test/javax/swing/text/LayoutQueue/Test6588003.java
diff --git a/jdk/src/share/classes/javax/swing/text/LayoutQueue.java b/jdk/src/share/classes/javax/swing/text/LayoutQueue.java
index e02f9b0f9b6..dbb5d00ccce 100644
--- a/jdk/src/share/classes/javax/swing/text/LayoutQueue.java
+++ b/jdk/src/share/classes/javax/swing/text/LayoutQueue.java
@@ -25,6 +25,7 @@
package javax.swing.text;
import java.util.Vector;
+import sun.awt.AppContext;
/**
* A queue of text layout tasks.
@@ -35,10 +36,10 @@ import java.util.Vector;
*/
public class LayoutQueue {
- Vector tasks;
- Thread worker;
+ private static final Object DEFAULT_QUEUE = new Object();
- static LayoutQueue defaultQueue;
+ private Vector tasks;
+ private Thread worker;
/**
* Construct a layout queue.
@@ -51,19 +52,31 @@ public class LayoutQueue {
* Fetch the default layout queue.
*/
public static LayoutQueue getDefaultQueue() {
- if (defaultQueue == null) {
- defaultQueue = new LayoutQueue();
+ AppContext ac = AppContext.getAppContext();
+ synchronized (DEFAULT_QUEUE) {
+ LayoutQueue defaultQueue = (LayoutQueue) ac.get(DEFAULT_QUEUE);
+ if (defaultQueue == null) {
+ defaultQueue = new LayoutQueue();
+ ac.put(DEFAULT_QUEUE, defaultQueue);
+ }
+ return defaultQueue;
}
- return defaultQueue;
}
/**
* Set the default layout queue.
*
- * @param q the new queue.
+ * @param defaultQueue the new queue.
*/
- public static void setDefaultQueue(LayoutQueue q) {
- defaultQueue = q;
+ public static void setDefaultQueue(LayoutQueue defaultQueue) {
+ synchronized (DEFAULT_QUEUE) {
+ AppContext ac = AppContext.getAppContext();
+ if (defaultQueue == null) {
+ ac.remove(DEFAULT_QUEUE);
+ } else {
+ ac.put(DEFAULT_QUEUE, defaultQueue);
+ }
+ }
}
/**
diff --git a/jdk/test/javax/swing/text/LayoutQueue/Test6588003.java b/jdk/test/javax/swing/text/LayoutQueue/Test6588003.java
new file mode 100644
index 00000000000..d14d6a56a95
--- /dev/null
+++ b/jdk/test/javax/swing/text/LayoutQueue/Test6588003.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+ @bug 6588003
+ @summary LayoutQueue should not share its DefaultQueue across AppContexts
+ @author Peter Zhelezniakov
+ @run main Test6588003
+*/
+
+import javax.swing.text.LayoutQueue;
+import sun.awt.SunToolkit;
+
+public class Test6588003 implements Runnable {
+ private static final LayoutQueue DEFAULT = new LayoutQueue();
+
+ public static void main(String[] args) throws InterruptedException {
+ LayoutQueue.setDefaultQueue(DEFAULT);
+
+ ThreadGroup group = new ThreadGroup("Test6588003");
+ Thread thread = new Thread(group, new Test6588003());
+ thread.start();
+ thread.join();
+
+ if (LayoutQueue.getDefaultQueue() != DEFAULT) {
+ throw new RuntimeException("Sharing detected");
+ }
+ }
+
+ public void run() {
+ SunToolkit.createNewAppContext();
+
+ if (LayoutQueue.getDefaultQueue() == DEFAULT) {
+ throw new RuntimeException("Sharing detected");
+ }
+
+ LayoutQueue.setDefaultQueue(new LayoutQueue());
+ }
+}
From 837ece487dd4c28c9d20b914695e5eae5277bb24 Mon Sep 17 00:00:00 2001
From: Sergey Malenkov
Date: Thu, 5 Feb 2009 14:48:10 +0300
Subject: [PATCH 031/292] 4769844: classes in java.beans that are serializable
but don't define serialVersionUID
Reviewed-by: peterz, rupashka
---
.../share/classes/java/beans/IndexedPropertyChangeEvent.java | 3 ++-
jdk/src/share/classes/java/beans/IntrospectionException.java | 3 ++-
jdk/src/share/classes/java/beans/PropertyChangeEvent.java | 3 ++-
jdk/src/share/classes/java/beans/PropertyVetoException.java | 4 ++--
.../classes/java/beans/beancontext/BeanContextEvent.java | 3 ++-
.../java/beans/beancontext/BeanContextMembershipEvent.java | 3 ++-
.../beans/beancontext/BeanContextServiceAvailableEvent.java | 3 ++-
.../beans/beancontext/BeanContextServiceRevokedEvent.java | 3 ++-
.../java/beans/beancontext/BeanContextServicesSupport.java | 4 +++-
jdk/src/share/classes/sun/beans/editors/ColorEditor.java | 4 +++-
jdk/src/share/classes/sun/beans/editors/FontEditor.java | 3 ++-
11 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/jdk/src/share/classes/java/beans/IndexedPropertyChangeEvent.java b/jdk/src/share/classes/java/beans/IndexedPropertyChangeEvent.java
index ea78643e435..951cd871fe5 100644
--- a/jdk/src/share/classes/java/beans/IndexedPropertyChangeEvent.java
+++ b/jdk/src/share/classes/java/beans/IndexedPropertyChangeEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* 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 @@ package java.beans;
* @author Mark Davidson
*/
public class IndexedPropertyChangeEvent extends PropertyChangeEvent {
+ private static final long serialVersionUID = -320227448495806870L;
private int index;
diff --git a/jdk/src/share/classes/java/beans/IntrospectionException.java b/jdk/src/share/classes/java/beans/IntrospectionException.java
index cac0b20fc01..2f5a65eda73 100644
--- a/jdk/src/share/classes/java/beans/IntrospectionException.java
+++ b/jdk/src/share/classes/java/beans/IntrospectionException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-1998 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -36,6 +36,7 @@ package java.beans;
public
class IntrospectionException extends Exception {
+ private static final long serialVersionUID = -3728150539969542619L;
/**
* Constructs an IntrospectionException
with a
diff --git a/jdk/src/share/classes/java/beans/PropertyChangeEvent.java b/jdk/src/share/classes/java/beans/PropertyChangeEvent.java
index 69f523d92e3..3e0c9cef6f9 100644
--- a/jdk/src/share/classes/java/beans/PropertyChangeEvent.java
+++ b/jdk/src/share/classes/java/beans/PropertyChangeEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -44,6 +44,7 @@ package java.beans;
*/
public class PropertyChangeEvent extends java.util.EventObject {
+ private static final long serialVersionUID = 7042693688939648123L;
/**
* Constructs a new PropertyChangeEvent
.
diff --git a/jdk/src/share/classes/java/beans/PropertyVetoException.java b/jdk/src/share/classes/java/beans/PropertyVetoException.java
index f736b3bade5..73376496b53 100644
--- a/jdk/src/share/classes/java/beans/PropertyVetoException.java
+++ b/jdk/src/share/classes/java/beans/PropertyVetoException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-1998 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
* 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,7 +33,7 @@ package java.beans;
public
class PropertyVetoException extends Exception {
-
+ private static final long serialVersionUID = 129596057694162164L;
/**
* Constructs a PropertyVetoException
with a
diff --git a/jdk/src/share/classes/java/beans/beancontext/BeanContextEvent.java b/jdk/src/share/classes/java/beans/beancontext/BeanContextEvent.java
index 4574605a154..2530869534b 100644
--- a/jdk/src/share/classes/java/beans/beancontext/BeanContextEvent.java
+++ b/jdk/src/share/classes/java/beans/beancontext/BeanContextEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -48,6 +48,7 @@ import java.beans.beancontext.BeanContext;
*/
public abstract class BeanContextEvent extends EventObject {
+ private static final long serialVersionUID = 7267998073569045052L;
/**
* Contruct a BeanContextEvent
diff --git a/jdk/src/share/classes/java/beans/beancontext/BeanContextMembershipEvent.java b/jdk/src/share/classes/java/beans/beancontext/BeanContextMembershipEvent.java
index 7e6c1ae0a69..3752e390341 100644
--- a/jdk/src/share/classes/java/beans/beancontext/BeanContextMembershipEvent.java
+++ b/jdk/src/share/classes/java/beans/beancontext/BeanContextMembershipEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2004 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -55,6 +55,7 @@ import java.util.Iterator;
* @see java.beans.beancontext.BeanContextMembershipListener
*/
public class BeanContextMembershipEvent extends BeanContextEvent {
+ private static final long serialVersionUID = 3499346510334590959L;
/**
* Contruct a BeanContextMembershipEvent
diff --git a/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceAvailableEvent.java b/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceAvailableEvent.java
index 558c7f9f363..7bb47a66033 100644
--- a/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceAvailableEvent.java
+++ b/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceAvailableEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2004 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -40,6 +40,7 @@ import java.util.Iterator;
*/
public class BeanContextServiceAvailableEvent extends BeanContextEvent {
+ private static final long serialVersionUID = -5333985775656400778L;
/**
* Construct a BeanContextAvailableServiceEvent
.
diff --git a/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceRevokedEvent.java b/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceRevokedEvent.java
index a508f4ca157..50d888cdf7e 100644
--- a/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceRevokedEvent.java
+++ b/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceRevokedEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2004 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -37,6 +37,7 @@ import java.beans.beancontext.BeanContextServices;
*
*/
public class BeanContextServiceRevokedEvent extends BeanContextEvent {
+ private static final long serialVersionUID = -1295543154724961754L;
/**
* Construct a BeanContextServiceEvent
.
diff --git a/jdk/src/share/classes/java/beans/beancontext/BeanContextServicesSupport.java b/jdk/src/share/classes/java/beans/beancontext/BeanContextServicesSupport.java
index d9552c8a34e..54dfdd7d227 100644
--- a/jdk/src/share/classes/java/beans/beancontext/BeanContextServicesSupport.java
+++ b/jdk/src/share/classes/java/beans/beancontext/BeanContextServicesSupport.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -60,6 +60,7 @@ import java.util.Locale;
public class BeanContextServicesSupport extends BeanContextSupport
implements BeanContextServices {
+ private static final long serialVersionUID = -8494482757288719206L;
/**
*
@@ -594,6 +595,7 @@ public class BeanContextServicesSupport extends BeanContextSupport
*/
protected static class BCSSServiceProvider implements Serializable {
+ private static final long serialVersionUID = 861278251667444782L;
BCSSServiceProvider(Class sc, BeanContextServiceProvider bcsp) {
super();
diff --git a/jdk/src/share/classes/sun/beans/editors/ColorEditor.java b/jdk/src/share/classes/sun/beans/editors/ColorEditor.java
index a3610e0ee2e..55dd9137be1 100644
--- a/jdk/src/share/classes/sun/beans/editors/ColorEditor.java
+++ b/jdk/src/share/classes/sun/beans/editors/ColorEditor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,8 @@ import java.awt.*;
import java.beans.*;
public class ColorEditor extends Panel implements PropertyEditor {
+ private static final long serialVersionUID = 1781257185164716054L;
+
public ColorEditor() {
setLayout(null);
diff --git a/jdk/src/share/classes/sun/beans/editors/FontEditor.java b/jdk/src/share/classes/sun/beans/editors/FontEditor.java
index 88de9aea48f..04d4c187e22 100644
--- a/jdk/src/share/classes/sun/beans/editors/FontEditor.java
+++ b/jdk/src/share/classes/sun/beans/editors/FontEditor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@ import java.awt.*;
import java.beans.*;
public class FontEditor extends Panel implements java.beans.PropertyEditor {
+ private static final long serialVersionUID = 6732704486002715933L;
public FontEditor() {
setLayout(null);
From 8f96eb9cea9b9b3886bb21a76da4aa9bcc5dc0a6 Mon Sep 17 00:00:00 2001
From: Sergey Malenkov
Date: Thu, 5 Feb 2009 17:00:57 +0300
Subject: [PATCH 032/292] 6669869: Beans.isDesignTime() and other queries
should be per-AppContext
Reviewed-by: peterz, rupashka
---
jdk/src/share/classes/java/beans/Beans.java | 96 ++++++++++---------
.../beans/Beans/6669869/TestDesignTime.java | 52 ++++++++++
.../beans/Beans/6669869/TestGuiAvailable.java | 53 ++++++++++
3 files changed, 158 insertions(+), 43 deletions(-)
create mode 100644 jdk/test/java/beans/Beans/6669869/TestDesignTime.java
create mode 100644 jdk/test/java/beans/Beans/6669869/TestGuiAvailable.java
diff --git a/jdk/src/share/classes/java/beans/Beans.java b/jdk/src/share/classes/java/beans/Beans.java
index f19b21aead2..8a750a8b15c 100644
--- a/jdk/src/share/classes/java/beans/Beans.java
+++ b/jdk/src/share/classes/java/beans/Beans.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,26 +27,41 @@ package java.beans;
import com.sun.beans.finder.ClassFinder;
-import java.applet.*;
+import java.applet.Applet;
+import java.applet.AppletContext;
+import java.applet.AppletStub;
+import java.applet.AudioClip;
-import java.awt.*;
-
-import java.beans.AppletInitializer;
+import java.awt.GraphicsEnvironment;
+import java.awt.Image;
import java.beans.beancontext.BeanContext;
-import java.io.*;
-
-import java.lang.reflect.Constructor;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectStreamClass;
+import java.io.StreamCorruptedException;
import java.net.URL;
-import java.lang.reflect.Array;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Vector;
+
+import sun.awt.AppContext;
/**
* This class provides some general purpose beans control methods.
*/
public class Beans {
+ private static final Object DESIGN_TIME = new Object();
+ private static final Object GUI_AVAILABLE = new Object();
/**
*
@@ -59,12 +74,12 @@ public class Beans {
* @param beanName the name of the bean within the class-loader.
* For example "sun.beanbox.foobah"
*
- * @exception java.lang.ClassNotFoundException if the class of a serialized
+ * @exception ClassNotFoundException if the class of a serialized
* object could not be found.
- * @exception java.io.IOException if an I/O error occurs.
+ * @exception IOException if an I/O error occurs.
*/
- public static Object instantiate(ClassLoader cls, String beanName) throws java.io.IOException, ClassNotFoundException {
+ public static Object instantiate(ClassLoader cls, String beanName) throws IOException, ClassNotFoundException {
return Beans.instantiate(cls, beanName, null, null);
}
@@ -80,12 +95,12 @@ public class Beans {
* For example "sun.beanbox.foobah"
* @param beanContext The BeanContext in which to nest the new bean
*
- * @exception java.lang.ClassNotFoundException if the class of a serialized
+ * @exception ClassNotFoundException if the class of a serialized
* object could not be found.
- * @exception java.io.IOException if an I/O error occurs.
+ * @exception IOException if an I/O error occurs.
*/
- public static Object instantiate(ClassLoader cls, String beanName, BeanContext beanContext) throws java.io.IOException, ClassNotFoundException {
+ public static Object instantiate(ClassLoader cls, String beanName, BeanContext beanContext) throws IOException, ClassNotFoundException {
return Beans.instantiate(cls, beanName, beanContext, null);
}
@@ -135,19 +150,19 @@ public class Beans {
* @param beanContext The BeanContext in which to nest the new bean
* @param initializer The AppletInitializer for the new bean
*
- * @exception java.lang.ClassNotFoundException if the class of a serialized
+ * @exception ClassNotFoundException if the class of a serialized
* object could not be found.
- * @exception java.io.IOException if an I/O error occurs.
+ * @exception IOException if an I/O error occurs.
*/
public static Object instantiate(ClassLoader cls, String beanName, BeanContext beanContext, AppletInitializer initializer)
- throws java.io.IOException, ClassNotFoundException {
+ throws IOException, ClassNotFoundException {
- java.io.InputStream ins;
- java.io.ObjectInputStream oins = null;
+ InputStream ins;
+ ObjectInputStream oins = null;
Object result = null;
boolean serialized = false;
- java.io.IOException serex = null;
+ IOException serex = null;
// If the given classloader is null, we check if an
// system classloader is available and (if so)
@@ -166,8 +181,8 @@ public class Beans {
// Try to find a serialized object with this name
final String serName = beanName.replace('.','/').concat(".ser");
final ClassLoader loader = cls;
- ins = (InputStream)java.security.AccessController.doPrivileged
- (new java.security.PrivilegedAction() {
+ ins = (InputStream)AccessController.doPrivileged
+ (new PrivilegedAction() {
public Object run() {
if (loader == null)
return ClassLoader.getSystemResourceAsStream(serName);
@@ -185,7 +200,7 @@ public class Beans {
result = oins.readObject();
serialized = true;
oins.close();
- } catch (java.io.IOException ex) {
+ } catch (IOException ex) {
ins.close();
// Drop through and try opening the class. But remember
// the exception in case we can't find the class either.
@@ -264,8 +279,8 @@ public class Beans {
final ClassLoader cloader = cls;
objectUrl = (URL)
- java.security.AccessController.doPrivileged
- (new java.security.PrivilegedAction() {
+ AccessController.doPrivileged
+ (new PrivilegedAction() {
public Object run() {
if (cloader == null)
return ClassLoader.getSystemResource
@@ -377,10 +392,11 @@ public class Beans {
* @return True if we are running in an application construction
* environment.
*
- * @see java.beans.DesignMode
+ * @see DesignMode
*/
public static boolean isDesignTime() {
- return designTime;
+ Object value = AppContext.getAppContext().get(DESIGN_TIME);
+ return (value instanceof Boolean) && (Boolean) value;
}
/**
@@ -393,11 +409,12 @@ public class Beans {
* false in a server environment or if an application is
* running as part of a batch job.
*
- * @see java.beans.Visibility
+ * @see Visibility
*
*/
public static boolean isGuiAvailable() {
- return guiAvailable;
+ Object value = AppContext.getAppContext().get(GUI_AVAILABLE);
+ return (value instanceof Boolean) ? (Boolean) value : !GraphicsEnvironment.isHeadless();
}
/**
@@ -423,7 +440,7 @@ public class Beans {
if (sm != null) {
sm.checkPropertiesAccess();
}
- designTime = isDesignTime;
+ AppContext.getAppContext().put(DESIGN_TIME, Boolean.valueOf(isDesignTime));
}
/**
@@ -449,14 +466,7 @@ public class Beans {
if (sm != null) {
sm.checkPropertiesAccess();
}
- guiAvailable = isGuiAvailable;
- }
-
-
- private static boolean designTime;
- private static boolean guiAvailable;
- static {
- guiAvailable = !GraphicsEnvironment.isHeadless();
+ AppContext.getAppContext().put(GUI_AVAILABLE, Boolean.valueOf(isGuiAvailable));
}
}
@@ -501,7 +511,7 @@ class ObjectInputStreamWithLoader extends ObjectInputStream
class BeansAppletContext implements AppletContext {
Applet target;
- java.util.Hashtable imageCache = new java.util.Hashtable();
+ Hashtable imageCache = new Hashtable();
BeansAppletContext(Applet target) {
this.target = target;
@@ -546,8 +556,8 @@ class BeansAppletContext implements AppletContext {
return null;
}
- public java.util.Enumeration getApplets() {
- java.util.Vector applets = new java.util.Vector();
+ public Enumeration getApplets() {
+ Vector applets = new Vector();
applets.addElement(target);
return applets.elements();
}
@@ -573,7 +583,7 @@ class BeansAppletContext implements AppletContext {
return null;
}
- public java.util.Iterator getStreamKeys(){
+ public Iterator getStreamKeys(){
// We do nothing.
return null;
}
diff --git a/jdk/test/java/beans/Beans/6669869/TestDesignTime.java b/jdk/test/java/beans/Beans/6669869/TestDesignTime.java
new file mode 100644
index 00000000000..e78142a2b90
--- /dev/null
+++ b/jdk/test/java/beans/Beans/6669869/TestDesignTime.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6669869
+ * @summary Tests DesignTime property in different application contexts
+ * @author Sergey Malenkov
+ */
+
+import java.beans.Beans;
+import sun.awt.SunToolkit;
+
+public class TestDesignTime implements Runnable {
+ public static void main(String[] args) throws InterruptedException {
+ if (Beans.isDesignTime()) {
+ throw new Error("unexpected DesignTime property");
+ }
+ Beans.setDesignTime(!Beans.isDesignTime());
+ ThreadGroup group = new ThreadGroup("$$$");
+ Thread thread = new Thread(group, new TestDesignTime());
+ thread.start();
+ thread.join();
+ }
+
+ public void run() {
+ SunToolkit.createNewAppContext();
+ if (Beans.isDesignTime()) {
+ throw new Error("shared DesignTime property");
+ }
+ }
+}
diff --git a/jdk/test/java/beans/Beans/6669869/TestGuiAvailable.java b/jdk/test/java/beans/Beans/6669869/TestGuiAvailable.java
new file mode 100644
index 00000000000..7144b6fad3b
--- /dev/null
+++ b/jdk/test/java/beans/Beans/6669869/TestGuiAvailable.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6669869
+ * @summary Tests GuiAvailable property in different application contexts
+ * @author Sergey Malenkov
+ */
+
+import java.awt.GraphicsEnvironment;
+import java.beans.Beans;
+import sun.awt.SunToolkit;
+
+public class TestGuiAvailable implements Runnable {
+ public static void main(String[] args) throws InterruptedException {
+ if (Beans.isGuiAvailable() == GraphicsEnvironment.isHeadless()) {
+ throw new Error("unexpected GuiAvailable property");
+ }
+ Beans.setGuiAvailable(!Beans.isGuiAvailable());
+ ThreadGroup group = new ThreadGroup("$$$");
+ Thread thread = new Thread(group, new TestGuiAvailable());
+ thread.start();
+ thread.join();
+ }
+
+ public void run() {
+ SunToolkit.createNewAppContext();
+ if (Beans.isGuiAvailable() == GraphicsEnvironment.isHeadless()) {
+ throw new Error("shared GuiAvailable property");
+ }
+ }
+}
From a21476939e4a000ab5ee85f0939c99b4afb80312 Mon Sep 17 00:00:00 2001
From: Peter Zhelezniakov
Date: Thu, 5 Feb 2009 19:16:13 +0300
Subject: [PATCH 033/292] 6801769: 6588003 should be backed out from jdk7
Reviewed-by: alexp
---
.../classes/javax/swing/text/LayoutQueue.java | 31 ++++++-------------
1 file changed, 9 insertions(+), 22 deletions(-)
diff --git a/jdk/src/share/classes/javax/swing/text/LayoutQueue.java b/jdk/src/share/classes/javax/swing/text/LayoutQueue.java
index dbb5d00ccce..e02f9b0f9b6 100644
--- a/jdk/src/share/classes/javax/swing/text/LayoutQueue.java
+++ b/jdk/src/share/classes/javax/swing/text/LayoutQueue.java
@@ -25,7 +25,6 @@
package javax.swing.text;
import java.util.Vector;
-import sun.awt.AppContext;
/**
* A queue of text layout tasks.
@@ -36,10 +35,10 @@ import sun.awt.AppContext;
*/
public class LayoutQueue {
- private static final Object DEFAULT_QUEUE = new Object();
+ Vector tasks;
+ Thread worker;
- private Vector tasks;
- private Thread worker;
+ static LayoutQueue defaultQueue;
/**
* Construct a layout queue.
@@ -52,31 +51,19 @@ public class LayoutQueue {
* Fetch the default layout queue.
*/
public static LayoutQueue getDefaultQueue() {
- AppContext ac = AppContext.getAppContext();
- synchronized (DEFAULT_QUEUE) {
- LayoutQueue defaultQueue = (LayoutQueue) ac.get(DEFAULT_QUEUE);
- if (defaultQueue == null) {
- defaultQueue = new LayoutQueue();
- ac.put(DEFAULT_QUEUE, defaultQueue);
- }
- return defaultQueue;
+ if (defaultQueue == null) {
+ defaultQueue = new LayoutQueue();
}
+ return defaultQueue;
}
/**
* Set the default layout queue.
*
- * @param defaultQueue the new queue.
+ * @param q the new queue.
*/
- public static void setDefaultQueue(LayoutQueue defaultQueue) {
- synchronized (DEFAULT_QUEUE) {
- AppContext ac = AppContext.getAppContext();
- if (defaultQueue == null) {
- ac.remove(DEFAULT_QUEUE);
- } else {
- ac.put(DEFAULT_QUEUE, defaultQueue);
- }
- }
+ public static void setDefaultQueue(LayoutQueue q) {
+ defaultQueue = q;
}
/**
From d83e26cba476db741b0638154ae0d2d922fe91f9 Mon Sep 17 00:00:00 2001
From: Andrew Brygin
Date: Fri, 6 Feb 2009 20:49:53 +0300
Subject: [PATCH 034/292] 6800846: REGRESSION: Printing quality degraded with
Java 6 compared to 5.0
Reviewed-by: igor, prr
---
jdk/src/share/native/sun/awt/image/dither.c | 11 +--
jdk/test/sun/awt/image/DrawByteBinary.java | 75 +++++++++++++++++++++
2 files changed, 81 insertions(+), 5 deletions(-)
create mode 100644 jdk/test/sun/awt/image/DrawByteBinary.java
diff --git a/jdk/src/share/native/sun/awt/image/dither.c b/jdk/src/share/native/sun/awt/image/dither.c
index a935d6766f6..cb2303e76d7 100644
--- a/jdk/src/share/native/sun/awt/image/dither.c
+++ b/jdk/src/share/native/sun/awt/image/dither.c
@@ -169,6 +169,7 @@ initCubemap(int* cmap,
int cubesize = cube_dim * cube_dim * cube_dim;
unsigned char *useFlags;
unsigned char *newILut = (unsigned char*)malloc(cubesize);
+ int cmap_mid = (cmap_len >> 1) + (cmap_len & 0x1);
if (newILut) {
useFlags = (unsigned char *)calloc(cubesize, 1);
@@ -188,7 +189,7 @@ initCubemap(int* cmap,
currentState.iLUT = newILut;
currentState.rgb = (unsigned short *)
- malloc(256 * sizeof(unsigned short));
+ malloc(cmap_len * sizeof(unsigned short));
if (currentState.rgb == NULL) {
free(newILut);
free(useFlags);
@@ -199,7 +200,7 @@ initCubemap(int* cmap,
}
currentState.indices = (unsigned char *)
- malloc(256 * sizeof(unsigned char));
+ malloc(cmap_len * sizeof(unsigned char));
if (currentState.indices == NULL) {
free(currentState.rgb);
free(newILut);
@@ -210,18 +211,18 @@ initCubemap(int* cmap,
return NULL;
}
- for (i = 0; i < 128; i++) {
+ for (i = 0; i < cmap_mid; i++) {
unsigned short rgb;
int pixel = cmap[i];
rgb = (pixel & 0x00f80000) >> 9;
rgb |= (pixel & 0x0000f800) >> 6;
rgb |= (pixel & 0xf8) >> 3;
INSERTNEW(currentState, rgb, i);
- pixel = cmap[255-i];
+ pixel = cmap[cmap_len - i - 1];
rgb = (pixel & 0x00f80000) >> 9;
rgb |= (pixel & 0x0000f800) >> 6;
rgb |= (pixel & 0xf8) >> 3;
- INSERTNEW(currentState, rgb, 255-i);
+ INSERTNEW(currentState, rgb, cmap_len - i - 1);
}
if (!recurseLevel(¤tState)) {
diff --git a/jdk/test/sun/awt/image/DrawByteBinary.java b/jdk/test/sun/awt/image/DrawByteBinary.java
new file mode 100644
index 00000000000..e9db5c63f23
--- /dev/null
+++ b/jdk/test/sun/awt/image/DrawByteBinary.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug 6800846
+ *
+ * @summary Test verifes that images with short palette are rendered
+ * withourt artifacts.
+ *
+ * @run main DrawByteBinary
+ */
+
+
+import java.awt.*;
+import java.awt.color.*;
+import java.awt.image.*;
+import static java.awt.image.BufferedImage.*;
+
+
+public class DrawByteBinary {
+
+ public static void main(String args[]) {
+ int w = 100, h = 30;
+ int x = 10;
+ byte[] arr = {(byte)0xff, (byte)0x0, (byte)0x00};
+
+ IndexColorModel newCM = new IndexColorModel(1, 2, arr, arr, arr);
+ BufferedImage orig = new BufferedImage(w, h, TYPE_BYTE_BINARY, newCM);
+ Graphics2D g2d = orig.createGraphics();
+ g2d.setColor(Color.white);
+ g2d.fillRect(0, 0, w, h);
+ g2d.setColor(Color.black);
+ g2d.drawLine(x, 0, x, h);
+ g2d.dispose();
+
+ IndexColorModel origCM = (IndexColorModel)orig.getColorModel();
+ BufferedImage test = new BufferedImage(w, h, TYPE_BYTE_BINARY,origCM);
+ g2d = test.createGraphics();
+ g2d.drawImage(orig, 0, 0, null);
+ g2d.dispose();
+
+ int y = h / 2;
+
+ // we expect white color outside the line
+ if (test.getRGB(x - 1, y) != 0xffffffff) {
+ throw new RuntimeException("Invalid color outside the line.");
+ }
+
+ // we expect black color on the line
+ if (test.getRGB(x, y) != 0xff000000) {
+ throw new RuntimeException("Invalid color on the line.");
+ }
+ }
+}
From e67e7cb5a7efd43e06e98039a581d0adcb593b23 Mon Sep 17 00:00:00 2001
From: Artem Ananiev
Date: Wed, 11 Feb 2009 17:07:06 +0300
Subject: [PATCH 035/292] 6633275: Need to support shaped/translucent windows
Forward-port from 6u14, no public API is introduced
Reviewed-by: anthony, dcherepanov
---
jdk/make/sun/awt/FILES_c_windows.gmk | 5 +-
jdk/make/sun/awt/Makefile | 3 +-
jdk/make/sun/awt/make.depend | 22 +-
jdk/make/sun/awt/mapfile-mawt-vers | 1 +
jdk/make/sun/awt/mapfile-vers-linux | 1 +
jdk/make/sun/xawt/mapfile-vers | 1 +
.../classes/com/sun/awt/AWTUtilities.java | 362 ++++++++++++-
jdk/src/share/classes/java/awt/Component.java | 69 ++-
jdk/src/share/classes/java/awt/Container.java | 5 +-
.../java/awt/DefaultKeyboardFocusManager.java | 2 +-
.../java/awt/GraphicsConfiguration.java | 18 +-
.../classes/java/awt/GraphicsDevice.java | 135 ++++-
.../java/awt/KeyboardFocusManager.java | 12 +-
jdk/src/share/classes/java/awt/Window.java | 288 +++++++++-
.../classes/java/awt/peer/WindowPeer.java | 26 +-
.../classes/javax/swing/RepaintManager.java | 45 +-
.../share/classes/sun/awt/AWTAccessor.java | 139 ++++-
.../share/classes/sun/awt/EmbeddedFrame.java | 11 +-
jdk/src/share/classes/sun/awt/SunToolkit.java | 117 +++-
jdk/src/share/native/sun/awt/utility/rect.c | 102 ++++
.../classes/sun/awt/X11/XNETProtocol.java | 10 +-
.../solaris/classes/sun/awt/X11/XToolkit.java | 34 +-
.../classes/sun/awt/X11/XWindowPeer.java | 67 ++-
.../awt/X11/generator/WrapperGenerator.java | 6 +-
.../sun/awt/X11/generator/xlibtypes.txt | 1 +
.../classes/sun/awt/X11GraphicsConfig.java | 11 +-
.../solaris/native/sun/awt/awt_GraphicsEnv.c | 102 +++-
jdk/src/solaris/native/sun/awt/awt_p.h | 3 +-
.../classes/sun/awt/Win32GraphicsConfig.java | 10 +-
.../sun/awt/Win32GraphicsEnvironment.java | 9 +-
.../awt/windows/TranslucentWindowPainter.java | 398 ++++++++++++++
.../classes/sun/awt/windows/WCanvasPeer.java | 27 +-
.../sun/awt/windows/WComponentPeer.java | 68 +--
.../sun/awt/windows/WFileDialogPeer.java | 8 +-
.../sun/awt/windows/WPrintDialogPeer.java | 8 +-
.../classes/sun/awt/windows/WToolkit.java | 32 +-
.../classes/sun/awt/windows/WWindowPeer.java | 181 ++++++-
.../sun/java2d/opengl/WGLSurfaceData.java | 12 +-
jdk/src/windows/native/sun/awt/utility/rect.h | 12 +-
.../native/sun/java2d/d3d/D3DSurfaceData.cpp | 14 +-
.../native/sun/java2d/opengl/WGLSurfaceData.c | 10 +-
.../native/sun/windows/awt_BitmapUtil.cpp | 226 +++++++-
.../native/sun/windows/awt_BitmapUtil.h | 28 +-
.../native/sun/windows/awt_Component.cpp | 33 +-
.../native/sun/windows/awt_Component.h | 11 +-
.../windows/native/sun/windows/awt_Window.cpp | 406 +++++++++++++-
.../windows/native/sun/windows/awt_Window.h | 38 +-
.../TranslucentJAppletTest.java | 103 ++++
.../TranslucentShapedFrameTest/TSFrame.java | 306 +++++++++++
.../TranslucentShapedFrameTest.form | 230 ++++++++
.../TranslucentShapedFrameTest.java | 359 ++++++++++++
.../sun/awt/Translucency/WindowOpacity.java | 461 ++++++++++++++++
jdk/test/sun/java2d/pipe/RegionOps.java | 510 ++++++++++++++++++
53 files changed, 4878 insertions(+), 220 deletions(-)
create mode 100644 jdk/src/share/native/sun/awt/utility/rect.c
create mode 100644 jdk/src/windows/classes/sun/awt/windows/TranslucentWindowPainter.java
create mode 100644 jdk/test/com/sun/awt/Translucency/TranslucentJAppletTest/TranslucentJAppletTest.java
create mode 100644 jdk/test/com/sun/awt/Translucency/TranslucentShapedFrameTest/TSFrame.java
create mode 100644 jdk/test/com/sun/awt/Translucency/TranslucentShapedFrameTest/TranslucentShapedFrameTest.form
create mode 100644 jdk/test/com/sun/awt/Translucency/TranslucentShapedFrameTest/TranslucentShapedFrameTest.java
create mode 100644 jdk/test/com/sun/awt/Translucency/WindowOpacity.java
create mode 100644 jdk/test/sun/java2d/pipe/RegionOps.java
diff --git a/jdk/make/sun/awt/FILES_c_windows.gmk b/jdk/make/sun/awt/FILES_c_windows.gmk
index 1a9b3b6ad3c..835da687938 100644
--- a/jdk/make/sun/awt/FILES_c_windows.gmk
+++ b/jdk/make/sun/awt/FILES_c_windows.gmk
@@ -1,5 +1,5 @@
#
-# Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -104,7 +104,8 @@ FILES_c = \
OGLVertexCache.c \
WGLGraphicsConfig.c \
WGLSurfaceData.c \
- AccelGlyphCache.c
+ AccelGlyphCache.c \
+ rect.c
FILES_cpp = \
CmdIDList.cpp \
diff --git a/jdk/make/sun/awt/Makefile b/jdk/make/sun/awt/Makefile
index 82a0a681de0..cd89650a597 100644
--- a/jdk/make/sun/awt/Makefile
+++ b/jdk/make/sun/awt/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright 1995-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 1995-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -219,6 +219,7 @@ vpath %.c $(SHARE_SRC)/native/$(PKGDIR)/image/cvutils
vpath %.c $(SHARE_SRC)/native/$(PKGDIR)/shell
vpath %.c $(SHARE_SRC)/native/$(PKGDIR)/medialib
vpath %.c $(SHARE_SRC)/native/$(PKGDIR)/debug
+vpath %.c $(SHARE_SRC)/native/$(PKGDIR)/utility
vpath %.c $(SHARE_SRC)/native/$(PKGDIR)/../java2d
vpath %.c $(SHARE_SRC)/native/$(PKGDIR)/../java2d/loops
vpath %.c $(SHARE_SRC)/native/$(PKGDIR)/../java2d/pipe
diff --git a/jdk/make/sun/awt/make.depend b/jdk/make/sun/awt/make.depend
index 650e4c7fde8..df9d4c0f7c2 100644
--- a/jdk/make/sun/awt/make.depend
+++ b/jdk/make/sun/awt/make.depend
@@ -16,7 +16,7 @@ $(OBJDIR)/AnyShort.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h ../../../src/s
$(OBJDIR)/awt_AWTEvent.obj:: $(CLASSHDRDIR)/java_awt_AWTEvent.h $(CLASSHDRDIR)/java_awt_Component.h $(CLASSHDRDIR)/java_awt_Dimension.h $(CLASSHDRDIR)/java_awt_Event.h $(CLASSHDRDIR)/java_awt_event_FocusEvent.h $(CLASSHDRDIR)/java_awt_event_KeyEvent.h $(CLASSHDRDIR)/java_awt_event_MouseEvent.h $(CLASSHDRDIR)/java_awt_event_WindowEvent.h $(CLASSHDRDIR)/java_awt_Font.h $(CLASSHDRDIR)/sun_awt_FontDescriptor.h $(CLASSHDRDIR)/sun_awt_PlatformFont.h $(CLASSHDRDIR)/sun_awt_windows_WComponentPeer.h $(CLASSHDRDIR)/sun_awt_windows_WFontMetrics.h $(CLASSHDRDIR)/sun_awt_windows_WObjectPeer.h $(CLASSHDRDIR)/sun_awt_windows_WToolkit.h ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/awt/image/cvutils/img_globals.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.h ../../../src/windows/native/sun/windows/alloc.h ../../../src/windows/native/sun/windows/awt.h ../../../src/windows/native/sun/windows/awtmsg.h ../../../src/windows/native/sun/windows/awt_AWTEvent.h ../../../src/windows/native/sun/windows/awt_Brush.h ../../../src/windows/native/sun/windows/awt_Component.h ../../../src/windows/native/sun/windows/awt_Debug.h ../../../src/windows/native/sun/windows/awt_Font.h ../../../src/windows/native/sun/windows/awt_GDIObject.h ../../../src/windows/native/sun/windows/awt_Object.h ../../../src/windows/native/sun/windows/awt_Palette.h ../../../src/windows/native/sun/windows/awt_Pen.h ../../../src/windows/native/sun/windows/awt_Toolkit.h ../../../src/windows/native/sun/windows/awt_Win32GraphicsDevice.h ../../../src/windows/native/sun/windows/colordata.h ../../../src/windows/native/sun/windows/Devices.h ../../../src/windows/native/sun/windows/GDIHashtable.h ../../../src/windows/native/sun/windows/Hashtable.h ../../../src/windows/native/sun/windows/ObjectList.h ../../../src/windows/native/sun/windows/stdhdrs.h
-$(OBJDIR)/awt_BitmapUtil.obj:: ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/windows/alloc.h ../../../src/windows/native/sun/windows/awt.h ../../../src/windows/native/sun/windows/awt_BitmapUtil.h ../../../src/windows/native/sun/windows/awt_Debug.h ../../../src/windows/native/sun/windows/stdhdrs.h
+$(OBJDIR)/awt_BitmapUtil.obj:: ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/windows/alloc.h ../../../src/windows/native/sun/windows/awt.h ../../../src/windows/native/sun/windows/awt_BitmapUtil.h ../../../src/windows/native/sun/windows/awt_Debug.h ../../../src/windows/native/sun/windows/stdhdrs.h ../../../src/windows/native/sun/awt/utility/rect.h
$(OBJDIR)/awt_Brush.obj:: $(CLASSHDRDIR)/sun_awt_windows_WToolkit.h ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/windows/alloc.h ../../../src/windows/native/sun/windows/awt.h ../../../src/windows/native/sun/windows/awtmsg.h ../../../src/windows/native/sun/windows/awt_Brush.h ../../../src/windows/native/sun/windows/awt_Debug.h ../../../src/windows/native/sun/windows/awt_GDIObject.h ../../../src/windows/native/sun/windows/awt_Toolkit.h ../../../src/windows/native/sun/windows/GDIHashtable.h ../../../src/windows/native/sun/windows/Hashtable.h ../../../src/windows/native/sun/windows/stdhdrs.h
@@ -32,7 +32,7 @@ $(OBJDIR)/awt_Clipboard.obj:: $(CLASSHDRDIR)/sun_awt_windows_WClipboard.h $(CLAS
$(OBJDIR)/awt_Color.obj:: $(CLASSHDRDIR)/sun_awt_windows_WColor.h ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/windows/alloc.h ../../../src/windows/native/sun/windows/awt.h ../../../src/windows/native/sun/windows/awt_Color.h ../../../src/windows/native/sun/windows/awt_Debug.h ../../../src/windows/native/sun/windows/stdhdrs.h
-$(OBJDIR)/awt_Component.obj:: $(CLASSHDRDIR)/java_awt_AWTEvent.h $(CLASSHDRDIR)/java_awt_Color.h $(CLASSHDRDIR)/java_awt_Component.h $(CLASSHDRDIR)/java_awt_Dimension.h $(CLASSHDRDIR)/java_awt_Event.h $(CLASSHDRDIR)/java_awt_event_FocusEvent.h $(CLASSHDRDIR)/java_awt_event_InputEvent.h $(CLASSHDRDIR)/java_awt_event_InputMethodEvent.h $(CLASSHDRDIR)/java_awt_event_KeyEvent.h $(CLASSHDRDIR)/java_awt_event_MouseEvent.h $(CLASSHDRDIR)/java_awt_event_MouseWheelEvent.h $(CLASSHDRDIR)/java_awt_event_WindowEvent.h $(CLASSHDRDIR)/java_awt_Font.h $(CLASSHDRDIR)/java_awt_FontMetrics.h $(CLASSHDRDIR)/java_awt_Frame.h $(CLASSHDRDIR)/java_awt_Insets.h $(CLASSHDRDIR)/java_awt_KeyboardFocusManager.h $(CLASSHDRDIR)/java_awt_Menu.h $(CLASSHDRDIR)/java_awt_MenuBar.h $(CLASSHDRDIR)/java_awt_MenuComponent.h $(CLASSHDRDIR)/java_awt_MenuItem.h $(CLASSHDRDIR)/java_awt_peer_MenuComponentPeer.h $(CLASSHDRDIR)/java_awt_Toolkit.h $(CLASSHDRDIR)/java_awt_Window.h $(CLASSHDRDIR)/sun_awt_FontDescriptor.h $(CLASSHDRDIR)/sun_awt_PlatformFont.h $(CLASSHDRDIR)/sun_awt_windows_WCanvasPeer.h $(CLASSHDRDIR)/sun_awt_windows_WComponentPeer.h $(CLASSHDRDIR)/sun_awt_windows_WFontMetrics.h $(CLASSHDRDIR)/sun_awt_windows_WFramePeer.h $(CLASSHDRDIR)/sun_awt_windows_WInputMethod.h $(CLASSHDRDIR)/sun_awt_windows_WMenuBarPeer.h $(CLASSHDRDIR)/sun_awt_windows_WMenuItemPeer.h $(CLASSHDRDIR)/sun_awt_windows_WMenuPeer.h $(CLASSHDRDIR)/sun_awt_windows_WObjectPeer.h $(CLASSHDRDIR)/sun_awt_windows_WPanelPeer.h $(CLASSHDRDIR)/sun_awt_windows_WToolkit.h $(CLASSHDRDIR)/sun_awt_windows_WWindowPeer.h ../../../src/share/javavm/export/jawt.h ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/awt/image/cvutils/img_globals.h ../../../src/share/native/sun/java2d/pipe/Region.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.h ../../../src/windows/native/sun/windows/alloc.h ../../../src/windows/native/sun/windows/awt.h ../../../src/windows/native/sun/windows/awtmsg.h ../../../src/windows/native/sun/windows/awt_AWTEvent.h ../../../src/windows/native/sun/windows/awt_Brush.h ../../../src/windows/native/sun/windows/awt_Canvas.h ../../../src/windows/native/sun/windows/awt_Component.h ../../../src/windows/native/sun/windows/awt_Cursor.h ../../../src/windows/native/sun/windows/awt_Debug.h ../../../src/windows/native/sun/windows/awt_Dimension.h ../../../src/windows/native/sun/windows/awt_DnDDT.h ../../../src/windows/native/sun/windows/awt_Font.h ../../../src/windows/native/sun/windows/awt_Frame.h ../../../src/windows/native/sun/windows/awt_GDIObject.h ../../../src/windows/native/sun/windows/awt_InputEvent.h ../../../src/windows/native/sun/windows/awt_InputTextInfor.h ../../../src/windows/native/sun/windows/awt_Insets.h ../../../src/windows/native/sun/windows/awt_KeyboardFocusManager.h ../../../src/windows/native/sun/windows/awt_KeyEvent.h ../../../src/windows/native/sun/windows/awt_Menu.h ../../../src/windows/native/sun/windows/awt_MenuBar.h ../../../src/windows/native/sun/windows/awt_MenuItem.h ../../../src/windows/native/sun/windows/awt_MouseEvent.h ../../../src/windows/native/sun/windows/awt_Object.h ../../../src/windows/native/sun/windows/awt_Palette.h ../../../src/windows/native/sun/windows/awt_Pen.h ../../../src/windows/native/sun/windows/awt_Toolkit.h ../../../src/windows/native/sun/windows/awt_Win32GraphicsDevice.h ../../../src/windows/native/sun/windows/awt_Window.h ../../../src/windows/native/sun/windows/colordata.h ../../../src/windows/native/sun/windows/ComCtl32Util.h ../../../src/windows/native/sun/windows/Devices.h ../../../src/windows/native/sun/windows/GDIHashtable.h ../../../src/windows/native/sun/windows/Hashtable.h ../../../src/windows/native/sun/windows/ObjectList.h ../../../src/windows/native/sun/windows/stdhdrs.h
+$(OBJDIR)/awt_Component.obj:: $(CLASSHDRDIR)/java_awt_AWTEvent.h $(CLASSHDRDIR)/java_awt_Color.h $(CLASSHDRDIR)/java_awt_Component.h $(CLASSHDRDIR)/java_awt_Dimension.h $(CLASSHDRDIR)/java_awt_Event.h $(CLASSHDRDIR)/java_awt_event_FocusEvent.h $(CLASSHDRDIR)/java_awt_event_InputEvent.h $(CLASSHDRDIR)/java_awt_event_InputMethodEvent.h $(CLASSHDRDIR)/java_awt_event_KeyEvent.h $(CLASSHDRDIR)/java_awt_event_MouseEvent.h $(CLASSHDRDIR)/java_awt_event_MouseWheelEvent.h $(CLASSHDRDIR)/java_awt_event_WindowEvent.h $(CLASSHDRDIR)/java_awt_Font.h $(CLASSHDRDIR)/java_awt_FontMetrics.h $(CLASSHDRDIR)/java_awt_Frame.h $(CLASSHDRDIR)/java_awt_Insets.h $(CLASSHDRDIR)/java_awt_KeyboardFocusManager.h $(CLASSHDRDIR)/java_awt_Menu.h $(CLASSHDRDIR)/java_awt_MenuBar.h $(CLASSHDRDIR)/java_awt_MenuComponent.h $(CLASSHDRDIR)/java_awt_MenuItem.h $(CLASSHDRDIR)/java_awt_peer_MenuComponentPeer.h $(CLASSHDRDIR)/java_awt_Toolkit.h $(CLASSHDRDIR)/java_awt_Window.h $(CLASSHDRDIR)/sun_awt_FontDescriptor.h $(CLASSHDRDIR)/sun_awt_PlatformFont.h $(CLASSHDRDIR)/sun_awt_windows_WCanvasPeer.h $(CLASSHDRDIR)/sun_awt_windows_WComponentPeer.h $(CLASSHDRDIR)/sun_awt_windows_WFontMetrics.h $(CLASSHDRDIR)/sun_awt_windows_WFramePeer.h $(CLASSHDRDIR)/sun_awt_windows_WInputMethod.h $(CLASSHDRDIR)/sun_awt_windows_WMenuBarPeer.h $(CLASSHDRDIR)/sun_awt_windows_WMenuItemPeer.h $(CLASSHDRDIR)/sun_awt_windows_WMenuPeer.h $(CLASSHDRDIR)/sun_awt_windows_WObjectPeer.h $(CLASSHDRDIR)/sun_awt_windows_WPanelPeer.h $(CLASSHDRDIR)/sun_awt_windows_WToolkit.h $(CLASSHDRDIR)/sun_awt_windows_WWindowPeer.h ../../../src/share/javavm/export/jawt.h ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/awt/image/cvutils/img_globals.h ../../../src/share/native/sun/java2d/pipe/Region.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.h ../../../src/windows/native/sun/windows/alloc.h ../../../src/windows/native/sun/windows/awt.h ../../../src/windows/native/sun/windows/awtmsg.h ../../../src/windows/native/sun/windows/awt_AWTEvent.h ../../../src/windows/native/sun/windows/awt_Brush.h ../../../src/windows/native/sun/windows/awt_Canvas.h ../../../src/windows/native/sun/windows/awt_Component.h ../../../src/windows/native/sun/windows/awt_Cursor.h ../../../src/windows/native/sun/windows/awt_Debug.h ../../../src/windows/native/sun/windows/awt_Dimension.h ../../../src/windows/native/sun/windows/awt_DnDDT.h ../../../src/windows/native/sun/windows/awt_Font.h ../../../src/windows/native/sun/windows/awt_Frame.h ../../../src/windows/native/sun/windows/awt_GDIObject.h ../../../src/windows/native/sun/windows/awt_InputEvent.h ../../../src/windows/native/sun/windows/awt_InputTextInfor.h ../../../src/windows/native/sun/windows/awt_Insets.h ../../../src/windows/native/sun/windows/awt_KeyboardFocusManager.h ../../../src/windows/native/sun/windows/awt_KeyEvent.h ../../../src/windows/native/sun/windows/awt_Menu.h ../../../src/windows/native/sun/windows/awt_MenuBar.h ../../../src/windows/native/sun/windows/awt_MenuItem.h ../../../src/windows/native/sun/windows/awt_MouseEvent.h ../../../src/windows/native/sun/windows/awt_Object.h ../../../src/windows/native/sun/windows/awt_Palette.h ../../../src/windows/native/sun/windows/awt_Pen.h ../../../src/windows/native/sun/windows/awt_Toolkit.h ../../../src/windows/native/sun/windows/awt_Win32GraphicsDevice.h ../../../src/windows/native/sun/windows/awt_Window.h ../../../src/windows/native/sun/windows/colordata.h ../../../src/windows/native/sun/windows/ComCtl32Util.h ../../../src/windows/native/sun/windows/Devices.h ../../../src/windows/native/sun/windows/GDIHashtable.h ../../../src/windows/native/sun/windows/Hashtable.h ../../../src/windows/native/sun/windows/ObjectList.h ../../../src/windows/native/sun/windows/stdhdrs.h ../../../src/windows/native/sun/awt/utility/rect.h
$(OBJDIR)/awt_Container.obj:: ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/windows/alloc.h ../../../src/windows/native/sun/windows/awt.h ../../../src/windows/native/sun/windows/awt_Container.h ../../../src/windows/native/sun/windows/awt_Debug.h ../../../src/windows/native/sun/windows/stdhdrs.h
@@ -144,9 +144,9 @@ $(OBJDIR)/awt_Win32GraphicsEnv.obj:: $(CLASSHDRDIR)/java_awt_AWTEvent.h $(CLASSH
$(OBJDIR)/awt_Window.obj:: $(CLASSHDRDIR)/java_awt_AWTEvent.h $(CLASSHDRDIR)/java_awt_Component.h $(CLASSHDRDIR)/java_awt_Container.h $(CLASSHDRDIR)/java_awt_Dialog.h $(CLASSHDRDIR)/java_awt_Dimension.h $(CLASSHDRDIR)/java_awt_Event.h $(CLASSHDRDIR)/java_awt_event_ComponentEvent.h $(CLASSHDRDIR)/java_awt_event_FocusEvent.h $(CLASSHDRDIR)/java_awt_event_KeyEvent.h $(CLASSHDRDIR)/java_awt_event_MouseEvent.h $(CLASSHDRDIR)/java_awt_event_WindowEvent.h $(CLASSHDRDIR)/java_awt_FileDialog.h $(CLASSHDRDIR)/java_awt_Font.h $(CLASSHDRDIR)/java_awt_FontMetrics.h $(CLASSHDRDIR)/java_awt_Frame.h $(CLASSHDRDIR)/java_awt_Insets.h $(CLASSHDRDIR)/java_awt_Menu.h $(CLASSHDRDIR)/java_awt_MenuBar.h $(CLASSHDRDIR)/java_awt_MenuComponent.h $(CLASSHDRDIR)/java_awt_MenuItem.h $(CLASSHDRDIR)/java_awt_peer_MenuComponentPeer.h $(CLASSHDRDIR)/java_awt_Window.h $(CLASSHDRDIR)/sun_awt_FontDescriptor.h $(CLASSHDRDIR)/sun_awt_PlatformFont.h $(CLASSHDRDIR)/sun_awt_windows_WCanvasPeer.h $(CLASSHDRDIR)/sun_awt_windows_WComponentPeer.h $(CLASSHDRDIR)/sun_awt_windows_WDialogPeer.h $(CLASSHDRDIR)/sun_awt_windows_WFileDialogPeer.h $(CLASSHDRDIR)/sun_awt_windows_WFontMetrics.h $(CLASSHDRDIR)/sun_awt_windows_WFramePeer.h $(CLASSHDRDIR)/sun_awt_windows_WMenuBarPeer.h $(CLASSHDRDIR)/sun_awt_windows_WMenuItemPeer.h $(CLASSHDRDIR)/sun_awt_windows_WMenuPeer.h $(CLASSHDRDIR)/sun_awt_windows_WObjectPeer.h $(CLASSHDRDIR)/sun_awt_windows_WToolkit.h $(CLASSHDRDIR)/sun_awt_windows_WWindowPeer.h ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/awt/image/cvutils/img_globals.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.h ../../../src/windows/native/sun/windows/alloc.h ../../../src/windows/native/sun/windows/awt.h ../../../src/windows/native/sun/windows/awtmsg.h ../../../src/windows/native/sun/windows/awt_BitmapUtil.h ../../../src/windows/native/sun/windows/awt_Brush.h ../../../src/windows/native/sun/windows/awt_Canvas.h ../../../src/windows/native/sun/windows/awt_Component.h ../../../src/windows/native/sun/windows/awt_Container.h ../../../src/windows/native/sun/windows/awt_Debug.h ../../../src/windows/native/sun/windows/awt_Dialog.h ../../../src/windows/native/sun/windows/awt_FileDialog.h ../../../src/windows/native/sun/windows/awt_Font.h ../../../src/windows/native/sun/windows/awt_Frame.h ../../../src/windows/native/sun/windows/awt_GDIObject.h ../../../src/windows/native/sun/windows/awt_IconCursor.h ../../../src/windows/native/sun/windows/awt_Insets.h ../../../src/windows/native/sun/windows/awt_Menu.h ../../../src/windows/native/sun/windows/awt_MenuBar.h ../../../src/windows/native/sun/windows/awt_MenuItem.h ../../../src/windows/native/sun/windows/awt_Object.h ../../../src/windows/native/sun/windows/awt_Palette.h ../../../src/windows/native/sun/windows/awt_Panel.h ../../../src/windows/native/sun/windows/awt_Pen.h ../../../src/windows/native/sun/windows/awt_PrintDialog.h ../../../src/windows/native/sun/windows/awt_Toolkit.h ../../../src/windows/native/sun/windows/awt_Win32GraphicsDevice.h ../../../src/windows/native/sun/windows/awt_Window.h ../../../src/windows/native/sun/windows/colordata.h ../../../src/windows/native/sun/windows/Devices.h ../../../src/windows/native/sun/windows/GDIHashtable.h ../../../src/windows/native/sun/windows/Hashtable.h ../../../src/windows/native/sun/windows/ObjectList.h ../../../src/windows/native/sun/windows/stdhdrs.h
-$(OBJDIR)/Blit.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_Blit.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/pipe/Region.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
+$(OBJDIR)/Blit.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_Blit.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/pipe/Region.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/sun/awt/utility/rect.h ../../../src/windows/native/sun/java2d/j2d_md.h
-$(OBJDIR)/BlitBg.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_BlitBg.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/pipe/Region.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
+$(OBJDIR)/BlitBg.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_BlitBg.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/pipe/Region.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/sun/awt/utility/rect.h ../../../src/windows/native/sun/java2d/j2d_md.h
$(OBJDIR)/BufferedMaskBlit.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_pipe_BufferedMaskBlit.h $(CLASSHDRDIR)/sun_java2d_pipe_BufferedOpCodes.h ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/ByteGray.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/loops/IntArgb.h ../../../src/share/native/sun/java2d/loops/IntBgr.h ../../../src/share/native/sun/java2d/loops/IntDcm.h ../../../src/share/native/sun/java2d/loops/IntRgb.h ../../../src/share/native/sun/java2d/loops/UshortGray.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
@@ -240,11 +240,11 @@ $(OBJDIR)/GDIHashtable.obj:: $(CLASSHDRDIR)/java_awt_AWTEvent.h $(CLASSHDRDIR)/j
$(OBJDIR)/GDIRenderer.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/java_awt_AWTEvent.h $(CLASSHDRDIR)/java_awt_Component.h $(CLASSHDRDIR)/java_awt_Dimension.h $(CLASSHDRDIR)/java_awt_Event.h $(CLASSHDRDIR)/java_awt_event_FocusEvent.h $(CLASSHDRDIR)/java_awt_event_KeyEvent.h $(CLASSHDRDIR)/java_awt_event_MouseEvent.h $(CLASSHDRDIR)/java_awt_event_WindowEvent.h $(CLASSHDRDIR)/java_awt_Font.h $(CLASSHDRDIR)/java_awt_geom_PathIterator.h $(CLASSHDRDIR)/sun_awt_FontDescriptor.h $(CLASSHDRDIR)/sun_awt_PlatformFont.h $(CLASSHDRDIR)/sun_awt_windows_WComponentPeer.h $(CLASSHDRDIR)/sun_awt_windows_WFontMetrics.h $(CLASSHDRDIR)/sun_awt_windows_WObjectPeer.h $(CLASSHDRDIR)/sun_awt_windows_WToolkit.h $(CLASSHDRDIR)/sun_java2d_windows_GDIRenderer.h ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/awt/image/cvutils/img_globals.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/j2d_md.h ../../../src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.h ../../../src/windows/native/sun/windows/alloc.h ../../../src/windows/native/sun/windows/awt.h ../../../src/windows/native/sun/windows/awtmsg.h ../../../src/windows/native/sun/windows/awt_Brush.h ../../../src/windows/native/sun/windows/awt_Component.h ../../../src/windows/native/sun/windows/awt_Debug.h ../../../src/windows/native/sun/windows/awt_Font.h ../../../src/windows/native/sun/windows/awt_GDIObject.h ../../../src/windows/native/sun/windows/awt_Object.h ../../../src/windows/native/sun/windows/awt_Palette.h ../../../src/windows/native/sun/windows/awt_Pen.h ../../../src/windows/native/sun/windows/awt_Toolkit.h ../../../src/windows/native/sun/windows/awt_Win32GraphicsDevice.h ../../../src/windows/native/sun/windows/colordata.h ../../../src/windows/native/sun/windows/Devices.h ../../../src/windows/native/sun/windows/GDIHashtable.h ../../../src/windows/native/sun/windows/Hashtable.h ../../../src/windows/native/sun/windows/ObjectList.h ../../../src/windows/native/sun/windows/stdhdrs.h
-$(OBJDIR)/GDIWindowSurfaceData.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/java_awt_AWTEvent.h $(CLASSHDRDIR)/java_awt_Component.h $(CLASSHDRDIR)/java_awt_Dimension.h $(CLASSHDRDIR)/java_awt_Event.h $(CLASSHDRDIR)/java_awt_event_FocusEvent.h $(CLASSHDRDIR)/java_awt_event_KeyEvent.h $(CLASSHDRDIR)/java_awt_event_MouseEvent.h $(CLASSHDRDIR)/java_awt_event_WindowEvent.h $(CLASSHDRDIR)/java_awt_Font.h $(CLASSHDRDIR)/sun_awt_FontDescriptor.h $(CLASSHDRDIR)/sun_awt_PlatformFont.h $(CLASSHDRDIR)/sun_awt_windows_WComponentPeer.h $(CLASSHDRDIR)/sun_awt_windows_WFontMetrics.h $(CLASSHDRDIR)/sun_awt_windows_WObjectPeer.h $(CLASSHDRDIR)/sun_awt_windows_WToolkit.h $(CLASSHDRDIR)/sun_java2d_windows_GDIWindowSurfaceData.h ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/awt/image/cvutils/img_globals.h ../../../src/share/native/sun/java2d/Disposer.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/pipe/Region.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/j2d_md.h ../../../src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.h ../../../src/windows/native/sun/java2d/windows/WindowsFlags.h ../../../src/windows/native/sun/windows/alloc.h ../../../src/windows/native/sun/windows/awt.h ../../../src/windows/native/sun/windows/awtmsg.h ../../../src/windows/native/sun/windows/awt_Brush.h ../../../src/windows/native/sun/windows/awt_Component.h ../../../src/windows/native/sun/windows/awt_Debug.h ../../../src/windows/native/sun/windows/awt_Font.h ../../../src/windows/native/sun/windows/awt_GDIObject.h ../../../src/windows/native/sun/windows/awt_Object.h ../../../src/windows/native/sun/windows/awt_Palette.h ../../../src/windows/native/sun/windows/awt_Pen.h ../../../src/windows/native/sun/windows/awt_Toolkit.h ../../../src/windows/native/sun/windows/awt_Win32GraphicsDevice.h ../../../src/windows/native/sun/windows/colordata.h ../../../src/windows/native/sun/windows/Devices.h ../../../src/windows/native/sun/windows/GDIHashtable.h ../../../src/windows/native/sun/windows/Hashtable.h ../../../src/windows/native/sun/windows/ObjectList.h ../../../src/windows/native/sun/windows/stdhdrs.h
+$(OBJDIR)/GDIWindowSurfaceData.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/java_awt_AWTEvent.h $(CLASSHDRDIR)/java_awt_Component.h $(CLASSHDRDIR)/java_awt_Dimension.h $(CLASSHDRDIR)/java_awt_Event.h $(CLASSHDRDIR)/java_awt_event_FocusEvent.h $(CLASSHDRDIR)/java_awt_event_KeyEvent.h $(CLASSHDRDIR)/java_awt_event_MouseEvent.h $(CLASSHDRDIR)/java_awt_event_WindowEvent.h $(CLASSHDRDIR)/java_awt_Font.h $(CLASSHDRDIR)/sun_awt_FontDescriptor.h $(CLASSHDRDIR)/sun_awt_PlatformFont.h $(CLASSHDRDIR)/sun_awt_windows_WComponentPeer.h $(CLASSHDRDIR)/sun_awt_windows_WFontMetrics.h $(CLASSHDRDIR)/sun_awt_windows_WObjectPeer.h $(CLASSHDRDIR)/sun_awt_windows_WToolkit.h $(CLASSHDRDIR)/sun_java2d_windows_GDIWindowSurfaceData.h ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/awt/image/cvutils/img_globals.h ../../../src/share/native/sun/java2d/Disposer.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/pipe/Region.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/j2d_md.h ../../../src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.h ../../../src/windows/native/sun/java2d/windows/WindowsFlags.h ../../../src/windows/native/sun/windows/alloc.h ../../../src/windows/native/sun/windows/awt.h ../../../src/windows/native/sun/windows/awtmsg.h ../../../src/windows/native/sun/windows/awt_Brush.h ../../../src/windows/native/sun/windows/awt_Component.h ../../../src/windows/native/sun/windows/awt_Debug.h ../../../src/windows/native/sun/windows/awt_Font.h ../../../src/windows/native/sun/windows/awt_GDIObject.h ../../../src/windows/native/sun/windows/awt_Object.h ../../../src/windows/native/sun/windows/awt_Palette.h ../../../src/windows/native/sun/windows/awt_Pen.h ../../../src/windows/native/sun/windows/awt_Toolkit.h ../../../src/windows/native/sun/windows/awt_Win32GraphicsDevice.h ../../../src/windows/native/sun/windows/colordata.h ../../../src/windows/native/sun/windows/Devices.h ../../../src/windows/native/sun/windows/GDIHashtable.h ../../../src/windows/native/sun/windows/Hashtable.h ../../../src/windows/native/sun/windows/ObjectList.h ../../../src/windows/native/sun/awt/utility/rect.h ../../../src/windows/native/sun/windows/stdhdrs.h
$(OBJDIR)/gifdecoder.obj:: ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/jlong_md.h
-$(OBJDIR)/GraphicsPrimitiveMgr.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_GraphicsPrimitiveMgr.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/java2d/loops/AlphaMacros.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/ByteGray.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/loops/IntArgb.h ../../../src/share/native/sun/java2d/loops/IntDcm.h ../../../src/share/native/sun/java2d/loops/UshortGray.h ../../../src/share/native/sun/java2d/pipe/Region.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
+$(OBJDIR)/GraphicsPrimitiveMgr.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_GraphicsPrimitiveMgr.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/java2d/loops/AlphaMacros.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/ByteGray.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/loops/IntArgb.h ../../../src/share/native/sun/java2d/loops/IntDcm.h ../../../src/share/native/sun/java2d/loops/UshortGray.h ../../../src/share/native/sun/java2d/pipe/Region.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/awt/utility/rect.h ../../../src/windows/native/sun/java2d/j2d_md.h
$(OBJDIR)/Hashtable.obj:: $(CLASSHDRDIR)/sun_awt_windows_WToolkit.h ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/windows/alloc.h ../../../src/windows/native/sun/windows/awt.h ../../../src/windows/native/sun/windows/awtmsg.h ../../../src/windows/native/sun/windows/awt_Debug.h ../../../src/windows/native/sun/windows/awt_Toolkit.h ../../../src/windows/native/sun/windows/Hashtable.h ../../../src/windows/native/sun/windows/stdhdrs.h
@@ -272,7 +272,7 @@ $(OBJDIR)/IntRgb.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h ../../../src/sha
$(OBJDIR)/IntRgbx.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/sun/java2d/loops/AlphaMacros.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/AnyInt.h ../../../src/share/native/sun/java2d/loops/ByteGray.h ../../../src/share/native/sun/java2d/loops/ByteIndexed.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/loops/IntArgb.h ../../../src/share/native/sun/java2d/loops/IntArgbBm.h ../../../src/share/native/sun/java2d/loops/IntArgbPre.h ../../../src/share/native/sun/java2d/loops/IntDcm.h ../../../src/share/native/sun/java2d/loops/IntRgb.h ../../../src/share/native/sun/java2d/loops/IntRgbx.h ../../../src/share/native/sun/java2d/loops/LineUtils.h ../../../src/share/native/sun/java2d/loops/LoopMacros.h ../../../src/share/native/sun/java2d/loops/ThreeByteBgr.h ../../../src/share/native/sun/java2d/loops/UshortGray.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
-$(OBJDIR)/MaskBlit.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_MaskBlit.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/pipe/Region.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
+$(OBJDIR)/MaskBlit.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_MaskBlit.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/pipe/Region.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/sun/java2d/j2d_md.h ../../../src/windows/native/sun/awt/utility/rect.h
$(OBJDIR)/MaskFill.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_MaskFill.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
@@ -284,7 +284,7 @@ $(OBJDIR)/OGLBlitLoops.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDR
$(OBJDIR)/OGLBufImgOps.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/java_awt_image_AffineTransformOp.h $(CLASSHDRDIR)/sun_java2d_opengl_OGLContext.h $(CLASSHDRDIR)/sun_java2d_opengl_OGLSurfaceData.h $(CLASSHDRDIR)/sun_java2d_pipe_BufferedContext.h $(CLASSHDRDIR)/sun_java2d_pipe_hw_AccelSurface.h ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/opengl/J2D_GL/gl.h ../../../src/share/native/sun/java2d/opengl/J2D_GL/glext.h ../../../src/share/native/sun/java2d/opengl/OGLBufImgOps.h ../../../src/share/native/sun/java2d/opengl/OGLContext.h ../../../src/share/native/sun/java2d/opengl/OGLFuncMacros.h ../../../src/share/native/sun/java2d/opengl/OGLFuncs.h ../../../src/share/native/sun/java2d/opengl/OGLRenderQueue.h ../../../src/share/native/sun/java2d/opengl/OGLSurfaceData.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/j2d_md.h ../../../src/windows/native/sun/java2d/opengl/J2D_GL/wglext.h ../../../src/windows/native/sun/java2d/opengl/OGLFuncs_md.h
-$(OBJDIR)/OGLContext.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/java_awt_image_AffineTransformOp.h $(CLASSHDRDIR)/sun_java2d_opengl_OGLContext.h $(CLASSHDRDIR)/sun_java2d_opengl_OGLSurfaceData.h $(CLASSHDRDIR)/sun_java2d_pipe_BufferedContext.h $(CLASSHDRDIR)/sun_java2d_pipe_hw_AccelSurface.h $(CLASSHDRDIR)/sun_java2d_SunGraphics2D.h ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/opengl/J2D_GL/gl.h ../../../src/share/native/sun/java2d/opengl/J2D_GL/glext.h ../../../src/share/native/sun/java2d/opengl/OGLContext.h ../../../src/share/native/sun/java2d/opengl/OGLFuncMacros.h ../../../src/share/native/sun/java2d/opengl/OGLFuncs.h ../../../src/share/native/sun/java2d/opengl/OGLRenderQueue.h ../../../src/share/native/sun/java2d/opengl/OGLSurfaceData.h ../../../src/share/native/sun/java2d/pipe/Region.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/j2d_md.h ../../../src/windows/native/sun/java2d/opengl/J2D_GL/wglext.h ../../../src/windows/native/sun/java2d/opengl/OGLFuncs_md.h
+$(OBJDIR)/OGLContext.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/java_awt_image_AffineTransformOp.h $(CLASSHDRDIR)/sun_java2d_opengl_OGLContext.h $(CLASSHDRDIR)/sun_java2d_opengl_OGLSurfaceData.h $(CLASSHDRDIR)/sun_java2d_pipe_BufferedContext.h $(CLASSHDRDIR)/sun_java2d_pipe_hw_AccelSurface.h $(CLASSHDRDIR)/sun_java2d_SunGraphics2D.h ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/opengl/J2D_GL/gl.h ../../../src/share/native/sun/java2d/opengl/J2D_GL/glext.h ../../../src/share/native/sun/java2d/opengl/OGLContext.h ../../../src/share/native/sun/java2d/opengl/OGLFuncMacros.h ../../../src/share/native/sun/java2d/opengl/OGLFuncs.h ../../../src/share/native/sun/java2d/opengl/OGLRenderQueue.h ../../../src/share/native/sun/java2d/opengl/OGLSurfaceData.h ../../../src/share/native/sun/java2d/pipe/Region.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/j2d_md.h ../../../src/windows/native/sun/java2d/opengl/J2D_GL/wglext.h ../../../src/windows/native/sun/java2d/opengl/OGLFuncs_md.h ../../../src/windows/native/sun/awt/utility/rect.h
$(OBJDIR)/OGLFuncs.obj:: ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/java2d/opengl/J2D_GL/gl.h ../../../src/share/native/sun/java2d/opengl/J2D_GL/glext.h ../../../src/share/native/sun/java2d/opengl/OGLFuncMacros.h ../../../src/share/native/sun/java2d/opengl/OGLFuncs.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/opengl/J2D_GL/wglext.h ../../../src/windows/native/sun/java2d/opengl/OGLFuncs_md.h
@@ -306,11 +306,11 @@ $(OBJDIR)/OGLVertexCache.obj:: $(CLASSHDRDIR)/java_awt_image_AffineTransformOp.h
$(OBJDIR)/ProcessPath.obj:: $(CLASSHDRDIR)/java_awt_geom_PathIterator.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/java2d/loops/ProcessPath.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
-$(OBJDIR)/Region.obj:: ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/java2d/pipe/Region.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/jlong_md.h
+$(OBJDIR)/Region.obj:: ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/java2d/pipe/Region.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/awt/utility/rect.h
$(OBJDIR)/RenderBuffer.obj:: $(CLASSHDRDIR)/sun_java2d_pipe_RenderBuffer.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/jlong_md.h
-$(OBJDIR)/ScaledBlit.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_ScaledBlit.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/pipe/Region.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
+$(OBJDIR)/ScaledBlit.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_ScaledBlit.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/pipe/Region.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/j2d_md.h ../../../src/windows/native/sun/awt/utility/rect.h
$(OBJDIR)/ShapeSpanIterator.obj:: $(CLASSHDRDIR)/java_awt_geom_PathIterator.h $(CLASSHDRDIR)/sun_java2d_pipe_ShapeSpanIterator.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/java2d/pipe/PathConsumer2D.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
@@ -326,7 +326,7 @@ $(OBJDIR)/ThreeByteBgr.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h ../../../s
$(OBJDIR)/Trace.obj:: ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/jlong_md.h
-$(OBJDIR)/TransformHelper.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/java_awt_image_AffineTransformOp.h $(CLASSHDRDIR)/sun_java2d_loops_TransformHelper.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/pipe/Region.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
+$(OBJDIR)/TransformHelper.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/java_awt_image_AffineTransformOp.h $(CLASSHDRDIR)/sun_java2d_loops_TransformHelper.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/pipe/Region.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/j2d_md.h ../../../src/windows/native/sun/awt/utility/rect.h
$(OBJDIR)/Ushort4444Argb.obj:: $(CLASSHDRDIR)/java_awt_AlphaComposite.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/sun/java2d/loops/AlphaMacros.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/AnyShort.h ../../../src/share/native/sun/java2d/loops/ByteGray.h ../../../src/share/native/sun/java2d/loops/ByteIndexed.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/loops/IntArgb.h ../../../src/share/native/sun/java2d/loops/IntArgbBm.h ../../../src/share/native/sun/java2d/loops/IntDcm.h ../../../src/share/native/sun/java2d/loops/IntRgb.h ../../../src/share/native/sun/java2d/loops/LineUtils.h ../../../src/share/native/sun/java2d/loops/LoopMacros.h ../../../src/share/native/sun/java2d/loops/ThreeByteBgr.h ../../../src/share/native/sun/java2d/loops/Ushort4444Argb.h ../../../src/share/native/sun/java2d/loops/UshortGray.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
diff --git a/jdk/make/sun/awt/mapfile-mawt-vers b/jdk/make/sun/awt/mapfile-mawt-vers
index ca3b430c57b..f24b57ec991 100644
--- a/jdk/make/sun/awt/mapfile-mawt-vers
+++ b/jdk/make/sun/awt/mapfile-mawt-vers
@@ -291,6 +291,7 @@ SUNWprivate_1.1 {
Java_sun_awt_X11GraphicsConfig_createBackBuffer;
Java_sun_awt_X11GraphicsConfig_destroyBackBuffer;
Java_sun_awt_X11GraphicsConfig_swapBuffers;
+ Java_sun_awt_X11GraphicsConfig_isTranslucencyCapable;
Java_sun_awt_X11GraphicsDevice_isDBESupported;
Java_sun_awt_X11GraphicsDevice_getDisplay;
Java_sun_awt_X11GraphicsDevice_getDoubleBufferVisuals;
diff --git a/jdk/make/sun/awt/mapfile-vers-linux b/jdk/make/sun/awt/mapfile-vers-linux
index 83afeebc7f2..a1e88de623c 100644
--- a/jdk/make/sun/awt/mapfile-vers-linux
+++ b/jdk/make/sun/awt/mapfile-vers-linux
@@ -407,6 +407,7 @@ SUNWprivate_1.1 {
Java_sun_awt_X11GraphicsConfig_getNumColors;
Java_sun_awt_X11GraphicsConfig_getXResolution;
Java_sun_awt_X11GraphicsConfig_getYResolution;
+ Java_sun_awt_X11GraphicsConfig_isTranslucencyCapable;
Java_sun_awt_X11GraphicsDevice_isDBESupported;
Java_sun_awt_X11GraphicsDevice_getDisplay;
Java_sun_awt_X11GraphicsDevice_getDoubleBufferVisuals;
diff --git a/jdk/make/sun/xawt/mapfile-vers b/jdk/make/sun/xawt/mapfile-vers
index 3f6bcdeb821..7bffbfd52bd 100644
--- a/jdk/make/sun/xawt/mapfile-vers
+++ b/jdk/make/sun/xawt/mapfile-vers
@@ -217,6 +217,7 @@ SUNWprivate_1.1 {
Java_sun_awt_X11GraphicsConfig_createBackBuffer;
Java_sun_awt_X11GraphicsConfig_destroyBackBuffer;
Java_sun_awt_X11GraphicsConfig_swapBuffers;
+ Java_sun_awt_X11GraphicsConfig_isTranslucencyCapable;
Java_java_awt_Insets_initIDs;
Java_java_awt_KeyboardFocusManager_initIDs;
Java_java_awt_Font_initIDs;
diff --git a/jdk/src/share/classes/com/sun/awt/AWTUtilities.java b/jdk/src/share/classes/com/sun/awt/AWTUtilities.java
index 818ac6f53e0..bf0628b4712 100644
--- a/jdk/src/share/classes/com/sun/awt/AWTUtilities.java
+++ b/jdk/src/share/classes/com/sun/awt/AWTUtilities.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,17 +26,37 @@
package com.sun.awt;
import java.awt.*;
-import sun.awt.AWTAccessor;
+import sun.awt.AWTAccessor;
+import sun.awt.SunToolkit;
/**
* A collection of utility methods for AWT.
*
* The functionality provided by the static methods of the class includes:
*
+ * - Setting shapes on top-level windows
+ *
- Setting a constant alpha value for each pixel of a top-level window
+ *
- Making a window non-opaque, after that it paints only explicitly
+ * painted pixels on the screen, with arbitrary alpha values for every pixel.
*
- Setting a 'mixing-cutout' shape for a component.
*
*
+ * A "top-level window" is an instance of the {@code Window} class (or its
+ * descendant, such as {@code JFrame}).
+ *
+ * Some of the mentioned features may not be supported by the native platform.
+ * To determine whether a particular feature is supported, the user must use
+ * the {@code isTranslucencySupported()} method of the class passing a desired
+ * translucency kind (a member of the {@code Translucency} enum) as an
+ * argument.
+ *
+ * The per-pixel alpha feature also requires the user to create her/his
+ * windows using a translucency-capable graphics configuration.
+ * The {@code isTranslucencyCapable()} method must
+ * be used to verify whether any given GraphicsConfiguration supports
+ * the trasnlcency effects.
+ *
* WARNING: This class is an implementation detail and only meant
* for limited use outside of the core platform. This API may change
* drastically between update release, and it may even be
@@ -50,6 +70,344 @@ public final class AWTUtilities {
private AWTUtilities() {
}
+ /** Kinds of translucency supported by the underlying system.
+ * @see #isTranslucencySupported
+ */
+ public static enum Translucency {
+ /**
+ * Represents support in the underlying system for windows each pixel
+ * of which is guaranteed to be either completely opaque, with
+ * an alpha value of 1.0, or completely transparent, with an alpha
+ * value of 0.0.
+ */
+ PERPIXEL_TRANSPARENT,
+
+ /**
+ * Represents support in the underlying system for windows all of
+ * the pixels of which have the same alpha value between or including
+ * 0.0 and 1.0.
+ */
+ TRANSLUCENT,
+
+ /**
+ * Represents support in the underlying system for windows that
+ * contain or might contain pixels with arbitrary alpha values
+ * between and including 0.0 and 1.0.
+ */
+ PERPIXEL_TRANSLUCENT;
+ }
+
+
+ /**
+ * Returns whether the given level of translucency is supported by
+ * the underlying system.
+ *
+ * Note that this method may sometimes return the value
+ * indicating that the particular level is supported, but
+ * the native windowing system may still not support the
+ * given level of translucency (due to the bugs in
+ * the windowing system).
+ *
+ * @param translucencyKind a kind of translucency support
+ * (either PERPIXEL_TRANSPARENT,
+ * TRANSLUCENT, or PERPIXEL_TRANSLUCENT)
+ * @return whether the given translucency kind is supported
+ */
+ public static boolean isTranslucencySupported(Translucency translucencyKind) {
+ switch (translucencyKind) {
+ case PERPIXEL_TRANSPARENT:
+ return isWindowShapingSupported();
+ case TRANSLUCENT:
+ return isWindowOpacitySupported();
+ case PERPIXEL_TRANSLUCENT:
+ return isWindowTranslucencySupported();
+ }
+ return false;
+ }
+
+
+ /**
+ * Returns whether the windowing system supports changing the opacity
+ * value of top-level windows.
+ * Note that this method may sometimes return true, but the native
+ * windowing system may still not support the concept of
+ * translucency (due to the bugs in the windowing system).
+ */
+ private static boolean isWindowOpacitySupported() {
+ Toolkit curToolkit = Toolkit.getDefaultToolkit();
+ if (!(curToolkit instanceof SunToolkit)) {
+ return false;
+ }
+ return ((SunToolkit)curToolkit).isWindowOpacitySupported();
+ }
+
+ /**
+ * Set the opacity of the window. The opacity is at the range [0..1].
+ * Note that setting the opacity level of 0 may or may not disable
+ * the mouse event handling on this window. This is
+ * a platform-dependent behavior.
+ *
+ * In order for this method to enable the translucency effect,
+ * the isTranslucencySupported() method should indicate that the
+ * TRANSLUCENT level of translucency is supported.
+ *
+ *
Also note that the window must not be in the full-screen mode
+ * when setting the opacity value < 1.0f. Otherwise
+ * the IllegalArgumentException is thrown.
+ *
+ * @param window the window to set the opacity level to
+ * @param opacity the opacity level to set to the window
+ * @throws NullPointerException if the window argument is null
+ * @throws IllegalArgumentException if the opacity is out of
+ * the range [0..1]
+ * @throws IllegalArgumentException if the window is in full screen mode,
+ * and the opacity is less than 1.0f
+ * @throws UnsupportedOperationException if the TRANSLUCENT translucency
+ * kind is not supported
+ */
+ public static void setWindowOpacity(Window window, float opacity) {
+ if (window == null) {
+ throw new NullPointerException(
+ "The window argument should not be null.");
+ }
+
+ AWTAccessor.getWindowAccessor().setOpacity(window, opacity);
+ }
+
+ /**
+ * Get the opacity of the window. If the opacity has not
+ * yet being set, this method returns 1.0.
+ *
+ * @param window the window to get the opacity level from
+ * @throws NullPointerException if the window argument is null
+ */
+ public static float getWindowOpacity(Window window) {
+ if (window == null) {
+ throw new NullPointerException(
+ "The window argument should not be null.");
+ }
+
+ return AWTAccessor.getWindowAccessor().getOpacity(window);
+ }
+
+ /**
+ * Returns whether the windowing system supports changing the shape
+ * of top-level windows.
+ * Note that this method may sometimes return true, but the native
+ * windowing system may still not support the concept of
+ * shaping (due to the bugs in the windowing system).
+ */
+ public static boolean isWindowShapingSupported() {
+ Toolkit curToolkit = Toolkit.getDefaultToolkit();
+ if (!(curToolkit instanceof SunToolkit)) {
+ return false;
+ }
+ return ((SunToolkit)curToolkit).isWindowShapingSupported();
+ }
+
+ /**
+ * Returns an object that implements the Shape interface and represents
+ * the shape previously set with the call to the setWindowShape() method.
+ * If no shape has been set yet, or the shape has been reset to null,
+ * this method returns null.
+ *
+ * @param window the window to get the shape from
+ * @return the current shape of the window
+ * @throws NullPointerException if the window argument is null
+ */
+ public static Shape getWindowShape(Window window) {
+ if (window == null) {
+ throw new NullPointerException(
+ "The window argument should not be null.");
+ }
+ return AWTAccessor.getWindowAccessor().getShape(window);
+ }
+
+ /**
+ * Sets a shape for the given window.
+ * If the shape argument is null, this methods restores
+ * the default shape making the window rectangular.
+ *
Note that in order to set a shape, the window must be undecorated.
+ * If the window is decorated, this method ignores the {@code shape}
+ * argument and resets the shape to null.
+ *
Also note that the window must not be in the full-screen mode
+ * when setting a non-null shape. Otherwise the IllegalArgumentException
+ * is thrown.
+ *
Depending on the platform, the method may return without
+ * effecting the shape of the window if the window has a non-null warning
+ * string ({@link Window#getWarningString()}). In this case the passed
+ * shape object is ignored.
+ *
+ * @param window the window to set the shape to
+ * @param shape the shape to set to the window
+ * @throws NullPointerException if the window argument is null
+ * @throws IllegalArgumentException if the window is in full screen mode,
+ * and the shape is not null
+ * @throws UnsupportedOperationException if the PERPIXEL_TRANSPARENT
+ * translucency kind is not supported
+ */
+ public static void setWindowShape(Window window, Shape shape) {
+ if (window == null) {
+ throw new NullPointerException(
+ "The window argument should not be null.");
+ }
+ AWTAccessor.getWindowAccessor().setShape(window, shape);
+ }
+
+ private static boolean isWindowTranslucencySupported() {
+ /*
+ * Per-pixel alpha is supported if all the conditions are TRUE:
+ * 1. The toolkit is a sort of SunToolkit
+ * 2. The toolkit supports translucency in general
+ * (isWindowTranslucencySupported())
+ * 3. There's at least one translucency-capable
+ * GraphicsConfiguration
+ */
+
+ Toolkit curToolkit = Toolkit.getDefaultToolkit();
+ if (!(curToolkit instanceof SunToolkit)) {
+ return false;
+ }
+
+ if (!((SunToolkit)curToolkit).isWindowTranslucencySupported()) {
+ return false;
+ }
+
+ GraphicsEnvironment env =
+ GraphicsEnvironment.getLocalGraphicsEnvironment();
+
+ // If the default GC supports translucency return true.
+ // It is important to optimize the verification this way,
+ // see CR 6661196 for more details.
+ if (isTranslucencyCapable(env.getDefaultScreenDevice()
+ .getDefaultConfiguration()))
+ {
+ return true;
+ }
+
+ // ... otherwise iterate through all the GCs.
+ GraphicsDevice[] devices = env.getScreenDevices();
+
+ for (int i = 0; i < devices.length; i++) {
+ GraphicsConfiguration[] configs = devices[i].getConfigurations();
+ for (int j = 0; j < configs.length; j++) {
+ if (isTranslucencyCapable(configs[j])) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Enables the per-pixel alpha support for the given window.
+ * Once the window becomes non-opaque (the isOpaque is set to false),
+ * the drawing sub-system is starting to respect the alpha value of each
+ * separate pixel. If a pixel gets painted with alpha color component
+ * equal to zero, it becomes visually transparent, if the alpha of the
+ * pixel is equal to 255, the pixel is fully opaque. Interim values
+ * of the alpha color component make the pixel semi-transparent (i.e.
+ * translucent).
+ *
Note that in order for the window to support the per-pixel alpha
+ * mode, the window must be created using the GraphicsConfiguration
+ * for which the {@link #isTranslucencyCapable}
+ * method returns true.
+ *
Also note that some native systems enable the per-pixel translucency
+ * mode for any window created using the translucency-compatible
+ * graphics configuration. However, it is highly recommended to always
+ * invoke the setWindowOpaque() method for these windows, at least for
+ * the sake of cross-platform compatibility reasons.
+ *
Also note that the window must not be in the full-screen mode
+ * when making it non-opaque. Otherwise the IllegalArgumentException
+ * is thrown.
+ *
If the window is a {@code Frame} or a {@code Dialog}, the window must
+ * be undecorated prior to enabling the per-pixel translucency effect (see
+ * {@link Frame#setUndecorated()} and/or {@link Dialog#setUndecorated()}).
+ * If the window becomes decorated through a subsequent call to the
+ * corresponding {@code setUndecorated()} method, the per-pixel
+ * translucency effect will be disabled and the opaque property reset to
+ * {@code true}.
+ *
Depending on the platform, the method may return without
+ * effecting the opaque property of the window if the window has a non-null
+ * warning string ({@link Window#getWarningString()}). In this case
+ * the passed 'isOpaque' value is ignored.
+ *
+ * @param window the window to set the shape to
+ * @param isOpaque whether the window must be opaque (true),
+ * or translucent (false)
+ * @throws NullPointerException if the window argument is null
+ * @throws IllegalArgumentException if the window uses
+ * a GraphicsConfiguration for which the
+ * {@code isTranslucencyCapable()}
+ * method returns false
+ * @throws IllegalArgumentException if the window is in full screen mode,
+ * and the isOpaque is false
+ * @throws IllegalArgumentException if the window is decorated and the
+ * isOpaque argument is {@code false}.
+ * @throws UnsupportedOperationException if the PERPIXEL_TRANSLUCENT
+ * translucency kind is not supported
+ */
+ public static void setWindowOpaque(Window window, boolean isOpaque) {
+ if (window == null) {
+ throw new NullPointerException(
+ "The window argument should not be null.");
+ }
+ if (!isOpaque && !isTranslucencySupported(Translucency.PERPIXEL_TRANSLUCENT)) {
+ throw new UnsupportedOperationException(
+ "The PERPIXEL_TRANSLUCENT translucency kind is not supported");
+ }
+ AWTAccessor.getWindowAccessor().setOpaque(window, isOpaque);
+ }
+
+ /**
+ * Returns whether the window is opaque or translucent.
+ *
+ * @param window the window to set the shape to
+ * @return whether the window is currently opaque (true)
+ * or translucent (false)
+ * @throws NullPointerException if the window argument is null
+ */
+ public static boolean isWindowOpaque(Window window) {
+ if (window == null) {
+ throw new NullPointerException(
+ "The window argument should not be null.");
+ }
+
+ return AWTAccessor.getWindowAccessor().isOpaque(window);
+ }
+
+ /**
+ * Verifies whether a given GraphicsConfiguration supports
+ * the PERPIXEL_TRANSLUCENT kind of translucency.
+ * All windows that are intended to be used with the {@link #setWindowOpaque}
+ * method must be created using a GraphicsConfiguration for which this method
+ * returns true.
+ *
Note that some native systems enable the per-pixel translucency
+ * mode for any window created using a translucency-capable
+ * graphics configuration. However, it is highly recommended to always
+ * invoke the setWindowOpaque() method for these windows, at least
+ * for the sake of cross-platform compatibility reasons.
+ *
+ * @param gc GraphicsConfiguration
+ * @throws NullPointerException if the gc argument is null
+ * @return whether the given GraphicsConfiguration supports
+ * the translucency effects.
+ */
+ public static boolean isTranslucencyCapable(GraphicsConfiguration gc) {
+ if (gc == null) {
+ throw new NullPointerException("The gc argument should not be null");
+ }
+ /*
+ return gc.isTranslucencyCapable();
+ */
+ Toolkit curToolkit = Toolkit.getDefaultToolkit();
+ if (!(curToolkit instanceof SunToolkit)) {
+ return false;
+ }
+ return ((SunToolkit)curToolkit).isTranslucencyCapable(gc);
+ }
+
/**
* Sets a 'mixing-cutout' shape for the given component.
*
diff --git a/jdk/src/share/classes/java/awt/Component.java b/jdk/src/share/classes/java/awt/Component.java
index afe091dccef..9828ddb5661 100644
--- a/jdk/src/share/classes/java/awt/Component.java
+++ b/jdk/src/share/classes/java/awt/Component.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1995-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -799,8 +799,24 @@ public abstract class Component implements ImageObserver, MenuContainer,
}
}
+ // Whether this Component has had the background erase flag
+ // specified via SunToolkit.disableBackgroundErase(). This is
+ // needed in order to make this function work on X11 platforms,
+ // where currently there is no chance to interpose on the creation
+ // of the peer and therefore the call to XSetBackground.
+ transient boolean backgroundEraseDisabled;
+
static {
AWTAccessor.setComponentAccessor(new AWTAccessor.ComponentAccessor() {
+ public void setBackgroundEraseDisabled(Component comp, boolean disabled) {
+ comp.backgroundEraseDisabled = disabled;
+ }
+ public boolean getBackgroundEraseDisabled(Component comp) {
+ return comp.backgroundEraseDisabled;
+ }
+ public Rectangle getBounds(Component comp) {
+ return new Rectangle(comp.x, comp.y, comp.width, comp.height);
+ }
public void setMixingCutoutShape(Component comp, Shape shape) {
Region region = shape == null ? null :
Region.getInstance(shape, null);
@@ -7456,7 +7472,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
// sometimes most recent focus owner may be null, but focus owner is not
// e.g. we reset most recent focus owner if user removes focus owner
focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
- if (focusOwner != null && getContainingWindow(focusOwner) != window) {
+ if (focusOwner != null && focusOwner.getContainingWindow() != window) {
focusOwner = null;
}
}
@@ -8689,30 +8705,8 @@ public abstract class Component implements ImageObserver, MenuContainer,
* null, if component is not a part of window hierarchy
*/
Window getContainingWindow() {
- return getContainingWindow(this);
+ return SunToolkit.getContainingWindow(this);
}
- /**
- * Returns the Window
ancestor of the component comp
.
- * @return Window ancestor of the component or component by itself if it is Window;
- * null, if component is not a part of window hierarchy
- */
- static Window getContainingWindow(Component comp) {
- while (comp != null && !(comp instanceof Window)) {
- comp = comp.getParent();
- }
-
- return (Window)comp;
- }
-
-
-
-
-
-
-
-
-
-
/**
* Initialize JNI field and method IDs
@@ -9827,4 +9821,29 @@ public abstract class Component implements ImageObserver, MenuContainer,
}
// ****************** END OF MIXING CODE ********************************
+
+ private static boolean doesClassImplement(Class cls, String interfaceName) {
+ if (cls == null) return false;
+
+ for (Class c : cls.getInterfaces()) {
+ if (c.getName().equals(interfaceName)) {
+ return true;
+ }
+ }
+ return doesClassImplement(cls.getSuperclass(), interfaceName);
+ }
+
+ /**
+ * Checks that the given object implements the given interface.
+ * @param obj Object to be checked
+ * @param interfaceName The name of the interface. Must be fully-qualified interface name.
+ * @return true, if this object implements the given interface,
+ * false, otherwise, or if obj or interfaceName is null
+ */
+ static boolean doesImplement(Object obj, String interfaceName) {
+ if (obj == null) return false;
+ if (interfaceName == null) return false;
+
+ return doesClassImplement(obj.getClass(), interfaceName);
+ }
}
diff --git a/jdk/src/share/classes/java/awt/Container.java b/jdk/src/share/classes/java/awt/Container.java
index 04425d5a45a..64de85477a7 100644
--- a/jdk/src/share/classes/java/awt/Container.java
+++ b/jdk/src/share/classes/java/awt/Container.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1995-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -167,6 +167,9 @@ public class Container extends Component {
transient int listeningBoundsChildren;
transient int descendantsCount;
+ /* Non-opaque window support -- see Window.setLayersOpaque */
+ transient Color preserveBackgroundColor = null;
+
/**
* JDK 1.1 serialVersionUID
*/
diff --git a/jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java b/jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java
index 5dd0d9061ff..71342bdaeed 100644
--- a/jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java
+++ b/jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java
@@ -479,7 +479,7 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
// that a Component outside of the focused Window receives a
// FOCUS_GAINED event. We synthesize a WINDOW_GAINED_FOCUS
// event in that case.
- final Window newFocusedWindow = Component.getContainingWindow(newFocusOwner);
+ final Window newFocusedWindow = SunToolkit.getContainingWindow(newFocusOwner);
final Window currentFocusedWindow = getGlobalFocusedWindow();
if (newFocusedWindow != null &&
newFocusedWindow != currentFocusedWindow)
diff --git a/jdk/src/share/classes/java/awt/GraphicsConfiguration.java b/jdk/src/share/classes/java/awt/GraphicsConfiguration.java
index 03b147f8a43..c520d310bbe 100644
--- a/jdk/src/share/classes/java/awt/GraphicsConfiguration.java
+++ b/jdk/src/share/classes/java/awt/GraphicsConfiguration.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -434,4 +434,20 @@ public abstract class GraphicsConfiguration {
}
return defaultImageCaps;
}
+
+ /**
+ * Returns whether this GraphicsConfiguration supports
+ * the {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSLUCENT
+ * PERPIXEL_TRANSLUCENT} kind of translucency.
+ *
+ * @param gc GraphicsConfiguration
+ * @throws NullPointerException if the gc argument is null
+ * @return whether the given GraphicsConfiguration supports
+ * the translucency effects.
+ * @see Window#setBackground(Color)
+ */
+ /*public */boolean isTranslucencyCapable() {
+ // Overridden in subclasses
+ return false;
}
+}
diff --git a/jdk/src/share/classes/java/awt/GraphicsDevice.java b/jdk/src/share/classes/java/awt/GraphicsDevice.java
index 47b578129dd..920687150d9 100644
--- a/jdk/src/share/classes/java/awt/GraphicsDevice.java
+++ b/jdk/src/share/classes/java/awt/GraphicsDevice.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,10 @@
package java.awt;
import java.awt.image.ColorModel;
+
+import sun.awt.AWTAccessor;
import sun.awt.AppContext;
+import sun.awt.SunToolkit;
/**
* The GraphicsDevice
class describes the graphics devices
@@ -109,6 +112,31 @@ public abstract class GraphicsDevice {
*/
public final static int TYPE_IMAGE_BUFFER = 2;
+ /** Kinds of translucency supported by the underlying system.
+ * @see #isTranslucencySupported
+ */
+ /*public */static enum WindowTranslucency {
+ /**
+ * Represents support in the underlying system for windows each pixel
+ * of which is guaranteed to be either completely opaque, with
+ * an alpha value of 1.0, or completely transparent, with an alpha
+ * value of 0.0.
+ */
+ PERPIXEL_TRANSPARENT,
+ /**
+ * Represents support in the underlying system for windows all of
+ * the pixels of which have the same alpha value between or including
+ * 0.0 and 1.0.
+ */
+ TRANSLUCENT,
+ /**
+ * Represents support in the underlying system for windows that
+ * contain or might contain pixels with arbitrary alpha values
+ * between and including 0.0 and 1.0.
+ */
+ PERPIXEL_TRANSLUCENT;
+ }
+
/**
* Returns the type of this GraphicsDevice
.
* @return the type of this GraphicsDevice
, which can
@@ -235,6 +263,21 @@ public abstract class GraphicsDevice {
* @since 1.4
*/
public void setFullScreenWindow(Window w) {
+ if (w != null) {
+ //XXX: The actions should be documented in some non-update release.
+ /*
+ if (w.getShape() != null) {
+ w.setShape(w, null);
+ }
+ if (!w.isOpaque()) {
+ w.setOpaque(false);
+ }
+ if (w.getOpacity() < 1.0f) {
+ w.setOpacity(1.0f);
+ }
+ */
+ }
+
if (fullScreenWindow != null && windowedModeBounds != null) {
// if the window went into fs mode before it was realized it may
// have (0,0) dimensions
@@ -424,4 +467,94 @@ public abstract class GraphicsDevice {
public int getAvailableAcceleratedMemory() {
return -1;
}
+
+ /**
+ * Returns whether the given level of translucency is supported
+ * this graphics device.
+ *
+ * @param translucencyKind a kind of translucency support
+ * @return whether the given translucency kind is supported
+ */
+ /*public */boolean isWindowTranslucencySupported(WindowTranslucency translucencyKind) {
+ switch (translucencyKind) {
+ case PERPIXEL_TRANSPARENT:
+ return isWindowShapingSupported();
+ case TRANSLUCENT:
+ return isWindowOpacitySupported();
+ case PERPIXEL_TRANSLUCENT:
+ return isWindowPerpixelTranslucencySupported();
+ }
+ return false;
+ }
+
+ /**
+ * Returns whether the windowing system supports changing the shape
+ * of top-level windows.
+ * Note that this method may sometimes return true, but the native
+ * windowing system may still not support the concept of
+ * shaping (due to the bugs in the windowing system).
+ */
+ static boolean isWindowShapingSupported() {
+ Toolkit curToolkit = Toolkit.getDefaultToolkit();
+ if (!(curToolkit instanceof SunToolkit)) {
+ return false;
+ }
+ return ((SunToolkit)curToolkit).isWindowShapingSupported();
+ }
+
+ /**
+ * Returns whether the windowing system supports changing the opacity
+ * value of top-level windows.
+ * Note that this method may sometimes return true, but the native
+ * windowing system may still not support the concept of
+ * translucency (due to the bugs in the windowing system).
+ */
+ static boolean isWindowOpacitySupported() {
+ Toolkit curToolkit = Toolkit.getDefaultToolkit();
+ if (!(curToolkit instanceof SunToolkit)) {
+ return false;
+ }
+ return ((SunToolkit)curToolkit).isWindowOpacitySupported();
+ }
+
+ boolean isWindowPerpixelTranslucencySupported() {
+ /*
+ * Per-pixel alpha is supported if all the conditions are TRUE:
+ * 1. The toolkit is a sort of SunToolkit
+ * 2. The toolkit supports translucency in general
+ * (isWindowTranslucencySupported())
+ * 3. There's at least one translucency-capable
+ * GraphicsConfiguration
+ */
+ Toolkit curToolkit = Toolkit.getDefaultToolkit();
+ if (!(curToolkit instanceof SunToolkit)) {
+ return false;
+ }
+ if (!((SunToolkit)curToolkit).isWindowTranslucencySupported()) {
+ return false;
+ }
+
+ // TODO: cache translucency capable GC
+ return getTranslucencyCapableGC() != null;
+ }
+
+ GraphicsConfiguration getTranslucencyCapableGC() {
+ // If the default GC supports translucency return true.
+ // It is important to optimize the verification this way,
+ // see CR 6661196 for more details.
+ GraphicsConfiguration defaultGC = getDefaultConfiguration();
+ if (defaultGC.isTranslucencyCapable()) {
+ return defaultGC;
+ }
+
+ // ... otherwise iterate through all the GCs.
+ GraphicsConfiguration[] configs = getConfigurations();
+ for (int j = 0; j < configs.length; j++) {
+ if (configs[j].isTranslucencyCapable()) {
+ return configs[j];
+ }
+ }
+
+ return null;
+ }
}
diff --git a/jdk/src/share/classes/java/awt/KeyboardFocusManager.java b/jdk/src/share/classes/java/awt/KeyboardFocusManager.java
index b84b93b021e..268eba915be 100644
--- a/jdk/src/share/classes/java/awt/KeyboardFocusManager.java
+++ b/jdk/src/share/classes/java/awt/KeyboardFocusManager.java
@@ -2208,7 +2208,7 @@ public abstract class KeyboardFocusManager
boolean temporary, boolean focusedWindowChangeAllowed,
long time)
{
- Window parentWindow = Component.getContainingWindow(heavyweight);
+ Window parentWindow = SunToolkit.getContainingWindow(heavyweight);
if (parentWindow == null || !parentWindow.syncLWRequests) {
return false;
}
@@ -2542,7 +2542,7 @@ public abstract class KeyboardFocusManager
(HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER);
Component activeWindow = ((hwFocusRequest != null)
- ? Component.getContainingWindow(hwFocusRequest.heavyweight)
+ ? SunToolkit.getContainingWindow(hwFocusRequest.heavyweight)
: nativeFocusedWindow);
while (activeWindow != null &&
!((activeWindow instanceof Frame) ||
@@ -3013,8 +3013,8 @@ public abstract class KeyboardFocusManager
}
private static boolean focusedWindowChanged(Component to, Component from) {
- Window wto = Component.getContainingWindow(to);
- Window wfrom = Component.getContainingWindow(from);
+ Window wto = SunToolkit.getContainingWindow(to);
+ Window wfrom = SunToolkit.getContainingWindow(from);
if (wto == null && wfrom == null) {
return true;
}
@@ -3028,8 +3028,8 @@ public abstract class KeyboardFocusManager
}
private static boolean isTemporary(Component to, Component from) {
- Window wto = Component.getContainingWindow(to);
- Window wfrom = Component.getContainingWindow(from);
+ Window wto = SunToolkit.getContainingWindow(to);
+ Window wfrom = SunToolkit.getContainingWindow(from);
if (wto == null && wfrom == null) {
return false;
}
diff --git a/jdk/src/share/classes/java/awt/Window.java b/jdk/src/share/classes/java/awt/Window.java
index 2651729f20d..64c611ac3c3 100644
--- a/jdk/src/share/classes/java/awt/Window.java
+++ b/jdk/src/share/classes/java/awt/Window.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1995-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@ package java.awt;
import java.awt.event.*;
import java.awt.im.InputContext;
import java.awt.image.BufferStrategy;
+import java.awt.image.BufferedImage;
import java.awt.peer.ComponentPeer;
import java.awt.peer.WindowPeer;
import java.beans.PropertyChangeListener;
@@ -49,6 +50,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.accessibility.*;
+import sun.awt.AWTAccessor;
import sun.awt.AppContext;
import sun.awt.CausedFocusEvent;
import sun.awt.SunToolkit;
@@ -291,6 +293,25 @@ public class Window extends Container implements Accessible {
*/
transient boolean isInShow = false;
+ /*
+ * Opacity level of the window
+ *
+ * @see #setOpacity(float)
+ * @see #getOpacity()
+ * @since 1.7
+ */
+ private float opacity = 1.0f;
+
+ /*
+ * The shape assigned to this window. This field is set to null if
+ * no shape is set (rectangular window).
+ *
+ * @see #getShape()
+ * @see #setShape(Shape)
+ * @since 1.7
+ */
+ private Shape shape = null;
+
private static final String base = "win";
private static int nameCounter = 0;
@@ -666,9 +687,9 @@ public class Window extends Container implements Accessible {
}
if (peer == null) {
peer = getToolkit().createWindow(this);
- }
- synchronized (allWindows) {
- allWindows.add(this);
+ synchronized (allWindows) {
+ allWindows.add(this);
+ }
}
super.addNotify();
}
@@ -2849,6 +2870,8 @@ public class Window extends Container implements Accessible {
if(aot) {
setAlwaysOnTop(aot); // since 1.5; subject to permission check
}
+ shape = (Shape)f.get("shape", null);
+ opacity = (Float)f.get("opacity", 1.0f);
deserializeResources(s);
}
@@ -3016,7 +3039,7 @@ public class Window extends Container implements Accessible {
Dimension windowSize = getSize();
// search a top-level of c
- Window componentWindow = Component.getContainingWindow(c);
+ Window componentWindow = SunToolkit.getContainingWindow(c);
if ((c == null) || (componentWindow == null)) {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
gc = ge.getDefaultScreenDevice().getDefaultConfiguration();
@@ -3304,6 +3327,225 @@ public class Window extends Container implements Accessible {
}
+ // ******************** SHAPES & TRANSPARENCY CODE ********************
+
+ /**
+ * JavaDoc
+ */
+ /*public */float getOpacity() {
+ synchronized (getTreeLock()) {
+ return opacity;
+ }
+ }
+
+ /**
+ * JavaDoc
+ */
+ /*public */void setOpacity(float opacity) {
+ synchronized (getTreeLock()) {
+ if (opacity < 0.0f || opacity > 1.0f) {
+ throw new IllegalArgumentException(
+ "The value of opacity should be in the range [0.0f .. 1.0f].");
+ }
+ GraphicsConfiguration gc = getGraphicsConfiguration();
+ GraphicsDevice gd = gc.getDevice();
+ if (!gd.isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency.TRANSLUCENT)) {
+ throw new UnsupportedOperationException(
+ "TRANSLUCENT translucency is not supported.");
+ }
+ if ((gc.getDevice().getFullScreenWindow() == this) && (opacity < 1.0f)) {
+ throw new IllegalArgumentException(
+ "Setting opacity for full-screen window is not supported.");
+ }
+ this.opacity = opacity;
+ WindowPeer peer = (WindowPeer)getPeer();
+ if (peer != null) {
+ peer.setOpacity(opacity);
+ }
+ }
+ }
+
+ /**
+ * JavaDoc
+ */
+ /*public */Shape getShape() {
+ synchronized (getTreeLock()) {
+ return shape;
+ }
+ }
+
+ /**
+ * JavaDoc
+ *
+ * @param window the window to set the shape to
+ * @param shape the shape to set to the window
+ * @throws IllegalArgumentException if the window is in full screen mode,
+ * and the shape is not null
+ */
+ /*public */void setShape(Shape shape) {
+ synchronized (getTreeLock()) {
+ GraphicsConfiguration gc = getGraphicsConfiguration();
+ GraphicsDevice gd = gc.getDevice();
+ if (!gd.isWindowTranslucencySupported(
+ GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
+ {
+ throw new UnsupportedOperationException(
+ "PERPIXEL_TRANSPARENT translucency is not supported.");
+ }
+ if ((gc.getDevice().getFullScreenWindow() == this) && (shape != null)) {
+ throw new IllegalArgumentException(
+ "Setting shape for full-screen window is not supported.");
+ }
+ this.shape = shape;
+ WindowPeer peer = (WindowPeer)getPeer();
+ if (peer != null) {
+ peer.applyShape(shape == null ? null : Region.getInstance(shape, null));
+ }
+ }
+ }
+
+ /**
+ * JavaDoc
+ */
+/*
+ @Override
+ public void setBackground(Color bgColor) {
+ int alpha = bgColor.getAlpha();
+ if (alpha < 255) { // non-opaque window
+ GraphicsConfiguration gc = getGraphicsConfiguration();
+ GraphicsDevice gd = gc.getDevice();
+ if (gc.getDevice().getFullScreenWindow() == this) {
+ throw new IllegalArgumentException(
+ "Making full-screen window non opaque is not supported.");
+ }
+ if (!gc.isTranslucencyCapable()) {
+ GraphicsConfiguration capableGC = gd.getTranslucencyCapableGC();
+ if (capableGC == null) {
+ throw new IllegalArgumentException(
+ "PERPIXEL_TRANSLUCENT translucency is not supported");
+ }
+ // TODO: change GC
+ }
+ setLayersOpaque(this, false);
+ }
+
+ super.setBackground(bgColor);
+
+ WindowPeer peer = (WindowPeer)getPeer();
+ if (peer != null) {
+ peer.setOpaque(alpha == 255);
+ }
+ }
+*/
+
+ private transient boolean opaque = true;
+
+ void setOpaque(boolean opaque) {
+ synchronized (getTreeLock()) {
+ GraphicsConfiguration gc = getGraphicsConfiguration();
+ if (!opaque && !com.sun.awt.AWTUtilities.isTranslucencyCapable(gc)) {
+ throw new IllegalArgumentException(
+ "The window must use a translucency-compatible graphics configuration");
+ }
+ if (!com.sun.awt.AWTUtilities.isTranslucencySupported(
+ com.sun.awt.AWTUtilities.Translucency.PERPIXEL_TRANSLUCENT))
+ {
+ throw new UnsupportedOperationException(
+ "PERPIXEL_TRANSLUCENT translucency is not supported.");
+ }
+ if ((gc.getDevice().getFullScreenWindow() == this) && !opaque) {
+ throw new IllegalArgumentException(
+ "Making full-screen window non opaque is not supported.");
+ }
+ setLayersOpaque(this, opaque);
+ this.opaque = opaque;
+ WindowPeer peer = (WindowPeer)getPeer();
+ if (peer != null) {
+ peer.setOpaque(opaque);
+ }
+ }
+ }
+
+ private void updateWindow(BufferedImage backBuffer) {
+ synchronized (getTreeLock()) {
+ WindowPeer peer = (WindowPeer)getPeer();
+ if (peer != null) {
+ peer.updateWindow(backBuffer);
+ }
+ }
+ }
+
+ private static final Color TRANSPARENT_BACKGROUND_COLOR = new Color(0, 0, 0, 0);
+
+ private static void setLayersOpaque(Component component, boolean isOpaque) {
+ // Shouldn't use instanceof to avoid loading Swing classes
+ // if it's a pure AWT application.
+ if (Component.doesImplement(component, "javax.swing.RootPaneContainer")) {
+ javax.swing.RootPaneContainer rpc = (javax.swing.RootPaneContainer)component;
+ javax.swing.JRootPane root = rpc.getRootPane();
+ javax.swing.JLayeredPane lp = root.getLayeredPane();
+ Container c = root.getContentPane();
+ javax.swing.JComponent content =
+ (c instanceof javax.swing.JComponent) ? (javax.swing.JComponent)c : null;
+ javax.swing.JComponent gp =
+ (rpc.getGlassPane() instanceof javax.swing.JComponent) ?
+ (javax.swing.JComponent)rpc.getGlassPane() : null;
+ if (gp != null) {
+ gp.setDoubleBuffered(isOpaque);
+ }
+ lp.setOpaque(isOpaque);
+ root.setOpaque(isOpaque);
+ root.setDoubleBuffered(isOpaque); //XXX: the "white rect" workaround
+ if (content != null) {
+ content.setOpaque(isOpaque);
+ content.setDoubleBuffered(isOpaque); //XXX: the "white rect" workaround
+
+ // Iterate down one level to see whether we have a JApplet
+ // (which is also a RootPaneContainer) which requires processing
+ int numChildren = content.getComponentCount();
+ if (numChildren > 0) {
+ Component child = content.getComponent(0);
+ // It's OK to use instanceof here because we've
+ // already loaded the RootPaneContainer class by now
+ if (child instanceof javax.swing.RootPaneContainer) {
+ setLayersOpaque(child, isOpaque);
+ }
+ }
+ }
+ }
+
+ Color bg = component.getBackground();
+ boolean hasTransparentBg = TRANSPARENT_BACKGROUND_COLOR.equals(bg);
+
+ Container container = null;
+ if (component instanceof Container) {
+ container = (Container) component;
+ }
+
+ if (isOpaque) {
+ if (hasTransparentBg) {
+ // Note: we use the SystemColor.window color as the default.
+ // This color is used in the WindowPeer implementations to
+ // initialize the background color of the window if it is null.
+ // (This might not be the right thing to do for other
+ // RootPaneContainers we might be invoked with)
+ Color newColor = null;
+ if (container != null && container.preserveBackgroundColor != null) {
+ newColor = container.preserveBackgroundColor;
+ } else {
+ newColor = SystemColor.window;
+ }
+ component.setBackground(newColor);
+ }
+ } else {
+ if (!hasTransparentBg && container != null) {
+ container.preserveBackgroundColor = bg;
+ }
+ component.setBackground(TRANSPARENT_BACKGROUND_COLOR);
+ }
+ }
+
+
// ************************** MIXING CODE *******************************
// A window has a parent, but it does NOT have a container
@@ -3341,6 +3583,42 @@ public class Window extends Container implements Accessible {
// ****************** END OF MIXING CODE ********************************
+ static {
+ AWTAccessor.setWindowAccessor(new AWTAccessor.WindowAccessor() {
+ public float getOpacity(Window window) {
+ return window.opacity;
+ }
+ public void setOpacity(Window window, float opacity) {
+ window.setOpacity(opacity);
+ }
+ public Shape getShape(Window window) {
+ return window.getShape();
+ }
+ public void setShape(Window window, Shape shape) {
+ window.setShape(shape);
+ }
+ public boolean isOpaque(Window window) {
+ /*
+ return window.getBackground().getAlpha() < 255;
+ */
+ synchronized (window.getTreeLock()) {
+ return window.opaque;
+ }
+ }
+ public void setOpaque(Window window, boolean opaque) {
+ /*
+ Color bg = window.getBackground();
+ window.setBackground(new Color(bg.getRed(), bg.getGreen(), bg.getBlue(),
+ opaque ? 255 : 0));
+ */
+ window.setOpaque(opaque);
+ }
+ public void updateWindow(Window window, BufferedImage backBuffer) {
+ window.updateWindow(backBuffer);
+ }
+ }); // WindowAccessor
+ } // static
+
} // class Window
diff --git a/jdk/src/share/classes/java/awt/peer/WindowPeer.java b/jdk/src/share/classes/java/awt/peer/WindowPeer.java
index 7b5da857f40..8a2589b9c8e 100644
--- a/jdk/src/share/classes/java/awt/peer/WindowPeer.java
+++ b/jdk/src/share/classes/java/awt/peer/WindowPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1995-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@ package java.awt.peer;
import java.awt.*;
+import java.awt.image.BufferedImage;
+
/**
* The peer interface for {@link Window}.
*
@@ -92,4 +94,26 @@ public interface WindowPeer extends ContainerPeer {
* @see Window#setIconImages(java.util.List)
*/
void updateIconImages();
+
+ /**
+ * Sets the level of opacity for the window.
+ *
+ * @see Window#setOpacity(float)
+ */
+ void setOpacity(float opacity);
+
+ /**
+ * Enables the per-pixel alpha support for the window.
+ *
+ * @see Window#setBackground(Color)
+ */
+ void setOpaque(boolean isOpaque);
+
+ /**
+ * Updates the native part of non-opaque window using
+ * the given image with color+alpha values for each pixel.
+ *
+ * @see Window#setBackground(Color)
+ */
+ void updateWindow(BufferedImage backBuffer);
}
diff --git a/jdk/src/share/classes/javax/swing/RepaintManager.java b/jdk/src/share/classes/javax/swing/RepaintManager.java
index b0e6c048f62..5fc08a1ccdf 100644
--- a/jdk/src/share/classes/javax/swing/RepaintManager.java
+++ b/jdk/src/share/classes/javax/swing/RepaintManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,7 @@ import java.security.AccessController;
import java.util.*;
import java.applet.*;
+import sun.awt.AWTAccessor;
import sun.awt.AppContext;
import sun.awt.DisplayChangedListener;
import sun.awt.SunToolkit;
@@ -716,6 +717,44 @@ public class RepaintManager
}
}
+ private Map
+ updateWindows(Map dirtyComponents)
+ {
+ Toolkit toolkit = Toolkit.getDefaultToolkit();
+ if (!(toolkit instanceof SunToolkit &&
+ ((SunToolkit)toolkit).needUpdateWindow()))
+ {
+ return dirtyComponents;
+ }
+
+ Set windows = new HashSet();
+ Set dirtyComps = dirtyComponents.keySet();
+ for (Iterator it = dirtyComps.iterator(); it.hasNext();) {
+ Component dirty = it.next();
+ Window window = dirty instanceof Window ?
+ (Window)dirty :
+ SwingUtilities.getWindowAncestor(dirty);
+
+ if (window != null &&
+ !AWTAccessor.getWindowAccessor().isOpaque(window))
+ {
+ // if this component's toplevel is perpixel translucent, it will
+ // be repainted below
+ it.remove();
+ // add to the set of windows to update (so that we don't update
+ // the window many times for each component to be repainted that
+ // belongs to this window)
+ windows.add(window);
+ }
+ }
+
+ for (Window window : windows) {
+ AWTAccessor.getWindowAccessor().updateWindow(window, null);
+ }
+
+ return dirtyComponents;
+ }
+
/**
* Paint all of the components that have been marked dirty.
*
@@ -749,6 +788,10 @@ public class RepaintManager
int localBoundsW;
Enumeration keys;
+ // the components belonging to perpixel-translucent windows will be
+ // removed from the list
+ tmpDirtyComponents = updateWindows(tmpDirtyComponents);
+
roots = new ArrayList(count);
for (Component dirty : tmpDirtyComponents.keySet()) {
diff --git a/jdk/src/share/classes/sun/awt/AWTAccessor.java b/jdk/src/share/classes/sun/awt/AWTAccessor.java
index 41b933c4a61..94d0bb25f0b 100644
--- a/jdk/src/share/classes/sun/awt/AWTAccessor.java
+++ b/jdk/src/share/classes/sun/awt/AWTAccessor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,9 @@
package sun.awt;
import java.awt.*;
+import java.awt.geom.Point2D;
+import java.awt.image.BufferedImage;
+
import sun.misc.Unsafe;
/** The AWTAccessor utility class.
@@ -35,37 +38,124 @@ import sun.misc.Unsafe;
* for another example.
*/
public final class AWTAccessor {
+
private static final Unsafe unsafe = Unsafe.getUnsafe();
- /** We don't need any objects of this class.
+ /*
+ * We don't need any objects of this class.
* It's rather a collection of static methods
* and interfaces.
*/
private AWTAccessor() {
}
- /** An accessor for the java.awt.Component class.
+ /*
+ * An interface of accessor for the java.awt.Component class.
*/
public interface ComponentAccessor {
- // See 6797587
- // Also see: 6776743, 6768307, and 6768332.
- /**
+ /*
+ * Sets whether the native background erase for a component
+ * has been disabled via SunToolkit.disableBackgroundErase().
+ */
+ void setBackgroundEraseDisabled(Component comp, boolean disabled);
+ /*
+ * Indicates whether the native background erase for a
+ * component has been disabled via
+ * SunToolkit.disableBackgroundErase().
+ */
+ boolean getBackgroundEraseDisabled(Component comp);
+ /*
+ *
+ * Gets the bounds of this component in the form of a
+ * Rectangle
object. The bounds specify this
+ * component's width, height, and location relative to
+ * its parent.
+ */
+ Rectangle getBounds(Component comp);
+ /*
* Sets the shape of a lw component to cut out from hw components.
+ *
+ * See 6797587, 6776743, 6768307, and 6768332 for details
*/
void setMixingCutoutShape(Component comp, Shape shape);
}
- /* The java.awt.Component class accessor object.
+ /*
+ * An interface of accessor for java.awt.Window class.
+ */
+ public interface WindowAccessor {
+ /*
+ * Get opacity level of the given window.
+ */
+ float getOpacity(Window window);
+ /*
+ * Set opacity level to the given window.
+ */
+ void setOpacity(Window window, float opacity);
+ /*
+ * Get a shape assigned to the given window.
+ */
+ Shape getShape(Window window);
+ /*
+ * Set a shape to the given window.
+ */
+ void setShape(Window window, Shape shape);
+ /*
+ * Identify whether the given window is opaque (true)
+ * or translucent (false).
+ */
+ boolean isOpaque(Window window);
+ /*
+ * Set the opaque preoperty to the given window.
+ */
+ void setOpaque(Window window, boolean isOpaque);
+ /*
+ * Update the image of a non-opaque (translucent) window.
+ */
+ void updateWindow(Window window, BufferedImage backBuffer);
+ }
+
+ /*
+ * An accessor for the AWTEvent class.
+ */
+ public interface AWTEventAccessor {
+ /*
+ *
+ * Sets the flag on this AWTEvent indicating that it was
+ * generated by the system.
+ */
+ void setSystemGenerated(AWTEvent ev);
+ /*
+ *
+ * Indicates whether this AWTEvent was generated by the system.
+ */
+ boolean isSystemGenerated(AWTEvent ev);
+ }
+
+ /*
+ * The java.awt.Component class accessor object.
*/
private static ComponentAccessor componentAccessor;
- /** Set an accessor object for the java.awt.Component class.
+ /*
+ * The java.awt.Window class accessor object.
+ */
+ private static WindowAccessor windowAccessor;
+
+ /*
+ * The java.awt.AWTEvent class accessor object.
+ */
+ private static AWTEventAccessor awtEventAccessor;
+
+ /*
+ * Set an accessor object for the java.awt.Component class.
*/
public static void setComponentAccessor(ComponentAccessor ca) {
componentAccessor = ca;
}
- /** Retrieve the accessor object for the java.awt.Window class.
+ /*
+ * Retrieve the accessor object for the java.awt.Window class.
*/
public static ComponentAccessor getComponentAccessor() {
if (componentAccessor == null) {
@@ -74,4 +164,35 @@ public final class AWTAccessor {
return componentAccessor;
}
+
+ /*
+ * Set an accessor object for the java.awt.Window class.
+ */
+ public static void setWindowAccessor(WindowAccessor wa) {
+ windowAccessor = wa;
+ }
+
+ /*
+ * Retrieve the accessor object for the java.awt.Window class.
+ */
+ public static WindowAccessor getWindowAccessor() {
+ if (windowAccessor == null) {
+ unsafe.ensureClassInitialized(Window.class);
+ }
+ return windowAccessor;
+ }
+
+ /*
+ * Set an accessor object for the java.awt.AWTEvent class.
+ */
+ public static void setAWTEventAccessor(AWTEventAccessor aea) {
+ awtEventAccessor = aea;
+ }
+
+ /*
+ * Retrieve the accessor object for the java.awt.AWTEvent class.
+ */
+ public static AWTEventAccessor getAWTEventAccessor() {
+ return awtEventAccessor;
+ }
}
diff --git a/jdk/src/share/classes/sun/awt/EmbeddedFrame.java b/jdk/src/share/classes/sun/awt/EmbeddedFrame.java
index d7450bebe1d..f636da47191 100644
--- a/jdk/src/share/classes/sun/awt/EmbeddedFrame.java
+++ b/jdk/src/share/classes/sun/awt/EmbeddedFrame.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -585,5 +585,12 @@ public abstract class EmbeddedFrame extends Frame
}
public void updateMinimumSize() {
}
- }
+
+ public void setOpacity(float opacity) {
+ }
+ public void setOpaque(boolean isOpaque) {
+ }
+ public void updateWindow(BufferedImage backBuffer) {
+ }
+ }
} // class EmbeddedFrame
diff --git a/jdk/src/share/classes/sun/awt/SunToolkit.java b/jdk/src/share/classes/sun/awt/SunToolkit.java
index 7c6f74856a9..ac375d836fd 100644
--- a/jdk/src/share/classes/sun/awt/SunToolkit.java
+++ b/jdk/src/share/classes/sun/awt/SunToolkit.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,14 +32,10 @@ import java.awt.dnd.peer.DragSourceContextPeer;
import java.awt.peer.*;
import java.awt.event.WindowEvent;
import java.awt.event.KeyEvent;
-import java.awt.im.spi.InputMethodDescriptor;
import java.awt.image.*;
-import java.awt.geom.AffineTransform;
import java.awt.TrayIcon;
import java.awt.SystemTray;
-import java.io.*;
import java.net.URL;
-import java.net.JarURLConnection;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
@@ -49,7 +45,6 @@ import java.util.logging.Logger;
import sun.misc.SoftCache;
import sun.font.FontDesignMetrics;
import sun.awt.im.InputContext;
-import sun.awt.im.SimpleInputMethodWindow;
import sun.awt.image.*;
import sun.security.action.GetPropertyAction;
import sun.security.action.GetBooleanAction;
@@ -824,16 +819,31 @@ public abstract class SunToolkit extends Toolkit
}
/**
- * Disables erasing of background on the canvas before painting
- * if this is supported by the current toolkit.
- *
- * @throws IllegalStateException if the canvas is not displayable
- * @see java.awt.Component#isDisplayable
+ * Disables erasing of background on the canvas before painting if
+ * this is supported by the current toolkit. It is recommended to
+ * call this method early, before the Canvas becomes displayable,
+ * because some Toolkit implementations do not support changing
+ * this property once the Canvas becomes displayable.
*/
public void disableBackgroundErase(Canvas canvas) {
- if (!canvas.isDisplayable()) {
- throw new IllegalStateException("Canvas must have a valid peer");
- }
+ disableBackgroundEraseImpl(canvas);
+ }
+
+ /**
+ * Disables the native erasing of the background on the given
+ * component before painting if this is supported by the current
+ * toolkit. This only has an effect for certain components such as
+ * Canvas, Panel and Window. It is recommended to call this method
+ * early, before the Component becomes displayable, because some
+ * Toolkit implementations do not support changing this property
+ * once the Component becomes displayable.
+ */
+ public void disableBackgroundErase(Component component) {
+ disableBackgroundEraseImpl(component);
+ }
+
+ private void disableBackgroundEraseImpl(Component component) {
+ AWTAccessor.getComponentAccessor().setBackgroundEraseDisabled(component, true);
}
/**
@@ -1972,6 +1982,18 @@ public abstract class SunToolkit extends Toolkit
AWTAutoShutdown.getInstance().dumpPeers(aLog);
}
+ /**
+ * Returns the Window
ancestor of the component comp
.
+ * @return Window ancestor of the component or component by itself if it is Window;
+ * null, if component is not a part of window hierarchy
+ */
+ public static Window getContainingWindow(Component comp) {
+ while (comp != null && !(comp instanceof Window)) {
+ comp = comp.getParent();
+ }
+ return (Window)comp;
+ }
+
private static Boolean sunAwtDisableMixing = null;
/**
@@ -1995,6 +2017,73 @@ public abstract class SunToolkit extends Toolkit
public boolean isNativeGTKAvailable() {
return false;
}
+
+ // Cosntant alpha
+ public boolean isWindowOpacitySupported() {
+ return false;
+ }
+
+ // Shaping
+ public boolean isWindowShapingSupported() {
+ return false;
+ }
+
+ // Per-pixel alpha
+ public boolean isWindowTranslucencySupported() {
+ return false;
+ }
+
+ public boolean isTranslucencyCapable(GraphicsConfiguration gc) {
+ return false;
+ }
+
+ /**
+ * Returns whether or not a containing top level window for the passed
+ * component is
+ * {@link com.sun.awt.AWTUtilities.Translucency#PERPIXEL_TRANSLUCENT PERPIXEL_TRANSLUCENT}.
+ *
+ * @param c a Component which toplevel's to check
+ * @return {@code true} if the passed component is not null and has a
+ * containing toplevel window which is opaque (so per-pixel translucency
+ * is not enabled), {@code false} otherwise
+ * @see com.sun.awt.AWTUtilities.Translucency#PERPIXEL_TRANSLUCENT
+ * @see com.sun.awt.AWTUtilities#isWindowOpaque(Window)
+ */
+ public static boolean isContainingTopLevelOpaque(Component c) {
+ Window w = getContainingWindow(c);
+ // return w != null && (w).isOpaque();
+ return w != null && com.sun.awt.AWTUtilities.isWindowOpaque(w);
+ }
+
+ /**
+ * Returns whether or not a containing top level window for the passed
+ * component is
+ * {@link com.sun.awt.AWTUtilities.Translucency#TRANSLUCENT TRANSLUCENT}.
+ *
+ * @param c a Component which toplevel's to check
+ * @return {@code true} if the passed component is not null and has a
+ * containing toplevel window which has opacity less than
+ * 1.0f (which means that it is translucent), {@code false} otherwise
+ * @see com.sun.awt.AWTUtilities.Translucency#TRANSLUCENT
+ * @see com.sun.awt.AWTUtilities#getWindowOpacity(Window)
+ */
+ public static boolean isContainingTopLevelTranslucent(Component c) {
+ Window w = getContainingWindow(c);
+ // return w != null && (w).getOpacity() < 1.0f;
+ return w != null && com.sun.awt.AWTUtilities.getWindowOpacity((Window)w) < 1.0f;
+ }
+
+ /**
+ * Returns whether the native system requires using the peer.updateWindow()
+ * method to update the contents of a non-opaque window, or if usual
+ * painting procedures are sufficient. The default return value covers
+ * the X11 systems. On MS Windows this method is overriden in WToolkit
+ * to return true.
+ */
+ public boolean needUpdateWindow() {
+ return false;
+ }
+
} // class SunToolkit
diff --git a/jdk/src/share/native/sun/awt/utility/rect.c b/jdk/src/share/native/sun/awt/utility/rect.c
new file mode 100644
index 00000000000..00bbecb6e11
--- /dev/null
+++ b/jdk/src/share/native/sun/awt/utility/rect.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+#include "utility/rect.h"
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/**
+ * bitsPerPixel must be 32 for now.
+ * outBuf must be large enough to conatin all the rectangles.
+ */
+int BitmapToYXBandedRectangles(int bitsPerPixel, int width, int height, unsigned char * buf, RECT_T * outBuf)
+{
+ //XXX: we might want to reuse the code in the splashscreen library,
+ // though we'd have to deal with the ALPHA_THRESHOLD and different
+ // image formats in this case.
+ int widthBytes = width * bitsPerPixel / 8;
+ int alignedWidth = (((widthBytes - 1) / 4) + 1) * 4;
+
+ RECT_T * out = outBuf;
+
+ RECT_T *pPrevLine = NULL, *pFirst = out, *pThis = pFirst;
+ int i, j, i0;
+ int length;
+
+ for (j = 0; j < height; j++) {
+ /* generate data for a scanline */
+
+ unsigned char *pSrc = (unsigned char *) buf + j * alignedWidth;
+ RECT_T *pLine = pThis;
+
+ i = 0;
+
+ do {
+ // pSrc[0,1,2] == B,G,R; pSrc[3] == Alpha
+ while (i < width && !pSrc[3]) {
+ pSrc += 4;
+ ++i;
+ }
+ if (i >= width)
+ break;
+ i0 = i;
+ while (i < width && pSrc[3]) {
+ pSrc += 4;
+ ++i;
+ }
+ RECT_SET(*pThis, i0, j, i - i0, 1);
+ ++pThis;
+ } while (i < width);
+
+ /* check if the previous scanline is exactly the same, merge if so
+ (this is the only optimization we can use for YXBanded rectangles,
+ and win32 supports YXBanded only */
+
+ length = pThis - pLine;
+ if (pPrevLine && pLine - pPrevLine == length) {
+ for (i = 0; i < length && RECT_EQ_X(pPrevLine[i], pLine[i]); ++i) {
+ }
+ if (i == pLine - pPrevLine) {
+ // do merge
+ for (i = 0; i < length; i++) {
+ RECT_INC_HEIGHT(pPrevLine[i]);
+ }
+ pThis = pLine;
+ continue;
+ }
+ }
+ /* or else use the generated scanline */
+
+ pPrevLine = pLine;
+ }
+
+ return pThis - pFirst;
+}
+
+#if defined(__cplusplus)
+}
+#endif
diff --git a/jdk/src/solaris/classes/sun/awt/X11/XNETProtocol.java b/jdk/src/solaris/classes/sun/awt/X11/XNETProtocol.java
index 68145a74f79..e145cd98206 100644
--- a/jdk/src/solaris/classes/sun/awt/X11/XNETProtocol.java
+++ b/jdk/src/solaris/classes/sun/awt/X11/XNETProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -252,6 +252,8 @@ final class XNETProtocol extends XProtocol implements XStateProtocol, XLayerProt
XAtom XA_NET_WM_WINDOW_TYPE = XAtom.get("_NET_WM_WINDOW_TYPE");
XAtom XA_NET_WM_WINDOW_TYPE_DIALOG = XAtom.get("_NET_WM_WINDOW_TYPE_DIALOG");
+ XAtom XA_NET_WM_WINDOW_OPACITY = XAtom.get("_NET_WM_WINDOW_OPACITY");
+
/* For _NET_WM_STATE ClientMessage requests */
final static int _NET_WM_STATE_REMOVE =0; /* remove/unset property */
final static int _NET_WM_STATE_ADD =1; /* add/set property */
@@ -289,6 +291,12 @@ final class XNETProtocol extends XProtocol implements XStateProtocol, XLayerProt
boolean res = active() && checkProtocol(XA_NET_SUPPORTED, XA_NET_WM_STATE_MODAL);
return res;
}
+
+ boolean doOpacityProtocol() {
+ boolean res = active() && checkProtocol(XA_NET_SUPPORTED, XA_NET_WM_WINDOW_OPACITY);
+ return res;
+ }
+
boolean isWMName(String name) {
if (!active()) {
return false;
diff --git a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java
index c3011dfa6a2..65324290213 100644
--- a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java
+++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2002-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -2273,4 +2273,36 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
public boolean areExtraMouseButtonsEnabled() throws HeadlessException {
return areExtraMouseButtonsEnabled;
}
+
+ @Override
+ public boolean isWindowOpacitySupported() {
+ XNETProtocol net_protocol = XWM.getWM().getNETProtocol();
+
+ if (net_protocol == null) {
+ return false;
+ }
+
+ return net_protocol.doOpacityProtocol();
+ }
+
+ @Override
+ public boolean isWindowShapingSupported() {
+ return XlibUtil.isShapingSupported();
+ }
+
+ @Override
+ public boolean isWindowTranslucencySupported() {
+ //NOTE: it may not be supported. The actual check is being performed
+ // at com.sun.awt.AWTUtilities(). In X11 we need to check
+ // whether there's any translucency-capable GC available.
+ return true;
+ }
+
+ @Override
+ public boolean isTranslucencyCapable(GraphicsConfiguration gc) {
+ if (!(gc instanceof X11GraphicsConfig)) {
+ return false;
+ }
+ return ((X11GraphicsConfig)gc).isTranslucencyCapable();
+ }
}
diff --git a/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java
index 5666cab8cda..619ff8a9c9b 100644
--- a/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java
+++ b/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2002-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,8 @@ import java.awt.event.ComponentEvent;
import java.awt.event.FocusEvent;
import java.awt.event.WindowEvent;
+import java.awt.image.BufferedImage;
+
import java.awt.peer.ComponentPeer;
import java.awt.peer.WindowPeer;
@@ -42,6 +44,7 @@ import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
+import sun.awt.AWTAccessor;
import sun.awt.ComponentAccessor;
import sun.awt.WindowAccessor;
import sun.awt.DisplayChangedListener;
@@ -49,6 +52,8 @@ import sun.awt.SunToolkit;
import sun.awt.X11GraphicsDevice;
import sun.awt.X11GraphicsEnvironment;
+import sun.java2d.pipe.Region;
+
class XWindowPeer extends XPanelPeer implements WindowPeer,
DisplayChangedListener {
@@ -260,6 +265,10 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
setSaveUnder(true);
updateIconImages();
+
+ updateShape();
+ updateOpacity();
+ // no need in updateOpaque() as it is no-op
}
public void updateIconImages() {
@@ -417,6 +426,22 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
return defaultIconInfo;
}
+ private void updateShape() {
+ // Shape shape = ((Window)target).getShape();
+ Shape shape = AWTAccessor.getWindowAccessor().getShape((Window)target);
+ if (shape != null) {
+ applyShape(Region.getInstance(shape, null));
+ }
+ }
+
+ private void updateOpacity() {
+ // float opacity = ((Window)target).getOpacity();
+ float opacity = AWTAccessor.getWindowAccessor().getOpacity((Window)target);
+ if (opacity < 1.0f) {
+ setOpacity(opacity);
+ }
+ }
+
public void updateMinimumSize() {
//This function only saves minimumSize value in XWindowPeer
//Setting WMSizeHints is implemented in XDecoratedPeer
@@ -2064,4 +2089,44 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
}
super.handleButtonPressRelease(xev);
}
+
+ public void print(Graphics g) {
+ // We assume we print the whole frame,
+ // so we expect no clip was set previously
+ Shape shape = AWTAccessor.getWindowAccessor().getShape((Window)target);
+ if (shape != null) {
+ g.setClip(shape);
+ }
+ super.print(g);
+ }
+
+ @Override
+ public void setOpacity(float opacity) {
+ final long maxOpacity = 0xffffffffl;
+ long iOpacity = (long)(opacity * maxOpacity);
+ if (iOpacity < 0) {
+ iOpacity = 0;
+ }
+ if (iOpacity > maxOpacity) {
+ iOpacity = maxOpacity;
+ }
+
+ XAtom netWmWindowOpacityAtom = XAtom.get("_NET_WM_WINDOW_OPACITY");
+
+ if (iOpacity == maxOpacity) {
+ netWmWindowOpacityAtom.DeleteProperty(getWindow());
+ } else {
+ netWmWindowOpacityAtom.setCard32Property(getWindow(), iOpacity);
+ }
+ }
+
+ @Override
+ public void setOpaque(boolean isOpaque) {
+ // no-op
+ }
+
+ @Override
+ public void updateWindow(BufferedImage backBuffer) {
+ // no-op
+ }
}
diff --git a/jdk/src/solaris/classes/sun/awt/X11/generator/WrapperGenerator.java b/jdk/src/solaris/classes/sun/awt/X11/generator/WrapperGenerator.java
index 84cfa254e4c..7aa039546fa 100644
--- a/jdk/src/solaris/classes/sun/awt/X11/generator/WrapperGenerator.java
+++ b/jdk/src/solaris/classes/sun/awt/X11/generator/WrapperGenerator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -859,14 +859,14 @@ public class WrapperGenerator {
pw.println("\n\tlong pData;");
pw.println("\n\tpublic long getPData() { return pData; }");
- pw.println("\n\n\t" + stp.getJavaClassName() + "(long addr) {");
+ pw.println("\n\n\tpublic " + stp.getJavaClassName() + "(long addr) {");
if (generateLog) {
pw.println("\t\tlog.finest(\"Creating\");");
}
pw.println("\t\tpData=addr;");
pw.println("\t\tshould_free_memory = false;");
pw.println("\t}");
- pw.println("\n\n\t" + stp.getJavaClassName() + "() {");
+ pw.println("\n\n\tpublic " + stp.getJavaClassName() + "() {");
if (generateLog) {
pw.println("\t\tlog.finest(\"Creating\");");
}
diff --git a/jdk/src/solaris/classes/sun/awt/X11/generator/xlibtypes.txt b/jdk/src/solaris/classes/sun/awt/X11/generator/xlibtypes.txt
index 21bc3ce02a9..7ef8fd44790 100644
--- a/jdk/src/solaris/classes/sun/awt/X11/generator/xlibtypes.txt
+++ b/jdk/src/solaris/classes/sun/awt/X11/generator/xlibtypes.txt
@@ -750,6 +750,7 @@ AwtGraphicsConfigData
pixelStride int
color_data pointer ColorData
glxInfo pointer
+ isTranslucencySupported int
AwtScreenData
numConfigs int
diff --git a/jdk/src/solaris/classes/sun/awt/X11GraphicsConfig.java b/jdk/src/solaris/classes/sun/awt/X11GraphicsConfig.java
index 8ea5717ac2a..aa4b527208b 100644
--- a/jdk/src/solaris/classes/sun/awt/X11GraphicsConfig.java
+++ b/jdk/src/solaris/classes/sun/awt/X11GraphicsConfig.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -450,4 +450,13 @@ public class X11GraphicsConfig extends GraphicsConfiguration
return 0x00; // UNDEFINED
}
}
+
+ /*
+ @Override
+ */
+ public boolean isTranslucencyCapable() {
+ return isTranslucencyCapable(getAData());
+ }
+
+ private native boolean isTranslucencyCapable(long x11ConfigData);
}
diff --git a/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c b/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
index 03f5c23d144..2e80cf7206d 100644
--- a/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
+++ b/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -354,6 +354,48 @@ makeDefaultConfig(JNIEnv *env, int screen) {
return NULL;
}
+/* Note: until we include the explicitly
+ * we have to define a couple of things ourselves.
+ */
+typedef unsigned long PictFormat;
+#define PictTypeIndexed 0
+#define PictTypeDirect 1
+
+typedef struct {
+ short red;
+ short redMask;
+ short green;
+ short greenMask;
+ short blue;
+ short blueMask;
+ short alpha;
+ short alphaMask;
+} XRenderDirectFormat;
+
+typedef struct {
+ PictFormat id;
+ int type;
+ int depth;
+ XRenderDirectFormat direct;
+ Colormap colormap;
+} XRenderPictFormat;
+
+#define PictFormatID (1 << 0)
+#define PictFormatType (1 << 1)
+#define PictFormatDepth (1 << 2)
+#define PictFormatRed (1 << 3)
+#define PictFormatRedMask (1 << 4)
+#define PictFormatGreen (1 << 5)
+#define PictFormatGreenMask (1 << 6)
+#define PictFormatBlue (1 << 7)
+#define PictFormatBlueMask (1 << 8)
+#define PictFormatAlpha (1 << 9)
+#define PictFormatAlphaMask (1 << 10)
+#define PictFormatColormap (1 << 11)
+
+typedef XRenderPictFormat *
+XRenderFindVisualFormatFunc (Display *dpy, _Xconst Visual *visual);
+
static void
getAllConfigs (JNIEnv *env, int screen, AwtScreenDataPtr screenDataPtr) {
@@ -367,6 +409,9 @@ getAllConfigs (JNIEnv *env, int screen, AwtScreenDataPtr screenDataPtr) {
int ind;
char errmsg[128];
int xinawareScreen;
+ void* xrenderLibHandle = NULL;
+ XRenderFindVisualFormatFunc *XRenderFindVisualFormat = NULL;
+ int major_opcode, first_event, first_error;
if (usingXinerama) {
xinawareScreen = 0;
@@ -449,6 +494,26 @@ getAllConfigs (JNIEnv *env, int screen, AwtScreenDataPtr screenDataPtr) {
graphicsConfigs[0] = defaultConfig;
nConfig = 1; /* reserve index 0 for default config */
+ // Only use the RENDER extension if it is available on the X server
+ if (XQueryExtension(awt_display, "RENDER",
+ &major_opcode, &first_event, &first_error))
+ {
+ xrenderLibHandle = dlopen("libXrender.so.1", RTLD_LAZY | RTLD_GLOBAL);
+
+#ifndef __linux__ /* SOLARIS */
+ if (xrenderLibHandle == NULL) {
+ xrenderLibHandle = dlopen("/usr/sfw/lib/libXrender.so.1",
+ RTLD_LAZY | RTLD_GLOBAL);
+ }
+#endif
+
+ if (xrenderLibHandle != NULL) {
+ XRenderFindVisualFormat =
+ (XRenderFindVisualFormatFunc*)dlsym(xrenderLibHandle,
+ "XRenderFindVisualFormat");
+ }
+ }
+
for (i = 0; i < nTrue; i++) {
if (XVisualIDFromVisual(pVITrue[i].visual) ==
XVisualIDFromVisual(defaultConfig->awt_visInfo.visual) ||
@@ -462,6 +527,21 @@ getAllConfigs (JNIEnv *env, int screen, AwtScreenDataPtr screenDataPtr) {
graphicsConfigs [ind]->awt_depth = pVITrue [i].depth;
memcpy (&graphicsConfigs [ind]->awt_visInfo, &pVITrue [i],
sizeof (XVisualInfo));
+ if (XRenderFindVisualFormat != NULL) {
+ XRenderPictFormat *format = XRenderFindVisualFormat (awt_display,
+ pVITrue [i].visual);
+ if (format &&
+ format->type == PictTypeDirect &&
+ format->direct.alphaMask)
+ {
+ graphicsConfigs [ind]->isTranslucencySupported = 1;
+ }
+ }
+ }
+
+ if (xrenderLibHandle != NULL) {
+ dlclose(xrenderLibHandle);
+ xrenderLibHandle = NULL;
}
for (i = 0; i < n8p; i++) {
@@ -1505,6 +1585,26 @@ Java_sun_awt_X11GraphicsConfig_swapBuffers
AWT_FLUSH_UNLOCK();
}
+/*
+ * Class: sun_awt_X11GraphicsConfig
+ * Method: isTranslucencyCapable
+ * Signature: (J)V
+ */
+JNIEXPORT jboolean JNICALL
+Java_sun_awt_X11GraphicsConfig_isTranslucencyCapable
+ (JNIEnv *env, jobject this, jlong configData)
+{
+#ifdef HEADLESS
+ return JNI_FALSE;
+#else
+ AwtGraphicsConfigDataPtr aData = (AwtGraphicsConfigDataPtr)jlong_to_ptr(configData);
+ if (aData == NULL) {
+ return JNI_FALSE;
+ }
+ return (jboolean)aData->isTranslucencySupported;
+#endif
+}
+
/*
* Class: sun_awt_X11GraphicsDevice
* Method: isDBESupported
diff --git a/jdk/src/solaris/native/sun/awt/awt_p.h b/jdk/src/solaris/native/sun/awt/awt_p.h
index fb4f513f79f..73e5dd0a88e 100644
--- a/jdk/src/solaris/native/sun/awt/awt_p.h
+++ b/jdk/src/solaris/native/sun/awt/awt_p.h
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1995-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -135,6 +135,7 @@ typedef struct _AwtGraphicsConfigData {
int pixelStride; /* Used in X11SurfaceData.c */
ColorData *color_data;
struct _GLXGraphicsConfigInfo *glxInfo;
+ int isTranslucencySupported; /* Uses Xrender to find this out. */
} AwtGraphicsConfigData;
typedef AwtGraphicsConfigData* AwtGraphicsConfigDataPtr;
diff --git a/jdk/src/windows/classes/sun/awt/Win32GraphicsConfig.java b/jdk/src/windows/classes/sun/awt/Win32GraphicsConfig.java
index d24ce0eb1bb..2eefb33f1ce 100644
--- a/jdk/src/windows/classes/sun/awt/Win32GraphicsConfig.java
+++ b/jdk/src/windows/classes/sun/awt/Win32GraphicsConfig.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -331,4 +331,12 @@ public class Win32GraphicsConfig extends GraphicsConfiguration
}
// the rest of the flip actions are not supported
}
+
+ /*
+ @Override
+ */
+ public boolean isTranslucencyCapable() {
+ //XXX: worth checking if 8-bit? Anyway, it doesn't hurt.
+ return true;
+ }
}
diff --git a/jdk/src/windows/classes/sun/awt/Win32GraphicsEnvironment.java b/jdk/src/windows/classes/sun/awt/Win32GraphicsEnvironment.java
index 80ee7747004..5c53d79d4d4 100644
--- a/jdk/src/windows/classes/sun/awt/Win32GraphicsEnvironment.java
+++ b/jdk/src/windows/classes/sun/awt/Win32GraphicsEnvironment.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -393,4 +393,11 @@ public class Win32GraphicsEnvironment
private static void dwmCompositionChanged(boolean enabled) {
isDWMCompositionEnabled = enabled;
}
+
+ /**
+ * Used to find out if the OS is Windows Vista or later.
+ *
+ * @return {@code true} if the OS is Vista or later, {@code false} otherwise
+ */
+ public static native boolean isVistaOS();
}
diff --git a/jdk/src/windows/classes/sun/awt/windows/TranslucentWindowPainter.java b/jdk/src/windows/classes/sun/awt/windows/TranslucentWindowPainter.java
new file mode 100644
index 00000000000..9f8193f9920
--- /dev/null
+++ b/jdk/src/windows/classes/sun/awt/windows/TranslucentWindowPainter.java
@@ -0,0 +1,398 @@
+/*
+ * Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+package sun.awt.windows;
+
+import java.awt.AlphaComposite;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.Image;
+import java.awt.Window;
+import java.awt.image.BufferedImage;
+import java.awt.image.DataBufferInt;
+import java.awt.image.VolatileImage;
+import java.lang.ref.WeakReference;
+import java.security.AccessController;
+import sun.awt.image.BufImgSurfaceData;
+import sun.java2d.DestSurfaceProvider;
+import sun.java2d.InvalidPipeException;
+import sun.java2d.Surface;
+import sun.java2d.pipe.RenderQueue;
+import sun.java2d.pipe.hw.AccelGraphicsConfig;
+import sun.java2d.pipe.hw.AccelSurface;
+import sun.security.action.GetPropertyAction;
+
+import static java.awt.image.VolatileImage.*;
+import static java.awt.Transparency.*;
+import static sun.java2d.pipe.hw.AccelSurface.*;
+import static sun.java2d.pipe.hw.ContextCapabilities.*;
+
+/**
+ * This class handles the updates of the non-opaque windows.
+ * The window associated with the peer is updated either given an image or
+ * the window is repainted to an internal buffer which is then used to update
+ * the window.
+ *
+ * Note: this class does not attempt to be thread safe, it is expected to be
+ * called from a single thread (EDT).
+ */
+public abstract class TranslucentWindowPainter {
+
+ protected Window window;
+ protected WWindowPeer peer;
+
+ // REMIND: we probably would want to remove this later
+ private static final boolean forceOpt =
+ Boolean.valueOf(AccessController.doPrivileged(
+ new GetPropertyAction("sun.java2d.twp.forceopt", "false")));
+ private static final boolean forceSW =
+ Boolean.valueOf(AccessController.doPrivileged(
+ new GetPropertyAction("sun.java2d.twp.forcesw", "false")));
+
+ /**
+ * Creates an instance of the painter for particular peer.
+ */
+ public static TranslucentWindowPainter createInstance(WWindowPeer peer) {
+ GraphicsConfiguration gc = peer.getGraphicsConfiguration();
+ if (!forceSW && gc instanceof AccelGraphicsConfig) {
+ String gcName = gc.getClass().getSimpleName();
+ AccelGraphicsConfig agc = (AccelGraphicsConfig)gc;
+ // this is a heuristic to check that we have a pcix board
+ // (those have higher transfer rate from gpu to cpu)
+ if ((agc.getContextCapabilities().getCaps() & CAPS_PS30) != 0 ||
+ forceOpt)
+ {
+ // we check for name to avoid loading classes unnecessarily if
+ // a pipeline isn't enabled
+ if (gcName.startsWith("D3D")) {
+ return new VIOptD3DWindowPainter(peer);
+ } else if (forceOpt && gcName.startsWith("WGL")) {
+ // on some boards (namely, ATI, even on pcix bus) ogl is
+ // very slow reading pixels back so for now it is disabled
+ // unless forced
+ return new VIOptWGLWindowPainter(peer);
+ }
+ }
+ }
+ return new BIWindowPainter(peer);
+ }
+
+ protected TranslucentWindowPainter(WWindowPeer peer) {
+ this.peer = peer;
+ this.window = (Window)peer.getTarget();
+ }
+
+ /**
+ * Creates (if needed), clears and returns the buffer for this painter.
+ */
+ protected abstract Image getBackBuffer();
+
+ /**
+ * Updates the the window associated with this painter with the contents
+ * of the passed image.
+ * The image can not be null, and NPE will be thrown if it is.
+ */
+ protected abstract boolean update(Image bb);
+
+ /**
+ * Flushes the resources associated with the painter. They will be
+ * recreated as needed.
+ */
+ public abstract void flush();
+
+ /**
+ * Updates the window associated with the painter given the passed image.
+ * If the passed image is null the painter will use its own buffer for
+ * rendering the contents of the window into it and updating the window.
+ *
+ * If the passed buffer has dimensions different from the window, it is
+ * copied into the internal buffer first and the latter is used to update
+ * the window.
+ *
+ * @param bb the image to update the non opaque window with, or null.
+ * If not null, the image must be of ARGB_PRE type.
+ */
+ public void updateWindow(Image bb) {
+ boolean done = false;
+ if (bb != null && (window.getWidth() != bb.getWidth(null) ||
+ window.getHeight() != bb.getHeight(null)))
+ {
+ Image ourBB = getBackBuffer();
+ Graphics2D g = (Graphics2D)ourBB.getGraphics();
+ g.drawImage(bb, 0, 0, null);
+ g.dispose();
+ bb = ourBB;
+ }
+ do {
+ if (bb == null) {
+ bb = getBackBuffer();
+ Graphics2D g = (Graphics2D)bb.getGraphics();
+ try {
+ window.paintAll(g);
+ } finally {
+ g.dispose();
+ }
+ }
+
+ peer.paintAppletWarning((Graphics2D)bb.getGraphics(),
+ bb.getWidth(null), bb.getHeight(null));
+
+ done = update(bb);
+ // in case they passed us a lost VI, next time around we'll use our
+ // own bb because we can not validate and restore the contents of
+ // their VI
+ if (!done) {
+ bb = null;
+ }
+ } while (!done);
+ }
+
+ private static final Image clearImage(Image bb) {
+ Graphics2D g = (Graphics2D)bb.getGraphics();
+ int w = bb.getWidth(null);
+ int h = bb.getHeight(null);
+
+ g.setComposite(AlphaComposite.Src);
+ g.setColor(new Color(0, 0, 0, 0));
+ g.fillRect(0, 0, w, h);
+
+ return bb;
+ }
+
+ /**
+ * A painter which uses BufferedImage as the internal buffer. The window
+ * is painted into this buffer, and the contents then are uploaded
+ * into the layered window.
+ *
+ * This painter handles all types of images passed to its paint(Image)
+ * method (VI, BI, regular Images).
+ */
+ private static class BIWindowPainter extends TranslucentWindowPainter {
+ private WeakReference biRef;
+
+ protected BIWindowPainter(WWindowPeer peer) {
+ super(peer);
+ }
+
+ private BufferedImage getBIBackBuffer() {
+ int w = window.getWidth();
+ int h = window.getHeight();
+ BufferedImage bb = biRef == null ? null : biRef.get();
+ if (bb == null || bb.getWidth() != w || bb.getHeight() != h) {
+ if (bb != null) {
+ bb.flush();
+ bb = null;
+ }
+ bb = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE);
+ biRef = new WeakReference(bb);
+ }
+ return (BufferedImage)clearImage(bb);
+ }
+
+ @Override
+ protected Image getBackBuffer() {
+ return getBIBackBuffer();
+ }
+
+ @Override
+ protected boolean update(Image bb) {
+ VolatileImage viBB = null;
+
+ if (bb instanceof BufferedImage) {
+ BufferedImage bi = (BufferedImage)bb;
+ int data[] =
+ ((DataBufferInt)bi.getRaster().getDataBuffer()).getData();
+ peer.updateWindowImpl(data, bi.getWidth(), bi.getHeight());
+ return true;
+ } else if (bb instanceof VolatileImage) {
+ viBB = (VolatileImage)bb;
+ if (bb instanceof DestSurfaceProvider) {
+ Surface s = ((DestSurfaceProvider)bb).getDestSurface();
+ if (s instanceof BufImgSurfaceData) {
+ // the image is probably lost, upload the data from the
+ // backup surface to avoid creating another heap-based
+ // image (the parent's buffer)
+ int w = viBB.getWidth();
+ int h = viBB.getHeight();
+ BufImgSurfaceData bisd = (BufImgSurfaceData)s;
+ int data[] = ((DataBufferInt)bisd.getRaster(0,0,w,h).
+ getDataBuffer()).getData();
+ peer.updateWindowImpl(data, w, h);
+ return true;
+ }
+ }
+ }
+
+ // copy the passed image into our own buffer, then upload
+ BufferedImage bi = getBIBackBuffer();
+ Graphics2D g = (Graphics2D)bi.getGraphics();
+ g.setComposite(AlphaComposite.Src);
+ g.drawImage(bb, 0, 0, null);
+
+ int data[] =
+ ((DataBufferInt)bi.getRaster().getDataBuffer()).getData();
+ peer.updateWindowImpl(data, bi.getWidth(), bi.getHeight());
+
+ return (viBB != null ? !viBB.contentsLost() : true);
+ }
+
+ public void flush() {
+ if (biRef != null) {
+ biRef.clear();
+ }
+ }
+ }
+
+ /**
+ * A version of the painter which uses VolatileImage as the internal buffer.
+ * The window is painted into this VI and then copied into the parent's
+ * Java heap-based buffer (which is then uploaded to the layered window)
+ */
+ private static class VIWindowPainter extends BIWindowPainter {
+ private WeakReference viRef;
+
+ protected VIWindowPainter(WWindowPeer peer) {
+ super(peer);
+ }
+
+ @Override
+ protected Image getBackBuffer() {
+ int w = window.getWidth();
+ int h = window.getHeight();
+ GraphicsConfiguration gc = peer.getGraphicsConfiguration();
+
+ VolatileImage viBB = viRef == null ? null : viRef.get();
+
+ if (viBB == null || viBB.getWidth() != w || viBB.getHeight() != h ||
+ viBB.validate(gc) == IMAGE_INCOMPATIBLE)
+ {
+ if (viBB != null) {
+ viBB.flush();
+ viBB = null;
+ }
+
+ if (gc instanceof AccelGraphicsConfig) {
+ AccelGraphicsConfig agc = ((AccelGraphicsConfig)gc);
+ viBB = agc.createCompatibleVolatileImage(w, h,
+ TRANSLUCENT,
+ RT_PLAIN);
+ }
+ if (viBB == null) {
+ viBB = gc.createCompatibleVolatileImage(w, h, TRANSLUCENT);
+ }
+ viBB.validate(gc);
+ viRef = new WeakReference(viBB);
+ }
+
+ return clearImage(viBB);
+ }
+
+ @Override
+ public void flush() {
+ if (viRef != null) {
+ VolatileImage viBB = viRef.get();
+ if (viBB != null) {
+ viBB.flush();
+ viBB = null;
+ }
+ viRef.clear();
+ }
+ }
+ }
+
+ /**
+ * Optimized version of hw painter. Uses VolatileImages for the
+ * buffer, and uses an optimized path to pull the data from those into
+ * the layered window, bypassing Java heap-based image.
+ */
+ private abstract static class VIOptWindowPainter extends VIWindowPainter {
+
+ protected VIOptWindowPainter(WWindowPeer peer) {
+ super(peer);
+ }
+
+ protected abstract boolean updateWindowAccel(long psdops, int w, int h);
+
+ @Override
+ protected boolean update(Image bb) {
+ if (bb instanceof DestSurfaceProvider) {
+ Surface s = ((DestSurfaceProvider)bb).getDestSurface();
+ if (s instanceof AccelSurface) {
+ final int w = bb.getWidth(null);
+ final int h = bb.getHeight(null);
+ final boolean arr[] = { false };
+ final AccelSurface as = (AccelSurface)s;
+ RenderQueue rq = as.getContext().getRenderQueue();
+ rq.lock();
+ try {
+ as.getContext().validateContext(as);
+ rq.flushAndInvokeNow(new Runnable() {
+ public void run() {
+ long psdops = as.getNativeOps();
+ arr[0] = updateWindowAccel(psdops, w, h);
+ }
+ });
+ } catch (InvalidPipeException e) {
+ // ignore, false will be returned
+ } finally {
+ rq.unlock();
+ }
+ return arr[0];
+ }
+ }
+ return super.update(bb);
+ }
+ }
+
+ private static class VIOptD3DWindowPainter extends VIOptWindowPainter {
+
+ protected VIOptD3DWindowPainter(WWindowPeer peer) {
+ super(peer);
+ }
+
+ @Override
+ protected boolean updateWindowAccel(long psdops, int w, int h) {
+ // note: this method is executed on the toolkit thread, no sync is
+ // necessary at the native level, and a pointer to peer can be used
+ return sun.java2d.d3d.D3DSurfaceData.
+ updateWindowAccelImpl(psdops, peer.getData(), w, h);
+ }
+ }
+
+ private static class VIOptWGLWindowPainter extends VIOptWindowPainter {
+
+ protected VIOptWGLWindowPainter(WWindowPeer peer) {
+ super(peer);
+ }
+
+ @Override
+ protected boolean updateWindowAccel(long psdops, int w, int h) {
+ // note: part of this method which deals with GDI will be on the
+ // toolkit thread
+ return sun.java2d.opengl.WGLSurfaceData.
+ updateWindowAccelImpl(psdops, peer, w, h);
+ }
+ }
+}
diff --git a/jdk/src/windows/classes/sun/awt/windows/WCanvasPeer.java b/jdk/src/windows/classes/sun/awt/windows/WCanvasPeer.java
index 5d88a0c3703..e1657102900 100644
--- a/jdk/src/windows/classes/sun/awt/windows/WCanvasPeer.java
+++ b/jdk/src/windows/classes/sun/awt/windows/WCanvasPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@ import java.awt.*;
import java.awt.peer.*;
import java.lang.ref.WeakReference;
import java.lang.reflect.Method;
+import sun.awt.AWTAccessor;
import sun.awt.ComponentAccessor;
import sun.awt.SunToolkit;
import sun.awt.Win32GraphicsDevice;
@@ -110,16 +111,20 @@ class WCanvasPeer extends WComponentPeer implements CanvasPeer {
}
public void print(Graphics g) {
- Dimension d = ((Component)target).getSize();
- if (g instanceof Graphics2D ||
- g instanceof sun.awt.Graphics2Delegate) {
- // background color is setup correctly, so just use clearRect
- g.clearRect(0, 0, d.width, d.height);
- } else {
- // emulate clearRect
- g.setColor(((Component)target).getBackground());
- g.fillRect(0, 0, d.width, d.height);
- g.setColor(((Component)target).getForeground());
+ if (!(target instanceof Window) ||
+ AWTAccessor.getWindowAccessor().isOpaque((Window)target))
+ {
+ Dimension d = ((Component)target).getSize();
+ if (g instanceof Graphics2D ||
+ g instanceof sun.awt.Graphics2Delegate) {
+ // background color is setup correctly, so just use clearRect
+ g.clearRect(0, 0, d.width, d.height);
+ } else {
+ // emulate clearRect
+ g.setColor(((Component)target).getBackground());
+ g.fillRect(0, 0, d.width, d.height);
+ g.setColor(((Component)target).getForeground());
+ }
}
super.print(g);
}
diff --git a/jdk/src/windows/classes/sun/awt/windows/WComponentPeer.java b/jdk/src/windows/classes/sun/awt/windows/WComponentPeer.java
index afbd170cc7f..3a414d1c328 100644
--- a/jdk/src/windows/classes/sun/awt/windows/WComponentPeer.java
+++ b/jdk/src/windows/classes/sun/awt/windows/WComponentPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
* 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,21 +39,22 @@ import java.awt.event.PaintEvent;
import java.awt.event.InvocationEvent;
import java.awt.event.KeyEvent;
import sun.awt.Win32GraphicsConfig;
+import sun.awt.Win32GraphicsEnvironment;
import sun.java2d.InvalidPipeException;
import sun.java2d.SurfaceData;
-import sun.java2d.d3d.D3DScreenUpdateManager;
-import static sun.java2d.d3d.D3DSurfaceData.*;
import sun.java2d.ScreenUpdateManager;
+import sun.java2d.d3d.D3DSurfaceData;
import sun.java2d.opengl.OGLSurfaceData;
+import sun.java2d.pipe.Region;
import sun.awt.DisplayChangedListener;
import sun.awt.PaintEventDispatcher;
+import sun.awt.SunToolkit;
import sun.awt.event.IgnorePaintEvent;
import java.awt.dnd.DropTarget;
import java.awt.dnd.peer.DropTargetPeer;
import sun.awt.ComponentAccessor;
-
import java.util.logging.*;
@@ -186,7 +187,7 @@ public abstract class WComponentPeer extends WObjectPeer
cont.invalidate();
cont.validate();
- if (surfaceData instanceof D3DWindowSurfaceData ||
+ if (surfaceData instanceof D3DSurfaceData.D3DWindowSurfaceData ||
surfaceData instanceof OGLSurfaceData)
{
// When OGL or D3D is enabled, it is necessary to
@@ -258,7 +259,7 @@ public abstract class WComponentPeer extends WObjectPeer
int[] pix = createPrintedPixels(0, startY, totalW, h);
if (pix != null) {
BufferedImage bim = new BufferedImage(totalW, h,
- BufferedImage.TYPE_INT_RGB);
+ BufferedImage.TYPE_INT_ARGB);
bim.setRGB(0, 0, totalW, h, pix, 0, totalW);
g.drawImage(bim, 0, startY, null);
bim.flush();
@@ -895,9 +896,29 @@ public abstract class WComponentPeer extends WObjectPeer
public void setBoundsOperation(int operation) {
}
+ /**
+ * Returns whether this component is capable of being hw accelerated.
+ * More specifically, whether rendering to this component or a
+ * BufferStrategy's back-buffer for this component can be hw accelerated.
+ *
+ * Conditions which could prevent hw acceleration include the toplevel
+ * window containing this component being
+ * {@link com.sun.awt.AWTUtilities.Translucency#TRANSLUCENT TRANSLUCENT}.
+ *
+ * @return {@code true} if this component is capable of being hw
+ * accelerated, {@code false} otherwise
+ * @see com.sun.awt.AWTUtilities.Translucency#TRANSLUCENT
+ */
+ public boolean isAccelCapable() {
+ boolean isTranslucent =
+ SunToolkit.isContainingTopLevelTranslucent((Component)target);
+ // D3D/OGL and translucent windows interacted poorly in Windows XP;
+ // these problems are no longer present in Vista
+ return !isTranslucent || Win32GraphicsEnvironment.isVistaOS();
+ }
native void setRectangularShape(int lox, int loy, int hix, int hiy,
- sun.java2d.pipe.Region region);
+ Region region);
// REMIND: Temp workaround for issues with using HW acceleration
@@ -914,42 +935,11 @@ public abstract class WComponentPeer extends WObjectPeer
return ((WEmbeddedFramePeer)c.getPeer()).isAccelCapable();
}
- /**
- * Returns whether this component is capable of being hw accelerated.
- * More specifically, whether rendering to this component or a
- * BufferStrategy's back-buffer for this component can be hw accelerated.
- *
- * Conditions which could prevent hw acceleration include the toplevel
- * window containing this component being
- * {@link com.sun.awt.AWTUtilities.Translucency#TRANSLUCENT TRANSLUCENT}.
- *
- * @return {@code true} if this component is capable of being hw
- * accelerated, {@code false} otherwise
- * @see com.sun.awt.AWTUtilities.Translucency#TRANSLUCENT
- */
- public boolean isAccelCapable() {
- // REMIND: Temp workaround for issues with using HW acceleration
- // in the browser on Vista when DWM is enabled
- if (!isContainingTopLevelAccelCapable((Component)target)) {
- return false;
- }
-
- // REMIND: translucent windows support-related
-/*
- boolean isTranslucent =
- SunToolkit.isContainingTopLevelTranslucent((Component)target);
- // D3D/OGL and translucent windows interacted poorly in Windows XP;
- // these problems are no longer present in Vista
- return !isTranslucent || Win32GraphicsEnvironment.isVistaOS();
-*/
- return true;
- }
-
/**
* Applies the shape to the native component window.
* @since 1.7
*/
- public void applyShape(sun.java2d.pipe.Region shape) {
+ public void applyShape(Region shape) {
if (shapeLog.isLoggable(Level.FINER)) {
shapeLog.finer(
"*** INFO: Setting shape: PEER: " + this
diff --git a/jdk/src/windows/classes/sun/awt/windows/WFileDialogPeer.java b/jdk/src/windows/classes/sun/awt/windows/WFileDialogPeer.java
index 548dc3d41ee..2d4dfccf7a1 100644
--- a/jdk/src/windows/classes/sun/awt/windows/WFileDialogPeer.java
+++ b/jdk/src/windows/classes/sun/awt/windows/WFileDialogPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -244,4 +244,10 @@ public class WFileDialogPeer extends WWindowPeer implements FileDialogPeer {
public boolean isRestackSupported() {
return false;
}
+
+ // The effects are not supported for system dialogs.
+ public void applyShape(sun.java2d.pipe.Region shape) {}
+ public void setOpacity(float opacity) {}
+ public void setOpaque(boolean isOpaque) {}
+ public void updateWindow(java.awt.image.BufferedImage backBuffer) {}
}
diff --git a/jdk/src/windows/classes/sun/awt/windows/WPrintDialogPeer.java b/jdk/src/windows/classes/sun/awt/windows/WPrintDialogPeer.java
index c1e06f53cb5..939d54520b6 100644
--- a/jdk/src/windows/classes/sun/awt/windows/WPrintDialogPeer.java
+++ b/jdk/src/windows/classes/sun/awt/windows/WPrintDialogPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -156,4 +156,10 @@ public class WPrintDialogPeer extends WWindowPeer implements DialogPeer {
public boolean isRestackSupported() {
return false;
}
+
+ // The effects are not supported for system dialogs.
+ public void applyShape(sun.java2d.pipe.Region shape) {}
+ public void setOpacity(float opacity) {}
+ public void setOpaque(boolean isOpaque) {}
+ public void updateWindow(java.awt.image.BufferedImage backBuffer) {}
}
diff --git a/jdk/src/windows/classes/sun/awt/windows/WToolkit.java b/jdk/src/windows/classes/sun/awt/windows/WToolkit.java
index 55c1dde092d..5376e8ff720 100644
--- a/jdk/src/windows/classes/sun/awt/windows/WToolkit.java
+++ b/jdk/src/windows/classes/sun/awt/windows/WToolkit.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -975,4 +975,34 @@ public class WToolkit extends SunToolkit implements Runnable {
public boolean areExtraMouseButtonsEnabled() throws HeadlessException {
return areExtraMouseButtonsEnabled;
}
+
+ @Override
+ public boolean isWindowOpacitySupported() {
+ // supported in Win2K and later
+ return true;
+ }
+
+ @Override
+ public boolean isWindowShapingSupported() {
+ return true;
+ }
+
+ @Override
+ public boolean isWindowTranslucencySupported() {
+ // supported in Win2K and later
+ return true;
+ }
+
+ @Override
+ public boolean isTranslucencyCapable(GraphicsConfiguration gc) {
+ //XXX: worth checking if 8-bit? Anyway, it doesn't hurt.
+ return true;
+ }
+
+ // On MS Windows one must use the peer.updateWindow() to implement
+ // non-opaque windows.
+ @Override
+ public boolean needUpdateWindow() {
+ return true;
+ }
}
diff --git a/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java b/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java
index 6afdb2be6b9..79818431063 100644
--- a/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java
+++ b/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
* 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,17 +31,15 @@ import java.awt.peer.*;
import java.beans.*;
-import java.lang.ref.*;
import java.lang.reflect.*;
-import java.security.*;
-
import java.util.*;
import java.util.List;
import java.util.logging.*;
import sun.awt.*;
-import sun.awt.image.*;
+
+import sun.java2d.pipe.Region;
public class WWindowPeer extends WPanelPeer implements WindowPeer {
@@ -52,6 +50,10 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer {
// extends WWindowPeer, not WDialogPeer
private WWindowPeer modalBlocker = null;
+ private boolean isOpaque;
+
+ private volatile TranslucentWindowPainter painter;
+
/*
* A key used for storing a list of active windows in AppContext. The value
* is a list of windows, sorted by the time of activation: later a window is
@@ -91,9 +93,18 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer {
l.remove(this);
}
}
+
// Remove ourself from the Map of DisplayChangeListeners
GraphicsConfiguration gc = getGraphicsConfiguration();
((Win32GraphicsDevice)gc.getDevice()).removeDisplayChangedListener(this);
+
+ TranslucentWindowPainter currentPainter = painter;
+ if (currentPainter != null) {
+ currentPainter.flush();
+ // don't set the current one to null here; reduces the chances of
+ // MT issues (like NPEs)
+ }
+
super.disposeImpl();
}
@@ -158,6 +169,10 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer {
initActiveWindowsTracking((Window)target);
updateIconImages();
+
+ updateShape();
+ updateOpacity();
+ updateOpaque();
}
native void createAwtWindow(WComponentPeer parent);
@@ -191,6 +206,8 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer {
if (((Window)target).isAlwaysOnTopSupported() && alwaysOnTop) {
setAlwaysOnTop(alwaysOnTop);
}
+
+ updateWindow(null);
}
// Synchronize the insets members (here & in helper) with actual window
@@ -273,6 +290,31 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer {
}
}
+ private void updateShape() {
+ // Shape shape = ((Window)target).getShape();
+ Shape shape = AWTAccessor.getWindowAccessor().getShape((Window)target);
+ if (shape != null) {
+ applyShape(Region.getInstance(shape, null));
+ }
+ }
+
+ private void updateOpacity() {
+ // float opacity = ((Window)target).getOpacity();
+ float opacity = AWTAccessor.getWindowAccessor().getOpacity((Window)target);
+ if (opacity < 1.0f) {
+ setOpacity(opacity);
+ }
+ }
+
+ private void updateOpaque() {
+ this.isOpaque = true;
+ // boolean opaque = ((Window)target).isOpaque();
+ boolean opaque = AWTAccessor.getWindowAccessor().isOpaque((Window)target);
+ if (!opaque) {
+ setOpaque(opaque);
+ }
+ }
+
native void setMinSize(int width, int height);
/*
@@ -525,6 +567,135 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer {
super.setBounds(newBounds.x, newBounds.y, newBounds.width, newBounds.height, op);
}
+ @Override
+ public void print(Graphics g) {
+ // We assume we print the whole frame,
+ // so we expect no clip was set previously
+ Shape shape = AWTAccessor.getWindowAccessor().getShape((Window)target);
+ if (shape != null) {
+ g.setClip(shape);
+ }
+ super.print(g);
+ }
+
+ private void replaceSurfaceDataRecursively(Component c) {
+ if (c instanceof Container) {
+ for (Component child : ((Container)c).getComponents()) {
+ replaceSurfaceDataRecursively(child);
+ }
+ }
+ ComponentPeer cp = c.getPeer();
+ if (cp instanceof WComponentPeer) {
+ ((WComponentPeer)cp).replaceSurfaceDataLater();
+ }
+ }
+
+ private native void setOpacity(int iOpacity);
+
+ public void setOpacity(float opacity) {
+ if (!((SunToolkit)((Window)target).getToolkit()).
+ isWindowOpacitySupported())
+ {
+ return;
+ }
+
+ replaceSurfaceDataRecursively((Component)getTarget());
+
+ final int maxOpacity = 0xff;
+ int iOpacity = (int)(opacity * maxOpacity);
+ if (iOpacity < 0) {
+ iOpacity = 0;
+ }
+ if (iOpacity > maxOpacity) {
+ iOpacity = maxOpacity;
+ }
+
+ setOpacity(iOpacity);
+ updateWindow(null);
+ }
+
+ private native void setOpaqueImpl(boolean isOpaque);
+
+ public void setOpaque(boolean isOpaque) {
+ Window target = (Window)getTarget();
+
+ SunToolkit sunToolkit = (SunToolkit)target.getToolkit();
+ if (!sunToolkit.isWindowTranslucencySupported() ||
+ !sunToolkit.isTranslucencyCapable(target.getGraphicsConfiguration()))
+ {
+ return;
+ }
+
+ boolean opaqueChanged = this.isOpaque != isOpaque;
+ boolean isVistaOS = Win32GraphicsEnvironment.isVistaOS();
+
+ if (opaqueChanged && !isVistaOS){
+ // non-Vista OS: only replace the surface data if the opacity
+ // status changed (see WComponentPeer.isAccelCapable() for more)
+ replaceSurfaceDataRecursively(target);
+ }
+
+ this.isOpaque = isOpaque;
+
+ setOpaqueImpl(isOpaque);
+
+ if (opaqueChanged) {
+ if (isOpaque) {
+ TranslucentWindowPainter currentPainter = painter;
+ if (currentPainter != null) {
+ currentPainter.flush();
+ painter = null;
+ }
+ } else {
+ painter = TranslucentWindowPainter.createInstance(this);
+ }
+ }
+
+ if (opaqueChanged && isVistaOS) {
+ // On Vista: setting the window non-opaque makes the window look
+ // rectangular, though still catching the mouse clicks within
+ // its shape only. To restore the correct visual appearance
+ // of the window (i.e. w/ the correct shape) we have to reset
+ // the shape.
+ Shape shape = AWTAccessor.getWindowAccessor().getShape(target);
+ if (shape != null) {
+ AWTAccessor.getWindowAccessor().setShape(target, shape);
+ }
+ }
+
+ updateWindow(null);
+ }
+
+ public native void updateWindowImpl(int[] data, int width, int height);
+
+ public void updateWindow(BufferedImage backBuffer) {
+ if (isOpaque) {
+ return;
+ }
+
+ TranslucentWindowPainter currentPainter = painter;
+ if (currentPainter != null) {
+ currentPainter.updateWindow(backBuffer);
+ } else if (log.isLoggable(Level.FINER)) {
+ log.log(Level.FINER,
+ "Translucent window painter is null in updateWindow");
+ }
+ }
+
+ /**
+ * Paints the Applet Warning into the passed Graphics2D. This method is
+ * called by the TranslucentWindowPainter before updating the layered
+ * window.
+ *
+ * @param g Graphics context to paint the warning to
+ * @param w the width of the area
+ * @param h the height of the area
+ * @see TranslucentWindowPainter
+ */
+ public void paintAppletWarning(Graphics2D g, int w, int h) {
+ // REMIND: the applet warning needs to be painted here
+ }
+
/*
* The method maps the list of the active windows to the window's AppContext,
* then the method registers ActiveWindowListener, GuiDisposedListener listeners;
diff --git a/jdk/src/windows/classes/sun/java2d/opengl/WGLSurfaceData.java b/jdk/src/windows/classes/sun/java2d/opengl/WGLSurfaceData.java
index 27997aa8c59..4164264a164 100644
--- a/jdk/src/windows/classes/sun/java2d/opengl/WGLSurfaceData.java
+++ b/jdk/src/windows/classes/sun/java2d/opengl/WGLSurfaceData.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2004-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -72,9 +72,8 @@ public abstract class WGLSurfaceData extends OGLSurfaceData {
// the OGL pipeline can render directly to the screen and interfere
// with layered windows, which is why we don't allow accelerated
// surfaces in this case
- if (!peer.isAccelCapable())
- // REMIND: commented until toplevel translucency is implemented
-// || !SunToolkit.isContainingTopLevelOpaque((Component)peer.getTarget()))
+ if (!peer.isAccelCapable() ||
+ !SunToolkit.isContainingTopLevelOpaque((Component)peer.getTarget()))
{
return null;
}
@@ -93,9 +92,8 @@ public abstract class WGLSurfaceData extends OGLSurfaceData {
// the OGL pipeline can render directly to the screen and interfere
// with layered windows, which is why we don't allow accelerated
// surfaces in this case
- if (!peer.isAccelCapable())
- // REMIND: commented until toplevel translucency is implemented
-// || !SunToolkit.isContainingTopLevelOpaque((Component)peer.getTarget()))
+ if (!peer.isAccelCapable() ||
+ !SunToolkit.isContainingTopLevelOpaque((Component)peer.getTarget()))
{
return null;
}
diff --git a/jdk/src/windows/native/sun/awt/utility/rect.h b/jdk/src/windows/native/sun/awt/utility/rect.h
index bc250e2ac1b..a8e9fc28bea 100644
--- a/jdk/src/windows/native/sun/awt/utility/rect.h
+++ b/jdk/src/windows/native/sun/awt/utility/rect.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2007-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -43,5 +43,15 @@ typedef RECT RECT_T;
#define RECT_INC_HEIGHT(r) (r).bottom++
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+int BitmapToYXBandedRectangles(int bitsPerPixel, int width, int height,
+ unsigned char * buf, RECT_T * outBuf);
+
+#if defined(__cplusplus)
+}
+#endif
#endif // _AWT_RECT_H
diff --git a/jdk/src/windows/native/sun/java2d/d3d/D3DSurfaceData.cpp b/jdk/src/windows/native/sun/java2d/d3d/D3DSurfaceData.cpp
index 9c865dc971b..c6d4bb1b3eb 100644
--- a/jdk/src/windows/native/sun/java2d/d3d/D3DSurfaceData.cpp
+++ b/jdk/src/windows/native/sun/java2d/d3d/D3DSurfaceData.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2007-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -613,17 +613,15 @@ JNICALL Java_sun_java2d_d3d_D3DSurfaceData_updateWindowAccelImpl
res = pTmpSurface->LockRect(&lockedRect, NULL, D3DLOCK_NOSYSLOCK);
if (SUCCEEDED(res)) {
- // REMIND: commented until translucent window support is integrated
-// hBitmap =
-// BitmapUtil::CreateBitmapFromARGBPre(w, h,
-// lockedRect.Pitch,
-// (int*)lockedRect.pBits);
+ hBitmap =
+ BitmapUtil::CreateBitmapFromARGBPre(w, h,
+ lockedRect.Pitch,
+ (int*)lockedRect.pBits);
pTmpSurface->UnlockRect();
}
RETURN_STATUS_IF_NULL(hBitmap, JNI_FALSE);
- // REMIND: commented until translucent window support is integrated
-// window->UpdateWindow(env, NULL, w, h, hBitmap);
+ window->UpdateWindow(env, NULL, w, h, hBitmap);
// hBitmap is released in UpdateWindow
diff --git a/jdk/src/windows/native/sun/java2d/opengl/WGLSurfaceData.c b/jdk/src/windows/native/sun/java2d/opengl/WGLSurfaceData.c
index 71d5e876406..3c3e09cecea 100644
--- a/jdk/src/windows/native/sun/java2d/opengl/WGLSurfaceData.c
+++ b/jdk/src/windows/native/sun/java2d/opengl/WGLSurfaceData.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2004-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -625,17 +625,15 @@ JNIEXPORT jboolean JNICALL
j2d_glPixelStorei(GL_PACK_ALIGNMENT, 4);
// the pixels read from the surface are already premultiplied
- // REMIND: commented until translucent window support is integrated
-// hBitmap = BitmapUtil_CreateBitmapFromARGBPre(w, h, scanStride,
-// (int*)pDst);
+ hBitmap = BitmapUtil_CreateBitmapFromARGBPre(w, h, scanStride,
+ (int*)pDst);
free(pDst);
if (hBitmap == NULL) {
return JNI_FALSE;
}
- // REMIND: commented until translucent window support is integrated
- // AwtWindow_UpdateWindow(env, peer, w, h, hBitmap);
+ AwtWindow_UpdateWindow(env, peer, w, h, hBitmap);
// hBitmap is released in UpdateWindow
diff --git a/jdk/src/windows/native/sun/windows/awt_BitmapUtil.cpp b/jdk/src/windows/native/sun/windows/awt_BitmapUtil.cpp
index 64c52e2f8f8..10e71b3e61e 100644
--- a/jdk/src/windows/native/sun/windows/awt_BitmapUtil.cpp
+++ b/jdk/src/windows/native/sun/windows/awt_BitmapUtil.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2006-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,9 +28,14 @@
#include
#include
+#include "GraphicsPrimitiveMgr.h"
+
#include "awt.h"
#include "awt_BitmapUtil.h"
+// Platform-dependent RECT_[EQ | SET | INC_HEIGHT] macros
+#include "utility/rect.h"
+
HBITMAP BitmapUtil::CreateTransparencyMaskFromARGB(int width, int height, int* imageData)
{
//Scan lines should be aligned to word boundary
@@ -148,3 +153,222 @@ HBITMAP BitmapUtil::CreateV4BitmapFromARGB(int width, int height, int* imageData
::GdiFlush();
return hBitmap;
}
+
+/*
+ * Creates 32-bit premultiplied ARGB bitmap from specified ARGBPre data.
+ * This function may not work on OS prior to Win95.
+ * See MSDN articles for CreateDIBitmap, BITMAPINFOHEADER,
+ * BITMAPV4HEADER, BITMAPV5HEADER for additional info.
+ */
+HBITMAP BitmapUtil::CreateBitmapFromARGBPre(int width, int height,
+ int srcStride,
+ int* imageData)
+{
+ BITMAPINFOHEADER bmi;
+ void *bitmapBits = NULL;
+
+ ZeroMemory(&bmi, sizeof(bmi));
+ bmi.biSize = sizeof(bmi);
+ bmi.biWidth = width;
+ bmi.biHeight = -height;
+ bmi.biPlanes = 1;
+ bmi.biBitCount = 32;
+ bmi.biCompression = BI_RGB;
+
+ HBITMAP hBitmap =
+ ::CreateDIBSection(NULL, (BITMAPINFO *) & bmi, DIB_RGB_COLORS,
+ &bitmapBits, NULL, 0);
+
+ if (!bitmapBits) {
+ return NULL;
+ }
+
+ int dstStride = width * 4;
+
+ if (srcStride == dstStride) {
+ memcpy(bitmapBits, (void*)imageData, srcStride * height);
+ } else if (height > 0) {
+ void *pSrcPixels = (void*)imageData;
+ void *pDstPixels = bitmapBits;
+ do {
+ memcpy(pDstPixels, pSrcPixels, dstStride);
+ pSrcPixels = PtrAddBytes(pSrcPixels, srcStride);
+ pDstPixels = PtrAddBytes(pDstPixels, dstStride);
+ } while (--height > 0);
+ }
+
+ return hBitmap;
+}
+
+extern "C" {
+
+/**
+ * This method is called from the WGL pipeline when it needs to create a bitmap
+ * needed to update the layered window.
+ */
+HBITMAP BitmapUtil_CreateBitmapFromARGBPre(int width, int height,
+ int srcStride,
+ int* imageData)
+{
+ return BitmapUtil::CreateBitmapFromARGBPre(width, height,
+ srcStride, imageData);
+
+}
+
+} /* extern "C" */
+
+
+/**
+ * Transforms the given bitmap into an HRGN representing the transparency
+ * of the bitmap. The bitmap MUST BE 32bpp. Alpha value == 0 is considered
+ * transparent, alpha > 0 - opaque.
+ */
+HRGN BitmapUtil::BitmapToRgn(HBITMAP hBitmap)
+{
+ HDC hdc = ::CreateCompatibleDC(NULL);
+ ::SelectObject(hdc, hBitmap);
+
+ BITMAPINFOEX bi;
+ ::ZeroMemory(&bi, sizeof(bi));
+
+ bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+
+ BOOL r = ::GetDIBits(hdc, hBitmap, 0, 0, NULL,
+ reinterpret_cast(&bi), DIB_RGB_COLORS);
+
+ if (!r || bi.bmiHeader.biBitCount != 32)
+ {
+ ::DeleteDC(hdc);
+ return NULL;
+ }
+
+ UINT width = bi.bmiHeader.biWidth;
+ UINT height = abs(bi.bmiHeader.biHeight);
+
+ BYTE * buf = (BYTE*)safe_Malloc(bi.bmiHeader.biSizeImage);
+ bi.bmiHeader.biHeight = -height;
+ ::GetDIBits(hdc, hBitmap, 0, height, buf,
+ reinterpret_cast(&bi), DIB_RGB_COLORS);
+
+ /* reserving memory for the worst case */
+ RGNDATA * pRgnData = (RGNDATA *) safe_Malloc(sizeof(RGNDATAHEADER) +
+ sizeof(RECT) * (width / 2 + 1) * height);
+ RGNDATAHEADER * pRgnHdr = (RGNDATAHEADER *) pRgnData;
+ pRgnHdr->dwSize = sizeof(RGNDATAHEADER);
+ pRgnHdr->iType = RDH_RECTANGLES;
+ pRgnHdr->nRgnSize = 0;
+ pRgnHdr->rcBound.top = 0;
+ pRgnHdr->rcBound.left = 0;
+ pRgnHdr->rcBound.bottom = height;
+ pRgnHdr->rcBound.right = width;
+
+ pRgnHdr->nCount = BitmapToYXBandedRectangles(32, width, height, buf,
+ (RECT_T *) (((BYTE *) pRgnData) + sizeof(RGNDATAHEADER)));
+
+ HRGN rgn = ::ExtCreateRegion(NULL,
+ sizeof(RGNDATAHEADER) + sizeof(RECT_T) * pRgnHdr->nCount,
+ pRgnData);
+
+ free(pRgnData);
+ ::DeleteDC(hdc);
+ free(buf);
+
+ return rgn;
+}
+
+/**
+ * Makes a copy of the given bitmap. Blends every pixel of the source
+ * with the given blendColor and alpha. If alpha == 0, the function
+ * simply makes a plain copy of the source without any blending.
+ */
+HBITMAP BitmapUtil::BlendCopy(HBITMAP hSrcBitmap, COLORREF blendColor,
+ BYTE alpha)
+{
+ HDC hdc = ::CreateCompatibleDC(NULL);
+ HBITMAP oldBitmap = (HBITMAP)::SelectObject(hdc, hSrcBitmap);
+
+ BITMAPINFOEX bi;
+ ::ZeroMemory(&bi, sizeof(bi));
+
+ bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+
+ BOOL r = ::GetDIBits(hdc, hSrcBitmap, 0, 0, NULL,
+ reinterpret_cast(&bi), DIB_RGB_COLORS);
+
+ if (!r || bi.bmiHeader.biBitCount != 32)
+ {
+ ::DeleteDC(hdc);
+ return NULL;
+ }
+
+ UINT width = bi.bmiHeader.biWidth;
+ UINT height = abs(bi.bmiHeader.biHeight);
+
+ BYTE * buf = (BYTE*)safe_Malloc(bi.bmiHeader.biSizeImage);
+ bi.bmiHeader.biHeight = -height;
+ ::GetDIBits(hdc, hSrcBitmap, 0, height, buf,
+ reinterpret_cast(&bi), DIB_RGB_COLORS);
+
+ UINT widthBytes = width * bi.bmiHeader.biBitCount / 8;
+ UINT alignedWidth = (((widthBytes - 1) / 4) + 1) * 4;
+ UINT i, j;
+
+ for (j = 0; j < height; j++) {
+ BYTE *pSrc = (BYTE *) buf + j * alignedWidth;
+ for (i = 0; i < width; i++, pSrc += 4) {
+ // Note: if the current alpha is zero, the other three color
+ // components may (theoretically) contain some uninitialized
+ // data. The developer does not expect to display them,
+ // hence we handle this situation differently.
+ if (pSrc[3] == 0) {
+ pSrc[0] = GetBValue(blendColor) * alpha / 255;
+ pSrc[1] = GetGValue(blendColor) * alpha / 255;
+ pSrc[2] = GetRValue(blendColor) * alpha / 255;
+ pSrc[3] = alpha;
+ } else {
+ pSrc[0] = (GetBValue(blendColor) * alpha / 255) +
+ (pSrc[0] * (255 - alpha) / 255);
+ pSrc[1] = (GetGValue(blendColor) * alpha / 255) +
+ (pSrc[1] * (255 - alpha) / 255);
+ pSrc[2] = (GetRValue(blendColor) * alpha / 255) +
+ (pSrc[2] * (255 - alpha) / 255);
+ pSrc[3] = (alpha * alpha / 255) +
+ (pSrc[3] * (255 - alpha) / 255);
+ }
+ }
+ }
+
+ HBITMAP hDstBitmap = ::CreateDIBitmap(hdc,
+ reinterpret_cast(&bi),
+ CBM_INIT,
+ buf,
+ reinterpret_cast(&bi),
+ DIB_RGB_COLORS
+ );
+
+ ::SelectObject(hdc, oldBitmap);
+ ::DeleteDC(hdc);
+ free(buf);
+
+ return hDstBitmap;
+}
+
+/**
+ * Creates a 32 bit ARGB bitmap. Returns the bitmap handle. The *bitmapBits
+ * contains the pointer to the bitmap data or NULL if an error occured.
+ */
+HBITMAP BitmapUtil::CreateARGBBitmap(int width, int height, void ** bitmapBitsPtr)
+{
+ BITMAPINFOHEADER bmi;
+
+ ::ZeroMemory(&bmi, sizeof(bmi));
+ bmi.biSize = sizeof(BITMAPINFOHEADER);
+ bmi.biWidth = width;
+ bmi.biHeight = -height;
+ bmi.biPlanes = 1;
+ bmi.biBitCount = 32;
+ bmi.biCompression = BI_RGB;
+
+ return ::CreateDIBSection(NULL, (BITMAPINFO *) & bmi, DIB_RGB_COLORS,
+ bitmapBitsPtr, NULL, 0);
+}
diff --git a/jdk/src/windows/native/sun/windows/awt_BitmapUtil.h b/jdk/src/windows/native/sun/windows/awt_BitmapUtil.h
index b32f3fe0a41..2c039232fcb 100644
--- a/jdk/src/windows/native/sun/windows/awt_BitmapUtil.h
+++ b/jdk/src/windows/native/sun/windows/awt_BitmapUtil.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2006-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -45,6 +45,32 @@ public:
*/
static HBITMAP CreateV4BitmapFromARGB(int width, int height, int* imageData);
+ /**
+ * Creates 32-bit premultiplied ARGB V4 Bitmap (Win95-compatible) from
+ * specified ARGB Pre input data.
+ */
+ static HBITMAP CreateBitmapFromARGBPre(int width, int height,
+ int srcStride,
+ int* imageData);
+
+ /**
+ * Transforms the given bitmap into an HRGN representing the transparency
+ * of the bitmap.
+ */
+ static HRGN BitmapToRgn(HBITMAP hBitmap);
+
+ /**
+ * Makes a copy of the given bitmap. Blends every pixel of the source
+ * with the given blendColor and alpha. If alpha == 0, the function
+ * simply makes a plain copy of the source without any blending.
+ */
+ static HBITMAP BlendCopy(HBITMAP hSrcBitmap, COLORREF blendColor, BYTE alpha);
+
+ /**
+ * Creates a 32 bit ARGB bitmap. Returns the bitmap handle.
+ * The pointer to the bitmap data is stored into bitmapBitsPtr.
+ */
+ static HBITMAP CreateARGBBitmap(int width, int height, void ** bitmapBitsPtr);
};
#endif
diff --git a/jdk/src/windows/native/sun/windows/awt_Component.cpp b/jdk/src/windows/native/sun/windows/awt_Component.cpp
index 6f0df2e449f..a49ae839459 100644
--- a/jdk/src/windows/native/sun/windows/awt_Component.cpp
+++ b/jdk/src/windows/native/sun/windows/awt_Component.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -199,9 +199,6 @@ BOOL AwtComponent::sm_rtl = PRIMARYLANGID(GetInputLanguage()) == LANG_ARABIC ||
BOOL AwtComponent::sm_rtlReadingOrder =
PRIMARYLANGID(GetInputLanguage()) == LANG_ARABIC;
-UINT AwtComponent::sm_95WheelMessage = WM_NULL;
-UINT AwtComponent::sm_95WheelSupport = WM_NULL;
-
HWND AwtComponent::sm_cursorOn;
BOOL AwtComponent::m_QueryNewPaletteCalled = FALSE;
@@ -4562,6 +4559,25 @@ HDC AwtComponent::GetDCFromComponent()
return hdc;
}
+void AwtComponent::FillBackground(HDC hMemoryDC, SIZE &size)
+{
+ RECT eraseR = { 0, 0, size.cx, size.cy };
+ VERIFY(::FillRect(hMemoryDC, &eraseR, GetBackgroundBrush()));
+}
+
+void AwtComponent::FillAlpha(void *bitmapBits, SIZE &size, BYTE alpha)
+{
+ if (bitmapBits) {
+ DWORD* dest = (DWORD*)bitmapBits;
+ //XXX: might be optimized to use one loop (cy*cx -> 0).
+ for (int i = 0; i < size.cy; i++ ) {
+ for (int j = 0; j < size.cx; j++ ) {
+ ((BYTE*)(dest++))[3] = alpha;
+ }
+ }
+ }
+}
+
jintArray AwtComponent::CreatePrintedPixels(SIZE &loc, SIZE &size) {
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
@@ -6107,15 +6123,12 @@ void AwtComponent::_SetRectangularShape(void *param)
AwtComponent *c = NULL;
-
-
PDATA pData;
JNI_CHECK_PEER_GOTO(self, ret);
- c = (AwtComponent *)pData;
- if (::IsWindow(c->GetHWnd()))
- {
- HRGN hRgn = NULL;
+ c = (AwtComponent *)pData;
+ if (::IsWindow(c->GetHWnd())) {
+ HRGN hRgn = NULL;
if (region || x1 || x2 || y1 || y2) {
// If all the params are zeros, the shape must be simply reset.
// Otherwise, convert it into a region.
diff --git a/jdk/src/windows/native/sun/windows/awt_Component.h b/jdk/src/windows/native/sun/windows/awt_Component.h
index 0c18961ed49..2c9c0318cad 100644
--- a/jdk/src/windows/native/sun/windows/awt_Component.h
+++ b/jdk/src/windows/native/sun/windows/awt_Component.h
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -434,9 +434,6 @@ public:
/* Functions for MouseWheel support on Windows95
* These should only be called if running on 95
*/
- static void Wheel95Init();
- INLINE static UINT Wheel95GetMsg() {return sm_95WheelMessage;}
- static UINT Wheel95GetScrLines();
/* Determines whether the component is obscured by another window */
// Called on Toolkit thread
@@ -715,9 +712,9 @@ protected:
virtual void SetDragCapture(UINT flags);
virtual void ReleaseDragCapture(UINT flags);
- // 95 support for mouse wheel
- static UINT sm_95WheelMessage;
- static UINT sm_95WheelSupport;
+ //These functions are overridden in AwtWindow to handle non-opaque windows.
+ virtual void FillBackground(HDC hMemoryDC, SIZE &size);
+ virtual void FillAlpha(void *bitmapBits, SIZE &size, BYTE alpha);
private:
/* A bitmask keeps the button's numbers as MK_LBUTTON, MK_MBUTTON, MK_RBUTTON
diff --git a/jdk/src/windows/native/sun/windows/awt_Window.cpp b/jdk/src/windows/native/sun/windows/awt_Window.cpp
index 0c9bce1210d..8d635b5d00d 100644
--- a/jdk/src/windows/native/sun/windows/awt_Window.cpp
+++ b/jdk/src/windows/native/sun/windows/awt_Window.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
#include "awt.h"
+#include
+
#include "awt_Component.h"
#include "awt_Container.h"
#include "awt_Frame.h"
@@ -88,7 +90,6 @@ struct ReshapeFrameStruct {
jint x, y;
jint w, h;
};
-
// struct for _SetIconImagesData
struct SetIconImagesDataStruct {
jobject window;
@@ -97,7 +98,6 @@ struct SetIconImagesDataStruct {
jintArray smallIconRaster;
jint smw, smh;
};
-
// struct for _SetMinSize() method
// and other methods setting sizes
struct SizeStruct {
@@ -114,6 +114,24 @@ struct ModalDisableStruct {
jobject window;
jlong blockerHWnd;
};
+// struct for _SetOpacity() method
+struct OpacityStruct {
+ jobject window;
+ jint iOpacity;
+};
+// struct for _SetOpaque() method
+struct OpaqueStruct {
+ jobject window;
+ jboolean isOpaque;
+};
+// struct for _UpdateWindow() method
+struct UpdateWindowStruct {
+ jobject window;
+ jintArray data;
+ HBITMAP hBitmap;
+ jint width, height;
+};
+
/************************************************************************
* AwtWindow fields
*/
@@ -162,6 +180,11 @@ AwtWindow::AwtWindow() {
::SetWindowsHookEx(WH_CBT, (HOOKPROC)AwtWindow::CBTFilter,
0, AwtToolkit::MainThread());
}
+
+ m_opaque = TRUE;
+ m_opacity = 0xff;
+
+ ::InitializeCriticalSection(&contentBitmapCS);
}
AwtWindow::~AwtWindow()
@@ -1839,6 +1862,216 @@ void AwtWindow::DoUpdateIcon()
//Does nothing for windows, is overriden for frames and dialogs
}
+void AwtWindow::RedrawWindow()
+{
+ if (isOpaque()) {
+ ::RedrawWindow(GetHWnd(), NULL, NULL,
+ RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
+ } else {
+ ::EnterCriticalSection(&contentBitmapCS);
+ if (hContentBitmap != NULL) {
+ UpdateWindowImpl(contentWidth, contentHeight, hContentBitmap);
+ }
+ ::LeaveCriticalSection(&contentBitmapCS);
+ }
+}
+
+void AwtWindow::SetTranslucency(BYTE opacity, BOOL opaque)
+{
+ BYTE old_opacity = getOpacity();
+ BOOL old_opaque = isOpaque();
+
+ if (opacity == old_opacity && opaque == old_opaque) {
+ return;
+ }
+
+ setOpacity(opacity);
+ setOpaque(opaque);
+
+ HWND hwnd = GetHWnd();
+
+ LONG ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE);
+
+ if (opaque != old_opaque) {
+ ::EnterCriticalSection(&contentBitmapCS);
+ if (hContentBitmap != NULL) {
+ ::DeleteObject(hContentBitmap);
+ hContentBitmap = NULL;
+ }
+ ::LeaveCriticalSection(&contentBitmapCS);
+ }
+
+ if (opaque && opacity == 0xff) {
+ // Turn off all the effects
+ ::SetWindowLong(hwnd, GWL_EXSTYLE, ex_style & ~WS_EX_LAYERED);
+ // Ask the window to repaint itself and all the children
+ RedrawWindow();
+ } else {
+ // We're going to enable some effects
+ if (!(ex_style & WS_EX_LAYERED)) {
+ ::SetWindowLong(hwnd, GWL_EXSTYLE, ex_style | WS_EX_LAYERED);
+ } else {
+ if ((opaque && opacity < 0xff) ^ (old_opaque && old_opacity < 0xff)) {
+ // _One_ of the modes uses the SetLayeredWindowAttributes.
+ // Need to reset the style in this case.
+ // If both modes are simple (i.e. just changing the opacity level),
+ // no need to reset the style.
+ ::SetWindowLong(hwnd, GWL_EXSTYLE, ex_style & ~WS_EX_LAYERED);
+ ::SetWindowLong(hwnd, GWL_EXSTYLE, ex_style | WS_EX_LAYERED);
+ }
+ }
+
+ if (opaque) {
+ // Simple opacity mode
+ ::SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), opacity, LWA_ALPHA);
+ }
+ }
+}
+
+static HBITMAP CreateBitmapFromRaster(JNIEnv* env, jintArray raster, jint w, jint h)
+{
+ HBITMAP image = NULL;
+ if (raster != NULL) {
+ int* rasterBuffer = NULL;
+ try {
+ rasterBuffer = (int *)env->GetPrimitiveArrayCritical(raster, 0);
+ JNI_CHECK_NULL_GOTO(rasterBuffer, "raster data", done);
+ image = BitmapUtil::CreateBitmapFromARGBPre(w, h, w*4, rasterBuffer);
+ } catch (...) {
+ if (rasterBuffer != NULL) {
+ env->ReleasePrimitiveArrayCritical(raster, rasterBuffer, 0);
+ }
+ throw;
+ }
+ if (rasterBuffer != NULL) {
+ env->ReleasePrimitiveArrayCritical(raster, rasterBuffer, 0);
+ }
+ }
+done:
+ return image;
+}
+
+void AwtWindow::UpdateWindowImpl(int width, int height, HBITMAP hBitmap)
+{
+ if (isOpaque()) {
+ return;
+ }
+
+ HWND hWnd = GetHWnd();
+ HDC hdcDst = ::GetDC(NULL);
+ HDC hdcSrc = ::CreateCompatibleDC(NULL);
+ HBITMAP hOldBitmap = (HBITMAP)::SelectObject(hdcSrc, hBitmap);
+
+ //XXX: this code doesn't paint the children (say, the java.awt.Button)!
+ //So, if we ever want to support HWs here, we need to repaint them
+ //in some other way...
+ //::SendMessage(hWnd, WM_PRINT, (WPARAM)hdcSrc, /*PRF_CHECKVISIBLE |*/
+ // PRF_CHILDREN /*| PRF_CLIENT | PRF_NONCLIENT*/);
+
+ POINT ptSrc;
+ ptSrc.x = ptSrc.y = 0;
+
+ RECT rect;
+ POINT ptDst;
+ SIZE size;
+
+ ::GetWindowRect(hWnd, &rect);
+ ptDst.x = rect.left;
+ ptDst.y = rect.top;
+ size.cx = width;
+ size.cy = height;
+
+ BLENDFUNCTION bf;
+
+ bf.SourceConstantAlpha = getOpacity();
+ bf.AlphaFormat = AC_SRC_ALPHA;
+ bf.BlendOp = AC_SRC_OVER;
+ bf.BlendFlags = 0;
+
+ ::UpdateLayeredWindow(hWnd, hdcDst, &ptDst, &size, hdcSrc, &ptSrc,
+ RGB(0, 0, 0), &bf, ULW_ALPHA);
+
+ ::ReleaseDC(NULL, hdcDst);
+ ::SelectObject(hdcSrc, hOldBitmap);
+ ::DeleteDC(hdcSrc);
+}
+
+void AwtWindow::UpdateWindow(JNIEnv* env, jintArray data, int width, int height,
+ HBITMAP hNewBitmap)
+{
+ if (isOpaque()) {
+ return;
+ }
+
+ HBITMAP hBitmap;
+ if (hNewBitmap == NULL) {
+ if (data == NULL) {
+ return;
+ }
+ hBitmap = CreateBitmapFromRaster(env, data, width, height);
+ if (hBitmap == NULL) {
+ return;
+ }
+ } else {
+ hBitmap = hNewBitmap;
+ }
+
+ ::EnterCriticalSection(&contentBitmapCS);
+ if (hContentBitmap != NULL) {
+ ::DeleteObject(hContentBitmap);
+ }
+ hContentBitmap = hBitmap;
+ contentWidth = width;
+ contentHeight = height;
+ UpdateWindowImpl(width, height, hBitmap);
+ ::LeaveCriticalSection(&contentBitmapCS);
+}
+
+void AwtWindow::FillBackground(HDC hMemoryDC, SIZE &size)
+{
+ if (isOpaque()) {
+ AwtCanvas::FillBackground(hMemoryDC, size);
+ }
+}
+
+void AwtWindow::FillAlpha(void *bitmapBits, SIZE &size, BYTE alpha)
+{
+ if (isOpaque()) {
+ AwtCanvas::FillAlpha(bitmapBits, size, alpha);
+ }
+}
+
+/*
+ * Fixed 6353381: it's improved fix for 4792958
+ * which was backed-out to avoid 5059656
+ */
+BOOL AwtWindow::HasValidRect()
+{
+ RECT inside;
+ RECT outside;
+
+ if (::IsIconic(GetHWnd())) {
+ return FALSE;
+ }
+
+ ::GetClientRect(GetHWnd(), &inside);
+ ::GetWindowRect(GetHWnd(), &outside);
+
+ BOOL isZeroClientArea = (inside.right == 0 && inside.bottom == 0);
+ BOOL isInvalidLocation = ((outside.left == -32000 && outside.top == -32000) || // Win2k && WinXP
+ (outside.left == 32000 && outside.top == 32000) || // Win95 && Win98
+ (outside.left == 3000 && outside.top == 3000)); // Win95 && Win98
+
+ // the bounds correspond to iconic state
+ if (isZeroClientArea && isInvalidLocation)
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
void AwtWindow::_SetIconImagesData(void * param)
{
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
@@ -2009,36 +2242,68 @@ void AwtWindow::_ModalEnable(void *param)
env->DeleteGlobalRef(self);
}
-/*
- * Fixed 6353381: it's improved fix for 4792958
- * which was backed-out to avoid 5059656
- */
-BOOL AwtWindow::HasValidRect()
+void AwtWindow::_SetOpacity(void* param)
{
- RECT inside;
- RECT outside;
+ JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
- if (::IsIconic(GetHWnd())) {
- return FALSE;
- }
+ OpacityStruct *os = (OpacityStruct *)param;
+ jobject self = os->window;
+ BYTE iOpacity = (BYTE)os->iOpacity;
- ::GetClientRect(GetHWnd(), &inside);
- ::GetWindowRect(GetHWnd(), &outside);
+ PDATA pData;
+ JNI_CHECK_PEER_GOTO(self, ret);
+ AwtWindow *window = (AwtWindow *)pData;
- BOOL isZeroClientArea = (inside.right == 0 && inside.bottom == 0);
- BOOL isInvalidLocation = ((outside.left == -32000 && outside.top == -32000) || // Win2k && WinXP
- (outside.left == 32000 && outside.top == 32000) || // Win95 && Win98
- (outside.left == 3000 && outside.top == 3000)); // Win95 && Win98
+ window->SetTranslucency(iOpacity, window->isOpaque());
- // the bounds correspond to iconic state
- if (isZeroClientArea && isInvalidLocation)
- {
- return FALSE;
- }
-
- return TRUE;
+ ret:
+ env->DeleteGlobalRef(self);
+ delete os;
}
+void AwtWindow::_SetOpaque(void* param)
+{
+ JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
+
+ OpaqueStruct *os = (OpaqueStruct *)param;
+ jobject self = os->window;
+ BOOL isOpaque = (BOOL)os->isOpaque;
+
+ PDATA pData;
+ JNI_CHECK_PEER_GOTO(self, ret);
+ AwtWindow *window = (AwtWindow *)pData;
+
+ window->SetTranslucency(window->getOpacity(), isOpaque);
+
+ ret:
+ env->DeleteGlobalRef(self);
+ delete os;
+}
+
+void AwtWindow::_UpdateWindow(void* param)
+{
+ JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
+
+ UpdateWindowStruct *uws = (UpdateWindowStruct *)param;
+ jobject self = uws->window;
+ jintArray data = uws->data;
+
+ PDATA pData;
+ JNI_CHECK_PEER_GOTO(self, ret);
+ AwtWindow *window = (AwtWindow *)pData;
+
+ window->UpdateWindow(env, data, (int)uws->width, (int)uws->height,
+ uws->hBitmap);
+
+ ret:
+ env->DeleteGlobalRef(self);
+ if (data != NULL) {
+ env->DeleteGlobalRef(data);
+ }
+ delete uws;
+}
+
+
extern "C" {
/*
@@ -2489,4 +2754,93 @@ Java_sun_awt_windows_WWindowPeer_nativeUngrab(JNIEnv *env, jobject self)
CATCH_BAD_ALLOC;
}
+/*
+ * Class: sun_awt_windows_WWindowPeer
+ * Method: setOpacity
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL
+Java_sun_awt_windows_WWindowPeer_setOpacity(JNIEnv *env, jobject self,
+ jint iOpacity)
+{
+ TRY;
+
+ OpacityStruct *os = new OpacityStruct;
+ os->window = env->NewGlobalRef(self);
+ os->iOpacity = iOpacity;
+
+ AwtToolkit::GetInstance().SyncCall(AwtWindow::_SetOpacity, os);
+ // global refs and mds are deleted in _SetMinSize
+
+ CATCH_BAD_ALLOC;
+}
+
+/*
+ * Class: sun_awt_windows_WWindowPeer
+ * Method: setOpaqueImpl
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL
+Java_sun_awt_windows_WWindowPeer_setOpaqueImpl(JNIEnv *env, jobject self,
+ jboolean isOpaque)
+{
+ TRY;
+
+ OpaqueStruct *os = new OpaqueStruct;
+ os->window = env->NewGlobalRef(self);
+ os->isOpaque = isOpaque;
+
+ AwtToolkit::GetInstance().SyncCall(AwtWindow::_SetOpaque, os);
+ // global refs and mds are deleted in _SetMinSize
+
+ CATCH_BAD_ALLOC;
+}
+
+/*
+ * Class: sun_awt_windows_WWindowPeer
+ * Method: updateWindowImpl
+ * Signature: ([III)V
+ */
+JNIEXPORT void JNICALL
+Java_sun_awt_windows_WWindowPeer_updateWindowImpl(JNIEnv *env, jobject self,
+ jintArray data,
+ jint width, jint height)
+{
+ TRY;
+
+ UpdateWindowStruct *uws = new UpdateWindowStruct;
+ uws->window = env->NewGlobalRef(self);
+ uws->data = (jintArray)env->NewGlobalRef(data);
+ uws->hBitmap = NULL;
+ uws->width = width;
+ uws->height = height;
+
+ AwtToolkit::GetInstance().InvokeFunction(AwtWindow::_UpdateWindow, uws);
+ // global refs and mds are deleted in _UpdateWindow
+
+ CATCH_BAD_ALLOC;
+}
+
+/**
+ * This method is called from the WGL pipeline when it needs to update
+ * the layered window WindowPeer's C++ level object.
+ */
+void AwtWindow_UpdateWindow(JNIEnv *env, jobject peer,
+ jint width, jint height, HBITMAP hBitmap)
+{
+ TRY;
+
+ UpdateWindowStruct *uws = new UpdateWindowStruct;
+ uws->window = env->NewGlobalRef(peer);
+ uws->data = NULL;
+ uws->hBitmap = hBitmap;
+ uws->width = width;
+ uws->height = height;
+
+ AwtToolkit::GetInstance().InvokeFunction(AwtWindow::_UpdateWindow, uws);
+ // global refs and mds are deleted in _UpdateWindow
+
+ CATCH_BAD_ALLOC;
+}
+
} /* extern "C" */
diff --git a/jdk/src/windows/native/sun/windows/awt_Window.h b/jdk/src/windows/native/sun/windows/awt_Window.h
index 9a252a25ce1..a3d57db7b2d 100644
--- a/jdk/src/windows/native/sun/windows/awt_Window.h
+++ b/jdk/src/windows/native/sun/windows/awt_Window.h
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -182,6 +182,9 @@ public:
void moveToDefaultLocation(); /* moves Window to X,Y specified by Window Manger */
+ void UpdateWindow(JNIEnv* env, jintArray data, int width, int height,
+ HBITMAP hNewBitmap = NULL);
+
INLINE virtual BOOL IsTopLevel() { return TRUE; }
static AwtWindow * GetGrabbedWindow() { return m_grabbedWindow; }
@@ -204,6 +207,9 @@ public:
static void _SetModalExcludedNativeProp(void *param);
static void _ModalDisable(void *param);
static void _ModalEnable(void *param);
+ static void _SetOpacity(void* param);
+ static void _SetOpaque(void* param);
+ static void _UpdateWindow(void* param);
inline static BOOL IsResizing() {
return sm_resizing;
@@ -228,6 +234,32 @@ private:
// from its hierarchy when shown. Currently applied to instances of
// javax/swing/Popup$HeavyWeightWindow class.
+ BYTE m_opacity; // The opacity level. == 0xff by default (when opacity mode is disabled)
+ BOOL m_opaque; // Whether the window uses the perpixel translucency (false), or not (true).
+
+ inline BYTE getOpacity() {
+ return m_opacity;
+ }
+ inline void setOpacity(BYTE opacity) {
+ m_opacity = opacity;
+ }
+
+ inline BOOL isOpaque() {
+ return m_opaque;
+ }
+ inline void setOpaque(BOOL opaque) {
+ m_opaque = opaque;
+ }
+
+ CRITICAL_SECTION contentBitmapCS;
+ HBITMAP hContentBitmap;
+ UINT contentWidth;
+ UINT contentHeight;
+
+ void RedrawWindow();
+ void SetTranslucency(BYTE opacity, BOOL opaque);
+ void UpdateWindowImpl(int width, int height, HBITMAP hBitmap);
+
protected:
BOOL m_isResizable;
static AwtWindow* m_grabbedWindow; // Current grabbing window
@@ -236,6 +268,10 @@ protected:
BOOL m_iconInherited; /* TRUE if icon is inherited from the owner */
BOOL m_filterFocusAndActivation; /* Used in the WH_CBT hook */
+ //These are used in AwtComponent::CreatePrintedPixels. They are overridden
+ //here to handle non-opaque windows.
+ virtual void FillBackground(HDC hMemoryDC, SIZE &size);
+ virtual void FillAlpha(void *bitmapBits, SIZE &size, BYTE alpha);
private:
int m_screenNum;
diff --git a/jdk/test/com/sun/awt/Translucency/TranslucentJAppletTest/TranslucentJAppletTest.java b/jdk/test/com/sun/awt/Translucency/TranslucentJAppletTest/TranslucentJAppletTest.java
new file mode 100644
index 00000000000..08cbe4069a3
--- /dev/null
+++ b/jdk/test/com/sun/awt/Translucency/TranslucentJAppletTest/TranslucentJAppletTest.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test %I% %E%
+ * @bug 6683728
+ * @summary Tests that a JApplet in a translucent JFrame works properly
+ * @author Kenneth.Russell@sun.com: area=Graphics
+ * @compile -XDignore.symbol.file=true TranslucentJAppletTest.java
+ * @run main/manual/othervm TranslucentJAppletTest
+ */
+
+import java.awt.*;
+import java.awt.image.*;
+
+import javax.swing.*;
+
+public class TranslucentJAppletTest {
+
+ private static JFrame frame;
+ private static volatile boolean paintComponentCalled = false;
+
+ private static void initAndShowGUI() {
+ frame = new JFrame();
+ JApplet applet = new JApplet();
+ JPanel panel = new JPanel() {
+ protected void paintComponent(Graphics g) {
+ paintComponentCalled = true;
+ g.setColor(Color.RED);
+ g.fillOval(0, 0, getWidth(), getHeight());
+ }
+ };
+ panel.setDoubleBuffered(false);
+ panel.setOpaque(false);
+ applet.add(panel);
+ frame.add(applet);
+ frame.setBounds(100, 100, 200, 200);
+ frame.setUndecorated(true);
+ com.sun.awt.AWTUtilities.setWindowOpaque(frame, false);
+ frame.setVisible(true);
+ }
+
+ public static void main(String[] args)
+ throws Exception
+ {
+ sun.awt.SunToolkit tk = (sun.awt.SunToolkit)Toolkit.getDefaultToolkit();
+
+ Robot r = new Robot();
+ Color color1 = r.getPixelColor(100, 100); // (0, 0) in frame coordinates
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ initAndShowGUI();
+ }
+ });
+ tk.realSync();
+
+ if (!paintComponentCalled) {
+ throw new RuntimeException("Test FAILED: panel's paintComponent() method is not called");
+ }
+
+ Color newColor1 = r.getPixelColor(100, 100);
+ // unfortunately, robot.getPixelColor() doesn't work for some unknown reason
+ // Color newColor2 = r.getPixelColor(200, 200);
+ BufferedImage bim = r.createScreenCapture(new Rectangle(200, 200, 1, 1));
+ Color newColor2 = new Color(bim.getRGB(0, 0));
+
+ // Frame must be transparent at (100, 100) in screen coords
+ if (!color1.equals(newColor1)) {
+ System.err.println("color1 = " + color1);
+ System.err.println("newColor1 = " + newColor1);
+ throw new RuntimeException("Test FAILED: frame pixel at (0, 0) is not transparent");
+ }
+
+ // Frame must be RED at (200, 200) in screen coords
+ if (!newColor2.equals(Color.RED)) {
+ System.err.println("newColor2 = " + newColor2);
+ throw new RuntimeException("Test FAILED: frame pixel at (100, 100) is not red (transparent?)");
+ }
+
+ System.out.println("Test PASSED");
+ }
+}
diff --git a/jdk/test/com/sun/awt/Translucency/TranslucentShapedFrameTest/TSFrame.java b/jdk/test/com/sun/awt/Translucency/TranslucentShapedFrameTest/TSFrame.java
new file mode 100644
index 00000000000..1e9cf74658e
--- /dev/null
+++ b/jdk/test/com/sun/awt/Translucency/TranslucentShapedFrameTest/TSFrame.java
@@ -0,0 +1,306 @@
+/*
+ * Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+import com.sun.awt.AWTUtilities;
+import static com.sun.awt.AWTUtilities.Translucency.*;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsEnvironment;
+import java.awt.RenderingHints;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.Canvas;
+import java.awt.Component;
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.Paint;
+import java.util.Random;
+import java.awt.geom.Ellipse2D;
+import javax.swing.JApplet;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
+
+public class TSFrame {
+
+ static volatile boolean done = false;
+
+ static final boolean useSwing = System.getProperty("useswing") != null;
+ static final boolean useShape = System.getProperty("useshape") != null;
+ static final boolean useTransl = System.getProperty("usetransl") != null;
+ static final boolean useNonOpaque = System.getProperty("usenonop") != null;
+
+ static final Random rnd = new Random();
+ private static void render(Graphics g, int w, int h, boolean useNonOpaque) {
+ if (useNonOpaque) {
+ Graphics2D g2d = (Graphics2D)g;
+ GradientPaint p =
+ new GradientPaint(0.0f, 0.0f,
+ new Color(rnd.nextInt(0xffffff)),
+ w, h,
+ new Color(rnd.nextInt(0xff),
+ rnd.nextInt(0xff),
+ rnd.nextInt(0xff), 0),
+ true);
+ g2d.setPaint(p);
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
+ g2d.fillOval(0, 0, w, h);
+ } else {
+ g.setColor(new Color(rnd.nextInt(0xffffff)));
+ g.fillRect(0, 0, w, h);
+ }
+ }
+
+ private static class MyCanvas extends Canvas {
+ @Override
+ public void paint(Graphics g) {
+ render(g, getWidth(), getHeight(), false);
+ }
+ @Override
+ public Dimension getPreferredSize() {
+ return new Dimension(200, 100);
+ }
+ }
+ private static class NonOpaqueJFrame extends JFrame {
+ NonOpaqueJFrame(GraphicsConfiguration gc) {
+ super("NonOpaque Swing JFrame", gc);
+ JPanel p = new JPanel() {
+ public void paintComponent(Graphics g) {
+ super.paintComponent(g);
+ render(g, getWidth(), getHeight(), true);
+ g.setColor(Color.red);
+ g.drawString("Non-Opaque Swing JFrame", 10, 15);
+ }
+ };
+ p.setDoubleBuffered(false);
+ p.setOpaque(false);
+ add(p);
+ setUndecorated(true);
+ }
+ }
+ private static class NonOpaqueJAppletFrame extends JFrame {
+ JPanel p;
+ NonOpaqueJAppletFrame(GraphicsConfiguration gc) {
+ super("NonOpaque Swing JAppletFrame", gc);
+ JApplet ja = new JApplet() {
+ public void paint(Graphics g) {
+ super.paint(g);
+ System.err.println("JAppletFrame paint called");
+ }
+ };
+ p = new JPanel() {
+ public void paintComponent(Graphics g) {
+ super.paintComponent(g);
+ render(g, getWidth(), getHeight(), true);
+ g.setColor(Color.red);
+ g.drawString("Non-Opaque Swing JFrame", 10, 15);
+ }
+ };
+ p.setDoubleBuffered(false);
+ p.setOpaque(false);
+ ja.add(p);
+ add(ja);
+ setUndecorated(true);
+ }
+ }
+ private static class NonOpaqueFrame extends Frame {
+ NonOpaqueFrame(GraphicsConfiguration gc) {
+ super("NonOpaque AWT Frame", gc);
+ // uncomment to test with hw child
+// setLayout(null);
+// Component c = new Panel() {
+// public void paint(Graphics g) {
+// g.setColor(new Color(1.0f, 1.0f, 1.0f, 0.5f));
+// g.fillRect(0, 0, getWidth(), getHeight());
+// }
+// };
+// c.setSize(100, 100);
+// c.setBackground(Color.red);
+// c.setForeground(Color.red);
+// add(c);
+// c.setLocation(130, 130);
+ }
+ @Override
+ public void paint(Graphics g) {
+ render(g, getWidth(), getHeight(), true);
+ g.setColor(Color.red);
+ g.drawString("Non-Opaque AWT Frame", 10, 15);
+ }
+ }
+
+ private static class MyJPanel extends JPanel {
+ @Override
+ public void paintComponent(Graphics g) {
+ render(g, getWidth(), getHeight(), false);
+ }
+ }
+
+ public static Frame createGui(GraphicsConfiguration gc,
+ final boolean useSwing,
+ final boolean useShape,
+ final boolean useTransl,
+ final boolean useNonOpaque,
+ final float factor)
+ {
+ Frame frame;
+ done = false;
+
+ if (gc == null) {
+ gc = GraphicsEnvironment.getLocalGraphicsEnvironment().
+ getDefaultScreenDevice().getDefaultConfiguration();
+ }
+
+ if (useNonOpaque) {
+ if (useSwing) {
+ frame = new NonOpaqueJFrame(gc);
+// frame = new NonOpaqueJAppletFrame(gc);
+ } else {
+ frame = new NonOpaqueFrame(gc);
+ }
+ animateComponent(frame);
+ } else if (useSwing) {
+ frame = new JFrame("Swing Frame", gc);
+ JComponent p = new JButton("Swing!");
+ p.setPreferredSize(new Dimension(200, 100));
+ frame.add("North", p);
+ p = new MyJPanel();
+ animateComponent(p);
+ frame.add("Center", p);
+ } else {
+ frame = new Frame("AWT Frame", gc) {
+ public void paint(Graphics g) {
+ g.setColor(Color.red);
+ g.fillRect(0, 0, 100, 100);
+ }
+ };
+ frame.setLayout(new BorderLayout());
+ Canvas c = new MyCanvas();
+ frame.add("North", c);
+ animateComponent(c);
+ c = new MyCanvas();
+ frame.add("Center", c);
+ animateComponent(c);
+ c = new MyCanvas();
+ frame.add("South", c);
+ animateComponent(c);
+ }
+ final Frame finalFrame = frame;
+ frame.addWindowListener(new WindowAdapter() {
+ @Override
+ public void windowClosing(WindowEvent e) {
+ finalFrame.dispose();
+ done = true;
+ }
+ });
+ frame.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ finalFrame.dispose();
+ done = true;
+ }
+ });
+ frame.setPreferredSize(new Dimension(800, 600));
+
+ if (useShape) {
+ frame.setUndecorated(true);
+ }
+
+ frame.setLocation(450, 10);
+ frame.pack();
+
+ if (useShape) {
+ if (AWTUtilities.isTranslucencySupported(PERPIXEL_TRANSPARENT)) {
+ System.out.println("applying PERPIXEL_TRANSPARENT");
+ AWTUtilities.setWindowShape(frame,
+ new Ellipse2D.Double(0, 0, frame.getWidth(),
+ frame.getHeight()/3));
+ frame.setTitle("PERPIXEL_TRANSPARENT");
+ } else {
+ System.out.println("Passed: PERPIXEL_TRANSPARENT unsupported");
+ }
+ }
+ if (useTransl) {
+ if (AWTUtilities.isTranslucencySupported(TRANSLUCENT)) {
+ System.out.println("applying TRANSLUCENT");
+ AWTUtilities.setWindowOpacity(frame, factor);
+ frame.setTitle("TRANSLUCENT");
+ } else {
+ System.out.println("Passed: TRANSLUCENT unsupported");
+ }
+ }
+ if (useNonOpaque) {
+ if (AWTUtilities.isTranslucencySupported(PERPIXEL_TRANSLUCENT) &&
+ AWTUtilities.isTranslucencyCapable(gc))
+ {
+ System.out.println("applying PERPIXEL_TRANSLUCENT");
+ AWTUtilities.setWindowOpaque(frame, false);
+ frame.setTitle("PERPIXEL_TRANSLUCENT");
+ } else {
+ System.out.println("Passed: PERPIXEL_TRANSLUCENT unsupported");
+ }
+ }
+ frame.setVisible(true);
+ return frame;
+ }
+
+ public static void stopThreads() {
+ done = true;
+ }
+
+ private static void animateComponent(final Component comp) {
+ Thread t = new Thread(new Runnable() {
+ public void run() {
+ do {
+ try {
+ Thread.sleep(50);
+ } catch (InterruptedException ex) {}
+ comp.repaint();
+ } while (!done);
+ }
+ });
+ t.start();
+ }
+
+ public static void main(String[] args) throws Exception {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ TSFrame.createGui(null, useSwing,
+ useShape,
+ useTransl,
+ useNonOpaque,
+ 0.7f);
+ }
+ });
+ }
+}
diff --git a/jdk/test/com/sun/awt/Translucency/TranslucentShapedFrameTest/TranslucentShapedFrameTest.form b/jdk/test/com/sun/awt/Translucency/TranslucentShapedFrameTest/TranslucentShapedFrameTest.form
new file mode 100644
index 00000000000..4291e0eeaac
--- /dev/null
+++ b/jdk/test/com/sun/awt/Translucency/TranslucentShapedFrameTest/TranslucentShapedFrameTest.form
@@ -0,0 +1,230 @@
+
+
+
diff --git a/jdk/test/com/sun/awt/Translucency/TranslucentShapedFrameTest/TranslucentShapedFrameTest.java b/jdk/test/com/sun/awt/Translucency/TranslucentShapedFrameTest/TranslucentShapedFrameTest.java
new file mode 100644
index 00000000000..edb58ff67b8
--- /dev/null
+++ b/jdk/test/com/sun/awt/Translucency/TranslucentShapedFrameTest/TranslucentShapedFrameTest.java
@@ -0,0 +1,359 @@
+/*
+ * Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test %I% %E%
+ * @bug 6655001 6670649 6687141
+ * @summary Tests that hw acceleration doesn't affect translucent/shaped windows
+ * @author Dmitri.Trembovetski@sun.com: area=Graphics
+ * @compile -XDignore.symbol.file=true TranslucentShapedFrameTest.java
+ * @compile -XDignore.symbol.file=true TSFrame.java
+ * @run main/manual/othervm TranslucentShapedFrameTest
+ * @run main/manual/othervm -Dsun.java2d.noddraw=true TranslucentShapedFrameTest
+ * @run main/manual/othervm -Dsun.java2d.opengl=True TranslucentShapedFrameTest
+ */
+import com.sun.awt.AWTUtilities;
+import static com.sun.awt.AWTUtilities.Translucency.*;
+import java.awt.Frame;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.awt.Shape;
+import java.awt.geom.Ellipse2D;
+import java.util.concurrent.CountDownLatch;
+import javax.swing.JSlider;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+
+public class TranslucentShapedFrameTest extends javax.swing.JFrame {
+ Frame testFrame;
+ static CountDownLatch done;
+ static volatile boolean failed = false;
+ GraphicsConfiguration gcToUse = null;
+
+ /**
+ * Creates new form TranslucentShapedFrameTest
+ */
+ public TranslucentShapedFrameTest() {
+ // not necessary, but we just look nicer
+ try {
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ } catch (Exception ex) {}
+
+ initComponents();
+ checkEffects();
+
+ SwingUtilities.updateComponentTreeUI(this);
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+ createDisposeGrp = new javax.swing.ButtonGroup();
+ jLabel1 = new javax.swing.JLabel();
+ transparencySld = new javax.swing.JSlider();
+ shapedCb = new javax.swing.JCheckBox();
+ nonOpaqueChb = new javax.swing.JCheckBox();
+ jScrollPane1 = new javax.swing.JScrollPane();
+ jTextArea1 = new javax.swing.JTextArea();
+ jLabel2 = new javax.swing.JLabel();
+ passedBtn = new javax.swing.JButton();
+ failedBtn = new javax.swing.JButton();
+ createFrameBtn = new javax.swing.JToggleButton();
+ disposeFrameBtn = new javax.swing.JToggleButton();
+ useSwingCb = new javax.swing.JCheckBox();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+ setTitle("TranslucentShapedFrameTest");
+ jLabel1.setText("Frame Opacity:");
+
+ transparencySld.setMajorTickSpacing(10);
+ transparencySld.setMinorTickSpacing(5);
+ transparencySld.setPaintLabels(true);
+ transparencySld.setPaintTicks(true);
+ transparencySld.setValue(100);
+ transparencySld.addChangeListener(new javax.swing.event.ChangeListener() {
+ public void stateChanged(javax.swing.event.ChangeEvent evt) {
+ transparencySldStateChanged(evt);
+ }
+ });
+
+ shapedCb.setText("Shaped Frame");
+ shapedCb.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
+ shapedCb.setMargin(new java.awt.Insets(0, 0, 0, 0));
+ shapedCb.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ shapedCbActionPerformed(evt);
+ }
+ });
+
+ nonOpaqueChb.setText("Non Opaque Frame");
+ nonOpaqueChb.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
+ nonOpaqueChb.setMargin(new java.awt.Insets(0, 0, 0, 0));
+ nonOpaqueChb.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ nonOpaqueChbActionPerformed(evt);
+ }
+ });
+
+ jTextArea1.setColumns(20);
+ jTextArea1.setRows(5);
+ jTextArea1.setText("Create translucent and/or shaped, or\nnon-opaque frame. Make sure it behaves\ncorrectly (no artifacts left on the screen\nwhen dragging - if dragging is possible).\nClick \"Passed\" if the test behaves correctly,\n\"Falied\" otherwise.");
+ jScrollPane1.setViewportView(jTextArea1);
+
+ jLabel2.setText("Instructions:");
+
+ passedBtn.setBackground(new java.awt.Color(129, 255, 100));
+ passedBtn.setText("Passed");
+ passedBtn.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ passedBtnActionPerformed(evt);
+ }
+ });
+
+ failedBtn.setBackground(java.awt.Color.red);
+ failedBtn.setText("Failed");
+ failedBtn.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ failedBtnActionPerformed(evt);
+ }
+ });
+
+ createDisposeGrp.add(createFrameBtn);
+ createFrameBtn.setText("Create Frame");
+ createFrameBtn.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ createFrameBtnActionPerformed(evt);
+ }
+ });
+
+ createDisposeGrp.add(disposeFrameBtn);
+ disposeFrameBtn.setSelected(true);
+ disposeFrameBtn.setText("Dispose Frame");
+ disposeFrameBtn.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ disposeFrameBtnActionPerformed(evt);
+ }
+ });
+
+ useSwingCb.setText("Use JFrame");
+ useSwingCb.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
+ useSwingCb.setMargin(new java.awt.Insets(0, 0, 0, 0));
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(transparencySld, javax.swing.GroupLayout.DEFAULT_SIZE, 375, Short.MAX_VALUE)
+ .addContainerGap())
+ .addComponent(jLabel1)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(shapedCb)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(nonOpaqueChb)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(useSwingCb)
+ .addContainerGap(102, Short.MAX_VALUE))
+ .addGroup(layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(jLabel2)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 314, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(passedBtn)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(failedBtn)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 241, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 375, Short.MAX_VALUE)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(createFrameBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(disposeFrameBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE)))
+ .addContainerGap())))
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(jLabel1)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(transparencySld, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(shapedCb)
+ .addComponent(nonOpaqueChb)
+ .addComponent(useSwingCb))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(disposeFrameBtn)
+ .addComponent(createFrameBtn))
+ .addGap(17, 17, 17)
+ .addComponent(jLabel2)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(passedBtn)
+ .addComponent(failedBtn))
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+ pack();
+ }// //GEN-END:initComponents
+
+ private void nonOpaqueChbActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nonOpaqueChbActionPerformed
+ if (testFrame != null) {
+ // REMIND: this path in the test doesn't work well (test bug)
+// AWTUtilities.setWindowOpaque(testFrame, !nonOpaqueChb.isSelected());
+ }
+ }//GEN-LAST:event_nonOpaqueChbActionPerformed
+
+ private void shapedCbActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_shapedCbActionPerformed
+ if (testFrame != null) {
+ Shape s = null;
+ if (shapedCb.isSelected()) {
+ s = new Ellipse2D.Double(0, 0,
+ testFrame.getWidth(),
+ testFrame.getHeight());
+ }
+ AWTUtilities.setWindowShape(testFrame, s);
+ }
+ }//GEN-LAST:event_shapedCbActionPerformed
+
+ private void transparencySldStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_transparencySldStateChanged
+ JSlider source = (JSlider)evt.getSource();
+ int transl = transparencySld.getValue();
+ if (testFrame != null) {
+ AWTUtilities.setWindowOpacity(testFrame, (float)transl/100f);
+ }
+ }//GEN-LAST:event_transparencySldStateChanged
+
+ private void failedBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_failedBtnActionPerformed
+ disposeFrameBtnActionPerformed(evt);
+ dispose();
+ failed = true;
+ done.countDown();
+ }//GEN-LAST:event_failedBtnActionPerformed
+
+ private void disposeFrameBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_disposeFrameBtnActionPerformed
+ TSFrame.stopThreads();
+ if (testFrame != null) {
+ testFrame.dispose();
+ testFrame = null;
+ }
+ }//GEN-LAST:event_disposeFrameBtnActionPerformed
+
+ private void createFrameBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createFrameBtnActionPerformed
+ disposeFrameBtnActionPerformed(evt);
+ int transl = transparencySld.getValue();
+ testFrame = TSFrame.createGui(gcToUse,
+ useSwingCb.isSelected(), shapedCb.isSelected(),
+ (transl < 100), nonOpaqueChb.isSelected(),
+ (float)transl/100f);
+ }//GEN-LAST:event_createFrameBtnActionPerformed
+
+ private void passedBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_passedBtnActionPerformed
+ disposeFrameBtnActionPerformed(evt);
+ dispose();
+ done.countDown();
+ }//GEN-LAST:event_passedBtnActionPerformed
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String args[]) {
+ done = new CountDownLatch(1);
+ java.awt.EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ new TranslucentShapedFrameTest().setVisible(true);
+ }
+ });
+ try {
+ done.await();
+ } catch (InterruptedException ex) {}
+ if (failed) {
+ throw new RuntimeException("Test FAILED");
+ }
+ System.out.println("Test PASSED");
+ }
+
+ private void checkEffects() {
+ if (!AWTUtilities.isTranslucencySupported(PERPIXEL_TRANSPARENT)) {
+ shapedCb.setEnabled(false);
+ }
+
+ if (!AWTUtilities.isTranslucencySupported(TRANSLUCENT)) {
+ transparencySld.setEnabled(false);
+ }
+
+ GraphicsConfiguration gc = null;
+ if (AWTUtilities.isTranslucencySupported(PERPIXEL_TRANSLUCENT)) {
+ gc = findGraphicsConfig();
+ if (gc == null) {
+ nonOpaqueChb.setEnabled(false);
+ }
+ }
+
+ gcToUse = gc;
+ }
+
+ private GraphicsConfiguration findGraphicsConfig() {
+ GraphicsDevice gd =
+ GraphicsEnvironment.getLocalGraphicsEnvironment().
+ getDefaultScreenDevice();
+ GraphicsConfiguration gcs[] = gd.getConfigurations();
+ for (GraphicsConfiguration gc : gcs) {
+ if (AWTUtilities.isTranslucencyCapable(gc)) {
+ return gc;
+ }
+ }
+ return null;
+ }
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.ButtonGroup createDisposeGrp;
+ private javax.swing.JToggleButton createFrameBtn;
+ private javax.swing.JToggleButton disposeFrameBtn;
+ private javax.swing.JButton failedBtn;
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JLabel jLabel2;
+ private javax.swing.JScrollPane jScrollPane1;
+ private javax.swing.JTextArea jTextArea1;
+ private javax.swing.JCheckBox nonOpaqueChb;
+ private javax.swing.JButton passedBtn;
+ private javax.swing.JCheckBox shapedCb;
+ private javax.swing.JSlider transparencySld;
+ private javax.swing.JCheckBox useSwingCb;
+ // End of variables declaration//GEN-END:variables
+
+}
diff --git a/jdk/test/com/sun/awt/Translucency/WindowOpacity.java b/jdk/test/com/sun/awt/Translucency/WindowOpacity.java
new file mode 100644
index 00000000000..d5d8a11d3d9
--- /dev/null
+++ b/jdk/test/com/sun/awt/Translucency/WindowOpacity.java
@@ -0,0 +1,461 @@
+/*
+ * Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ @test %W% %E%
+ @bug 6594131
+ @summary Tests the AWTUtilities.get/setWindowOpacity() methods
+ @author anthony.petrov@...: area=awt.toplevel
+ @run main WindowOpacity
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+
+import com.sun.awt.AWTUtilities;
+import sun.awt.SunToolkit;
+
+public class WindowOpacity
+{
+ //*** test-writer defined static variables go here ***
+
+ private static void realSync() {
+ ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ }
+
+
+ private static void init()
+ {
+ //*** Create instructions for the user here ***
+ String[] instructions =
+ {
+ "This is an AUTOMATIC test, simply wait until it is done.",
+ "The result (passed or failed) will be shown in the",
+ "message window below."
+ };
+ Sysout.createDialog( );
+ Sysout.printInstructions( instructions );
+
+ if (!AWTUtilities.isTranslucencySupported(AWTUtilities.Translucency.TRANSLUCENT)) {
+ System.out.println("Either the Toolkit or the native system does not support controlling the window opacity level.");
+ pass();
+ }
+
+ boolean passed;
+
+ Frame f = new Frame("Opacity test");
+
+ passed = false;
+ try {
+ AWTUtilities.getWindowOpacity(null);
+ } catch (NullPointerException e) {
+ passed = true;
+ }
+ if (!passed) {
+ fail("getWindowOpacity() allows passing null.");
+ }
+
+
+ passed = false;
+ try {
+ AWTUtilities.setWindowOpacity(null, 0.5f);
+ } catch (NullPointerException e) {
+ passed = true;
+ }
+ if (!passed) {
+ fail("setWindowOpacity() allows passing null.");
+ }
+
+
+ float curOpacity = AWTUtilities.getWindowOpacity(f);
+ if (curOpacity < 1.0f || curOpacity > 1.0f) {
+ fail("getWindowOpacity() reports the initial opacity level other than 1.0: " + curOpacity);
+ }
+
+
+
+ passed = false;
+ try {
+ AWTUtilities.setWindowOpacity(f, -0.5f);
+ } catch (IllegalArgumentException e) {
+ passed = true;
+ }
+ if (!passed) {
+ fail("setWindowOpacity() allows passing negative opacity level.");
+ }
+
+
+
+ passed = false;
+ try {
+ AWTUtilities.setWindowOpacity(f, 1.5f);
+ } catch (IllegalArgumentException e) {
+ passed = true;
+ }
+ if (!passed) {
+ fail("setWindowOpacity() allows passing opacity level greater than 1.0.");
+ }
+
+
+ AWTUtilities.setWindowOpacity(f, 0.5f);
+
+ curOpacity = AWTUtilities.getWindowOpacity(f);
+ if (curOpacity < 0.5f || curOpacity > 0.5f) {
+ fail("getWindowOpacity() reports the opacity level that differs from the value set with setWindowOpacity: " + curOpacity);
+ }
+
+
+ AWTUtilities.setWindowOpacity(f, 0.75f);
+
+ curOpacity = AWTUtilities.getWindowOpacity(f);
+ if (curOpacity < 0.75f || curOpacity > 0.75f) {
+ fail("getWindowOpacity() reports the opacity level that differs from the value set with setWindowOpacity the second time: " + curOpacity);
+ }
+
+
+ f.setBounds(100, 100, 300, 200);
+ f.setVisible(true);
+
+ realSync();
+
+ curOpacity = AWTUtilities.getWindowOpacity(f);
+ if (curOpacity < 0.75f || curOpacity > 0.75f) {
+ fail("getWindowOpacity() reports the opacity level that differs from the value set with setWindowOpacity before showing the frame: " + curOpacity);
+ }
+
+
+
+ AWTUtilities.setWindowOpacity(f, 0.5f);
+ realSync();
+
+ curOpacity = AWTUtilities.getWindowOpacity(f);
+ if (curOpacity < 0.5f || curOpacity > 0.5f) {
+ fail("getWindowOpacity() reports the opacity level that differs from the value set with setWindowOpacity after showing the frame: " + curOpacity);
+ }
+
+ WindowOpacity.pass();
+
+ }//End init()
+
+
+
+ /*****************************************************
+ * Standard Test Machinery Section
+ * DO NOT modify anything in this section -- it's a
+ * standard chunk of code which has all of the
+ * synchronisation necessary for the test harness.
+ * By keeping it the same in all tests, it is easier
+ * to read and understand someone else's test, as
+ * well as insuring that all tests behave correctly
+ * with the test harness.
+ * There is a section following this for test-
+ * classes
+ ******************************************************/
+ private static boolean theTestPassed = false;
+ private static boolean testGeneratedInterrupt = false;
+ private static String failureMessage = "";
+
+ private static Thread mainThread = null;
+
+ private static int sleepTime = 300000;
+
+ // Not sure about what happens if multiple of this test are
+ // instantiated in the same VM. Being static (and using
+ // static vars), it aint gonna work. Not worrying about
+ // it for now.
+ public static void main( String args[] ) throws InterruptedException
+ {
+ mainThread = Thread.currentThread();
+ try
+ {
+ init();
+ }
+ catch( TestPassedException e )
+ {
+ //The test passed, so just return from main and harness will
+ // interepret this return as a pass
+ return;
+ }
+ //At this point, neither test pass nor test fail has been
+ // called -- either would have thrown an exception and ended the
+ // test, so we know we have multiple threads.
+
+ //Test involves other threads, so sleep and wait for them to
+ // called pass() or fail()
+ try
+ {
+ Thread.sleep( sleepTime );
+ //Timed out, so fail the test
+ throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
+ }
+ catch (InterruptedException e)
+ {
+ //The test harness may have interrupted the test. If so, rethrow the exception
+ // so that the harness gets it and deals with it.
+ if( ! testGeneratedInterrupt ) throw e;
+
+ //reset flag in case hit this code more than once for some reason (just safety)
+ testGeneratedInterrupt = false;
+
+ if ( theTestPassed == false )
+ {
+ throw new RuntimeException( failureMessage );
+ }
+ }
+
+ }//main
+
+ public static synchronized void setTimeoutTo( int seconds )
+ {
+ sleepTime = seconds * 1000;
+ }
+
+ public static synchronized void pass()
+ {
+ Sysout.println( "The test passed." );
+ Sysout.println( "The test is over, hit Ctl-C to stop Java VM" );
+ //first check if this is executing in main thread
+ if ( mainThread == Thread.currentThread() )
+ {
+ //Still in the main thread, so set the flag just for kicks,
+ // and throw a test passed exception which will be caught
+ // and end the test.
+ theTestPassed = true;
+ throw new TestPassedException();
+ }
+ theTestPassed = true;
+ testGeneratedInterrupt = true;
+ mainThread.interrupt();
+ }//pass()
+
+ public static synchronized void fail()
+ {
+ //test writer didn't specify why test failed, so give generic
+ fail( "it just plain failed! :-)" );
+ }
+
+ public static synchronized void fail( String whyFailed )
+ {
+ Sysout.println( "The test failed: " + whyFailed );
+ Sysout.println( "The test is over, hit Ctl-C to stop Java VM" );
+ //check if this called from main thread
+ if ( mainThread == Thread.currentThread() )
+ {
+ //If main thread, fail now 'cause not sleeping
+ throw new RuntimeException( whyFailed );
+ }
+ theTestPassed = false;
+ testGeneratedInterrupt = true;
+ failureMessage = whyFailed;
+ mainThread.interrupt();
+ }//fail()
+
+}// class WindowOpacity
+
+//This exception is used to exit from any level of call nesting
+// when it's determined that the test has passed, and immediately
+// end the test.
+class TestPassedException extends RuntimeException
+{
+}
+
+//*********** End Standard Test Machinery Section **********
+
+
+//************ Begin classes defined for the test ****************
+
+// if want to make listeners, here is the recommended place for them, then instantiate
+// them in init()
+
+/* Example of a class which may be written as part of a test
+class NewClass implements anInterface
+ {
+ static int newVar = 0;
+
+ public void eventDispatched(AWTEvent e)
+ {
+ //Counting events to see if we get enough
+ eventCount++;
+
+ if( eventCount == 20 )
+ {
+ //got enough events, so pass
+
+ WindowOpacity.pass();
+ }
+ else if( tries == 20 )
+ {
+ //tried too many times without getting enough events so fail
+
+ WindowOpacity.fail();
+ }
+
+ }// eventDispatched()
+
+ }// NewClass class
+
+*/
+
+
+//************** End classes defined for the test *******************
+
+
+
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+ chunk of code whose purpose is to make user
+ interaction uniform, and thereby make it simpler
+ to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+ for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+ WithInstructions method. Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+ with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+ as standalone.
+ */
+
+class Sysout
+{
+ private static TestDialog dialog;
+
+ public static void createDialogWithInstructions( String[] instructions )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ dialog.printInstructions( instructions );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+ public static void createDialog( )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ String[] defInstr = { "Instructions will appear here. ", "" } ;
+ dialog.printInstructions( defInstr );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+
+ public static void printInstructions( String[] instructions )
+ {
+ dialog.printInstructions( instructions );
+ }
+
+
+ public static void println( String messageIn )
+ {
+ dialog.displayMessage( messageIn );
+ System.out.println(messageIn);
+ }
+
+}// Sysout class
+
+/**
+ This is part of the standard test machinery. It provides a place for the
+ test instructions to be displayed, and a place for interactive messages
+ to the user to be displayed.
+ To have the test instructions displayed, see Sysout.
+ To have a message to the user be displayed, see Sysout.
+ Do not call anything in this dialog directly.
+ */
+class TestDialog extends Dialog
+{
+
+ TextArea instructionsText;
+ TextArea messageText;
+ int maxStringLength = 80;
+
+ //DO NOT call this directly, go through Sysout
+ public TestDialog( Frame frame, String name )
+ {
+ super( frame, name );
+ int scrollBoth = TextArea.SCROLLBARS_BOTH;
+ instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+ add( "North", instructionsText );
+
+ messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+ add("Center", messageText);
+
+ pack();
+
+ setVisible(true);
+ }// TestDialog()
+
+ //DO NOT call this directly, go through Sysout
+ public void printInstructions( String[] instructions )
+ {
+ //Clear out any current instructions
+ instructionsText.setText( "" );
+
+ //Go down array of instruction strings
+
+ String printStr, remainingStr;
+ for( int i=0; i < instructions.length; i++ )
+ {
+ //chop up each into pieces maxSringLength long
+ remainingStr = instructions[ i ];
+ while( remainingStr.length() > 0 )
+ {
+ //if longer than max then chop off first max chars to print
+ if( remainingStr.length() >= maxStringLength )
+ {
+ //Try to chop on a word boundary
+ int posOfSpace = remainingStr.
+ lastIndexOf( ' ', maxStringLength - 1 );
+
+ if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+ printStr = remainingStr.substring( 0, posOfSpace + 1 );
+ remainingStr = remainingStr.substring( posOfSpace + 1 );
+ }
+ //else just print
+ else
+ {
+ printStr = remainingStr;
+ remainingStr = "";
+ }
+
+ instructionsText.append( printStr + "\n" );
+
+ }// while
+
+ }// for
+
+ }//printInstructions()
+
+ //DO NOT call this directly, go through Sysout
+ public void displayMessage( String messageIn )
+ {
+ messageText.append( messageIn + "\n" );
+ System.out.println(messageIn);
+ }
+
+}// TestDialog class
diff --git a/jdk/test/sun/java2d/pipe/RegionOps.java b/jdk/test/sun/java2d/pipe/RegionOps.java
new file mode 100644
index 00000000000..30f8c223a25
--- /dev/null
+++ b/jdk/test/sun/java2d/pipe/RegionOps.java
@@ -0,0 +1,510 @@
+/*
+ * @test %W% %E%
+ * @bug 6504874
+ * @summary This test verifies the operation (and performance) of the
+ * various CAG operations on the internal Region class.
+ * @run main RegionOps
+ */
+
+import java.awt.Rectangle;
+import java.awt.geom.Area;
+import java.awt.geom.AffineTransform;
+import java.awt.image.BufferedImage;
+import java.util.Random;
+import sun.java2d.pipe.Region;
+
+public class RegionOps {
+ public static final int DEFAULT_NUMREGIONS = 50;
+ public static final int DEFAULT_MINSUBRECTS = 1;
+ public static final int DEFAULT_MAXSUBRECTS = 10;
+
+ public static final int MINCOORD = -20;
+ public static final int MAXCOORD = 20;
+
+ public static boolean useArea;
+
+ static int numops;
+ static int numErrors;
+ static Random rand = new Random();
+ static boolean skipCheck;
+ static boolean countErrors;
+
+ static {
+ // Instantiating BufferedImage initializes sun.java2d
+ BufferedImage bimg =
+ new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
+ }
+
+ public static void usage(String error) {
+ if (error != null) {
+ System.err.println("Error: "+error);
+ }
+ System.err.println("Usage: java RegionOps "+
+ "[-regions N] [-rects M] "+
+ "[-[min|max]rects M] [-area]");
+ System.err.println(" "+
+ "[-add|union] [-sub|diff] "+
+ "[-int[ersect]] [-xor]");
+ System.err.println(" "+
+ "[-seed S] [-nocheck] [-count[errors]] [-help]");
+ System.exit((error != null) ? 1 : 0);
+ }
+
+ public static void error(RectListImpl a, RectListImpl b, String problem) {
+ System.err.println("Operating on: "+a);
+ if (b != null) {
+ System.err.println("and: "+b);
+ }
+ if (countErrors) {
+ System.err.println(problem);
+ numErrors++;
+ } else {
+ throw new RuntimeException(problem);
+ }
+ }
+
+ public static void main(String argv[]) {
+ int numregions = DEFAULT_NUMREGIONS;
+ int minsubrects = DEFAULT_MINSUBRECTS;
+ int maxsubrects = DEFAULT_MAXSUBRECTS;
+ boolean doUnion = false;
+ boolean doIntersect = false;
+ boolean doSubtract = false;
+ boolean doXor = false;
+
+ for (int i = 0; i < argv.length; i++) {
+ String arg = argv[i];
+ if (arg.equalsIgnoreCase("-regions")) {
+ if (i+1 >= argv.length) {
+ usage("missing arg for -regions");
+ }
+ numregions = Integer.parseInt(argv[++i]);
+ } else if (arg.equalsIgnoreCase("-rects")) {
+ if (i+1 >= argv.length) {
+ usage("missing arg for -rects");
+ }
+ minsubrects = maxsubrects = Integer.parseInt(argv[++i]);
+ } else if (arg.equalsIgnoreCase("-minrects")) {
+ if (i+1 >= argv.length) {
+ usage("missing arg for -minrects");
+ }
+ minsubrects = Integer.parseInt(argv[++i]);
+ } else if (arg.equalsIgnoreCase("-maxrects")) {
+ if (i+1 >= argv.length) {
+ usage("missing arg for -maxrects");
+ }
+ maxsubrects = Integer.parseInt(argv[++i]);
+ } else if (arg.equalsIgnoreCase("-area")) {
+ useArea = true;
+ } else if (arg.equalsIgnoreCase("-add") ||
+ arg.equalsIgnoreCase("-union"))
+ {
+ doUnion = true;
+ } else if (arg.equalsIgnoreCase("-sub") ||
+ arg.equalsIgnoreCase("-diff"))
+ {
+ doSubtract = true;
+ } else if (arg.equalsIgnoreCase("-int") ||
+ arg.equalsIgnoreCase("-intersect"))
+ {
+ doIntersect = true;
+ } else if (arg.equalsIgnoreCase("-xor")) {
+ doXor = true;
+ } else if (arg.equalsIgnoreCase("-seed")) {
+ if (i+1 >= argv.length) {
+ usage("missing arg for -seed");
+ }
+ rand.setSeed(Long.decode(argv[++i]).longValue());
+ } else if (arg.equalsIgnoreCase("-nocheck")) {
+ skipCheck = true;
+ } else if (arg.equalsIgnoreCase("-count") ||
+ arg.equalsIgnoreCase("-counterrors"))
+ {
+ countErrors = true;
+ } else if (arg.equalsIgnoreCase("-help")) {
+ usage(null);
+ } else {
+ usage("Unknown argument: "+arg);
+ }
+ }
+
+ if (maxsubrects < minsubrects) {
+ usage("maximum number of subrectangles less than minimum");
+ }
+
+ if (minsubrects <= 0) {
+ usage("minimum number of subrectangles must be positive");
+ }
+
+ if (!doUnion && !doSubtract && !doIntersect && !doXor) {
+ doUnion = doSubtract = doIntersect = doXor = true;
+ }
+
+ long start = System.currentTimeMillis();
+ RectListImpl rlist[] = new RectListImpl[numregions];
+ int totalrects = 0;
+ for (int i = 0; i < rlist.length; i++) {
+ RectListImpl rli = RectListImpl.getInstance();
+ int numsubrects =
+ minsubrects + rand.nextInt(maxsubrects - minsubrects + 1);
+ for (int j = 0; j < numsubrects; j++) {
+ addRectTo(rli);
+ totalrects++;
+ }
+ rlist[i] = rli;
+ }
+ long end = System.currentTimeMillis();
+ System.out.println((end-start)+"ms to create "+
+ rlist.length+" regions containing "+
+ totalrects+" subrectangles");
+
+ start = System.currentTimeMillis();
+ for (int i = 0; i < rlist.length; i++) {
+ RectListImpl a = rlist[i];
+ testTranslate(a);
+ for (int j = i; j < rlist.length; j++) {
+ RectListImpl b = rlist[j];
+ if (doUnion) testUnion(a, b);
+ if (doSubtract) testDifference(a, b);
+ if (doIntersect) testIntersection(a, b);
+ if (doXor) testExclusiveOr(a, b);
+ }
+ }
+ end = System.currentTimeMillis();
+ System.out.println(numops+" ops took "+(end-start)+"ms");
+
+ if (numErrors > 0) {
+ throw new RuntimeException(numErrors+" errors encountered");
+ }
+ }
+
+ public static void addRectTo(RectListImpl rli) {
+ int lox = MINCOORD + rand.nextInt(MAXCOORD - MINCOORD + 1);
+ int hix = MINCOORD + rand.nextInt(MAXCOORD - MINCOORD + 1);
+ int loy = MINCOORD + rand.nextInt(MAXCOORD - MINCOORD + 1);
+ int hiy = MINCOORD + rand.nextInt(MAXCOORD - MINCOORD + 1);
+ rli.addRect(lox, loy, hix, hiy);
+ }
+
+ public static void checkEqual(RectListImpl a, RectListImpl b,
+ String optype)
+ {
+ if (a.hashCode() != b.hashCode()) {
+ error(a, b, "hashcode failed for "+optype);
+ }
+ if (!a.equals(b)) {
+ error(a, b, "equals failed for "+optype);
+ }
+ }
+
+ public static void testTranslate(RectListImpl a) {
+ RectListImpl maxTrans =
+ a.getTranslation(Integer.MAX_VALUE, Integer.MAX_VALUE)
+ .getTranslation(Integer.MAX_VALUE, Integer.MAX_VALUE)
+ .getTranslation(Integer.MAX_VALUE, Integer.MAX_VALUE);
+ if (!maxTrans.checkTransEmpty()) {
+ error(maxTrans, null, "overflow translated RectList not empty");
+ }
+ RectListImpl minTrans =
+ a.getTranslation(Integer.MIN_VALUE, Integer.MIN_VALUE)
+ .getTranslation(Integer.MIN_VALUE, Integer.MIN_VALUE)
+ .getTranslation(Integer.MIN_VALUE, Integer.MIN_VALUE);
+ if (!minTrans.checkTransEmpty()) {
+ error(minTrans, null, "overflow translated RectList not empty");
+ }
+ testTranslate(a, Integer.MAX_VALUE, Integer.MAX_VALUE, false,
+ MINCOORD, 0, MINCOORD, 0);
+ testTranslate(a, Integer.MAX_VALUE, Integer.MIN_VALUE, false,
+ MINCOORD, 0, 0, MAXCOORD);
+ testTranslate(a, Integer.MIN_VALUE, Integer.MAX_VALUE, false,
+ 0, MAXCOORD, MINCOORD, 0);
+ testTranslate(a, Integer.MIN_VALUE, Integer.MIN_VALUE, false,
+ 0, MAXCOORD, 0, MAXCOORD);
+ for (int dy = -100; dy <= 100; dy += 50) {
+ for (int dx = -100; dx <= 100; dx += 50) {
+ testTranslate(a, dx, dy, true,
+ MINCOORD, MAXCOORD,
+ MINCOORD, MAXCOORD);
+ }
+ }
+ }
+
+ public static void testTranslate(RectListImpl a, int dx, int dy,
+ boolean isNonDestructive,
+ int xmin, int xmax,
+ int ymin, int ymax)
+ {
+ RectListImpl theTrans = a.getTranslation(dx, dy); numops++;
+ if (skipCheck) return;
+ RectListImpl unTrans = theTrans.getTranslation(-dx, -dy);
+ if (isNonDestructive) checkEqual(a, unTrans, "Translate");
+ for (int x = xmin; x < xmax; x++) {
+ for (int y = ymin; y < ymax; y++) {
+ boolean inside = a.contains(x, y);
+ if (theTrans.contains(x+dx, y+dy) != inside) {
+ error(a, null, "translation failed for "+
+ dx+", "+dy+" at "+x+", "+y);
+ }
+ }
+ }
+ }
+
+ public static void testUnion(RectListImpl a, RectListImpl b) {
+ RectListImpl aUb = a.getUnion(b); numops++;
+ RectListImpl bUa = b.getUnion(a); numops++;
+ if (skipCheck) return;
+ checkEqual(aUb, bUa, "Union");
+ testUnion(a, b, aUb);
+ testUnion(a, b, bUa);
+ }
+
+ public static void testUnion(RectListImpl a, RectListImpl b,
+ RectListImpl theUnion)
+ {
+ for (int x = MINCOORD; x < MAXCOORD; x++) {
+ for (int y = MINCOORD; y < MAXCOORD; y++) {
+ boolean inside = (a.contains(x, y) || b.contains(x, y));
+ if (theUnion.contains(x, y) != inside) {
+ error(a, b, "union failed at "+x+", "+y);
+ }
+ }
+ }
+ }
+
+ public static void testDifference(RectListImpl a, RectListImpl b) {
+ RectListImpl aDb = a.getDifference(b); numops++;
+ RectListImpl bDa = b.getDifference(a); numops++;
+ if (skipCheck) return;
+ // Note that difference is not commutative so we cannot check equals
+ // checkEqual(a, b, "Difference");
+ testDifference(a, b, aDb);
+ testDifference(b, a, bDa);
+ }
+
+ public static void testDifference(RectListImpl a, RectListImpl b,
+ RectListImpl theDifference)
+ {
+ for (int x = MINCOORD; x < MAXCOORD; x++) {
+ for (int y = MINCOORD; y < MAXCOORD; y++) {
+ boolean inside = (a.contains(x, y) && !b.contains(x, y));
+ if (theDifference.contains(x, y) != inside) {
+ error(a, b, "difference failed at "+x+", "+y);
+ }
+ }
+ }
+ }
+
+ public static void testIntersection(RectListImpl a, RectListImpl b) {
+ RectListImpl aIb = a.getIntersection(b); numops++;
+ RectListImpl bIa = b.getIntersection(a); numops++;
+ if (skipCheck) return;
+ checkEqual(aIb, bIa, "Intersection");
+ testIntersection(a, b, aIb);
+ testIntersection(a, b, bIa);
+ }
+
+ public static void testIntersection(RectListImpl a, RectListImpl b,
+ RectListImpl theIntersection)
+ {
+ for (int x = MINCOORD; x < MAXCOORD; x++) {
+ for (int y = MINCOORD; y < MAXCOORD; y++) {
+ boolean inside = (a.contains(x, y) && b.contains(x, y));
+ if (theIntersection.contains(x, y) != inside) {
+ error(a, b, "intersection failed at "+x+", "+y);
+ }
+ }
+ }
+ }
+
+ public static void testExclusiveOr(RectListImpl a, RectListImpl b) {
+ RectListImpl aXb = a.getExclusiveOr(b); numops++;
+ RectListImpl bXa = b.getExclusiveOr(a); numops++;
+ if (skipCheck) return;
+ checkEqual(aXb, bXa, "ExclusiveOr");
+ testExclusiveOr(a, b, aXb);
+ testExclusiveOr(a, b, bXa);
+ }
+
+ public static void testExclusiveOr(RectListImpl a, RectListImpl b,
+ RectListImpl theExclusiveOr)
+ {
+ for (int x = MINCOORD; x < MAXCOORD; x++) {
+ for (int y = MINCOORD; y < MAXCOORD; y++) {
+ boolean inside = (a.contains(x, y) != b.contains(x, y));
+ if (theExclusiveOr.contains(x, y) != inside) {
+ error(a, b, "xor failed at "+x+", "+y);
+ }
+ }
+ }
+ }
+
+ public abstract static class RectListImpl {
+ public static RectListImpl getInstance() {
+ if (useArea) {
+ return new AreaImpl();
+ } else {
+ return new RegionImpl();
+ }
+ }
+
+ public abstract void addRect(int lox, int loy, int hix, int hiy);
+
+ public abstract RectListImpl getTranslation(int dx, int dy);
+
+ public abstract RectListImpl getIntersection(RectListImpl rli);
+ public abstract RectListImpl getExclusiveOr(RectListImpl rli);
+ public abstract RectListImpl getDifference(RectListImpl rli);
+ public abstract RectListImpl getUnion(RectListImpl rli);
+
+ // Used for making sure that 3xMAX translates yields an empty region
+ public abstract boolean checkTransEmpty();
+
+ public abstract boolean contains(int x, int y);
+
+ public abstract int hashCode();
+ public abstract boolean equals(RectListImpl other);
+ }
+
+ public static class AreaImpl extends RectListImpl {
+ Area theArea;
+
+ public AreaImpl() {
+ }
+
+ public AreaImpl(Area a) {
+ theArea = a;
+ }
+
+ public void addRect(int lox, int loy, int hix, int hiy) {
+ Area a2 = new Area(new Rectangle(lox, loy, hix-lox, hiy-loy));
+ if (theArea == null) {
+ theArea = a2;
+ } else {
+ theArea.add(a2);
+ }
+ }
+
+ public RectListImpl getTranslation(int dx, int dy) {
+ AffineTransform at = AffineTransform.getTranslateInstance(dx, dy);
+ return new AreaImpl(theArea.createTransformedArea(at));
+ }
+
+ public RectListImpl getIntersection(RectListImpl rli) {
+ Area a2 = new Area(theArea);
+ a2.intersect(((AreaImpl) rli).theArea);
+ return new AreaImpl(a2);
+ }
+
+ public RectListImpl getExclusiveOr(RectListImpl rli) {
+ Area a2 = new Area(theArea);
+ a2.exclusiveOr(((AreaImpl) rli).theArea);
+ return new AreaImpl(a2);
+ }
+
+ public RectListImpl getDifference(RectListImpl rli) {
+ Area a2 = new Area(theArea);
+ a2.subtract(((AreaImpl) rli).theArea);
+ return new AreaImpl(a2);
+ }
+
+ public RectListImpl getUnion(RectListImpl rli) {
+ Area a2 = new Area(theArea);
+ a2.add(((AreaImpl) rli).theArea);
+ return new AreaImpl(a2);
+ }
+
+ // Used for making sure that 3xMAX translates yields an empty region
+ public boolean checkTransEmpty() {
+ // Area objects will actually survive 3 MAX translates so just
+ // pretend that it had the intended effect...
+ return true;
+ }
+
+ public boolean contains(int x, int y) {
+ return theArea.contains(x, y);
+ }
+
+ public int hashCode() {
+ // Area does not override hashCode...
+ return 0;
+ }
+
+ public boolean equals(RectListImpl other) {
+ return theArea.equals(((AreaImpl) other).theArea);
+ }
+
+ public String toString() {
+ return theArea.toString();
+ }
+ }
+
+ public static class RegionImpl extends RectListImpl {
+ Region theRegion;
+
+ public RegionImpl() {
+ }
+
+ public RegionImpl(Region r) {
+ theRegion = r;
+ }
+
+ public void addRect(int lox, int loy, int hix, int hiy) {
+ Region r2 = Region.getInstanceXYXY(lox, loy, hix, hiy);
+ if (theRegion == null) {
+ theRegion = r2;
+ } else {
+ theRegion = theRegion.getUnion(r2);
+ }
+ }
+
+ public RectListImpl getTranslation(int dx, int dy) {
+ return new RegionImpl(theRegion.getTranslatedRegion(dx, dy));
+ }
+
+ public RectListImpl getIntersection(RectListImpl rli) {
+ Region r2 = ((RegionImpl) rli).theRegion;
+ r2 = theRegion.getIntersection(r2);
+ return new RegionImpl(r2);
+ }
+
+ public RectListImpl getExclusiveOr(RectListImpl rli) {
+ Region r2 = ((RegionImpl) rli).theRegion;
+ r2 = theRegion.getExclusiveOr(r2);
+ return new RegionImpl(r2);
+ }
+
+ public RectListImpl getDifference(RectListImpl rli) {
+ Region r2 = ((RegionImpl) rli).theRegion;
+ r2 = theRegion.getDifference(r2);
+ return new RegionImpl(r2);
+ }
+
+ public RectListImpl getUnion(RectListImpl rli) {
+ Region r2 = ((RegionImpl) rli).theRegion;
+ r2 = theRegion.getUnion(r2);
+ return new RegionImpl(r2);
+ }
+
+ // Used for making sure that 3xMAX translates yields an empty region
+ public boolean checkTransEmpty() {
+ // Region objects should be empty after 3 MAX translates...
+ return theRegion.isEmpty();
+ }
+
+ public boolean contains(int x, int y) {
+ return theRegion.contains(x, y);
+ }
+
+ public int hashCode() {
+ return theRegion.hashCode();
+ }
+
+ public boolean equals(RectListImpl other) {
+ return theRegion.equals(((RegionImpl) other).theRegion);
+ }
+
+ public String toString() {
+ return theRegion.toString();
+ }
+ }
+}
From b8af3d50192f8bc98d83f8102f0fd1989f302e32 Mon Sep 17 00:00:00 2001
From: Artem Ananiev
Date: Thu, 12 Feb 2009 14:19:06 +0300
Subject: [PATCH 036/292] 6799345: JFC demos threw exception in the Java
Console when applets are closed
Reviewed-by: alexp, peterz
---
.../classes/javax/swing/SwingWorker.java | 50 +++--
.../share/classes/javax/swing/TimerQueue.java | 9 +-
.../swing/system/6799345/TestShutdown.java | 203 ++++++++++++++++++
3 files changed, 234 insertions(+), 28 deletions(-)
create mode 100644 jdk/test/javax/swing/system/6799345/TestShutdown.java
diff --git a/jdk/src/share/classes/javax/swing/SwingWorker.java b/jdk/src/share/classes/javax/swing/SwingWorker.java
index 9eca7d535f6..263284acc4e 100644
--- a/jdk/src/share/classes/javax/swing/SwingWorker.java
+++ b/jdk/src/share/classes/javax/swing/SwingWorker.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -778,35 +778,33 @@ public abstract class SwingWorker implements RunnableFuture {
threadFactory);
appContext.put(SwingWorker.class, executorService);
- //register shutdown hook for this executor service
+ // Don't use ShutdownHook here as it's not enough. We should track
+ // AppContext disposal instead of JVM shutdown, see 6799345 for details
final ExecutorService es = executorService;
- final Runnable shutdownHook =
- new Runnable() {
- final WeakReference executorServiceRef =
- new WeakReference(es);
- public void run() {
- final ExecutorService executorService =
- executorServiceRef.get();
- if (executorService != null) {
- AccessController.doPrivileged(
- new PrivilegedAction() {
- public Void run() {
- executorService.shutdown();
- return null;
+ appContext.addPropertyChangeListener(AppContext.DISPOSED_PROPERTY_NAME,
+ new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent pce) {
+ boolean disposed = (Boolean)pce.getNewValue();
+ if (disposed) {
+ final WeakReference executorServiceRef =
+ new WeakReference(es);
+ final ExecutorService executorService =
+ executorServiceRef.get();
+ if (executorService != null) {
+ AccessController.doPrivileged(
+ new PrivilegedAction() {
+ public Void run() {
+ executorService.shutdown();
+ return null;
+ }
}
- });
+ );
+ }
}
}
- };
-
- AccessController.doPrivileged(
- new PrivilegedAction() {
- public Void run() {
- Runtime.getRuntime().addShutdownHook(
- new Thread(shutdownHook));
- return null;
- }
- });
+ }
+ );
}
return executorService;
}
diff --git a/jdk/src/share/classes/javax/swing/TimerQueue.java b/jdk/src/share/classes/javax/swing/TimerQueue.java
index f68f4e99688..642bc56bac7 100644
--- a/jdk/src/share/classes/javax/swing/TimerQueue.java
+++ b/jdk/src/share/classes/javax/swing/TimerQueue.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -191,7 +191,12 @@ class TimerQueue implements Runnable
} finally {
timer.getLock().unlock();
}
- } catch (InterruptedException ignore) {
+ } catch (InterruptedException ie) {
+ // Shouldn't ignore InterruptedExceptions here, so AppContext
+ // is disposed gracefully, see 6799345 for details
+ if (AppContext.getAppContext().isDisposed()) {
+ break;
+ }
}
}
}
diff --git a/jdk/test/javax/swing/system/6799345/TestShutdown.java b/jdk/test/javax/swing/system/6799345/TestShutdown.java
new file mode 100644
index 00000000000..694df3eac01
--- /dev/null
+++ b/jdk/test/javax/swing/system/6799345/TestShutdown.java
@@ -0,0 +1,203 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+ @bug 6799345
+ @summary Tests that no exceptions are thrown from TimerQueue and
+SwingWorker on AppContext shutdown
+ @author art
+ @run main TestShutdown
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+
+import java.util.*;
+
+import javax.swing.*;
+
+import sun.awt.*;
+
+public class TestShutdown
+{
+ private static AppContext targetAppContext;
+
+ private static JFrame f;
+ private static JTextField tf;
+
+ private static volatile boolean exceptionsOccurred = false;
+ private static volatile boolean appcontextInitDone = false;
+
+ private static int timerValue = 0;
+
+ public static void main(String[] args)
+ throws Exception
+ {
+ ThreadGroup tg = new TestThreadGroup("TTG");
+ Thread t = new Thread(tg, new TestRunnable(), "InitThread");
+ t.start();
+
+ while (!appcontextInitDone)
+ {
+ Thread.sleep(500);
+ }
+
+ targetAppContext.dispose();
+
+ if (exceptionsOccurred)
+ {
+ throw new RuntimeException("Test FAILED: some exceptions occurred");
+ }
+ }
+
+ static void initGUI()
+ {
+ f = new JFrame("F");
+ f.setBounds(100, 100, 200, 100);
+ tf = new JTextField("Test");
+ f.add(tf);
+ f.setVisible(true);
+ }
+
+ static void startGUI()
+ {
+ // caret blink Timer
+ tf.requestFocusInWindow();
+
+ // misc Timer
+ ActionListener al = new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent ae)
+ {
+ System.out.println("Timer tick: " + timerValue++);
+ }
+ };
+ new javax.swing.Timer(30, al).start();
+ }
+
+ static class TestThreadGroup extends ThreadGroup
+ {
+ public TestThreadGroup(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ public synchronized void uncaughtException(Thread thread, Throwable t)
+ {
+ if (t instanceof ThreadDeath)
+ {
+ // this one is expected, rethrow
+ throw (ThreadDeath)t;
+ }
+ System.err.println("Test FAILED: an exception is caught in the " +
+ "target thread group on thread " + thread.getName());
+ t.printStackTrace(System.err);
+ exceptionsOccurred = true;
+ }
+ }
+
+ static class TestRunnable implements Runnable
+ {
+ @Override
+ public void run()
+ {
+ SunToolkit stk = (SunToolkit)Toolkit.getDefaultToolkit();
+ targetAppContext = stk.createNewAppContext();
+
+ // create and show frame and text field
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ initGUI();
+ }
+ });
+ stk.realSync();
+
+ // start some Timers
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ startGUI();
+ }
+ });
+ stk.realSync();
+
+ // start multiple SwingWorkers
+ while (!Thread.interrupted())
+ {
+ try
+ {
+ new TestSwingWorker().execute();
+ Thread.sleep(40);
+ }
+ catch (Exception e)
+ {
+ // exception here is expected, skip
+ break;
+ }
+ }
+ }
+ }
+
+ static class TestSwingWorker extends SwingWorker
+ {
+ @Override
+ public String doInBackground()
+ {
+ Random r = new Random();
+ for (int i = 0; i < 10; i++)
+ {
+ try
+ {
+ int delay = r.nextInt() % 50;
+ Thread.sleep(delay);
+ publish(delay);
+ }
+ catch (Exception z)
+ {
+ break;
+ }
+ }
+ if (!appcontextInitDone)
+ {
+ appcontextInitDone = true;
+ }
+ return "Done";
+ }
+
+ @Override
+ public void process(java.util.List chunks)
+ {
+ for (Integer i : chunks)
+ {
+ System.err.println("Processed: " + i);
+ }
+ }
+ }
+}
From 3ca96fa4452cd6ae18e07df6a10740c362c1e790 Mon Sep 17 00:00:00 2001
From: Artem Ananiev
Date: Thu, 12 Feb 2009 17:27:39 +0300
Subject: [PATCH 037/292] 6804680: Solaris AMD64 build fails after the fix for
6633275/7
Addition to the fix for 6633275
Reviewed-by: yan
---
.../classes/sun/awt/X11/generator/sizes.64-solaris-i386 | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/jdk/src/solaris/classes/sun/awt/X11/generator/sizes.64-solaris-i386 b/jdk/src/solaris/classes/sun/awt/X11/generator/sizes.64-solaris-i386
index 38ec9071b05..f6e3beb3f1c 100644
--- a/jdk/src/solaris/classes/sun/awt/X11/generator/sizes.64-solaris-i386
+++ b/jdk/src/solaris/classes/sun/awt/X11/generator/sizes.64-solaris-i386
@@ -774,7 +774,8 @@ AwtGraphicsConfigData.monoPixmapGC 128
AwtGraphicsConfigData.pixelStride 136
AwtGraphicsConfigData.color_data 144
AwtGraphicsConfigData.glxInfo 152
-AwtGraphicsConfigData 160
+AwtGraphicsConfigData.isTranslucencySupported 160
+AwtGraphicsConfigData 168
XColor.pixel 0
XColor.red 8
XColor.green 10
From ce1993bf8e883ea3571235bd6c314f01aa0baf57 Mon Sep 17 00:00:00 2001
From: Dmitry Cherepanov
Date: Thu, 12 Feb 2009 18:24:35 +0300
Subject: [PATCH 038/292] 6724890: Deadlock between AWT-EventQueue-1 and
AWT-XAWT threads during IDE start
Reviewed-by: art, ant
---
jdk/src/share/classes/java/awt/Frame.java | 36 ++++++++++++++-----
.../share/classes/sun/awt/AWTAccessor.java | 36 +++++++++++++++++++
.../classes/sun/awt/X11/XFramePeer.java | 20 ++++++++---
.../classes/sun/awt/windows/WFramePeer.java | 29 ++++++++++++---
.../windows/native/sun/windows/awt_Frame.cpp | 35 ++++++++++++++----
.../windows/native/sun/windows/awt_Frame.h | 12 +++----
6 files changed, 138 insertions(+), 30 deletions(-)
diff --git a/jdk/src/share/classes/java/awt/Frame.java b/jdk/src/share/classes/java/awt/Frame.java
index 290f7f9bb3d..761b9b8420b 100644
--- a/jdk/src/share/classes/java/awt/Frame.java
+++ b/jdk/src/share/classes/java/awt/Frame.java
@@ -36,6 +36,7 @@ import java.io.ObjectInputStream;
import java.io.IOException;
import sun.awt.AppContext;
import sun.awt.SunToolkit;
+import sun.awt.AWTAccessor;
import java.lang.ref.WeakReference;
import javax.accessibility.*;
@@ -738,11 +739,15 @@ public class Frame extends Window implements MenuContainer {
* @since 1.4
* @see java.awt.Window#addWindowStateListener
*/
- public synchronized void setExtendedState(int state) {
+ public void setExtendedState(int state) {
if ( !isFrameStateSupported( state ) ) {
return;
}
- this.state = state;
+ synchronized (getObjectLock()) {
+ this.state = state;
+ }
+ // peer.setState must be called outside of object lock
+ // synchronization block to avoid possible deadlock
FramePeer peer = (FramePeer)this.peer;
if (peer != null) {
peer.setState(state);
@@ -804,12 +809,27 @@ public class Frame extends Window implements MenuContainer {
* @see #setExtendedState(int)
* @since 1.4
*/
- public synchronized int getExtendedState() {
- FramePeer peer = (FramePeer)this.peer;
- if (peer != null) {
- state = peer.getState();
+ public int getExtendedState() {
+ synchronized (getObjectLock()) {
+ return state;
}
- return state;
+ }
+
+ static {
+ AWTAccessor.setFrameAccessor(
+ new AWTAccessor.FrameAccessor() {
+ public void setExtendedState(Frame frame, int state) {
+ synchronized(frame.getObjectLock()) {
+ frame.state = state;
+ }
+ }
+ public int getExtendedState(Frame frame) {
+ synchronized(frame.getObjectLock()) {
+ return frame.state;
+ }
+ }
+ }
+ );
}
/**
@@ -967,7 +987,7 @@ public class Frame extends Window implements MenuContainer {
if (resizable) {
str += ",resizable";
}
- getExtendedState(); // sync with peer
+ int state = getExtendedState();
if (state == NORMAL) {
str += ",normal";
}
diff --git a/jdk/src/share/classes/sun/awt/AWTAccessor.java b/jdk/src/share/classes/sun/awt/AWTAccessor.java
index 94d0bb25f0b..2145f0f10a4 100644
--- a/jdk/src/share/classes/sun/awt/AWTAccessor.java
+++ b/jdk/src/share/classes/sun/awt/AWTAccessor.java
@@ -132,6 +132,20 @@ public final class AWTAccessor {
boolean isSystemGenerated(AWTEvent ev);
}
+ /*
+ * An accessor for the java.awt.Frame class.
+ */
+ public interface FrameAccessor {
+ /*
+ * Sets the state of this frame.
+ */
+ void setExtendedState(Frame frame, int state);
+ /*
+ * Gets the state of this frame.
+ */
+ int getExtendedState(Frame frame);
+ }
+
/*
* The java.awt.Component class accessor object.
*/
@@ -147,6 +161,11 @@ public final class AWTAccessor {
*/
private static AWTEventAccessor awtEventAccessor;
+ /*
+ * The java.awt.Frame class accessor object.
+ */
+ private static FrameAccessor frameAccessor;
+
/*
* Set an accessor object for the java.awt.Component class.
*/
@@ -195,4 +214,21 @@ public final class AWTAccessor {
public static AWTEventAccessor getAWTEventAccessor() {
return awtEventAccessor;
}
+
+ /*
+ * Set an accessor object for the java.awt.Frame class.
+ */
+ public static void setFrameAccessor(FrameAccessor fa) {
+ frameAccessor = fa;
+ }
+
+ /*
+ * Retrieve the accessor object for the java.awt.Frame class.
+ */
+ public static FrameAccessor getFrameAccessor() {
+ if (frameAccessor == null) {
+ unsafe.ensureClassInitialized(Frame.class);
+ }
+ return frameAccessor;
+ }
}
diff --git a/jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java b/jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java
index 3820bf61013..22cb163ebbb 100644
--- a/jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java
+++ b/jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java
@@ -36,6 +36,7 @@ import java.awt.Rectangle;
import java.awt.peer.FramePeer;
import java.util.logging.Level;
import java.util.logging.Logger;
+import sun.awt.AWTAccessor;
class XFramePeer extends XDecoratedPeer implements FramePeer {
private static Logger log = Logger.getLogger("sun.awt.X11.XFramePeer");
@@ -231,13 +232,19 @@ class XFramePeer extends XDecoratedPeer implements FramePeer {
}
}
- public int getState() { return state; }
+ public int getState() {
+ synchronized(getStateLock()) {
+ return state;
+ }
+ }
public void setState(int newState) {
- if (!isShowing()) {
- stateLog.finer("Frame is not showing");
- state = newState;
- return;
+ synchronized(getStateLock()) {
+ if (!isShowing()) {
+ stateLog.finer("Frame is not showing");
+ state = newState;
+ return;
+ }
}
changeState(newState);
}
@@ -296,6 +303,9 @@ class XFramePeer extends XDecoratedPeer implements FramePeer {
int old_state = state;
state = newState;
+ // sync target with peer
+ AWTAccessor.getFrameAccessor().setExtendedState((Frame)target, state);
+
if ((changed & Frame.ICONIFIED) != 0) {
if ((state & Frame.ICONIFIED) != 0) {
stateLog.finer("Iconified");
diff --git a/jdk/src/windows/classes/sun/awt/windows/WFramePeer.java b/jdk/src/windows/classes/sun/awt/windows/WFramePeer.java
index 2353daf3d29..79bf6b77e41 100644
--- a/jdk/src/windows/classes/sun/awt/windows/WFramePeer.java
+++ b/jdk/src/windows/classes/sun/awt/windows/WFramePeer.java
@@ -25,27 +25,46 @@
package sun.awt.windows;
import java.util.Vector;
+
import java.awt.*;
import java.awt.peer.*;
import java.awt.image.ImageObserver;
-import sun.awt.image.ImageRepresentation;
-import sun.awt.image.IntegerComponentRaster;
-import sun.awt.image.ToolkitImage;
+
import java.awt.image.Raster;
import java.awt.image.DataBuffer;
import java.awt.image.DataBufferInt;
import java.awt.image.BufferedImage;
-import sun.awt.im.*;
-import sun.awt.Win32GraphicsDevice;
+
import java.awt.image.ColorModel;
+import sun.awt.image.ImageRepresentation;
+import sun.awt.image.IntegerComponentRaster;
+import sun.awt.image.ToolkitImage;
+import sun.awt.im.*;
+import sun.awt.Win32GraphicsDevice;
+import sun.awt.AWTAccessor;
class WFramePeer extends WWindowPeer implements FramePeer {
+ static {
+ initIDs();
+ }
+
+ // initialize JNI field and method IDs
+ private static native void initIDs();
+
// FramePeer implementation
public native void setState(int state);
public native int getState();
+ // sync target and peer
+ public void setExtendedState(int state) {
+ AWTAccessor.getFrameAccessor().setExtendedState((Frame)target, state);
+ }
+ public int getExtendedState() {
+ return AWTAccessor.getFrameAccessor().getExtendedState((Frame)target);
+ }
+
// Convenience methods to save us from trouble of extracting
// Rectangle fields in native code.
private native void setMaximizedBounds(int x, int y, int w, int h);
diff --git a/jdk/src/windows/native/sun/windows/awt_Frame.cpp b/jdk/src/windows/native/sun/windows/awt_Frame.cpp
index 60738e69357..888ed50b5cb 100644
--- a/jdk/src/windows/native/sun/windows/awt_Frame.cpp
+++ b/jdk/src/windows/native/sun/windows/awt_Frame.cpp
@@ -90,8 +90,10 @@ struct BlockedThreadStruct {
*/
jfieldID AwtFrame::handleID;
-jfieldID AwtFrame::stateID;
+
jfieldID AwtFrame::undecoratedID;
+jmethodID AwtFrame::getExtendedStateMID;
+jmethodID AwtFrame::setExtendedStateMID;
jmethodID AwtFrame::activateEmbeddingTopLevelMID;
@@ -232,7 +234,7 @@ AwtFrame* AwtFrame::Create(jobject self, jobject parent)
frame->InitPeerGraphicsConfig(env, self);
AwtToolkit::GetInstance().RegisterEmbedderProcessId(hwndParent);
} else {
- jint state = env->GetIntField(target, AwtFrame::stateID);
+ jint state = env->CallIntMethod(self, AwtFrame::getExtendedStateMID);
DWORD exStyle;
DWORD style;
@@ -883,6 +885,11 @@ MsgRouting AwtFrame::WmSize(UINT type, int w, int h)
if (changed != 0) {
DTRACE_PRINTLN2("AwtFrame::WmSize: reporting state change %x -> %x",
oldState, newState);
+
+ // sync target with peer
+ JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
+ env->CallVoidMethod(GetPeer(env), AwtFrame::setExtendedStateMID, newState);
+
// report (de)iconification to old clients
if (changed & java_awt_Frame_ICONIFIED) {
if (newState & java_awt_Frame_ICONIFIED) {
@@ -1594,7 +1601,7 @@ void AwtFrame::_NotifyModalBlocked(void *param)
extern "C" {
/*
- * Class: sun_awt_windows_WFramePeer
+ * Class: java_awt_Frame
* Method: initIDs
* Signature: ()V
*/
@@ -1603,15 +1610,31 @@ Java_java_awt_Frame_initIDs(JNIEnv *env, jclass cls)
{
TRY;
- AwtFrame::stateID = env->GetFieldID(cls, "state", "I");
- DASSERT(AwtFrame::stateID != NULL);
-
AwtFrame::undecoratedID = env->GetFieldID(cls,"undecorated","Z");
DASSERT(AwtFrame::undecoratedID != NULL);
CATCH_BAD_ALLOC;
}
+/*
+ * Class: sun_awt_windows_WFramePeer
+ * Method: initIDs
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL
+Java_sun_awt_windows_WFramePeer_initIDs(JNIEnv *env, jclass cls)
+{
+ TRY;
+
+ AwtFrame::setExtendedStateMID = env->GetMethodID(cls, "setExtendedState", "(I)V");
+ AwtFrame::getExtendedStateMID = env->GetMethodID(cls, "getExtendedState", "()I");
+
+ DASSERT(AwtFrame::setExtendedStateMID);
+ DASSERT(AwtFrame::getExtendedStateMID);
+
+ CATCH_BAD_ALLOC;
+}
+
/*
* Class: sun_awt_windows_WFramePeer
* Method: setState
diff --git a/jdk/src/windows/native/sun/windows/awt_Frame.h b/jdk/src/windows/native/sun/windows/awt_Frame.h
index 3634f95924d..65a21655a03 100644
--- a/jdk/src/windows/native/sun/windows/awt_Frame.h
+++ b/jdk/src/windows/native/sun/windows/awt_Frame.h
@@ -48,14 +48,14 @@ public:
FRAME_SETMENUBAR
};
- /* int handle field for sun.awt.windows.WEmbeddedFrame */
+ /* java.awt.Frame fields and method IDs */
+ static jfieldID undecoratedID;
+
+ /* sun.awt.windows.WEmbeddedFrame fields and method IDs */
static jfieldID handleID;
- /* int state field for java.awt.Frame */
- static jfieldID stateID;
-
- /* boolean undecorated field for java.awt.Frame */
- static jfieldID undecoratedID;
+ static jmethodID setExtendedStateMID;
+ static jmethodID getExtendedStateMID;
/* method id for WEmbeddedFrame.requestActivate() method */
static jmethodID activateEmbeddingTopLevelMID;
From 022fb387d9bf5ea16e6599f2f5b55e6802c21310 Mon Sep 17 00:00:00 2001
From: Artem Ananiev
Date: Tue, 17 Feb 2009 10:42:12 +0300
Subject: [PATCH 039/292] 6806035: Fix for 6804680 is incomplete
Reviewed-by: yan
---
.../solaris/classes/sun/awt/X11/generator/sizes.64-solaris-i386 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/jdk/src/solaris/classes/sun/awt/X11/generator/sizes.64-solaris-i386 b/jdk/src/solaris/classes/sun/awt/X11/generator/sizes.64-solaris-i386
index f6e3beb3f1c..29d6603890e 100644
--- a/jdk/src/solaris/classes/sun/awt/X11/generator/sizes.64-solaris-i386
+++ b/jdk/src/solaris/classes/sun/awt/X11/generator/sizes.64-solaris-i386
@@ -774,7 +774,7 @@ AwtGraphicsConfigData.monoPixmapGC 128
AwtGraphicsConfigData.pixelStride 136
AwtGraphicsConfigData.color_data 144
AwtGraphicsConfigData.glxInfo 152
-AwtGraphicsConfigData.isTranslucencySupported 160
+AwtGraphicsConfigData.isTranslucencySupported 160
AwtGraphicsConfigData 168
XColor.pixel 0
XColor.red 8
From 0d79cc7529927349921b4e825f529cb9160beb72 Mon Sep 17 00:00:00 2001
From: Dmitry Cherepanov
Date: Tue, 17 Feb 2009 14:27:03 +0300
Subject: [PATCH 040/292] 6769607: PIT : Modal frame hangs for a while for few
seconds in 6u12 b01 pit build
Reviewed-by: art, anthony
---
jdk/src/share/classes/java/awt/Window.java | 6 +-
.../windows/native/sun/windows/awt_Dialog.cpp | 100 ++++++++++--------
.../windows/native/sun/windows/awt_Dialog.h | 3 +
3 files changed, 64 insertions(+), 45 deletions(-)
diff --git a/jdk/src/share/classes/java/awt/Window.java b/jdk/src/share/classes/java/awt/Window.java
index 64c611ac3c3..e1ff8db14c3 100644
--- a/jdk/src/share/classes/java/awt/Window.java
+++ b/jdk/src/share/classes/java/awt/Window.java
@@ -687,9 +687,9 @@ public class Window extends Container implements Accessible {
}
if (peer == null) {
peer = getToolkit().createWindow(this);
- synchronized (allWindows) {
- allWindows.add(this);
- }
+ }
+ synchronized (allWindows) {
+ allWindows.add(this);
}
super.addNotify();
}
diff --git a/jdk/src/windows/native/sun/windows/awt_Dialog.cpp b/jdk/src/windows/native/sun/windows/awt_Dialog.cpp
index ecf74549d46..77f80b7fac6 100644
--- a/jdk/src/windows/native/sun/windows/awt_Dialog.cpp
+++ b/jdk/src/windows/native/sun/windows/awt_Dialog.cpp
@@ -230,25 +230,8 @@ LRESULT CALLBACK AwtDialog::ModalFilterProc(int code,
if (::IsIconic(hWnd)) {
::ShowWindow(hWnd, SW_RESTORE);
}
- HWND topMostBlocker = blocker;
- HWND toolkitHWnd = AwtToolkit::GetInstance().GetHWnd();
- while (::IsWindow(blocker)) {
- topMostBlocker = blocker;
- // fix for 6494032: restore the blocker if it was minimized
- // together with its parent frame; in such cases the check
- // ::IsIconic() for the blocker returns false, so we use
- // ::IsWindowVisible() instead
- if (!::IsWindowVisible(topMostBlocker) &&
- (topMostBlocker != toolkitHWnd))
- {
- ::ShowWindow(topMostBlocker, SW_SHOWNA);
- }
- ::BringWindowToTop(blocker);
- blocker = AwtWindow::GetModalBlocker(blocker);
- }
- if (topMostBlocker != toolkitHWnd) {
- ::SetForegroundWindow(topMostBlocker);
- }
+ PopupAllDialogs(blocker, TRUE, ::GetForegroundWindow(), FALSE);
+ // return 1 to prevent the system from allowing the operation
return 1;
}
return CallNextHookEx(0, code, wParam, lParam);
@@ -271,30 +254,11 @@ LRESULT CALLBACK AwtDialog::MouseHookProc(int nCode,
(wParam == WM_NCRBUTTONDOWN))
{
HWND blocker = AwtWindow::GetModalBlocker(AwtComponent::GetTopLevelParentForWindow(hWnd));
- HWND topMostBlocker = blocker;
- HWND prevForegroundWindow = ::GetForegroundWindow();
if (::IsWindow(blocker)) {
- ::BringWindowToTop(hWnd);
- }
- while (::IsWindow(blocker)) {
- topMostBlocker = blocker;
- ::BringWindowToTop(blocker);
- blocker = AwtWindow::GetModalBlocker(blocker);
- }
- if (::IsWindow(topMostBlocker)) {
- // no beep/flash if the mouse was clicked in the taskbar menu
- // or the dialog is currently inactive
- if ((::WindowFromPoint(mhs->pt) == hWnd) &&
- (prevForegroundWindow == topMostBlocker))
- {
- ::MessageBeep(MB_OK);
- // some heuristics: 3 times x 64 milliseconds
- AwtWindow::FlashWindowEx(topMostBlocker, 3, 64, FLASHW_CAPTION);
- }
- if (topMostBlocker != AwtToolkit::GetInstance().GetHWnd()) {
- ::BringWindowToTop(topMostBlocker);
- ::SetForegroundWindow(topMostBlocker);
- }
+ BOOL onTaskbar = !(::WindowFromPoint(mhs->pt) == hWnd);
+ PopupAllDialogs(hWnd, FALSE, ::GetForegroundWindow(), onTaskbar);
+ // return a nonzero value to prevent the system from passing
+ // the message to the target window procedure
return 1;
}
}
@@ -303,6 +267,58 @@ LRESULT CALLBACK AwtDialog::MouseHookProc(int nCode,
return CallNextHookEx(0, nCode, wParam, lParam);
}
+/*
+ * The function goes through the heirarchy of the blocker dialogs and
+ * popups all the dialogs. Note that the function starts from the top
+ * blocker dialog and goes down to the dialog which is the bottom dialog.
+ * Using another traversal may cause to the flickering issue as a bottom
+ * dialog will cover a top dialog for some period of time.
+ */
+void AwtDialog::PopupAllDialogs(HWND dialog, BOOL isModalHook, HWND prevFGWindow, BOOL onTaskbar)
+{
+ HWND blocker = AwtWindow::GetModalBlocker(dialog);
+ BOOL isBlocked = ::IsWindow(blocker);
+ if (isBlocked) {
+ PopupAllDialogs(blocker, isModalHook, prevFGWindow, onTaskbar);
+ }
+ PopupOneDialog(dialog, blocker, isModalHook, prevFGWindow, onTaskbar);
+}
+
+/*
+ * The function popups the dialog, it distinguishes non-blocked dialogs
+ * and activates the dialogs (sets as foreground window). If the dialog is
+ * blocked, then it changes the Z-order of the dialog.
+ */
+void AwtDialog::PopupOneDialog(HWND dialog, HWND blocker, BOOL isModalHook, HWND prevFGWindow, BOOL onTaskbar)
+{
+ if (dialog == AwtToolkit::GetInstance().GetHWnd()) {
+ return;
+ }
+
+ // fix for 6494032
+ if (isModalHook && !::IsWindowVisible(dialog)) {
+ ::ShowWindow(dialog, SW_SHOWNA);
+ }
+
+ BOOL isBlocked = ::IsWindow(blocker);
+ UINT flags = SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE;
+
+ if (isBlocked) {
+ ::SetWindowPos(dialog, blocker, 0, 0, 0, 0, flags);
+ } else {
+ ::SetWindowPos(dialog, HWND_TOP, 0, 0, 0, 0, flags);
+ // no beep/flash if the mouse was clicked in the taskbar menu
+ // or the dialog is currently inactive
+ if (!isModalHook && !onTaskbar && (dialog == prevFGWindow)) {
+ ::MessageBeep(MB_OK);
+ // some heuristics: 3 times x 64 milliseconds
+ AwtWindow::FlashWindowEx(dialog, 3, 64, FLASHW_CAPTION);
+ }
+ ::BringWindowToTop(dialog);
+ ::SetForegroundWindow(dialog);
+ }
+}
+
LRESULT CALLBACK AwtDialog::MouseHookProc_NonTT(int nCode,
WPARAM wParam, LPARAM lParam)
{
diff --git a/jdk/src/windows/native/sun/windows/awt_Dialog.h b/jdk/src/windows/native/sun/windows/awt_Dialog.h
index 41ab6ad05b0..5f181e63422 100644
--- a/jdk/src/windows/native/sun/windows/awt_Dialog.h
+++ b/jdk/src/windows/native/sun/windows/awt_Dialog.h
@@ -113,6 +113,9 @@ private:
*/
static void ModalPerformActivation(HWND hWnd);
+ static void PopupAllDialogs(HWND dialog, BOOL isModalHook, HWND prevFGWindow, BOOL onTaskbar);
+ static void PopupOneDialog(HWND dialog, HWND blocker, BOOL isModalHook, HWND prevFGWindow, BOOL onTaskbar);
+
public:
// WH_CBT hook procedure used in modality, prevents modal
From e05fd5d6f5d9aa6aac7874903c290400c2d2501a Mon Sep 17 00:00:00 2001
From: Dmitry Cherepanov
Date: Tue, 17 Feb 2009 14:30:52 +0300
Subject: [PATCH 041/292] 6792023: Print suspends on Windows 2000 Pro since
6u12 b01
Reviewed-by: art, anthony
---
.../windows/native/sun/windows/awt_FileDialog.cpp | 12 ++++++++----
.../windows/native/sun/windows/awt_PrintDialog.cpp | 12 ++++++++----
jdk/src/windows/native/sun/windows/awt_PrintJob.cpp | 12 ++++++++----
jdk/src/windows/native/sun/windows/awt_Window.h | 1 +
4 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/jdk/src/windows/native/sun/windows/awt_FileDialog.cpp b/jdk/src/windows/native/sun/windows/awt_FileDialog.cpp
index 84339e40eee..080e8d42741 100644
--- a/jdk/src/windows/native/sun/windows/awt_FileDialog.cpp
+++ b/jdk/src/windows/native/sun/windows/awt_FileDialog.cpp
@@ -101,7 +101,8 @@ LRESULT CALLBACK FileDialogWndProc(HWND hWnd, UINT message,
}
}
- return ComCtl32Util::GetInstance().DefWindowProc(NULL, hWnd, message, wParam, lParam);
+ WNDPROC lpfnWndProc = (WNDPROC)(::GetProp(hWnd, NativeDialogWndProcProp));
+ return ComCtl32Util::GetInstance().DefWindowProc(lpfnWndProc, hWnd, message, wParam, lParam);
}
static UINT_PTR CALLBACK
@@ -135,16 +136,19 @@ FileDialogHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
}
// subclass dialog's parent to receive additional messages
- ComCtl32Util::GetInstance().SubclassHWND(parent,
- FileDialogWndProc);
+ WNDPROC lpfnWndProc = ComCtl32Util::GetInstance().SubclassHWND(parent,
+ FileDialogWndProc);
+ ::SetProp(parent, NativeDialogWndProcProp, reinterpret_cast(lpfnWndProc));
break;
}
case WM_DESTROY: {
+ WNDPROC lpfnWndProc = (WNDPROC)(::GetProp(parent, NativeDialogWndProcProp));
ComCtl32Util::GetInstance().UnsubclassHWND(parent,
FileDialogWndProc,
- NULL);
+ lpfnWndProc);
::RemoveProp(parent, ModalDialogPeerProp);
+ ::RemoveProp(parent, NativeDialogWndProcProp);
break;
}
case WM_NOTIFY: {
diff --git a/jdk/src/windows/native/sun/windows/awt_PrintDialog.cpp b/jdk/src/windows/native/sun/windows/awt_PrintDialog.cpp
index 762ae2673eb..12b208b9493 100644
--- a/jdk/src/windows/native/sun/windows/awt_PrintDialog.cpp
+++ b/jdk/src/windows/native/sun/windows/awt_PrintDialog.cpp
@@ -65,7 +65,8 @@ LRESULT CALLBACK PrintDialogWndProc(HWND hWnd, UINT message,
}
}
- return ComCtl32Util::GetInstance().DefWindowProc(NULL, hWnd, message, wParam, lParam);
+ WNDPROC lpfnWndProc = (WNDPROC)(::GetProp(hWnd, NativeDialogWndProcProp));
+ return ComCtl32Util::GetInstance().DefWindowProc(lpfnWndProc, hWnd, message, wParam, lParam);
}
static UINT_PTR CALLBACK
@@ -99,16 +100,19 @@ PrintDialogHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
}
// subclass dialog's parent to receive additional messages
- ComCtl32Util::GetInstance().SubclassHWND(hdlg,
- PrintDialogWndProc);
+ WNDPROC lpfnWndProc = ComCtl32Util::GetInstance().SubclassHWND(hdlg,
+ PrintDialogWndProc);
+ ::SetProp(hdlg, NativeDialogWndProcProp, reinterpret_cast(lpfnWndProc));
break;
}
case WM_DESTROY: {
+ WNDPROC lpfnWndProc = (WNDPROC)(::GetProp(hdlg, NativeDialogWndProcProp));
ComCtl32Util::GetInstance().UnsubclassHWND(hdlg,
PrintDialogWndProc,
- NULL);
+ lpfnWndProc);
::RemoveProp(hdlg, ModalDialogPeerProp);
+ ::RemoveProp(hdlg, NativeDialogWndProcProp);
break;
}
}
diff --git a/jdk/src/windows/native/sun/windows/awt_PrintJob.cpp b/jdk/src/windows/native/sun/windows/awt_PrintJob.cpp
index 9136b786412..c3339778695 100644
--- a/jdk/src/windows/native/sun/windows/awt_PrintJob.cpp
+++ b/jdk/src/windows/native/sun/windows/awt_PrintJob.cpp
@@ -2885,7 +2885,8 @@ LRESULT CALLBACK PageDialogWndProc(HWND hWnd, UINT message,
}
}
- return ComCtl32Util::GetInstance().DefWindowProc(NULL, hWnd, message, wParam, lParam);
+ WNDPROC lpfnWndProc = (WNDPROC)(::GetProp(hWnd, NativeDialogWndProcProp));
+ return ComCtl32Util::GetInstance().DefWindowProc(lpfnWndProc, hWnd, message, wParam, lParam);
}
/**
@@ -2919,16 +2920,19 @@ static UINT CALLBACK pageDlgHook(HWND hDlg, UINT msg,
}
// subclass dialog's parent to receive additional messages
- ComCtl32Util::GetInstance().SubclassHWND(hDlg,
- PageDialogWndProc);
+ WNDPROC lpfnWndProc = ComCtl32Util::GetInstance().SubclassHWND(hDlg,
+ PageDialogWndProc);
+ ::SetProp(hDlg, NativeDialogWndProcProp, reinterpret_cast(lpfnWndProc));
break;
}
case WM_DESTROY: {
+ WNDPROC lpfnWndProc = (WNDPROC)(::GetProp(hDlg, NativeDialogWndProcProp));
ComCtl32Util::GetInstance().UnsubclassHWND(hDlg,
PageDialogWndProc,
- NULL);
+ lpfnWndProc);
::RemoveProp(hDlg, ModalDialogPeerProp);
+ ::RemoveProp(hDlg, NativeDialogWndProcProp);
break;
}
}
diff --git a/jdk/src/windows/native/sun/windows/awt_Window.h b/jdk/src/windows/native/sun/windows/awt_Window.h
index a3d57db7b2d..17f05ec164a 100644
--- a/jdk/src/windows/native/sun/windows/awt_Window.h
+++ b/jdk/src/windows/native/sun/windows/awt_Window.h
@@ -34,6 +34,7 @@
// property name tagging windows disabled by modality
static LPCTSTR ModalBlockerProp = TEXT("SunAwtModalBlockerProp");
static LPCTSTR ModalDialogPeerProp = TEXT("SunAwtModalDialogPeerProp");
+static LPCTSTR NativeDialogWndProcProp = TEXT("SunAwtNativeDialogWndProcProp");
#ifndef WH_MOUSE_LL
#define WH_MOUSE_LL 14
From c59552fc2d58cc2393a9f865e2ae13c1f926d5a1 Mon Sep 17 00:00:00 2001
From: Dmitry Cherepanov
Date: Tue, 17 Feb 2009 14:44:58 +0300
Subject: [PATCH 042/292] 6723941: Crash in
sun.awt.windows.WToolkit.eventLoop()
Reviewed-by: art, ant
---
jdk/src/windows/native/sun/windows/awt_Frame.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/jdk/src/windows/native/sun/windows/awt_Frame.cpp b/jdk/src/windows/native/sun/windows/awt_Frame.cpp
index 888ed50b5cb..94bb0050c9e 100644
--- a/jdk/src/windows/native/sun/windows/awt_Frame.cpp
+++ b/jdk/src/windows/native/sun/windows/awt_Frame.cpp
@@ -321,7 +321,8 @@ LRESULT CALLBACK AwtFrame::ProxyWindowProc(HWND hwnd, UINT message,
AwtComponent::GetComponentImpl(::GetParent(hwnd));
if (!parent || parent->GetProxyFocusOwner() != hwnd ||
- message == AwtComponent::WmAwtIsComponent)
+ message == AwtComponent::WmAwtIsComponent ||
+ message == WM_GETOBJECT)
{
return ComCtl32Util::GetInstance().DefWindowProc(NULL, hwnd, message, wParam, lParam);
}
From f1847266b7f75eff1d0ec63a15c71b4666beca18 Mon Sep 17 00:00:00 2001
From: Jon Masamitsu
Date: Tue, 17 Feb 2009 15:35:58 -0800
Subject: [PATCH 043/292] 6786346: intermittent Internal Error
(src/share/vm/memory/cardTableModRefBS.cpp:226)
Two assertions were incorrectly composed.
Reviewed-by: tonyp
---
.../src/share/vm/memory/cardTableModRefBS.cpp | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/hotspot/src/share/vm/memory/cardTableModRefBS.cpp b/hotspot/src/share/vm/memory/cardTableModRefBS.cpp
index ee9ed1fc8be..a47d62b7f1a 100644
--- a/hotspot/src/share/vm/memory/cardTableModRefBS.cpp
+++ b/hotspot/src/share/vm/memory/cardTableModRefBS.cpp
@@ -217,15 +217,28 @@ void CardTableModRefBS::resize_covered_region(MemRegion new_region) {
(HeapWord*) align_size_up((uintptr_t)new_end, _page_size);
assert(new_end_aligned >= (HeapWord*) new_end,
"align up, but less");
+ // Check the other regions (excludes "ind") to ensure that
+ // the new_end_aligned does not intrude onto the committed
+ // space of another region.
int ri = 0;
for (ri = 0; ri < _cur_covered_regions; ri++) {
if (ri != ind) {
if (_committed[ri].contains(new_end_aligned)) {
- assert((new_end_aligned >= _committed[ri].start()) &&
- (_committed[ri].start() > _committed[ind].start()),
+ // The prior check included in the assert
+ // (new_end_aligned >= _committed[ri].start())
+ // is redundant with the "contains" test.
+ // Any region containing the new end
+ // should start at or beyond the region found (ind)
+ // for the new end (committed regions are not expected to
+ // be proper subsets of other committed regions).
+ assert(_committed[ri].start() >= _committed[ind].start(),
"New end of committed region is inconsistent");
new_end_aligned = _committed[ri].start();
- assert(new_end_aligned > _committed[ind].start(),
+ // new_end_aligned can be equal to the start of its
+ // committed region (i.e., of "ind") if a second
+ // region following "ind" also start at the same location
+ // as "ind".
+ assert(new_end_aligned >= _committed[ind].start(),
"New end of committed region is before start");
debug_only(collided = true;)
// Should only collide with 1 region
From 73e8e582ba6980d01e17f5b480b0e4b94beaa374 Mon Sep 17 00:00:00 2001
From: Vladimir Kozlov
Date: Wed, 18 Feb 2009 13:53:42 -0800
Subject: [PATCH 044/292] 6807084: AutoBox elimination is broken with
compressed oops
Add checks for DecodeN nodes into AutoBox elimination code.
Reviewed-by: never
---
hotspot/src/share/vm/opto/memnode.cpp | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/hotspot/src/share/vm/opto/memnode.cpp b/hotspot/src/share/vm/opto/memnode.cpp
index 9c79f2ec936..95e41e0d592 100644
--- a/hotspot/src/share/vm/opto/memnode.cpp
+++ b/hotspot/src/share/vm/opto/memnode.cpp
@@ -1066,11 +1066,11 @@ Node* LoadNode::eliminate_autobox(PhaseGVN* phase) {
break;
}
}
- LoadNode* load = NULL;
- if (allocation != NULL && base->in(load_index)->is_Load()) {
- load = base->in(load_index)->as_Load();
- }
- if (load != NULL && in(Memory)->is_Phi() && in(Memory)->in(0) == base->in(0)) {
+ bool has_load = ( allocation != NULL &&
+ (base->in(load_index)->is_Load() ||
+ base->in(load_index)->is_DecodeN() &&
+ base->in(load_index)->in(1)->is_Load()) );
+ if (has_load && in(Memory)->is_Phi() && in(Memory)->in(0) == base->in(0)) {
// Push the loads from the phi that comes from valueOf up
// through it to allow elimination of the loads and the recovery
// of the original value.
@@ -1106,11 +1106,20 @@ Node* LoadNode::eliminate_autobox(PhaseGVN* phase) {
result->set_req(load_index, in2);
return result;
}
- } else if (base->is_Load()) {
+ } else if (base->is_Load() ||
+ base->is_DecodeN() && base->in(1)->is_Load()) {
+ if (base->is_DecodeN()) {
+ // Get LoadN node which loads cached Integer object
+ base = base->in(1);
+ }
// Eliminate the load of Integer.value for integers from the cache
// array by deriving the value from the index into the array.
// Capture the offset of the load and then reverse the computation.
Node* load_base = base->in(Address)->in(AddPNode::Base);
+ if (load_base->is_DecodeN()) {
+ // Get LoadN node which loads IntegerCache.cache field
+ load_base = load_base->in(1);
+ }
if (load_base != NULL) {
Compile::AliasType* atp = phase->C->alias_type(load_base->adr_type());
intptr_t cache_offset;
From dcbd65a1c35d8e693d35275ae2a92e7ce891d32b Mon Sep 17 00:00:00 2001
From: Kumar Srinivasan
Date: Wed, 18 Feb 2009 14:14:03 -0800
Subject: [PATCH 045/292] 6792554: Java JAR Pack200 header checks are
insufficent
Added several checks to ensure that the values read from the headers are consistent
Reviewed-by: jrose
---
.../com/sun/java/util/jar/pack/bands.cpp | 15 +-
.../com/sun/java/util/jar/pack/coding.cpp | 3 +-
.../com/sun/java/util/jar/pack/defines.h | 4 +-
.../com/sun/java/util/jar/pack/unpack.cpp | 85 +++-
.../tools/pack200/MemoryAllocatorTest.java | 369 ------------------
5 files changed, 97 insertions(+), 379 deletions(-)
delete mode 100644 jdk/test/tools/pack200/MemoryAllocatorTest.java
diff --git a/jdk/src/share/native/com/sun/java/util/jar/pack/bands.cpp b/jdk/src/share/native/com/sun/java/util/jar/pack/bands.cpp
index d900404dec4..e96d61c6b06 100644
--- a/jdk/src/share/native/com/sun/java/util/jar/pack/bands.cpp
+++ b/jdk/src/share/native/com/sun/java/util/jar/pack/bands.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2002-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -94,6 +94,7 @@ void band::readData(int expectedLength) {
assert(!valc->isMalloc);
}
xvs.init(u->rp, u->rplimit, valc);
+ CHECK;
int X = xvs.getInt();
if (valc->S() != 0) {
assert(valc->min <= -256);
@@ -117,6 +118,7 @@ void band::readData(int expectedLength) {
byte XB_byte = (byte) XB;
byte* XB_ptr = &XB_byte;
cm.init(u->rp, u->rplimit, XB_ptr, 0, defc, length, null);
+ CHECK;
} else {
NOT_PRODUCT(byte* meta_rp0 = u->meta_rp);
assert(u->meta_rp != null);
@@ -215,8 +217,19 @@ int band::getIntTotal() {
if (length == 0) return 0;
if (total_memo > 0) return total_memo-1;
int total = getInt();
+ // overflow checks require that none of the addends are <0,
+ // and that the partial sums never overflow (wrap negative)
+ if (total < 0) {
+ abort("overflow detected");
+ return 0;
+ }
for (int k = length-1; k > 0; k--) {
+ int prev_total = total;
total += vs[0].getInt();
+ if (total < prev_total) {
+ abort("overflow detected");
+ return 0;
+ }
}
rewind();
total_memo = total+1;
diff --git a/jdk/src/share/native/com/sun/java/util/jar/pack/coding.cpp b/jdk/src/share/native/com/sun/java/util/jar/pack/coding.cpp
index d3ec4ae0e22..713ca999c98 100644
--- a/jdk/src/share/native/com/sun/java/util/jar/pack/coding.cpp
+++ b/jdk/src/share/native/com/sun/java/util/jar/pack/coding.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2002-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -809,6 +809,7 @@ void coding_method::init(byte* &band_rp, byte* band_limit,
}
band_rp = vs.rp;
}
+ CHECK;
// Get an accurate upper limit now.
vs0.rplimit = band_rp;
diff --git a/jdk/src/share/native/com/sun/java/util/jar/pack/defines.h b/jdk/src/share/native/com/sun/java/util/jar/pack/defines.h
index f780f247b2a..fa280ffb054 100644
--- a/jdk/src/share/native/com/sun/java/util/jar/pack/defines.h
+++ b/jdk/src/share/native/com/sun/java/util/jar/pack/defines.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -155,6 +155,8 @@ enum { false, true };
#define CHECK_NULL_(y,p) _CHECK_DO((p)==null, return y)
#define CHECK_NULL_0(p) _CHECK_DO((p)==null, return 0)
+#define CHECK_COUNT(t) if (t < 0){abort("bad value count");} CHECK
+
#define STR_TRUE "true"
#define STR_FALSE "false"
diff --git a/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.cpp b/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.cpp
index 08fbbc2aa4a..e3a6945f30b 100644
--- a/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.cpp
+++ b/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -504,15 +504,39 @@ void unpacker::read_file_header() {
enum {
MAGIC_BYTES = 4,
AH_LENGTH_0 = 3, //minver, majver, options are outside of archive_size
+ AH_LENGTH_0_MAX = AH_LENGTH_0 + 1, // options might have 2 bytes
AH_LENGTH = 26, //maximum archive header length (w/ all fields)
// Length contributions from optional header fields:
AH_FILE_HEADER_LEN = 5, // sizehi/lo/next/modtime/files
+ AH_ARCHIVE_SIZE_LEN = 2, // sizehi/lo only; part of AH_FILE_HEADER_LEN
AH_CP_NUMBER_LEN = 4, // int/float/long/double
AH_SPECIAL_FORMAT_LEN = 2, // layouts/band-headers
AH_LENGTH_MIN = AH_LENGTH
-(AH_FILE_HEADER_LEN+AH_SPECIAL_FORMAT_LEN+AH_CP_NUMBER_LEN),
+ ARCHIVE_SIZE_MIN = AH_LENGTH_MIN - (AH_LENGTH_0 + AH_ARCHIVE_SIZE_LEN),
FIRST_READ = MAGIC_BYTES + AH_LENGTH_MIN
};
+
+ assert(AH_LENGTH_MIN == 15); // # of UNSIGNED5 fields required after archive_magic
+ assert(ARCHIVE_SIZE_MIN == 10); // # of UNSIGNED5 fields required after archive_size
+ // An absolute minimum null archive is magic[4], {minver,majver,options}[3],
+ // archive_size[0], cp_counts[8], class_counts[4], for a total of 19 bytes.
+ // (Note that archive_size is optional; it may be 0..10 bytes in length.)
+ // The first read must capture everything up through the options field.
+ // This happens to work even if {minver,majver,options} is a pathological
+ // 15 bytes long. Legal pack files limit those three fields to 1+1+2 bytes.
+ assert(FIRST_READ >= MAGIC_BYTES + AH_LENGTH_0 * B_MAX);
+
+ // Up through archive_size, the largest possible archive header is
+ // magic[4], {minver,majver,options}[4], archive_size[10].
+ // (Note only the low 12 bits of options are allowed to be non-zero.)
+ // In order to parse archive_size, we need at least this many bytes
+ // in the first read. Of course, if archive_size_hi is more than
+ // a byte, we probably will fail to allocate the buffer, since it
+ // will be many gigabytes long. This is a practical, not an
+ // architectural limit to Pack200 archive sizes.
+ assert(FIRST_READ >= MAGIC_BYTES + AH_LENGTH_0_MAX + 2*B_MAX);
+
bool foreign_buf = (read_input_fn == null);
byte initbuf[FIRST_READ + C_SLOP + 200]; // 200 is for JAR I/O
if (foreign_buf) {
@@ -528,7 +552,7 @@ void unpacker::read_file_header() {
// There is no way to tell the caller that we used only part of them.
// Therefore, the caller must use only a bare minimum of read-ahead.
if (inbytes.len > FIRST_READ) {
- abort("too much pushback");
+ abort("too much read-ahead");
return;
}
input.set(initbuf, sizeof(initbuf));
@@ -538,7 +562,7 @@ void unpacker::read_file_header() {
rplimit += inbytes.len;
bytes_read += inbytes.len;
}
- // Read only 19 bytes, which is certain to contain #archive_size fields,
+ // Read only 19 bytes, which is certain to contain #archive_options fields,
// but is certain not to overflow past the archive_header.
input.b.len = FIRST_READ;
if (!ensure_input(FIRST_READ))
@@ -610,9 +634,9 @@ void unpacker::read_file_header() {
#undef ORBIT
if ((archive_options & ~OPTION_LIMIT) != 0) {
fprintf(errstrm, "Warning: Illegal archive options 0x%x\n",
- archive_options);
- // Do not abort. If the format really changes, version numbers will bump.
- //abort("illegal archive options");
+ archive_options);
+ abort("illegal archive options");
+ return;
}
if ((archive_options & AO_HAVE_FILE_HEADERS) != 0) {
@@ -643,8 +667,17 @@ void unpacker::read_file_header() {
return;
}
} else if (archive_size != 0) {
+ if (archive_size < ARCHIVE_SIZE_MIN) {
+ abort("impossible archive size"); // bad input data
+ return;
+ }
+ if (archive_size < header_size_1) {
+ abort("too much read-ahead"); // somehow we pre-fetched too much?
+ return;
+ }
input.set(U_NEW(byte, add_size(header_size_0, archive_size, C_SLOP)),
(size_t) header_size_0 + archive_size);
+ CHECK;
assert(input.limit()[0] == 0);
// Move all the bytes we read initially into the real buffer.
input.b.copyFrom(initbuf, header_size);
@@ -659,6 +692,7 @@ void unpacker::read_file_header() {
rp = rplimit = input.base();
// Set up input buffer as if we already read the header:
input.b.copyFrom(initbuf, header_size);
+ CHECK;
rplimit += header_size;
while (ensure_input(input.limit() - rp)) {
size_t dataSoFar = input_remaining();
@@ -694,8 +728,10 @@ void unpacker::read_file_header() {
if ((archive_options & AO_HAVE_FILE_HEADERS) != 0) {
archive_next_count = hdr.getInt();
+ CHECK_COUNT(archive_next_count);
archive_modtime = hdr.getInt();
file_count = hdr.getInt();
+ CHECK_COUNT(file_count);
hdrVals += 3;
} else {
hdrValsSkipped += 3;
@@ -703,7 +739,9 @@ void unpacker::read_file_header() {
if ((archive_options & AO_HAVE_SPECIAL_FORMATS) != 0) {
band_headers_size = hdr.getInt();
+ CHECK_COUNT(band_headers_size);
attr_definition_count = hdr.getInt();
+ CHECK_COUNT(attr_definition_count);
hdrVals += 2;
} else {
hdrValsSkipped += 2;
@@ -723,13 +761,16 @@ void unpacker::read_file_header() {
}
}
cp_counts[k] = hdr.getInt();
+ CHECK_COUNT(cp_counts[k]);
hdrVals += 1;
}
ic_count = hdr.getInt();
+ CHECK_COUNT(ic_count);
default_class_minver = hdr.getInt();
default_class_majver = hdr.getInt();
class_count = hdr.getInt();
+ CHECK_COUNT(class_count);
hdrVals += 4;
// done with archive_header
@@ -783,7 +824,6 @@ void unpacker::read_file_header() {
bytes::of(band_headers.limit(), C_SLOP).clear(_meta_error);
}
-
void unpacker::finish() {
if (verbose >= 1) {
fprintf(errstrm,
@@ -2089,6 +2129,7 @@ void unpacker::read_classes() {
field_descr.readData(field_count);
read_attrs(ATTR_CONTEXT_FIELD, field_count);
+ CHECK;
method_descr.readData(method_count);
read_attrs(ATTR_CONTEXT_METHOD, method_count);
@@ -2096,6 +2137,7 @@ void unpacker::read_classes() {
CHECK;
read_attrs(ATTR_CONTEXT_CLASS, class_count);
+ CHECK;
read_code_headers();
@@ -2122,10 +2164,12 @@ void unpacker::read_attrs(int attrc, int obj_count) {
assert(endsWith(xxx_flags_hi.name, "_flags_hi"));
if (haveLongFlags)
xxx_flags_hi.readData(obj_count);
+ CHECK;
band& xxx_flags_lo = ad.xxx_flags_lo();
assert(endsWith(xxx_flags_lo.name, "_flags_lo"));
xxx_flags_lo.readData(obj_count);
+ CHECK;
// pre-scan flags, counting occurrences of each index bit
julong indexMask = ad.flagIndexMask(); // which flag bits are index bits?
@@ -2148,11 +2192,13 @@ void unpacker::read_attrs(int attrc, int obj_count) {
assert(endsWith(xxx_attr_count.name, "_attr_count"));
// There is one count element for each 1<<16 bit set in flags:
xxx_attr_count.readData(ad.predefCount(X_ATTR_OVERFLOW));
+ CHECK;
band& xxx_attr_indexes = ad.xxx_attr_indexes();
assert(endsWith(xxx_attr_indexes.name, "_attr_indexes"));
int overflowIndexCount = xxx_attr_count.getIntTotal();
xxx_attr_indexes.readData(overflowIndexCount);
+ CHECK;
// pre-scan attr indexes, counting occurrences of each value
for (i = 0; i < overflowIndexCount; i++) {
idx = xxx_attr_indexes.getInt();
@@ -2183,6 +2229,7 @@ void unpacker::read_attrs(int attrc, int obj_count) {
}
}
ad.xxx_attr_calls().readData(backwardCounts);
+ CHECK;
// Read built-in bands.
// Mostly, these are hand-coded equivalents to readBandData().
@@ -2191,42 +2238,53 @@ void unpacker::read_attrs(int attrc, int obj_count) {
count = ad.predefCount(CLASS_ATTR_SourceFile);
class_SourceFile_RUN.readData(count);
+ CHECK;
count = ad.predefCount(CLASS_ATTR_EnclosingMethod);
class_EnclosingMethod_RC.readData(count);
class_EnclosingMethod_RDN.readData(count);
+ CHECK;
count = ad.predefCount(X_ATTR_Signature);
class_Signature_RS.readData(count);
+ CHECK;
ad.readBandData(X_ATTR_RuntimeVisibleAnnotations);
ad.readBandData(X_ATTR_RuntimeInvisibleAnnotations);
count = ad.predefCount(CLASS_ATTR_InnerClasses);
class_InnerClasses_N.readData(count);
+ CHECK;
+
count = class_InnerClasses_N.getIntTotal();
class_InnerClasses_RC.readData(count);
class_InnerClasses_F.readData(count);
+ CHECK;
// Drop remaining columns wherever flags are zero:
count -= class_InnerClasses_F.getIntCount(0);
class_InnerClasses_outer_RCN.readData(count);
class_InnerClasses_name_RUN.readData(count);
+ CHECK;
count = ad.predefCount(CLASS_ATTR_ClassFile_version);
class_ClassFile_version_minor_H.readData(count);
class_ClassFile_version_major_H.readData(count);
+ CHECK;
break;
case ATTR_CONTEXT_FIELD:
count = ad.predefCount(FIELD_ATTR_ConstantValue);
field_ConstantValue_KQ.readData(count);
+ CHECK;
count = ad.predefCount(X_ATTR_Signature);
field_Signature_RS.readData(count);
+ CHECK;
ad.readBandData(X_ATTR_RuntimeVisibleAnnotations);
ad.readBandData(X_ATTR_RuntimeInvisibleAnnotations);
+ CHECK;
break;
case ATTR_CONTEXT_METHOD:
@@ -2238,15 +2296,18 @@ void unpacker::read_attrs(int attrc, int obj_count) {
method_Exceptions_N.readData(count);
count = method_Exceptions_N.getIntTotal();
method_Exceptions_RC.readData(count);
+ CHECK;
count = ad.predefCount(X_ATTR_Signature);
method_Signature_RS.readData(count);
+ CHECK;
ad.readBandData(X_ATTR_RuntimeVisibleAnnotations);
ad.readBandData(X_ATTR_RuntimeInvisibleAnnotations);
ad.readBandData(METHOD_ATTR_RuntimeVisibleParameterAnnotations);
ad.readBandData(METHOD_ATTR_RuntimeInvisibleParameterAnnotations);
ad.readBandData(METHOD_ATTR_AnnotationDefault);
+ CHECK;
break;
case ATTR_CONTEXT_CODE:
@@ -2258,8 +2319,10 @@ void unpacker::read_attrs(int attrc, int obj_count) {
return;
}
code_StackMapTable_N.readData(count);
+ CHECK;
count = code_StackMapTable_N.getIntTotal();
code_StackMapTable_frame_T.readData(count);
+ CHECK;
// the rest of it depends in a complicated way on frame tags
{
int fat_frame_count = 0;
@@ -2293,18 +2356,23 @@ void unpacker::read_attrs(int attrc, int obj_count) {
// deal completely with fat frames:
offset_count += fat_frame_count;
code_StackMapTable_local_N.readData(fat_frame_count);
+ CHECK;
type_count += code_StackMapTable_local_N.getIntTotal();
code_StackMapTable_stack_N.readData(fat_frame_count);
type_count += code_StackMapTable_stack_N.getIntTotal();
+ CHECK;
// read the rest:
code_StackMapTable_offset.readData(offset_count);
code_StackMapTable_T.readData(type_count);
+ CHECK;
// (7) [RCH]
count = code_StackMapTable_T.getIntCount(7);
code_StackMapTable_RC.readData(count);
+ CHECK;
// (8) [PH]
count = code_StackMapTable_T.getIntCount(8);
code_StackMapTable_P.readData(count);
+ CHECK;
}
count = ad.predefCount(CODE_ATTR_LineNumberTable);
@@ -2626,6 +2694,7 @@ void unpacker::read_code_headers() {
code_max_na_locals.readData();
code_handler_count.readData();
totalHandlerCount += code_handler_count.getIntTotal();
+ CHECK;
// Read handler specifications.
// Cf. PackageReader.readCodeHandlers.
@@ -2633,8 +2702,10 @@ void unpacker::read_code_headers() {
code_handler_end_PO.readData(totalHandlerCount);
code_handler_catch_PO.readData(totalHandlerCount);
code_handler_class_RCN.readData(totalHandlerCount);
+ CHECK;
read_attrs(ATTR_CONTEXT_CODE, totalFlagsCount);
+ CHECK;
}
static inline bool is_in_range(uint n, uint min, uint max) {
diff --git a/jdk/test/tools/pack200/MemoryAllocatorTest.java b/jdk/test/tools/pack200/MemoryAllocatorTest.java
deleted file mode 100644
index 6015a4e470d..00000000000
--- a/jdk/test/tools/pack200/MemoryAllocatorTest.java
+++ /dev/null
@@ -1,369 +0,0 @@
-/*
- * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-/*
- * @test
- * @bug 6755943
- * @summary Checks any memory overruns in archive length.
- * @run main/timeout=1200 MemoryAllocatorTest
- */
-import java.io.BufferedReader;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.RandomAccessFile;
-import java.nio.MappedByteBuffer;
-import java.nio.channels.FileChannel;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-public class MemoryAllocatorTest {
-
- /*
- * The smallest possible pack file with 1 empty resource
- */
- static int[] magic = {
- 0xCA, 0xFE, 0xD0, 0x0D
- };
- static int[] version_info = {
- 0x07, // minor
- 0x96 // major
- };
- static int[] option = {
- 0x10
- };
- static int[] size_hi = {
- 0x00
- };
- static int[] size_lo_ulong = {
- 0xFF, 0xFC, 0xFC, 0xFC, 0xFC // ULONG_MAX 0xFFFFFFFF
- };
- static int[] size_lo_correct = {
- 0x17
- };
- static int[] data = {
- 0x00, 0xEC, 0xDA, 0xDE, 0xF8, 0x45, 0x01, 0x02,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01, 0x31, 0x01, 0x00
- };
- // End of pack file data
-
- static final String JAVA_HOME = System.getProperty("java.home");
-
- static final boolean debug = Boolean.getBoolean("MemoryAllocatorTest.Debug");
- static final boolean WINDOWS = System.getProperty("os.name").startsWith("Windows");
- static final boolean LINUX = System.getProperty("os.name").startsWith("Linux");
- static final boolean SIXTYFOUR_BIT = System.getProperty("sun.arch.data.model", "32").equals("64");
- static final private int EXPECTED_EXIT_CODE = (WINDOWS) ? -1 : 255;
-
- static int testExitValue = 0;
-
- static byte[] bytes(int[] a) {
- byte[] b = new byte[a.length];
- for (int i = 0; i < b.length; i++) {
- b[i] = (byte) a[i];
- }
- return b;
- }
-
- static void createPackFile(boolean good, File packFile) throws IOException {
- FileOutputStream fos = new FileOutputStream(packFile);
- fos.write(bytes(magic));
- fos.write(bytes(version_info));
- fos.write(bytes(option));
- fos.write(bytes(size_hi));
- if (good) {
- fos.write(bytes(size_lo_correct));
- } else {
- fos.write(bytes(size_lo_ulong));
- }
- fos.write(bytes(data));
- }
-
- /*
- * This method modifies the LSB of the size_lo for various wicked
- * values between MAXINT-0x3F and MAXINT.
- */
- static int modifyPackFile(File packFile) throws IOException {
- RandomAccessFile raf = new RandomAccessFile(packFile, "rws");
- long len = packFile.length();
- FileChannel fc = raf.getChannel();
- MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_WRITE, 0, len);
- int pos = magic.length + version_info.length + option.length +
- size_hi.length;
- byte value = bb.get(pos);
- value--;
- bb.position(pos);
- bb.put(value);
- bb.force();
- fc.truncate(len);
- fc.close();
- return value & 0xFF;
- }
-
- static String getUnpack200Cmd() throws Exception {
- File binDir = new File(JAVA_HOME, "bin");
- File unpack200File = WINDOWS
- ? new File(binDir, "unpack200.exe")
- : new File(binDir, "unpack200");
-
- String cmd = unpack200File.getAbsolutePath();
- if (!unpack200File.canExecute()) {
- throw new Exception("please check" +
- cmd + " exists and is executable");
- }
- return cmd;
- }
-
- static TestResult runUnpacker(File packFile) throws Exception {
- if (!packFile.exists()) {
- throw new Exception("please check" + packFile + " exists");
- }
- ArrayList alist = new ArrayList();
- ProcessBuilder pb = new ProcessBuilder(getUnpack200Cmd(),
- packFile.getName(), "testout.jar");
- Map env = pb.environment();
- pb.directory(new File("."));
- int retval = 0;
- try {
- pb.redirectErrorStream(true);
- Process p = pb.start();
- BufferedReader rd = new BufferedReader(
- new InputStreamReader(p.getInputStream()), 8192);
- String in = rd.readLine();
- while (in != null) {
- alist.add(in);
- System.out.println(in);
- in = rd.readLine();
- }
- retval = p.waitFor();
- p.destroy();
- } catch (Exception ex) {
- ex.printStackTrace();
- throw new RuntimeException(ex.getMessage());
- }
- return new TestResult("", retval, alist);
- }
-
- /*
- * The debug version builds of unpack200 call abort(3) which might set
- * an unexpected return value, therefore this test is to determine
- * if we are using a product or non-product build and check the
- * return value appropriately.
- */
- static boolean isNonProductVersion() throws Exception {
- ArrayList alist = new ArrayList();
- ProcessBuilder pb = new ProcessBuilder(getUnpack200Cmd(), "--version");
- Map env = pb.environment();
- pb.directory(new File("."));
- int retval = 0;
- try {
- pb.redirectErrorStream(true);
- Process p = pb.start();
- BufferedReader rd = new BufferedReader(
- new InputStreamReader(p.getInputStream()), 8192);
- String in = rd.readLine();
- while (in != null) {
- alist.add(in);
- System.out.println(in);
- in = rd.readLine();
- }
- retval = p.waitFor();
- p.destroy();
- } catch (Exception ex) {
- ex.printStackTrace();
- throw new RuntimeException(ex.getMessage());
- }
- for (String x : alist) {
- if (x.contains("non-product")) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * @param args the command line arguments
- * @throws java.lang.Exception
- */
- public static void main(String[] args) throws Exception {
-
- File packFile = new File("tiny.pack");
- boolean isNPVersion = isNonProductVersion();
-
- // Create a good pack file and test if everything is ok
- createPackFile(true, packFile);
- TestResult tr = runUnpacker(packFile);
- tr.setDescription("a good pack file");
- tr.checkPositive();
- tr.isOK();
- System.out.println(tr);
-
- /*
- * jprt systems on windows and linux seem to have abundant memory
- * therefore can take a very long time to run, and even if it does
- * the error message is not accurate for us to discern if the test
- * passess successfully.
- */
- if (SIXTYFOUR_BIT && (LINUX || WINDOWS)) {
- System.out.println("Warning: Windows/Linux 64bit tests passes vacuously");
- return;
- }
-
- /*
- * debug builds call abort, the exit code under these conditions
- * are not really relevant.
- */
- if (isNPVersion) {
- System.out.println("Warning: non-product build: exit values not checked");
- }
-
- // create a bad pack file
- createPackFile(false, packFile);
- tr = runUnpacker(packFile);
- tr.setDescription("a wicked pack file");
- tr.contains("Native allocation failed");
- if(!isNPVersion) {
- tr.checkValue(EXPECTED_EXIT_CODE);
- }
- System.out.println(tr);
- int value = modifyPackFile(packFile);
- tr.setDescription("value=" + value);
-
- // continue creating bad pack files by modifying the specimen pack file.
- while (value >= 0xc0) {
- tr = runUnpacker(packFile);
- tr.contains("Native allocation failed");
- if (!isNPVersion) {
- tr.checkValue(EXPECTED_EXIT_CODE);
- }
- tr.setDescription("wicked value=0x" +
- Integer.toHexString(value & 0xFF));
- System.out.println(tr);
- value = modifyPackFile(packFile);
- }
- if (testExitValue != 0) {
- throw new Exception("Pack200 archive length tests(" +
- testExitValue + ") failed ");
- } else {
- System.out.println("All tests pass");
- }
- }
-
- /*
- * A class to encapsulate the test results and stuff, with some ease
- * of use methods to check the test results.
- */
- static class TestResult {
-
- StringBuilder status;
- int exitValue;
- List testOutput;
- String description;
-
- public TestResult(String str, int rv, List oList) {
- status = new StringBuilder(str);
- exitValue = rv;
- testOutput = oList;
- }
-
- void setDescription(String description) {
- this.description = description;
- }
-
- void checkValue(int value) {
- if (exitValue != value) {
- status =
- status.append(" Error: test expected exit value " +
- value + "got " + exitValue);
- testExitValue++;
- }
- }
-
- void checkNegative() {
- if (exitValue == 0) {
- status = status.append(
- " Error: test did not expect 0 exit value");
-
- testExitValue++;
- }
- }
-
- void checkPositive() {
- if (exitValue != 0) {
- status = status.append(
- " Error: test did not return 0 exit value");
- testExitValue++;
- }
- }
-
- boolean isOK() {
- return exitValue == 0;
- }
-
- boolean isZeroOutput() {
- if (!testOutput.isEmpty()) {
- status = status.append(" Error: No message from cmd please");
- testExitValue++;
- return false;
- }
- return true;
- }
-
- boolean isNotZeroOutput() {
- if (testOutput.isEmpty()) {
- status = status.append(" Error: Missing message");
- testExitValue++;
- return false;
- }
- return true;
- }
-
- public String toString() {
- if (debug) {
- for (String x : testOutput) {
- status = status.append(x + "\n");
- }
- }
- if (description != null) {
- status.insert(0, description);
- }
- return status.append("\nexitValue = " + exitValue).toString();
- }
-
- boolean contains(String str) {
- for (String x : testOutput) {
- if (x.contains(str)) {
- return true;
- }
- }
- status = status.append(" Error: string <" + str + "> not found ");
- testExitValue++;
- return false;
- }
- }
-}
From 6aec7d2ea914a6afb8dcd4a6a921b1ff54ba9b15 Mon Sep 17 00:00:00 2001
From: Ivan P Krylov
Date: Thu, 19 Feb 2009 04:54:22 -0500
Subject: [PATCH 046/292] 6806046: Hotspot build error when compiled from
Visual Studio
Define HOTSPOT_LIB_ARCH in the preprocessor flags of the generated projects
Reviewed-by: kamg, xlu
---
hotspot/src/share/tools/MakeDeps/BuildConfig.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/hotspot/src/share/tools/MakeDeps/BuildConfig.java b/hotspot/src/share/tools/MakeDeps/BuildConfig.java
index 442972dab9c..accdab67550 100644
--- a/hotspot/src/share/tools/MakeDeps/BuildConfig.java
+++ b/hotspot/src/share/tools/MakeDeps/BuildConfig.java
@@ -247,6 +247,7 @@ class BuildConfig {
sysDefines.add("HOTSPOT_BUILD_USER="+System.getProperty("user.name"));
sysDefines.add("HOTSPOT_BUILD_TARGET=\\\""+get("Build")+"\\\"");
sysDefines.add("_JNI_IMPLEMENTATION_");
+ sysDefines.add("HOTSPOT_LIB_ARCH=\\\"i486\\\"");
sysDefines.addAll(defines);
From a1117d31b6e286fb36264f36827c1cd7efb41373 Mon Sep 17 00:00:00 2001
From: Dmitry Cherepanov
Date: Thu, 19 Feb 2009 14:10:19 +0300
Subject: [PATCH 047/292] 6806224: PIT : Getting java.lang.NullPointerException
while opening Filedialog
Reviewed-by: art, dav
---
.../classes/sun/awt/X11/XComponentPeer.java | 6 +---
.../classes/sun/awt/X11/XFileDialogPeer.java | 30 ++++++++-----------
2 files changed, 14 insertions(+), 22 deletions(-)
diff --git a/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java
index 8a14cfe5f0f..46c4a8768f0 100644
--- a/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java
+++ b/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java
@@ -166,7 +166,7 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget
enableLog.log(Level.FINE, "Initial enable state: {0}", new Object[] {Boolean.valueOf(enabled)});
if (target.isVisible()) {
- show();
+ setVisible(true);
}
}
@@ -496,10 +496,6 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget
xSetVisible(b);
}
- public void show() {
- setVisible(true);
- }
-
public void hide() {
setVisible(false);
}
diff --git a/jdk/src/solaris/classes/sun/awt/X11/XFileDialogPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XFileDialogPeer.java
index 0675847af79..0b8085e759d 100644
--- a/jdk/src/solaris/classes/sun/awt/X11/XFileDialogPeer.java
+++ b/jdk/src/solaris/classes/sun/awt/X11/XFileDialogPeer.java
@@ -739,7 +739,17 @@ class XFileDialogPeer extends XDialogPeer implements FileDialogPeer, ActionListe
this.filter = filter;
}
- public void show() {
+
+ public void dispose() {
+ FileDialog fd = (FileDialog)fileDialog;
+ if (fd != null) {
+ fd.removeAll();
+ }
+ super.dispose();
+ }
+
+ // 03/02/2005 b5097243 Pressing 'ESC' on a file dlg does not dispose the dlg on Xtoolkit
+ public void setVisible(boolean b){
if (fileDialog == null) {
init((FileDialog)target);
}
@@ -754,34 +764,20 @@ class XFileDialogPeer extends XDialogPeer implements FileDialogPeer, ActionListe
setFile(savedFile);
}
- super.show();
- selectionField.requestFocusInWindow();
- }
-
- public void dispose() {
- FileDialog fd = (FileDialog)fileDialog;
- if (fd != null) {
- fd.removeAll();
- }
- super.dispose();
- }
-
- // 03/02/2005 b5097243 Pressing 'ESC' on a file dlg does not dispose the dlg on Xtoolkit
- public void setVisible(boolean b){
super.setVisible(b);
if (b == true){
// See 6240074 for more information
XChoicePeer choicePeer = (XChoicePeer)pathChoice.getPeer();
choicePeer.addXChoicePeerListener(this);
-
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(this);
}else{
// See 6240074 for more information
XChoicePeer choicePeer = (XChoicePeer)pathChoice.getPeer();
choicePeer.removeXChoicePeerListener();
-
KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventDispatcher(this);
}
+
+ selectionField.requestFocusInWindow();
}
/*
From dc3008a5136187865130ec9f4acaf330cc256140 Mon Sep 17 00:00:00 2001
From: Vladimir Kozlov
Date: Thu, 19 Feb 2009 17:38:53 -0800
Subject: [PATCH 048/292] 6802499: EA: assert(false,"unknown node on this
path")
Add missing checks for SCMemProj node in Escape analysis code.
Reviewed-by: never
---
hotspot/src/share/vm/opto/escape.cpp | 10 ++++++++++
hotspot/src/share/vm/opto/macro.cpp | 16 ++++++++++++++++
2 files changed, 26 insertions(+)
diff --git a/hotspot/src/share/vm/opto/escape.cpp b/hotspot/src/share/vm/opto/escape.cpp
index bccfb9c64ba..2606d0df82a 100644
--- a/hotspot/src/share/vm/opto/escape.cpp
+++ b/hotspot/src/share/vm/opto/escape.cpp
@@ -756,6 +756,16 @@ Node* ConnectionGraph::find_inst_mem(Node *orig_mem, int alias_idx, GrowableArra
} else {
break;
}
+ } else if (result->Opcode() == Op_SCMemProj) {
+ assert(result->in(0)->is_LoadStore(), "sanity");
+ const Type *at = phase->type(result->in(0)->in(MemNode::Address));
+ if (at != Type::TOP) {
+ assert (at->isa_ptr() != NULL, "pointer type required.");
+ int idx = C->get_alias_index(at->is_ptr());
+ assert(idx != alias_idx, "Object is not scalar replaceable if a LoadStore node access its field");
+ break;
+ }
+ result = result->in(0)->in(MemNode::Memory);
}
}
if (result->is_Phi()) {
diff --git a/hotspot/src/share/vm/opto/macro.cpp b/hotspot/src/share/vm/opto/macro.cpp
index f77b14ada56..857568b6d05 100644
--- a/hotspot/src/share/vm/opto/macro.cpp
+++ b/hotspot/src/share/vm/opto/macro.cpp
@@ -250,6 +250,15 @@ static Node *scan_mem_chain(Node *mem, int alias_idx, int offset, Node *start_me
assert(adr_idx == Compile::AliasIdxRaw, "address must match or be raw");
}
mem = mem->in(MemNode::Memory);
+ } else if (mem->Opcode() == Op_SCMemProj) {
+ assert(mem->in(0)->is_LoadStore(), "sanity");
+ const TypePtr* atype = mem->in(0)->in(MemNode::Address)->bottom_type()->is_ptr();
+ int adr_idx = Compile::current()->get_alias_index(atype);
+ if (adr_idx == alias_idx) {
+ assert(false, "Object is not scalar replaceable if a LoadStore node access its field");
+ return NULL;
+ }
+ mem = mem->in(0)->in(MemNode::Memory);
} else {
return mem;
}
@@ -329,8 +338,15 @@ Node *PhaseMacroExpand::value_from_mem_phi(Node *mem, BasicType ft, const Type *
return NULL;
}
values.at_put(j, val);
+ } else if (val->Opcode() == Op_SCMemProj) {
+ assert(val->in(0)->is_LoadStore(), "sanity");
+ assert(false, "Object is not scalar replaceable if a LoadStore node access its field");
+ return NULL;
} else {
+#ifdef ASSERT
+ val->dump();
assert(false, "unknown node on this path");
+#endif
return NULL; // unknown node on this path
}
}
From 22f94de7e6abdcf00ef9893416ccf5c0c3436ab8 Mon Sep 17 00:00:00 2001
From: Andrew Brygin
Date: Fri, 20 Feb 2009 13:48:32 +0300
Subject: [PATCH 049/292] 6804996: JWS PNG Decoding Integer Overflow
[V-flrhat2ln8]
Reviewed-by: prr
---
.../sun/awt/splashscreen/splashscreen_gif.c | 4 ----
.../sun/awt/splashscreen/splashscreen_impl.h | 4 ++++
.../sun/awt/splashscreen/splashscreen_png.c | 23 +++++++++++++++++++
3 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gif.c b/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gif.c
index 71bc3a3b39d..f1651ab1f49 100644
--- a/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gif.c
+++ b/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gif.c
@@ -53,10 +53,6 @@ static const char szNetscape20ext[11] = "NETSCAPE2.0";
// convert libungif samples to our ones
#define MAKE_QUAD_GIF(c,a) MAKE_QUAD((c).Red, (c).Green, (c).Blue, (a))
-#define SAFE_TO_ALLOC(c, sz) \
- (((c) > 0) && ((sz) > 0) && \
- ((0xffffffffu / ((unsigned int)(c))) > (unsigned int)(sz)))
-
/* stdio FILE* and memory input functions for libungif */
int
SplashStreamGifInputFunc(GifFileType * gif, GifByteType * buf, int n)
diff --git a/jdk/src/share/native/sun/awt/splashscreen/splashscreen_impl.h b/jdk/src/share/native/sun/awt/splashscreen/splashscreen_impl.h
index c6bad14c45a..6f4e03ef53e 100644
--- a/jdk/src/share/native/sun/awt/splashscreen/splashscreen_impl.h
+++ b/jdk/src/share/native/sun/awt/splashscreen/splashscreen_impl.h
@@ -155,6 +155,10 @@ int BitmapToYXBandedRectangles(ImageRect * pSrcRect, RECT_T * out);
void SplashInitFrameShape(Splash * splash, int imageIndex);
+#define SAFE_TO_ALLOC(c, sz) \
+ (((c) > 0) && ((sz) > 0) && \
+ ((0xffffffffu / ((unsigned int)(c))) > (unsigned int)(sz)))
+
#define dbgprintf printf
#endif
diff --git a/jdk/src/share/native/sun/awt/splashscreen/splashscreen_png.c b/jdk/src/share/native/sun/awt/splashscreen/splashscreen_png.c
index f0926ec90dc..abc54dcb753 100644
--- a/jdk/src/share/native/sun/awt/splashscreen/splashscreen_png.c
+++ b/jdk/src/share/native/sun/awt/splashscreen/splashscreen_png.c
@@ -103,9 +103,17 @@ SplashDecodePng(Splash * splash, png_rw_ptr read_func, void *io_ptr)
rowbytes = png_get_rowbytes(png_ptr, info_ptr);
+ if (!SAFE_TO_ALLOC(rowbytes, height)) {
+ goto done;
+ }
+
if ((image_data = (unsigned char *) malloc(rowbytes * height)) == NULL) {
goto done;
}
+
+ if (!SAFE_TO_ALLOC(height, sizeof(png_bytep))) {
+ goto done;
+ }
if ((row_pointers = (png_bytepp) malloc(height * sizeof(png_bytep)))
== NULL) {
goto done;
@@ -121,13 +129,28 @@ SplashDecodePng(Splash * splash, png_rw_ptr read_func, void *io_ptr)
splash->width = width;
splash->height = height;
+ if (!SAFE_TO_ALLOC(splash->width, splash->imageFormat.depthBytes)) {
+ goto done;
+ }
stride = splash->width * splash->imageFormat.depthBytes;
+ if (!SAFE_TO_ALLOC(splash->height, stride)) {
+ goto done;
+ }
splash->frameCount = 1;
splash->frames = (SplashImage *)
malloc(sizeof(SplashImage) * splash->frameCount);
+
+ if (splash->frames == NULL) {
+ goto done;
+ }
+
splash->loopCount = 1;
splash->frames[0].bitmapBits = malloc(stride * splash->height);
+ if (splash->frames[0].bitmapBits == NULL) {
+ free(splash->frames);
+ goto done;
+ }
splash->frames[0].delay = 0;
/* FIXME: sort out the real format */
From f9a987bf43ae09a989b51e70a88f5c14ae14ac39 Mon Sep 17 00:00:00 2001
From: Anthony Petrov
Date: Fri, 20 Feb 2009 17:34:16 +0300
Subject: [PATCH 050/292] 6804747: Ensure consistent graphicsConfig member
across components hierarchy
Reviewed-by: art, dcherepanov
---
jdk/src/share/classes/java/awt/Canvas.java | 13 +++-
jdk/src/share/classes/java/awt/Component.java | 51 ++++--------
jdk/src/share/classes/java/awt/Container.java | 18 +++++
jdk/src/share/classes/java/awt/Window.java | 71 +++++++----------
.../classes/java/awt/peer/CanvasPeer.java | 10 +++
.../classes/java/awt/peer/ComponentPeer.java | 6 ++
.../share/classes/sun/awt/AWTAccessor.java | 5 ++
.../classes/sun/awt/ComponentAccessor.java | 16 ----
.../classes/sun/awt/NullComponentPeer.java | 8 ++
.../classes/sun/awt/X11/XCanvasPeer.java | 78 ++++++++-----------
.../classes/sun/awt/X11/XComponentPeer.java | 5 ++
.../sun/awt/X11/XEmbedChildProxyPeer.java | 2 +
.../classes/sun/awt/X11/XPanelPeer.java | 33 --------
.../classes/sun/awt/X11/XWindowPeer.java | 24 +++---
.../solaris/native/sun/awt/awt_Component.h | 5 --
jdk/src/solaris/native/sun/awt/awt_Window.h | 1 -
jdk/src/solaris/native/sun/xawt/XToolkit.c | 6 --
.../classes/sun/awt/Win32GraphicsDevice.java | 1 -
.../classes/sun/awt/windows/WCanvasPeer.java | 38 ++-------
.../sun/awt/windows/WComponentPeer.java | 20 +----
.../classes/sun/awt/windows/WPanelPeer.java | 28 -------
.../classes/sun/awt/windows/WWindowPeer.java | 37 +++++----
22 files changed, 181 insertions(+), 295 deletions(-)
diff --git a/jdk/src/share/classes/java/awt/Canvas.java b/jdk/src/share/classes/java/awt/Canvas.java
index 04b3bc2dca4..86315e7c12e 100644
--- a/jdk/src/share/classes/java/awt/Canvas.java
+++ b/jdk/src/share/classes/java/awt/Canvas.java
@@ -25,6 +25,7 @@
package java.awt;
import java.awt.image.BufferStrategy;
+import java.awt.peer.CanvasPeer;
import javax.accessibility.*;
/**
@@ -65,7 +66,17 @@ public class Canvas extends Component implements Accessible {
*/
public Canvas(GraphicsConfiguration config) {
this();
- graphicsConfig = config;
+ setGraphicsConfiguration(config);
+ }
+
+ @Override
+ void setGraphicsConfiguration(GraphicsConfiguration gc) {
+ CanvasPeer peer = (CanvasPeer)getPeer();
+ if (peer != null) {
+ gc = peer.getAppropriateGraphicsConfiguration(gc);
+ }
+
+ super.setGraphicsConfiguration(gc);
}
/**
diff --git a/jdk/src/share/classes/java/awt/Component.java b/jdk/src/share/classes/java/awt/Component.java
index 9828ddb5661..e59d37a5826 100644
--- a/jdk/src/share/classes/java/awt/Component.java
+++ b/jdk/src/share/classes/java/awt/Component.java
@@ -300,7 +300,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
* @see GraphicsConfiguration
* @see #getGraphicsConfiguration
*/
- transient GraphicsConfiguration graphicsConfig = null;
+ private transient GraphicsConfiguration graphicsConfig = null;
/**
* A reference to a BufferStrategy
object
@@ -845,6 +845,12 @@ public abstract class Component implements ImageObserver, MenuContainer,
}
}
}
+
+ public void setGraphicsConfiguration(Component comp,
+ GraphicsConfiguration gc)
+ {
+ comp.setGraphicsConfiguration(gc);
+ }
});
}
@@ -1012,50 +1018,21 @@ public abstract class Component implements ImageObserver, MenuContainer,
*/
public GraphicsConfiguration getGraphicsConfiguration() {
synchronized(getTreeLock()) {
- if (graphicsConfig != null) {
- return graphicsConfig;
- } else if (getParent() != null) {
- return getParent().getGraphicsConfiguration();
- } else {
- return null;
- }
+ return getGraphicsConfiguration_NoClientCode();
}
}
final GraphicsConfiguration getGraphicsConfiguration_NoClientCode() {
- GraphicsConfiguration graphicsConfig = this.graphicsConfig;
- Container parent = this.parent;
- if (graphicsConfig != null) {
- return graphicsConfig;
- } else if (parent != null) {
- return parent.getGraphicsConfiguration_NoClientCode();
- } else {
- return null;
- }
+ return graphicsConfig;
}
- /**
- * Resets this Component
's
- * GraphicsConfiguration
back to a default
- * value. For most componenets, this is null
.
- * Called from the Toolkit thread, so NO CLIENT CODE.
- */
- void resetGC() {
+ void setGraphicsConfiguration(GraphicsConfiguration gc) {
synchronized(getTreeLock()) {
- graphicsConfig = null;
- }
- }
+ graphicsConfig = gc;
- /*
- * Not called on Component, but needed for Canvas and Window
- */
- void setGCFromPeer() {
- synchronized(getTreeLock()) {
- if (peer != null) { // can't imagine how this will be false,
- // but just in case
- graphicsConfig = peer.getGraphicsConfiguration();
- } else {
- graphicsConfig = null;
+ ComponentPeer peer = getPeer();
+ if (peer != null) {
+ peer.updateGraphicsData(gc);
}
}
}
diff --git a/jdk/src/share/classes/java/awt/Container.java b/jdk/src/share/classes/java/awt/Container.java
index 64de85477a7..fb520547e1e 100644
--- a/jdk/src/share/classes/java/awt/Container.java
+++ b/jdk/src/share/classes/java/awt/Container.java
@@ -506,6 +506,7 @@ public class Container extends Component {
adjustDescendants(-(comp.countHierarchyMembers()));
comp.parent = null;
+ comp.setGraphicsConfiguration(null);
component.remove(index);
invalidateIfValid();
@@ -789,6 +790,7 @@ public class Container extends Component {
component.add(index, comp);
}
comp.parent = this;
+ comp.setGraphicsConfiguration(getGraphicsConfiguration());
adjustListeningChildren(AWTEvent.HIERARCHY_EVENT_MASK,
comp.numListening(AWTEvent.HIERARCHY_EVENT_MASK));
@@ -1056,6 +1058,7 @@ public class Container extends Component {
component.add(index, comp);
}
comp.parent = this;
+ comp.setGraphicsConfiguration(thisGC);
adjustListeningChildren(AWTEvent.HIERARCHY_EVENT_MASK,
comp.numListening(AWTEvent.HIERARCHY_EVENT_MASK));
@@ -1094,6 +1097,19 @@ public class Container extends Component {
}
}
+ @Override
+ void setGraphicsConfiguration(GraphicsConfiguration gc) {
+ synchronized (getTreeLock()) {
+ super.setGraphicsConfiguration(gc);
+
+ for (Component comp : component) {
+ if (comp != null) {
+ comp.setGraphicsConfiguration(gc);
+ }
+ }
+ }
+ }
+
/**
* Checks that all Components that this Container contains are on
* the same GraphicsDevice as this Container. If not, throws an
@@ -1151,6 +1167,7 @@ public class Container extends Component {
comp.parent = null;
component.remove(index);
+ comp.setGraphicsConfiguration(null);
invalidateIfValid();
if (containerListener != null ||
@@ -1227,6 +1244,7 @@ public class Container extends Component {
layoutMgr.removeLayoutComponent(comp);
}
comp.parent = null;
+ comp.setGraphicsConfiguration(null);
if (containerListener != null ||
(eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0 ||
Toolkit.enabledOnToolkit(AWTEvent.CONTAINER_EVENT_MASK)) {
diff --git a/jdk/src/share/classes/java/awt/Window.java b/jdk/src/share/classes/java/awt/Window.java
index e1ff8db14c3..062870fe101 100644
--- a/jdk/src/share/classes/java/awt/Window.java
+++ b/jdk/src/share/classes/java/awt/Window.java
@@ -394,6 +394,18 @@ public class Window extends Container implements Accessible {
}
}
+ private GraphicsConfiguration initGC(GraphicsConfiguration gc) {
+ GraphicsEnvironment.checkHeadless();
+
+ if (gc == null) {
+ gc = GraphicsEnvironment.getLocalGraphicsEnvironment().
+ getDefaultScreenDevice().getDefaultConfiguration();
+ }
+ setGraphicsConfiguration(gc);
+
+ return gc;
+ }
+
private void init(GraphicsConfiguration gc) {
GraphicsEnvironment.checkHeadless();
@@ -405,14 +417,10 @@ public class Window extends Container implements Accessible {
setWarningString();
this.cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
this.visible = false;
- if (gc == null) {
- this.graphicsConfig =
- GraphicsEnvironment.getLocalGraphicsEnvironment().
- getDefaultScreenDevice().getDefaultConfiguration();
- } else {
- this.graphicsConfig = gc;
- }
- if (graphicsConfig.getDevice().getType() !=
+
+ gc = initGC(gc);
+
+ if (gc.getDevice().getType() !=
GraphicsDevice.TYPE_RASTER_SCREEN) {
throw new IllegalArgumentException("not a screen device");
}
@@ -420,8 +428,8 @@ public class Window extends Container implements Accessible {
/* offset the initial location with the original of the screen */
/* and any insets */
- Rectangle screenBounds = graphicsConfig.getBounds();
- Insets screenInsets = getToolkit().getScreenInsets(graphicsConfig);
+ Rectangle screenBounds = gc.getBounds();
+ Insets screenInsets = getToolkit().getScreenInsets(gc);
int x = getX() + screenBounds.x + screenInsets.left;
int y = getY() + screenBounds.y + screenInsets.top;
if (x != this.x || y != this.y) {
@@ -2765,7 +2773,7 @@ public class Window extends Container implements Accessible {
sun.java2d.Disposer.addRecord(anchor, new WindowDisposerRecord(appContext, this));
addToWindowList();
-
+ initGC(null);
}
private void deserializeResources(ObjectInputStream s)
@@ -2939,41 +2947,18 @@ public class Window extends Container implements Accessible {
} // inner class AccessibleAWTWindow
- /**
- * This method returns the GraphicsConfiguration used by this Window.
- * @since 1.3
- */
- public GraphicsConfiguration getGraphicsConfiguration() {
- //NOTE: for multiscreen, this will need to take into account
- //which screen the window is on/mostly on instead of returning the
- //default or constructor argument config.
- synchronized(getTreeLock()) {
- if (graphicsConfig == null && !GraphicsEnvironment.isHeadless()) {
- graphicsConfig =
- GraphicsEnvironment. getLocalGraphicsEnvironment().
- getDefaultScreenDevice().
- getDefaultConfiguration();
- }
- return graphicsConfig;
- }
- }
-
- /**
- * Reset this Window's GraphicsConfiguration to match its peer.
- */
- void resetGC() {
- if (!GraphicsEnvironment.isHeadless()) {
- // use the peer's GC
- setGCFromPeer();
- // if it's still null, use the default
- if (graphicsConfig == null) {
- graphicsConfig = GraphicsEnvironment.
+ @Override
+ void setGraphicsConfiguration(GraphicsConfiguration gc) {
+ if (gc == null) {
+ gc = GraphicsEnvironment.
getLocalGraphicsEnvironment().
getDefaultScreenDevice().
getDefaultConfiguration();
- }
+ }
+ synchronized (getTreeLock()) {
+ super.setGraphicsConfiguration(gc);
if (log.isLoggable(Level.FINER)) {
- log.finer("+ Window.resetGC(): new GC is \n+ " + graphicsConfig + "\n+ this is " + this);
+ log.finer("+ Window.setGraphicsConfiguration(): new GC is \n+ " + getGraphicsConfiguration_NoClientCode() + "\n+ this is " + this);
}
}
}
@@ -3033,7 +3018,7 @@ public class Window extends Container implements Accessible {
// target location
int dx = 0, dy = 0;
// target GC
- GraphicsConfiguration gc = this.graphicsConfig;
+ GraphicsConfiguration gc = getGraphicsConfiguration_NoClientCode();
Rectangle gcBounds = gc.getBounds();
Dimension windowSize = getSize();
diff --git a/jdk/src/share/classes/java/awt/peer/CanvasPeer.java b/jdk/src/share/classes/java/awt/peer/CanvasPeer.java
index bbf6a111086..94b8d189d8d 100644
--- a/jdk/src/share/classes/java/awt/peer/CanvasPeer.java
+++ b/jdk/src/share/classes/java/awt/peer/CanvasPeer.java
@@ -25,6 +25,7 @@
package java.awt.peer;
import java.awt.Canvas;
+import java.awt.GraphicsConfiguration;
/**
* The peer interface for {@link Canvas}.
@@ -36,4 +37,13 @@ import java.awt.Canvas;
* instances.
*/
public interface CanvasPeer extends ComponentPeer {
+ /**
+ * Requests a GC that best suits this Canvas. The returned GC may differ
+ * from the requested GC passed as the argument to this method. This method
+ * must return a non-null value (given the argument is non-null as well).
+ *
+ * @since 1.7
+ */
+ GraphicsConfiguration getAppropriateGraphicsConfiguration(
+ GraphicsConfiguration gc);
}
diff --git a/jdk/src/share/classes/java/awt/peer/ComponentPeer.java b/jdk/src/share/classes/java/awt/peer/ComponentPeer.java
index e71ab27f7ac..3a2845f37fa 100644
--- a/jdk/src/share/classes/java/awt/peer/ComponentPeer.java
+++ b/jdk/src/share/classes/java/awt/peer/ComponentPeer.java
@@ -539,4 +539,10 @@ public interface ComponentPeer {
*/
void applyShape(Region shape);
+ /**
+ * Updates internal data structures related to the component's GC.
+ *
+ * @since 1.7
+ */
+ void updateGraphicsData(GraphicsConfiguration gc);
}
diff --git a/jdk/src/share/classes/sun/awt/AWTAccessor.java b/jdk/src/share/classes/sun/awt/AWTAccessor.java
index 2145f0f10a4..767b4147778 100644
--- a/jdk/src/share/classes/sun/awt/AWTAccessor.java
+++ b/jdk/src/share/classes/sun/awt/AWTAccessor.java
@@ -78,6 +78,11 @@ public final class AWTAccessor {
* See 6797587, 6776743, 6768307, and 6768332 for details
*/
void setMixingCutoutShape(Component comp, Shape shape);
+
+ /**
+ * Sets GraphicsConfiguration value for the component.
+ */
+ void setGraphicsConfiguration(Component comp, GraphicsConfiguration gc);
}
/*
diff --git a/jdk/src/share/classes/sun/awt/ComponentAccessor.java b/jdk/src/share/classes/sun/awt/ComponentAccessor.java
index af3abcf8a95..49a383815db 100644
--- a/jdk/src/share/classes/sun/awt/ComponentAccessor.java
+++ b/jdk/src/share/classes/sun/awt/ComponentAccessor.java
@@ -73,7 +73,6 @@ public class ComponentAccessor
private static Field fieldPacked;
private static Field fieldIgnoreRepaint;
private static Field fieldPeer;
- private static Method methodResetGC;
private static Field fieldVisible;
private static Method methodIsEnabledImpl;
private static Method methodGetCursorNoClientCode;
@@ -124,9 +123,6 @@ public class ComponentAccessor
fieldPeer = componentClass.getDeclaredField("peer");
fieldPeer.setAccessible(true);
- methodResetGC = componentClass.getDeclaredMethod("resetGC", (Class[]) null);
- methodResetGC.setAccessible(true);
-
fieldVisible = componentClass.getDeclaredField("visible");
fieldVisible.setAccessible(true);
@@ -425,18 +421,6 @@ public class ComponentAccessor
return false;
}
- public static void resetGC(Component c) {
- try {
- methodResetGC.invoke(c, (Object[]) null);
- }
- catch (IllegalAccessException e) {
- log.log(Level.FINE, "Unable to access the Component object", e);
- }
- catch (InvocationTargetException e) {
- log.log(Level.FINE, "Unable to invoke on the Component object", e);
- }
- }
-
public static boolean getVisible(Component c) {
try {
return fieldVisible.getBoolean(c);
diff --git a/jdk/src/share/classes/sun/awt/NullComponentPeer.java b/jdk/src/share/classes/sun/awt/NullComponentPeer.java
index 8818c472877..2feea7b518c 100644
--- a/jdk/src/share/classes/sun/awt/NullComponentPeer.java
+++ b/jdk/src/share/classes/sun/awt/NullComponentPeer.java
@@ -305,4 +305,12 @@ public class NullComponentPeer implements LightweightPeer,
*/
public void applyShape(Region shape) {
}
+
+ public void updateGraphicsData(GraphicsConfiguration gc) {}
+
+ public GraphicsConfiguration getAppropriateGraphicsConfiguration(
+ GraphicsConfiguration gc)
+ {
+ return gc;
+ }
}
diff --git a/jdk/src/solaris/classes/sun/awt/X11/XCanvasPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XCanvasPeer.java
index 4c38c88b9fc..8fc6f1f7d28 100644
--- a/jdk/src/solaris/classes/sun/awt/X11/XCanvasPeer.java
+++ b/jdk/src/solaris/classes/sun/awt/X11/XCanvasPeer.java
@@ -27,7 +27,6 @@ package sun.awt.X11;
import java.awt.*;
import java.awt.peer.*;
-import sun.awt.ComponentAccessor;
import sun.awt.SunToolkit;
import sun.awt.X11GraphicsConfig;
@@ -54,60 +53,45 @@ class XCanvasPeer extends XComponentPeer implements CanvasPeer {
}
}
- void resetTargetGC(Component target) {
- ComponentAccessor.resetGC(target);
- }
-
- /*
- * Called when the Window this
- * Canvas is on is moved onto another Xinerama screen.
- *
- * Canvases can be created with a non-defulat GraphicsConfiguration. The
- * GraphicsConfiguration needs to be changed to one on the new screen,
- * preferably with the same visual ID.
- *
- * Up-called for other windows peer instances (XPanelPeer, XWindowPeer).
- *
- * Should only be called from the event thread.
- */
- public void displayChanged(int screenNum) {
- resetLocalGC(screenNum);
- resetTargetGC(target);
- }
-
- /* Set graphicsConfig to a GraphicsConfig with the same visual on the new
+ /* Get a GraphicsConfig with the same visual on the new
* screen, which should be easy in Xinerama mode.
- *
- * Should only be called from displayChanged(), and therefore only from
- * the event thread.
*/
- void resetLocalGC(int screenNum) {
+ public GraphicsConfiguration getAppropriateGraphicsConfiguration(
+ GraphicsConfiguration gc)
+ {
+ if (graphicsConfig == null || gc == null) {
+ return gc;
+ }
// Opt: Only need to do if we're not using the default GC
- if (graphicsConfig != null) {
- X11GraphicsConfig parentgc;
- // save vis id of current gc
- int visual = graphicsConfig.getVisual();
- X11GraphicsDevice newDev = (X11GraphicsDevice) GraphicsEnvironment.
- getLocalGraphicsEnvironment().
- getScreenDevices()[screenNum];
+ int screenNum = ((X11GraphicsDevice)gc.getDevice()).getScreen();
- for (int i = 0; i < newDev.getNumConfigs(screenNum); i++) {
- if (visual == newDev.getConfigVisualId(i, screenNum)) {
- // use that
- graphicsConfig = (X11GraphicsConfig)newDev.getConfigurations()[i];
- break;
- }
- }
- // just in case...
- if (graphicsConfig == null) {
- graphicsConfig = (X11GraphicsConfig) GraphicsEnvironment.
- getLocalGraphicsEnvironment().
- getScreenDevices()[screenNum].
- getDefaultConfiguration();
+ X11GraphicsConfig parentgc;
+ // save vis id of current gc
+ int visual = graphicsConfig.getVisual();
+
+ X11GraphicsDevice newDev = (X11GraphicsDevice) GraphicsEnvironment.
+ getLocalGraphicsEnvironment().
+ getScreenDevices()[screenNum];
+
+ for (int i = 0; i < newDev.getNumConfigs(screenNum); i++) {
+ if (visual == newDev.getConfigVisualId(i, screenNum)) {
+ // use that
+ graphicsConfig = (X11GraphicsConfig)newDev.getConfigurations()[i];
+ break;
}
}
+ // just in case...
+ if (graphicsConfig == null) {
+ graphicsConfig = (X11GraphicsConfig) GraphicsEnvironment.
+ getLocalGraphicsEnvironment().
+ getScreenDevices()[screenNum].
+ getDefaultConfiguration();
+ }
+
+ return graphicsConfig;
}
+
protected boolean shouldFocusOnClick() {
// Canvas should always be able to be focused by mouse clicks.
return true;
diff --git a/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java
index 46c4a8768f0..4c83ac750c8 100644
--- a/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java
+++ b/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java
@@ -35,6 +35,7 @@ import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
+import java.awt.GraphicsConfiguration;
import java.awt.Image;
import java.awt.Insets;
import java.awt.KeyboardFocusManager;
@@ -1556,4 +1557,8 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget
}
}
}
+
+ public void updateGraphicsData(GraphicsConfiguration gc) {
+ initGraphicsConfiguration();
+ }
}
diff --git a/jdk/src/solaris/classes/sun/awt/X11/XEmbedChildProxyPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XEmbedChildProxyPeer.java
index e4500043ae1..eae300aee08 100644
--- a/jdk/src/solaris/classes/sun/awt/X11/XEmbedChildProxyPeer.java
+++ b/jdk/src/solaris/classes/sun/awt/X11/XEmbedChildProxyPeer.java
@@ -379,4 +379,6 @@ public class XEmbedChildProxyPeer implements ComponentPeer, XEventDispatcher{
public void applyShape(Region shape) {
}
+
+ public void updateGraphicsData(GraphicsConfiguration gc) {}
}
diff --git a/jdk/src/solaris/classes/sun/awt/X11/XPanelPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XPanelPeer.java
index aac632569ad..c070fcf3ad8 100644
--- a/jdk/src/solaris/classes/sun/awt/X11/XPanelPeer.java
+++ b/jdk/src/solaris/classes/sun/awt/X11/XPanelPeer.java
@@ -130,39 +130,6 @@ public class XPanelPeer extends XCanvasPeer implements PanelPeer {
return getInsets();
}
- /*
- * This method is called from XWindowPeer.displayChanged, when
- * the window this Panel is on is moved to the new screen, or
- * display mode is changed.
- *
- * The notification is propagated to the child Canvas components.
- * Top-level windows and other Panels are notified too as their
- * peers are subclasses of XCanvasPeer.
- */
- public void displayChanged(int screenNum) {
- super.displayChanged(screenNum);
- displayChanged((Container)target, screenNum);
- }
-
- /*
- * Recursively iterates through all the HW and LW children
- * of the container and calls displayChanged() for HW peers.
- * Iteration through children peers only is not enough as the
- * displayChanged notification may not be propagated to HW
- * components inside LW containers, see 4452373 for details.
- */
- private static void displayChanged(Container target, int screenNum) {
- Component children[] = ((Container)target).getComponents();
- for (Component child : children) {
- ComponentPeer cpeer = child.getPeer();
- if (cpeer instanceof XCanvasPeer) {
- ((XCanvasPeer)cpeer).displayChanged(screenNum);
- } else if (child instanceof Container) {
- displayChanged((Container)child, screenNum);
- }
- }
- }
-
public void dispose() {
if (embedder != null) {
embedder.deinstall();
diff --git a/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java
index 619ff8a9c9b..4f9fa56fd8f 100644
--- a/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java
+++ b/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java
@@ -47,6 +47,7 @@ import java.util.logging.Logger;
import sun.awt.AWTAccessor;
import sun.awt.ComponentAccessor;
import sun.awt.WindowAccessor;
+import sun.awt.AWTAccessor;
import sun.awt.DisplayChangedListener;
import sun.awt.SunToolkit;
import sun.awt.X11GraphicsDevice;
@@ -711,6 +712,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
int curScreenNum = ((X11GraphicsDevice)getGraphicsConfiguration().getDevice()).getScreen();
int newScreenNum = 0;
GraphicsDevice gds[] = XToolkit.localEnv.getScreenDevices();
+ GraphicsConfiguration newGC = null;
Rectangle screenBounds;
for (int i = 0; i < gds.length; i++) {
@@ -726,11 +728,13 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
if (intAmt == area) {
// Completely on this screen - done!
newScreenNum = i;
+ newGC = gds[i].getDefaultConfiguration();
break;
}
if (intAmt > largestAmt) {
largestAmt = intAmt;
newScreenNum = i;
+ newGC = gds[i].getDefaultConfiguration();
}
}
}
@@ -738,28 +742,20 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
if (log.isLoggable(Level.FINEST)) {
log.finest("XWindowPeer: Moved to a new screen");
}
- draggedToNewScreen(newScreenNum);
+ executeDisplayChangedOnEDT(newGC);
}
}
- /* Xinerama
- * called to update our GC when dragged onto another screen
- */
- public void draggedToNewScreen(int screenNum) {
- executeDisplayChangedOnEDT(screenNum);
- }
-
/**
* Helper method that executes the displayChanged(screen) method on
* the event dispatch thread. This method is used in the Xinerama case
* and after display mode change events.
*/
- private void executeDisplayChangedOnEDT(final int screenNum) {
+ private void executeDisplayChangedOnEDT(final GraphicsConfiguration gc) {
Runnable dc = new Runnable() {
public void run() {
- // Updates this window's GC and notifies all the children.
- // See XPanelPeer/XCanvasPeer.displayChanged(int) for details.
- displayChanged(screenNum);
+ AWTAccessor.getComponentAccessor().
+ setGraphicsConfiguration((Component)target, gc);
}
};
SunToolkit.executeOnEventHandlerThread((Component)target, dc);
@@ -770,9 +766,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
* X11GraphicsDevice when the display mode has been changed.
*/
public void displayChanged() {
- GraphicsConfiguration gc = getGraphicsConfiguration();
- int curScreenNum = ((X11GraphicsDevice)gc.getDevice()).getScreen();
- executeDisplayChangedOnEDT(curScreenNum);
+ executeDisplayChangedOnEDT(getGraphicsConfiguration());
}
/**
diff --git a/jdk/src/solaris/native/sun/awt/awt_Component.h b/jdk/src/solaris/native/sun/awt/awt_Component.h
index 8ee7fe82f45..d6ee776be01 100644
--- a/jdk/src/solaris/native/sun/awt/awt_Component.h
+++ b/jdk/src/solaris/native/sun/awt/awt_Component.h
@@ -41,7 +41,6 @@ struct ComponentIDs {
jfieldID appContext;
jmethodID getParent;
jmethodID getLocationOnScreen;
- jmethodID resetGCMID;
};
/* field and method IDs for Container */
@@ -65,7 +64,3 @@ struct MComponentPeerIDs {
extern void processTree(Widget from, Widget to, Boolean action);
#endif // HEADLESS
-/* fieldIDs for Canvas fields that may be accessed from C */
-struct CanvasIDs {
- jmethodID setGCFromPeerMID;
-};
diff --git a/jdk/src/solaris/native/sun/awt/awt_Window.h b/jdk/src/solaris/native/sun/awt/awt_Window.h
index 875f55b2fa1..a93e4ad34d1 100644
--- a/jdk/src/solaris/native/sun/awt/awt_Window.h
+++ b/jdk/src/solaris/native/sun/awt/awt_Window.h
@@ -28,7 +28,6 @@
/* fieldIDs for Window fields that may be accessed from C */
struct WindowIDs {
jfieldID warningString;
- jmethodID resetGCMID;
jfieldID locationByPlatform;
jfieldID isAutoRequestFocus;
};
diff --git a/jdk/src/solaris/native/sun/xawt/XToolkit.c b/jdk/src/solaris/native/sun/xawt/XToolkit.c
index ac3fecc0c76..3b9669cb92b 100644
--- a/jdk/src/solaris/native/sun/xawt/XToolkit.c
+++ b/jdk/src/solaris/native/sun/xawt/XToolkit.c
@@ -182,9 +182,6 @@ Java_java_awt_Component_initIDs
(*env)->GetMethodID(env, cls, "getLocationOnScreen_NoTreeLock",
"()Ljava/awt/Point;");
- componentIDs.resetGCMID =
- (*env)->GetMethodID(env, cls, "resetGC", "()V");
-
keyclass = (*env)->FindClass(env, "java/awt/event/KeyEvent");
DASSERT (keyclass != NULL);
@@ -197,9 +194,6 @@ Java_java_awt_Component_initIDs
"Lsun/awt/AppContext;");
(*env)->DeleteLocalRef(env, keyclass);
-
- DASSERT(componentIDs.resetGCMID);
-
}
diff --git a/jdk/src/windows/classes/sun/awt/Win32GraphicsDevice.java b/jdk/src/windows/classes/sun/awt/Win32GraphicsDevice.java
index ba4769813d8..1da339ce9f1 100644
--- a/jdk/src/windows/classes/sun/awt/Win32GraphicsDevice.java
+++ b/jdk/src/windows/classes/sun/awt/Win32GraphicsDevice.java
@@ -380,7 +380,6 @@ public class Win32GraphicsDevice extends GraphicsDevice implements
// fix for 4868278
peer.updateGC();
- peer.resetTargetGC();
}
}
diff --git a/jdk/src/windows/classes/sun/awt/windows/WCanvasPeer.java b/jdk/src/windows/classes/sun/awt/windows/WCanvasPeer.java
index e1657102900..b97a3787b64 100644
--- a/jdk/src/windows/classes/sun/awt/windows/WCanvasPeer.java
+++ b/jdk/src/windows/classes/sun/awt/windows/WCanvasPeer.java
@@ -38,44 +38,12 @@ class WCanvasPeer extends WComponentPeer implements CanvasPeer {
private boolean eraseBackground;
- Method resetGCMethod;
-
// Toolkit & peer internals
WCanvasPeer(Component target) {
super(target);
}
- /*
- * From the DisplayChangedListener interface.
- *
- * Overrides WComponentPeer version because Canvases can be created with
- * a non-defulat GraphicsConfiguration, which is no longer valid.
- * Up-called for other windows peer instances (WPanelPeer, WWindowPeer).
- */
- public void displayChanged() {
- clearLocalGC();
- resetTargetGC();
- super.displayChanged();
- }
-
- /*
- * Reset the graphicsConfiguration member of our target Component.
- * Component.resetGC() is a package-private method, so we have to call it
- * through reflection.
- */
- public void resetTargetGC() {
- ComponentAccessor.resetGC((Component)target);
- }
-
- /*
- * Clears the peer's winGraphicsConfig member.
- * Overridden by WWindowPeer, which shouldn't have a null winGraphicsConfig.
- */
- void clearLocalGC() {
- winGraphicsConfig = null;
- }
-
native void create(WComponentPeer parent);
void initialize() {
@@ -152,4 +120,10 @@ class WCanvasPeer extends WComponentPeer implements CanvasPeer {
*/
private native void setNativeBackgroundErase(boolean doErase,
boolean doEraseOnResize);
+
+ public GraphicsConfiguration getAppropriateGraphicsConfiguration(
+ GraphicsConfiguration gc)
+ {
+ return gc;
+ }
}
diff --git a/jdk/src/windows/classes/sun/awt/windows/WComponentPeer.java b/jdk/src/windows/classes/sun/awt/windows/WComponentPeer.java
index 3a414d1c328..56eb45fa3f5 100644
--- a/jdk/src/windows/classes/sun/awt/windows/WComponentPeer.java
+++ b/jdk/src/windows/classes/sun/awt/windows/WComponentPeer.java
@@ -59,7 +59,7 @@ import java.util.logging.*;
public abstract class WComponentPeer extends WObjectPeer
- implements ComponentPeer, DropTargetPeer, DisplayChangedListener
+ implements ComponentPeer, DropTargetPeer
{
/**
* Handle to native window
@@ -452,15 +452,8 @@ public abstract class WComponentPeer extends WObjectPeer
}
}
- /**
- * From the DisplayChangedListener interface.
- *
- * Called after a change in the display mode. This event
- * triggers replacing the surfaceData object (since that object
- * reflects the current display depth information, which has
- * just changed).
- */
- public void displayChanged() {
+ public void updateGraphicsData(GraphicsConfiguration gc) {
+ winGraphicsConfig = (Win32GraphicsConfig)gc;
try {
replaceSurfaceData();
} catch (InvalidPipeException e) {
@@ -468,13 +461,6 @@ public abstract class WComponentPeer extends WObjectPeer
}
}
- /**
- * Part of the DisplayChangedListener interface: components
- * do not need to react to this event
- */
- public void paletteChanged() {
- }
-
//This will return null for Components not yet added to a Container
public ColorModel getColorModel() {
GraphicsConfiguration gc = getGraphicsConfiguration();
diff --git a/jdk/src/windows/classes/sun/awt/windows/WPanelPeer.java b/jdk/src/windows/classes/sun/awt/windows/WPanelPeer.java
index 8a0d7ffbcc1..10ca423146c 100644
--- a/jdk/src/windows/classes/sun/awt/windows/WPanelPeer.java
+++ b/jdk/src/windows/classes/sun/awt/windows/WPanelPeer.java
@@ -100,34 +100,6 @@ class WPanelPeer extends WCanvasPeer implements PanelPeer {
return getInsets();
}
- /*
- * From the DisplayChangedListener interface. Often is
- * up-called from a WWindowPeer instance.
- */
- public void displayChanged() {
- super.displayChanged();
- displayChanged((Container)target);
- }
-
- /*
- * Recursively iterates through all the HW and LW children
- * of the container and calls displayChanged() for HW peers.
- * Iteration through children peers only is not enough as the
- * displayChanged notification may not be propagated to HW
- * components inside LW containers, see 4452373 for details.
- */
- private static void displayChanged(Container target) {
- Component children[] = ((Container)target).getComponents();
- for (Component child : children) {
- ComponentPeer cpeer = child.getPeer();
- if (cpeer instanceof WComponentPeer) {
- ((WComponentPeer)cpeer).displayChanged();
- } else if (child instanceof Container) {
- displayChanged((Container)child);
- }
- }
- }
-
private native void pRestack(Object[] peers);
private void restack(Container cont, Vector peers) {
for (int i = 0; i < cont.getComponentCount(); i++) {
diff --git a/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java b/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java
index 79818431063..73f9e3f811f 100644
--- a/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java
+++ b/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java
@@ -41,7 +41,9 @@ import sun.awt.*;
import sun.java2d.pipe.Region;
-public class WWindowPeer extends WPanelPeer implements WindowPeer {
+public class WWindowPeer extends WPanelPeer implements WindowPeer,
+ DisplayChangedListener
+{
private static final Logger log = Logger.getLogger("sun.awt.windows.WWindowPeer");
private static final Logger screenLog = Logger.getLogger("sun.awt.windows.screen.WWindowPeer");
@@ -198,7 +200,6 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer {
// super.displayChanged() in WWindowPeer.displayChanged() regardless of whether
// GraphicsDevice was really changed, or not. So we need to track it here.
updateGC();
- resetTargetGC();
realShow();
updateMinimumSize();
@@ -400,14 +401,6 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer {
});
}
-
- /*
- * Called from WCanvasPeer.displayChanged().
- * Override to do nothing - Window and WWindowPeer GC must never be set to
- * null!
- */
- void clearLocalGC() {}
-
public void updateGC() {
int scrn = getScreenImOn();
if (screenLog.isLoggable(Level.FINER)) {
@@ -446,18 +439,36 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer {
oldDev.removeDisplayChangedListener(this);
newDev.addDisplayChangedListener(this);
}
+
+ SunToolkit.executeOnEventHandlerThread((Component)target,
+ new Runnable() {
+ public void run() {
+ AWTAccessor.getComponentAccessor().
+ setGraphicsConfiguration((Component)target, winGraphicsConfig);
+ }
+ });
}
- /*
- * From the DisplayChangedListener interface
+ /**
+ * From the DisplayChangedListener interface.
*
* This method handles a display change - either when the display settings
* are changed, or when the window has been dragged onto a different
* display.
+ * Called after a change in the display mode. This event
+ * triggers replacing the surfaceData object (since that object
+ * reflects the current display depth information, which has
+ * just changed).
*/
public void displayChanged() {
updateGC();
- super.displayChanged();
+ }
+
+ /**
+ * Part of the DisplayChangedListener interface: components
+ * do not need to react to this event
+ */
+ public void paletteChanged() {
}
private native int getScreenImOn();
From 0723dab28bd58c6741f9fc7df3e195d06d391371 Mon Sep 17 00:00:00 2001
From: Christian Thalinger
Date: Mon, 23 Feb 2009 12:02:30 -0800
Subject: [PATCH 051/292] 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
There is very much duplicated code in vm_version_x86_{32,64}.{cpp,hpp}. Refactoring these would help maintainability.
Reviewed-by: kvn, never
---
..._version_x86_32.cpp => vm_version_x86.cpp} | 62 ++-
..._version_x86_64.hpp => vm_version_x86.hpp} | 82 ++--
hotspot/src/cpu/x86/vm/vm_version_x86_32.hpp | 439 ------------------
hotspot/src/cpu/x86/vm/vm_version_x86_64.cpp | 419 -----------------
.../os_cpu/solaris_x86/vm/os_solaris_x86.cpp | 10 +-
.../os_cpu/solaris_x86/vm/os_solaris_x86.hpp | 5 +-
hotspot/src/share/vm/includeDB_core | 36 +-
7 files changed, 126 insertions(+), 927 deletions(-)
rename hotspot/src/cpu/x86/vm/{vm_version_x86_32.cpp => vm_version_x86.cpp} (91%)
rename hotspot/src/cpu/x86/vm/{vm_version_x86_64.hpp => vm_version_x86.hpp} (92%)
delete mode 100644 hotspot/src/cpu/x86/vm/vm_version_x86_32.hpp
delete mode 100644 hotspot/src/cpu/x86/vm/vm_version_x86_64.cpp
diff --git a/hotspot/src/cpu/x86/vm/vm_version_x86_32.cpp b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp
similarity index 91%
rename from hotspot/src/cpu/x86/vm/vm_version_x86_32.cpp
rename to hotspot/src/cpu/x86/vm/vm_version_x86.cpp
index edd1da4e31f..cf112067fe4 100644
--- a/hotspot/src/cpu/x86/vm/vm_version_x86_32.cpp
+++ b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* 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 @@
*/
# include "incls/_precompiled.incl"
-# include "incls/_vm_version_x86_32.cpp.incl"
+# include "incls/_vm_version_x86.cpp.incl"
int VM_Version::_cpu;
@@ -67,8 +67,14 @@ class VM_Version_StubGenerator: public StubCodeGenerator {
//
// void getPsrInfo(VM_Version::CpuidInfo* cpuid_info);
//
+ // LP64: rcx and rdx are first and second argument registers on windows
+
__ push(rbp);
+#ifdef _LP64
+ __ mov(rbp, c_rarg0); // cpuid_info address
+#else
__ movptr(rbp, Address(rsp, 8)); // cpuid_info address
+#endif
__ push(rbx);
__ push(rsi);
__ pushf(); // preserve rbx, and flags
@@ -110,12 +116,12 @@ class VM_Version_StubGenerator: public StubCodeGenerator {
__ jmp(done);
//
- // at this point, we have a chip which supports the "cpuid" instruction
+ // At this point, we have a chip which supports the "cpuid" instruction
//
__ bind(detect_586);
- __ xorptr(rax, rax);
+ __ xorl(rax, rax);
__ cpuid();
- __ orptr(rax, rax);
+ __ orl(rax, rax);
__ jcc(Assembler::equal, cpu486); // if cpuid doesn't support an input
// value of at least 1, we give up and
// assume a 486
@@ -131,12 +137,12 @@ class VM_Version_StubGenerator: public StubCodeGenerator {
//
// cpuid(0x4) Deterministic cache params
//
- __ movl(rax, 4); // and rcx already set to 0x0
- __ xorl(rcx, rcx);
+ __ movl(rax, 4);
+ __ xorl(rcx, rcx); // L1 cache
__ cpuid();
__ push(rax);
__ andl(rax, 0x1f); // Determine if valid cache parameters used
- __ orl(rax, rax); // rax,[4:0] == 0 indicates invalid cache
+ __ orl(rax, rax); // eax[4:0] == 0 indicates invalid cache
__ pop(rax);
__ jccb(Assembler::equal, std_cpuid1);
@@ -225,6 +231,7 @@ void VM_Version::get_processor_features() {
_stepping = 0;
_cpuFeatures = 0;
_logical_processors_per_package = 1;
+
if (!Use486InstrsOnly) {
// Get raw processor info
getPsrInfo_stub(&_cpuid_info);
@@ -232,6 +239,7 @@ void VM_Version::get_processor_features() {
_cpu = extended_cpu_family();
_model = extended_cpu_model();
_stepping = cpu_stepping();
+
if (cpu_family() > 4) { // it supports CPUID
_cpuFeatures = feature_flags();
// Logical processors are only available on P4s and above,
@@ -239,21 +247,34 @@ void VM_Version::get_processor_features() {
_logical_processors_per_package = logical_processor_count();
}
}
+
_supports_cx8 = supports_cmpxchg8();
- // if the OS doesn't support SSE, we can't use this feature even if the HW does
- if( !os::supports_sse())
+
+#ifdef _LP64
+ // OS should support SSE for x64 and hardware should support at least SSE2.
+ if (!VM_Version::supports_sse2()) {
+ vm_exit_during_initialization("Unknown x64 processor: SSE2 not supported");
+ }
+#endif
+
+ // If the OS doesn't support SSE, we can't use this feature even if the HW does
+ if (!os::supports_sse())
_cpuFeatures &= ~(CPU_SSE|CPU_SSE2|CPU_SSE3|CPU_SSSE3|CPU_SSE4A|CPU_SSE4_1|CPU_SSE4_2);
+
if (UseSSE < 4) {
_cpuFeatures &= ~CPU_SSE4_1;
_cpuFeatures &= ~CPU_SSE4_2;
}
+
if (UseSSE < 3) {
_cpuFeatures &= ~CPU_SSE3;
_cpuFeatures &= ~CPU_SSSE3;
_cpuFeatures &= ~CPU_SSE4A;
}
+
if (UseSSE < 2)
_cpuFeatures &= ~CPU_SSE2;
+
if (UseSSE < 1)
_cpuFeatures &= ~CPU_SSE;
@@ -418,10 +439,21 @@ void VM_Version::get_processor_features() {
if( AllocatePrefetchStyle == 2 && is_intel() &&
cpu_family() == 6 && supports_sse3() ) { // watermark prefetching on Core
+#ifdef _LP64
+ AllocatePrefetchDistance = 384;
+#else
AllocatePrefetchDistance = 320;
+#endif
}
assert(AllocatePrefetchDistance % AllocatePrefetchStepSize == 0, "invalid value");
+#ifdef _LP64
+ // Prefetch settings
+ PrefetchCopyIntervalInBytes = prefetch_copy_interval_in_bytes();
+ PrefetchScanIntervalInBytes = prefetch_scan_interval_in_bytes();
+ PrefetchFieldsAhead = prefetch_fields_ahead();
+#endif
+
#ifndef PRODUCT
if (PrintMiscellaneous && Verbose) {
tty->print_cr("Logical CPUs per core: %u",
@@ -450,6 +482,16 @@ void VM_Version::get_processor_features() {
tty->print_cr(" %d, one line", AllocatePrefetchDistance);
}
}
+
+ if (PrefetchCopyIntervalInBytes > 0) {
+ tty->print_cr("PrefetchCopyIntervalInBytes %d", PrefetchCopyIntervalInBytes);
+ }
+ if (PrefetchScanIntervalInBytes > 0) {
+ tty->print_cr("PrefetchScanIntervalInBytes %d", PrefetchScanIntervalInBytes);
+ }
+ if (PrefetchFieldsAhead > 0) {
+ tty->print_cr("PrefetchFieldsAhead %d", PrefetchFieldsAhead);
+ }
}
#endif // !PRODUCT
}
diff --git a/hotspot/src/cpu/x86/vm/vm_version_x86_64.hpp b/hotspot/src/cpu/x86/vm/vm_version_x86.hpp
similarity index 92%
rename from hotspot/src/cpu/x86/vm/vm_version_x86_64.hpp
rename to hotspot/src/cpu/x86/vm/vm_version_x86.hpp
index 43492f5fb16..bf876fc92a6 100644
--- a/hotspot/src/cpu/x86/vm/vm_version_x86_64.hpp
+++ b/hotspot/src/cpu/x86/vm/vm_version_x86.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -112,20 +112,6 @@ public:
} bits;
};
- union ExtCpuid1Edx {
- uint32_t value;
- struct {
- uint32_t : 22,
- mmx_amd : 1,
- mmx : 1,
- fxsr : 1,
- : 4,
- long_mode : 1,
- tdnow2 : 1,
- tdnow : 1;
- } bits;
- };
-
union ExtCpuid1Ecx {
uint32_t value;
struct {
@@ -140,6 +126,20 @@ public:
} bits;
};
+ union ExtCpuid1Edx {
+ uint32_t value;
+ struct {
+ uint32_t : 22,
+ mmx_amd : 1,
+ mmx : 1,
+ fxsr : 1,
+ : 4,
+ long_mode : 1,
+ tdnow2 : 1,
+ tdnow : 1;
+ } bits;
+ };
+
union ExtCpuid5Ex {
uint32_t value;
struct {
@@ -167,17 +167,17 @@ protected:
static const char* _features_str;
enum {
- CPU_CX8 = (1 << 0), // next bits are from cpuid 1 (EDX)
- CPU_CMOV = (1 << 1),
- CPU_FXSR = (1 << 2),
- CPU_HT = (1 << 3),
- CPU_MMX = (1 << 4),
- CPU_3DNOW= (1 << 5),
- CPU_SSE = (1 << 6),
- CPU_SSE2 = (1 << 7),
- CPU_SSE3 = (1 << 8),
- CPU_SSSE3= (1 << 9),
- CPU_SSE4A= (1 <<10),
+ CPU_CX8 = (1 << 0), // next bits are from cpuid 1 (EDX)
+ CPU_CMOV = (1 << 1),
+ CPU_FXSR = (1 << 2),
+ CPU_HT = (1 << 3),
+ CPU_MMX = (1 << 4),
+ CPU_3DNOW = (1 << 5), // 3DNow comes from cpuid 0x80000001 (EDX)
+ CPU_SSE = (1 << 6),
+ CPU_SSE2 = (1 << 7),
+ CPU_SSE3 = (1 << 8), // SSE3 comes from cpuid 1 (ECX)
+ CPU_SSSE3 = (1 << 9),
+ CPU_SSE4A = (1 << 10),
CPU_SSE4_1 = (1 << 11),
CPU_SSE4_2 = (1 << 12)
} cpuFeatureFlags;
@@ -360,7 +360,7 @@ public:
result = _cpuid_info.ext_cpuid5_ecx.bits.L1_line_size;
}
if (result < 32) // not defined ?
- result = 32; // 32 bytes by default for other x64
+ result = 32; // 32 bytes by default on x86 and other x64
return result;
}
@@ -395,26 +395,36 @@ public:
// This method should be called before allocate_prefetch_style().
//
// Hardware prefetching (distance/size in bytes):
+ // Pentium 3 - 64 / 32
// Pentium 4 - 256 / 128
+ // Athlon - 64 / 32 ????
// Opteron - 128 / 64 only when 2 sequential cache lines accessed
// Core - 128 / 64
//
// Software prefetching (distance in bytes / instruction with best score):
+ // Pentium 3 - 128 / prefetchnta
// Pentium 4 - 512 / prefetchnta
+ // Athlon - 128 / prefetchnta
// Opteron - 256 / prefetchnta
// Core - 256 / prefetchnta
// It will be used only when AllocatePrefetchStyle > 0
intx count = AllocatePrefetchDistance;
- if (count < 0) { // default ?
- if (is_amd()) { // AMD
- count = 256; // Opteron
- } else { // Intel
- if (cpu_family() == 6) {
- count = 256;// Pentium M, Core, Core2
- } else {
- count = 512;// Pentium 4
- }
+ if (count < 0) { // default ?
+ if (is_amd()) { // AMD
+ if (supports_sse2())
+ count = 256; // Opteron
+ else
+ count = 128; // Athlon
+ } else { // Intel
+ if (supports_sse2())
+ if (cpu_family() == 6) {
+ count = 256; // Pentium M, Core, Core2
+ } else {
+ count = 512; // Pentium 4
+ }
+ else
+ count = 128; // Pentium 3 (and all other old CPUs)
}
}
return count;
diff --git a/hotspot/src/cpu/x86/vm/vm_version_x86_32.hpp b/hotspot/src/cpu/x86/vm/vm_version_x86_32.hpp
deleted file mode 100644
index 54b3cb0370d..00000000000
--- a/hotspot/src/cpu/x86/vm/vm_version_x86_32.hpp
+++ /dev/null
@@ -1,439 +0,0 @@
-/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-class VM_Version: public Abstract_VM_Version {
-public:
- // cpuid result register layouts. These are all unions of a uint32_t
- // (in case anyone wants access to the register as a whole) and a bitfield.
-
- union StdCpuid1Eax {
- uint32_t value;
- struct {
- uint32_t stepping : 4,
- model : 4,
- family : 4,
- proc_type : 2,
- : 2,
- ext_model : 4,
- ext_family : 8,
- : 4;
- } bits;
- };
-
- union StdCpuid1Ebx { // example, unused
- uint32_t value;
- struct {
- uint32_t brand_id : 8,
- clflush_size : 8,
- threads_per_cpu : 8,
- apic_id : 8;
- } bits;
- };
-
- union StdCpuid1Ecx {
- uint32_t value;
- struct {
- uint32_t sse3 : 1,
- : 2,
- monitor : 1,
- : 1,
- vmx : 1,
- : 1,
- est : 1,
- : 1,
- ssse3 : 1,
- cid : 1,
- : 2,
- cmpxchg16: 1,
- : 4,
- dca : 1,
- sse4_1 : 1,
- sse4_2 : 1,
- : 11;
- } bits;
- };
-
- union StdCpuid1Edx {
- uint32_t value;
- struct {
- uint32_t : 4,
- tsc : 1,
- : 3,
- cmpxchg8 : 1,
- : 6,
- cmov : 1,
- : 7,
- mmx : 1,
- fxsr : 1,
- sse : 1,
- sse2 : 1,
- : 1,
- ht : 1,
- : 3;
- } bits;
- };
-
- union DcpCpuid4Eax {
- uint32_t value;
- struct {
- uint32_t cache_type : 5,
- : 21,
- cores_per_cpu : 6;
- } bits;
- };
-
- union DcpCpuid4Ebx {
- uint32_t value;
- struct {
- uint32_t L1_line_size : 12,
- partitions : 10,
- associativity : 10;
- } bits;
- };
-
- union ExtCpuid1Ecx {
- uint32_t value;
- struct {
- uint32_t LahfSahf : 1,
- CmpLegacy : 1,
- : 4,
- abm : 1,
- sse4a : 1,
- misalignsse : 1,
- prefetchw : 1,
- : 22;
- } bits;
- };
-
- union ExtCpuid1Edx {
- uint32_t value;
- struct {
- uint32_t : 22,
- mmx_amd : 1,
- mmx : 1,
- fxsr : 1,
- : 4,
- long_mode : 1,
- tdnow2 : 1,
- tdnow : 1;
- } bits;
- };
-
- union ExtCpuid5Ex {
- uint32_t value;
- struct {
- uint32_t L1_line_size : 8,
- L1_tag_lines : 8,
- L1_assoc : 8,
- L1_size : 8;
- } bits;
- };
-
- union ExtCpuid8Ecx {
- uint32_t value;
- struct {
- uint32_t cores_per_cpu : 8,
- : 24;
- } bits;
- };
-
-protected:
- static int _cpu;
- static int _model;
- static int _stepping;
- static int _cpuFeatures; // features returned by the "cpuid" instruction
- // 0 if this instruction is not available
- static const char* _features_str;
-
- enum {
- CPU_CX8 = (1 << 0), // next bits are from cpuid 1 (EDX)
- CPU_CMOV = (1 << 1),
- CPU_FXSR = (1 << 2),
- CPU_HT = (1 << 3),
- CPU_MMX = (1 << 4),
- CPU_3DNOW= (1 << 5), // 3DNow comes from cpuid 0x80000001 (EDX)
- CPU_SSE = (1 << 6),
- CPU_SSE2 = (1 << 7),
- CPU_SSE3 = (1 << 8), // sse3 comes from cpuid 1 (ECX)
- CPU_SSSE3= (1 << 9),
- CPU_SSE4A= (1 <<10),
- CPU_SSE4_1 = (1 << 11),
- CPU_SSE4_2 = (1 << 12)
- } cpuFeatureFlags;
-
- // cpuid information block. All info derived from executing cpuid with
- // various function numbers is stored here. Intel and AMD info is
- // merged in this block: accessor methods disentangle it.
- //
- // The info block is laid out in subblocks of 4 dwords corresponding to
- // rax, rbx, rcx and rdx, whether or not they contain anything useful.
- struct CpuidInfo {
- // cpuid function 0
- uint32_t std_max_function;
- uint32_t std_vendor_name_0;
- uint32_t std_vendor_name_1;
- uint32_t std_vendor_name_2;
-
- // cpuid function 1
- StdCpuid1Eax std_cpuid1_rax;
- StdCpuid1Ebx std_cpuid1_rbx;
- StdCpuid1Ecx std_cpuid1_rcx;
- StdCpuid1Edx std_cpuid1_rdx;
-
- // cpuid function 4 (deterministic cache parameters)
- DcpCpuid4Eax dcp_cpuid4_rax;
- DcpCpuid4Ebx dcp_cpuid4_rbx;
- uint32_t dcp_cpuid4_rcx; // unused currently
- uint32_t dcp_cpuid4_rdx; // unused currently
-
- // cpuid function 0x80000000 // example, unused
- uint32_t ext_max_function;
- uint32_t ext_vendor_name_0;
- uint32_t ext_vendor_name_1;
- uint32_t ext_vendor_name_2;
-
- // cpuid function 0x80000001
- uint32_t ext_cpuid1_rax; // reserved
- uint32_t ext_cpuid1_rbx; // reserved
- ExtCpuid1Ecx ext_cpuid1_rcx;
- ExtCpuid1Edx ext_cpuid1_rdx;
-
- // cpuid functions 0x80000002 thru 0x80000004: example, unused
- uint32_t proc_name_0, proc_name_1, proc_name_2, proc_name_3;
- uint32_t proc_name_4, proc_name_5, proc_name_6, proc_name_7;
- uint32_t proc_name_8, proc_name_9, proc_name_10,proc_name_11;
-
- // cpuid function 0x80000005 //AMD L1, Intel reserved
- uint32_t ext_cpuid5_rax; // unused currently
- uint32_t ext_cpuid5_rbx; // reserved
- ExtCpuid5Ex ext_cpuid5_rcx; // L1 data cache info (AMD)
- ExtCpuid5Ex ext_cpuid5_rdx; // L1 instruction cache info (AMD)
-
- // cpuid function 0x80000008
- uint32_t ext_cpuid8_rax; // unused currently
- uint32_t ext_cpuid8_rbx; // reserved
- ExtCpuid8Ecx ext_cpuid8_rcx;
- uint32_t ext_cpuid8_rdx; // reserved
- };
-
- // The actual cpuid info block
- static CpuidInfo _cpuid_info;
-
- // Extractors and predicates
- static uint32_t extended_cpu_family() {
- uint32_t result = _cpuid_info.std_cpuid1_rax.bits.family;
- result += _cpuid_info.std_cpuid1_rax.bits.ext_family;
- return result;
- }
- static uint32_t extended_cpu_model() {
- uint32_t result = _cpuid_info.std_cpuid1_rax.bits.model;
- result |= _cpuid_info.std_cpuid1_rax.bits.ext_model << 4;
- return result;
- }
- static uint32_t cpu_stepping() {
- uint32_t result = _cpuid_info.std_cpuid1_rax.bits.stepping;
- return result;
- }
- static uint logical_processor_count() {
- uint result = threads_per_core();
- return result;
- }
- static uint32_t feature_flags() {
- uint32_t result = 0;
- if (_cpuid_info.std_cpuid1_rdx.bits.cmpxchg8 != 0)
- result |= CPU_CX8;
- if (_cpuid_info.std_cpuid1_rdx.bits.cmov != 0)
- result |= CPU_CMOV;
- if (_cpuid_info.std_cpuid1_rdx.bits.fxsr != 0 || is_amd() &&
- _cpuid_info.ext_cpuid1_rdx.bits.fxsr != 0)
- result |= CPU_FXSR;
- // HT flag is set for multi-core processors also.
- if (threads_per_core() > 1)
- result |= CPU_HT;
- if (_cpuid_info.std_cpuid1_rdx.bits.mmx != 0 || is_amd() &&
- _cpuid_info.ext_cpuid1_rdx.bits.mmx != 0)
- result |= CPU_MMX;
- if (is_amd() && _cpuid_info.ext_cpuid1_rdx.bits.tdnow != 0)
- result |= CPU_3DNOW;
- if (_cpuid_info.std_cpuid1_rdx.bits.sse != 0)
- result |= CPU_SSE;
- if (_cpuid_info.std_cpuid1_rdx.bits.sse2 != 0)
- result |= CPU_SSE2;
- if (_cpuid_info.std_cpuid1_rcx.bits.sse3 != 0)
- result |= CPU_SSE3;
- if (_cpuid_info.std_cpuid1_rcx.bits.ssse3 != 0)
- result |= CPU_SSSE3;
- if (is_amd() && _cpuid_info.ext_cpuid1_rcx.bits.sse4a != 0)
- result |= CPU_SSE4A;
- if (_cpuid_info.std_cpuid1_rcx.bits.sse4_1 != 0)
- result |= CPU_SSE4_1;
- if (_cpuid_info.std_cpuid1_rcx.bits.sse4_2 != 0)
- result |= CPU_SSE4_2;
- return result;
- }
-
- static void get_processor_features();
-
-public:
- // Offsets for cpuid asm stub
- static ByteSize std_cpuid0_offset() { return byte_offset_of(CpuidInfo, std_max_function); }
- static ByteSize std_cpuid1_offset() { return byte_offset_of(CpuidInfo, std_cpuid1_rax); }
- static ByteSize dcp_cpuid4_offset() { return byte_offset_of(CpuidInfo, dcp_cpuid4_rax); }
- static ByteSize ext_cpuid1_offset() { return byte_offset_of(CpuidInfo, ext_cpuid1_rax); }
- static ByteSize ext_cpuid5_offset() { return byte_offset_of(CpuidInfo, ext_cpuid5_rax); }
- static ByteSize ext_cpuid8_offset() { return byte_offset_of(CpuidInfo, ext_cpuid8_rax); }
-
- // Initialization
- static void initialize();
-
- // Asserts
- static void assert_is_initialized() {
- assert(_cpuid_info.std_cpuid1_rax.bits.family != 0, "VM_Version not initialized");
- }
-
- //
- // Processor family:
- // 3 - 386
- // 4 - 486
- // 5 - Pentium
- // 6 - PentiumPro, Pentium II, Celeron, Xeon, Pentium III, Athlon,
- // Pentium M, Core Solo, Core Duo, Core2 Duo
- // family 6 model: 9, 13, 14, 15
- // 0x0f - Pentium 4, Opteron
- //
- // Note: The cpu family should be used to select between
- // instruction sequences which are valid on all Intel
- // processors. Use the feature test functions below to
- // determine whether a particular instruction is supported.
- //
- static int cpu_family() { return _cpu;}
- static bool is_P6() { return cpu_family() >= 6; }
-
- static bool is_amd() { assert_is_initialized(); return _cpuid_info.std_vendor_name_0 == 0x68747541; } // 'htuA'
- static bool is_intel() { assert_is_initialized(); return _cpuid_info.std_vendor_name_0 == 0x756e6547; } // 'uneG'
-
- static uint cores_per_cpu() {
- uint result = 1;
- if (is_intel()) {
- result = (_cpuid_info.dcp_cpuid4_rax.bits.cores_per_cpu + 1);
- } else if (is_amd()) {
- result = (_cpuid_info.ext_cpuid8_rcx.bits.cores_per_cpu + 1);
- }
- return result;
- }
-
- static uint threads_per_core() {
- uint result = 1;
- if (_cpuid_info.std_cpuid1_rdx.bits.ht != 0) {
- result = _cpuid_info.std_cpuid1_rbx.bits.threads_per_cpu /
- cores_per_cpu();
- }
- return result;
- }
-
- static intx L1_data_cache_line_size() {
- intx result = 0;
- if (is_intel()) {
- result = (_cpuid_info.dcp_cpuid4_rbx.bits.L1_line_size + 1);
- } else if (is_amd()) {
- result = _cpuid_info.ext_cpuid5_rcx.bits.L1_line_size;
- }
- if (result < 32) // not defined ?
- result = 32; // 32 bytes by default on x86
- return result;
- }
-
- //
- // Feature identification
- //
- static bool supports_cpuid() { return _cpuFeatures != 0; }
- static bool supports_cmpxchg8() { return (_cpuFeatures & CPU_CX8) != 0; }
- static bool supports_cmov() { return (_cpuFeatures & CPU_CMOV) != 0; }
- static bool supports_fxsr() { return (_cpuFeatures & CPU_FXSR) != 0; }
- static bool supports_ht() { return (_cpuFeatures & CPU_HT) != 0; }
- static bool supports_mmx() { return (_cpuFeatures & CPU_MMX) != 0; }
- static bool supports_sse() { return (_cpuFeatures & CPU_SSE) != 0; }
- static bool supports_sse2() { return (_cpuFeatures & CPU_SSE2) != 0; }
- static bool supports_sse3() { return (_cpuFeatures & CPU_SSE3) != 0; }
- static bool supports_ssse3() { return (_cpuFeatures & CPU_SSSE3)!= 0; }
- static bool supports_sse4_1() { return (_cpuFeatures & CPU_SSE4_1) != 0; }
- static bool supports_sse4_2() { return (_cpuFeatures & CPU_SSE4_2) != 0; }
- //
- // AMD features
- //
- static bool supports_3dnow() { return (_cpuFeatures & CPU_3DNOW) != 0; }
- static bool supports_mmx_ext() { return is_amd() && _cpuid_info.ext_cpuid1_rdx.bits.mmx_amd != 0; }
- static bool supports_3dnow2() { return is_amd() && _cpuid_info.ext_cpuid1_rdx.bits.tdnow2 != 0; }
- static bool supports_sse4a() { return (_cpuFeatures & CPU_SSE4A) != 0; }
-
- static bool supports_compare_and_exchange() { return true; }
-
- static const char* cpu_features() { return _features_str; }
-
- static intx allocate_prefetch_distance() {
- // This method should be called before allocate_prefetch_style().
- //
- // Hardware prefetching (distance/size in bytes):
- // Pentium 3 - 64 / 32
- // Pentium 4 - 256 / 128
- // Athlon - 64 / 32 ????
- // Opteron - 128 / 64 only when 2 sequential cache lines accessed
- // Core - 128 / 64
- //
- // Software prefetching (distance in bytes / instruction with best score):
- // Pentium 3 - 128 / prefetchnta
- // Pentium 4 - 512 / prefetchnta
- // Athlon - 128 / prefetchnta
- // Opteron - 256 / prefetchnta
- // Core - 256 / prefetchnta
- // It will be used only when AllocatePrefetchStyle > 0
-
- intx count = AllocatePrefetchDistance;
- if (count < 0) { // default ?
- if (is_amd()) { // AMD
- if (supports_sse2())
- count = 256; // Opteron
- else
- count = 128; // Athlon
- } else { // Intel
- if (supports_sse2())
- if (cpu_family() == 6) {
- count = 256; // Pentium M, Core, Core2
- } else {
- count = 512; // Pentium 4
- }
- else
- count = 128; // Pentium 3 (and all other old CPUs)
- }
- }
- return count;
- }
- static intx allocate_prefetch_style() {
- assert(AllocatePrefetchStyle >= 0, "AllocatePrefetchStyle should be positive");
- // Return 0 if AllocatePrefetchDistance was not defined or
- // prefetch instruction is not supported.
- return (AllocatePrefetchDistance > 0 &&
- (supports_3dnow() || supports_sse())) ? AllocatePrefetchStyle : 0;
- }
-};
diff --git a/hotspot/src/cpu/x86/vm/vm_version_x86_64.cpp b/hotspot/src/cpu/x86/vm/vm_version_x86_64.cpp
deleted file mode 100644
index 7994aab7a78..00000000000
--- a/hotspot/src/cpu/x86/vm/vm_version_x86_64.cpp
+++ /dev/null
@@ -1,419 +0,0 @@
-/*
- * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-# include "incls/_precompiled.incl"
-# include "incls/_vm_version_x86_64.cpp.incl"
-
-int VM_Version::_cpu;
-int VM_Version::_model;
-int VM_Version::_stepping;
-int VM_Version::_cpuFeatures;
-const char* VM_Version::_features_str = "";
-VM_Version::CpuidInfo VM_Version::_cpuid_info = { 0, };
-
-static BufferBlob* stub_blob;
-static const int stub_size = 300;
-
-extern "C" {
- typedef void (*getPsrInfo_stub_t)(void*);
-}
-static getPsrInfo_stub_t getPsrInfo_stub = NULL;
-
-
-class VM_Version_StubGenerator: public StubCodeGenerator {
- public:
-
- VM_Version_StubGenerator(CodeBuffer *c) : StubCodeGenerator(c) {}
-
- address generate_getPsrInfo() {
-
- Label std_cpuid1, ext_cpuid1, ext_cpuid5, done;
-
- StubCodeMark mark(this, "VM_Version", "getPsrInfo_stub");
-# define __ _masm->
-
- address start = __ pc();
-
- //
- // void getPsrInfo(VM_Version::CpuidInfo* cpuid_info);
- //
- // rcx and rdx are first and second argument registers on windows
-
- __ push(rbp);
- __ mov(rbp, c_rarg0); // cpuid_info address
- __ push(rbx);
- __ push(rsi);
-
- //
- // we have a chip which supports the "cpuid" instruction
- //
- __ xorl(rax, rax);
- __ cpuid();
- __ lea(rsi, Address(rbp, in_bytes(VM_Version::std_cpuid0_offset())));
- __ movl(Address(rsi, 0), rax);
- __ movl(Address(rsi, 4), rbx);
- __ movl(Address(rsi, 8), rcx);
- __ movl(Address(rsi,12), rdx);
-
- __ cmpl(rax, 3); // Is cpuid(0x4) supported?
- __ jccb(Assembler::belowEqual, std_cpuid1);
-
- //
- // cpuid(0x4) Deterministic cache params
- //
- __ movl(rax, 4);
- __ xorl(rcx, rcx); // L1 cache
- __ cpuid();
- __ push(rax);
- __ andl(rax, 0x1f); // Determine if valid cache parameters used
- __ orl(rax, rax); // eax[4:0] == 0 indicates invalid cache
- __ pop(rax);
- __ jccb(Assembler::equal, std_cpuid1);
-
- __ lea(rsi, Address(rbp, in_bytes(VM_Version::dcp_cpuid4_offset())));
- __ movl(Address(rsi, 0), rax);
- __ movl(Address(rsi, 4), rbx);
- __ movl(Address(rsi, 8), rcx);
- __ movl(Address(rsi,12), rdx);
-
- //
- // Standard cpuid(0x1)
- //
- __ bind(std_cpuid1);
- __ movl(rax, 1);
- __ cpuid();
- __ lea(rsi, Address(rbp, in_bytes(VM_Version::std_cpuid1_offset())));
- __ movl(Address(rsi, 0), rax);
- __ movl(Address(rsi, 4), rbx);
- __ movl(Address(rsi, 8), rcx);
- __ movl(Address(rsi,12), rdx);
-
- __ movl(rax, 0x80000000);
- __ cpuid();
- __ cmpl(rax, 0x80000000); // Is cpuid(0x80000001) supported?
- __ jcc(Assembler::belowEqual, done);
- __ cmpl(rax, 0x80000004); // Is cpuid(0x80000005) supported?
- __ jccb(Assembler::belowEqual, ext_cpuid1);
- __ cmpl(rax, 0x80000007); // Is cpuid(0x80000008) supported?
- __ jccb(Assembler::belowEqual, ext_cpuid5);
- //
- // Extended cpuid(0x80000008)
- //
- __ movl(rax, 0x80000008);
- __ cpuid();
- __ lea(rsi, Address(rbp, in_bytes(VM_Version::ext_cpuid8_offset())));
- __ movl(Address(rsi, 0), rax);
- __ movl(Address(rsi, 4), rbx);
- __ movl(Address(rsi, 8), rcx);
- __ movl(Address(rsi,12), rdx);
-
- //
- // Extended cpuid(0x80000005)
- //
- __ bind(ext_cpuid5);
- __ movl(rax, 0x80000005);
- __ cpuid();
- __ lea(rsi, Address(rbp, in_bytes(VM_Version::ext_cpuid5_offset())));
- __ movl(Address(rsi, 0), rax);
- __ movl(Address(rsi, 4), rbx);
- __ movl(Address(rsi, 8), rcx);
- __ movl(Address(rsi,12), rdx);
-
- //
- // Extended cpuid(0x80000001)
- //
- __ bind(ext_cpuid1);
- __ movl(rax, 0x80000001);
- __ cpuid();
- __ lea(rsi, Address(rbp, in_bytes(VM_Version::ext_cpuid1_offset())));
- __ movl(Address(rsi, 0), rax);
- __ movl(Address(rsi, 4), rbx);
- __ movl(Address(rsi, 8), rcx);
- __ movl(Address(rsi,12), rdx);
-
- //
- // return
- //
- __ bind(done);
- __ pop(rsi);
- __ pop(rbx);
- __ pop(rbp);
- __ ret(0);
-
-# undef __
-
- return start;
- };
-};
-
-
-void VM_Version::get_processor_features() {
-
- _logical_processors_per_package = 1;
- // Get raw processor info
- getPsrInfo_stub(&_cpuid_info);
- assert_is_initialized();
- _cpu = extended_cpu_family();
- _model = extended_cpu_model();
- _stepping = cpu_stepping();
- _cpuFeatures = feature_flags();
- // Logical processors are only available on P4s and above,
- // and only if hyperthreading is available.
- _logical_processors_per_package = logical_processor_count();
- _supports_cx8 = supports_cmpxchg8();
- // OS should support SSE for x64 and hardware should support at least SSE2.
- if (!VM_Version::supports_sse2()) {
- vm_exit_during_initialization("Unknown x64 processor: SSE2 not supported");
- }
- if (UseSSE < 4) {
- _cpuFeatures &= ~CPU_SSE4_1;
- _cpuFeatures &= ~CPU_SSE4_2;
- }
- if (UseSSE < 3) {
- _cpuFeatures &= ~CPU_SSE3;
- _cpuFeatures &= ~CPU_SSSE3;
- _cpuFeatures &= ~CPU_SSE4A;
- }
- if (UseSSE < 2)
- _cpuFeatures &= ~CPU_SSE2;
- if (UseSSE < 1)
- _cpuFeatures &= ~CPU_SSE;
-
- if (logical_processors_per_package() == 1) {
- // HT processor could be installed on a system which doesn't support HT.
- _cpuFeatures &= ~CPU_HT;
- }
-
- char buf[256];
- jio_snprintf(buf, sizeof(buf), "(%u cores per cpu, %u threads per core) family %d model %d stepping %d%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
- cores_per_cpu(), threads_per_core(),
- cpu_family(), _model, _stepping,
- (supports_cmov() ? ", cmov" : ""),
- (supports_cmpxchg8() ? ", cx8" : ""),
- (supports_fxsr() ? ", fxsr" : ""),
- (supports_mmx() ? ", mmx" : ""),
- (supports_sse() ? ", sse" : ""),
- (supports_sse2() ? ", sse2" : ""),
- (supports_sse3() ? ", sse3" : ""),
- (supports_ssse3()? ", ssse3": ""),
- (supports_sse4_1() ? ", sse4.1" : ""),
- (supports_sse4_2() ? ", sse4.2" : ""),
- (supports_mmx_ext() ? ", mmxext" : ""),
- (supports_3dnow() ? ", 3dnow" : ""),
- (supports_3dnow2() ? ", 3dnowext" : ""),
- (supports_sse4a() ? ", sse4a": ""),
- (supports_ht() ? ", ht": ""));
- _features_str = strdup(buf);
-
- // UseSSE is set to the smaller of what hardware supports and what
- // the command line requires. I.e., you cannot set UseSSE to 2 on
- // older Pentiums which do not support it.
- if( UseSSE > 4 ) UseSSE=4;
- if( UseSSE < 0 ) UseSSE=0;
- if( !supports_sse4_1() ) // Drop to 3 if no SSE4 support
- UseSSE = MIN2((intx)3,UseSSE);
- if( !supports_sse3() ) // Drop to 2 if no SSE3 support
- UseSSE = MIN2((intx)2,UseSSE);
- if( !supports_sse2() ) // Drop to 1 if no SSE2 support
- UseSSE = MIN2((intx)1,UseSSE);
- if( !supports_sse () ) // Drop to 0 if no SSE support
- UseSSE = 0;
-
- // On new cpus instructions which update whole XMM register should be used
- // to prevent partial register stall due to dependencies on high half.
- //
- // UseXmmLoadAndClearUpper == true --> movsd(xmm, mem)
- // UseXmmLoadAndClearUpper == false --> movlpd(xmm, mem)
- // UseXmmRegToRegMoveAll == true --> movaps(xmm, xmm), movapd(xmm, xmm).
- // UseXmmRegToRegMoveAll == false --> movss(xmm, xmm), movsd(xmm, xmm).
-
- if( is_amd() ) { // AMD cpus specific settings
- if( FLAG_IS_DEFAULT(UseAddressNop) ) {
- // Use it on all AMD cpus starting from Opteron (don't need
- // a cpu check since only Opteron and new cpus support 64-bits mode).
- UseAddressNop = true;
- }
- if( FLAG_IS_DEFAULT(UseXmmLoadAndClearUpper) ) {
- if( supports_sse4a() ) {
- UseXmmLoadAndClearUpper = true; // use movsd only on '10h' Opteron
- } else {
- UseXmmLoadAndClearUpper = false;
- }
- }
- if( FLAG_IS_DEFAULT(UseXmmRegToRegMoveAll) ) {
- if( supports_sse4a() ) {
- UseXmmRegToRegMoveAll = true; // use movaps, movapd only on '10h'
- } else {
- UseXmmRegToRegMoveAll = false;
- }
- }
- if( FLAG_IS_DEFAULT(UseXmmI2F) ) {
- if( supports_sse4a() ) {
- UseXmmI2F = true;
- } else {
- UseXmmI2F = false;
- }
- }
- if( FLAG_IS_DEFAULT(UseXmmI2D) ) {
- if( supports_sse4a() ) {
- UseXmmI2D = true;
- } else {
- UseXmmI2D = false;
- }
- }
- }
-
- if( is_intel() ) { // Intel cpus specific settings
- if( FLAG_IS_DEFAULT(UseStoreImmI16) ) {
- UseStoreImmI16 = false; // don't use it on Intel cpus
- }
- if( FLAG_IS_DEFAULT(UseAddressNop) ) {
- // Use it on all Intel cpus starting from PentiumPro
- // (don't need a cpu check since only new cpus support 64-bits mode).
- UseAddressNop = true;
- }
- if( FLAG_IS_DEFAULT(UseXmmLoadAndClearUpper) ) {
- UseXmmLoadAndClearUpper = true; // use movsd on all Intel cpus
- }
- if( FLAG_IS_DEFAULT(UseXmmRegToRegMoveAll) ) {
- if( supports_sse3() ) {
- UseXmmRegToRegMoveAll = true; // use movaps, movapd on new Intel cpus
- } else {
- UseXmmRegToRegMoveAll = false;
- }
- }
- if( cpu_family() == 6 && supports_sse3() ) { // New Intel cpus
-#ifdef COMPILER2
- if( FLAG_IS_DEFAULT(MaxLoopPad) ) {
- // For new Intel cpus do the next optimization:
- // don't align the beginning of a loop if there are enough instructions
- // left (NumberOfLoopInstrToAlign defined in c2_globals.hpp)
- // in current fetch line (OptoLoopAlignment) or the padding
- // is big (> MaxLoopPad).
- // Set MaxLoopPad to 11 for new Intel cpus to reduce number of
- // generated NOP instructions. 11 is the largest size of one
- // address NOP instruction '0F 1F' (see Assembler::nop(i)).
- MaxLoopPad = 11;
- }
-#endif // COMPILER2
- if( FLAG_IS_DEFAULT(UseXMMForArrayCopy) ) {
- UseXMMForArrayCopy = true; // use SSE2 movq on new Intel cpus
- }
- if( supports_sse4_2() && supports_ht() ) { // Newest Intel cpus
- if( FLAG_IS_DEFAULT(UseUnalignedLoadStores) && UseXMMForArrayCopy ) {
- UseUnalignedLoadStores = true; // use movdqu on newest Intel cpus
- }
- }
- }
- }
-
- assert(0 <= ReadPrefetchInstr && ReadPrefetchInstr <= 3, "invalid value");
- assert(0 <= AllocatePrefetchInstr && AllocatePrefetchInstr <= 3, "invalid value");
-
- // set valid Prefetch instruction
- if( ReadPrefetchInstr < 0 ) ReadPrefetchInstr = 0;
- if( ReadPrefetchInstr > 3 ) ReadPrefetchInstr = 3;
- if( ReadPrefetchInstr == 3 && !supports_3dnow() ) ReadPrefetchInstr = 0;
-
- if( AllocatePrefetchInstr < 0 ) AllocatePrefetchInstr = 0;
- if( AllocatePrefetchInstr > 3 ) AllocatePrefetchInstr = 3;
- if( AllocatePrefetchInstr == 3 && !supports_3dnow() ) AllocatePrefetchInstr=0;
-
- // Allocation prefetch settings
- intx cache_line_size = L1_data_cache_line_size();
- if( cache_line_size > AllocatePrefetchStepSize )
- AllocatePrefetchStepSize = cache_line_size;
- if( FLAG_IS_DEFAULT(AllocatePrefetchLines) )
- AllocatePrefetchLines = 3; // Optimistic value
- assert(AllocatePrefetchLines > 0, "invalid value");
- if( AllocatePrefetchLines < 1 ) // set valid value in product VM
- AllocatePrefetchLines = 1; // Conservative value
-
- AllocatePrefetchDistance = allocate_prefetch_distance();
- AllocatePrefetchStyle = allocate_prefetch_style();
-
- if( AllocatePrefetchStyle == 2 && is_intel() &&
- cpu_family() == 6 && supports_sse3() ) { // watermark prefetching on Core
- AllocatePrefetchDistance = 384;
- }
- assert(AllocatePrefetchDistance % AllocatePrefetchStepSize == 0, "invalid value");
-
- // Prefetch settings
- PrefetchCopyIntervalInBytes = prefetch_copy_interval_in_bytes();
- PrefetchScanIntervalInBytes = prefetch_scan_interval_in_bytes();
- PrefetchFieldsAhead = prefetch_fields_ahead();
-
-#ifndef PRODUCT
- if (PrintMiscellaneous && Verbose) {
- tty->print_cr("Logical CPUs per core: %u",
- logical_processors_per_package());
- tty->print_cr("UseSSE=%d",UseSSE);
- tty->print("Allocation: ");
- if (AllocatePrefetchStyle <= 0) {
- tty->print_cr("no prefetching");
- } else {
- if (AllocatePrefetchInstr == 0) {
- tty->print("PREFETCHNTA");
- } else if (AllocatePrefetchInstr == 1) {
- tty->print("PREFETCHT0");
- } else if (AllocatePrefetchInstr == 2) {
- tty->print("PREFETCHT2");
- } else if (AllocatePrefetchInstr == 3) {
- tty->print("PREFETCHW");
- }
- if (AllocatePrefetchLines > 1) {
- tty->print_cr(" %d, %d lines with step %d bytes", AllocatePrefetchDistance, AllocatePrefetchLines, AllocatePrefetchStepSize);
- } else {
- tty->print_cr(" %d, one line", AllocatePrefetchDistance);
- }
- }
- if (PrefetchCopyIntervalInBytes > 0) {
- tty->print_cr("PrefetchCopyIntervalInBytes %d", PrefetchCopyIntervalInBytes);
- }
- if (PrefetchScanIntervalInBytes > 0) {
- tty->print_cr("PrefetchScanIntervalInBytes %d", PrefetchScanIntervalInBytes);
- }
- if (PrefetchFieldsAhead > 0) {
- tty->print_cr("PrefetchFieldsAhead %d", PrefetchFieldsAhead);
- }
- }
-#endif // !PRODUCT
-}
-
-void VM_Version::initialize() {
- ResourceMark rm;
- // Making this stub must be FIRST use of assembler
-
- stub_blob = BufferBlob::create("getPsrInfo_stub", stub_size);
- if (stub_blob == NULL) {
- vm_exit_during_initialization("Unable to allocate getPsrInfo_stub");
- }
- CodeBuffer c(stub_blob->instructions_begin(),
- stub_blob->instructions_size());
- VM_Version_StubGenerator g(&c);
- getPsrInfo_stub = CAST_TO_FN_PTR(getPsrInfo_stub_t,
- g.generate_getPsrInfo());
-
- get_processor_features();
-}
diff --git a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp
index c37370b572b..71f99cba0da 100644
--- a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp
+++ b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -299,13 +299,17 @@ static void check_for_sse_support() {
}
+#endif // AMD64
+
bool os::supports_sse() {
+#ifdef AMD64
+ return true;
+#else
if (sse_status == SSE_UNKNOWN)
check_for_sse_support();
return sse_status == SSE_SUPPORTED;
-}
-
#endif // AMD64
+}
bool os::is_allocatable(size_t bytes) {
#ifdef AMD64
diff --git a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.hpp b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.hpp
index c7f1de37c6b..fd5707cbe37 100644
--- a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.hpp
+++ b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2004 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* 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,9 +41,10 @@
static void fence_bootstrap ();
static void setup_fpu();
- static bool supports_sse();
#endif // AMD64
+ static bool supports_sse();
+
static bool is_allocatable(size_t bytes);
// Used to register dynamic code cache area with the OS
diff --git a/hotspot/src/share/vm/includeDB_core b/hotspot/src/share/vm/includeDB_core
index 8d39f327758..603485132e8 100644
--- a/hotspot/src/share/vm/includeDB_core
+++ b/hotspot/src/share/vm/includeDB_core
@@ -1,5 +1,5 @@
//
-// Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+// Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
//
// This code is free software; you can redistribute it and/or modify it
@@ -176,7 +176,7 @@ arguments.cpp management.hpp
arguments.cpp oop.inline.hpp
arguments.cpp os_.inline.hpp
arguments.cpp universe.inline.hpp
-arguments.cpp vm_version_.hpp
+arguments.cpp vm_version_.hpp
arguments.hpp java.hpp
arguments.hpp perfData.hpp
@@ -241,7 +241,7 @@ assembler.hpp oopRecorder.hpp
assembler.hpp register_.hpp
assembler.hpp relocInfo.hpp
assembler.hpp top.hpp
-assembler.hpp vm_version_.hpp
+assembler.hpp vm_version_.hpp
assembler.inline.hpp assembler.hpp
assembler.inline.hpp codeBuffer.hpp
@@ -280,7 +280,7 @@ atomic.hpp allocation.hpp
atomic_.inline.hpp atomic.hpp
atomic_.inline.hpp os.hpp
-atomic_.inline.hpp vm_version_.hpp
+atomic_.inline.hpp vm_version_.hpp
// attachListener is jck optional, put cpp deps in includeDB_features
@@ -2176,7 +2176,7 @@ interpreterRuntime.cpp templateTable.hpp
interpreterRuntime.cpp threadCritical.hpp
interpreterRuntime.cpp universe.inline.hpp
interpreterRuntime.cpp vmSymbols.hpp
-interpreterRuntime.cpp vm_version_.hpp
+interpreterRuntime.cpp vm_version_.hpp
interpreterRuntime.hpp bytecode.hpp
interpreterRuntime.hpp frame.inline.hpp
@@ -2279,7 +2279,7 @@ java.cpp timer.hpp
java.cpp universe.hpp
java.cpp vmError.hpp
java.cpp vm_operations.hpp
-java.cpp vm_version_.hpp
+java.cpp vm_version_.hpp
java.cpp vtune.hpp
java.hpp os.hpp
@@ -3485,7 +3485,7 @@ register.hpp top.hpp
register_.cpp register_.hpp
register_.hpp register.hpp
-register_.hpp vm_version_.hpp
+register_.hpp vm_version_.hpp
registerMap.hpp globalDefinitions.hpp
registerMap.hpp register_.hpp
@@ -3835,7 +3835,7 @@ statSampler.cpp resourceArea.hpp
statSampler.cpp statSampler.hpp
statSampler.cpp systemDictionary.hpp
statSampler.cpp vmSymbols.hpp
-statSampler.cpp vm_version_.hpp
+statSampler.cpp vm_version_.hpp
statSampler.hpp perfData.hpp
statSampler.hpp task.hpp
@@ -4579,22 +4579,22 @@ vm_operations.hpp top.hpp
vm_version.cpp arguments.hpp
vm_version.cpp oop.inline.hpp
vm_version.cpp universe.hpp
-vm_version.cpp vm_version_.hpp
+vm_version.cpp vm_version_.hpp
vm_version.hpp allocation.hpp
vm_version.hpp ostream.hpp
-vm_version_.cpp assembler_.inline.hpp
-vm_version_.cpp java.hpp
-vm_version_.cpp os_.inline.hpp
-vm_version_.cpp resourceArea.hpp
-vm_version_.cpp stubCodeGenerator.hpp
-vm_version_.cpp vm_version_.hpp
+vm_version_.cpp assembler_.inline.hpp
+vm_version_.cpp java.hpp
+vm_version_.cpp os_.inline.hpp
+vm_version_.cpp resourceArea.hpp
+vm_version_.cpp stubCodeGenerator.hpp
+vm_version_.cpp vm_version_.hpp
-vm_version_.hpp globals_extension.hpp
-vm_version_.hpp vm_version.hpp
+vm_version_.hpp globals_extension.hpp
+vm_version_.hpp vm_version.hpp
-vm_version_.cpp vm_version_.hpp
+vm_version_.cpp vm_version_.hpp
vmreg.cpp assembler.hpp
vmreg.cpp vmreg.hpp
From b07ac51bf3f9553fbdbc7fc8560646e6e97ea40b Mon Sep 17 00:00:00 2001
From: Vladimir Kozlov
Date: Mon, 23 Feb 2009 16:03:19 -0800
Subject: [PATCH 052/292] 6791572: assert("duplicating node that's already been
matched")
Mark inputs for an address expression as shared if there are other uses besides address expressions.
Reviewed-by: never
---
hotspot/src/share/vm/opto/matcher.cpp | 48 ++++++++++++++++++++-------
1 file changed, 36 insertions(+), 12 deletions(-)
diff --git a/hotspot/src/share/vm/opto/matcher.cpp b/hotspot/src/share/vm/opto/matcher.cpp
index e911c065ccd..9f424c0e46d 100644
--- a/hotspot/src/share/vm/opto/matcher.cpp
+++ b/hotspot/src/share/vm/opto/matcher.cpp
@@ -1707,11 +1707,18 @@ OptoReg::Name Matcher::find_receiver( bool is_outgoing ) {
void Matcher::find_shared( Node *n ) {
// Allocate stack of size C->unique() * 2 to avoid frequent realloc
MStack mstack(C->unique() * 2);
+ // Mark nodes as address_visited if they are inputs to an address expression
+ VectorSet address_visited(Thread::current()->resource_area());
mstack.push(n, Visit); // Don't need to pre-visit root node
while (mstack.is_nonempty()) {
n = mstack.node(); // Leave node on stack
Node_State nstate = mstack.state();
+ uint nop = n->Opcode();
if (nstate == Pre_Visit) {
+ if (address_visited.test(n->_idx)) { // Visited in address already?
+ // Flag as visited and shared now.
+ set_visited(n);
+ }
if (is_visited(n)) { // Visited already?
// Node is shared and has no reason to clone. Flag it as shared.
// This causes it to match into a register for the sharing.
@@ -1726,7 +1733,7 @@ void Matcher::find_shared( Node *n ) {
set_visited(n); // Flag as visited now
bool mem_op = false;
- switch( n->Opcode() ) { // Handle some opcodes special
+ switch( nop ) { // Handle some opcodes special
case Op_Phi: // Treat Phis as shared roots
case Op_Parm:
case Op_Proj: // All handled specially during matching
@@ -1887,34 +1894,51 @@ void Matcher::find_shared( Node *n ) {
// to have a single use so force sharing here.
set_shared(m->in(AddPNode::Base)->in(1));
}
+
+ // Some inputs for address expression are not put on stack
+ // to avoid marking them as shared and forcing them into register
+ // if they are used only in address expressions.
+ // But they should be marked as shared if there are other uses
+ // besides address expressions.
+
Node *off = m->in(AddPNode::Offset);
- if( off->is_Con() ) {
- set_visited(m); // Flag as visited now
+ if( off->is_Con() &&
+ // When there are other uses besides address expressions
+ // put it on stack and mark as shared.
+ !is_visited(m) ) {
+ address_visited.test_set(m->_idx); // Flag as address_visited
Node *adr = m->in(AddPNode::Address);
// Intel, ARM and friends can handle 2 adds in addressing mode
if( clone_shift_expressions && adr->is_AddP() &&
// AtomicAdd is not an addressing expression.
// Cheap to find it by looking for screwy base.
- !adr->in(AddPNode::Base)->is_top() ) {
- set_visited(adr); // Flag as visited now
+ !adr->in(AddPNode::Base)->is_top() &&
+ // Are there other uses besides address expressions?
+ !is_visited(adr) ) {
+ address_visited.set(adr->_idx); // Flag as address_visited
Node *shift = adr->in(AddPNode::Offset);
// Check for shift by small constant as well
if( shift->Opcode() == Op_LShiftX && shift->in(2)->is_Con() &&
- shift->in(2)->get_int() <= 3 ) {
- set_visited(shift); // Flag as visited now
+ shift->in(2)->get_int() <= 3 &&
+ // Are there other uses besides address expressions?
+ !is_visited(shift) ) {
+ address_visited.set(shift->_idx); // Flag as address_visited
mstack.push(shift->in(2), Visit);
+ Node *conv = shift->in(1);
#ifdef _LP64
// Allow Matcher to match the rule which bypass
// ConvI2L operation for an array index on LP64
// if the index value is positive.
- if( shift->in(1)->Opcode() == Op_ConvI2L &&
- shift->in(1)->as_Type()->type()->is_long()->_lo >= 0 ) {
- set_visited(shift->in(1)); // Flag as visited now
- mstack.push(shift->in(1)->in(1), Pre_Visit);
+ if( conv->Opcode() == Op_ConvI2L &&
+ conv->as_Type()->type()->is_long()->_lo >= 0 &&
+ // Are there other uses besides address expressions?
+ !is_visited(conv) ) {
+ address_visited.set(conv->_idx); // Flag as address_visited
+ mstack.push(conv->in(1), Pre_Visit);
} else
#endif
- mstack.push(shift->in(1), Pre_Visit);
+ mstack.push(conv, Pre_Visit);
} else {
mstack.push(shift, Pre_Visit);
}
From 07338e17b5b23fc0d5df60d6ef839a5facd1fae3 Mon Sep 17 00:00:00 2001
From: Peter Zhelezniakov
Date: Tue, 24 Feb 2009 19:17:51 +0300
Subject: [PATCH 053/292] 6804221: Three tests for JTabbedPane produce VM crash
on rhel3
Reviewed-by: stayer, campbell
---
jdk/src/solaris/native/sun/awt/gtk2_interface.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/jdk/src/solaris/native/sun/awt/gtk2_interface.c b/jdk/src/solaris/native/sun/awt/gtk2_interface.c
index cfbc5ef6f6e..1afeeef173b 100644
--- a/jdk/src/solaris/native/sun/awt/gtk2_interface.c
+++ b/jdk/src/solaris/native/sun/awt/gtk2_interface.c
@@ -93,6 +93,7 @@ static int gtk2_pixbuf_height = 0;
/* Static buffer for conversion from java.lang.String to UTF-8 */
static char convertionBuffer[CONV_BUFFER_SIZE];
+static gboolean new_combo = TRUE;
const char ENV_PREFIX[] = "GTK_MODULES=";
/*******************/
@@ -608,6 +609,7 @@ gboolean gtk2_load()
dlsym(gtk2_libhandle, "gtk_combo_box_entry_new");
if (fp_gtk_combo_box_entry_new == NULL) {
fp_gtk_combo_box_entry_new = dl_symbol("gtk_combo_new");
+ new_combo = FALSE;
}
fp_gtk_separator_tool_item_new =
@@ -1423,17 +1425,13 @@ static GtkWidget *gtk2_get_widget(WidgetType widget_type)
*/
GtkWidget *combo = (*fp_gtk_combo_box_entry_new)();
- if (widget_type == COMBO_BOX_TEXT_FIELD)
- (*fp_gtk_container_add)((GtkContainer *)combo, result);
- else
- {
+ if (new_combo && widget_type == COMBO_BOX_ARROW_BUTTON) {
(*fp_gtk_widget_set_parent)(result, combo);
((GtkBin*)combo)->child = result;
+ } else {
+ (*fp_gtk_container_add)((GtkContainer *)combo, result);
}
-
(*fp_gtk_container_add)((GtkContainer *)gtk2_fixed, combo);
- (*fp_gtk_widget_realize)(result);
- return result;
}
else if (widget_type != TOOL_TIP &&
widget_type != INTERNAL_FRAME &&
From f883e6fde85a9dc0430b1af0a8686ffad76d8914 Mon Sep 17 00:00:00 2001
From: Antonios Printezis
Date: Tue, 24 Feb 2009 15:50:23 -0500
Subject: [PATCH 054/292] 6804746: G1: guarantee(variance() > -1.0,"variance
should be >= 0") (due to evacuation failure)
Under certain circumstances (evacuation failure) the pause time is not communicated to the policy and, as a result, the pause time field is not initialized properly.
Reviewed-by: jmasa
---
.../share/vm/gc_implementation/g1/g1CollectedHeap.cpp | 5 ++---
.../share/vm/gc_implementation/g1/g1CollectorPolicy.cpp | 9 +++++----
.../share/vm/gc_implementation/g1/g1CollectorPolicy.hpp | 2 +-
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
index 1c6766b9947..8d7b5e18862 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
@@ -2626,9 +2626,8 @@ G1CollectedHeap::do_collection_pause_at_safepoint(HeapRegion* popular_region) {
#endif // SCAN_ONLY_VERBOSE
double end_time_sec = os::elapsedTime();
- if (!evacuation_failed()) {
- g1_policy()->record_pause_time((end_time_sec - start_time_sec)*1000.0);
- }
+ double pause_time_ms = (end_time_sec - start_time_sec) * MILLIUNITS;
+ g1_policy()->record_pause_time_ms(pause_time_ms);
GCOverheadReporter::recordSTWEnd(end_time_sec);
g1_policy()->record_collection_pause_end(popular_region != NULL,
abandoned);
diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp
index 949e3f99700..142a4e24fcc 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp
@@ -1014,7 +1014,7 @@ void G1CollectorPolicy::record_full_collection_end() {
_all_full_gc_times_ms->add(full_gc_time_ms);
- update_recent_gc_times(end_sec, full_gc_time_sec);
+ update_recent_gc_times(end_sec, full_gc_time_ms);
_g1->clear_full_collection();
@@ -1475,6 +1475,7 @@ void G1CollectorPolicy::record_collection_pause_end(bool popular,
size_t cur_used_bytes = _g1->used();
assert(cur_used_bytes == _g1->recalculate_used(), "It should!");
bool last_pause_included_initial_mark = false;
+ bool update_stats = !abandoned && !_g1->evacuation_failed();
#ifndef PRODUCT
if (G1YoungSurvRateVerbose) {
@@ -1535,7 +1536,7 @@ void G1CollectorPolicy::record_collection_pause_end(bool popular,
_n_pauses++;
- if (!abandoned) {
+ if (update_stats) {
_recent_CH_strong_roots_times_ms->add(_cur_CH_strong_roots_dur_ms);
_recent_G1_strong_roots_times_ms->add(_cur_G1_strong_roots_dur_ms);
_recent_evac_times_ms->add(evac_ms);
@@ -1636,7 +1637,7 @@ void G1CollectorPolicy::record_collection_pause_end(bool popular,
double termination_time = avg_value(_par_last_termination_times_ms);
double parallel_other_time;
- if (!abandoned) {
+ if (update_stats) {
MainBodySummary* body_summary = summary->main_body_summary();
guarantee(body_summary != NULL, "should not be null!");
@@ -1852,7 +1853,7 @@ void G1CollectorPolicy::record_collection_pause_end(bool popular,
//
- if (!popular && !abandoned) {
+ if (!popular && update_stats) {
double pause_time_ms = elapsed_ms;
size_t diff = 0;
diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp
index 1649584cd31..404e292b844 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp
@@ -966,7 +966,7 @@ public:
record_termination_time(0, ms);
}
- void record_pause_time(double ms) {
+ void record_pause_time_ms(double ms) {
_last_pause_time_ms = ms;
}
From 34f01f340ef747ada113f4002f2f6b2e992678aa Mon Sep 17 00:00:00 2001
From: Jennifer Godinez
Date: Tue, 24 Feb 2009 14:32:17 -0800
Subject: [PATCH 055/292] 6750383: 2D_PrintingTiger\PrintDocOrientationTest
fails, wrong orientated images are printed
Reviewed-by: campbell, prr
---
jdk/src/solaris/classes/sun/print/IPPPrintService.java | 6 ++++++
jdk/src/solaris/classes/sun/print/UnixPrintJob.java | 4 ++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/jdk/src/solaris/classes/sun/print/IPPPrintService.java b/jdk/src/solaris/classes/sun/print/IPPPrintService.java
index 07b68b18fa8..ec5344ae379 100644
--- a/jdk/src/solaris/classes/sun/print/IPPPrintService.java
+++ b/jdk/src/solaris/classes/sun/print/IPPPrintService.java
@@ -661,6 +661,12 @@ public class IPPPrintService implements PrintService, SunPrinterJobService {
}
}
} else if (category == OrientationRequested.class) {
+ if (flavor.equals(DocFlavor.INPUT_STREAM.POSTSCRIPT) ||
+ flavor.equals(DocFlavor.URL.POSTSCRIPT) ||
+ flavor.equals(DocFlavor.BYTE_ARRAY.POSTSCRIPT)) {
+ return null;
+ }
+
boolean revPort = false;
OrientationRequested[] orientSup = null;
diff --git a/jdk/src/solaris/classes/sun/print/UnixPrintJob.java b/jdk/src/solaris/classes/sun/print/UnixPrintJob.java
index 1a96e92f2c8..b4da652a8fc 100644
--- a/jdk/src/solaris/classes/sun/print/UnixPrintJob.java
+++ b/jdk/src/solaris/classes/sun/print/UnixPrintJob.java
@@ -362,10 +362,10 @@ public class UnixPrintJob implements CancelablePrintJob {
mOptions += " number-up="+nUp.getValue();
}
- if (orient == OrientationRequested.LANDSCAPE &&
+ if (orient != OrientationRequested.PORTRAIT &&
(flavor != null) &&
!flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE)) {
- mOptions += " landscape";
+ mOptions += " orientation-requested="+orient.getValue();
}
if (sides != null) {
From 0b44eecef272e5910ce6b8bdb790a3db7cf34435 Mon Sep 17 00:00:00 2001
From: Joe Darcy
Date: Tue, 24 Feb 2009 17:16:18 -0800
Subject: [PATCH 056/292] 6501749: 6501749 Filer should state connection
between created files and root elements
Reviewed-by: jjg
---
.../share/classes/javax/annotation/processing/Filer.java | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/langtools/src/share/classes/javax/annotation/processing/Filer.java b/langtools/src/share/classes/javax/annotation/processing/Filer.java
index e0da17b5169..7ebdc6fb72a 100644
--- a/langtools/src/share/classes/javax/annotation/processing/Filer.java
+++ b/langtools/src/share/classes/javax/annotation/processing/Filer.java
@@ -35,9 +35,11 @@ import java.io.IOException;
* processor. Files created in this way will be known to the
* annotation processing tool implementing this interface, better
* enabling the tool to manage them. Source and class files so
- * created will be considered for processing by the tool after the
- * {@code close} method has been called on the {@code Writer} or
- * {@code OutputStream} used to write the contents of the file.
+ * created will be {@linkplain RoundEnvironment#getRootElements
+ * considered for processing} by the tool in a subsequent {@linkplain
+ * RoundEnvironment round of processing} after the {@code close}
+ * method has been called on the {@code Writer} or {@code
+ * OutputStream} used to write the contents of the file.
*
* Three kinds of files are distinguished: source files, class files,
* and auxiliary resource files.
From 178049faf3b09f0ebb585cac30472b25a219e4e5 Mon Sep 17 00:00:00 2001
From: Joe Darcy
Date: Tue, 24 Feb 2009 17:48:53 -0800
Subject: [PATCH 057/292] 6498938: Faulty comparison of TypeMirror objects in
getElementsAnnotatedWith implementation
Reviewed-by: jjg
---
.../processing/JavacRoundEnvironment.java | 11 +++--
.../processing/environment/round/Foo.java | 27 +++++++++++
.../round/TestElementsAnnotatedWith.java | 46 +++++++++++++++++--
3 files changed, 77 insertions(+), 7 deletions(-)
create mode 100644 langtools/test/tools/javac/processing/environment/round/Foo.java
diff --git a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java
index f6af2af4698..bdf2671bff0 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -111,6 +111,7 @@ public class JavacRoundEnvironment implements RoundEnvironment {
*/
public Set extends Element> getElementsAnnotatedWith(TypeElement a) {
Set result = Collections.emptySet();
+ Types typeUtil = processingEnv.getTypeUtils();
if (a.getKind() != ElementKind.ANNOTATION_TYPE)
throw new IllegalArgumentException(NOT_AN_ANNOTATION_TYPE + a);
@@ -122,7 +123,7 @@ public class JavacRoundEnvironment implements RoundEnvironment {
throw new AssertionError("Bad implementation type for " + tm);
ElementScanner6, DeclaredType> scanner =
- new AnnotationSetScanner(result);
+ new AnnotationSetScanner(result, typeUtil);
for (Element element : rootElements)
result = scanner.scan(element, annotationTypeElement);
@@ -135,9 +136,11 @@ public class JavacRoundEnvironment implements RoundEnvironment {
ElementScanner6, DeclaredType> {
// Insertion-order preserving set
Set annotatedElements = new LinkedHashSet();
+ Types typeUtil;
- AnnotationSetScanner(Set defaultSet) {
+ AnnotationSetScanner(Set defaultSet, Types typeUtil) {
super(defaultSet);
+ this.typeUtil = typeUtil;
}
@Override
@@ -145,7 +148,7 @@ public class JavacRoundEnvironment implements RoundEnvironment {
java.util.List extends AnnotationMirror> annotationMirrors =
processingEnv.getElementUtils().getAllAnnotationMirrors(e);
for (AnnotationMirror annotationMirror : annotationMirrors) {
- if (annotationMirror.getAnnotationType().equals(p))
+ if (typeUtil.isSameType(annotationMirror.getAnnotationType(), p))
annotatedElements.add(e);
}
e.accept(this, p);
diff --git a/langtools/test/tools/javac/processing/environment/round/Foo.java b/langtools/test/tools/javac/processing/environment/round/Foo.java
new file mode 100644
index 00000000000..58ada1d4f95
--- /dev/null
+++ b/langtools/test/tools/javac/processing/environment/round/Foo.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+@AnnotatedElementInfo(annotationName="AnnotatedElementInfo",
+ expectedSize=1,
+ names="Foo")
+public class Foo {}
diff --git a/langtools/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java b/langtools/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java
index 2a948350bab..867c3c40b97 100644
--- a/langtools/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java
+++ b/langtools/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2006-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2006-2009 Sun Microsystems, Inc. All Rights Reserved.
* 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 6397298 6400986 6425592 6449798 6453386 6508401
+ * @bug 6397298 6400986 6425592 6449798 6453386 6508401 6498938
* @summary Tests that getElementsAnnotatedWith works properly.
* @author Joseph D. Darcy
* @compile TestElementsAnnotatedWith.java
@@ -31,16 +31,22 @@
* @compile -processor TestElementsAnnotatedWith -proc:only SurfaceAnnotations.java
* @compile -processor TestElementsAnnotatedWith -proc:only BuriedAnnotations.java
* @compile -processor TestElementsAnnotatedWith -proc:only Part1.java Part2.java
- * @compile -processor TestElementsAnnotatedWith -proc:only TestElementsAnnotatedWith.java
* @compile -processor TestElementsAnnotatedWith -proc:only C2.java
+ * @compile -processor TestElementsAnnotatedWith -proc:only Foo.java
+ * @compile -XD-d=. Foo.java
+ * @compile -processor TestElementsAnnotatedWith -proc:only TestElementsAnnotatedWith.java
*/
import java.lang.annotation.Annotation;
+import java.io.*;
import java.util.Collections;
import java.util.Set;
import java.util.HashSet;
+import java.util.List;
+import java.util.ArrayList;
import java.util.Arrays;
import javax.annotation.processing.*;
+import javax.tools.*;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.*;
import javax.lang.model.util.*;
@@ -120,6 +126,9 @@ public class TestElementsAnnotatedWith extends AbstractProcessor {
System.err.println("AnnotatedElementInfo: " + annotatedElementInfo);
throw new RuntimeException();
}
+
+ if("TestElementsAnnotatedWith".equals(firstType.getSimpleName().toString()))
+ writeClassFile(); // Start another round to test class file input
} else {
// If processing is over without an error, the specified
// elements should be empty so an empty set should be returned.
@@ -161,6 +170,37 @@ public class TestElementsAnnotatedWith extends AbstractProcessor {
} catch(IllegalArgumentException iae) {}
}
+ /*
+ * Hack alert! The class file read below is generated by the
+ * "@compile -XD-d=. Foo.java" directive above. This sneakily
+ * overrides the output location to the current directory where a
+ * subsequent @compile can read the file. This could be improved
+ * if either a new directive like @process accepted class file
+ * arguments (the javac command accepts such arguments but
+ * @compile does not) or the test.src and test.classes properties
+ * were set to be read with @compile jobs.
+ */
+ private void writeClassFile() {
+ try {
+ Filer filer = processingEnv.getFiler();
+ JavaFileObject jfo = filer.createClassFile("Foo");
+ OutputStream os = jfo.openOutputStream();
+ // Copy the bytes over
+ System.out.println((new File(".")).getAbsolutePath());
+ InputStream io = new BufferedInputStream(new FileInputStream(new File(".", "Foo.class")));
+ int datum = io.read();
+ while(datum != -1) {
+ os.write(datum);
+ datum = io.read();
+ }
+ os.close();
+ } catch (IOException io) {
+ throw new RuntimeException(io);
+ }
+
+
+ }
+
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
From b051a23591c41c16d1368b78e00fcf4df14f3db8 Mon Sep 17 00:00:00 2001
From: Jon Masamitsu
Date: Tue, 24 Feb 2009 22:12:24 -0800
Subject: [PATCH 058/292] 6806226: Signed integer overflow in growable array
code causes JVM crash
Workaround the overflow by doing the intermediate calculations in an unsigned variable.
Reviewed-by: ysr, jcoomes
---
hotspot/src/share/vm/utilities/growableArray.cpp | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/hotspot/src/share/vm/utilities/growableArray.cpp b/hotspot/src/share/vm/utilities/growableArray.cpp
index eeb259c5317..8ad410249b4 100644
--- a/hotspot/src/share/vm/utilities/growableArray.cpp
+++ b/hotspot/src/share/vm/utilities/growableArray.cpp
@@ -43,11 +43,13 @@ void GenericGrowableArray::check_nesting() {
#endif
void* GenericGrowableArray::raw_allocate(int elementSize) {
+ assert(_max >= 0, "integer overflow");
+ size_t byte_size = elementSize * (size_t) _max;
if (on_stack()) {
- return (void*)resource_allocate_bytes(elementSize * _max);
+ return (void*)resource_allocate_bytes(byte_size);
} else if (on_C_heap()) {
- return (void*)AllocateHeap(elementSize * _max, "GrET in " __FILE__);
+ return (void*)AllocateHeap(byte_size, "GrET in " __FILE__);
} else {
- return _arena->Amalloc(elementSize * _max);
+ return _arena->Amalloc(byte_size);
}
}
From a82243d8874d390a58956c5752ac72c7a2024631 Mon Sep 17 00:00:00 2001
From: Tom Rodriguez
Date: Wed, 25 Feb 2009 10:53:14 -0800
Subject: [PATCH 059/292] 6805427: adlc compiler may generate incorrect
machnode emission code
Reviewed-by: kvn, twisti
---
hotspot/src/share/vm/adlc/formssel.cpp | 19 ++++++++++++-------
hotspot/src/share/vm/adlc/formssel.hpp | 9 ++++++---
2 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/hotspot/src/share/vm/adlc/formssel.cpp b/hotspot/src/share/vm/adlc/formssel.cpp
index c265c1d04c7..12477be68ac 100644
--- a/hotspot/src/share/vm/adlc/formssel.cpp
+++ b/hotspot/src/share/vm/adlc/formssel.cpp
@@ -1217,13 +1217,17 @@ void InstructForm::rep_var_format(FILE *fp, const char *rep_var) {
// Seach through operands to determine parameters unique positions.
void InstructForm::set_unique_opnds() {
uint* uniq_idx = NULL;
- uint nopnds = num_opnds();
+ int nopnds = num_opnds();
uint num_uniq = nopnds;
- uint i;
+ int i;
+ _uniq_idx_length = 0;
if ( nopnds > 0 ) {
- // Allocate index array with reserve.
- uniq_idx = (uint*) malloc(sizeof(uint)*(nopnds + 2));
- for( i = 0; i < nopnds+2; i++ ) {
+ // Allocate index array. Worst case we're mapping from each
+ // component back to an index and any DEF always goes at 0 so the
+ // length of the array has to be the number of components + 1.
+ _uniq_idx_length = _components.count() + 1;
+ uniq_idx = (uint*) malloc(sizeof(uint)*(_uniq_idx_length));
+ for( i = 0; i < _uniq_idx_length; i++ ) {
uniq_idx[i] = i;
}
}
@@ -1238,8 +1242,8 @@ void InstructForm::set_unique_opnds() {
_parameters.reset();
while( (name = _parameters.iter()) != NULL ) {
count = 0;
- uint position = 0;
- uint uniq_position = 0;
+ int position = 0;
+ int uniq_position = 0;
_components.reset();
Component *comp = NULL;
if( sets_result() ) {
@@ -1255,6 +1259,7 @@ void InstructForm::set_unique_opnds() {
}
if( strcmp(name, comp->_name)==0 ) {
if( ++count > 1 ) {
+ assert(position < _uniq_idx_length, "out of bounds");
uniq_idx[position] = uniq_position;
has_dupl_use = true;
} else {
diff --git a/hotspot/src/share/vm/adlc/formssel.hpp b/hotspot/src/share/vm/adlc/formssel.hpp
index a363f16ee41..e1aa84d91ca 100644
--- a/hotspot/src/share/vm/adlc/formssel.hpp
+++ b/hotspot/src/share/vm/adlc/formssel.hpp
@@ -101,6 +101,7 @@ public:
const char *_ins_pipe; // Instruction Scheduline description class
uint *_uniq_idx; // Indexes of unique operands
+ int _uniq_idx_length; // Length of _uniq_idx array
uint _num_uniq; // Number of unique operands
ComponentList _components; // List of Components matches MachNode's
// operand structure
@@ -257,11 +258,13 @@ public:
void set_unique_opnds();
uint num_unique_opnds() { return _num_uniq; }
uint unique_opnds_idx(int idx) {
- if( _uniq_idx != NULL && idx > 0 )
+ if( _uniq_idx != NULL && idx > 0 ) {
+ assert(idx < _uniq_idx_length, "out of bounds");
return _uniq_idx[idx];
- else
+ } else {
return idx;
- }
+ }
+ }
// Operands which are only KILLs aren't part of the input array and
// require special handling in some cases. Their position in this
From f7098831dde98a67b776d0bc9bdc22c963e95579 Mon Sep 17 00:00:00 2001
From: Tom Rodriguez
Date: Wed, 25 Feb 2009 14:36:27 -0800
Subject: [PATCH 060/292] 6807963: need tool to make sense of LogCompilaton
output
Reviewed-by: kvn
---
.../src/share/tools/LogCompilation/Makefile | 75 +++
hotspot/src/share/tools/LogCompilation/README | 18 +
.../share/tools/LogCompilation/manifest.mf | 1 +
.../hotspot/tools/compiler/BasicLogEvent.java | 75 +++
.../sun/hotspot/tools/compiler/CallSite.java | 183 ++++++++
.../hotspot/tools/compiler/Compilation.java | 236 ++++++++++
.../sun/hotspot/tools/compiler/Constants.java | 46 ++
.../tools/compiler/LogCleanupReader.java | 212 +++++++++
.../tools/compiler/LogCompilation.java | 177 +++++++
.../sun/hotspot/tools/compiler/LogEvent.java | 38 ++
.../sun/hotspot/tools/compiler/LogParser.java | 430 ++++++++++++++++++
.../tools/compiler/MakeNotEntrantEvent.java | 55 +++
.../sun/hotspot/tools/compiler/Method.java | 120 +++++
.../sun/hotspot/tools/compiler/NMethod.java | 60 +++
.../com/sun/hotspot/tools/compiler/Phase.java | 63 +++
.../tools/compiler/UncommonTrapEvent.java | 84 ++++
16 files changed, 1873 insertions(+)
create mode 100644 hotspot/src/share/tools/LogCompilation/Makefile
create mode 100644 hotspot/src/share/tools/LogCompilation/README
create mode 100644 hotspot/src/share/tools/LogCompilation/manifest.mf
create mode 100644 hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/BasicLogEvent.java
create mode 100644 hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/CallSite.java
create mode 100644 hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Compilation.java
create mode 100644 hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Constants.java
create mode 100644 hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogCleanupReader.java
create mode 100644 hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogCompilation.java
create mode 100644 hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogEvent.java
create mode 100644 hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogParser.java
create mode 100644 hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/MakeNotEntrantEvent.java
create mode 100644 hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Method.java
create mode 100644 hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/NMethod.java
create mode 100644 hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Phase.java
create mode 100644 hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/UncommonTrapEvent.java
diff --git a/hotspot/src/share/tools/LogCompilation/Makefile b/hotspot/src/share/tools/LogCompilation/Makefile
new file mode 100644
index 00000000000..2a2e2a5d71a
--- /dev/null
+++ b/hotspot/src/share/tools/LogCompilation/Makefile
@@ -0,0 +1,75 @@
+#
+# Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+#
+PKGLIST = \
+com.sun.hotspot.tools.compiler
+#END PKGLIST
+
+FILELIST = com/sun/hotspot/tools/compiler/*.java
+
+ifneq "x$(ALT_BOOTDIR)" "x"
+ BOOTDIR := $(ALT_BOOTDIR)
+endif
+
+ifeq "x$(BOOTDIR)" "x"
+ JDK_HOME := $(shell dirname $(shell which java))/..
+else
+ JDK_HOME := $(BOOTDIR)
+endif
+
+isUnix := $(shell test -r c:/; echo $$?)
+
+ifeq "$(isUnix)" "1"
+ CPS := :
+else
+ CPS := ";"
+endif
+
+SRC_DIR = src
+BUILD_DIR = build
+OUTPUT_DIR = $(BUILD_DIR)/classes
+
+# gnumake 3.78.1 does not accept the *s,
+# so use the shell to expand them
+ALLFILES := $(patsubst %,$(SRC_DIR)/%,$(FILELIST))
+ALLFILES := $(shell /bin/ls $(ALLFILES))
+
+JAVAC = $(JDK_HOME)/bin/javac
+JAR = $(JDK_HOME)/bin/jar
+
+# Tagging it on because there's no reason not to run it
+all: logc.jar
+
+logc.jar: filelist manifest.mf
+ @mkdir -p $(OUTPUT_DIR)
+ $(JAVAC) -source 1.5 -deprecation -sourcepath $(SRC_DIR) -d $(OUTPUT_DIR) @filelist
+ $(JAR) cvfm logc.jar manifest.mf -C $(OUTPUT_DIR) com
+
+.PHONY: filelist
+filelist: $(ALLFILES)
+ @rm -f $@
+ @echo $(ALLFILES) > $@
+
+clean::
+ rm -rf filelist logc.jar
+ rm -rf $(BUILD_DIR)
diff --git a/hotspot/src/share/tools/LogCompilation/README b/hotspot/src/share/tools/LogCompilation/README
new file mode 100644
index 00000000000..ed3cbbc8121
--- /dev/null
+++ b/hotspot/src/share/tools/LogCompilation/README
@@ -0,0 +1,18 @@
+This is a very rough tool for parsing -XX:+LogCompilation output.
+It's main purpose is to recreate output similar to
+-XX:+PrintCompilation -XX:+PrintInlining output from a debug JVM. It
+requires a 1.5 JDK to build and simply typing make should build it.
+
+It produces a jar file, logc.jar, that can be run on the
+hotspot.log from LogCompilation output like this:
+
+ java -jar logc.jar hotspot.log
+
+This will produce something like the normal PrintCompilation output.
+Adding the -i option with also report inlining like PrintInlining.
+
+More information about the LogCompilation output can be found at
+
+http://wikis.sun.com/display/HotSpotInternals/LogCompilation+overview
+http://wikis.sun.com/display/HotSpotInternals/PrintCompilation
+http://wikis.sun.com/display/HotSpotInternals/LogCompilation+tool
diff --git a/hotspot/src/share/tools/LogCompilation/manifest.mf b/hotspot/src/share/tools/LogCompilation/manifest.mf
new file mode 100644
index 00000000000..62a36155dd0
--- /dev/null
+++ b/hotspot/src/share/tools/LogCompilation/manifest.mf
@@ -0,0 +1 @@
+Main-Class: com.sun.hotspot.tools.compiler.LogCompilation
diff --git a/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/BasicLogEvent.java b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/BasicLogEvent.java
new file mode 100644
index 00000000000..8d9d630a474
--- /dev/null
+++ b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/BasicLogEvent.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package com.sun.hotspot.tools.compiler;
+
+import java.io.PrintStream;
+
+/**
+ *
+ * @author never
+ */
+public abstract class BasicLogEvent implements LogEvent {
+
+ protected final String id;
+ protected final double start;
+ protected double end;
+ protected Compilation compilation;
+
+ BasicLogEvent(double start, String id) {
+ this.start = start;
+ this.end = start;
+ this.id = id;
+ }
+
+ public double getStart() {
+ return start;
+ }
+
+ public double getEnd() {
+ return end;
+ }
+
+ public void setEnd(double end) {
+ this.end = end;
+ }
+
+ public double getElapsedTime() {
+ return ((int) ((getEnd() - getStart()) * 1000)) / 1000.0;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public Compilation getCompilation() {
+ return compilation;
+ }
+
+ public void setCompilation(Compilation compilation) {
+ this.compilation = compilation;
+ }
+
+ abstract public void print(PrintStream stream);
+}
diff --git a/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/CallSite.java b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/CallSite.java
new file mode 100644
index 00000000000..bf96b1fbc91
--- /dev/null
+++ b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/CallSite.java
@@ -0,0 +1,183 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package com.sun.hotspot.tools.compiler;
+
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+
+public class CallSite {
+
+ private int bci;
+ private Method method;
+ private int count;
+ private String receiver;
+ private int receiver_count;
+ private String reason;
+ private List calls;
+
+ CallSite() {
+ }
+
+ CallSite(int bci, Method m) {
+ this.bci = bci;
+ this.method = m;
+ }
+
+ void add(CallSite site) {
+ if (getCalls() == null) {
+ setCalls(new ArrayList());
+ }
+ getCalls().add(site);
+ }
+
+ CallSite last() {
+ return last(-1);
+ }
+
+ CallSite last(int fromEnd) {
+ return getCalls().get(getCalls().size() + fromEnd);
+ }
+
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ if (getReason() == null) {
+ sb.append(" @ " + getBci() + " " + getMethod());
+ } else {
+ sb.append("- @ " + getBci() + " " + getMethod() + " " + getReason());
+ }
+ sb.append("\n");
+ if (getCalls() != null) {
+ for (CallSite site : getCalls()) {
+ sb.append(site);
+ sb.append("\n");
+ }
+ }
+ return sb.toString();
+ }
+
+ public void print(PrintStream stream) {
+ print(stream, 0);
+ }
+
+ void emit(PrintStream stream, int indent) {
+ for (int i = 0; i < indent; i++) {
+ stream.print(' ');
+ }
+ }
+ private static boolean compat = true;
+
+ public void print(PrintStream stream, int indent) {
+ emit(stream, indent);
+ String m = getMethod().getHolder().replace('/', '.') + "::" + getMethod().getName();
+ if (getReason() == null) {
+ stream.println(" @ " + getBci() + " " + m + " (" + getMethod().getBytes() + " bytes)");
+
+ } else {
+ if (isCompat()) {
+ stream.println(" @ " + getBci() + " " + m + " " + getReason());
+ } else {
+ stream.println("- @ " + getBci() + " " + m +
+ " (" + getMethod().getBytes() + " bytes) " + getReason());
+ }
+ }
+ if (getReceiver() != null) {
+ emit(stream, indent + 3);
+ // stream.println("type profile " + method.holder + " -> " + receiver + " (" +
+ // receiver_count + "/" + count + "," + (receiver_count * 100 / count) + "%)");
+ stream.println("type profile " + getMethod().getHolder() + " -> " + getReceiver() + " (" +
+ (getReceiverCount() * 100 / getCount()) + "%)");
+ }
+ if (getCalls() != null) {
+ for (CallSite site : getCalls()) {
+ site.print(stream, indent + 2);
+ }
+ }
+ }
+
+ public int getBci() {
+ return bci;
+ }
+
+ public void setBci(int bci) {
+ this.bci = bci;
+ }
+
+ public Method getMethod() {
+ return method;
+ }
+
+ public void setMethod(Method method) {
+ this.method = method;
+ }
+
+ public int getCount() {
+ return count;
+ }
+
+ public void setCount(int count) {
+ this.count = count;
+ }
+
+ public String getReceiver() {
+ return receiver;
+ }
+
+ public void setReceiver(String receiver) {
+ this.receiver = receiver;
+ }
+
+ public int getReceiverCount() {
+ return receiver_count;
+ }
+
+ public void setReceiver_count(int receiver_count) {
+ this.receiver_count = receiver_count;
+ }
+
+ public String getReason() {
+ return reason;
+ }
+
+ public void setReason(String reason) {
+ this.reason = reason;
+ }
+
+ public List getCalls() {
+ return calls;
+ }
+
+ public void setCalls(List calls) {
+ this.calls = calls;
+ }
+
+ public static boolean isCompat() {
+ return compat;
+ }
+
+ public static void setCompat(boolean aCompat) {
+ compat = aCompat;
+ }
+}
diff --git a/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Compilation.java b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Compilation.java
new file mode 100644
index 00000000000..3695ebd01e0
--- /dev/null
+++ b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Compilation.java
@@ -0,0 +1,236 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package com.sun.hotspot.tools.compiler;
+
+import java.io.PrintStream;
+import java.util.ArrayList;
+
+public class Compilation implements LogEvent {
+
+ private int id;
+ private boolean osr;
+ private Method method;
+ private CallSite call = new CallSite();
+ private int osrBci;
+ private String icount;
+ private String bcount;
+ private String special;
+ private double start;
+ private double end;
+ private int attempts;
+ private NMethod nmethod;
+ private ArrayList phases = new ArrayList(4);
+ private String failureReason;
+
+ Compilation(int id) {
+ this.id = id;
+ }
+
+ Phase getPhase(String s) {
+ for (Phase p : getPhases()) {
+ if (p.getName().equals(s)) {
+ return p;
+ }
+ }
+ return null;
+ }
+
+ double getRegallocTime() {
+ return getPhase("regalloc").getElapsedTime();
+ }
+
+ public double getStart() {
+ return start;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(getId());
+ sb.append(" ");
+ sb.append(getMethod());
+ sb.append(" ");
+ sb.append(getIcount());
+ sb.append("+");
+ sb.append(getBcount());
+ sb.append("\n");
+ for (CallSite site : getCall().getCalls()) {
+ sb.append(site);
+ sb.append("\n");
+ }
+ return sb.toString();
+ }
+
+ public void printShort(PrintStream stream) {
+ if (getMethod() == null) {
+ stream.println(getSpecial());
+ } else {
+ int bc = isOsr() ? getOsr_bci() : -1;
+ stream.print(getId() + getMethod().decodeFlags(bc) + getMethod().format(bc));
+ }
+ }
+
+ public void print(PrintStream stream) {
+ print(stream, 0, false);
+ }
+
+ public void print(PrintStream stream, boolean printInlining) {
+ print(stream, 0, printInlining);
+ }
+
+ public void print(PrintStream stream, int indent, boolean printInlining) {
+ if (getMethod() == null) {
+ stream.println(getSpecial());
+ } else {
+ int bc = isOsr() ? getOsr_bci() : -1;
+ stream.print(getId() + getMethod().decodeFlags(bc) + getMethod().format(bc));
+ stream.println();
+ if (getFailureReason() != null) {
+ stream.println("COMPILE FAILED " + getFailureReason());
+ }
+ if (printInlining && call.getCalls() != null) {
+ for (CallSite site : call.getCalls()) {
+ site.print(stream, indent + 2);
+ }
+ }
+ }
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public boolean isOsr() {
+ return osr;
+ }
+
+ public void setOsr(boolean osr) {
+ this.osr = osr;
+ }
+
+ public int getOsr_bci() {
+ return osrBci;
+ }
+
+ public void setOsr_bci(int osrBci) {
+ this.osrBci = osrBci;
+ }
+
+ public String getIcount() {
+ return icount;
+ }
+
+ public void setICount(String icount) {
+ this.icount = icount;
+ }
+
+ public String getBcount() {
+ return bcount;
+ }
+
+ public void setBCount(String bcount) {
+ this.bcount = bcount;
+ }
+
+ public String getSpecial() {
+ return special;
+ }
+
+ public void setSpecial(String special) {
+ this.special = special;
+ }
+
+ public void setStart(double start) {
+ this.start = start;
+ }
+
+ public double getEnd() {
+ return end;
+ }
+
+ public void setEnd(double end) {
+ this.end = end;
+ }
+
+ public int getAttempts() {
+ return attempts;
+ }
+
+ public void setAttempts(int attempts) {
+ this.attempts = attempts;
+ }
+
+ public NMethod getNMethod() {
+ return nmethod;
+ }
+
+ public void setNMethod(NMethod NMethod) {
+ this.nmethod = NMethod;
+ }
+
+ public ArrayList getPhases() {
+ return phases;
+ }
+
+ public void setPhases(ArrayList phases) {
+ this.setPhases(phases);
+ }
+
+ public String getFailureReason() {
+ return failureReason;
+ }
+
+ public void setFailureReason(String failureReason) {
+ this.failureReason = failureReason;
+ }
+
+ public Method getMethod() {
+ return method;
+ }
+
+ public void setMethod(Method method) {
+ this.method = method;
+ }
+
+ public CallSite getCall() {
+ return call;
+ }
+
+ public void setCall(CallSite call) {
+ this.call = call;
+ }
+
+ public double getElapsedTime() {
+ return end - start;
+ }
+
+ public Compilation getCompilation() {
+ return this;
+ }
+}
diff --git a/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Constants.java b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Constants.java
new file mode 100644
index 00000000000..e06dd05db54
--- /dev/null
+++ b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Constants.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package com.sun.hotspot.tools.compiler;
+
+interface Constants {
+ static final int JVM_ACC_PUBLIC = 0x0001; /* visible to everyone */
+ static final int JVM_ACC_PRIVATE = 0x0002; /* visible only to the defining class */
+ static final int JVM_ACC_PROTECTED = 0x0004; /* visible to subclasses */
+ static final int JVM_ACC_STATIC = 0x0008; /* instance variable is static */
+ static final int JVM_ACC_FINAL = 0x0010; /* no further subclassing, overriding */
+ static final int JVM_ACC_SYNCHRONIZED = 0x0020; /* wrap method call in monitor lock */
+ static final int JVM_ACC_SUPER = 0x0020; /* funky handling of invokespecial */
+ static final int JVM_ACC_VOLATILE = 0x0040; /* can not cache in registers */
+ static final int JVM_ACC_BRIDGE = 0x0040; /* bridge method generated by compiler */
+ static final int JVM_ACC_TRANSIENT = 0x0080; /* not persistent */
+ static final int JVM_ACC_VARARGS = 0x0080; /* method declared with variable number of args */
+ static final int JVM_ACC_NATIVE = 0x0100; /* implemented in C */
+ static final int JVM_ACC_INTERFACE = 0x0200; /* class is an interface */
+ static final int JVM_ACC_ABSTRACT = 0x0400; /* no definition provided */
+ static final int JVM_ACC_STRICT = 0x0800; /* strict floating point */
+ static final int JVM_ACC_SYNTHETIC = 0x1000; /* compiler-generated class, method or field */
+ static final int JVM_ACC_ANNOTATION = 0x2000; /* annotation type */
+ static final int JVM_ACC_ENUM = 0x4000; /* field is declared as element of enum */
+}
diff --git a/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogCleanupReader.java b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogCleanupReader.java
new file mode 100644
index 00000000000..eb3140c171b
--- /dev/null
+++ b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogCleanupReader.java
@@ -0,0 +1,212 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package com.sun.hotspot.tools.compiler;
+
+import java.io.*;
+import java.util.regex.*;
+
+/**
+ * This class is a filter class to deal with malformed XML that used
+ * to be produced by the JVM when generating LogCompilation. In 1.6
+ * and later releases it shouldn't be required.
+ * @author never
+ */
+
+class LogCleanupReader extends Reader {
+ private Reader reader;
+
+ private char[] buffer = new char[4096];
+
+ private int bufferCount;
+
+ private int bufferOffset;
+
+ private char[] line = new char[1024];
+
+ private int index;
+
+ private int length;
+
+ private char[] one = new char[1];
+
+ LogCleanupReader(Reader r) {
+ reader = r;
+ }
+
+ static final private Matcher pattern = Pattern.compile(".+ compile_id='[0-9]+'.*( compile_id='[0-9]+)").matcher("");
+ static final private Matcher pattern2 = Pattern.compile("' (C[12]) compile_id=").matcher("");
+ static final private Matcher pattern3 = Pattern.compile("'(destroy_vm)/").matcher("");
+
+ private void fill() throws IOException {
+ rawFill();
+ if (length != -1) {
+ boolean changed = false;
+ String s = new String(line, 0, length);
+ String orig = s;
+
+ pattern2.reset(s);
+ if (pattern2.find()) {
+ s = s.substring(0, pattern2.start(1)) + s.substring(pattern2.end(1) + 1);
+ changed = true;
+ }
+
+ pattern.reset(s);
+ if (pattern.lookingAt()) {
+ s = s.substring(0, pattern.start(1)) + s.substring(pattern.end(1) + 1);
+ changed = true;
+ }
+
+ pattern3.reset(s);
+ if (pattern3.find()) {
+ s = s.substring(0, pattern3.start(1)) + s.substring(pattern3.end(1));
+ changed = true;
+ }
+
+ if (changed) {
+ s.getChars(0, s.length(), line, 0);
+ length = s.length();
+ }
+ }
+ }
+
+ private void rawFill() throws IOException {
+ if (bufferCount == -1) {
+ length = -1;
+ return;
+ }
+
+ int i = 0;
+ boolean fillNonEOL = true;
+ outer:
+ while (true) {
+ if (fillNonEOL) {
+ int p;
+ for (p = bufferOffset; p < bufferCount; p++) {
+ char c = buffer[p];
+ if (c == '\r' || c == '\n') {
+ bufferOffset = p;
+ fillNonEOL = false;
+ continue outer;
+ }
+ if (i >= line.length) {
+ // copy and enlarge the line array
+ char[] newLine = new char[line.length * 2];
+ System.arraycopy(line, 0, newLine, 0, line.length);
+ line = newLine;
+ }
+ line[i++] = c;
+ }
+ bufferOffset = p;
+ } else {
+ int p;
+ for (p = bufferOffset; p < bufferCount; p++) {
+ char c = buffer[p];
+ if (c != '\r' && c != '\n') {
+ bufferOffset = p;
+ length = i;
+ index = 0;
+ return;
+ }
+ line[i++] = c;
+ }
+ bufferOffset = p;
+ }
+ if (bufferCount == -1) {
+ if (i == 0) {
+ length = -1;
+ } else {
+ length = i;
+ }
+ index = 0;
+ return;
+ }
+ if (bufferOffset != bufferCount) {
+ System.out.println(bufferOffset);
+ System.out.println(bufferCount);
+ throw new InternalError("how did we get here");
+ }
+ // load more data and try again.
+ bufferCount = reader.read(buffer, 0, buffer.length);
+ bufferOffset = 0;
+ }
+ }
+
+ public int read() throws java.io.IOException {
+ read(one, 0, 1);
+ return one[0];
+ }
+
+ public int read(char[] buffer) throws java.io.IOException {
+ return read(buffer, 0, buffer.length);
+ }
+
+ public int read(char[] b, int off, int len) throws java.io.IOException {
+ if (length == -1) {
+ return -1;
+ }
+
+ if (index == length) {
+ fill();
+ if (length == -1) {
+ return -1;
+ }
+ }
+ int n = Math.min(length - index, Math.min(b.length - off, len));
+ // System.out.printf("%d %d %d %d %d\n", index, length, off, len, n);
+ System.arraycopy(line, index, b, off, n);
+ index += n;
+ return n;
+ }
+
+ public long skip(long n) throws java.io.IOException {
+ long result = n;
+ while (n-- > 0) read();
+ return result;
+ }
+
+ public boolean ready() throws java.io.IOException {
+ return reader.ready() || (line != null && length > 0);
+ }
+
+ public boolean markSupported() {
+ return false;
+ }
+
+ public void mark(int unused) throws java.io.IOException {
+ throw new UnsupportedOperationException("mark not supported");
+ }
+
+ public void reset() throws java.io.IOException {
+ reader.reset();
+ line = null;
+ index = 0;
+ }
+
+ public void close() throws java.io.IOException {
+ reader.close();
+ line = null;
+ index = 0;
+ }
+}
diff --git a/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogCompilation.java b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogCompilation.java
new file mode 100644
index 00000000000..5edbad656ee
--- /dev/null
+++ b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogCompilation.java
@@ -0,0 +1,177 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+/**
+ * The main command line driver of a parser for LogCompilation output.
+ * @author never
+ */
+
+package com.sun.hotspot.tools.compiler;
+
+import java.io.PrintStream;
+import java.util.*;
+import org.xml.sax.*;
+import org.xml.sax.helpers.*;
+
+public class LogCompilation extends DefaultHandler implements ErrorHandler, Constants {
+
+ public static void usage(int exitcode) {
+ System.out.println("Usage: LogCompilation [ -v ] [ -c ] [ -s ] [ -e | -N ] file1 ...");
+ System.out.println(" -c: clean up malformed 1.5 xml");
+ System.out.println(" -i: print inlining decisions");
+ System.out.println(" -S: print compilation statistics");
+ System.out.println(" -s: sort events by start time");
+ System.out.println(" -e: sort events by elapsed time");
+ System.out.println(" -N: sort events by name and start");
+ System.exit(exitcode);
+ }
+
+ public static void main(String[] args) throws Exception {
+ Comparator defaultSort = LogParser.sortByStart;
+ boolean statistics = false;
+ boolean printInlining = false;
+ boolean cleanup = false;
+ int index = 0;
+
+ while (args.length > index) {
+ if (args[index].equals("-e")) {
+ defaultSort = LogParser.sortByElapsed;
+ index++;
+ } else if (args[index].equals("-n")) {
+ defaultSort = LogParser.sortByNameAndStart;
+ index++;
+ } else if (args[index].equals("-s")) {
+ defaultSort = LogParser.sortByStart;
+ index++;
+ } else if (args[index].equals("-c")) {
+ cleanup = true;
+ index++;
+ } else if (args[index].equals("-S")) {
+ statistics = true;
+ index++;
+ } else if (args[index].equals("-h")) {
+ usage(0);
+ } else if (args[index].equals("-i")) {
+ printInlining = true;
+ index++;
+ } else {
+ break;
+ }
+ }
+
+ if (index >= args.length) {
+ usage(1);
+ }
+
+ while (index < args.length) {
+ ArrayList events = LogParser.parse(args[index], cleanup);
+
+ if (statistics) {
+ printStatistics(events, System.out);
+ } else {
+ Collections.sort(events, defaultSort);
+ for (LogEvent c : events) {
+ if (printInlining && c instanceof Compilation) {
+ Compilation comp = (Compilation)c;
+ comp.print(System.out, true);
+ } else {
+ c.print(System.out);
+ }
+ }
+ }
+ index++;
+ }
+ }
+
+ public static void printStatistics(ArrayList events, PrintStream out) {
+ long cacheSize = 0;
+ long maxCacheSize = 0;
+ int nmethodsCreated = 0;
+ int nmethodsLive = 0;
+ int[] attempts = new int[32];
+ double regallocTime = 0;
+ int maxattempts = 0;
+
+ LinkedHashMap phaseTime = new LinkedHashMap(7);
+ LinkedHashMap phaseNodes = new LinkedHashMap(7);
+ double elapsed = 0;
+
+ for (LogEvent e : events) {
+ if (e instanceof Compilation) {
+ Compilation c = (Compilation) e;
+ c.printShort(out);
+ out.printf(" %6.4f\n", c.getElapsedTime());
+ attempts[c.getAttempts()]++;
+ maxattempts = Math.max(maxattempts,c.getAttempts());
+ elapsed += c.getElapsedTime();
+ for (Phase phase : c.getPhases()) {
+ out.printf("\t%s %6.4f\n", phase.getName(), phase.getElapsedTime());
+ Double v = phaseTime.get(phase.getName());
+ if (v == null) {
+ v = Double.valueOf(0.0);
+ }
+ phaseTime.put(phase.getName(), Double.valueOf(v.doubleValue() + phase.getElapsedTime()));
+
+ Integer v2 = phaseNodes.get(phase.getName());
+ if (v2 == null) {
+ v2 = Integer.valueOf(0);
+ }
+ phaseNodes.put(phase.getName(), Integer.valueOf(v2.intValue() + phase.getNodes()));
+ }
+ } else if (e instanceof MakeNotEntrantEvent) {
+ MakeNotEntrantEvent mne = (MakeNotEntrantEvent) e;
+ NMethod nm = mne.getNMethod();
+ if (mne.isZombie()) {
+ if (nm == null) {
+ System.err.println(mne.getId());
+ }
+ cacheSize -= nm.getSize();
+ nmethodsLive--;
+ }
+ } else if (e instanceof NMethod) {
+ nmethodsLive++;
+ nmethodsCreated++;
+ NMethod nm = (NMethod) e;
+ cacheSize += nm.getSize();
+ maxCacheSize = Math.max(cacheSize, maxCacheSize);
+ }
+ }
+ out.printf("NMethods: %d created %d live %d bytes (%d peak) in the code cache\n",
+ nmethodsCreated, nmethodsLive, cacheSize, maxCacheSize);
+ out.println("Phase times:");
+ for (String name : phaseTime.keySet()) {
+ Double v = phaseTime.get(name);
+ Integer v2 = phaseNodes.get(name);
+ out.printf("%20s %6.4f %d\n", name, v.doubleValue(), v2.intValue());
+ }
+ out.printf("%20s %6.4f\n", "total", elapsed);
+
+ if (maxattempts > 0) {
+ out.println("Distribution of regalloc passes:");
+ for (int i = 0; i <= maxattempts; i++) {
+ out.printf("%2d %8d\n", i, attempts[i]);
+ }
+ }
+ }
+}
diff --git a/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogEvent.java b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogEvent.java
new file mode 100644
index 00000000000..69f6d385b0e
--- /dev/null
+++ b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogEvent.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package com.sun.hotspot.tools.compiler;
+
+import java.io.PrintStream;
+import java.util.*;
+
+public interface LogEvent {
+ public double getStart();
+
+ public double getElapsedTime();
+
+ public Compilation getCompilation();
+
+ public void print(PrintStream stream);
+}
diff --git a/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogParser.java b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogParser.java
new file mode 100644
index 00000000000..bfff7dfa916
--- /dev/null
+++ b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogParser.java
@@ -0,0 +1,430 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+/**
+ * A SAX based parser of LogCompilation output from HotSpot. It takes a complete
+ * @author never
+ */
+
+package com.sun.hotspot.tools.compiler;
+
+import java.io.FileReader;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Stack;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import org.xml.sax.Attributes;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.helpers.DefaultHandler;
+
+public class LogParser extends DefaultHandler implements ErrorHandler, Constants {
+
+ static final HashMap typeMap;
+ static {
+ typeMap = new HashMap();
+ typeMap.put("[I", "int[]");
+ typeMap.put("[C", "char[]");
+ typeMap.put("[Z", "boolean[]");
+ typeMap.put("[L", "Object[]");
+ typeMap.put("[B", "byte[]");
+ }
+
+ static Comparator sortByStart = new Comparator() {
+
+ public int compare(LogEvent a, LogEvent b) {
+ double difference = (a.getStart() - b.getStart());
+ if (difference < 0) {
+ return -1;
+ }
+ if (difference > 0) {
+ return 1;
+ }
+ return 0;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return 7;
+ }
+ };
+ static Comparator sortByNameAndStart = new Comparator() {
+
+ public int compare(LogEvent a, LogEvent b) {
+ Compilation c1 = a.getCompilation();
+ Compilation c2 = b.getCompilation();
+ if (c1 != null && c2 != null) {
+ int result = c1.getMethod().toString().compareTo(c2.getMethod().toString());
+ if (result != 0) {
+ return result;
+ }
+ }
+ double difference = (a.getStart() - b.getStart());
+ if (difference < 0) {
+ return -1;
+ }
+ if (difference > 0) {
+ return 1;
+ }
+ return 0;
+ }
+
+ public boolean equals(Object other) {
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return 7;
+ }
+ };
+ static Comparator sortByElapsed = new Comparator() {
+
+ public int compare(LogEvent a, LogEvent b) {
+ double difference = (a.getElapsedTime() - b.getElapsedTime());
+ if (difference < 0) {
+ return -1;
+ }
+ if (difference > 0) {
+ return 1;
+ }
+ return 0;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return 7;
+ }
+ };
+
+ private ArrayList events = new ArrayList();
+
+ private HashMap types = new HashMap();
+ private HashMap methods = new HashMap();
+ private LinkedHashMap nmethods = new LinkedHashMap();
+ private HashMap compiles = new HashMap();
+ private String failureReason;
+ private int bci;
+ private Stack scopes = new Stack();
+ private Compilation compile;
+ private CallSite site;
+ private Stack phaseStack = new Stack();
+ private UncommonTrapEvent currentTrap;
+
+ long parseLong(String l) {
+ try {
+ return Long.decode(l).longValue();
+ } catch (NumberFormatException nfe) {
+ int split = l.length() - 8;
+ String s1 = "0x" + l.substring(split);
+ String s2 = l.substring(0, split);
+ long v1 = Long.decode(s1).longValue() & 0xffffffffL;
+ long v2 = (Long.decode(s2).longValue() & 0xffffffffL) << 32;
+ if (!l.equals("0x" + Long.toHexString(v1 + v2))) {
+ System.out.println(l);
+ System.out.println(s1);
+ System.out.println(s2);
+ System.out.println(v1);
+ System.out.println(v2);
+ System.out.println(Long.toHexString(v1 + v2));
+ throw new InternalError("bad conversion");
+ }
+ return v1 + v2;
+ }
+ }
+
+ public static ArrayList parse(String file, boolean cleanup) throws Exception {
+ return parse(new FileReader(file), cleanup);
+ }
+
+ public static ArrayList parse(Reader reader, boolean cleanup) throws Exception {
+ // Create the XML input factory
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+
+ // Create the XML LogEvent reader
+ SAXParser p = factory.newSAXParser();
+
+ if (cleanup) {
+ // some versions of the log have slightly malformed XML, so clean it
+ // up before passing it to SAX
+ reader = new LogCleanupReader(reader);
+ }
+
+ LogParser log = new LogParser();
+ p.parse(new InputSource(reader), log);
+
+ // Associate compilations with their NMethods
+ for (NMethod nm : log.nmethods.values()) {
+ Compilation c = log.compiles.get(nm.getId());
+ nm.setCompilation(c);
+ // Native wrappers for methods don't have a compilation
+ if (c != null) {
+ c.setNMethod(nm);
+ }
+ }
+
+ // Initially we want the LogEvent log sorted by timestamp
+ Collections.sort(log.events, sortByStart);
+
+ return log.events;
+ }
+
+ String search(Attributes attr, String name) {
+ return search(attr, name, null);
+ }
+
+ String search(Attributes attr, String name, String defaultValue) {
+ String result = attr.getValue(name);
+ if (result != null) {
+ return result;
+ }
+ if (defaultValue != null) {
+ return defaultValue;
+ }
+ for (int i = 0; i < attr.getLength(); i++) {
+ System.out.println(attr.getQName(i) + " " + attr.getValue(attr.getQName(i)));
+ }
+ throw new InternalError("can't find " + name);
+ }
+ int indent = 0;
+ String compile_id;
+
+ String type(String id) {
+ String result = types.get(id);
+ if (result == null) {
+ throw new InternalError(id);
+ }
+ String remapped = typeMap.get(result);
+ if (remapped != null) {
+ return remapped;
+ }
+ return result;
+ }
+
+ void type(String id, String name) {
+ assert type(id) == null;
+ types.put(id, name);
+ }
+
+ Method method(String id) {
+ Method result = methods.get(id);
+ if (result == null) {
+ throw new InternalError(id);
+ }
+ return result;
+ }
+
+ public String makeId(Attributes atts) {
+ String id = atts.getValue("compile_id");
+ String kind = atts.getValue("kind");
+ if (kind != null && kind.equals("osr")) {
+ id += "%";
+ }
+ return id;
+ }
+
+ @Override
+ public void startElement(String uri,
+ String localName,
+ String qname,
+ Attributes atts) {
+ if (qname.equals("phase")) {
+ Phase p = new Phase(search(atts, "name"),
+ Double.parseDouble(search(atts, "stamp")),
+ Integer.parseInt(search(atts, "nodes")));
+ phaseStack.push(p);
+ } else if (qname.equals("phase_done")) {
+ Phase p = phaseStack.pop();
+ p.setEndNodes(Integer.parseInt(search(atts, "nodes")));
+ p.setEnd(Double.parseDouble(search(atts, "stamp")));
+ compile.getPhases().add(p);
+ } else if (qname.equals("task")) {
+ compile = new Compilation(Integer.parseInt(search(atts, "compile_id", "-1")));
+ compile.setStart(Double.parseDouble(search(atts, "stamp")));
+ compile.setICount(search(atts, "count", "0"));
+ compile.setBCount(search(atts, "backedge_count", "0"));
+
+ String method = atts.getValue("method");
+ int space = method.indexOf(' ');
+ method = method.substring(0, space) + "::" +
+ method.substring(space + 1, method.indexOf(' ', space + 1) + 1);
+ String compiler = atts.getValue("compiler");
+ if (compiler == null) {
+ compiler = "";
+ }
+ String kind = atts.getValue("compile_kind");
+ if (kind == null) {
+ kind = "normal";
+ }
+ if (kind.equals("osr")) {
+ compile.setOsr(true);
+ compile.setOsr_bci(Integer.parseInt(search(atts, "osr_bci")));
+ } else if (kind.equals("c2i")) {
+ compile.setSpecial("--- adapter " + method);
+ } else {
+ compile.setSpecial(compile.getId() + " " + method + " (0 bytes)");
+ }
+ events.add(compile);
+ compiles.put(makeId(atts), compile);
+ } else if (qname.equals("type")) {
+ type(search(atts, "id"), search(atts, "name"));
+ } else if (qname.equals("bc")) {
+ bci = Integer.parseInt(search(atts, "bci"));
+ } else if (qname.equals("klass")) {
+ type(search(atts, "id"), search(atts, "name"));
+ } else if (qname.equals("method")) {
+ String id = search(atts, "id");
+ Method m = new Method();
+ m.setHolder(type(search(atts, "holder")));
+ m.setName(search(atts, "name"));
+ m.setReturnType(type(search(atts, "return")));
+ m.setArguments(search(atts, "arguments", "void"));
+ m.setBytes(search(atts, "bytes"));
+ m.setIICount(search(atts, "iicount"));
+ m.setFlags(search(atts, "flags"));
+ methods.put(id, m);
+ } else if (qname.equals("call")) {
+ site = new CallSite(bci, method(search(atts, "method")));
+ site.setCount(Integer.parseInt(search(atts, "count")));
+ String receiver = atts.getValue("receiver");
+ if (receiver != null) {
+ site.setReceiver(type(receiver));
+ site.setReceiver_count(Integer.parseInt(search(atts, "receiver_count")));
+ }
+ scopes.peek().add(site);
+ } else if (qname.equals("regalloc")) {
+ compile.setAttempts(Integer.parseInt(search(atts, "attempts")));
+ } else if (qname.equals("inline_fail")) {
+ scopes.peek().last().setReason(search(atts, "reason"));
+ } else if (qname.equals("failure")) {
+ failureReason = search(atts, "reason");
+ } else if (qname.equals("task_done")) {
+ compile.setEnd(Double.parseDouble(search(atts, "stamp")));
+ if (Integer.parseInt(search(atts, "success")) == 0) {
+ compile.setFailureReason(failureReason);
+ }
+ } else if (qname.equals("make_not_entrant")) {
+ String id = makeId(atts);
+ NMethod nm = nmethods.get(id);
+ if (nm == null) throw new InternalError();
+ LogEvent e = new MakeNotEntrantEvent(Double.parseDouble(search(atts, "stamp")), id,
+ atts.getValue("zombie") != null, nm);
+ events.add(e);
+ } else if (qname.equals("uncommon_trap")) {
+ String id = atts.getValue("compile_id");
+ if (id != null) {
+ id = makeId(atts);
+ currentTrap = new UncommonTrapEvent(Double.parseDouble(search(atts, "stamp")),
+ id,
+ atts.getValue("reason"),
+ atts.getValue("action"),
+ Integer.parseInt(search(atts, "count", "0")));
+ events.add(currentTrap);
+ } else {
+ // uncommon trap inserted during parsing.
+ // ignore for now
+ }
+ } else if (qname.equals("jvms")) {
+ //
+ if (currentTrap != null) {
+ currentTrap.addJVMS(atts.getValue("method"), Integer.parseInt(atts.getValue("bci")));
+ } else {
+ System.err.println("Missing uncommon_trap for jvms");
+ }
+ } else if (qname.equals("nmethod")) {
+ String id = makeId(atts);
+ NMethod nm = new NMethod(Double.parseDouble(search(atts, "stamp")),
+ id,
+ parseLong(atts.getValue("address")),
+ parseLong(atts.getValue("size")));
+ nmethods.put(id, nm);
+ events.add(nm);
+ } else if (qname.equals("parse")) {
+ Method m = method(search(atts, "method"));
+ if (scopes.size() == 0) {
+ compile.setMethod(m);
+ scopes.push(compile.getCall());
+ } else {
+ if (site.getMethod() == m) {
+ scopes.push(site);
+ } else if (scopes.peek().getCalls().size() > 2 && m == scopes.peek().last(-2).getMethod()) {
+ scopes.push(scopes.peek().last(-2));
+ } else {
+ System.out.println(site.getMethod());
+ System.out.println(m);
+ throw new InternalError("call site and parse don't match");
+ }
+ }
+ }
+ }
+
+ @Override
+ public void endElement(String uri,
+ String localName,
+ String qname) {
+ if (qname.equals("parse")) {
+ indent -= 2;
+ scopes.pop();
+ } else if (qname.equals("uncommon_trap")) {
+ currentTrap = null;
+ } else if (qname.equals("task")) {
+ types.clear();
+ methods.clear();
+ site = null;
+ }
+ }
+
+ @Override
+ public void warning(org.xml.sax.SAXParseException e) {
+ System.err.println(e.getMessage() + " at line " + e.getLineNumber() + ", column " + e.getColumnNumber());
+ e.printStackTrace();
+ }
+
+ @Override
+ public void error(org.xml.sax.SAXParseException e) {
+ System.err.println(e.getMessage() + " at line " + e.getLineNumber() + ", column " + e.getColumnNumber());
+ e.printStackTrace();
+ }
+
+ @Override
+ public void fatalError(org.xml.sax.SAXParseException e) {
+ System.err.println(e.getMessage() + " at line " + e.getLineNumber() + ", column " + e.getColumnNumber());
+ e.printStackTrace();
+ }
+}
diff --git a/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/MakeNotEntrantEvent.java b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/MakeNotEntrantEvent.java
new file mode 100644
index 00000000000..2b3fc56b359
--- /dev/null
+++ b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/MakeNotEntrantEvent.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package com.sun.hotspot.tools.compiler;
+
+import java.io.PrintStream;
+
+class MakeNotEntrantEvent extends BasicLogEvent {
+ private final boolean zombie;
+
+ private NMethod nmethod;
+
+ MakeNotEntrantEvent(double s, String i, boolean z, NMethod nm) {
+ super(s, i);
+ zombie = z;
+ nmethod = nm;
+ }
+
+ public NMethod getNMethod() {
+ return nmethod;
+ }
+
+ public void print(PrintStream stream) {
+ if (isZombie()) {
+ stream.printf("%s make_zombie\n", getId());
+ } else {
+ stream.printf("%s make_not_entrant\n", getId());
+ }
+ }
+
+ public boolean isZombie() {
+ return zombie;
+ }
+}
diff --git a/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Method.java b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Method.java
new file mode 100644
index 00000000000..f2c9a9c710b
--- /dev/null
+++ b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Method.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package com.sun.hotspot.tools.compiler;
+
+import java.util.Arrays;
+
+public class Method implements Constants {
+
+ private String holder;
+ private String name;
+ private String returnType;
+ private String arguments;
+ private String bytes;
+ private String iicount;
+ private String flags;
+
+ String decodeFlags(int osr_bci) {
+ int f = Integer.parseInt(getFlags());
+ char[] c = new char[4];
+ Arrays.fill(c, ' ');
+ if (osr_bci >= 0) {
+ c[0] = '%';
+ }
+ if ((f & JVM_ACC_SYNCHRONIZED) != 0) {
+ c[1] = 's';
+ }
+ return new String(c);
+ }
+
+ String format(int osr_bci) {
+ if (osr_bci >= 0) {
+ return getHolder().replace('/', '.') + "::" + getName() + " @ " + osr_bci + " (" + getBytes() + " bytes)";
+ } else {
+ return getHolder().replace('/', '.') + "::" + getName() + " (" + getBytes() + " bytes)";
+ }
+ }
+
+ @Override
+ public String toString() {
+ return getHolder().replace('/', '.') + "::" + getName() + " (" + getBytes() + " bytes)";
+ }
+
+ public String getHolder() {
+ return holder;
+ }
+
+ public void setHolder(String holder) {
+ this.holder = holder;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getReturnType() {
+ return returnType;
+ }
+
+ public void setReturnType(String returnType) {
+ this.returnType = returnType;
+ }
+
+ public String getArguments() {
+ return arguments;
+ }
+
+ public void setArguments(String arguments) {
+ this.arguments = arguments;
+ }
+
+ public String getBytes() {
+ return bytes;
+ }
+
+ public void setBytes(String bytes) {
+ this.bytes = bytes;
+ }
+
+ public String getIICount() {
+ return iicount;
+ }
+
+ public void setIICount(String iicount) {
+ this.iicount = iicount;
+ }
+
+ public String getFlags() {
+ return flags;
+ }
+
+ public void setFlags(String flags) {
+ this.flags = flags;
+ }
+}
diff --git a/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/NMethod.java b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/NMethod.java
new file mode 100644
index 00000000000..8fb277d00d6
--- /dev/null
+++ b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/NMethod.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package com.sun.hotspot.tools.compiler;
+
+import java.io.PrintStream;
+
+public class NMethod extends BasicLogEvent {
+
+ private long address;
+ private long size;
+
+ NMethod(double s, String i, long a, long sz) {
+ super(s, i);
+ address = a;
+ size = sz;
+ }
+
+ public void print(PrintStream out) {
+ // XXX Currently we do nothing
+ // throw new InternalError();
+ }
+
+ public long getAddress() {
+ return address;
+ }
+
+ public void setAddress(long address) {
+ this.address = address;
+ }
+
+ public long getSize() {
+ return size;
+ }
+
+ public void setSize(long size) {
+ this.size = size;
+ }
+}
diff --git a/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Phase.java b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Phase.java
new file mode 100644
index 00000000000..8c29149a217
--- /dev/null
+++ b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Phase.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package com.sun.hotspot.tools.compiler;
+
+import java.io.PrintStream;
+
+public class Phase extends BasicLogEvent {
+
+ private final int startNodes;
+ private int endNodes;
+
+ Phase(String n, double s, int nodes) {
+ super(s, n);
+ startNodes = nodes;
+ }
+
+ int getNodes() {
+ return getStartNodes();
+ }
+
+ void setEndNodes(int n) {
+ endNodes = n;
+ }
+
+ public String getName() {
+ return getId();
+ }
+
+ public int getStartNodes() {
+ return startNodes;
+ }
+
+ public int getEndNodes() {
+ return endNodes;
+ }
+
+ @Override
+ public void print(PrintStream stream) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+}
diff --git a/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/UncommonTrapEvent.java b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/UncommonTrapEvent.java
new file mode 100644
index 00000000000..894cbdc7724
--- /dev/null
+++ b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/UncommonTrapEvent.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package com.sun.hotspot.tools.compiler;
+
+import java.io.PrintStream;
+
+class UncommonTrapEvent extends BasicLogEvent {
+
+ private final String reason;
+ private final String action;
+ private int count;
+ private String jvms = "";
+
+ UncommonTrapEvent(double s, String i, String r, String a, int c) {
+ super(s, i);
+ reason = r;
+ action = a;
+ count = c;
+ }
+
+
+ public void addJVMS(String method, int bci) {
+ setJvms(getJvms() + " @" + bci + " " + method + "\n");
+ }
+
+ public void updateCount(UncommonTrapEvent trap) {
+ setCount(Math.max(getCount(), trap.getCount()));
+ }
+
+ public void print(PrintStream stream) {
+ stream.printf("%s uncommon trap %s %s\n", getId(), getReason(), getAction());
+ stream.print(getJvms());
+ }
+
+ public String getReason() {
+ return reason;
+ }
+
+ public String getAction() {
+ return action;
+ }
+
+ public int getCount() {
+ return count;
+ }
+
+ public void setCount(int count) {
+ this.count = count;
+ }
+
+ public String getJvms() {
+ return jvms;
+ }
+
+ public void setJvms(String jvms) {
+ this.jvms = jvms;
+ }
+
+ public void setCompilation(Compilation compilation) {
+ this.compilation = compilation;
+ }
+}
From 95a3c4a81f7e58041681cfc6da30f9a016bf6b92 Mon Sep 17 00:00:00 2001
From: Pavel Porvatov
Date: Thu, 26 Feb 2009 11:44:43 +0300
Subject: [PATCH 061/292] 6794831: Infinite loop while painting ticks on Slider
with maximum=MAX_INT
Reviewed-by: malenkov
---
.../javax/swing/plaf/basic/BasicSliderUI.java | 66 +++++++----
.../swing/JSlider/6794831/bug6794831.java | 105 ++++++++++++++++++
2 files changed, 148 insertions(+), 23 deletions(-)
create mode 100644 jdk/test/javax/swing/JSlider/6794831/bug6794831.java
diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicSliderUI.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicSliderUI.java
index 864ad13264a..0a858d41c18 100644
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicSliderUI.java
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicSliderUI.java
@@ -1004,47 +1004,62 @@ public class BasicSliderUI extends SliderUI{
g.setColor(DefaultLookup.getColor(slider, this, "Slider.tickColor", Color.black));
if ( slider.getOrientation() == JSlider.HORIZONTAL ) {
- g.translate( 0, tickBounds.y);
+ g.translate(0, tickBounds.y);
- int value = slider.getMinimum();
- int xPos;
+ if (slider.getMinorTickSpacing() > 0) {
+ int value = slider.getMinimum();
- if ( slider.getMinorTickSpacing() > 0 ) {
while ( value <= slider.getMaximum() ) {
- xPos = xPositionForValue( value );
+ int xPos = xPositionForValue(value);
paintMinorTickForHorizSlider( g, tickBounds, xPos );
+
+ // Overflow checking
+ if (Integer.MAX_VALUE - slider.getMinorTickSpacing() < value) {
+ break;
+ }
+
value += slider.getMinorTickSpacing();
}
}
- if ( slider.getMajorTickSpacing() > 0 ) {
- value = slider.getMinimum();
+ if (slider.getMajorTickSpacing() > 0) {
+ int value = slider.getMinimum();
while ( value <= slider.getMaximum() ) {
- xPos = xPositionForValue( value );
+ int xPos = xPositionForValue(value);
paintMajorTickForHorizSlider( g, tickBounds, xPos );
+
+ // Overflow checking
+ if (Integer.MAX_VALUE - slider.getMajorTickSpacing() < value) {
+ break;
+ }
+
value += slider.getMajorTickSpacing();
}
}
g.translate( 0, -tickBounds.y);
- }
- else {
- g.translate(tickBounds.x, 0);
+ } else {
+ g.translate(tickBounds.x, 0);
- int value = slider.getMinimum();
- int yPos;
-
- if ( slider.getMinorTickSpacing() > 0 ) {
+ if (slider.getMinorTickSpacing() > 0) {
int offset = 0;
if(!BasicGraphicsUtils.isLeftToRight(slider)) {
offset = tickBounds.width - tickBounds.width / 2;
g.translate(offset, 0);
}
- while ( value <= slider.getMaximum() ) {
- yPos = yPositionForValue( value );
+ int value = slider.getMinimum();
+
+ while (value <= slider.getMaximum()) {
+ int yPos = yPositionForValue(value);
paintMinorTickForVertSlider( g, tickBounds, yPos );
+
+ // Overflow checking
+ if (Integer.MAX_VALUE - slider.getMinorTickSpacing() < value) {
+ break;
+ }
+
value += slider.getMinorTickSpacing();
}
@@ -1053,15 +1068,22 @@ public class BasicSliderUI extends SliderUI{
}
}
- if ( slider.getMajorTickSpacing() > 0 ) {
- value = slider.getMinimum();
+ if (slider.getMajorTickSpacing() > 0) {
if(!BasicGraphicsUtils.isLeftToRight(slider)) {
g.translate(2, 0);
}
- while ( value <= slider.getMaximum() ) {
- yPos = yPositionForValue( value );
+ int value = slider.getMinimum();
+
+ while (value <= slider.getMaximum()) {
+ int yPos = yPositionForValue(value);
paintMajorTickForVertSlider( g, tickBounds, yPos );
+
+ // Overflow checking
+ if (Integer.MAX_VALUE - slider.getMajorTickSpacing() < value) {
+ break;
+ }
+
value += slider.getMajorTickSpacing();
}
@@ -1775,8 +1797,6 @@ public class BasicSliderUI extends SliderUI{
thumbMiddle = thumbLeft + halfThumbWidth;
slider.setValue(valueForXPosition(thumbMiddle));
break;
- default:
- return;
}
}
diff --git a/jdk/test/javax/swing/JSlider/6794831/bug6794831.java b/jdk/test/javax/swing/JSlider/6794831/bug6794831.java
new file mode 100644
index 00000000000..a147987d417
--- /dev/null
+++ b/jdk/test/javax/swing/JSlider/6794831/bug6794831.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+ * @bug 6794831
+ * @summary Infinite loop while painting ticks on Slider with maximum=MAX_INT
+ * @author Pavel Porvatov
+ @run main bug6794831
+ */
+
+import javax.swing.*;
+import javax.swing.plaf.basic.BasicSliderUI;
+import java.awt.image.BufferedImage;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+public class bug6794831 {
+ private final CountDownLatch countDownLatch = new CountDownLatch(1);
+
+ public static void main(String args[]) throws InterruptedException {
+ new bug6794831().run();
+ }
+
+ private void run() throws InterruptedException {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ for (UIManager.LookAndFeelInfo lookAndFeelInfo : UIManager.getInstalledLookAndFeels()) {
+ try {
+ UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+
+ BufferedImage image = new BufferedImage(300, 200, BufferedImage.TYPE_INT_ARGB);
+
+ // Test 1
+ JSlider slider = new JSlider(0, Integer.MAX_VALUE - 1, 0);
+
+ slider.setMajorTickSpacing((Integer.MAX_VALUE - 1) / 4);
+ slider.setPaintTicks(true);
+
+ ((BasicSliderUI) slider.getUI()).paintTicks(image.getGraphics());
+
+ // Test 2
+ slider = new JSlider(0, Integer.MAX_VALUE - 1, 0);
+
+ slider.setMinorTickSpacing((Integer.MAX_VALUE - 1) / 4);
+ slider.setPaintTicks(true);
+
+ ((BasicSliderUI) slider.getUI()).paintTicks(image.getGraphics());
+
+ // Test 3
+ slider = new JSlider(0, Integer.MAX_VALUE - 1, 0);
+
+ slider.setOrientation(JSlider.VERTICAL);
+ slider.setMajorTickSpacing((Integer.MAX_VALUE - 1) / 4);
+ slider.setPaintTicks(true);
+
+ ((BasicSliderUI) slider.getUI()).paintTicks(image.getGraphics());
+
+ // Test 4
+ slider = new JSlider(0, Integer.MAX_VALUE - 1, 0);
+
+ slider.setOrientation(JSlider.VERTICAL);
+ slider.setMinorTickSpacing((Integer.MAX_VALUE - 1) / 4);
+ slider.setPaintTicks(true);
+
+ ((BasicSliderUI) slider.getUI()).paintTicks(image.getGraphics());
+
+ countDownLatch.countDown();
+ }
+ }
+ });
+
+ if (countDownLatch.await(3000, TimeUnit.MILLISECONDS)) {
+ System.out.println("bug6794831 passed");
+ } else {
+ fail("bug6794831 failed");
+ }
+ }
+
+ private static void fail(String msg) {
+ throw new RuntimeException(msg);
+ }
+}
From 4fd14806a47371139817f7e496da823066954fd1 Mon Sep 17 00:00:00 2001
From: Clemens Eisserer
Date: Thu, 26 Feb 2009 13:38:38 -0800
Subject: [PATCH 062/292] 6791612: OGLBat tests are failed in jdk 7 b42
Reviewed-by: tdv
---
jdk/make/sun/xawt/mapfile-vers | 2 ++
1 file changed, 2 insertions(+)
diff --git a/jdk/make/sun/xawt/mapfile-vers b/jdk/make/sun/xawt/mapfile-vers
index d4b5b6e32ba..07b16cefcc8 100644
--- a/jdk/make/sun/xawt/mapfile-vers
+++ b/jdk/make/sun/xawt/mapfile-vers
@@ -302,12 +302,14 @@ SUNWprivate_1.1 {
Java_java_awt_FileDialog_initIDs;
Java_sun_awt_X11_XWindow_initIDs;
+ Java_sun_java2d_opengl_OGLContext_getOGLIdString;
Java_sun_java2d_opengl_OGLMaskFill_maskFill;
Java_sun_java2d_opengl_OGLRenderer_drawPoly;
Java_sun_java2d_opengl_OGLRenderQueue_flushBuffer;
Java_sun_java2d_opengl_OGLSurfaceData_initTexture;
Java_sun_java2d_opengl_OGLSurfaceData_initFBObject;
Java_sun_java2d_opengl_OGLSurfaceData_initFlipBackbuffer;
+ Java_sun_java2d_opengl_OGLSurfaceData_getTextureID;
Java_sun_java2d_opengl_OGLSurfaceData_getTextureTarget;
Java_sun_java2d_opengl_OGLTextRenderer_drawGlyphList;
Java_sun_java2d_opengl_GLXGraphicsConfig_getGLXConfigInfo;
From 9b31d58b9817aeabba733861cb2b2c3a5ed84843 Mon Sep 17 00:00:00 2001
From: Vladimir Kozlov
Date: Thu, 26 Feb 2009 14:26:02 -0800
Subject: [PATCH 063/292] 6809798: SafePointScalarObject node placed into
incorrect block during GCM
Replace the control edge of a pinned node before scheduling.
Reviewed-by: never
---
hotspot/src/share/vm/opto/block.cpp | 4 ++
hotspot/src/share/vm/opto/block.hpp | 2 +
hotspot/src/share/vm/opto/callnode.cpp | 1 +
hotspot/src/share/vm/opto/callnode.hpp | 4 ++
hotspot/src/share/vm/opto/gcm.cpp | 67 +++++++++++++++-----------
hotspot/src/share/vm/opto/macro.cpp | 1 +
6 files changed, 52 insertions(+), 27 deletions(-)
diff --git a/hotspot/src/share/vm/opto/block.cpp b/hotspot/src/share/vm/opto/block.cpp
index cf15fa7c4fb..28400047756 100644
--- a/hotspot/src/share/vm/opto/block.cpp
+++ b/hotspot/src/share/vm/opto/block.cpp
@@ -909,6 +909,10 @@ void PhaseCFG::verify( ) const {
!(n->jvms() != NULL && n->jvms()->is_monitor_use(k)) ) {
assert( b->find_node(def) < j, "uses must follow definitions" );
}
+ if( def->is_SafePointScalarObject() ) {
+ assert(_bbs[def->_idx] == b, "SafePointScalarObject Node should be at the same block as its SafePoint node");
+ assert(_bbs[def->_idx] == _bbs[def->in(0)->_idx], "SafePointScalarObject Node should be at the same block as its control edge");
+ }
}
}
}
diff --git a/hotspot/src/share/vm/opto/block.hpp b/hotspot/src/share/vm/opto/block.hpp
index 43ce09fe9ad..0da859abbba 100644
--- a/hotspot/src/share/vm/opto/block.hpp
+++ b/hotspot/src/share/vm/opto/block.hpp
@@ -347,6 +347,8 @@ class PhaseCFG : public Phase {
// Helper function to insert a node into a block
void schedule_node_into_block( Node *n, Block *b );
+ void PhaseCFG::replace_block_proj_ctrl( Node *n );
+
// Set the basic block for pinned Nodes
void schedule_pinned_nodes( VectorSet &visited );
diff --git a/hotspot/src/share/vm/opto/callnode.cpp b/hotspot/src/share/vm/opto/callnode.cpp
index 7dff291fc1c..811693cce7b 100644
--- a/hotspot/src/share/vm/opto/callnode.cpp
+++ b/hotspot/src/share/vm/opto/callnode.cpp
@@ -975,6 +975,7 @@ SafePointScalarObjectNode::SafePointScalarObjectNode(const TypeOopPtr* tp,
}
bool SafePointScalarObjectNode::pinned() const { return true; }
+bool SafePointScalarObjectNode::depends_only_on_test() const { return false; }
uint SafePointScalarObjectNode::ideal_reg() const {
return 0; // No matching to machine instruction
diff --git a/hotspot/src/share/vm/opto/callnode.hpp b/hotspot/src/share/vm/opto/callnode.hpp
index 06c783364c0..40a4abeae1d 100644
--- a/hotspot/src/share/vm/opto/callnode.hpp
+++ b/hotspot/src/share/vm/opto/callnode.hpp
@@ -437,6 +437,10 @@ public:
// of the SafePoint node for which it was generated.
virtual bool pinned() const; // { return true; }
+ // SafePointScalarObject depends on the SafePoint node
+ // for which it was generated.
+ virtual bool depends_only_on_test() const; // { return false; }
+
virtual uint size_of() const { return sizeof(*this); }
// Assumes that "this" is an argument to a safepoint node "s", and that
diff --git a/hotspot/src/share/vm/opto/gcm.cpp b/hotspot/src/share/vm/opto/gcm.cpp
index b56fb157119..65c63339e29 100644
--- a/hotspot/src/share/vm/opto/gcm.cpp
+++ b/hotspot/src/share/vm/opto/gcm.cpp
@@ -57,6 +57,37 @@ void PhaseCFG::schedule_node_into_block( Node *n, Block *b ) {
}
}
+//----------------------------replace_block_proj_ctrl-------------------------
+// Nodes that have is_block_proj() nodes as their control need to use
+// the appropriate Region for their actual block as their control since
+// the projection will be in a predecessor block.
+void PhaseCFG::replace_block_proj_ctrl( Node *n ) {
+ const Node *in0 = n->in(0);
+ assert(in0 != NULL, "Only control-dependent");
+ const Node *p = in0->is_block_proj();
+ if (p != NULL && p != n) { // Control from a block projection?
+ assert(!n->pinned() || n->is_SafePointScalarObject(), "only SafePointScalarObject pinned node is expected here");
+ // Find trailing Region
+ Block *pb = _bbs[in0->_idx]; // Block-projection already has basic block
+ uint j = 0;
+ if (pb->_num_succs != 1) { // More then 1 successor?
+ // Search for successor
+ uint max = pb->_nodes.size();
+ assert( max > 1, "" );
+ uint start = max - pb->_num_succs;
+ // Find which output path belongs to projection
+ for (j = start; j < max; j++) {
+ if( pb->_nodes[j] == in0 )
+ break;
+ }
+ assert( j < max, "must find" );
+ // Change control to match head of successor basic block
+ j -= start;
+ }
+ n->set_req(0, pb->_succs[j]->head());
+ }
+}
+
//------------------------------schedule_pinned_nodes--------------------------
// Set the basic block for Nodes pinned into blocks
@@ -68,8 +99,10 @@ void PhaseCFG::schedule_pinned_nodes( VectorSet &visited ) {
Node *n = spstack.pop();
if( !visited.test_set(n->_idx) ) { // Test node and flag it as visited
if( n->pinned() && !_bbs.lookup(n->_idx) ) { // Pinned? Nail it down!
+ assert( n->in(0), "pinned Node must have Control" );
+ // Before setting block replace block_proj control edge
+ replace_block_proj_ctrl(n);
Node *input = n->in(0);
- assert( input, "pinned Node must have Control" );
while( !input->is_block_start() )
input = input->in(0);
Block *b = _bbs[input->_idx]; // Basic block of controlling input
@@ -158,34 +191,12 @@ bool PhaseCFG::schedule_early(VectorSet &visited, Node_List &roots) {
uint i = nstack_top_i;
if (i == 0) {
- // Special control input processing.
- // While I am here, go ahead and look for Nodes which are taking control
- // from a is_block_proj Node. After I inserted RegionNodes to make proper
- // blocks, the control at a is_block_proj more properly comes from the
- // Region being controlled by the block_proj Node.
+ // Fixup some control. Constants without control get attached
+ // to root and nodes that use is_block_proj() nodes should be attached
+ // to the region that starts their block.
const Node *in0 = n->in(0);
if (in0 != NULL) { // Control-dependent?
- const Node *p = in0->is_block_proj();
- if (p != NULL && p != n) { // Control from a block projection?
- // Find trailing Region
- Block *pb = _bbs[in0->_idx]; // Block-projection already has basic block
- uint j = 0;
- if (pb->_num_succs != 1) { // More then 1 successor?
- // Search for successor
- uint max = pb->_nodes.size();
- assert( max > 1, "" );
- uint start = max - pb->_num_succs;
- // Find which output path belongs to projection
- for (j = start; j < max; j++) {
- if( pb->_nodes[j] == in0 )
- break;
- }
- assert( j < max, "must find" );
- // Change control to match head of successor basic block
- j -= start;
- }
- n->set_req(0, pb->_succs[j]->head());
- }
+ replace_block_proj_ctrl(n);
} else { // n->in(0) == NULL
if (n->req() == 1) { // This guy is a constant with NO inputs?
n->set_req(0, _root);
@@ -226,6 +237,8 @@ bool PhaseCFG::schedule_early(VectorSet &visited, Node_List &roots) {
if (!n->pinned()) {
// Set earliest legal block.
_bbs.map(n->_idx, find_deepest_input(n, _bbs));
+ } else {
+ assert(_bbs[n->_idx] == _bbs[n->in(0)->_idx], "Pinned Node should be at the same block as its control edge");
}
if (nstack.is_empty()) {
diff --git a/hotspot/src/share/vm/opto/macro.cpp b/hotspot/src/share/vm/opto/macro.cpp
index 857568b6d05..aa8bc492116 100644
--- a/hotspot/src/share/vm/opto/macro.cpp
+++ b/hotspot/src/share/vm/opto/macro.cpp
@@ -64,6 +64,7 @@ void PhaseMacroExpand::copy_call_debug_info(CallNode *oldcall, CallNode * newcal
uint old_unique = C->unique();
Node* new_in = old_sosn->clone(jvms_adj, sosn_map);
if (old_unique != C->unique()) {
+ new_in->set_req(0, newcall->in(0)); // reset control edge
new_in = transform_later(new_in); // Register new node.
}
old_in = new_in;
From 114da9bcfc6b22248fd697c33c6a9474c3f1597d Mon Sep 17 00:00:00 2001
From: Tom Rodriguez
Date: Thu, 26 Feb 2009 16:57:21 -0800
Subject: [PATCH 064/292] 6810855: KILL vs. TEMP ordering restrictions are too
strong
Reviewed-by: kvn
---
hotspot/src/share/vm/adlc/formssel.cpp | 14 +-------------
1 file changed, 1 insertion(+), 13 deletions(-)
diff --git a/hotspot/src/share/vm/adlc/formssel.cpp b/hotspot/src/share/vm/adlc/formssel.cpp
index 12477be68ac..d26a94c3bc7 100644
--- a/hotspot/src/share/vm/adlc/formssel.cpp
+++ b/hotspot/src/share/vm/adlc/formssel.cpp
@@ -858,19 +858,7 @@ void InstructForm::build_components() {
OperandForm* kill = (OperandForm*)_localNames[kill_name];
globalAD->syntax_err(_linenum, "%s: %s %s must be at the end of the argument list\n",
_ident, kill->_ident, kill_name);
- } else if (e->isa(Component::KILL)) {
- kill_name = name;
- }
-
- // TEMPs are real uses and need to be among the first parameters
- // listed, otherwise the numbering of operands and inputs gets
- // screwy, so enforce this restriction during parse.
- if (kill_name != NULL &&
- e->isa(Component::TEMP) && !e->isa(Component::DEF)) {
- OperandForm* kill = (OperandForm*)_localNames[kill_name];
- globalAD->syntax_err(_linenum, "%s: %s %s must follow %s %s in the argument list\n",
- _ident, kill->_ident, kill_name, opForm->_ident, name);
- } else if (e->isa(Component::KILL)) {
+ } else if (e->isa(Component::KILL) && !e->isa(Component::USE)) {
kill_name = name;
}
}
From c50a9c66cc420550000af4562abf5de34935504b Mon Sep 17 00:00:00 2001
From: Jonathan Gibbons
Date: Thu, 26 Feb 2009 18:28:21 -0800
Subject: [PATCH 065/292] 6809563: corba build in JDK uses invalid
bootclasspath for javah
Reviewed-by: ohair
---
corba/make/common/shared/Defs-java.gmk | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/corba/make/common/shared/Defs-java.gmk b/corba/make/common/shared/Defs-java.gmk
index f811bee0859..d36ef8022d2 100644
--- a/corba/make/common/shared/Defs-java.gmk
+++ b/corba/make/common/shared/Defs-java.gmk
@@ -117,7 +117,7 @@ JAVACFLAGS += -classpath $(BOOTDIR)/lib/tools.jar
JAVACFLAGS += $(OTHER_JAVACFLAGS)
# Needed for javah
-JAVAHFLAGS += -bootclasspath $(CLASSBINDIR)
+JAVAHFLAGS += -classpath $(CLASSBINDIR)
# Langtools
ifdef LANGTOOLS_DIST
From 8ecfee604a4b9f03ecd7cbdca3c9d23d92fdef9c Mon Sep 17 00:00:00 2001
From: Jonathan Gibbons
Date: Thu, 26 Feb 2009 18:32:46 -0800
Subject: [PATCH 066/292] 6810915: Sun proprietary warnings in JDK build
Reviewed-by: ohair
---
corba/make/Makefile | 2 --
corba/make/common/shared/Defs-java.gmk | 3 +++
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/corba/make/Makefile b/corba/make/Makefile
index 0b5c31d7001..5eebabb2cd5 100644
--- a/corba/make/Makefile
+++ b/corba/make/Makefile
@@ -112,8 +112,6 @@ ifndef TARGET_JAVA
TARGET_JAVA = java
endif
-NO_PROPRIETARY_API_WARNINGS = -XDignore.symbol.file=true
-
SELF = $(lastword $(MAKEFILE_LIST))
# for jdk, we generate the following:
diff --git a/corba/make/common/shared/Defs-java.gmk b/corba/make/common/shared/Defs-java.gmk
index d36ef8022d2..f80f0ffa4e1 100644
--- a/corba/make/common/shared/Defs-java.gmk
+++ b/corba/make/common/shared/Defs-java.gmk
@@ -104,6 +104,9 @@ ifeq ($(COMPILER_WARNINGS_FATAL), true)
JAVACFLAGS += -Werror
endif
+NO_PROPRIETARY_API_WARNINGS = -XDignore.symbol.file=true
+JAVACFLAGS += $(NO_PROPRIETARY_API_WARNINGS)
+
# Add the source level (currently all source is 1.5, should this be 1.6?)
LANGUAGE_VERSION = -source 1.5
JAVACFLAGS += $(LANGUAGE_VERSION)
From d6cdfde9d9a5cf3a5c0ec1cf4730a8161a1cc751 Mon Sep 17 00:00:00 2001
From: Lillian Angel
Date: Fri, 27 Feb 2009 03:35:40 -0800
Subject: [PATCH 067/292] 6778669: Patch from Red Hat -- fixes compilation
errors
Some fixes which are required to build on recent GCCs.
Reviewed-by: never, kvn
---
hotspot/make/linux/makefiles/adlc.make | 6 +-
hotspot/make/solaris/makefiles/adlc.make | 4 +-
hotspot/src/share/vm/adlc/adlc.hpp | 1 +
hotspot/src/share/vm/adlc/adlparse.cpp | 56 ++++++++-------
hotspot/src/share/vm/adlc/archDesc.cpp | 16 +++--
hotspot/src/share/vm/adlc/dfa.cpp | 6 +-
hotspot/src/share/vm/adlc/filebuff.cpp | 6 +-
hotspot/src/share/vm/adlc/filebuff.hpp | 7 +-
hotspot/src/share/vm/adlc/forms.cpp | 4 +-
hotspot/src/share/vm/adlc/forms.hpp | 4 +-
hotspot/src/share/vm/adlc/formsopt.cpp | 44 ++++++------
hotspot/src/share/vm/adlc/formsopt.hpp | 24 +++----
hotspot/src/share/vm/adlc/formssel.cpp | 52 +++++++-------
hotspot/src/share/vm/adlc/formssel.hpp | 26 +++----
hotspot/src/share/vm/adlc/main.cpp | 9 +--
hotspot/src/share/vm/adlc/output_c.cpp | 83 +++++++++++-----------
hotspot/src/share/vm/adlc/output_h.cpp | 4 +-
hotspot/src/share/vm/includeDB_core | 1 +
hotspot/src/share/vm/utilities/vmError.cpp | 6 +-
hotspot/src/share/vm/utilities/vmError.hpp | 4 +-
20 files changed, 188 insertions(+), 175 deletions(-)
diff --git a/hotspot/make/linux/makefiles/adlc.make b/hotspot/make/linux/makefiles/adlc.make
index 5e48fed1567..927462967f7 100644
--- a/hotspot/make/linux/makefiles/adlc.make
+++ b/hotspot/make/linux/makefiles/adlc.make
@@ -1,5 +1,5 @@
#
-# Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -61,8 +61,8 @@ CPPFLAGS = $(SYSDEFS) $(INCLUDES)
CPPFLAGS += -DASSERT
# CFLAGS_WARN holds compiler options to suppress/enable warnings.
-# Suppress warnings (for now)
-CFLAGS_WARN = -w
+# Compiler warnings are treated as errors
+CFLAGS_WARN = -Werror
CFLAGS += $(CFLAGS_WARN)
OBJECTNAMES = \
diff --git a/hotspot/make/solaris/makefiles/adlc.make b/hotspot/make/solaris/makefiles/adlc.make
index 2d1a87a20b4..b13e1fa528f 100644
--- a/hotspot/make/solaris/makefiles/adlc.make
+++ b/hotspot/make/solaris/makefiles/adlc.make
@@ -1,5 +1,5 @@
#
-# Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -67,6 +67,8 @@ ifndef USE_GCC
endif
# CFLAGS_WARN holds compiler options to suppress/enable warnings.
+# Compiler warnings are treated as errors
+CFLAGS_WARN = +w -errwarn
CFLAGS += $(CFLAGS_WARN)
ifeq ("${Platform_compiler}", "sparcWorks")
diff --git a/hotspot/src/share/vm/adlc/adlc.hpp b/hotspot/src/share/vm/adlc/adlc.hpp
index 14bc5d6b738..3d59b539b3e 100644
--- a/hotspot/src/share/vm/adlc/adlc.hpp
+++ b/hotspot/src/share/vm/adlc/adlc.hpp
@@ -79,6 +79,7 @@ typedef unsigned int uintptr_t;
// Macros
// Debugging note: Put a breakpoint on "abort".
+#undef assert
#define assert(cond, msg) { if (!(cond)) { fprintf(stderr, "assert fails %s %d: %s\n", __FILE__, __LINE__, msg); abort(); }}
#define max(a, b) (((a)>(b)) ? (a) : (b))
diff --git a/hotspot/src/share/vm/adlc/adlparse.cpp b/hotspot/src/share/vm/adlc/adlparse.cpp
index 81a95e861ab..f212d3f5756 100644
--- a/hotspot/src/share/vm/adlc/adlparse.cpp
+++ b/hotspot/src/share/vm/adlc/adlparse.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -298,7 +298,7 @@ void ADLParser::matchrule_clone_and_swap(MatchRule* rule, const char* instr_iden
rule->count_commutative_op(count);
if (count > 0) {
// Clone match rule and swap commutative operation's operands.
- rule->swap_commutative_op(instr_ident, count, match_rules_cnt);
+ rule->matchrule_swap_commutative_op(instr_ident, count, match_rules_cnt);
}
}
@@ -2586,7 +2586,7 @@ void ADLParser::peep_constraint_parse(Peephole &peep) {
while( _curchar != ')' ) {
// Get information on the left instruction and its operand
// left-instructions's number
- intptr_t left_inst = get_int();
+ int left_inst = get_int();
// Left-instruction's operand
skipws();
if( _curchar != '.' ) {
@@ -2602,7 +2602,7 @@ void ADLParser::peep_constraint_parse(Peephole &peep) {
skipws();
// Get information on the right instruction and its operand
- intptr_t right_inst; // Right-instructions's number
+ int right_inst; // Right-instructions's number
if( isdigit(_curchar) ) {
right_inst = get_int();
// Right-instruction's operand
@@ -3497,22 +3497,24 @@ FormatRule* ADLParser::template_parse(void) {
// (1)
// Check if there is a string to pass through to output
- char *start = _ptr; // Record start of the next string
- while ((_curchar != '$') && ((_curchar != '%') || (*(_ptr+1) != '}')) ) {
- // If at the start of a comment, skip past it
- if( (_curchar == '/') && ((*(_ptr+1) == '/') || (*(_ptr+1) == '*')) ) {
- skipws_no_preproc();
- } else {
- // ELSE advance to the next character, or start of the next line
- next_char_or_line();
+ {
+ char *start = _ptr; // Record start of the next string
+ while ((_curchar != '$') && ((_curchar != '%') || (*(_ptr+1) != '}')) ) {
+ // If at the start of a comment, skip past it
+ if( (_curchar == '/') && ((*(_ptr+1) == '/') || (*(_ptr+1) == '*')) ) {
+ skipws_no_preproc();
+ } else {
+ // ELSE advance to the next character, or start of the next line
+ next_char_or_line();
+ }
+ }
+ // If a string was found, terminate it and record in EncClass
+ if ( start != _ptr ) {
+ *_ptr = '\0'; // Terminate the string
+ // Add flag to _strings list indicating we should check _rep_vars
+ format->_strings.addName(NameList::_signal2);
+ format->_strings.addName(start);
}
- }
- // If a string was found, terminate it and record in EncClass
- if ( start != _ptr ) {
- *_ptr = '\0'; // Terminate the string
- // Add flag to _strings list indicating we should check _rep_vars
- format->_strings.addName(NameList::_signal2);
- format->_strings.addName(start);
}
// (2)
@@ -3563,10 +3565,10 @@ FormatRule* ADLParser::template_parse(void) {
// copy it and record in FormatRule
if ( _curchar == '$' ) {
next_char(); // Move past the '$'
- char* rep_var = get_ident(); // Nil terminate the variable name
- rep_var = strdup(rep_var);// Copy the string
+ char* next_rep_var = get_ident(); // Nil terminate the variable name
+ next_rep_var = strdup(next_rep_var);// Copy the string
*_ptr = _curchar; // and replace Nil with original character
- format->_rep_vars.addName(rep_var);
+ format->_rep_vars.addName(next_rep_var);
// Add flag to _strings list indicating we should check _rep_vars
format->_strings.addName(NameList::_signal);
}
@@ -3714,13 +3716,13 @@ ExpandRule* ADLParser::expand_parse(InstructForm *instr) {
parse_err(SYNERR, "identifier expected at %c\n", _curchar);
continue;
} // Check that you have a valid operand
- const Form *form = instr->_localNames[ident2];
- if (!form) {
+ const Form *form2 = instr->_localNames[ident2];
+ if (!form2) {
parse_err(SYNERR, "operand name expected at %s\n", ident2);
continue;
}
- oper = form->is_operand();
- if (oper == NULL && !form->is_opclass()) {
+ oper = form2->is_operand();
+ if (oper == NULL && !form2->is_opclass()) {
parse_err(SYNERR, "operand name expected at %s\n", ident2);
continue;
} // Add operand to list
@@ -4271,7 +4273,7 @@ int ADLParser::get_int(void) {
int result; // Storage for integer result
if( _curline == NULL ) // Return NULL at EOF.
- return NULL;
+ return 0;
skipws(); // Skip whitespace before identifier
start = end = _ptr; // Start points at first character
diff --git a/hotspot/src/share/vm/adlc/archDesc.cpp b/hotspot/src/share/vm/adlc/archDesc.cpp
index a73ad76da23..408f0323cd1 100644
--- a/hotspot/src/share/vm/adlc/archDesc.cpp
+++ b/hotspot/src/share/vm/adlc/archDesc.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+// Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
//
// This code is free software; you can redistribute it and/or modify it
@@ -436,10 +436,12 @@ void ArchDesc::build_chain_rule(OperandForm *oper) {
if ((oper->_matrule) && (oper->_matrule->_lChild == NULL) &&
(oper->_matrule->_rChild == NULL)) {
- const Form *form = _globalNames[oper->_matrule->_opType];
- if ((form) && form->is_operand() &&
- (form->ideal_only() == false)) {
- add_chain_rule_entry(oper->_matrule->_opType, oper->cost(), oper->_ident);
+ {
+ const Form *form = _globalNames[oper->_matrule->_opType];
+ if ((form) && form->is_operand() &&
+ (form->ideal_only() == false)) {
+ add_chain_rule_entry(oper->_matrule->_opType, oper->cost(), oper->_ident);
+ }
}
// Check for additional chain rules
if (oper->_matrule->_next) {
@@ -1015,12 +1017,12 @@ void ArchDesc::initBaseOpTypes() {
int idealIndex = 0;
for (idealIndex = 1; idealIndex < _last_machine_leaf; ++idealIndex) {
const char *idealName = NodeClassNames[idealIndex];
- _idealIndex.Insert((void*)idealName, (void*)idealIndex);
+ _idealIndex.Insert((void*) idealName, (void*) (intptr_t) idealIndex);
}
for ( idealIndex = _last_machine_leaf+1;
idealIndex < _last_opcode; ++idealIndex) {
const char *idealName = NodeClassNames[idealIndex];
- _idealIndex.Insert((void*)idealName, (void*)idealIndex);
+ _idealIndex.Insert((void*) idealName, (void*) (intptr_t) idealIndex);
}
}
diff --git a/hotspot/src/share/vm/adlc/dfa.cpp b/hotspot/src/share/vm/adlc/dfa.cpp
index 1075c9da774..20834184732 100644
--- a/hotspot/src/share/vm/adlc/dfa.cpp
+++ b/hotspot/src/share/vm/adlc/dfa.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2004 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -870,7 +870,7 @@ void ExprDict::print_asserts(FILE *fp) {
}
// Print out the dictionary contents as key-value pairs
-static void dumpekey(const void* key) { fprintf(stdout, "%s", key); }
+static void dumpekey(const void* key) { fprintf(stdout, "%s", (char*) key); }
static void dumpexpr(const void* expr) { fflush(stdout); ((Expr*)expr)->print(); }
void ExprDict::dump() {
@@ -1020,7 +1020,7 @@ void ProductionState::set_cost_bounds(const char *result, const Expr *cost, bool
}
// Print out the dictionary contents as key-value pairs
-static void print_key (const void* key) { fprintf(stdout, "%s", key); }
+static void print_key (const void* key) { fprintf(stdout, "%s", (char*) key); }
static void print_production(const void* production) { fflush(stdout); ((Production*)production)->print(); }
void ProductionState::print() {
diff --git a/hotspot/src/share/vm/adlc/filebuff.cpp b/hotspot/src/share/vm/adlc/filebuff.cpp
index 9cccb5d069e..36e611e15b6 100644
--- a/hotspot/src/share/vm/adlc/filebuff.cpp
+++ b/hotspot/src/share/vm/adlc/filebuff.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
// FILEBUFF.CPP - Routines for handling a parser file buffer
#include "adlc.hpp"
+using namespace std;
+
//------------------------------FileBuff---------------------------------------
// Create a new parsing buffer
FileBuff::FileBuff( BufferedFile *fptr, ArchDesc& archDesc) : _fp(fptr), _AD(archDesc) {
@@ -217,7 +219,7 @@ static int printline( ostream& os, const char *fname, int line,
off = expandtab(os,off,*s++,'-','-');
if( i == len ) os << '^'; // Mark end of region
os << '\n'; // End of marked line
- return 0L; // All done
+ return 0; // All done
}
//------------------------------print------------------------------------------
diff --git a/hotspot/src/share/vm/adlc/filebuff.hpp b/hotspot/src/share/vm/adlc/filebuff.hpp
index 8f12f9262d9..e5e8cccbea0 100644
--- a/hotspot/src/share/vm/adlc/filebuff.hpp
+++ b/hotspot/src/share/vm/adlc/filebuff.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
#include
using namespace std;
+
// STRUCTURE FOR HANDLING INPUT AND OUTPUT FILES
typedef struct {
const char *_name;
@@ -72,7 +73,7 @@ class FileBuff {
// This converts a pointer into the buffer to a file offset. It only works
// when the pointer is valid (i.e. just obtained from getline()).
- int getoff(const char *s) { return _bufoff+(int)(s-_buf); }
+ long getoff(const char* s) { return _bufoff + (s - _buf); }
};
//------------------------------FileBuffRegion---------------------------------
@@ -95,8 +96,6 @@ class FileBuffRegion {
FileBuffRegion *copy(); // Deep copy
FileBuffRegion *merge(FileBuffRegion*); // Merge 2 regions; delete input
-// void print(std::ostream&);
-// friend std::ostream& operator<< (std::ostream&, FileBuffRegion&);
void print(ostream&);
friend ostream& operator<< (ostream&, FileBuffRegion&);
};
diff --git a/hotspot/src/share/vm/adlc/forms.cpp b/hotspot/src/share/vm/adlc/forms.cpp
index cfcfd0a36d8..17bbe7f9657 100644
--- a/hotspot/src/share/vm/adlc/forms.cpp
+++ b/hotspot/src/share/vm/adlc/forms.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -370,7 +370,7 @@ bool FormDict::operator ==(const FormDict &d) const {
}
// Print out the dictionary contents as key-value pairs
-static void dumpkey (const void* key) { fprintf(stdout, "%s", key); }
+static void dumpkey (const void* key) { fprintf(stdout, "%s", (char*) key); }
static void dumpform(const void* form) { fflush(stdout); ((Form*)form)->dump(); }
void FormDict::dump() {
diff --git a/hotspot/src/share/vm/adlc/forms.hpp b/hotspot/src/share/vm/adlc/forms.hpp
index bf930b8e6da..8a0011b711c 100644
--- a/hotspot/src/share/vm/adlc/forms.hpp
+++ b/hotspot/src/share/vm/adlc/forms.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -124,7 +124,7 @@ protected:
public:
// Public Data
Form *_next; // Next pointer for form lists
- long _linenum; // Line number for debugging
+ int _linenum; // Line number for debugging
// Dynamic type check for common forms.
virtual OpClassForm *is_opclass() const;
diff --git a/hotspot/src/share/vm/adlc/formsopt.cpp b/hotspot/src/share/vm/adlc/formsopt.cpp
index df1f912e9a6..3b601897690 100644
--- a/hotspot/src/share/vm/adlc/formsopt.cpp
+++ b/hotspot/src/share/vm/adlc/formsopt.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -273,13 +273,13 @@ int RegClass::regs_in_word( int wordnum, bool stack_also ) {
for(_regDefs.reset(); (name = _regDefs.iter()) != NULL;) {
int rnum = ((RegDef*)_regDef[name])->register_num();
if( (rnum >> 5) == wordnum )
- word |= (1L<<(rnum&31));
+ word |= (1 << (rnum & 31));
}
if( stack_also ) {
// Now also collect stack bits
for( int i = 0; i < 32; i++ )
if( wordnum*32+i >= RegisterForm::_reg_ctr )
- word |= (1L< _max_position ) _max_position = position;
- _parent.addName((char *)parent);
- _position.addName((char *)position);
+ _parent.addName((char*) (intptr_t) parent);
+ _position.addName((char*) (intptr_t) position);
_instrs.addName(name);
- _input.addName((char *)input);
+ _input.addName((char*) (intptr_t) input);
}
// Access info about instructions in the peep-match rule
@@ -603,7 +603,7 @@ int PeepMatch::max_position() {
return _max_position;
}
-const char *PeepMatch::instruction_name(intptr_t position) {
+const char *PeepMatch::instruction_name(int position) {
return _instrs.name(position);
}
@@ -615,11 +615,11 @@ void PeepMatch::reset() {
_input.reset();
}
-void PeepMatch::next_instruction( intptr_t &parent, intptr_t &position, const char * &name, intptr_t &input ){
- parent = (intptr_t)_parent.iter();
- position = (intptr_t)_position.iter();
+void PeepMatch::next_instruction(int &parent, int &position, const char* &name, int &input) {
+ parent = (int) (intptr_t) _parent.iter();
+ position = (int) (intptr_t) _position.iter();
name = _instrs.iter();
- input = (intptr_t)_input.iter();
+ input = (int) (intptr_t) _input.iter();
}
// 'true' if current position in iteration is a placeholder, not matched.
@@ -637,15 +637,15 @@ void PeepMatch::output(FILE *fp) { // Write info to output files
}
//------------------------------PeepConstraint---------------------------------
-PeepConstraint::PeepConstraint(intptr_t left_inst, char *left_op, char *relation,
- intptr_t right_inst, char *right_op)
+PeepConstraint::PeepConstraint(int left_inst, char* left_op, char* relation,
+ int right_inst, char* right_op)
: _left_inst(left_inst), _left_op(left_op), _relation(relation),
_right_inst(right_inst), _right_op(right_op), _next(NULL) {}
PeepConstraint::~PeepConstraint() {
}
// Check if constraints use instruction at position
-bool PeepConstraint::constrains_instruction(intptr_t position) {
+bool PeepConstraint::constrains_instruction(int position) {
// Check local instruction constraints
if( _left_inst == position ) return true;
if( _right_inst == position ) return true;
@@ -692,7 +692,7 @@ void PeepReplace::add_instruction(char *root) {
}
void PeepReplace::add_operand( int inst_num, char *inst_operand ) {
_instruction.add_signal();
- _operand_inst_num.addName((char*)inst_num);
+ _operand_inst_num.addName((char*) (intptr_t) inst_num);
_operand_op_name.addName(inst_operand);
}
@@ -702,15 +702,15 @@ void PeepReplace::reset() {
_operand_inst_num.reset();
_operand_op_name.reset();
}
-void PeepReplace::next_instruction(const char * &inst){
+void PeepReplace::next_instruction(const char* &inst){
inst = _instruction.iter();
- intptr_t inst_num = (intptr_t)_operand_inst_num.iter();
- const char *inst_operand = _operand_op_name.iter();
+ int inst_num = (int) (intptr_t) _operand_inst_num.iter();
+ const char* inst_operand = _operand_op_name.iter();
}
-void PeepReplace::next_operand( intptr_t &inst_num, const char * &inst_operand ) {
- const char *inst = _instruction.iter();
- inst_num = (intptr_t)_operand_inst_num.iter();
- inst_operand = _operand_op_name.iter();
+void PeepReplace::next_operand(int &inst_num, const char* &inst_operand) {
+ const char* inst = _instruction.iter();
+ inst_num = (int) (intptr_t) _operand_inst_num.iter();
+ inst_operand = _operand_op_name.iter();
}
diff --git a/hotspot/src/share/vm/adlc/formsopt.hpp b/hotspot/src/share/vm/adlc/formsopt.hpp
index 627dc4de035..bb4ba107212 100644
--- a/hotspot/src/share/vm/adlc/formsopt.hpp
+++ b/hotspot/src/share/vm/adlc/formsopt.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -457,10 +457,10 @@ public:
// Access info about instructions in the peep-match rule
int max_position();
- const char *instruction_name(intptr_t position);
+ const char *instruction_name(int position);
// Iterate through all info on matched instructions
void reset();
- void next_instruction( intptr_t &parent, intptr_t &position, const char * &name, intptr_t &input );
+ void next_instruction(int &parent, int &position, const char* &name, int &input);
// 'true' if current position in iteration is a placeholder, not matched.
bool is_placeholder();
@@ -474,20 +474,20 @@ private:
PeepConstraint *_next; // Additional constraints ANDed together
public:
- const intptr_t _left_inst;
- const char *_left_op;
- const char *_relation;
- const intptr_t _right_inst;
- const char *_right_op;
+ const int _left_inst;
+ const char* _left_op;
+ const char* _relation;
+ const int _right_inst;
+ const char* _right_op;
public:
// Public Methods
- PeepConstraint(intptr_t left_inst, char *left_op, char *relation,
- intptr_t right_inst, char *right_op);
+ PeepConstraint(int left_inst, char* left_op, char* relation,
+ int right_inst, char* right_op);
~PeepConstraint();
// Check if constraints use instruction at position
- bool constrains_instruction(intptr_t position);
+ bool constrains_instruction(int position);
// Add another constraint
void append(PeepConstraint *next_peep_constraint);
@@ -519,7 +519,7 @@ public:
// Access contents of peepreplace
void reset();
void next_instruction(const char * &root);
- void next_operand( intptr_t &inst_num, const char * &inst_operand );
+ void next_operand(int &inst_num, const char * &inst_operand );
// Utilities
void dump();
diff --git a/hotspot/src/share/vm/adlc/formssel.cpp b/hotspot/src/share/vm/adlc/formssel.cpp
index d26a94c3bc7..cf48d265084 100644
--- a/hotspot/src/share/vm/adlc/formssel.cpp
+++ b/hotspot/src/share/vm/adlc/formssel.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -844,8 +844,12 @@ void InstructForm::build_components() {
for (_parameters.reset(); (name = _parameters.iter()) != NULL;) {
OperandForm *opForm = (OperandForm*)_localNames[name];
- const Form *form = _effects[name];
- Effect *e = form ? form->is_effect() : NULL;
+ Effect* e = NULL;
+ {
+ const Form* form = _effects[name];
+ e = form ? form->is_effect() : NULL;
+ }
+
if (e != NULL) {
has_temp |= e->is(Component::TEMP);
@@ -1110,7 +1114,7 @@ bool InstructForm::cisc_spills_to(ArchDesc &AD, InstructForm *instr) {
const char *op_name = NULL;
const char *reg_type = NULL;
FormDict &globals = AD.globalNames();
- cisc_spill_operand = _matrule->cisc_spill_match(globals, AD.get_registers(), instr->_matrule, op_name, reg_type);
+ cisc_spill_operand = _matrule->matchrule_cisc_spill_match(globals, AD.get_registers(), instr->_matrule, op_name, reg_type);
if( (cisc_spill_operand != Not_cisc_spillable) && (op_name != NULL) && equivalent_predicates(this, instr) ) {
cisc_spill_operand = operand_position(op_name, Component::USE);
int def_oper = operand_position(op_name, Component::DEF);
@@ -2194,7 +2198,7 @@ int OperandForm::operand_position(const char *name, int usedef) {
// Return -1 if not in list.
int OperandForm::constant_position(FormDict &globals, const Component *last) {
// Iterate through components and count constants preceeding 'constant'
- uint position = 0;
+ int position = 0;
Component *comp;
_components.reset();
while( (comp = _components.iter()) != NULL && (comp != last) ) {
@@ -2297,7 +2301,7 @@ void OperandForm::disp_is_oop(FILE *fp, FormDict &globals) {
if ( op->is_base_constant(globals) == Form::idealP ) {
// Find the constant's index: _c0, _c1, _c2, ... , _cN
uint idx = op->constant_position( globals, rep_var);
- fprintf(fp," virtual bool disp_is_oop() const {", _ident);
+ fprintf(fp," virtual bool disp_is_oop() const {");
fprintf(fp, " return _c%d->isa_oop_ptr();", idx);
fprintf(fp, " }\n");
}
@@ -3035,9 +3039,9 @@ bool MatchNode::find_type(const char *type, int &position) const {
// Recursive call collecting info on top-level operands, not transitive.
// Implementation does not modify state of internal structures.
-void MatchNode::append_components(FormDict &locals, ComponentList &components,
- bool deflag) const {
- int usedef = deflag ? Component::DEF : Component::USE;
+void MatchNode::append_components(FormDict& locals, ComponentList& components,
+ bool def_flag) const {
+ int usedef = def_flag ? Component::DEF : Component::USE;
FormDict &globals = _AD.globalNames();
assert (_name != NULL, "MatchNode::build_components encountered empty node\n");
@@ -3055,10 +3059,10 @@ void MatchNode::append_components(FormDict &locals, ComponentList &components,
return;
}
// Promote results of "Set" to DEF
- bool def_flag = (!strcmp(_opType, "Set")) ? true : false;
- if (_lChild) _lChild->append_components(locals, components, def_flag);
- def_flag = false; // only applies to component immediately following 'Set'
- if (_rChild) _rChild->append_components(locals, components, def_flag);
+ bool tmpdef_flag = (!strcmp(_opType, "Set")) ? true : false;
+ if (_lChild) _lChild->append_components(locals, components, tmpdef_flag);
+ tmpdef_flag = false; // only applies to component immediately following 'Set'
+ if (_rChild) _rChild->append_components(locals, components, tmpdef_flag);
}
// Find the n'th base-operand in the match node,
@@ -3404,9 +3408,9 @@ bool static root_ops_match(FormDict &globals, const char *op1, const char *op2)
return (form1 == form2);
}
-//-------------------------cisc_spill_match------------------------------------
+//-------------------------cisc_spill_match_node-------------------------------
// Recursively check two MatchRules for legal conversion via cisc-spilling
-int MatchNode::cisc_spill_match(FormDict &globals, RegisterForm *registers, MatchNode *mRule2, const char * &operand, const char * ®_type) {
+int MatchNode::cisc_spill_match(FormDict& globals, RegisterForm* registers, MatchNode* mRule2, const char* &operand, const char* ®_type) {
int cisc_spillable = Maybe_cisc_spillable;
int left_spillable = Maybe_cisc_spillable;
int right_spillable = Maybe_cisc_spillable;
@@ -3480,13 +3484,13 @@ int MatchNode::cisc_spill_match(FormDict &globals, RegisterForm *registers, Mat
return cisc_spillable;
}
-//---------------------------cisc_spill_match----------------------------------
+//---------------------------cisc_spill_match_rule------------------------------
// Recursively check two MatchRules for legal conversion via cisc-spilling
// This method handles the root of Match tree,
// general recursive checks done in MatchNode
-int MatchRule::cisc_spill_match(FormDict &globals, RegisterForm *registers,
- MatchRule *mRule2, const char * &operand,
- const char * ®_type) {
+int MatchRule::matchrule_cisc_spill_match(FormDict& globals, RegisterForm* registers,
+ MatchRule* mRule2, const char* &operand,
+ const char* ®_type) {
int cisc_spillable = Maybe_cisc_spillable;
int left_spillable = Maybe_cisc_spillable;
int right_spillable = Maybe_cisc_spillable;
@@ -3524,7 +3528,7 @@ int MatchRule::cisc_spill_match(FormDict &globals, RegisterForm *registers,
//----------------------------- equivalent ------------------------------------
// Recursively check to see if two match rules are equivalent.
// This rule handles the root.
-bool MatchRule::equivalent(FormDict &globals, MatchRule *mRule2) {
+bool MatchRule::equivalent(FormDict &globals, MatchNode *mRule2) {
// Check that each sets a result
if (sets_result() != mRule2->sets_result()) {
return false;
@@ -3640,7 +3644,7 @@ void MatchNode::swap_commutative_op(bool atroot, int id) {
//-------------------------- swap_commutative_op ------------------------------
// Recursively swap specified commutative operation with subtree operands.
-void MatchRule::swap_commutative_op(const char* instr_ident, int count, int& match_rules_cnt) {
+void MatchRule::matchrule_swap_commutative_op(const char* instr_ident, int count, int& match_rules_cnt) {
assert(match_rules_cnt < 100," too many match rule clones");
// Clone
MatchRule* clone = new MatchRule(_AD, this);
@@ -3653,8 +3657,8 @@ void MatchRule::swap_commutative_op(const char* instr_ident, int count, int& mat
clone->_next = this->_next;
this-> _next = clone;
if( (--count) > 0 ) {
- this-> swap_commutative_op(instr_ident, count, match_rules_cnt);
- clone->swap_commutative_op(instr_ident, count, match_rules_cnt);
+ this-> matchrule_swap_commutative_op(instr_ident, count, match_rules_cnt);
+ clone->matchrule_swap_commutative_op(instr_ident, count, match_rules_cnt);
}
}
@@ -3686,7 +3690,7 @@ MatchRule::~MatchRule() {
// Recursive call collecting info on top-level operands, not transitive.
// Implementation does not modify state of internal structures.
-void MatchRule::append_components(FormDict &locals, ComponentList &components) const {
+void MatchRule::append_components(FormDict& locals, ComponentList& components, bool def_flag) const {
assert (_name != NULL, "MatchNode::build_components encountered empty node\n");
MatchNode::append_components(locals, components,
diff --git a/hotspot/src/share/vm/adlc/formssel.hpp b/hotspot/src/share/vm/adlc/formssel.hpp
index e1aa84d91ca..84c49be69eb 100644
--- a/hotspot/src/share/vm/adlc/formssel.hpp
+++ b/hotspot/src/share/vm/adlc/formssel.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -920,8 +920,8 @@ public:
// return 1 if found and position is incremented by operand offset in rule
bool find_name(const char *str, int &position) const;
bool find_type(const char *str, int &position) const;
- void append_components(FormDict &locals, ComponentList &components,
- bool def_flag) const;
+ virtual void append_components(FormDict& locals, ComponentList& components,
+ bool def_flag = false) const;
bool base_operand(uint &position, FormDict &globals,
const char * &result, const char * &name,
const char * &opType) const;
@@ -947,12 +947,12 @@ public:
const char *reduce_left (FormDict &globals) const;
// Recursive version of check in MatchRule
- int cisc_spill_match(FormDict &globals, RegisterForm *registers,
- MatchNode *mRule2, const char * &operand,
- const char * ®_type);
+ int cisc_spill_match(FormDict& globals, RegisterForm* registers,
+ MatchNode* mRule2, const char* &operand,
+ const char* ®_type);
int cisc_spill_merge(int left_result, int right_result);
- bool equivalent(FormDict &globals, MatchNode *mNode2);
+ virtual bool equivalent(FormDict& globals, MatchNode* mNode2);
void count_commutative_op(int& count);
void swap_commutative_op(bool atroot, int count);
@@ -979,7 +979,7 @@ public:
MatchRule(ArchDesc &ad, MatchNode* mroot, int depth, char* construct, int numleaves);
~MatchRule();
- void append_components(FormDict &locals, ComponentList &components) const;
+ virtual void append_components(FormDict& locals, ComponentList& components, bool def_flag = false) const;
// Recursive call on all operands' match rules in my match rule.
bool base_operand(uint &position, FormDict &globals,
const char * &result, const char * &name,
@@ -1006,14 +1006,14 @@ public:
Form::DataType is_ideal_store() const;// node matches ideal 'StoreXNode'
// Check if 'mRule2' is a cisc-spill variant of this MatchRule
- int cisc_spill_match(FormDict &globals, RegisterForm *registers,
- MatchRule *mRule2, const char * &operand,
- const char * ®_type);
+ int matchrule_cisc_spill_match(FormDict &globals, RegisterForm* registers,
+ MatchRule* mRule2, const char* &operand,
+ const char* ®_type);
// Check if 'mRule2' is equivalent to this MatchRule
- bool equivalent(FormDict &globals, MatchRule *mRule2);
+ virtual bool equivalent(FormDict& globals, MatchNode* mRule2);
- void swap_commutative_op(const char* instr_ident, int count, int& match_rules_cnt);
+ void matchrule_swap_commutative_op(const char* instr_ident, int count, int& match_rules_cnt);
void dump();
void output(FILE *fp);
diff --git a/hotspot/src/share/vm/adlc/main.cpp b/hotspot/src/share/vm/adlc/main.cpp
index c5b405d0208..7fb780935a3 100644
--- a/hotspot/src/share/vm/adlc/main.cpp
+++ b/hotspot/src/share/vm/adlc/main.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -349,7 +349,7 @@ void ArchDesc::close_files(int delete_out)
}
else {
if (_ADL_file._name) printf("%s --> ", _ADL_file._name);
- printf("%s, %s, %s, %s, %s, %s, %s, %s, %s",
+ printf("%s, %s, %s, %s, %s, %s, %s, %s, %s, %s",
_CPP_file._name,
_CPP_CLONE_file._name,
_CPP_EXPAND_file._name,
@@ -358,7 +358,8 @@ void ArchDesc::close_files(int delete_out)
_CPP_MISC_file._name,
_CPP_PEEPHOLE_file._name,
_CPP_PIPELINE_file._name,
- _HPP_file._name, _DFA_file._name);
+ _HPP_file._name,
+ _DFA_file._name);
}
printf("\n");
}
@@ -431,7 +432,7 @@ int get_legal_text(FileBuff &fbuf, char **legal_text)
legal_end = fbuf.get_line();
}
*legal_text = legal_start;
- return (legal_end - legal_start);
+ return (int) (legal_end - legal_start);
}
// VS2005 has its own definition, identical to this one.
diff --git a/hotspot/src/share/vm/adlc/output_c.cpp b/hotspot/src/share/vm/adlc/output_c.cpp
index dbc287b1d1a..f1d010979f6 100644
--- a/hotspot/src/share/vm/adlc/output_c.cpp
+++ b/hotspot/src/share/vm/adlc/output_c.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -225,11 +225,11 @@ static int pipeline_reads_initializer(FILE *fp_cpp, NameList &pipeline_reads, Pi
pipeclass->_parameters.reset();
while ( (paramname = pipeclass->_parameters.iter()) != NULL ) {
- const PipeClassOperandForm *pipeopnd =
+ const PipeClassOperandForm *tmppipeopnd =
(const PipeClassOperandForm *)pipeclass->_localUsage[paramname];
- if (pipeopnd)
- templen += 10 + (int)strlen(pipeopnd->_stage);
+ if (tmppipeopnd)
+ templen += 10 + (int)strlen(tmppipeopnd->_stage);
else
templen += 19;
@@ -253,10 +253,10 @@ static int pipeline_reads_initializer(FILE *fp_cpp, NameList &pipeline_reads, Pi
pipeclass->_parameters.reset();
while ( (paramname = pipeclass->_parameters.iter()) != NULL ) {
- const PipeClassOperandForm *pipeopnd =
+ const PipeClassOperandForm *tmppipeopnd =
(const PipeClassOperandForm *)pipeclass->_localUsage[paramname];
templen += sprintf(&operand_stages[templen], " stage_%s%c\n",
- pipeopnd ? pipeopnd->_stage : "undefined",
+ tmppipeopnd ? tmppipeopnd->_stage : "undefined",
(++i < paramcount ? ',' : ' ') );
}
@@ -1042,10 +1042,10 @@ static void defineOut_RegMask(FILE *fp, const char *node, const char *regMask) {
// Scan the peepmatch and output a test for each instruction
static void check_peepmatch_instruction_tree(FILE *fp, PeepMatch *pmatch, PeepConstraint *pconstraint) {
- intptr_t parent = -1;
- intptr_t inst_position = 0;
- const char *inst_name = NULL;
- intptr_t input = 0;
+ int parent = -1;
+ int inst_position = 0;
+ const char* inst_name = NULL;
+ int input = 0;
fprintf(fp, " // Check instruction sub-tree\n");
pmatch->reset();
for( pmatch->next_instruction( parent, inst_position, inst_name, input );
@@ -1055,14 +1055,14 @@ static void check_peepmatch_instruction_tree(FILE *fp, PeepMatch *pmatch, PeepCo
if( ! pmatch->is_placeholder() ) {
// Define temporaries 'inst#', based on parent and parent's input index
if( parent != -1 ) { // root was initialized
- fprintf(fp, " inst%ld = inst%ld->in(%ld);\n",
+ fprintf(fp, " inst%d = inst%d->in(%d);\n",
inst_position, parent, input);
}
// When not the root
// Test we have the correct instruction by comparing the rule
if( parent != -1 ) {
- fprintf(fp, " matches = matches && ( inst%ld->rule() == %s_rule );",
+ fprintf(fp, " matches = matches && ( inst%d->rule() == %s_rule );",
inst_position, inst_name);
}
} else {
@@ -1073,20 +1073,20 @@ static void check_peepmatch_instruction_tree(FILE *fp, PeepMatch *pmatch, PeepCo
}
}
-static void print_block_index(FILE *fp, intptr_t inst_position) {
+static void print_block_index(FILE *fp, int inst_position) {
assert( inst_position >= 0, "Instruction number less than zero");
fprintf(fp, "block_index");
if( inst_position != 0 ) {
- fprintf(fp, " - %ld", inst_position);
+ fprintf(fp, " - %d", inst_position);
}
}
// Scan the peepmatch and output a test for each instruction
static void check_peepmatch_instruction_sequence(FILE *fp, PeepMatch *pmatch, PeepConstraint *pconstraint) {
- intptr_t parent = -1;
- intptr_t inst_position = 0;
- const char *inst_name = NULL;
- intptr_t input = 0;
+ int parent = -1;
+ int inst_position = 0;
+ const char* inst_name = NULL;
+ int input = 0;
fprintf(fp, " // Check instruction sub-tree\n");
pmatch->reset();
for( pmatch->next_instruction( parent, inst_position, inst_name, input );
@@ -1101,14 +1101,14 @@ static void check_peepmatch_instruction_sequence(FILE *fp, PeepMatch *pmatch, Pe
print_block_index(fp, inst_position);
fprintf(fp, " > 0 ) {\n Node *n = block->_nodes.at(");
print_block_index(fp, inst_position);
- fprintf(fp, ");\n inst%ld = (n->is_Mach()) ? ", inst_position);
+ fprintf(fp, ");\n inst%d = (n->is_Mach()) ? ", inst_position);
fprintf(fp, "n->as_Mach() : NULL;\n }\n");
}
// When not the root
// Test we have the correct instruction by comparing the rule.
if( parent != -1 ) {
- fprintf(fp, " matches = matches && (inst%ld != NULL) && (inst%ld->rule() == %s_rule);\n",
+ fprintf(fp, " matches = matches && (inst%d != NULL) && (inst%d->rule() == %s_rule);\n",
inst_position, inst_position, inst_name);
}
} else {
@@ -1121,10 +1121,10 @@ static void check_peepmatch_instruction_sequence(FILE *fp, PeepMatch *pmatch, Pe
// Build mapping for register indices, num_edges to input
static void build_instruction_index_mapping( FILE *fp, FormDict &globals, PeepMatch *pmatch ) {
- intptr_t parent = -1;
- intptr_t inst_position = 0;
- const char *inst_name = NULL;
- intptr_t input = 0;
+ int parent = -1;
+ int inst_position = 0;
+ const char* inst_name = NULL;
+ int input = 0;
fprintf(fp, " // Build map to register info\n");
pmatch->reset();
for( pmatch->next_instruction( parent, inst_position, inst_name, input );
@@ -1136,9 +1136,9 @@ static void build_instruction_index_mapping( FILE *fp, FormDict &globals, PeepMa
InstructForm *inst = globals[inst_name]->is_instruction();
if( inst != NULL ) {
char inst_prefix[] = "instXXXX_";
- sprintf(inst_prefix, "inst%ld_", inst_position);
+ sprintf(inst_prefix, "inst%d_", inst_position);
char receiver[] = "instXXXX->";
- sprintf(receiver, "inst%ld->", inst_position);
+ sprintf(receiver, "inst%d->", inst_position);
inst->index_temps( fp, globals, inst_prefix, receiver );
}
}
@@ -1168,7 +1168,7 @@ static void check_peepconstraints(FILE *fp, FormDict &globals, PeepMatch *pmatch
}
// LEFT
- intptr_t left_index = pconstraint->_left_inst;
+ int left_index = pconstraint->_left_inst;
const char *left_op = pconstraint->_left_op;
// Access info on the instructions whose operands are compared
InstructForm *inst_left = globals[pmatch->instruction_name(left_index)]->is_instruction();
@@ -1191,7 +1191,7 @@ static void check_peepconstraints(FILE *fp, FormDict &globals, PeepMatch *pmatch
// RIGHT
int right_op_index = -1;
- intptr_t right_index = pconstraint->_right_inst;
+ int right_index = pconstraint->_right_inst;
const char *right_op = pconstraint->_right_op;
if( right_index != -1 ) { // Match operand
// Access info on the instructions whose operands are compared
@@ -1351,7 +1351,7 @@ static void generate_peepreplace( FILE *fp, FormDict &globals, PeepMatch *pmatch
assert( root_form != NULL, "Replacement instruction was not previously defined");
fprintf(fp, " %sNode *root = new (C) %sNode();\n", root_inst, root_inst);
- intptr_t inst_num;
+ int inst_num;
const char *op_name;
int opnds_index = 0; // define result operand
// Then install the use-operands for the new sub-tree
@@ -1362,7 +1362,6 @@ static void generate_peepreplace( FILE *fp, FormDict &globals, PeepMatch *pmatch
InstructForm *inst_form;
inst_form = globals[pmatch->instruction_name(inst_num)]->is_instruction();
assert( inst_form, "Parser should guaranty this is an instruction");
- int op_base = inst_form->oper_input_base(globals);
int inst_op_num = inst_form->operand_position(op_name, Component::USE);
if( inst_op_num == NameList::Not_in_list )
inst_op_num = inst_form->operand_position(op_name, Component::USE_DEF);
@@ -1379,32 +1378,32 @@ static void generate_peepreplace( FILE *fp, FormDict &globals, PeepMatch *pmatch
// Add unmatched edges from root of match tree
int op_base = root_form->oper_input_base(globals);
for( int unmatched_edge = 1; unmatched_edge < op_base; ++unmatched_edge ) {
- fprintf(fp, " root->add_req(inst%ld->in(%d)); // unmatched ideal edge\n",
+ fprintf(fp, " root->add_req(inst%d->in(%d)); // unmatched ideal edge\n",
inst_num, unmatched_edge);
}
// If new instruction captures bottom type
if( root_form->captures_bottom_type() ) {
// Get bottom type from instruction whose result we are replacing
- fprintf(fp, " root->_bottom_type = inst%ld->bottom_type();\n", inst_num);
+ fprintf(fp, " root->_bottom_type = inst%d->bottom_type();\n", inst_num);
}
// Define result register and result operand
- fprintf(fp, " ra_->add_reference(root, inst%ld);\n", inst_num);
- fprintf(fp, " ra_->set_oop (root, ra_->is_oop(inst%ld));\n", inst_num);
- fprintf(fp, " ra_->set_pair(root->_idx, ra_->get_reg_second(inst%ld), ra_->get_reg_first(inst%ld));\n", inst_num, inst_num);
- fprintf(fp, " root->_opnds[0] = inst%ld->_opnds[0]->clone(C); // result\n", inst_num);
+ fprintf(fp, " ra_->add_reference(root, inst%d);\n", inst_num);
+ fprintf(fp, " ra_->set_oop (root, ra_->is_oop(inst%d));\n", inst_num);
+ fprintf(fp, " ra_->set_pair(root->_idx, ra_->get_reg_second(inst%d), ra_->get_reg_first(inst%d));\n", inst_num, inst_num);
+ fprintf(fp, " root->_opnds[0] = inst%d->_opnds[0]->clone(C); // result\n", inst_num);
fprintf(fp, " // ----- Done with initial setup -----\n");
} else {
if( (op_form == NULL) || (op_form->is_base_constant(globals) == Form::none) ) {
// Do not have ideal edges for constants after matching
- fprintf(fp, " for( unsigned x%d = inst%ld_idx%d; x%d < inst%ld_idx%d; x%d++ )\n",
+ fprintf(fp, " for( unsigned x%d = inst%d_idx%d; x%d < inst%d_idx%d; x%d++ )\n",
inst_op_num, inst_num, inst_op_num,
inst_op_num, inst_num, inst_op_num+1, inst_op_num );
- fprintf(fp, " root->add_req( inst%ld->in(x%d) );\n",
+ fprintf(fp, " root->add_req( inst%d->in(x%d) );\n",
inst_num, inst_op_num );
} else {
fprintf(fp, " // no ideal edge for constants after matching\n");
}
- fprintf(fp, " root->_opnds[%d] = inst%ld->_opnds[%d]->clone(C);\n",
+ fprintf(fp, " root->_opnds[%d] = inst%d->_opnds[%d]->clone(C);\n",
opnds_index, inst_num, inst_op_num );
}
++opnds_index;
@@ -1443,7 +1442,7 @@ void ArchDesc::definePeephole(FILE *fp, InstructForm *node) {
}
for( int i = 0; i <= max_position; ++i ) {
if( i == 0 ) {
- fprintf(fp, " MachNode *inst0 = this;\n", i);
+ fprintf(fp, " MachNode *inst0 = this;\n");
} else {
fprintf(fp, " MachNode *inst%d = NULL;\n", i);
}
@@ -1743,7 +1742,7 @@ void ArchDesc::defineExpand(FILE *fp, InstructForm *node) {
}
// delete the rest of edges
fprintf(fp," for(int i = idx%d - 1; i >= (int)idx%d; i--) {\n", cur_num_opnds, new_num_opnds);
- fprintf(fp," del_req(i);\n", i);
+ fprintf(fp," del_req(i);\n");
fprintf(fp," }\n");
fprintf(fp," _num_opnds = %d;\n", new_num_opnds);
}
@@ -1817,7 +1816,7 @@ void ArchDesc::defineExpand(FILE *fp, InstructForm *node) {
fprintf(fp,"\n");
if( node->expands() ) {
- fprintf(fp," return result;\n",cnt-1);
+ fprintf(fp," return result;\n");
} else {
fprintf(fp," return this;\n");
}
diff --git a/hotspot/src/share/vm/adlc/output_h.cpp b/hotspot/src/share/vm/adlc/output_h.cpp
index d2fd489abe9..764dcd03dc4 100644
--- a/hotspot/src/share/vm/adlc/output_h.cpp
+++ b/hotspot/src/share/vm/adlc/output_h.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -1832,7 +1832,7 @@ void ArchDesc::declareClasses(FILE *fp) {
break;
case Form::idealP:
case Form::idealN:
- fprintf(fp," return opnd_array(1)->type();\n",result);
+ fprintf(fp," return opnd_array(1)->type();\n");
break;
case Form::idealD:
fprintf(fp," return TypeD::make(opnd_array(1)->constantD());\n");
diff --git a/hotspot/src/share/vm/includeDB_core b/hotspot/src/share/vm/includeDB_core
index 603485132e8..85e710c5b50 100644
--- a/hotspot/src/share/vm/includeDB_core
+++ b/hotspot/src/share/vm/includeDB_core
@@ -474,6 +474,7 @@ cardTableModRefBS.cpp java.hpp
cardTableModRefBS.cpp mutexLocker.hpp
cardTableModRefBS.cpp sharedHeap.hpp
cardTableModRefBS.cpp space.hpp
+cardTableModRefBS.cpp space.inline.hpp
cardTableModRefBS.cpp universe.hpp
cardTableModRefBS.cpp virtualspace.hpp
diff --git a/hotspot/src/share/vm/utilities/vmError.cpp b/hotspot/src/share/vm/utilities/vmError.cpp
index a4d0cb0baf0..f3f3edc12fc 100644
--- a/hotspot/src/share/vm/utilities/vmError.cpp
+++ b/hotspot/src/share/vm/utilities/vmError.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -306,7 +306,7 @@ void VMError::report(outputStream* st) {
strncpy(buf, file, buflen);
if (len + 10 < buflen) {
- sprintf(buf + len, ":" SIZE_FORMAT, _lineno);
+ sprintf(buf + len, ":%d", _lineno);
}
st->print(" (%s)", buf);
} else {
@@ -420,7 +420,7 @@ void VMError::report(outputStream* st) {
if (fr.sp()) {
st->print(", sp=" PTR_FORMAT, fr.sp());
- st->print(", free space=%dk",
+ st->print(", free space=%" INTPTR_FORMAT "k",
((intptr_t)fr.sp() - (intptr_t)stack_bottom) >> 10);
}
diff --git a/hotspot/src/share/vm/utilities/vmError.hpp b/hotspot/src/share/vm/utilities/vmError.hpp
index 8e618d91462..4a8cc23523d 100644
--- a/hotspot/src/share/vm/utilities/vmError.hpp
+++ b/hotspot/src/share/vm/utilities/vmError.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* 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 @@ class VMError : public StackObj {
// additional info for VM internal errors
const char * _filename;
- size_t _lineno;
+ int _lineno;
// used by fatal error handler
int _current_step;
From 67a5668b16866b9b0fea7e813a2d9cd1437e6cd1 Mon Sep 17 00:00:00 2001
From: Vladimir Kozlov
Date: Fri, 27 Feb 2009 08:34:19 -0800
Subject: [PATCH 068/292] 6811267: Fix for 6809798 broke linux build
Fix method's declaration.
Reviewed-by: phh, twisti
---
hotspot/src/share/vm/opto/block.hpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hotspot/src/share/vm/opto/block.hpp b/hotspot/src/share/vm/opto/block.hpp
index 0da859abbba..f678983ddaf 100644
--- a/hotspot/src/share/vm/opto/block.hpp
+++ b/hotspot/src/share/vm/opto/block.hpp
@@ -347,7 +347,7 @@ class PhaseCFG : public Phase {
// Helper function to insert a node into a block
void schedule_node_into_block( Node *n, Block *b );
- void PhaseCFG::replace_block_proj_ctrl( Node *n );
+ void replace_block_proj_ctrl( Node *n );
// Set the basic block for pinned Nodes
void schedule_pinned_nodes( VectorSet &visited );
From 05d1de77274ccd96bb5a98505da0317b5ad617c1 Mon Sep 17 00:00:00 2001
From: Christian Thalinger
Date: Fri, 27 Feb 2009 13:27:09 -0800
Subject: [PATCH 069/292] 6810672: Comment typos
I have collected some typos I have found while looking at the code.
Reviewed-by: kvn, never
---
.../src/cpu/sparc/vm/interp_masm_sparc.cpp | 2 +-
hotspot/src/cpu/sparc/vm/nativeInst_sparc.hpp | 2 +-
hotspot/src/cpu/sparc/vm/sparc.ad | 16 +++++------
.../src/cpu/sparc/vm/templateTable_sparc.cpp | 4 +--
.../src/cpu/x86/vm/c1_LIRGenerator_x86.cpp | 2 +-
hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp | 6 ++--
.../src/cpu/x86/vm/sharedRuntime_x86_64.cpp | 2 +-
.../cpu/x86/vm/templateInterpreter_x86_64.cpp | 2 +-
.../src/cpu/x86/vm/templateTable_x86_32.cpp | 2 +-
.../src/cpu/x86/vm/templateTable_x86_64.cpp | 2 +-
hotspot/src/cpu/x86/vm/x86_32.ad | 6 ++--
hotspot/src/cpu/x86/vm/x86_64.ad | 6 ++--
hotspot/src/os/linux/launcher/java.c | 4 +--
hotspot/src/os/linux/launcher/java_md.h | 2 +-
hotspot/src/os/linux/vm/perfMemory_linux.cpp | 2 +-
hotspot/src/os/solaris/launcher/java.c | 4 +--
hotspot/src/os/solaris/launcher/java_md.h | 2 +-
.../src/os/solaris/vm/perfMemory_solaris.cpp | 2 +-
.../src/os/windows/vm/perfMemory_windows.cpp | 6 ++--
.../solaris_sparc/vm/os_solaris_sparc.cpp | 2 +-
.../os_cpu/solaris_x86/vm/os_solaris_x86.cpp | 2 +-
.../src/share/tools/MakeDeps/Database.java | 2 +-
hotspot/src/share/vm/adlc/Doc/Syntax.doc | 4 +--
hotspot/src/share/vm/adlc/adlparse.cpp | 2 +-
hotspot/src/share/vm/adlc/dict2.cpp | 6 ++--
hotspot/src/share/vm/adlc/dict2.hpp | 4 +--
hotspot/src/share/vm/adlc/filebuff.cpp | 12 ++++----
hotspot/src/share/vm/adlc/filebuff.hpp | 6 ++--
hotspot/src/share/vm/adlc/formssel.cpp | 6 ++--
hotspot/src/share/vm/adlc/formssel.hpp | 4 +--
hotspot/src/share/vm/adlc/output_h.cpp | 2 +-
hotspot/src/share/vm/asm/assembler.cpp | 2 +-
hotspot/src/share/vm/asm/assembler.hpp | 2 +-
hotspot/src/share/vm/ci/ciTypeFlow.cpp | 2 +-
.../src/share/vm/classfile/symbolTable.cpp | 4 +--
hotspot/src/share/vm/code/nmethod.cpp | 2 +-
hotspot/src/share/vm/code/nmethod.hpp | 2 +-
.../cmsAdaptiveSizePolicy.hpp | 2 +-
.../cmsGCAdaptivePolicyCounters.hpp | 2 +-
.../concurrentMarkSweepGeneration.cpp | 4 +--
.../gc_implementation/g1/g1CollectedHeap.cpp | 2 +-
.../parallelScavenge/cardTableExtension.cpp | 4 +--
.../parallelScavenge/objectStartArray.hpp | 2 +-
.../parallelScavenge/prefetchQueue.hpp | 2 +-
.../shared/mutableNUMASpace.cpp | 2 +-
.../vm/interpreter/abstractInterpreter.hpp | 2 +-
.../vm/interpreter/bytecodeInterpreter.cpp | 2 +-
.../bytecodeInterpreter.inline.hpp | 2 +-
.../share/vm/interpreter/cppInterpreter.hpp | 2 +-
.../interpreter/cppInterpreterGenerator.hpp | 2 +-
.../src/share/vm/interpreter/interpreter.hpp | 2 +-
.../vm/interpreter/interpreterGenerator.hpp | 2 +-
.../vm/interpreter/templateInterpreter.hpp | 2 +-
.../templateInterpreterGenerator.hpp | 2 +-
hotspot/src/share/vm/libadt/dict.cpp | 6 ++--
hotspot/src/share/vm/libadt/dict.hpp | 4 +--
hotspot/src/share/vm/memory/filemap.cpp | 4 +--
hotspot/src/share/vm/memory/permGen.hpp | 2 +-
hotspot/src/share/vm/oops/generateOopMap.cpp | 2 +-
hotspot/src/share/vm/oops/generateOopMap.hpp | 4 +--
hotspot/src/share/vm/oops/instanceKlass.cpp | 2 +-
hotspot/src/share/vm/oops/klass.cpp | 2 +-
hotspot/src/share/vm/oops/klass.hpp | 2 +-
hotspot/src/share/vm/oops/methodOop.hpp | 2 +-
hotspot/src/share/vm/opto/block.cpp | 6 ++--
hotspot/src/share/vm/opto/block.hpp | 2 +-
hotspot/src/share/vm/opto/buildOopMap.cpp | 2 +-
hotspot/src/share/vm/opto/cfgnode.cpp | 12 ++++----
hotspot/src/share/vm/opto/chaitin.cpp | 2 +-
hotspot/src/share/vm/opto/chaitin.hpp | 4 +--
hotspot/src/share/vm/opto/coalesce.cpp | 8 +++---
hotspot/src/share/vm/opto/compile.cpp | 8 +++---
hotspot/src/share/vm/opto/connode.cpp | 2 +-
hotspot/src/share/vm/opto/divnode.cpp | 6 ++--
hotspot/src/share/vm/opto/domgraph.cpp | 2 +-
hotspot/src/share/vm/opto/escape.cpp | 10 +++----
hotspot/src/share/vm/opto/gcm.cpp | 8 +++---
hotspot/src/share/vm/opto/graphKit.cpp | 4 +--
hotspot/src/share/vm/opto/ifg.cpp | 2 +-
hotspot/src/share/vm/opto/ifnode.cpp | 10 +++----
hotspot/src/share/vm/opto/library_call.cpp | 22 +++++++--------
hotspot/src/share/vm/opto/live.cpp | 2 +-
hotspot/src/share/vm/opto/locknode.cpp | 2 +-
hotspot/src/share/vm/opto/loopTransform.cpp | 4 +--
hotspot/src/share/vm/opto/loopUnswitch.cpp | 2 +-
hotspot/src/share/vm/opto/loopnode.cpp | 24 ++++++++--------
hotspot/src/share/vm/opto/loopnode.hpp | 4 +--
hotspot/src/share/vm/opto/loopopts.cpp | 4 +--
hotspot/src/share/vm/opto/machnode.cpp | 2 +-
hotspot/src/share/vm/opto/macro.cpp | 6 ++--
hotspot/src/share/vm/opto/matcher.cpp | 8 +++---
hotspot/src/share/vm/opto/memnode.cpp | 14 +++++-----
hotspot/src/share/vm/opto/memnode.hpp | 4 +--
hotspot/src/share/vm/opto/node.cpp | 27 +++++++++---------
hotspot/src/share/vm/opto/node.hpp | 4 +--
hotspot/src/share/vm/opto/output.cpp | 14 +++++-----
hotspot/src/share/vm/opto/parse.hpp | 2 +-
hotspot/src/share/vm/opto/parse1.cpp | 2 +-
hotspot/src/share/vm/opto/parse2.cpp | 14 +++++-----
hotspot/src/share/vm/opto/phase.cpp | 2 +-
hotspot/src/share/vm/opto/phaseX.cpp | 8 +++---
hotspot/src/share/vm/opto/postaloc.cpp | 4 +--
hotspot/src/share/vm/opto/reg_split.cpp | 10 +++----
hotspot/src/share/vm/opto/runtime.cpp | 2 +-
hotspot/src/share/vm/opto/split_if.cpp | 2 +-
hotspot/src/share/vm/opto/superword.cpp | 4 +--
hotspot/src/share/vm/opto/superword.hpp | 2 +-
hotspot/src/share/vm/opto/type.cpp | 10 +++----
.../share/vm/prims/jvmtiRedefineClasses.cpp | 28 +++++++++----------
hotspot/src/share/vm/runtime/extendedPC.hpp | 2 +-
hotspot/src/share/vm/runtime/fprofiler.cpp | 4 +--
hotspot/src/share/vm/runtime/frame.cpp | 2 +-
hotspot/src/share/vm/runtime/frame.inline.hpp | 2 +-
hotspot/src/share/vm/runtime/mutex.hpp | 2 +-
hotspot/src/share/vm/runtime/orderAccess.hpp | 2 +-
hotspot/src/share/vm/runtime/os.cpp | 2 +-
hotspot/src/share/vm/runtime/safepoint.cpp | 2 +-
hotspot/src/share/vm/runtime/signature.hpp | 2 +-
.../src/share/vm/runtime/threadCritical.hpp | 2 +-
.../share/vm/utilities/globalDefinitions.hpp | 4 +--
120 files changed, 278 insertions(+), 277 deletions(-)
diff --git a/hotspot/src/cpu/sparc/vm/interp_masm_sparc.cpp b/hotspot/src/cpu/sparc/vm/interp_masm_sparc.cpp
index f134852e4d6..d1ac3e5b302 100644
--- a/hotspot/src/cpu/sparc/vm/interp_masm_sparc.cpp
+++ b/hotspot/src/cpu/sparc/vm/interp_masm_sparc.cpp
@@ -2465,7 +2465,7 @@ void InterpreterMacroAssembler::verify_FPU(int stack_depth, TosState state) {
// InterpreterRuntime::post_method_entry();
// }
// if (DTraceMethodProbes) {
-// SharedRuntime::dtrace_method_entry(method, reciever);
+// SharedRuntime::dtrace_method_entry(method, receiver);
// }
void InterpreterMacroAssembler::notify_method_entry() {
diff --git a/hotspot/src/cpu/sparc/vm/nativeInst_sparc.hpp b/hotspot/src/cpu/sparc/vm/nativeInst_sparc.hpp
index 2527e35b3e9..81bdca4cd28 100644
--- a/hotspot/src/cpu/sparc/vm/nativeInst_sparc.hpp
+++ b/hotspot/src/cpu/sparc/vm/nativeInst_sparc.hpp
@@ -243,7 +243,7 @@ class NativeInstruction VALUE_OBJ_CLASS_SPEC {
// Regenerate the instruction sequence that performs the 64 bit
// sethi. This only does the sethi. The disp field (bottom 10 bits)
- // must be handled seperately.
+ // must be handled separately.
static void set_data64_sethi(address instaddr, intptr_t x);
// combine the fields of a sethi/simm13 pair (simm13 = or, add, jmpl, ld/st)
diff --git a/hotspot/src/cpu/sparc/vm/sparc.ad b/hotspot/src/cpu/sparc/vm/sparc.ad
index b4a94ac240a..0095f652caa 100644
--- a/hotspot/src/cpu/sparc/vm/sparc.ad
+++ b/hotspot/src/cpu/sparc/vm/sparc.ad
@@ -189,7 +189,7 @@ reg_def R_F31( SOC, SOC, Op_RegF, 31, F31->as_VMReg());
// double fp register numbers. FloatRegisterImpl in register_sparc.hpp
// wants 0-63, so we have to convert every time we want to use fp regs
// with the macroassembler, using reg_to_DoubleFloatRegister_object().
-// 255 is a flag meaning 'dont go here'.
+// 255 is a flag meaning "don't go here".
// I believe we can't handle callee-save doubles D32 and up until
// the place in the sparc stack crawler that asserts on the 255 is
// fixed up.
@@ -462,7 +462,7 @@ extern bool can_branch_register( Node *bol, Node *cmp );
// Macros to extract hi & lo halves from a long pair.
// G0 is not part of any long pair, so assert on that.
-// Prevents accidently using G1 instead of G0.
+// Prevents accidentally using G1 instead of G0.
#define LONG_HI_REG(x) (x)
#define LONG_LO_REG(x) (x)
@@ -1431,7 +1431,7 @@ uint MachSpillCopyNode::implementation( CodeBuffer *cbuf,
#ifndef _LP64
// In the LP64 build, all registers can be moved as aligned/adjacent
- // pairs, so there's never any need to move the high bits seperately.
+ // pairs, so there's never any need to move the high bits separately.
// The 32-bit builds have to deal with the 32-bit ABI which can force
// all sorts of silly alignment problems.
@@ -1624,7 +1624,7 @@ void MachUEPNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
Register temp_reg = G3;
assert( G5_ic_reg != temp_reg, "conflicting registers" );
- // Load klass from reciever
+ // Load klass from receiver
__ load_klass(O0, temp_reg);
// Compare against expected klass
__ cmp(temp_reg, G5_ic_reg);
@@ -4149,7 +4149,7 @@ operand cmpOp_commute() %{
//----------OPERAND CLASSES----------------------------------------------------
// Operand Classes are groups of operands that are used to simplify
-// instruction definitions by not requiring the AD writer to specify seperate
+// instruction definitions by not requiring the AD writer to specify separate
// instructions for every form of operand when the instruction accepts
// multiple operand types with the same basic encoding and format. The classic
// case of this is memory operands.
@@ -6847,7 +6847,7 @@ instruct mul_hi(iRegIsafe dst, iRegIsafe src1, iRegIsafe src2 ) %{
ins_pipe(sdiv_reg_reg);
%}
-// Magic constant, reciprical of 10
+// Magic constant, reciprocal of 10
instruct loadConI_x66666667(iRegIsafe dst) %{
effect( DEF dst );
@@ -6857,7 +6857,7 @@ instruct loadConI_x66666667(iRegIsafe dst) %{
ins_pipe(ialu_hi_lo_reg);
%}
-// Register Shift Right Arithmatic Long by 32-63
+// Register Shift Right Arithmetic Long by 32-63
instruct sra_31( iRegI dst, iRegI src ) %{
effect( DEF dst, USE src );
format %{ "SRA $src,31,$dst\t! Used in div-by-10" %}
@@ -9048,7 +9048,7 @@ instruct storeL_reversed(memory dst, iRegL src) %{
// These must follow all instruction definitions as they use the names
// defined in the instructions definitions.
//
-// peepmatch ( root_instr_name [preceeding_instruction]* );
+// peepmatch ( root_instr_name [preceding_instruction]* );
//
// peepconstraint %{
// (instruction_number.operand_name relational_op instruction_number.operand_name
diff --git a/hotspot/src/cpu/sparc/vm/templateTable_sparc.cpp b/hotspot/src/cpu/sparc/vm/templateTable_sparc.cpp
index 6ba85859c2b..a4c1fa89258 100644
--- a/hotspot/src/cpu/sparc/vm/templateTable_sparc.cpp
+++ b/hotspot/src/cpu/sparc/vm/templateTable_sparc.cpp
@@ -1545,7 +1545,7 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) {
// Handle all the JSR stuff here, then exit.
// It's much shorter and cleaner than intermingling with the
- // non-JSR normal-branch stuff occuring below.
+ // non-JSR normal-branch stuff occurring below.
if( is_jsr ) {
// compute return address as bci in Otos_i
__ ld_ptr(Address(Lmethod, 0, in_bytes(methodOopDesc::const_offset())), G3_scratch);
@@ -3079,7 +3079,7 @@ void TemplateTable::invokeinterface(int byte_no) {
Label ok;
// Check that entry is non-null. Null entries are probably a bytecode
- // problem. If the interface isn't implemented by the reciever class,
+ // problem. If the interface isn't implemented by the receiver class,
// the VM should throw IncompatibleClassChangeError. linkResolver checks
// this too but that's only if the entry isn't already resolved, so we
// need to check again.
diff --git a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp
index 26acffbb321..5b46c4a88ce 100644
--- a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp
@@ -501,7 +501,7 @@ void LIRGenerator::do_ArithmeticOp_Long(ArithmeticOp* x) {
LIRItem right(x->y(), this);
left.load_item();
- // dont load constants to save register
+ // don't load constants to save register
right.load_nonconstant();
rlock_result(x);
arithmetic_op_long(x->op(), x->operand(), left.result(), right.result(), NULL);
diff --git a/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp b/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp
index a3621ad886c..377d0f2617b 100644
--- a/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp
@@ -523,7 +523,7 @@ void CppInterpreterGenerator::generate_compute_interpreter_state(const Register
#ifdef _LP64
// Make sure stack is properly aligned and sized for the abi
__ subptr(rsp, frame::arg_reg_save_area_bytes); // windows
- __ andptr(rsp, -16); // must be 16 byte boundry (see amd64 ABI)
+ __ andptr(rsp, -16); // must be 16 byte boundary (see amd64 ABI)
#endif // _LP64
@@ -970,7 +970,7 @@ address InterpreterGenerator::generate_native_entry(bool synchronized) {
#ifdef _LP64
// duplicate the alignment rsp got after setting stack_base
__ subptr(rax, frame::arg_reg_save_area_bytes); // windows
- __ andptr(rax, -16); // must be 16 byte boundry (see amd64 ABI)
+ __ andptr(rax, -16); // must be 16 byte boundary (see amd64 ABI)
#endif // _LP64
__ cmpptr(rax, rsp);
__ jcc(Assembler::equal, L);
@@ -1067,7 +1067,7 @@ address InterpreterGenerator::generate_native_entry(bool synchronized) {
#ifdef _LP64
__ subptr(rsp, t);
__ subptr(rsp, frame::arg_reg_save_area_bytes); // windows
- __ andptr(rsp, -16); // must be 16 byte boundry (see amd64 ABI)
+ __ andptr(rsp, -16); // must be 16 byte boundary (see amd64 ABI)
#else
__ addptr(t, 2*wordSize); // allocate two more slots for JNIEnv and possible mirror
__ subptr(rsp, t);
diff --git a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp
index 7fc2b6685e4..2fbcb7010fa 100644
--- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp
+++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp
@@ -1350,7 +1350,7 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,
{
Label L;
__ mov(rax, rsp);
- __ andptr(rax, -16); // must be 16 byte boundry (see amd64 ABI)
+ __ andptr(rax, -16); // must be 16 byte boundary (see amd64 ABI)
__ cmpptr(rax, rsp);
__ jcc(Assembler::equal, L);
__ stop("improperly aligned stack");
diff --git a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp
index 9caf33f6b09..b237b7b5fff 100644
--- a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp
+++ b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp
@@ -826,7 +826,7 @@ address InterpreterGenerator::generate_native_entry(bool synchronized) {
__ subptr(rsp, t);
__ subptr(rsp, frame::arg_reg_save_area_bytes); // windows
- __ andptr(rsp, -16); // must be 16 byte boundry (see amd64 ABI)
+ __ andptr(rsp, -16); // must be 16 byte boundary (see amd64 ABI)
// get signature handler
{
diff --git a/hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp b/hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp
index 13242651c7e..6acbc8e2836 100644
--- a/hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp
+++ b/hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp
@@ -1586,7 +1586,7 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) {
// Handle all the JSR stuff here, then exit.
// It's much shorter and cleaner than intermingling with the
- // non-JSR normal-branch stuff occuring below.
+ // non-JSR normal-branch stuff occurring below.
if (is_jsr) {
// Pre-load the next target bytecode into EBX
__ load_unsigned_byte(rbx, Address(rsi, rdx, Address::times_1, 0));
diff --git a/hotspot/src/cpu/x86/vm/templateTable_x86_64.cpp b/hotspot/src/cpu/x86/vm/templateTable_x86_64.cpp
index e4b4cb96980..50c23fd458c 100644
--- a/hotspot/src/cpu/x86/vm/templateTable_x86_64.cpp
+++ b/hotspot/src/cpu/x86/vm/templateTable_x86_64.cpp
@@ -1559,7 +1559,7 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) {
// Handle all the JSR stuff here, then exit.
// It's much shorter and cleaner than intermingling with the non-JSR
- // normal-branch stuff occuring below.
+ // normal-branch stuff occurring below.
if (is_jsr) {
// Pre-load the next target bytecode into rbx
__ load_unsigned_byte(rbx, Address(r13, rdx, Address::times_1, 0));
diff --git a/hotspot/src/cpu/x86/vm/x86_32.ad b/hotspot/src/cpu/x86/vm/x86_32.ad
index edc6a63e79f..43daf35fc22 100644
--- a/hotspot/src/cpu/x86/vm/x86_32.ad
+++ b/hotspot/src/cpu/x86/vm/x86_32.ad
@@ -130,7 +130,7 @@ reg_def XMM7b( SOC, SOC, Op_RegF, 7, xmm7->as_VMReg()->next());
// allocation. Highest priority is first. A useful heuristic is to
// give registers a low priority when they are required by machine
// instructions, like EAX and EDX. Registers which are used as
-// pairs must fall on an even boundry (witness the FPR#L's in this list).
+// pairs must fall on an even boundary (witness the FPR#L's in this list).
// For the Intel integer registers, the equivalent Long pairs are
// EDX:EAX, EBX:ECX, and EDI:EBP.
alloc_class chunk0( ECX, EBX, EBP, EDI, EAX, EDX, ESI, ESP,
@@ -5857,7 +5857,7 @@ operand cmpOp_commute() %{
//----------OPERAND CLASSES----------------------------------------------------
// Operand Classes are groups of operands that are used as to simplify
-// instruction definitions by not requiring the AD writer to specify seperate
+// instruction definitions by not requiring the AD writer to specify separate
// instructions for every form of operand when the instruction accepts
// multiple operand types with the same basic encoding and format. The classic
// case of this is memory operands.
@@ -13220,7 +13220,7 @@ instruct safePoint_poll(eFlagsReg cr) %{
// These must follow all instruction definitions as they use the names
// defined in the instructions definitions.
//
-// peepmatch ( root_instr_name [preceeding_instruction]* );
+// peepmatch ( root_instr_name [preceding_instruction]* );
//
// peepconstraint %{
// (instruction_number.operand_name relational_op instruction_number.operand_name
diff --git a/hotspot/src/cpu/x86/vm/x86_64.ad b/hotspot/src/cpu/x86/vm/x86_64.ad
index ad4f03b23a3..09157f3a34b 100644
--- a/hotspot/src/cpu/x86/vm/x86_64.ad
+++ b/hotspot/src/cpu/x86/vm/x86_64.ad
@@ -5483,7 +5483,7 @@ operand cmpOpUCF2() %{
//----------OPERAND CLASSES----------------------------------------------------
// Operand Classes are groups of operands that are used as to simplify
-// instruction definitions by not requiring the AD writer to specify seperate
+// instruction definitions by not requiring the AD writer to specify separate
// instructions for every form of operand when the instruction accepts
// multiple operand types with the same basic encoding and format. The classic
// case of this is memory operands.
@@ -8363,7 +8363,7 @@ instruct divModL_rReg_divmod(rax_RegL rax, rdx_RegL rdx, no_rax_rdx_RegL div,
//----------- DivL-By-Constant-Expansions--------------------------------------
// DivI cases are handled by the compiler
-// Magic constant, reciprical of 10
+// Magic constant, reciprocal of 10
instruct loadConL_0x6666666666666667(rRegL dst)
%{
effect(DEF dst);
@@ -12082,7 +12082,7 @@ instruct RethrowException()
// These must follow all instruction definitions as they use the names
// defined in the instructions definitions.
//
-// peepmatch ( root_instr_name [precerding_instruction]* );
+// peepmatch ( root_instr_name [preceding_instruction]* );
//
// peepconstraint %{
// (instruction_number.operand_name relational_op instruction_number.operand_name
diff --git a/hotspot/src/os/linux/launcher/java.c b/hotspot/src/os/linux/launcher/java.c
index a13782ec437..e335776325d 100644
--- a/hotspot/src/os/linux/launcher/java.c
+++ b/hotspot/src/os/linux/launcher/java.c
@@ -419,7 +419,7 @@ main(int argc, char ** argv)
goto leave;
}
mainClass = LoadClass(env, classname);
- if(mainClass == NULL) { /* exception occured */
+ if(mainClass == NULL) { /* exception occurred */
ReportExceptionDescription(env);
message = "Could not find the main class. Program will exit.";
goto leave;
@@ -441,7 +441,7 @@ main(int argc, char ** argv)
goto leave;
}
mainClass = LoadClass(env, classname);
- if(mainClass == NULL) { /* exception occured */
+ if(mainClass == NULL) { /* exception occurred */
ReportExceptionDescription(env);
message = "Could not find the main class. Program will exit.";
goto leave;
diff --git a/hotspot/src/os/linux/launcher/java_md.h b/hotspot/src/os/linux/launcher/java_md.h
index 89e4d0b7ac8..6016621754a 100644
--- a/hotspot/src/os/linux/launcher/java_md.h
+++ b/hotspot/src/os/linux/launcher/java_md.h
@@ -47,7 +47,7 @@
#ifdef JAVA_ARGS
/*
* ApplicationHome is prepended to each of these entries; the resulting
- * strings are concatenated (seperated by PATH_SEPARATOR) and used as the
+ * strings are concatenated (separated by PATH_SEPARATOR) and used as the
* value of -cp option to the launcher.
*/
#ifndef APP_CLASSPATH
diff --git a/hotspot/src/os/linux/vm/perfMemory_linux.cpp b/hotspot/src/os/linux/vm/perfMemory_linux.cpp
index c56798c0187..38165056267 100644
--- a/hotspot/src/os/linux/vm/perfMemory_linux.cpp
+++ b/hotspot/src/os/linux/vm/perfMemory_linux.cpp
@@ -192,7 +192,7 @@ static pid_t filename_to_pid(const char* filename) {
// check if the given path is considered a secure directory for
// the backing store files. Returns true if the directory exists
// and is considered a secure location. Returns false if the path
-// is a symbolic link or if an error occured.
+// is a symbolic link or if an error occurred.
//
static bool is_directory_secure(const char* path) {
struct stat statbuf;
diff --git a/hotspot/src/os/solaris/launcher/java.c b/hotspot/src/os/solaris/launcher/java.c
index e4fc014de6d..866be7c65b7 100644
--- a/hotspot/src/os/solaris/launcher/java.c
+++ b/hotspot/src/os/solaris/launcher/java.c
@@ -419,7 +419,7 @@ main(int argc, char ** argv)
goto leave;
}
mainClass = LoadClass(env, classname);
- if(mainClass == NULL) { /* exception occured */
+ if(mainClass == NULL) { /* exception occurred */
ReportExceptionDescription(env);
message = "Could not find the main class. Program will exit.";
goto leave;
@@ -441,7 +441,7 @@ main(int argc, char ** argv)
goto leave;
}
mainClass = LoadClass(env, classname);
- if(mainClass == NULL) { /* exception occured */
+ if(mainClass == NULL) { /* exception occurred */
ReportExceptionDescription(env);
message = "Could not find the main class. Program will exit.";
goto leave;
diff --git a/hotspot/src/os/solaris/launcher/java_md.h b/hotspot/src/os/solaris/launcher/java_md.h
index c65b42e2a3f..5122de9fc25 100644
--- a/hotspot/src/os/solaris/launcher/java_md.h
+++ b/hotspot/src/os/solaris/launcher/java_md.h
@@ -47,7 +47,7 @@
#ifdef JAVA_ARGS
/*
* ApplicationHome is prepended to each of these entries; the resulting
- * strings are concatenated (seperated by PATH_SEPARATOR) and used as the
+ * strings are concatenated (separated by PATH_SEPARATOR) and used as the
* value of -cp option to the launcher.
*/
#ifndef APP_CLASSPATH
diff --git a/hotspot/src/os/solaris/vm/perfMemory_solaris.cpp b/hotspot/src/os/solaris/vm/perfMemory_solaris.cpp
index 4626d7299b4..459ef573a90 100644
--- a/hotspot/src/os/solaris/vm/perfMemory_solaris.cpp
+++ b/hotspot/src/os/solaris/vm/perfMemory_solaris.cpp
@@ -194,7 +194,7 @@ static pid_t filename_to_pid(const char* filename) {
// check if the given path is considered a secure directory for
// the backing store files. Returns true if the directory exists
// and is considered a secure location. Returns false if the path
-// is a symbolic link or if an error occured.
+// is a symbolic link or if an error occurred.
//
static bool is_directory_secure(const char* path) {
struct stat statbuf;
diff --git a/hotspot/src/os/windows/vm/perfMemory_windows.cpp b/hotspot/src/os/windows/vm/perfMemory_windows.cpp
index 42a45ee6527..95063df2eb0 100644
--- a/hotspot/src/os/windows/vm/perfMemory_windows.cpp
+++ b/hotspot/src/os/windows/vm/perfMemory_windows.cpp
@@ -195,7 +195,7 @@ static int filename_to_pid(const char* filename) {
// check if the given path is considered a secure directory for
// the backing store files. Returns true if the directory exists
// and is considered a secure location. Returns false if the path
-// is a symbolic link or if an error occured.
+// is a symbolic link or if an error occurred.
//
static bool is_directory_secure(const char* path) {
@@ -994,7 +994,7 @@ static bool add_allow_aces(PSECURITY_DESCRIPTOR pSD,
return false;
}
- // if running on windows 2000 or later, set the automatic inheritence
+ // if running on windows 2000 or later, set the automatic inheritance
// control flags.
SetSecurityDescriptorControlFnPtr _SetSecurityDescriptorControl;
_SetSecurityDescriptorControl = (SetSecurityDescriptorControlFnPtr)
@@ -1002,7 +1002,7 @@ static bool add_allow_aces(PSECURITY_DESCRIPTOR pSD,
"SetSecurityDescriptorControl");
if (_SetSecurityDescriptorControl != NULL) {
- // We do not want to further propogate inherited DACLs, so making them
+ // We do not want to further propagate inherited DACLs, so making them
// protected prevents that.
if (!_SetSecurityDescriptorControl(pSD, SE_DACL_PROTECTED,
SE_DACL_PROTECTED)) {
diff --git a/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp b/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp
index 012c170a980..802934511af 100644
--- a/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp
+++ b/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp
@@ -532,7 +532,7 @@ int JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid, int abort_
if (oldAct.sa_sigaction != signalHandler) {
void* sighand = oldAct.sa_sigaction ? CAST_FROM_FN_PTR(void*, oldAct.sa_sigaction)
: CAST_FROM_FN_PTR(void*, oldAct.sa_handler);
- warning("Unexpected Signal %d occured under user-defined signal handler " INTPTR_FORMAT, sig, (intptr_t)sighand);
+ warning("Unexpected Signal %d occurred under user-defined signal handler " INTPTR_FORMAT, sig, (intptr_t)sighand);
}
}
diff --git a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp
index 71f99cba0da..e6b1edca5a4 100644
--- a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp
+++ b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp
@@ -694,7 +694,7 @@ int JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid, int abort_
if (oldAct.sa_sigaction != signalHandler) {
void* sighand = oldAct.sa_sigaction ? CAST_FROM_FN_PTR(void*, oldAct.sa_sigaction)
: CAST_FROM_FN_PTR(void*, oldAct.sa_handler);
- warning("Unexpected Signal %d occured under user-defined signal handler %#lx", sig, (long)sighand);
+ warning("Unexpected Signal %d occurred under user-defined signal handler %#lx", sig, (long)sighand);
}
}
diff --git a/hotspot/src/share/tools/MakeDeps/Database.java b/hotspot/src/share/tools/MakeDeps/Database.java
index 5cec93b7d03..3cdffebca49 100644
--- a/hotspot/src/share/tools/MakeDeps/Database.java
+++ b/hotspot/src/share/tools/MakeDeps/Database.java
@@ -365,7 +365,7 @@ public class Database {
// HACK ALERT. The compilation of ad_ files is very slow.
// We want to start compiling them as early as possible. The compilation
- // order on unix is dependant on the order we emit files here.
+ // order on unix is dependent on the order we emit files here.
// By sorting the output before emitting it, we expect
// that ad_ will be compiled early.
boolean shouldSortObjFiles = true;
diff --git a/hotspot/src/share/vm/adlc/Doc/Syntax.doc b/hotspot/src/share/vm/adlc/Doc/Syntax.doc
index ade893410c3..c2a24afc3a8 100644
--- a/hotspot/src/share/vm/adlc/Doc/Syntax.doc
+++ b/hotspot/src/share/vm/adlc/Doc/Syntax.doc
@@ -88,7 +88,7 @@ reg_class X_REG(AX, BX); // form a matcher register class of X_REG
// these are used for constraints, etc.
alloc_class class1(AX, BX); // form an allocation class of registers
- // used by the register allocator for seperate
+ // used by the register allocator for separate
// allocation of target register classes
3. Pipeline Syntax for Scheduling
@@ -150,7 +150,7 @@ D. Delimiters
b. %} (block terminator)
c. EOF (file terminator)
- 4. Each statement must start on a seperate line
+ 4. Each statement must start on a separate line
5. Identifiers cannot contain: (){}%;,"/\
diff --git a/hotspot/src/share/vm/adlc/adlparse.cpp b/hotspot/src/share/vm/adlc/adlparse.cpp
index f212d3f5756..61ba5e2483c 100644
--- a/hotspot/src/share/vm/adlc/adlparse.cpp
+++ b/hotspot/src/share/vm/adlc/adlparse.cpp
@@ -4555,7 +4555,7 @@ void ADLParser::parse_err(int flag, const char *fmt, ...) {
//---------------------------ensure_start_of_line------------------------------
// A preprocessor directive has been encountered. Be sure it has fallen at
-// the begining of a line, or else report an error.
+// the beginning of a line, or else report an error.
void ADLParser::ensure_start_of_line(void) {
if (_curchar == '\n') { next_line(); return; }
assert( _ptr >= _curline && _ptr < _curline+strlen(_curline),
diff --git a/hotspot/src/share/vm/adlc/dict2.cpp b/hotspot/src/share/vm/adlc/dict2.cpp
index f46693fd06c..d1816423dc6 100644
--- a/hotspot/src/share/vm/adlc/dict2.cpp
+++ b/hotspot/src/share/vm/adlc/dict2.cpp
@@ -275,7 +275,7 @@ void Dict::print(PrintKeyOrValue print_key, PrintKeyOrValue print_value) {
// Convert string to hash key. This algorithm implements a universal hash
// function with the multipliers frozen (ok, so it's not universal). The
// multipliers (and allowable characters) are all odd, so the resultant sum
-// is odd - guarenteed not divisible by any power of two, so the hash tables
+// is odd - guaranteed not divisible by any power of two, so the hash tables
// can be any power of two with good results. Also, I choose multipliers
// that have only 2 bits set (the low is always set to be odd) so
// multiplication requires only shifts and adds. Characters are required to
@@ -296,7 +296,7 @@ int hashstr(const void *t) {
}
//------------------------------hashptr--------------------------------------
-// Slimey cheap hash function; no guarenteed performance. Better than the
+// Slimey cheap hash function; no guaranteed performance. Better than the
// default for pointers, especially on MS-DOS machines.
int hashptr(const void *key) {
#ifdef __TURBOC__
@@ -306,7 +306,7 @@ int hashptr(const void *key) {
#endif
}
-// Slimey cheap hash function; no guarenteed performance.
+// Slimey cheap hash function; no guaranteed performance.
int hashkey(const void *key) {
return (int)((intptr_t)key);
}
diff --git a/hotspot/src/share/vm/adlc/dict2.hpp b/hotspot/src/share/vm/adlc/dict2.hpp
index 41a1b19d167..14c75e5df49 100644
--- a/hotspot/src/share/vm/adlc/dict2.hpp
+++ b/hotspot/src/share/vm/adlc/dict2.hpp
@@ -89,10 +89,10 @@ class Dict { // Dictionary structure
// Hashing functions
int hashstr(const void *s); // Nice string hash
-// Slimey cheap hash function; no guarenteed performance. Better than the
+// Slimey cheap hash function; no guaranteed performance. Better than the
// default for pointers, especially on MS-DOS machines.
int hashptr(const void *key);
-// Slimey cheap hash function; no guarenteed performance.
+// Slimey cheap hash function; no guaranteed performance.
int hashkey(const void *key);
// Key comparators
diff --git a/hotspot/src/share/vm/adlc/filebuff.cpp b/hotspot/src/share/vm/adlc/filebuff.cpp
index 36e611e15b6..d5dfd218651 100644
--- a/hotspot/src/share/vm/adlc/filebuff.cpp
+++ b/hotspot/src/share/vm/adlc/filebuff.cpp
@@ -50,10 +50,10 @@ FileBuff::FileBuff( BufferedFile *fptr, ArchDesc& archDesc) : _fp(fptr), _AD(arc
file_error(SEMERR, 0, "Buffer allocation failed\n");
exit(1); // Exit on allocation failure
}
- *_bigbuf = '\n'; // Lead with a sentinal newline
- _buf = _bigbuf+1; // Skip sentinal
+ *_bigbuf = '\n'; // Lead with a sentinel newline
+ _buf = _bigbuf+1; // Skip sentinel
_bufmax = _buf; // Buffer is empty
- _bufeol = _bigbuf; // _bufeol points at sentinal
+ _bufeol = _bigbuf; // _bufeol points at sentinel
_filepos = -1; // filepos is in sync with _bufeol
_bufoff = _offset = 0L; // Offset at file start
@@ -62,8 +62,8 @@ FileBuff::FileBuff( BufferedFile *fptr, ArchDesc& archDesc) : _fp(fptr), _AD(arc
file_error(SEMERR, 0, "File read error, no input read\n");
exit(1); // Exit on read error
}
- *_bufmax = '\n'; // End with a sentinal new-line
- *(_bufmax+1) = '\0'; // Then end with a sentinal NULL
+ *_bufmax = '\n'; // End with a sentinel new-line
+ *(_bufmax+1) = '\0'; // Then end with a sentinel NULL
}
//------------------------------~FileBuff--------------------------------------
@@ -81,7 +81,7 @@ char *FileBuff::get_line(void) {
_linenum++;
retval = ++_bufeol; // return character following end of previous line
- if (*retval == '\0') return NULL; // Check for EOF sentinal
+ if (*retval == '\0') return NULL; // Check for EOF sentinel
// Search for newline character which must end each line
for(_filepos++; *_bufeol != '\n'; _bufeol++)
_filepos++; // keep filepos in sync with _bufeol
diff --git a/hotspot/src/share/vm/adlc/filebuff.hpp b/hotspot/src/share/vm/adlc/filebuff.hpp
index e5e8cccbea0..6967d64a39c 100644
--- a/hotspot/src/share/vm/adlc/filebuff.hpp
+++ b/hotspot/src/share/vm/adlc/filebuff.hpp
@@ -37,7 +37,7 @@ class ArchDesc;
//------------------------------FileBuff--------------------------------------
// This class defines a nicely behaved buffer of text. Entire file of text
-// is read into buffer at creation, with sentinals at start and end.
+// is read into buffer at creation, with sentinels at start and end.
class FileBuff {
friend class FileBuffRegion;
private:
@@ -46,8 +46,8 @@ class FileBuff {
long _bufoff; // Start of buffer file offset
char *_buf; // The buffer itself.
- char *_bigbuf; // The buffer plus sentinals; actual heap area
- char *_bufmax; // A pointer to the buffer end sentinal
+ char *_bigbuf; // The buffer plus sentinels; actual heap area
+ char *_bufmax; // A pointer to the buffer end sentinel
char *_bufeol; // A pointer to the last complete line end
int _err; // Error flag for file seek/read operations
diff --git a/hotspot/src/share/vm/adlc/formssel.cpp b/hotspot/src/share/vm/adlc/formssel.cpp
index cf48d265084..d203e2d7f6d 100644
--- a/hotspot/src/share/vm/adlc/formssel.cpp
+++ b/hotspot/src/share/vm/adlc/formssel.cpp
@@ -1281,7 +1281,7 @@ void InstructForm::set_unique_opnds() {
_num_uniq = num_uniq;
}
-// Generate index values needed for determing the operand position
+// Generate index values needed for determining the operand position
void InstructForm::index_temps(FILE *fp, FormDict &globals, const char *prefix, const char *receiver) {
uint idx = 0; // position of operand in match rule
int cur_num_opnds = num_opnds();
@@ -2197,7 +2197,7 @@ int OperandForm::operand_position(const char *name, int usedef) {
// Return zero-based position in component list, only counting constants;
// Return -1 if not in list.
int OperandForm::constant_position(FormDict &globals, const Component *last) {
- // Iterate through components and count constants preceeding 'constant'
+ // Iterate through components and count constants preceding 'constant'
int position = 0;
Component *comp;
_components.reset();
@@ -2235,7 +2235,7 @@ int OperandForm::constant_position(FormDict &globals, const char *name) {
// Return zero-based position in component list, only counting constants;
// Return -1 if not in list.
int OperandForm::register_position(FormDict &globals, const char *reg_name) {
- // Iterate through components and count registers preceeding 'last'
+ // Iterate through components and count registers preceding 'last'
uint position = 0;
Component *comp;
_components.reset();
diff --git a/hotspot/src/share/vm/adlc/formssel.hpp b/hotspot/src/share/vm/adlc/formssel.hpp
index 84c49be69eb..2a7bfbb7934 100644
--- a/hotspot/src/share/vm/adlc/formssel.hpp
+++ b/hotspot/src/share/vm/adlc/formssel.hpp
@@ -277,7 +277,7 @@ public:
//
// Generate the format call for the replacement variable
void rep_var_format(FILE *fp, const char *rep_var);
- // Generate index values needed for determing the operand position
+ // Generate index values needed for determining the operand position
void index_temps (FILE *fp, FormDict &globals, const char *prefix = "", const char *receiver = "");
// ---------------------------
@@ -344,7 +344,7 @@ public:
// --------------------------- Code Block
// Add code
- void add_code(const char *string_preceeding_replacement_var);
+ void add_code(const char *string_preceding_replacement_var);
// Add a replacement variable or one of its subfields
// Subfields are stored with a leading '$'
void add_rep_var(char *replacement_var);
diff --git a/hotspot/src/share/vm/adlc/output_h.cpp b/hotspot/src/share/vm/adlc/output_h.cpp
index 764dcd03dc4..4668d68f9fa 100644
--- a/hotspot/src/share/vm/adlc/output_h.cpp
+++ b/hotspot/src/share/vm/adlc/output_h.cpp
@@ -574,7 +574,7 @@ void gen_inst_format(FILE *fp, FormDict &globals, InstructForm &inst, bool for_c
// Generate the user-defined portion of the format
if( inst._format ) {
// If there are replacement variables,
- // Generate index values needed for determing the operand position
+ // Generate index values needed for determining the operand position
if( inst._format->_rep_vars.count() )
inst.index_temps(fp, globals);
diff --git a/hotspot/src/share/vm/asm/assembler.cpp b/hotspot/src/share/vm/asm/assembler.cpp
index e9d99621b6b..0afc3960422 100644
--- a/hotspot/src/share/vm/asm/assembler.cpp
+++ b/hotspot/src/share/vm/asm/assembler.cpp
@@ -31,7 +31,7 @@
// The AbstractAssembler is generating code into a CodeBuffer. To make code generation faster,
// the assembler keeps a copy of the code buffers boundaries & modifies them when
// emitting bytes rather than using the code buffers accessor functions all the time.
-// The code buffer is updated via set_code_end(...) after emiting a whole instruction.
+// The code buffer is updated via set_code_end(...) after emitting a whole instruction.
AbstractAssembler::AbstractAssembler(CodeBuffer* code) {
if (code == NULL) return;
diff --git a/hotspot/src/share/vm/asm/assembler.hpp b/hotspot/src/share/vm/asm/assembler.hpp
index 7af6e5dffa1..b8a29ceadca 100644
--- a/hotspot/src/share/vm/asm/assembler.hpp
+++ b/hotspot/src/share/vm/asm/assembler.hpp
@@ -22,7 +22,7 @@
*
*/
-// This file contains platform-independant assembler declarations.
+// This file contains platform-independent assembler declarations.
class CodeBuffer;
class MacroAssembler;
diff --git a/hotspot/src/share/vm/ci/ciTypeFlow.cpp b/hotspot/src/share/vm/ci/ciTypeFlow.cpp
index 08396235067..51f49132b61 100644
--- a/hotspot/src/share/vm/ci/ciTypeFlow.cpp
+++ b/hotspot/src/share/vm/ci/ciTypeFlow.cpp
@@ -541,7 +541,7 @@ void ciTypeFlow::StateVector::do_aaload(ciBytecodeStream* str) {
// is report a value that will meet correctly with any downstream
// reference types on paths that will truly be executed. This null type
// meets with any reference type to yield that same reference type.
- // (The compiler will generate an unconditonal exception here.)
+ // (The compiler will generate an unconditional exception here.)
push(null_type());
return;
}
diff --git a/hotspot/src/share/vm/classfile/symbolTable.cpp b/hotspot/src/share/vm/classfile/symbolTable.cpp
index 0c2d6bbb3e9..b77db6bd952 100644
--- a/hotspot/src/share/vm/classfile/symbolTable.cpp
+++ b/hotspot/src/share/vm/classfile/symbolTable.cpp
@@ -156,7 +156,7 @@ symbolOop SymbolTable::basic_add(int index, u1 *name, int len,
symbolOop test = lookup(index, (char*)name, len, hashValue);
if (test != NULL) {
- // A race occured and another thread introduced the symbol, this one
+ // A race occurred and another thread introduced the symbol, this one
// will be dropped and collected.
return test;
}
@@ -193,7 +193,7 @@ bool SymbolTable::basic_add(constantPoolHandle cp, int names_count,
int index = hash_to_index(hashValues[i]);
symbolOop test = lookup(index, names[i], lengths[i], hashValues[i]);
if (test != NULL) {
- // A race occured and another thread introduced the symbol, this one
+ // A race occurred and another thread introduced the symbol, this one
// will be dropped and collected. Use test instead.
cp->symbol_at_put(cp_indices[i], test);
} else {
diff --git a/hotspot/src/share/vm/code/nmethod.cpp b/hotspot/src/share/vm/code/nmethod.cpp
index 6baa28690db..ff5985f1e2a 100644
--- a/hotspot/src/share/vm/code/nmethod.cpp
+++ b/hotspot/src/share/vm/code/nmethod.cpp
@@ -380,7 +380,7 @@ address nmethod::handler_for_exception_and_pc(Handle exception, address pc) {
void nmethod::add_handler_for_exception_and_pc(Handle exception, address pc, address handler) {
// There are potential race conditions during exception cache updates, so we
// must own the ExceptionCache_lock before doing ANY modifications. Because
- // we dont lock during reads, it is possible to have several threads attempt
+ // we don't lock during reads, it is possible to have several threads attempt
// to update the cache with the same data. We need to check for already inserted
// copies of the current data before adding it.
diff --git a/hotspot/src/share/vm/code/nmethod.hpp b/hotspot/src/share/vm/code/nmethod.hpp
index d2c4af89501..8305f7949d0 100644
--- a/hotspot/src/share/vm/code/nmethod.hpp
+++ b/hotspot/src/share/vm/code/nmethod.hpp
@@ -167,7 +167,7 @@ class nmethod : public CodeBlob {
nmFlags flags; // various flags to keep track of nmethod state
bool _markedForDeoptimization; // Used for stack deoptimization
enum { alive = 0,
- not_entrant = 1, // uncommon trap has happend but activations may still exist
+ not_entrant = 1, // uncommon trap has happened but activations may still exist
zombie = 2,
unloaded = 3 };
diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp
index 3a07470e395..b21dab7ff7a 100644
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp
@@ -393,7 +393,7 @@ class CMSAdaptiveSizePolicy : public AdaptiveSizePolicy {
// Restarts the concurrent phases timer.
void concurrent_phases_resume();
- // Time begining and end of the marking phase for
+ // Time beginning and end of the marking phase for
// a synchronous MS collection. A MS collection
// that finishes in the foreground can have started
// in the background. These methods capture the
diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsGCAdaptivePolicyCounters.hpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsGCAdaptivePolicyCounters.hpp
index 33321824520..f9054002078 100644
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsGCAdaptivePolicyCounters.hpp
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsGCAdaptivePolicyCounters.hpp
@@ -69,7 +69,7 @@ class CMSGCAdaptivePolicyCounters : public GCAdaptivePolicyCounters {
// end of the sweep of the tenured generation.
PerfVariable* _avg_cms_free_counter;
// Average of the free space in the tenured generation at the
- // start of the sweep of the tenured genertion.
+ // start of the sweep of the tenured generation.
PerfVariable* _avg_cms_free_at_sweep_counter;
// Average of the free space in the tenured generation at the
// after any resizing of the tenured generation at the end
diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp
index d716797bab4..11480430f4a 100644
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp
@@ -4178,7 +4178,7 @@ bool CMSCollector::do_marking_mt(bool asynch) {
// and is deferred for now; see CR# TBF. 07252005YSR. XXX
assert(!CMSAbortSemantics || tsk.aborted(), "Inconsistency");
// If _restart_addr is non-NULL, a marking stack overflow
- // occured; we need to do a fresh marking iteration from the
+ // occurred; we need to do a fresh marking iteration from the
// indicated restart address.
if (_foregroundGCIsActive && asynch) {
// We may be running into repeated stack overflows, having
@@ -4221,7 +4221,7 @@ bool CMSCollector::do_marking_st(bool asynch) {
// should be incremental with periodic yields.
_markBitMap.iterate(&markFromRootsClosure);
// If _restart_addr is non-NULL, a marking stack overflow
- // occured; we need to do a fresh iteration from the
+ // occurred; we need to do a fresh iteration from the
// indicated restart address.
while (_restart_addr != NULL) {
if (_foregroundGCIsActive && asynch) {
diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
index 1c6766b9947..38e49da9360 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
@@ -2513,7 +2513,7 @@ G1CollectedHeap::do_collection_pause_at_safepoint(HeapRegion* popular_region) {
}
save_marks();
- // We must do this before any possible evacuation that should propogate
+ // We must do this before any possible evacuation that should propagate
// marks, including evacuation of popular objects in a popular pause.
if (mark_in_progress()) {
double start_time_sec = os::elapsedTime();
diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/cardTableExtension.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/cardTableExtension.cpp
index cd260de6c82..8bf1a3e69f2 100644
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/cardTableExtension.cpp
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/cardTableExtension.cpp
@@ -78,7 +78,7 @@ class CheckForUnmarkedObjects : public ObjectClosure {
}
// Card marks are not precise. The current system can leave us with
- // a mismash of precise marks and begining of object marks. This means
+ // a mismash of precise marks and beginning of object marks. This means
// we test for missing precise marks first. If any are found, we don't
// fail unless the object head is also unmarked.
virtual void do_object(oop obj) {
@@ -258,7 +258,7 @@ void CardTableExtension::scavenge_contents_parallel(ObjectStartArray* start_arra
if (!start_array->object_starts_in_range(slice_start, slice_end)) {
continue;
}
- // Update our begining addr
+ // Update our beginning addr
HeapWord* first_object = start_array->object_start(slice_start);
debug_only(oop* first_object_within_slice = (oop*) first_object;)
if (first_object < slice_start) {
diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/objectStartArray.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/objectStartArray.hpp
index d587d0ae291..f44bcbbb083 100644
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/objectStartArray.hpp
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/objectStartArray.hpp
@@ -127,7 +127,7 @@ class ObjectStartArray : public CHeapObj {
// Optimized for finding the first object that crosses into
// a given block. The blocks contain the offset of the last
// object in that block. Scroll backwards by one, and the first
- // object hit should be at the begining of the block
+ // object hit should be at the beginning of the block
HeapWord* object_start(HeapWord* addr) const {
assert(_covered_region.contains(addr), "Must be in covered region");
jbyte* block = block_for_addr(addr);
diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/prefetchQueue.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/prefetchQueue.hpp
index 5266d67319b..7c6f86d3ff8 100644
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/prefetchQueue.hpp
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/prefetchQueue.hpp
@@ -26,7 +26,7 @@
// PrefetchQueue is a FIFO queue of variable length (currently 8).
//
// We need to examine the performance penalty of variable lengths.
-// We may also want to split this into cpu dependant bits.
+// We may also want to split this into cpu dependent bits.
//
const int PREFETCH_QUEUE_SIZE = 8;
diff --git a/hotspot/src/share/vm/gc_implementation/shared/mutableNUMASpace.cpp b/hotspot/src/share/vm/gc_implementation/shared/mutableNUMASpace.cpp
index a3787c8cd29..e710fd77918 100644
--- a/hotspot/src/share/vm/gc_implementation/shared/mutableNUMASpace.cpp
+++ b/hotspot/src/share/vm/gc_implementation/shared/mutableNUMASpace.cpp
@@ -74,7 +74,7 @@ void MutableNUMASpace::ensure_parsability() {
for (int i = 0; i < lgrp_spaces()->length(); i++) {
LGRPSpace *ls = lgrp_spaces()->at(i);
MutableSpace *s = ls->space();
- if (s->top() < top()) { // For all spaces preceeding the one containing top()
+ if (s->top() < top()) { // For all spaces preceding the one containing top()
if (s->free_in_words() > 0) {
size_t area_touched_words = pointer_delta(s->end(), s->top());
CollectedHeap::fill_with_object(s->top(), area_touched_words);
diff --git a/hotspot/src/share/vm/interpreter/abstractInterpreter.hpp b/hotspot/src/share/vm/interpreter/abstractInterpreter.hpp
index 76fbb53b83c..581ddfb160b 100644
--- a/hotspot/src/share/vm/interpreter/abstractInterpreter.hpp
+++ b/hotspot/src/share/vm/interpreter/abstractInterpreter.hpp
@@ -22,7 +22,7 @@
*
*/
-// This file contains the platform-independant parts
+// This file contains the platform-independent parts
// of the abstract interpreter and the abstract interpreter generator.
// Organization of the interpreter(s). There exists two different interpreters in hotpot
diff --git a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp
index 351d29cc9cc..c9343622b65 100644
--- a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp
+++ b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp
@@ -2642,7 +2642,7 @@ handle_return:
// two interpreted frames). We need to save the current arguments in C heap so that
// the deoptimized frame when it restarts can copy the arguments to its expression
// stack and re-execute the call. We also have to notify deoptimization that this
- // has occured and to pick the preerved args copy them to the deoptimized frame's
+ // has occurred and to pick the preserved args copy them to the deoptimized frame's
// java expression stack. Yuck.
//
THREAD->popframe_preserve_args(in_ByteSize(METHOD->size_of_parameters() * wordSize),
diff --git a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.inline.hpp b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.inline.hpp
index b765dcebe98..a40991d09ab 100644
--- a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.inline.hpp
+++ b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.inline.hpp
@@ -22,7 +22,7 @@
*
*/
-// This file holds platform-independant bodies of inline functions for the C++ based interpreter
+// This file holds platform-independent bodies of inline functions for the C++ based interpreter
#ifdef CC_INTERP
diff --git a/hotspot/src/share/vm/interpreter/cppInterpreter.hpp b/hotspot/src/share/vm/interpreter/cppInterpreter.hpp
index 9e4b87fba5a..bb61d4009eb 100644
--- a/hotspot/src/share/vm/interpreter/cppInterpreter.hpp
+++ b/hotspot/src/share/vm/interpreter/cppInterpreter.hpp
@@ -24,7 +24,7 @@
#ifdef CC_INTERP
-// This file contains the platform-independant parts
+// This file contains the platform-independent parts
// of the c++ interpreter
class CppInterpreter: public AbstractInterpreter {
diff --git a/hotspot/src/share/vm/interpreter/cppInterpreterGenerator.hpp b/hotspot/src/share/vm/interpreter/cppInterpreterGenerator.hpp
index 3ce3ce15628..b077f4224c6 100644
--- a/hotspot/src/share/vm/interpreter/cppInterpreterGenerator.hpp
+++ b/hotspot/src/share/vm/interpreter/cppInterpreterGenerator.hpp
@@ -22,7 +22,7 @@
*
*/
-// This file contains the platform-independant parts
+// This file contains the platform-independent parts
// of the template interpreter generator.
#ifdef CC_INTERP
diff --git a/hotspot/src/share/vm/interpreter/interpreter.hpp b/hotspot/src/share/vm/interpreter/interpreter.hpp
index eb316c5bce7..767b748dadc 100644
--- a/hotspot/src/share/vm/interpreter/interpreter.hpp
+++ b/hotspot/src/share/vm/interpreter/interpreter.hpp
@@ -22,7 +22,7 @@
*
*/
-// This file contains the platform-independant parts
+// This file contains the platform-independent parts
// of the interpreter and the interpreter generator.
//------------------------------------------------------------------------------------------------------------------------
diff --git a/hotspot/src/share/vm/interpreter/interpreterGenerator.hpp b/hotspot/src/share/vm/interpreter/interpreterGenerator.hpp
index 791b4777ae3..cf6089c3b81 100644
--- a/hotspot/src/share/vm/interpreter/interpreterGenerator.hpp
+++ b/hotspot/src/share/vm/interpreter/interpreterGenerator.hpp
@@ -22,7 +22,7 @@
*
*/
-// This file contains the platform-independant parts
+// This file contains the platform-independent parts
// of the interpreter generator.
diff --git a/hotspot/src/share/vm/interpreter/templateInterpreter.hpp b/hotspot/src/share/vm/interpreter/templateInterpreter.hpp
index f6c89f9bd18..e6442351647 100644
--- a/hotspot/src/share/vm/interpreter/templateInterpreter.hpp
+++ b/hotspot/src/share/vm/interpreter/templateInterpreter.hpp
@@ -22,7 +22,7 @@
*
*/
-// This file contains the platform-independant parts
+// This file contains the platform-independent parts
// of the template interpreter and the template interpreter generator.
#ifndef CC_INTERP
diff --git a/hotspot/src/share/vm/interpreter/templateInterpreterGenerator.hpp b/hotspot/src/share/vm/interpreter/templateInterpreterGenerator.hpp
index 452e1c534ec..52425a04538 100644
--- a/hotspot/src/share/vm/interpreter/templateInterpreterGenerator.hpp
+++ b/hotspot/src/share/vm/interpreter/templateInterpreterGenerator.hpp
@@ -22,7 +22,7 @@
*
*/
-// This file contains the platform-independant parts
+// This file contains the platform-independent parts
// of the template interpreter generator.
#ifndef CC_INTERP
diff --git a/hotspot/src/share/vm/libadt/dict.cpp b/hotspot/src/share/vm/libadt/dict.cpp
index 003dd6a4f05..5620f15c54b 100644
--- a/hotspot/src/share/vm/libadt/dict.cpp
+++ b/hotspot/src/share/vm/libadt/dict.cpp
@@ -306,7 +306,7 @@ void Dict::print() {
// Convert string to hash key. This algorithm implements a universal hash
// function with the multipliers frozen (ok, so it's not universal). The
// multipliers (and allowable characters) are all odd, so the resultant sum
-// is odd - guarenteed not divisible by any power of two, so the hash tables
+// is odd - guaranteed not divisible by any power of two, so the hash tables
// can be any power of two with good results. Also, I choose multipliers
// that have only 2 bits set (the low is always set to be odd) so
// multiplication requires only shifts and adds. Characters are required to
@@ -326,7 +326,7 @@ int hashstr(const void *t) {
}
//------------------------------hashptr--------------------------------------
-// Slimey cheap hash function; no guarenteed performance. Better than the
+// Slimey cheap hash function; no guaranteed performance. Better than the
// default for pointers, especially on MS-DOS machines.
int hashptr(const void *key) {
#ifdef __TURBOC__
@@ -336,7 +336,7 @@ int hashptr(const void *key) {
#endif
}
-// Slimey cheap hash function; no guarenteed performance.
+// Slimey cheap hash function; no guaranteed performance.
int hashkey(const void *key) {
return (intptr_t)key;
}
diff --git a/hotspot/src/share/vm/libadt/dict.hpp b/hotspot/src/share/vm/libadt/dict.hpp
index 93f86829e09..a3553ed873e 100644
--- a/hotspot/src/share/vm/libadt/dict.hpp
+++ b/hotspot/src/share/vm/libadt/dict.hpp
@@ -86,10 +86,10 @@ class Dict : public ResourceObj { // Dictionary structure
// Hashing functions
int hashstr(const void *s); // Nice string hash
-// Slimey cheap hash function; no guarenteed performance. Better than the
+// Slimey cheap hash function; no guaranteed performance. Better than the
// default for pointers, especially on MS-DOS machines.
int hashptr(const void *key);
-// Slimey cheap hash function; no guarenteed performance.
+// Slimey cheap hash function; no guaranteed performance.
int hashkey(const void *key);
// Key comparators
diff --git a/hotspot/src/share/vm/memory/filemap.cpp b/hotspot/src/share/vm/memory/filemap.cpp
index b68f94c0aeb..2f317bf77d8 100644
--- a/hotspot/src/share/vm/memory/filemap.cpp
+++ b/hotspot/src/share/vm/memory/filemap.cpp
@@ -35,14 +35,14 @@
extern address JVM_FunctionAtStart();
extern address JVM_FunctionAtEnd();
-// Complain and stop. All error conditions occuring during the writing of
+// Complain and stop. All error conditions occurring during the writing of
// an archive file should stop the process. Unrecoverable errors during
// the reading of the archive file should stop the process.
static void fail(const char *msg, va_list ap) {
// This occurs very early during initialization: tty is not initialized.
jio_fprintf(defaultStream::error_stream(),
- "An error has occured while processing the"
+ "An error has occurred while processing the"
" shared archive file.\n");
jio_vfprintf(defaultStream::error_stream(), msg, ap);
jio_fprintf(defaultStream::error_stream(), "\n");
diff --git a/hotspot/src/share/vm/memory/permGen.hpp b/hotspot/src/share/vm/memory/permGen.hpp
index 454b10f7986..1b57828499e 100644
--- a/hotspot/src/share/vm/memory/permGen.hpp
+++ b/hotspot/src/share/vm/memory/permGen.hpp
@@ -36,7 +36,7 @@ class PermGen : public CHeapObj {
friend class VMStructs;
protected:
size_t _capacity_expansion_limit; // maximum expansion allowed without a
- // full gc occuring
+ // full gc occurring
HeapWord* mem_allocate_in_gen(size_t size, Generation* gen);
diff --git a/hotspot/src/share/vm/oops/generateOopMap.cpp b/hotspot/src/share/vm/oops/generateOopMap.cpp
index 4a9741c0fc8..5828a6d3783 100644
--- a/hotspot/src/share/vm/oops/generateOopMap.cpp
+++ b/hotspot/src/share/vm/oops/generateOopMap.cpp
@@ -2003,7 +2003,7 @@ void GenerateOopMap::print_time() {
// ============ Main Entry Point ===========
//
GenerateOopMap::GenerateOopMap(methodHandle method) {
- // We have to initialize all variables here, that can be queried direcly
+ // We have to initialize all variables here, that can be queried directly
_method = method;
_max_locals=0;
_init_vars = NULL;
diff --git a/hotspot/src/share/vm/oops/generateOopMap.hpp b/hotspot/src/share/vm/oops/generateOopMap.hpp
index 432902ef362..00057d574b5 100644
--- a/hotspot/src/share/vm/oops/generateOopMap.hpp
+++ b/hotspot/src/share/vm/oops/generateOopMap.hpp
@@ -292,7 +292,7 @@ class GenerateOopMap VALUE_OBJ_CLASS_SPEC {
int _max_stack; // Cached value of max. stack depth
int _max_monitors; // Cached value of max. monitor stack depth
int _has_exceptions; // True, if exceptions exist for method
- bool _got_error; // True, if an error occured during interpretation.
+ bool _got_error; // True, if an error occurred during interpretation.
Handle _exception; // Exception if got_error is true.
bool _did_rewriting; // was bytecodes rewritten
bool _did_relocation; // was relocation neccessary
@@ -422,7 +422,7 @@ class GenerateOopMap VALUE_OBJ_CLASS_SPEC {
void add_to_ref_init_set (int localNo);
// Conflicts rewrite logic
- bool _conflict; // True, if a conflict occured during interpretation
+ bool _conflict; // True, if a conflict occurred during interpretation
int _nof_refval_conflicts; // No. of conflicts that require rewrites
int * _new_var_map;
diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp
index 7a2d3408747..12adb12aba6 100644
--- a/hotspot/src/share/vm/oops/instanceKlass.cpp
+++ b/hotspot/src/share/vm/oops/instanceKlass.cpp
@@ -1917,7 +1917,7 @@ methodOop instanceKlass::method_at_itable(klassOop holder, int index, TRAPS) {
/ itableOffsetEntry::size();
for (int cnt = 0 ; ; cnt ++, ioe ++) {
- // If the interface isn't implemented by the reciever class,
+ // If the interface isn't implemented by the receiver class,
// the VM should throw IncompatibleClassChangeError.
if (cnt >= nof_interfaces) {
THROW_OOP_0(vmSymbols::java_lang_IncompatibleClassChangeError());
diff --git a/hotspot/src/share/vm/oops/klass.cpp b/hotspot/src/share/vm/oops/klass.cpp
index a028f65bb4e..63a342e5b67 100644
--- a/hotspot/src/share/vm/oops/klass.cpp
+++ b/hotspot/src/share/vm/oops/klass.cpp
@@ -71,7 +71,7 @@ Klass *Klass::up_cast_abstract() {
return r; // Return the 1 concrete class
}
-// Find LCA in class heirarchy
+// Find LCA in class hierarchy
Klass *Klass::LCA( Klass *k2 ) {
Klass *k1 = this;
while( 1 ) {
diff --git a/hotspot/src/share/vm/oops/klass.hpp b/hotspot/src/share/vm/oops/klass.hpp
index 881da970d03..7fac5288670 100644
--- a/hotspot/src/share/vm/oops/klass.hpp
+++ b/hotspot/src/share/vm/oops/klass.hpp
@@ -471,7 +471,7 @@ class Klass : public Klass_vtbl {
}
bool search_secondary_supers(klassOop k) const;
- // Find LCA in class heirarchy
+ // Find LCA in class hierarchy
Klass *LCA( Klass *k );
// Check whether reflection/jni/jvm code is allowed to instantiate this class;
diff --git a/hotspot/src/share/vm/oops/methodOop.hpp b/hotspot/src/share/vm/oops/methodOop.hpp
index 8b03a68380a..d266c9a3377 100644
--- a/hotspot/src/share/vm/oops/methodOop.hpp
+++ b/hotspot/src/share/vm/oops/methodOop.hpp
@@ -296,7 +296,7 @@ class methodOopDesc : public oopDesc {
void set_compiled_invocation_count(int count) { _compiled_invocation_count = count; }
#endif // not PRODUCT
- // Clear (non-shared space) pointers which could not be relevent
+ // Clear (non-shared space) pointers which could not be relevant
// if this (shared) method were mapped into another JVM.
void remove_unshareable_info();
diff --git a/hotspot/src/share/vm/opto/block.cpp b/hotspot/src/share/vm/opto/block.cpp
index 28400047756..4749dc34dd5 100644
--- a/hotspot/src/share/vm/opto/block.cpp
+++ b/hotspot/src/share/vm/opto/block.cpp
@@ -181,7 +181,7 @@ int Block::is_Empty() const {
}
//------------------------------has_uncommon_code------------------------------
-// Return true if the block's code implies that it is not likely to be
+// Return true if the block's code implies that it is likely to be
// executed infrequently. Check to see if the block ends in a Halt or
// a low probability call.
bool Block::has_uncommon_code() const {
@@ -1311,7 +1311,7 @@ void PhaseBlockLayout::merge_traces(bool fall_thru_only)
}
} else if (e->state() == CFGEdge::open) {
// Append traces, even without a fall-thru connection.
- // But leave root entry at the begining of the block list.
+ // But leave root entry at the beginning of the block list.
if (targ_trace != trace(_cfg._broot)) {
e->set_state(CFGEdge::connected);
src_trace->append(targ_trace);
@@ -1434,7 +1434,7 @@ bool Trace::backedge(CFGEdge *e) {
}
// Backbranch to the top of a trace
- // Scroll foward through the trace from the targ_block. If we find
+ // Scroll forward through the trace from the targ_block. If we find
// a loop head before another loop top, use the the loop head alignment.
for (Block *b = targ_block; b != NULL; b = next(b)) {
if (b->has_loop_alignment()) {
diff --git a/hotspot/src/share/vm/opto/block.hpp b/hotspot/src/share/vm/opto/block.hpp
index f678983ddaf..f4c46ba2a50 100644
--- a/hotspot/src/share/vm/opto/block.hpp
+++ b/hotspot/src/share/vm/opto/block.hpp
@@ -609,7 +609,7 @@ class Trace : public ResourceObj {
Block * next(Block *b) const { return _next_list[b->_pre_order]; }
void set_next(Block *b, Block *n) const { _next_list[b->_pre_order] = n; }
- // Return the block that preceeds "b" in the trace.
+ // Return the block that precedes "b" in the trace.
Block * prev(Block *b) const { return _prev_list[b->_pre_order]; }
void set_prev(Block *b, Block *p) const { _prev_list[b->_pre_order] = p; }
diff --git a/hotspot/src/share/vm/opto/buildOopMap.cpp b/hotspot/src/share/vm/opto/buildOopMap.cpp
index 30a9d2684d0..4a8612687f0 100644
--- a/hotspot/src/share/vm/opto/buildOopMap.cpp
+++ b/hotspot/src/share/vm/opto/buildOopMap.cpp
@@ -55,7 +55,7 @@
// breadth-first approach but it was worse (showed O(n^2) in the
// pick-next-block code).
//
-// The relevent data is kept in a struct of arrays (it could just as well be
+// The relevant data is kept in a struct of arrays (it could just as well be
// an array of structs, but the struct-of-arrays is generally a little more
// efficient). The arrays are indexed by register number (including
// stack-slots as registers) and so is bounded by 200 to 300 elements in
diff --git a/hotspot/src/share/vm/opto/cfgnode.cpp b/hotspot/src/share/vm/opto/cfgnode.cpp
index e29cc0d58e3..139672ed725 100644
--- a/hotspot/src/share/vm/opto/cfgnode.cpp
+++ b/hotspot/src/share/vm/opto/cfgnode.cpp
@@ -1350,7 +1350,7 @@ static void split_once(PhaseIterGVN *igvn, Node *phi, Node *val, Node *n, Node *
}
// Register the new node but do not transform it. Cannot transform until the
- // entire Region/Phi conglerate has been hacked as a single huge transform.
+ // entire Region/Phi conglomerate has been hacked as a single huge transform.
igvn->register_new_node_with_optimizer( newn );
// Now I can point to the new node.
n->add_req(newn);
@@ -1381,7 +1381,7 @@ static Node* split_flow_path(PhaseGVN *phase, PhiNode *phi) {
Node *val = phi->in(i); // Constant to split for
uint hit = 0; // Number of times it occurs
- for( ; i < phi->req(); i++ ){ // Count occurances of constant
+ for( ; i < phi->req(); i++ ){ // Count occurrences of constant
Node *n = phi->in(i);
if( !n ) return NULL;
if( phase->type(n) == Type::TOP ) return NULL;
@@ -1423,7 +1423,7 @@ static Node* split_flow_path(PhaseGVN *phase, PhiNode *phi) {
//=============================================================================
//------------------------------simple_data_loop_check-------------------------
-// Try to determing if the phi node in a simple safe/unsafe data loop.
+// Try to determining if the phi node in a simple safe/unsafe data loop.
// Returns:
// enum LoopSafety { Safe = 0, Unsafe, UnsafeLoop };
// Safe - safe case when the phi and it's inputs reference only safe data
@@ -1687,7 +1687,7 @@ Node *PhiNode::Ideal(PhaseGVN *phase, bool can_reshape) {
progress = phase->C->top();
break;
}
- // If tranformed to a MergeMem, get the desired slice
+ // If transformed to a MergeMem, get the desired slice
// Otherwise the returned node represents memory for every slice
Node *new_mem = (m->is_MergeMem()) ?
m->as_MergeMem()->memory_at(alias_idx) : m;
@@ -1962,7 +1962,7 @@ const Type *CatchNode::Value( PhaseTransform *phase ) const {
f[CatchProjNode::fall_through_index] = Type::TOP;
} else if( call->req() > TypeFunc::Parms ) {
const Type *arg0 = phase->type( call->in(TypeFunc::Parms) );
- // Check for null reciever to virtual or interface calls
+ // Check for null receiver to virtual or interface calls
if( call->is_CallDynamicJava() &&
arg0->higher_equal(TypePtr::NULL_PTR) ) {
f[CatchProjNode::fall_through_index] = Type::TOP;
@@ -1995,7 +1995,7 @@ Node *CatchProjNode::Identity( PhaseTransform *phase ) {
// also remove any exception table entry. Thus we must know the call
// feeding the Catch will not really throw an exception. This is ok for
// the main fall-thru control (happens when we know a call can never throw
- // an exception) or for "rethrow", because a further optimnization will
+ // an exception) or for "rethrow", because a further optimization will
// yank the rethrow (happens when we inline a function that can throw an
// exception and the caller has no handler). Not legal, e.g., for passing
// a NULL receiver to a v-call, or passing bad types to a slow-check-cast.
diff --git a/hotspot/src/share/vm/opto/chaitin.cpp b/hotspot/src/share/vm/opto/chaitin.cpp
index 82558d8f577..363db91175c 100644
--- a/hotspot/src/share/vm/opto/chaitin.cpp
+++ b/hotspot/src/share/vm/opto/chaitin.cpp
@@ -1246,7 +1246,7 @@ uint PhaseChaitin::Select( ) {
// If the live range is not bound, then we actually had some choices
// to make. In this case, the mask has more bits in it than the colors
- // choosen. Restrict the mask to just what was picked.
+ // chosen. Restrict the mask to just what was picked.
if( lrg->num_regs() == 1 ) { // Size 1 live range
lrg->Clear(); // Clear the mask
lrg->Insert(reg); // Set regmask to match selected reg
diff --git a/hotspot/src/share/vm/opto/chaitin.hpp b/hotspot/src/share/vm/opto/chaitin.hpp
index 307d6110c04..bbf828d590c 100644
--- a/hotspot/src/share/vm/opto/chaitin.hpp
+++ b/hotspot/src/share/vm/opto/chaitin.hpp
@@ -327,7 +327,7 @@ class PhaseChaitin : public PhaseRegAlloc {
// True if lidx is used before any real register is def'd in the block
bool prompt_use( Block *b, uint lidx );
Node *get_spillcopy_wide( Node *def, Node *use, uint uidx );
- // Insert the spill at chosen location. Skip over any interveneing Proj's or
+ // Insert the spill at chosen location. Skip over any intervening Proj's or
// Phis. Skip over a CatchNode and projs, inserting in the fall-through block
// instead. Update high-pressure indices. Create a new live range.
void insert_proj( Block *b, uint i, Node *spill, uint maxlrg );
@@ -431,7 +431,7 @@ private:
void Simplify();
// Select colors by re-inserting edges into the IFG.
- // Return TRUE if any spills occured.
+ // Return TRUE if any spills occurred.
uint Select( );
// Helper function for select which allows biased coloring
OptoReg::Name choose_color( LRG &lrg, int chunk );
diff --git a/hotspot/src/share/vm/opto/coalesce.cpp b/hotspot/src/share/vm/opto/coalesce.cpp
index 7d9ab008398..52c00992719 100644
--- a/hotspot/src/share/vm/opto/coalesce.cpp
+++ b/hotspot/src/share/vm/opto/coalesce.cpp
@@ -123,7 +123,7 @@ void PhaseChaitin::new_lrg( const Node *x, uint lrg ) {
}
//------------------------------clone_projs------------------------------------
-// After cloning some rematierialized instruction, clone any MachProj's that
+// After cloning some rematerialized instruction, clone any MachProj's that
// follow it. Example: Intel zero is XOR, kills flags. Sparc FP constants
// use G3 as an address temp.
int PhaseChaitin::clone_projs( Block *b, uint idx, Node *con, Node *copy, uint &maxlrg ) {
@@ -694,8 +694,8 @@ uint PhaseConservativeCoalesce::compute_separating_interferences(Node *dst_copy,
} // End of if not infinite-stack neighbor
} // End of if actually inserted
} // End of if live range overlaps
- } // End of else collect intereferences for 1 node
- } // End of while forever, scan back for intereferences
+ } // End of else collect interferences for 1 node
+ } // End of while forever, scan back for interferences
return reg_degree;
}
@@ -786,7 +786,7 @@ bool PhaseConservativeCoalesce::copy_copy( Node *dst_copy, Node *src_copy, Block
if( rm_size == 0 ) return false;
// Another early bail-out test is when we are double-coalescing and the
- // 2 copies are seperated by some control flow.
+ // 2 copies are separated by some control flow.
if( dst_copy != src_copy ) {
Block *src_b = _phc._cfg._bbs[src_copy->_idx];
Block *b2 = b;
diff --git a/hotspot/src/share/vm/opto/compile.cpp b/hotspot/src/share/vm/opto/compile.cpp
index 7c6f751f8ff..5790af4c6e1 100644
--- a/hotspot/src/share/vm/opto/compile.cpp
+++ b/hotspot/src/share/vm/opto/compile.cpp
@@ -337,7 +337,7 @@ void Compile::print_compile_messages() {
tty->print_cr("*********************************************************");
}
if (env()->break_at_compile()) {
- // Open the debugger when compiing this method.
+ // Open the debugger when compiling this method.
tty->print("### Breaking when compiling: ");
method()->print_short_name();
tty->cr();
@@ -1191,8 +1191,8 @@ const TypePtr *Compile::flatten_alias_type( const TypePtr *tj ) const {
default: ShouldNotReachHere();
}
break;
- case 2: // No collasping at level 2; keep all splits
- case 3: // No collasping at level 3; keep all splits
+ case 2: // No collapsing at level 2; keep all splits
+ case 3: // No collapsing at level 3; keep all splits
break;
default:
Unimplemented();
@@ -2102,7 +2102,7 @@ static void final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &fpu ) {
// [base_reg + offset]
// NullCheck base_reg
//
- // Pin the new DecodeN node to non-null path on these patforms (Sparc)
+ // Pin the new DecodeN node to non-null path on these platform (Sparc)
// to keep the information to which NULL check the new DecodeN node
// corresponds to use it as value in implicit_null_check().
//
diff --git a/hotspot/src/share/vm/opto/connode.cpp b/hotspot/src/share/vm/opto/connode.cpp
index 7e1cafefa57..d46b6d4e952 100644
--- a/hotspot/src/share/vm/opto/connode.cpp
+++ b/hotspot/src/share/vm/opto/connode.cpp
@@ -71,7 +71,7 @@ testing.
to figure out which test post-dominates. The real problem is that it doesn't
matter which one you pick. After you pick up, the dominating-test elider in
IGVN can remove the test and allow you to hoist up to the dominating test on
-the choosen oop bypassing the test on the not-choosen oop. Seen in testing.
+the chosen oop bypassing the test on the not-chosen oop. Seen in testing.
Oops.
(3) Leave the CastPP's in. This makes the graph more accurate in some sense;
diff --git a/hotspot/src/share/vm/opto/divnode.cpp b/hotspot/src/share/vm/opto/divnode.cpp
index 67cad067960..55350e11f66 100644
--- a/hotspot/src/share/vm/opto/divnode.cpp
+++ b/hotspot/src/share/vm/opto/divnode.cpp
@@ -35,7 +35,7 @@
// by constant into a multiply/shift/add series. Return false if calculations
// fail.
//
-// Borrowed almost verbatum from Hacker's Delight by Henry S. Warren, Jr. with
+// Borrowed almost verbatim from Hacker's Delight by Henry S. Warren, Jr. with
// minor type name and parameter changes.
static bool magic_int_divide_constants(jint d, jint &M, jint &s) {
int32_t p;
@@ -202,7 +202,7 @@ static Node *transform_int_divide( PhaseGVN *phase, Node *dividend, jint divisor
// by constant into a multiply/shift/add series. Return false if calculations
// fail.
//
-// Borrowed almost verbatum from Hacker's Delight by Henry S. Warren, Jr. with
+// Borrowed almost verbatim from Hacker's Delight by Henry S. Warren, Jr. with
// minor type name and parameter changes. Adjusted to 64 bit word width.
static bool magic_long_divide_constants(jlong d, jlong &M, jint &s) {
int64_t p;
@@ -1069,7 +1069,7 @@ Node *ModLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
int log2_con = -1;
- // If this is a power of two, they maybe we can mask it
+ // If this is a power of two, then maybe we can mask it
if( is_power_of_2_long(pos_con) ) {
log2_con = log2_long(pos_con);
diff --git a/hotspot/src/share/vm/opto/domgraph.cpp b/hotspot/src/share/vm/opto/domgraph.cpp
index 2ef02fd0cec..af198e3c71f 100644
--- a/hotspot/src/share/vm/opto/domgraph.cpp
+++ b/hotspot/src/share/vm/opto/domgraph.cpp
@@ -183,7 +183,7 @@ class Block_Stack {
if (pre_order == 1)
t->_parent = NULL; // first block doesn't have parent
else {
- // Save parent (currernt top block on stack) in DFS
+ // Save parent (current top block on stack) in DFS
t->_parent = &_tarjan[_stack_top->block->_pre_order];
}
// Now put this block on stack
diff --git a/hotspot/src/share/vm/opto/escape.cpp b/hotspot/src/share/vm/opto/escape.cpp
index 2606d0df82a..c9ddc95dcfb 100644
--- a/hotspot/src/share/vm/opto/escape.cpp
+++ b/hotspot/src/share/vm/opto/escape.cpp
@@ -515,7 +515,7 @@ bool ConnectionGraph::split_AddP(Node *addp, Node *base, PhaseGVN *igvn) {
// cause the failure in add_offset() with narrow oops since TypeOopPtr()
// constructor verifies correctness of the offset.
//
- // It could happend on subclass's branch (from the type profiling
+ // It could happened on subclass's branch (from the type profiling
// inlining) which was not eliminated during parsing since the exactness
// of the allocation type was not propagated to the subclass type check.
//
@@ -703,7 +703,7 @@ Node* ConnectionGraph::find_inst_mem(Node *orig_mem, int alias_idx, GrowableArra
while (prev != result) {
prev = result;
if (result == start_mem)
- break; // hit one of our sentinals
+ break; // hit one of our sentinels
if (result->is_Mem()) {
const Type *at = phase->type(result->in(MemNode::Address));
if (at != Type::TOP) {
@@ -720,7 +720,7 @@ Node* ConnectionGraph::find_inst_mem(Node *orig_mem, int alias_idx, GrowableArra
if (result->is_Proj() && result->as_Proj()->_con == TypeFunc::Memory) {
Node *proj_in = result->in(0);
if (proj_in->is_Allocate() && proj_in->_idx == (uint)tinst->instance_id()) {
- break; // hit one of our sentinals
+ break; // hit one of our sentinels
} else if (proj_in->is_Call()) {
CallNode *call = proj_in->as_Call();
if (!call->may_modify(tinst, phase)) {
@@ -804,7 +804,7 @@ Node* ConnectionGraph::find_inst_mem(Node *orig_mem, int alias_idx, GrowableArra
// Phase 2: Process MemNode's from memnode_worklist. compute new address type and
// search the Memory chain for a store with the appropriate type
// address type. If a Phi is found, create a new version with
-// the approriate memory slices from each of the Phi inputs.
+// the appropriate memory slices from each of the Phi inputs.
// For stores, process the users as follows:
// MemNode: push on memnode_worklist
// MergeMem: push on mergemem_worklist
@@ -1558,7 +1558,7 @@ bool ConnectionGraph::compute_escape() {
has_non_escaping_obj = true; // Non GlobalEscape
Node* n = ptn->_node;
if (n->is_Allocate() && ptn->_scalar_replaceable ) {
- // Push scalar replaceable alocations on alloc_worklist
+ // Push scalar replaceable allocations on alloc_worklist
// for processing in split_unique_types().
alloc_worklist.append(n);
}
diff --git a/hotspot/src/share/vm/opto/gcm.cpp b/hotspot/src/share/vm/opto/gcm.cpp
index 65c63339e29..27ccc8126df 100644
--- a/hotspot/src/share/vm/opto/gcm.cpp
+++ b/hotspot/src/share/vm/opto/gcm.cpp
@@ -606,7 +606,7 @@ Block* PhaseCFG::insert_anti_dependences(Block* LCA, Node* load, bool verify) {
if (pred_block != early) {
// If any predecessor of the Phi matches the load's "early block",
// we do not need a precedence edge between the Phi and 'load'
- // since the load will be forced into a block preceeding the Phi.
+ // since the load will be forced into a block preceding the Phi.
pred_block->set_raise_LCA_mark(load_index);
assert(!LCA_orig->dominates(pred_block) ||
early->dominates(pred_block), "early is high enough");
@@ -1399,7 +1399,7 @@ void PhaseCFG::Estimate_Block_Frequency() {
#ifdef ASSERT
for (uint i = 0; i < _num_blocks; i++ ) {
Block *b = _blocks[i];
- assert(b->_freq >= MIN_BLOCK_FREQUENCY, "Register Allocator requiers meaningful block frequency");
+ assert(b->_freq >= MIN_BLOCK_FREQUENCY, "Register Allocator requires meaningful block frequency");
}
#endif
@@ -1652,7 +1652,7 @@ float Block::succ_prob(uint i) {
// successor blocks.
assert(_num_succs == 2, "expecting 2 successors of a null check");
// If either successor has only one predecessor, then the
- // probabiltity estimate can be derived using the
+ // probability estimate can be derived using the
// relative frequency of the successor and this block.
if (_succs[i]->num_preds() == 2) {
return _succs[i]->_freq / _freq;
@@ -1854,7 +1854,7 @@ void Block::update_uncommon_branch(Block* ub) {
}
//------------------------------update_succ_freq-------------------------------
-// Update the appropriate frequency associated with block 'b', a succesor of
+// Update the appropriate frequency associated with block 'b', a successor of
// a block in this loop.
void CFGLoop::update_succ_freq(Block* b, float freq) {
if (b->_loop == this) {
diff --git a/hotspot/src/share/vm/opto/graphKit.cpp b/hotspot/src/share/vm/opto/graphKit.cpp
index c0cb4ba0132..e81e0075340 100644
--- a/hotspot/src/share/vm/opto/graphKit.cpp
+++ b/hotspot/src/share/vm/opto/graphKit.cpp
@@ -1148,7 +1148,7 @@ Node* GraphKit::null_check_common(Node* value, BasicType type,
Node *tst = _gvn.transform( btst );
//-----------
- // if peephole optimizations occured, a prior test existed.
+ // if peephole optimizations occurred, a prior test existed.
// If a prior test existed, maybe it dominates as we can avoid this test.
if (tst != btst && type == T_OBJECT) {
// At this point we want to scan up the CFG to see if we can
@@ -1196,7 +1196,7 @@ Node* GraphKit::null_check_common(Node* value, BasicType type,
// Consider using 'Reason_class_check' instead?
// To cause an implicit null check, we set the not-null probability
- // to the maximum (PROB_MAX). For an explicit check the probablity
+ // to the maximum (PROB_MAX). For an explicit check the probability
// is set to a smaller value.
if (null_control != NULL || too_many_traps(reason)) {
// probability is less likely
diff --git a/hotspot/src/share/vm/opto/ifg.cpp b/hotspot/src/share/vm/opto/ifg.cpp
index b3250513d7a..d5b7dc9b493 100644
--- a/hotspot/src/share/vm/opto/ifg.cpp
+++ b/hotspot/src/share/vm/opto/ifg.cpp
@@ -292,7 +292,7 @@ void PhaseIFG::verify( const PhaseChaitin *pc ) const {
//------------------------------interfere_with_live----------------------------
// Interfere this register with everything currently live. Use the RegMasks
// to trim the set of possible interferences. Return a count of register-only
-// inteferences as an estimate of register pressure.
+// interferences as an estimate of register pressure.
void PhaseChaitin::interfere_with_live( uint r, IndexSet *liveout ) {
uint retval = 0;
// Interfere with everything live.
diff --git a/hotspot/src/share/vm/opto/ifnode.cpp b/hotspot/src/share/vm/opto/ifnode.cpp
index 4f230765ab8..38fab34a50d 100644
--- a/hotspot/src/share/vm/opto/ifnode.cpp
+++ b/hotspot/src/share/vm/opto/ifnode.cpp
@@ -81,7 +81,7 @@ static Node* split_if(IfNode *iff, PhaseIterGVN *igvn) {
uint i4;
for( i4 = 1; i4 < phi->req(); i4++ ) {
con1 = phi->in(i4);
- if( !con1 ) return NULL; // Do not optimize partially collaped merges
+ if( !con1 ) return NULL; // Do not optimize partially collapsed merges
if( con1->is_Con() ) break; // Found a constant
// Also allow null-vs-not-null checks
const TypePtr *tp = igvn->type(con1)->isa_ptr();
@@ -204,7 +204,7 @@ static Node* split_if(IfNode *iff, PhaseIterGVN *igvn) {
// T F T F T F
// ..s.. ..t .. ..s.. ..t.. ..s.. ..t..
//
- // Split the paths coming into the merge point into 2 seperate groups of
+ // Split the paths coming into the merge point into 2 separate groups of
// merges. On the left will be all the paths feeding constants into the
// Cmp's Phi. On the right will be the remaining paths. The Cmp's Phi
// will fold up into a constant; this will let the Cmp fold up as well as
@@ -236,7 +236,7 @@ static Node* split_if(IfNode *iff, PhaseIterGVN *igvn) {
}
// Register the new RegionNodes but do not transform them. Cannot
- // transform until the entire Region/Phi conglerate has been hacked
+ // transform until the entire Region/Phi conglomerate has been hacked
// as a single huge transform.
igvn->register_new_node_with_optimizer( region_c );
igvn->register_new_node_with_optimizer( region_x );
@@ -599,7 +599,7 @@ const TypeInt* IfNode::filtered_int_type(PhaseGVN* gvn, Node *val, Node* if_proj
//------------------------------fold_compares----------------------------
// See if a pair of CmpIs can be converted into a CmpU. In some cases
-// the direction of this if is determined by the preciding if so it
+// the direction of this if is determined by the preceding if so it
// can be eliminate entirely. Given an if testing (CmpI n c) check
// for an immediately control dependent if that is testing (CmpI n c2)
// and has one projection leading to this if and the other projection
@@ -811,7 +811,7 @@ Node *IfNode::Ideal(PhaseGVN *phase, bool can_reshape) {
// Try to remove extra range checks. All 'up_one_dom' gives up at merges
// so all checks we inspect post-dominate the top-most check we find.
// If we are going to fail the current check and we reach the top check
- // then we are guarenteed to fail, so just start interpreting there.
+ // then we are guaranteed to fail, so just start interpreting there.
// We 'expand' the top 2 range checks to include all post-dominating
// checks.
diff --git a/hotspot/src/share/vm/opto/library_call.cpp b/hotspot/src/share/vm/opto/library_call.cpp
index 17a5c1f79d1..6cbcee84b51 100644
--- a/hotspot/src/share/vm/opto/library_call.cpp
+++ b/hotspot/src/share/vm/opto/library_call.cpp
@@ -992,7 +992,7 @@ bool LibraryCallKit::inline_string_indexOf() {
Node *argument = pop(); // pop non-receiver first: it was pushed second
Node *receiver = pop();
- // don't intrinsify is argument isn't a constant string.
+ // don't intrinsify if argument isn't a constant string.
if (!argument->is_Con()) {
return false;
}
@@ -1267,7 +1267,7 @@ bool LibraryCallKit::inline_pow(vmIntrinsics::ID id) {
// result = DPow(x,y);
// }
// if (result != result)? {
- // ucommon_trap();
+ // uncommon_trap();
// }
// return result;
@@ -1324,7 +1324,7 @@ bool LibraryCallKit::inline_pow(vmIntrinsics::ID id) {
// Check if (y isn't int) then go to slow path
Node *bol2 = _gvn.transform( new (C, 2) BoolNode( cmpinty, BoolTest::ne ) );
- // Branch eith way
+ // Branch either way
IfNode *if2 = create_and_xform_if(complex_path,bol2, PROB_STATIC_INFREQUENT, COUNT_UNKNOWN);
Node *slow_path = opt_iff(r,if2); // Set region path 2
@@ -1715,8 +1715,8 @@ inline Node* LibraryCallKit::make_unsafe_address(Node* base, Node* offset) {
}
//----------------------------inline_reverseBytes_int/long-------------------
-// inline Int.reverseBytes(int)
-// inline Long.reverseByes(long)
+// inline Integer.reverseBytes(int)
+// inline Long.reverseBytes(long)
bool LibraryCallKit::inline_reverseBytes(vmIntrinsics::ID id) {
assert(id == vmIntrinsics::_reverseBytes_i || id == vmIntrinsics::_reverseBytes_l, "not reverse Bytes");
if (id == vmIntrinsics::_reverseBytes_i && !Matcher::has_match_rule(Op_ReverseBytesI)) return false;
@@ -1915,7 +1915,7 @@ bool LibraryCallKit::inline_unsafe_access(bool is_native_ptr, bool is_store, Bas
// addition to memory membars when is_volatile. This is a little
// too strong, but avoids the need to insert per-alias-type
// volatile membars (for stores; compare Parse::do_put_xxx), which
- // we cannot do effctively here because we probably only have a
+ // we cannot do effectively here because we probably only have a
// rough approximation of type.
need_mem_bar = true;
// For Stores, place a memory ordering barrier now.
@@ -2099,7 +2099,7 @@ bool LibraryCallKit::inline_unsafe_CAS(BasicType type) {
// overly confusing. (This is a true fact! I originally combined
// them, but even I was confused by it!) As much code/comments as
// possible are retained from inline_unsafe_access though to make
- // the correspondances clearer. - dl
+ // the correspondences clearer. - dl
if (callee()->is_static()) return false; // caller must have the capability!
@@ -2166,7 +2166,7 @@ bool LibraryCallKit::inline_unsafe_CAS(BasicType type) {
int alias_idx = C->get_alias_index(adr_type);
// Memory-model-wise, a CAS acts like a little synchronized block,
- // so needs barriers on each side. These don't't translate into
+ // so needs barriers on each side. These don't translate into
// actual barriers on most machines, but we still need rest of
// compiler to respect ordering.
@@ -3208,7 +3208,7 @@ bool LibraryCallKit::inline_native_hashcode(bool is_virtual, bool is_static) {
Node *hash_shift = _gvn.intcon(markOopDesc::hash_shift);
Node *hshifted_header= _gvn.transform( new (C, 3) URShiftXNode(header, hash_shift) );
// This hack lets the hash bits live anywhere in the mark object now, as long
- // as the shift drops the relevent bits into the low 32 bits. Note that
+ // as the shift drops the relevant bits into the low 32 bits. Note that
// Java spec says that HashCode is an int so there's no point in capturing
// an 'X'-sized hashcode (32 in 32-bit build or 64 in 64-bit build).
hshifted_header = ConvX2I(hshifted_header);
@@ -3255,7 +3255,7 @@ bool LibraryCallKit::inline_native_hashcode(bool is_virtual, bool is_static) {
}
//---------------------------inline_native_getClass----------------------------
-// Build special case code for calls to hashCode on an object.
+// Build special case code for calls to getClass on an object.
bool LibraryCallKit::inline_native_getClass() {
Node* obj = null_check_receiver(callee());
if (stopped()) return true;
@@ -4594,7 +4594,7 @@ LibraryCallKit::generate_arraycopy(const TypePtr* adr_type,
}
// The memory edges above are precise in order to model effects around
- // array copyies accurately to allow value numbering of field loads around
+ // array copies accurately to allow value numbering of field loads around
// arraycopy. Such field loads, both before and after, are common in Java
// collections and similar classes involving header/array data structures.
//
diff --git a/hotspot/src/share/vm/opto/live.cpp b/hotspot/src/share/vm/opto/live.cpp
index d2ff515058c..e9aa3815c13 100644
--- a/hotspot/src/share/vm/opto/live.cpp
+++ b/hotspot/src/share/vm/opto/live.cpp
@@ -39,7 +39,7 @@
// Leftover bits become the new live-in for the predecessor block, and the pred
// block is put on the worklist.
// The locally live-in stuff is computed once and added to predecessor
-// live-out sets. This seperate compilation is done in the outer loop below.
+// live-out sets. This separate compilation is done in the outer loop below.
PhaseLive::PhaseLive( const PhaseCFG &cfg, LRG_List &names, Arena *arena ) : Phase(LIVE), _cfg(cfg), _names(names), _arena(arena), _live(0) {
}
diff --git a/hotspot/src/share/vm/opto/locknode.cpp b/hotspot/src/share/vm/opto/locknode.cpp
index 0099284a701..f6a01222117 100644
--- a/hotspot/src/share/vm/opto/locknode.cpp
+++ b/hotspot/src/share/vm/opto/locknode.cpp
@@ -121,7 +121,7 @@ void Parse::do_monitor_exit() {
kill_dead_locals();
pop(); // Pop oop to unlock
- // Because monitors are guarenteed paired (else we bail out), we know
+ // Because monitors are guaranteed paired (else we bail out), we know
// the matching Lock for this Unlock. Hence we know there is no need
// for a null check on Unlock.
shared_unlock(map()->peek_monitor_box(), map()->peek_monitor_obj());
diff --git a/hotspot/src/share/vm/opto/loopTransform.cpp b/hotspot/src/share/vm/opto/loopTransform.cpp
index caa676f6ffd..4ff59d9d46e 100644
--- a/hotspot/src/share/vm/opto/loopTransform.cpp
+++ b/hotspot/src/share/vm/opto/loopTransform.cpp
@@ -119,7 +119,7 @@ void IdealLoopTree::compute_profile_trip_cnt( PhaseIdealLoop *phase ) {
//---------------------is_invariant_addition-----------------------------
// Return nonzero index of invariant operand for an Add or Sub
-// of (nonconstant) invariant and variant values. Helper for reassoicate_invariants.
+// of (nonconstant) invariant and variant values. Helper for reassociate_invariants.
int IdealLoopTree::is_invariant_addition(Node* n, PhaseIdealLoop *phase) {
int op = n->Opcode();
if (op == Op_AddI || op == Op_SubI) {
@@ -520,7 +520,7 @@ bool IdealLoopTree::policy_unroll( PhaseIdealLoop *phase ) const {
//------------------------------policy_align-----------------------------------
// Return TRUE or FALSE if the loop should be cache-line aligned. Gather the
// expression that does the alignment. Note that only one array base can be
-// aligned in a loop (unless the VM guarentees mutual alignment). Note that
+// aligned in a loop (unless the VM guarantees mutual alignment). Note that
// if we vectorize short memory ops into longer memory ops, we may want to
// increase alignment.
bool IdealLoopTree::policy_align( PhaseIdealLoop *phase ) const {
diff --git a/hotspot/src/share/vm/opto/loopUnswitch.cpp b/hotspot/src/share/vm/opto/loopUnswitch.cpp
index 2a385e76846..4bb67ad0f8a 100644
--- a/hotspot/src/share/vm/opto/loopUnswitch.cpp
+++ b/hotspot/src/share/vm/opto/loopUnswitch.cpp
@@ -131,7 +131,7 @@ void PhaseIdealLoop::do_unswitching (IdealLoopTree *loop, Node_List &old_new) {
ProjNode* proj_false = invar_iff->proj_out(0)->as_Proj();
- // Hoist invariant casts out of each loop to the appropiate
+ // Hoist invariant casts out of each loop to the appropriate
// control projection.
Node_List worklist;
diff --git a/hotspot/src/share/vm/opto/loopnode.cpp b/hotspot/src/share/vm/opto/loopnode.cpp
index fba4a350bbb..7f939a197a3 100644
--- a/hotspot/src/share/vm/opto/loopnode.cpp
+++ b/hotspot/src/share/vm/opto/loopnode.cpp
@@ -274,7 +274,7 @@ Node *PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) {
//
// Canonicalize the condition on the test. If we can exactly determine
// the trip-counter exit value, then set limit to that value and use
- // a '!=' test. Otherwise use conditon '<' for count-up loops and
+ // a '!=' test. Otherwise use condition '<' for count-up loops and
// '>' for count-down loops. If the condition is inverted and we will
// be rolling through MININT to MAXINT, then bail out.
@@ -290,7 +290,7 @@ Node *PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) {
// If compare points to incr, we are ok. Otherwise the compare
// can directly point to the phi; in this case adjust the compare so that
- // it points to the incr by adusting the limit.
+ // it points to the incr by adjusting the limit.
if( cmp->in(1) == phi || cmp->in(2) == phi )
limit = gvn->transform(new (C, 3) AddINode(limit,stride));
@@ -471,7 +471,7 @@ Node *PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) {
lazy_replace( x, l );
set_idom(l, init_control, dom_depth(x));
- // Check for immediately preceeding SafePoint and remove
+ // Check for immediately preceding SafePoint and remove
Node *sfpt2 = le->in(0);
if( sfpt2->Opcode() == Op_SafePoint && is_deleteable_safept(sfpt2))
lazy_replace( sfpt2, sfpt2->in(TypeFunc::Control));
@@ -1506,7 +1506,7 @@ PhaseIdealLoop::PhaseIdealLoop( PhaseIterGVN &igvn, const PhaseIdealLoop *verify
// Build Dominators for elision of NULL checks & loop finding.
// Since nodes do not have a slot for immediate dominator, make
- // a persistant side array for that info indexed on node->_idx.
+ // a persistent side array for that info indexed on node->_idx.
_idom_size = C->unique();
_idom = NEW_RESOURCE_ARRAY( Node*, _idom_size );
_dom_depth = NEW_RESOURCE_ARRAY( uint, _idom_size );
@@ -1529,7 +1529,7 @@ PhaseIdealLoop::PhaseIdealLoop( PhaseIterGVN &igvn, const PhaseIdealLoop *verify
// Given dominators, try to find inner loops with calls that must
// always be executed (call dominates loop tail). These loops do
- // not need a seperate safepoint.
+ // not need a separate safepoint.
Node_List cisstack(a);
_ltree_root->check_safepts(visited, cisstack);
@@ -2332,7 +2332,7 @@ void PhaseIdealLoop::build_loop_early( VectorSet &visited, Node_List &worklist,
if (done) {
// All of n's inputs have been processed, complete post-processing.
- // Compute earilest point this Node can go.
+ // Compute earliest point this Node can go.
// CFG, Phi, pinned nodes already know their controlling input.
if (!has_node(n)) {
// Record earliest legal location
@@ -2672,9 +2672,9 @@ void PhaseIdealLoop::build_loop_late_post( Node *n, const PhaseIdealLoop *verify
pinned = false;
}
if( pinned ) {
- IdealLoopTree *choosen_loop = get_loop(n->is_CFG() ? n : get_ctrl(n));
- if( !choosen_loop->_child ) // Inner loop?
- choosen_loop->_body.push(n); // Collect inner loops
+ IdealLoopTree *chosen_loop = get_loop(n->is_CFG() ? n : get_ctrl(n));
+ if( !chosen_loop->_child ) // Inner loop?
+ chosen_loop->_body.push(n); // Collect inner loops
return;
}
} else { // No slot zero
@@ -2746,9 +2746,9 @@ void PhaseIdealLoop::build_loop_late_post( Node *n, const PhaseIdealLoop *verify
set_ctrl(n, least);
// Collect inner loop bodies
- IdealLoopTree *choosen_loop = get_loop(least);
- if( !choosen_loop->_child ) // Inner loop?
- choosen_loop->_body.push(n);// Collect inner loops
+ IdealLoopTree *chosen_loop = get_loop(least);
+ if( !chosen_loop->_child ) // Inner loop?
+ chosen_loop->_body.push(n);// Collect inner loops
}
#ifndef PRODUCT
diff --git a/hotspot/src/share/vm/opto/loopnode.hpp b/hotspot/src/share/vm/opto/loopnode.hpp
index 53775646696..ab172a3eb43 100644
--- a/hotspot/src/share/vm/opto/loopnode.hpp
+++ b/hotspot/src/share/vm/opto/loopnode.hpp
@@ -390,7 +390,7 @@ public:
// Return TRUE or FALSE if the loop should be cache-line aligned.
// Gather the expression that does the alignment. Note that only
- // one array base can be aligned in a loop (unless the VM guarentees
+ // one array base can be aligned in a loop (unless the VM guarantees
// mutual alignment). Note that if we vectorize short memory ops
// into longer memory ops, we may want to increase alignment.
bool policy_align( PhaseIdealLoop *phase ) const;
@@ -403,7 +403,7 @@ public:
// Reassociate invariant add and subtract expressions.
Node* reassociate_add_sub(Node* n1, PhaseIdealLoop *phase);
// Return nonzero index of invariant operand if invariant and variant
- // are combined with an Add or Sub. Helper for reassoicate_invariants.
+ // are combined with an Add or Sub. Helper for reassociate_invariants.
int is_invariant_addition(Node* n, PhaseIdealLoop *phase);
// Return true if n is invariant
diff --git a/hotspot/src/share/vm/opto/loopopts.cpp b/hotspot/src/share/vm/opto/loopopts.cpp
index 41048cbcbe9..454c207fd81 100644
--- a/hotspot/src/share/vm/opto/loopopts.cpp
+++ b/hotspot/src/share/vm/opto/loopopts.cpp
@@ -97,7 +97,7 @@ Node *PhaseIdealLoop::split_thru_phi( Node *n, Node *region, int policy ) {
// (Note: This tweaking with igvn only works because x is a new node.)
_igvn.set_type(x, t);
// If x is a TypeNode, capture any more-precise type permanently into Node
- // othewise it will be not updated during igvn->transform since
+ // otherwise it will be not updated during igvn->transform since
// igvn->type(x) is set to x->Value() already.
x->raise_bottom_type(t);
Node *y = x->Identity(&_igvn);
@@ -879,7 +879,7 @@ void PhaseIdealLoop::split_if_with_blocks_post( Node *n ) {
Node *x_ctrl = NULL;
if( u->is_Phi() ) {
// Replace all uses of normal nodes. Replace Phi uses
- // individually, so the seperate Nodes can sink down
+ // individually, so the separate Nodes can sink down
// different paths.
uint k = 1;
while( u->in(k) != n ) k++;
diff --git a/hotspot/src/share/vm/opto/machnode.cpp b/hotspot/src/share/vm/opto/machnode.cpp
index eadd0da5fff..adb7ecb98ba 100644
--- a/hotspot/src/share/vm/opto/machnode.cpp
+++ b/hotspot/src/share/vm/opto/machnode.cpp
@@ -136,7 +136,7 @@ void MachNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
// Size of instruction in bytes
uint MachNode::size(PhaseRegAlloc *ra_) const {
// If a virtual was not defined for this specific instruction,
- // Call the helper which finds the size by emiting the bits.
+ // Call the helper which finds the size by emitting the bits.
return MachNode::emit_size(ra_);
}
diff --git a/hotspot/src/share/vm/opto/macro.cpp b/hotspot/src/share/vm/opto/macro.cpp
index aa8bc492116..5b67f078c06 100644
--- a/hotspot/src/share/vm/opto/macro.cpp
+++ b/hotspot/src/share/vm/opto/macro.cpp
@@ -216,7 +216,7 @@ static Node *scan_mem_chain(Node *mem, int alias_idx, int offset, Node *start_me
const TypeOopPtr *tinst = phase->C->get_adr_type(alias_idx)->isa_oopptr();
while (true) {
if (mem == alloc_mem || mem == start_mem ) {
- return mem; // hit one of our sentinals
+ return mem; // hit one of our sentinels
} else if (mem->is_MergeMem()) {
mem = mem->as_MergeMem()->memory_at(alias_idx);
} else if (mem->is_Proj() && mem->as_Proj()->_con == TypeFunc::Memory) {
@@ -1668,7 +1668,7 @@ void PhaseMacroExpand::expand_lock_node(LockNode *lock) {
if (UseOptoBiasInlining) {
/*
- * See the full descrition in MacroAssembler::biased_locking_enter().
+ * See the full description in MacroAssembler::biased_locking_enter().
*
* if( (mark_word & biased_lock_mask) == biased_lock_pattern ) {
* // The object is biased.
@@ -1904,7 +1904,7 @@ void PhaseMacroExpand::expand_unlock_node(UnlockNode *unlock) {
if (UseOptoBiasInlining) {
// Check for biased locking unlock case, which is a no-op.
- // See the full descrition in MacroAssembler::biased_locking_exit().
+ // See the full description in MacroAssembler::biased_locking_exit().
region = new (C, 4) RegionNode(4);
// create a Phi for the memory state
mem_phi = new (C, 4) PhiNode( region, Type::MEMORY, TypeRawPtr::BOTTOM);
diff --git a/hotspot/src/share/vm/opto/matcher.cpp b/hotspot/src/share/vm/opto/matcher.cpp
index 9f424c0e46d..74c7a70878e 100644
--- a/hotspot/src/share/vm/opto/matcher.cpp
+++ b/hotspot/src/share/vm/opto/matcher.cpp
@@ -897,7 +897,7 @@ Node *Matcher::xform( Node *n, int max_stack ) {
#ifdef ASSERT
_new2old_map.map(m->_idx, n);
#endif
- mstack.push(m, Post_Visit, n, i); // Don't neet to visit
+ mstack.push(m, Post_Visit, n, i); // Don't need to visit
mstack.push(m->in(0), Visit, m, 0);
} else {
mstack.push(m, Visit, n, i);
@@ -1267,7 +1267,7 @@ static bool match_into_reg( const Node *n, Node *m, Node *control, int i, bool s
}
}
- // Not forceably cloning. If shared, put it into a register.
+ // Not forceable cloning. If shared, put it into a register.
return shared;
}
@@ -1542,7 +1542,7 @@ void Matcher::ReduceInst_Chain_Rule( State *s, int rule, Node *&mem, MachNode *m
// This is what my child will give me.
int opnd_class_instance = s->_rule[op];
// Choose between operand class or not.
- // This is what I will recieve.
+ // This is what I will receive.
int catch_op = (FIRST_OPERAND_CLASS <= op && op < NUM_OPERANDS) ? opnd_class_instance : op;
// New rule for child. Chase operand classes to get the actual rule.
int newrule = s->_rule[catch_op];
@@ -1966,7 +1966,7 @@ void Matcher::find_shared( Node *n ) {
// BoolNode::match_edge always returns a zero.
// We reorder the Op_If in a pre-order manner, so we can visit without
- // accidently sharing the Cmp (the Bool and the If make 2 users).
+ // accidentally sharing the Cmp (the Bool and the If make 2 users).
n->add_req( n->in(1)->in(1) ); // Add the Cmp next to the Bool
}
else if (nstate == Post_Visit) {
diff --git a/hotspot/src/share/vm/opto/memnode.cpp b/hotspot/src/share/vm/opto/memnode.cpp
index 95e41e0d592..3d096b248f3 100644
--- a/hotspot/src/share/vm/opto/memnode.cpp
+++ b/hotspot/src/share/vm/opto/memnode.cpp
@@ -100,12 +100,12 @@ Node *MemNode::optimize_simple_memory_chain(Node *mchain, const TypePtr *t_adr,
while (prev != result) {
prev = result;
if (result == start_mem)
- break; // hit one of our sentinals
+ break; // hit one of our sentinels
// skip over a call which does not affect this memory slice
if (result->is_Proj() && result->as_Proj()->_con == TypeFunc::Memory) {
Node *proj_in = result->in(0);
if (proj_in->is_Allocate() && proj_in->_idx == instance_id) {
- break; // hit one of our sentinals
+ break; // hit one of our sentinels
} else if (proj_in->is_Call()) {
CallNode *call = proj_in->as_Call();
if (!call->may_modify(t_adr, phase)) {
@@ -198,7 +198,7 @@ static Node *step_through_mergemem(PhaseGVN *phase, MergeMemNode *mmem, const T
// If not, we can update the input infinitely along a MergeMem cycle
// Equivalent code in PhiNode::Ideal
Node* m = phase->transform(mmem);
- // If tranformed to a MergeMem, get the desired slice
+ // If transformed to a MergeMem, get the desired slice
// Otherwise the returned node represents memory for every slice
mem = (m->is_MergeMem())? m->as_MergeMem()->memory_at(alias_idx) : m;
// Update input if it is progress over what we have now
@@ -970,7 +970,7 @@ Node *LoadNode::Identity( PhaseTransform *phase ) {
}
// Search for an existing data phi which was generated before for the same
- // instance's field to avoid infinite genertion of phis in a loop.
+ // instance's field to avoid infinite generation of phis in a loop.
Node *region = mem->in(0);
if (is_instance_field_load_with_local_phi(region)) {
const TypePtr *addr_t = in(MemNode::Address)->bottom_type()->isa_ptr();
@@ -1254,7 +1254,7 @@ Node *LoadNode::split_through_phi(PhaseGVN *phase) {
// (This tweaking with igvn only works because x is a new node.)
igvn->set_type(x, t);
// If x is a TypeNode, capture any more-precise type permanently into Node
- // othewise it will be not updated during igvn->transform since
+ // otherwise it will be not updated during igvn->transform since
// igvn->type(x) is set to x->Value() already.
x->raise_bottom_type(t);
Node *y = x->Identity(igvn);
@@ -2591,7 +2591,7 @@ Node *MemBarNode::match( const ProjNode *proj, const Matcher *m ) {
// capturing of nearby memory operations.
//
// During macro-expansion, all captured initializations which store
-// constant values of 32 bits or smaller are coalesced (if advantagous)
+// constant values of 32 bits or smaller are coalesced (if advantageous)
// into larger 'tiles' 32 or 64 bits. This allows an object to be
// initialized in fewer memory operations. Memory words which are
// covered by neither tiles nor non-constant stores are pre-zeroed
@@ -3678,7 +3678,7 @@ Node *MergeMemNode::Ideal(PhaseGVN *phase, bool can_reshape) {
else if (old_mmem != NULL) {
new_mem = old_mmem->memory_at(i);
}
- // else preceeding memory was not a MergeMem
+ // else preceding memory was not a MergeMem
// replace equivalent phis (unfortunately, they do not GVN together)
if (new_mem != NULL && new_mem != new_base &&
diff --git a/hotspot/src/share/vm/opto/memnode.hpp b/hotspot/src/share/vm/opto/memnode.hpp
index 63cb0d653f7..3da000dff92 100644
--- a/hotspot/src/share/vm/opto/memnode.hpp
+++ b/hotspot/src/share/vm/opto/memnode.hpp
@@ -757,10 +757,10 @@ public:
// Model. Monitor-enter and volatile-load act as Aquires: no following ref
// can be moved to before them. We insert a MemBar-Acquire after a FastLock or
// volatile-load. Monitor-exit and volatile-store act as Release: no
-// preceeding ref can be moved to after them. We insert a MemBar-Release
+// preceding ref can be moved to after them. We insert a MemBar-Release
// before a FastUnlock or volatile-store. All volatiles need to be
// serialized, so we follow all volatile-stores with a MemBar-Volatile to
-// seperate it from any following volatile-load.
+// separate it from any following volatile-load.
class MemBarNode: public MultiNode {
virtual uint hash() const ; // { return NO_HASH; }
virtual uint cmp( const Node &n ) const ; // Always fail, except on self
diff --git a/hotspot/src/share/vm/opto/node.cpp b/hotspot/src/share/vm/opto/node.cpp
index 9130403ed9d..f7d71d17234 100644
--- a/hotspot/src/share/vm/opto/node.cpp
+++ b/hotspot/src/share/vm/opto/node.cpp
@@ -968,22 +968,23 @@ const Type *Node::Value( PhaseTransform * ) const {
// Example: when reshape "(X+3)+4" into "X+7" you must leave the Node for
// "X+3" unchanged in case it is shared.
//
-// If you modify the 'this' pointer's inputs, you must use 'set_req' with
-// def-use info. If you are making a new Node (either as the new root or
-// some new internal piece) you must NOT use set_req with def-use info.
-// You can make a new Node with either 'new' or 'clone'. In either case,
-// def-use info is (correctly) not generated.
+// If you modify the 'this' pointer's inputs, you should use
+// 'set_req'. If you are making a new Node (either as the new root or
+// some new internal piece) you may use 'init_req' to set the initial
+// value. You can make a new Node with either 'new' or 'clone'. In
+// either case, def-use info is correctly maintained.
+//
// Example: reshape "(X+3)+4" into "X+7":
-// set_req(1,in(1)->in(1) /* grab X */, du /* must use DU on 'this' */);
-// set_req(2,phase->intcon(7),du);
+// set_req(1, in(1)->in(1));
+// set_req(2, phase->intcon(7));
// return this;
-// Example: reshape "X*4" into "X<<1"
-// return new (C,3) LShiftINode( in(1), phase->intcon(1) );
+// Example: reshape "X*4" into "X<<2"
+// return new (C,3) LShiftINode(in(1), phase->intcon(2));
//
// You must call 'phase->transform(X)' on any new Nodes X you make, except
-// for the returned root node. Example: reshape "X*31" with "(X<<5)-1".
+// for the returned root node. Example: reshape "X*31" with "(X<<5)-X".
// Node *shift=phase->transform(new(C,3)LShiftINode(in(1),phase->intcon(5)));
-// return new (C,3) AddINode(shift, phase->intcon(-1));
+// return new (C,3) AddINode(shift, in(1));
//
// When making a Node for a constant use 'phase->makecon' or 'phase->intcon'.
// These forms are faster than 'phase->transform(new (C,1) ConNode())' and Do
@@ -1679,7 +1680,7 @@ void Node::verify_edges(Unique_Node_List &visited) {
if (visited.member(this)) return;
visited.push(this);
- // Walk over all input edges, checking for correspondance
+ // Walk over all input edges, checking for correspondence
for( i = 0; i < len(); i++ ) {
n = in(i);
if (n != NULL && !n->is_top()) {
@@ -1723,7 +1724,7 @@ void Node::verify_recur(const Node *n, int verify_depth,
// Contained in new_space or old_space?
VectorSet *v = C->node_arena()->contains(n) ? &new_space : &old_space;
// Check for visited in the proper space. Numberings are not unique
- // across spaces so we need a seperate VectorSet for each space.
+ // across spaces so we need a separate VectorSet for each space.
if( v->test_set(n->_idx) ) return;
if (n->is_Con() && n->bottom_type() == Type::TOP) {
diff --git a/hotspot/src/share/vm/opto/node.hpp b/hotspot/src/share/vm/opto/node.hpp
index f55a403099a..bad1607058e 100644
--- a/hotspot/src/share/vm/opto/node.hpp
+++ b/hotspot/src/share/vm/opto/node.hpp
@@ -257,7 +257,7 @@ protected:
Node **_in; // Array of use-def references to Nodes
Node **_out; // Array of def-use references to Nodes
- // Input edges are split into two catagories. Required edges are required
+ // Input edges are split into two categories. Required edges are required
// for semantic correctness; order is important and NULLs are allowed.
// Precedence edges are used to help determine execution order and are
// added, e.g., for scheduling purposes. They are unordered and not
@@ -854,7 +854,7 @@ public:
// If the hash function returns the special sentinel value NO_HASH,
// the node is guaranteed never to compare equal to any other node.
- // If we accidently generate a hash with value NO_HASH the node
+ // If we accidentally generate a hash with value NO_HASH the node
// won't go into the table and we'll lose a little optimization.
enum { NO_HASH = 0 };
virtual uint hash() const;
diff --git a/hotspot/src/share/vm/opto/output.cpp b/hotspot/src/share/vm/opto/output.cpp
index 7d6482ccd3c..c29274174e0 100644
--- a/hotspot/src/share/vm/opto/output.cpp
+++ b/hotspot/src/share/vm/opto/output.cpp
@@ -1171,7 +1171,7 @@ void Compile::Fill_buffer() {
cb->flush_bundle(false);
// The following logic is duplicated in the code ifdeffed for
- // ENABLE_ZAP_DEAD_LOCALS which apppears above in this file. It
+ // ENABLE_ZAP_DEAD_LOCALS which appears above in this file. It
// should be factored out. Or maybe dispersed to the nodes?
// Special handling for SafePoint/Call Nodes
@@ -1275,7 +1275,7 @@ void Compile::Fill_buffer() {
}
#ifdef ASSERT
- // Check that oop-store preceeds the card-mark
+ // Check that oop-store precedes the card-mark
else if( mach->ideal_Opcode() == Op_StoreCM ) {
uint storeCM_idx = j;
Node *oop_store = mach->in(mach->_cnt); // First precedence edge
@@ -1291,7 +1291,7 @@ void Compile::Fill_buffer() {
#endif
else if( !n->is_Proj() ) {
- // Remember the begining of the previous instruction, in case
+ // Remember the beginning of the previous instruction, in case
// it's followed by a flag-kill and a null-check. Happens on
// Intel all the time, with add-to-memory kind of opcodes.
previous_offset = current_offset;
@@ -1567,7 +1567,7 @@ Scheduling::Scheduling(Arena *arena, Compile &compile)
compile.set_node_bundling_limit(_node_bundling_limit);
- // This one is persistant within the Compile class
+ // This one is persistent within the Compile class
_node_bundling_base = NEW_ARENA_ARRAY(compile.comp_arena(), Bundle, node_max);
// Allocate space for fixed-size arrays
@@ -1666,7 +1666,7 @@ void Compile::ScheduleAndBundle() {
// Compute the latency of all the instructions. This is fairly simple,
// because we already have a legal ordering. Walk over the instructions
// from first to last, and compute the latency of the instruction based
-// on the latency of the preceeding instruction(s).
+// on the latency of the preceding instruction(s).
void Scheduling::ComputeLocalLatenciesForward(const Block *bb) {
#ifndef PRODUCT
if (_cfg->C->trace_opto_output())
@@ -1931,7 +1931,7 @@ void Scheduling::AddNodeToBundle(Node *n, const Block *bb) {
uint siz = _available.size();
// Conditional branches can support an instruction that
- // is unconditionally executed and not dependant by the
+ // is unconditionally executed and not dependent by the
// branch, OR a conditionally executed instruction if
// the branch is taken. In practice, this means that
// the first instruction at the branch target is
@@ -1947,7 +1947,7 @@ void Scheduling::AddNodeToBundle(Node *n, const Block *bb) {
#endif
// At least 1 instruction is on the available list
- // that is not dependant on the branch
+ // that is not dependent on the branch
for (uint i = 0; i < siz; i++) {
Node *d = _available[i];
const Pipeline *avail_pipeline = d->pipeline();
diff --git a/hotspot/src/share/vm/opto/parse.hpp b/hotspot/src/share/vm/opto/parse.hpp
index d33acba3e7a..e00dfca6a7a 100644
--- a/hotspot/src/share/vm/opto/parse.hpp
+++ b/hotspot/src/share/vm/opto/parse.hpp
@@ -78,7 +78,7 @@ public:
};
// See if it is OK to inline.
- // The reciever is the inline tree for the caller.
+ // The receiver is the inline tree for the caller.
//
// The result is a temperature indication. If it is hot or cold,
// inlining is immediate or undesirable. Otherwise, the info block
diff --git a/hotspot/src/share/vm/opto/parse1.cpp b/hotspot/src/share/vm/opto/parse1.cpp
index b896faca492..12b75fb327f 100644
--- a/hotspot/src/share/vm/opto/parse1.cpp
+++ b/hotspot/src/share/vm/opto/parse1.cpp
@@ -607,7 +607,7 @@ void Parse::do_all_blocks() {
if (control()->is_Region() && !block->is_loop_head() && !has_irreducible && !block->is_handler()) {
// In the absence of irreducible loops, the Region and Phis
// associated with a merge that doesn't involve a backedge can
- // be simplfied now since the RPO parsing order guarantees
+ // be simplified now since the RPO parsing order guarantees
// that any path which was supposed to reach here has already
// been parsed or must be dead.
Node* c = control();
diff --git a/hotspot/src/share/vm/opto/parse2.cpp b/hotspot/src/share/vm/opto/parse2.cpp
index 0f40fdd962e..201ffad99c0 100644
--- a/hotspot/src/share/vm/opto/parse2.cpp
+++ b/hotspot/src/share/vm/opto/parse2.cpp
@@ -32,7 +32,7 @@ extern int explicit_null_checks_inserted,
void Parse::array_load(BasicType elem_type) {
const Type* elem = Type::TOP;
Node* adr = array_addressing(elem_type, 0, &elem);
- if (stopped()) return; // guarenteed null or range check
+ if (stopped()) return; // guaranteed null or range check
_sp -= 2; // Pop array and index
const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(elem_type);
Node* ld = make_load(control(), adr, elem, elem_type, adr_type);
@@ -43,7 +43,7 @@ void Parse::array_load(BasicType elem_type) {
//--------------------------------array_store----------------------------------
void Parse::array_store(BasicType elem_type) {
Node* adr = array_addressing(elem_type, 1);
- if (stopped()) return; // guarenteed null or range check
+ if (stopped()) return; // guaranteed null or range check
Node* val = pop();
_sp -= 2; // Pop array and index
const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(elem_type);
@@ -1541,14 +1541,14 @@ void Parse::do_one_bytecode() {
case Bytecodes::_aaload: array_load(T_OBJECT); break;
case Bytecodes::_laload: {
a = array_addressing(T_LONG, 0);
- if (stopped()) return; // guarenteed null or range check
+ if (stopped()) return; // guaranteed null or range check
_sp -= 2; // Pop array and index
push_pair( make_load(control(), a, TypeLong::LONG, T_LONG, TypeAryPtr::LONGS));
break;
}
case Bytecodes::_daload: {
a = array_addressing(T_DOUBLE, 0);
- if (stopped()) return; // guarenteed null or range check
+ if (stopped()) return; // guaranteed null or range check
_sp -= 2; // Pop array and index
push_pair( make_load(control(), a, Type::DOUBLE, T_DOUBLE, TypeAryPtr::DOUBLES));
break;
@@ -1560,7 +1560,7 @@ void Parse::do_one_bytecode() {
case Bytecodes::_fastore: array_store(T_FLOAT); break;
case Bytecodes::_aastore: {
d = array_addressing(T_OBJECT, 1);
- if (stopped()) return; // guarenteed null or range check
+ if (stopped()) return; // guaranteed null or range check
array_store_check();
c = pop(); // Oop to store
b = pop(); // index (already used)
@@ -1572,7 +1572,7 @@ void Parse::do_one_bytecode() {
}
case Bytecodes::_lastore: {
a = array_addressing(T_LONG, 2);
- if (stopped()) return; // guarenteed null or range check
+ if (stopped()) return; // guaranteed null or range check
c = pop_pair();
_sp -= 2; // Pop array and index
store_to_memory(control(), a, c, T_LONG, TypeAryPtr::LONGS);
@@ -1580,7 +1580,7 @@ void Parse::do_one_bytecode() {
}
case Bytecodes::_dastore: {
a = array_addressing(T_DOUBLE, 2);
- if (stopped()) return; // guarenteed null or range check
+ if (stopped()) return; // guaranteed null or range check
c = pop_pair();
_sp -= 2; // Pop array and index
c = dstore_rounding(c);
diff --git a/hotspot/src/share/vm/opto/phase.cpp b/hotspot/src/share/vm/opto/phase.cpp
index 904214a330f..b0ea80a8242 100644
--- a/hotspot/src/share/vm/opto/phase.cpp
+++ b/hotspot/src/share/vm/opto/phase.cpp
@@ -73,7 +73,7 @@ elapsedTimer Phase::_t_buildOopMaps;
//------------------------------Phase------------------------------------------
Phase::Phase( PhaseNumber pnum ) : _pnum(pnum), C( pnum == Compiler ? NULL : Compile::current()) {
- // Poll for requests from shutdown mechanism to quiesce comiler (4448539, 4448544).
+ // Poll for requests from shutdown mechanism to quiesce compiler (4448539, 4448544).
// This is an effective place to poll, since the compiler is full of phases.
// In particular, every inlining site uses a recursively created Parse phase.
CompileBroker::maybe_block();
diff --git a/hotspot/src/share/vm/opto/phaseX.cpp b/hotspot/src/share/vm/opto/phaseX.cpp
index 484629a90ce..78c48452244 100644
--- a/hotspot/src/share/vm/opto/phaseX.cpp
+++ b/hotspot/src/share/vm/opto/phaseX.cpp
@@ -196,7 +196,7 @@ void NodeHash::hash_insert( Node *n ) {
}
//------------------------------hash_delete------------------------------------
-// Replace in hash table with sentinal
+// Replace in hash table with sentinel
bool NodeHash::hash_delete( const Node *n ) {
Node *k;
uint hash = n->hash();
@@ -207,7 +207,7 @@ bool NodeHash::hash_delete( const Node *n ) {
uint key = hash & (_max-1);
uint stride = key | 0x01;
debug_only( uint counter = 0; );
- for( ; /* (k != NULL) && (k != _sentinal) */; ) {
+ for( ; /* (k != NULL) && (k != _sentinel) */; ) {
debug_only( counter++ );
debug_only( _delete_probes++ );
k = _table[key]; // Get hashed value
@@ -715,7 +715,7 @@ Node *PhaseGVN::transform_no_reclaim( Node *n ) {
#ifdef ASSERT
//------------------------------dead_loop_check--------------------------------
-// Check for a simple dead loop when a data node references itself direcly
+// Check for a simple dead loop when a data node references itself directly
// or through an other data node excluding cons and phis.
void PhaseGVN::dead_loop_check( Node *n ) {
// Phi may reference itself in a loop
@@ -1359,7 +1359,7 @@ void PhaseCCP::analyze() {
worklist.push(p); // Propagate change to user
}
}
- // If we changed the reciever type to a call, we need to revisit
+ // If we changed the receiver type to a call, we need to revisit
// the Catch following the call. It's looking for a non-NULL
// receiver to know when to enable the regular fall-through path
// in addition to the NullPtrException path
diff --git a/hotspot/src/share/vm/opto/postaloc.cpp b/hotspot/src/share/vm/opto/postaloc.cpp
index cd881065f32..fa28c6aa1cc 100644
--- a/hotspot/src/share/vm/opto/postaloc.cpp
+++ b/hotspot/src/share/vm/opto/postaloc.cpp
@@ -46,7 +46,7 @@ bool PhaseChaitin::may_be_copy_of_callee( Node *def ) const {
// be splitting live ranges for callee save registers to such
// an extent that in large methods the chains can be very long
// (50+). The conservative answer is to return true if we don't
- // know as this prevents optimizations from occuring.
+ // know as this prevents optimizations from occurring.
const int limit = 60;
int i;
@@ -286,7 +286,7 @@ bool PhaseChaitin::eliminate_copy_of_constant(Node* val, Node* n,
//
// n will be replaced with the old value but n might have
// kills projections associated with it so remove them now so that
- // yank_if_dead will be able to elminate the copy once the uses
+ // yank_if_dead will be able to eliminate the copy once the uses
// have been transferred to the old[value].
for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) {
Node* use = n->fast_out(i);
diff --git a/hotspot/src/share/vm/opto/reg_split.cpp b/hotspot/src/share/vm/opto/reg_split.cpp
index 003df4c48b7..f3254dc2abd 100644
--- a/hotspot/src/share/vm/opto/reg_split.cpp
+++ b/hotspot/src/share/vm/opto/reg_split.cpp
@@ -26,8 +26,8 @@
#include "incls/_reg_split.cpp.incl"
//------------------------------Split--------------------------------------
-// Walk the graph in RPO and for each lrg which spills, propogate reaching
-// definitions. During propogation, split the live range around regions of
+// Walk the graph in RPO and for each lrg which spills, propagate reaching
+// definitions. During propagation, split the live range around regions of
// High Register Pressure (HRP). If a Def is in a region of Low Register
// Pressure (LRP), it will not get spilled until we encounter a region of
// HRP between it and one of its uses. We will spill at the transition
@@ -88,7 +88,7 @@ Node *PhaseChaitin::get_spillcopy_wide( Node *def, Node *use, uint uidx ) {
}
//------------------------------insert_proj------------------------------------
-// Insert the spill at chosen location. Skip over any interveneing Proj's or
+// Insert the spill at chosen location. Skip over any intervening Proj's or
// Phis. Skip over a CatchNode and projs, inserting in the fall-through block
// instead. Update high-pressure indices. Create a new live range.
void PhaseChaitin::insert_proj( Block *b, uint i, Node *spill, uint maxlrg ) {
@@ -125,7 +125,7 @@ void PhaseChaitin::insert_proj( Block *b, uint i, Node *spill, uint maxlrg ) {
}
//------------------------------split_DEF--------------------------------------
-// There are four catagories of Split; UP/DOWN x DEF/USE
+// There are four categories of Split; UP/DOWN x DEF/USE
// Only three of these really occur as DOWN/USE will always color
// Any Split with a DEF cannot CISC-Spill now. Thus we need
// two helper routines, one for Split DEFS (insert after instruction),
@@ -726,7 +726,7 @@ uint PhaseChaitin::Split( uint maxlrg ) {
// ********** Handle Crossing HRP Boundry **********
if( (insidx == b->_ihrp_index) || (insidx == b->_fhrp_index) ) {
for( slidx = 0; slidx < spill_cnt; slidx++ ) {
- // Check for need to split at HRP boundry - split if UP
+ // Check for need to split at HRP boundary - split if UP
n1 = Reachblock[slidx];
// bail out if no reaching DEF
if( n1 == NULL ) continue;
diff --git a/hotspot/src/share/vm/opto/runtime.cpp b/hotspot/src/share/vm/opto/runtime.cpp
index 7b5effc8182..cbbbfacfcb5 100644
--- a/hotspot/src/share/vm/opto/runtime.cpp
+++ b/hotspot/src/share/vm/opto/runtime.cpp
@@ -1196,7 +1196,7 @@ JRT_END
// The following does not work because for one thing, the
// thread state is wrong; it expects java, but it is native.
-// Also, the invarients in a native stub are different and
+// Also, the invariants in a native stub are different and
// I'm not sure it is safe to have a MachCalRuntimeDirectNode
// in there.
// So for now, we do not zap in native stubs.
diff --git a/hotspot/src/share/vm/opto/split_if.cpp b/hotspot/src/share/vm/opto/split_if.cpp
index 130b2667513..a7a6baaa925 100644
--- a/hotspot/src/share/vm/opto/split_if.cpp
+++ b/hotspot/src/share/vm/opto/split_if.cpp
@@ -318,7 +318,7 @@ Node *PhaseIdealLoop::find_use_block( Node *use, Node *def, Node *old_false, Nod
if( use->is_Phi() ) { // Phi uses in prior block
// Grab the first Phi use; there may be many.
- // Each will be handled as a seperate iteration of
+ // Each will be handled as a separate iteration of
// the "while( phi->outcnt() )" loop.
uint j;
for( j = 1; j < use->req(); j++ )
diff --git a/hotspot/src/share/vm/opto/superword.cpp b/hotspot/src/share/vm/opto/superword.cpp
index 4551162bff3..e0ca68f3187 100644
--- a/hotspot/src/share/vm/opto/superword.cpp
+++ b/hotspot/src/share/vm/opto/superword.cpp
@@ -470,7 +470,7 @@ void SuperWord::mem_slice_preds(Node* start, Node* stop, GrowableArray &p
}
//------------------------------stmts_can_pack---------------------------
-// Can s1 and s2 be in a pack with s1 immediately preceeding s2 and
+// Can s1 and s2 be in a pack with s1 immediately preceding s2 and
// s1 aligned at "align"
bool SuperWord::stmts_can_pack(Node* s1, Node* s2, int align) {
if (isomorphic(s1, s2)) {
@@ -869,7 +869,7 @@ bool SuperWord::profitable(Node_List* p) {
for (uint i = start; i < end; i++) {
if (!is_vector_use(p0, i)) {
// For now, return false if not scalar promotion case (inputs are the same.)
- // Later, implement PackNode and allow differring, non-vector inputs
+ // Later, implement PackNode and allow differing, non-vector inputs
// (maybe just the ones from outside the block.)
Node* p0_def = p0->in(i);
for (uint j = 1; j < p->size(); j++) {
diff --git a/hotspot/src/share/vm/opto/superword.hpp b/hotspot/src/share/vm/opto/superword.hpp
index b60cc83c1f0..1c09607ed7d 100644
--- a/hotspot/src/share/vm/opto/superword.hpp
+++ b/hotspot/src/share/vm/opto/superword.hpp
@@ -308,7 +308,7 @@ class SuperWord : public ResourceObj {
void dependence_graph();
// Return a memory slice (node list) in predecessor order starting at "start"
void mem_slice_preds(Node* start, Node* stop, GrowableArray &preds);
- // Can s1 and s2 be in a pack with s1 immediately preceeding s2 and s1 aligned at "align"
+ // Can s1 and s2 be in a pack with s1 immediately preceding s2 and s1 aligned at "align"
bool stmts_can_pack(Node* s1, Node* s2, int align);
// Does s exist in a pack at position pos?
bool exists_at(Node* s, uint pos);
diff --git a/hotspot/src/share/vm/opto/type.cpp b/hotspot/src/share/vm/opto/type.cpp
index 6830277ea3f..3f250be521b 100644
--- a/hotspot/src/share/vm/opto/type.cpp
+++ b/hotspot/src/share/vm/opto/type.cpp
@@ -2455,7 +2455,7 @@ intptr_t TypeOopPtr::get_con() const {
// code and dereferenced at the time the nmethod is made. Until that time,
// it is not reasonable to do arithmetic with the addresses of oops (we don't
// have access to the addresses!). This does not seem to currently happen,
- // but this assertion here is to help prevent its occurrance.
+ // but this assertion here is to help prevent its occurence.
tty->print_cr("Found oop constant with non-zero offset");
ShouldNotReachHere();
}
@@ -2761,7 +2761,7 @@ const Type *TypeInstPtr::xmeet( const Type *t ) const {
// LCA is object_klass, but if we subclass from the top we can do better
if( above_centerline(_ptr) ) { // if( _ptr == TopPTR || _ptr == AnyNull )
// If 'this' (InstPtr) is above the centerline and it is Object class
- // then we can subclass in the Java class heirarchy.
+ // then we can subclass in the Java class hierarchy.
if (klass()->equals(ciEnv::current()->Object_klass())) {
// that is, tp's array type is a subtype of my klass
return TypeAryPtr::make(ptr, tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id);
@@ -3022,7 +3022,7 @@ ciType* TypeInstPtr::java_mirror_type() const {
//------------------------------xdual------------------------------------------
// Dual: do NOT dual on klasses. This means I do NOT understand the Java
-// inheritence mechanism.
+// inheritance mechanism.
const Type *TypeInstPtr::xdual() const {
return new TypeInstPtr( dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id() );
}
@@ -3176,7 +3176,7 @@ const TypeInt* TypeAryPtr::narrow_size_type(const TypeInt* size) const {
bool chg = false;
if (lo < min_lo) { lo = min_lo; chg = true; }
if (hi > max_hi) { hi = max_hi; chg = true; }
- // Negative length arrays will produce weird intermediate dead fath-path code
+ // Negative length arrays will produce weird intermediate dead fast-path code
if (lo > hi)
return TypeInt::ZERO;
if (!chg)
@@ -3358,7 +3358,7 @@ const Type *TypeAryPtr::xmeet( const Type *t ) const {
// LCA is object_klass, but if we subclass from the top we can do better
if (above_centerline(tp->ptr())) {
// If 'tp' is above the centerline and it is Object class
- // then we can subclass in the Java class heirarchy.
+ // then we can subclass in the Java class hierarchy.
if( tp->klass()->equals(ciEnv::current()->Object_klass()) ) {
// that is, my array type is a subtype of 'tp' klass
return make( ptr, _ary, _klass, _klass_is_exact, offset, instance_id );
diff --git a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp
index 4cc6b577b47..154ab65077f 100644
--- a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp
+++ b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp
@@ -1349,39 +1349,39 @@ bool VM_RedefineClasses::rewrite_cp_refs(instanceKlassHandle scratch_class,
// rewrite constant pool references in the methods:
if (!rewrite_cp_refs_in_methods(scratch_class, THREAD)) {
- // propogate failure back to caller
+ // propagate failure back to caller
return false;
}
// rewrite constant pool references in the class_annotations:
if (!rewrite_cp_refs_in_class_annotations(scratch_class, THREAD)) {
- // propogate failure back to caller
+ // propagate failure back to caller
return false;
}
// rewrite constant pool references in the fields_annotations:
if (!rewrite_cp_refs_in_fields_annotations(scratch_class, THREAD)) {
- // propogate failure back to caller
+ // propagate failure back to caller
return false;
}
// rewrite constant pool references in the methods_annotations:
if (!rewrite_cp_refs_in_methods_annotations(scratch_class, THREAD)) {
- // propogate failure back to caller
+ // propagate failure back to caller
return false;
}
// rewrite constant pool references in the methods_parameter_annotations:
if (!rewrite_cp_refs_in_methods_parameter_annotations(scratch_class,
THREAD)) {
- // propogate failure back to caller
+ // propagate failure back to caller
return false;
}
// rewrite constant pool references in the methods_default_annotations:
if (!rewrite_cp_refs_in_methods_default_annotations(scratch_class,
THREAD)) {
- // propogate failure back to caller
+ // propagate failure back to caller
return false;
}
@@ -1600,7 +1600,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_annotations_typeArray(
byte_i_ref, THREAD)) {
RC_TRACE_WITH_THREAD(0x02000000, THREAD,
("bad annotation_struct at %d", calc_num_annotations));
- // propogate failure back to caller
+ // propagate failure back to caller
return false;
}
}
@@ -1666,7 +1666,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_annotation_struct(
byte_i_ref, THREAD)) {
RC_TRACE_WITH_THREAD(0x02000000, THREAD,
("bad element_value at %d", calc_num_element_value_pairs));
- // propogate failure back to caller
+ // propagate failure back to caller
return false;
}
} // end for each component
@@ -1815,7 +1815,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_element_value(
// field. This is a nested annotation.
if (!rewrite_cp_refs_in_annotation_struct(annotations_typeArray,
byte_i_ref, THREAD)) {
- // propogate failure back to caller
+ // propagate failure back to caller
return false;
}
break;
@@ -1842,7 +1842,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_element_value(
annotations_typeArray, byte_i_ref, THREAD)) {
RC_TRACE_WITH_THREAD(0x02000000, THREAD,
("bad nested element_value at %d", calc_num_values));
- // propogate failure back to caller
+ // propagate failure back to caller
return false;
}
}
@@ -1886,7 +1886,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_fields_annotations(
THREAD)) {
RC_TRACE_WITH_THREAD(0x02000000, THREAD,
("bad field_annotations at %d", i));
- // propogate failure back to caller
+ // propagate failure back to caller
return false;
}
}
@@ -1923,7 +1923,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_methods_annotations(
THREAD)) {
RC_TRACE_WITH_THREAD(0x02000000, THREAD,
("bad method_annotations at %d", i));
- // propogate failure back to caller
+ // propagate failure back to caller
return false;
}
}
@@ -1991,7 +1991,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_methods_parameter_annotations(
method_parameter_annotations, byte_i, THREAD)) {
RC_TRACE_WITH_THREAD(0x02000000, THREAD,
("bad method_parameter_annotations at %d", calc_num_parameters));
- // propogate failure back to caller
+ // propagate failure back to caller
return false;
}
}
@@ -2041,7 +2041,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_methods_default_annotations(
method_default_annotations, byte_i, THREAD)) {
RC_TRACE_WITH_THREAD(0x02000000, THREAD,
("bad default element_value at %d", i));
- // propogate failure back to caller
+ // propagate failure back to caller
return false;
}
}
diff --git a/hotspot/src/share/vm/runtime/extendedPC.hpp b/hotspot/src/share/vm/runtime/extendedPC.hpp
index a2680851adc..19ce2a51447 100644
--- a/hotspot/src/share/vm/runtime/extendedPC.hpp
+++ b/hotspot/src/share/vm/runtime/extendedPC.hpp
@@ -23,7 +23,7 @@
*/
// An ExtendedPC contains the _pc from a signal handler in a platform
-// independant way.
+// independent way.
class ExtendedPC VALUE_OBJ_CLASS_SPEC {
private:
diff --git a/hotspot/src/share/vm/runtime/fprofiler.cpp b/hotspot/src/share/vm/runtime/fprofiler.cpp
index adecc642de4..87554e371f2 100644
--- a/hotspot/src/share/vm/runtime/fprofiler.cpp
+++ b/hotspot/src/share/vm/runtime/fprofiler.cpp
@@ -988,7 +988,7 @@ extern "C" void find(int x);
void ThreadProfiler::record_tick_for_running_frame(JavaThread* thread, frame fr) {
- // The tick happend in real code -> non VM code
+ // The tick happened in real code -> non VM code
if (fr.is_interpreted_frame()) {
interval_data_ref()->inc_interpreted();
record_interpreted_tick(thread, fr, tp_code, FlatProfiler::bytecode_ticks);
@@ -1019,7 +1019,7 @@ void ThreadProfiler::record_tick_for_running_frame(JavaThread* thread, frame fr)
}
void ThreadProfiler::record_tick_for_calling_frame(JavaThread* thread, frame fr) {
- // The tick happend in VM code
+ // The tick happened in VM code
interval_data_ref()->inc_native();
if (fr.is_interpreted_frame()) {
record_interpreted_tick(thread, fr, tp_native, FlatProfiler::bytecode_ticks_stub);
diff --git a/hotspot/src/share/vm/runtime/frame.cpp b/hotspot/src/share/vm/runtime/frame.cpp
index e84d6d3ad8b..8d53406e41b 100644
--- a/hotspot/src/share/vm/runtime/frame.cpp
+++ b/hotspot/src/share/vm/runtime/frame.cpp
@@ -930,7 +930,7 @@ void frame::oops_interpreted_do(OopClosure* f, const RegisterMap* map, bool quer
// => process callee's arguments
//
// Note: The expression stack can be empty if an exception
- // occured during method resolution/execution. In all
+ // occurred during method resolution/execution. In all
// cases we empty the expression stack completely be-
// fore handling the exception (the exception handling
// code in the interpreter calls a blocking runtime
diff --git a/hotspot/src/share/vm/runtime/frame.inline.hpp b/hotspot/src/share/vm/runtime/frame.inline.hpp
index 3449ead761a..95acb8dbbda 100644
--- a/hotspot/src/share/vm/runtime/frame.inline.hpp
+++ b/hotspot/src/share/vm/runtime/frame.inline.hpp
@@ -22,7 +22,7 @@
*
*/
-// This file holds platform-independant bodies of inline functions for frames.
+// This file holds platform-independent bodies of inline functions for frames.
// Note: The bcx usually contains the bcp; however during GC it contains the bci
// (changed by gc_prologue() and gc_epilogue()) to be methodOop position
diff --git a/hotspot/src/share/vm/runtime/mutex.hpp b/hotspot/src/share/vm/runtime/mutex.hpp
index edebb8800ae..f0b9e8bd79d 100644
--- a/hotspot/src/share/vm/runtime/mutex.hpp
+++ b/hotspot/src/share/vm/runtime/mutex.hpp
@@ -82,7 +82,7 @@ class ParkEvent ;
// *in that order*. If their implementations change such that these
// assumptions are violated, a whole lot of code will break.
-// The default length of monitor name is choosen to be 64 to avoid false sharing.
+// The default length of monitor name is chosen to be 64 to avoid false sharing.
static const int MONITOR_NAME_LEN = 64;
class Monitor : public CHeapObj {
diff --git a/hotspot/src/share/vm/runtime/orderAccess.hpp b/hotspot/src/share/vm/runtime/orderAccess.hpp
index a2040ed8488..c51a9229735 100644
--- a/hotspot/src/share/vm/runtime/orderAccess.hpp
+++ b/hotspot/src/share/vm/runtime/orderAccess.hpp
@@ -31,7 +31,7 @@
// at runtime.
//
// In the following, the terms 'previous', 'subsequent', 'before',
-// 'after', 'preceeding' and 'succeeding' refer to program order. The
+// 'after', 'preceding' and 'succeeding' refer to program order. The
// terms 'down' and 'below' refer to forward load or store motion
// relative to program order, while 'up' and 'above' refer to backward
// motion.
diff --git a/hotspot/src/share/vm/runtime/os.cpp b/hotspot/src/share/vm/runtime/os.cpp
index 8c81d42734a..de8f12a2ca9 100644
--- a/hotspot/src/share/vm/runtime/os.cpp
+++ b/hotspot/src/share/vm/runtime/os.cpp
@@ -943,7 +943,7 @@ bool os::stack_shadow_pages_available(Thread *thread, methodHandle method) {
assert(StackRedPages > 0 && StackYellowPages > 0,"Sanity check");
address sp = current_stack_pointer();
// Check if we have StackShadowPages above the yellow zone. This parameter
- // is dependant on the depth of the maximum VM call stack possible from
+ // is dependent on the depth of the maximum VM call stack possible from
// the handler for stack overflow. 'instanceof' in the stack overflow
// handler or a println uses at least 8k stack of VM and native code
// respectively.
diff --git a/hotspot/src/share/vm/runtime/safepoint.cpp b/hotspot/src/share/vm/runtime/safepoint.cpp
index c13af643a85..32af64a23e7 100644
--- a/hotspot/src/share/vm/runtime/safepoint.cpp
+++ b/hotspot/src/share/vm/runtime/safepoint.cpp
@@ -369,7 +369,7 @@ void SafepointSynchronize::end() {
// Start suspended threads
for(JavaThread *current = Threads::first(); current; current = current->next()) {
- // A problem occuring on Solaris is when attempting to restart threads
+ // A problem occurring on Solaris is when attempting to restart threads
// the first #cpus - 1 go well, but then the VMThread is preempted when we get
// to the next one (since it has been running the longest). We then have
// to wait for a cpu to become available before we can continue restarting
diff --git a/hotspot/src/share/vm/runtime/signature.hpp b/hotspot/src/share/vm/runtime/signature.hpp
index 51b45a0a063..9b506d32902 100644
--- a/hotspot/src/share/vm/runtime/signature.hpp
+++ b/hotspot/src/share/vm/runtime/signature.hpp
@@ -266,7 +266,7 @@ class Fingerprinter: public SignatureIterator {
class NativeSignatureIterator: public SignatureIterator {
private:
methodHandle _method;
-// We need seperate JNI and Java offset values because in 64 bit mode,
+// We need separate JNI and Java offset values because in 64 bit mode,
// the argument offsets are not in sync with the Java stack.
// For example a long takes up 1 "C" stack entry but 2 Java stack entries.
int _offset; // The java stack offset
diff --git a/hotspot/src/share/vm/runtime/threadCritical.hpp b/hotspot/src/share/vm/runtime/threadCritical.hpp
index 6f8529512e2..42b43379b5d 100644
--- a/hotspot/src/share/vm/runtime/threadCritical.hpp
+++ b/hotspot/src/share/vm/runtime/threadCritical.hpp
@@ -29,7 +29,7 @@
//
// Due to race conditions during vm exit, some of the os level
// synchronization primitives may not be deallocated at exit. It
-// is a good plan to implement the platform dependant sections of
+// is a good plan to implement the platform dependent sections of
// code with resources that are recoverable during process
// cleanup by the os. Calling the initialize method before use
// is also problematic, it is best to use preinitialized primitives
diff --git a/hotspot/src/share/vm/utilities/globalDefinitions.hpp b/hotspot/src/share/vm/utilities/globalDefinitions.hpp
index 0a9b8f2a2f3..757910c17b6 100644
--- a/hotspot/src/share/vm/utilities/globalDefinitions.hpp
+++ b/hotspot/src/share/vm/utilities/globalDefinitions.hpp
@@ -881,7 +881,7 @@ inline int log2_intptr(intptr_t x) {
i++; p *= 2;
}
// p = 2^(i+1) && x < p (i.e., 2^i <= x < 2^(i+1))
- // (if p = 0 then overflow occured and i = 31)
+ // (if p = 0 then overflow occurred and i = 31)
return i;
}
@@ -895,7 +895,7 @@ inline int log2_long(jlong x) {
i++; p *= 2;
}
// p = 2^(i+1) && x < p (i.e., 2^i <= x < 2^(i+1))
- // (if p = 0 then overflow occured and i = 63)
+ // (if p = 0 then overflow occurred and i = 63)
return i;
}
From 50208648879aa897d02648e9e642d5be7ab6f115 Mon Sep 17 00:00:00 2001
From: Bhavesh Patel
Date: Fri, 27 Feb 2009 18:57:17 -0800
Subject: [PATCH 070/292] 6786690: Javadoc HTML WCAG 2.0 accessibility issues
in standard doclet - DL tag and nesting issue
Reviewed-by: jjg
---
.../formats/html/AbstractIndexWriter.java | 36 +-
.../formats/html/AbstractMemberWriter.java | 33 +-
...nnotationTypeOptionalMemberWriterImpl.java | 28 +-
...nnotationTypeRequiredMemberWriterImpl.java | 20 +-
.../html/AnnotationTypeWriterImpl.java | 6 +-
.../doclets/formats/html/ClassWriterImpl.java | 26 +-
.../formats/html/ConstructorWriterImpl.java | 24 +-
.../formats/html/EnumConstantWriterImpl.java | 22 +-
.../doclets/formats/html/FieldWriterImpl.java | 20 +-
.../formats/html/HtmlDocletWriter.java | 63 ++-
.../formats/html/HtmlSerialFieldWriter.java | 84 ++--
.../formats/html/HtmlSerialMethodWriter.java | 24 +-
.../formats/html/MethodWriterImpl.java | 25 +-
.../formats/html/NestedClassWriterImpl.java | 7 +-
.../formats/html/PackageTreeWriter.java | 7 +-
.../formats/html/TagletWriterImpl.java | 35 +-
.../doclets/formats/html/TreeWriter.java | 8 +-
.../formats/html/markup/HtmlDocWriter.java | 25 ++
.../formats/html/markup/HtmlWriter.java | 18 +-
.../toolkit/SerializedFormWriter.java | 32 +-
.../builders/SerializedFormBuilder.java | 25 +-
.../internal/toolkit/resources/doclet.xml | 410 +++++++++---------
.../com/sun/javadoc/AuthorDD/AuthorDD.java | 2 +-
.../TestClassCrossReferences.java | 2 +-
.../TestConstructorIndent.java | 7 +-
.../TestDeprecatedDocs.java | 5 +-
.../TestExternalOverridenMethod.java | 4 +-
.../com/sun/javadoc/testHref/TestHref.java | 2 +-
.../TestHtmlDefinitionListTag.java | 370 ++++++++++++++++
.../testHtmlDefinitionListTag/pkg1/C1.java | 108 +++++
.../testHtmlDefinitionListTag/pkg1/C2.java | 86 ++++
.../testHtmlDefinitionListTag/pkg1/C3.java | 42 ++
.../testHtmlDefinitionListTag/pkg1/C4.java | 39 ++
.../testHtmlDefinitionListTag/pkg1/C5.java | 65 +++
.../com/sun/javadoc/testIndex/TestIndex.java | 4 +-
.../javadoc/testInterface/TestInterface.java | 12 +-
.../testLinkOption/TestLinkOption.java | 3 +-
.../testLinkTaglet/TestLinkTaglet.java | 2 +-
.../TestMemberInheritence.java | 2 +-
.../TestNewLanguageFeatures.java | 30 +-
.../TestOverridenPrivateMethods.java | 12 +-
...verridenPrivateMethodsWithPackageFlag.java | 12 +-
...verridenPrivateMethodsWithPrivateFlag.java | 12 +-
.../testParamTaglet/TestParamTaglet.java | 4 +-
.../TestPrivateClasses.java | 18 +-
.../TestSerializedFormDeprecationInfo.java | 52 +--
.../javadoc/testThrowsTag/TestThrowsTag.java | 16 +-
47 files changed, 1360 insertions(+), 529 deletions(-)
create mode 100644 langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java
create mode 100644 langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C1.java
create mode 100644 langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C2.java
create mode 100644 langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C3.java
create mode 100644 langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C4.java
create mode 100644 langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C5.java
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java
index a7cad980bbc..0809e184705 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java
@@ -25,12 +25,12 @@
package com.sun.tools.doclets.formats.html;
-import com.sun.tools.doclets.internal.toolkit.util.*;
-
-import com.sun.javadoc.*;
import java.io.*;
import java.util.*;
+import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
+
/**
* Generate Index for all the Member Names with Indexing in
* Unicode Order. This class is a base class for {@link SingleIndexWriter} and
@@ -100,18 +100,22 @@ public class AbstractIndexWriter extends HtmlDocletWriter {
h2();
strong(unicode.toString());
h2End();
- dl();
- for (int i = 0; i < memberlist.size(); i++) {
- Doc element = memberlist.get(i);
- if (element instanceof MemberDoc) {
- printDescription((MemberDoc)element);
- } else if (element instanceof ClassDoc) {
- printDescription((ClassDoc)element);
- } else if (element instanceof PackageDoc) {
- printDescription((PackageDoc)element);
+ int memberListSize = memberlist.size();
+ // Display the list only if there are elements to be displayed.
+ if (memberListSize > 0) {
+ dl();
+ for (int i = 0; i < memberListSize; i++) {
+ Doc element = memberlist.get(i);
+ if (element instanceof MemberDoc) {
+ printDescription((MemberDoc)element);
+ } else if (element instanceof ClassDoc) {
+ printDescription((ClassDoc)element);
+ } else if (element instanceof PackageDoc) {
+ printDescription((PackageDoc)element);
+ }
}
+ dlEnd();
}
- dlEnd();
hr();
}
@@ -126,8 +130,10 @@ public class AbstractIndexWriter extends HtmlDocletWriter {
printPackageLink(pkg, Util.getPackageName(pkg), true);
print(" - ");
print(configuration.getText("doclet.package") + " " + pkg.name());
+ dtEnd();
dd();
printSummaryComment(pkg);
+ ddEnd();
}
/**
@@ -140,8 +146,10 @@ public class AbstractIndexWriter extends HtmlDocletWriter {
printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_INDEX, cd, true));
print(" - ");
printClassInfo(cd);
+ dtEnd();
dd();
printComment(cd);
+ ddEnd();
}
/**
@@ -178,8 +186,10 @@ public class AbstractIndexWriter extends HtmlDocletWriter {
println(" - ");
printMemberDesc(member);
println();
+ dtEnd();
dd();
printComment(member);
+ ddEnd();
println();
}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java
index 268dbe009fb..d6c298f13da 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java
@@ -25,12 +25,12 @@
package com.sun.tools.doclets.formats.html;
-import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.tools.doclets.internal.toolkit.taglets.*;
+import java.lang.reflect.Modifier;
+import java.util.*;
import com.sun.javadoc.*;
-import java.util.*;
-import java.lang.reflect.Modifier;
+import com.sun.tools.doclets.internal.toolkit.util.*;
+import com.sun.tools.doclets.internal.toolkit.taglets.*;
/**
* The base class for member writers.
@@ -38,6 +38,7 @@ import java.lang.reflect.Modifier;
* @author Robert Field
* @author Atul M Dambalkar
* @author Jamie Ho (Re-write)
+ * @author Bhavesh Patel (Modified)
*/
public abstract class AbstractMemberWriter {
@@ -232,10 +233,26 @@ public abstract class AbstractMemberWriter {
}
}
+ /**
+ * Print the deprecated output for the given member.
+ *
+ * @param member the member being documented.
+ */
+ protected void printDeprecated(ProgramElementDoc member) {
+ String output = (new DeprecatedTaglet()).getTagletOutput(member,
+ writer.getTagletWriterInstance(false)).toString().trim();
+ if (!output.isEmpty()) {
+ writer.printMemberDetailsListStartTag();
+ writer.print(output);
+ }
+ }
+
protected void printComment(ProgramElementDoc member) {
if (member.inlineTags().length > 0) {
+ writer.printMemberDetailsListStartTag();
writer.dd();
writer.printInlineComment(member);
+ writer.ddEnd();
}
}
@@ -266,6 +283,14 @@ public abstract class AbstractMemberWriter {
writer.printTags(member);
}
+ /**
+ * Write the member footer.
+ */
+ protected void printMemberFooter() {
+ writer.printMemberDetailsListEndTag();
+ assert !writer.getMemberDetailsListPrinted();
+ }
+
/**
* Forward to containing writer
*/
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java
index 570f27542dd..1442e3ccf0c 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java
@@ -25,11 +25,11 @@
package com.sun.tools.doclets.formats.html;
-import com.sun.tools.doclets.internal.toolkit.*;
-import com.sun.javadoc.*;
-
import java.io.*;
+import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+
/**
* Writes annotation type optional member documentation in HTML format.
*
@@ -63,14 +63,20 @@ public class AnnotationTypeOptionalMemberWriterImpl extends
* {@inheritDoc}
*/
public void writeDefaultValueInfo(MemberDoc member) {
- writer.dl();
- writer.dt();
- writer.strong(ConfigurationImpl.getInstance().
- getText("doclet.Default"));
- writer.dd();
- writer.print(((AnnotationTypeElementDoc) member).defaultValue());
- writer.ddEnd();
- writer.dlEnd();
+ if (((AnnotationTypeElementDoc) member).defaultValue() != null) {
+ writer.printMemberDetailsListStartTag();
+ writer.dd();
+ writer.dl();
+ writer.dt();
+ writer.strong(ConfigurationImpl.getInstance().
+ getText("doclet.Default"));
+ writer.dtEnd();
+ writer.dd();
+ writer.print(((AnnotationTypeElementDoc) member).defaultValue());
+ writer.ddEnd();
+ writer.dlEnd();
+ writer.ddEnd();
+ }
}
/**
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java
index 801ec8a241d..01e517ce426 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java
@@ -25,12 +25,11 @@
package com.sun.tools.doclets.formats.html;
-import com.sun.tools.doclets.internal.toolkit.*;
-import com.sun.tools.doclets.internal.toolkit.taglets.*;
-import com.sun.javadoc.*;
-
import java.io.*;
+import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+
/**
* Writes annotation type required member documentation in HTML format.
*
@@ -134,17 +133,14 @@ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter
strong(member.name());
}
writer.preEnd();
- writer.dl();
+ assert !writer.getMemberDetailsListPrinted();
}
/**
* {@inheritDoc}
*/
public void writeComments(MemberDoc member) {
- if (member.inlineTags().length > 0) {
- writer.dd();
- writer.printInlineComment(member);
- }
+ printComment(member);
}
/**
@@ -160,7 +156,7 @@ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter
* Write the annotation type member footer.
*/
public void writeMemberFooter() {
- writer.dlEnd();
+ printMemberFooter();
}
/**
@@ -267,9 +263,7 @@ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter
* {@inheritDoc}
*/
public void writeDeprecated(MemberDoc member) {
- print(((TagletOutputImpl)
- (new DeprecatedTaglet()).getTagletOutput(member,
- writer.getTagletWriterInstance(false))).toString());
+ printDeprecated(member);
}
private Type getType(MemberDoc member) {
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java
index fc2527db89b..594ce856a05 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java
@@ -25,10 +25,10 @@
package com.sun.tools.doclets.formats.html;
+import com.sun.javadoc.*;
import com.sun.tools.doclets.internal.toolkit.*;
import com.sun.tools.doclets.internal.toolkit.util.*;
import com.sun.tools.doclets.internal.toolkit.builders.*;
-import com.sun.javadoc.*;
/**
* Generate the Class Information Page.
@@ -165,8 +165,6 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
* {@inheritDoc}
*/
public void writeAnnotationTypeSignature(String modifiers) {
- dl();
- dt();
preNoNewLine();
writeAnnotationInfo(annotationType);
print(modifiers);
@@ -178,7 +176,6 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
} else {
strong(name);
}
- dlEnd();
preEnd();
p();
}
@@ -334,6 +331,7 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
} else {
strongText("doclet.Enclosing_Class");
}
+ dtEnd();
dd();
printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS, outerClass,
false));
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java
index c15f76367dc..8044b42dcbf 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java
@@ -25,12 +25,12 @@
package com.sun.tools.doclets.formats.html;
+import java.util.*;
+
+import com.sun.javadoc.*;
import com.sun.tools.doclets.internal.toolkit.*;
import com.sun.tools.doclets.internal.toolkit.util.*;
import com.sun.tools.doclets.internal.toolkit.builders.*;
-import com.sun.javadoc.*;
-
-import java.util.*;
import com.sun.tools.doclets.internal.toolkit.taglets.*;
/**
@@ -171,8 +171,6 @@ public class ClassWriterImpl extends SubWriterHolderWriter
*/
public void writeClassSignature(String modifiers) {
boolean isInterface = classDoc.isInterface();
- dl();
- dt();
preNoNewLine();
writeAnnotationInfo(classDoc);
print(modifiers);
@@ -191,7 +189,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter
Type superclass = Util.getFirstVisibleSuperClass(classDoc,
configuration());
if (superclass != null) {
- dt();
+ println();
print("extends ");
printLink(new LinkInfoImpl(
LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME,
@@ -208,7 +206,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter
continue;
}
if (counter == 0) {
- dt();
+ println();
print(isInterface? "extends " : "implements ");
} else {
print(", ");
@@ -219,7 +217,6 @@ public class ClassWriterImpl extends SubWriterHolderWriter
counter++;
}
}
- dlEnd();
preEnd();
p();
}
@@ -342,6 +339,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter
TagletOutput output = (new ParamTaglet()).getTagletOutput(classDoc,
getTagletWriterInstance(false));
print(output.toString());
+ dtEnd();
dlEnd();
}
}
@@ -360,8 +358,10 @@ public class ClassWriterImpl extends SubWriterHolderWriter
dl();
dt();
strongText("doclet.Subclasses");
+ dtEnd();
writeClassLinks(LinkInfoImpl.CONTEXT_SUBCLASSES,
subclasses);
+ dlEnd();
}
}
}
@@ -376,8 +376,10 @@ public class ClassWriterImpl extends SubWriterHolderWriter
dl();
dt();
strongText("doclet.Subinterfaces");
+ dtEnd();
writeClassLinks(LinkInfoImpl.CONTEXT_SUBINTERFACES,
subInterfaces);
+ dlEnd();
}
}
}
@@ -398,8 +400,10 @@ public class ClassWriterImpl extends SubWriterHolderWriter
dl();
dt();
strongText("doclet.Implementing_Classes");
+ dtEnd();
writeClassLinks(LinkInfoImpl.CONTEXT_IMPLEMENTED_CLASSES,
implcl);
+ dlEnd();
}
}
@@ -414,8 +418,10 @@ public class ClassWriterImpl extends SubWriterHolderWriter
dl();
dt();
strongText("doclet.All_Implemented_Interfaces");
+ dtEnd();
writeClassLinks(LinkInfoImpl.CONTEXT_IMPLEMENTED_INTERFACES,
interfaceArray);
+ dlEnd();
}
}
@@ -430,8 +436,10 @@ public class ClassWriterImpl extends SubWriterHolderWriter
dl();
dt();
strongText("doclet.All_Superinterfaces");
+ dtEnd();
writeClassLinks(LinkInfoImpl.CONTEXT_SUPER_INTERFACES,
interfaceArray);
+ dlEnd();
}
}
@@ -455,7 +463,6 @@ public class ClassWriterImpl extends SubWriterHolderWriter
}
}
ddEnd();
- dlEnd();
}
protected void navLinkTree() {
@@ -574,6 +581,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter
} else {
strongText("doclet.Enclosing_Class");
}
+ dtEnd();
dd();
printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS, outerClass,
false));
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java
index 72d2e7ca4c5..cb5adbdeeaf 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java
@@ -25,12 +25,12 @@
package com.sun.tools.doclets.formats.html;
+import java.io.*;
+import java.util.*;
+
+import com.sun.javadoc.*;
import com.sun.tools.doclets.internal.toolkit.*;
import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.tools.doclets.internal.toolkit.taglets.*;
-import com.sun.javadoc.*;
-import java.util.*;
-import java.io.*;
/**
* Writes constructor documentation.
@@ -149,7 +149,7 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter
writeParameters(constructor);
writeExceptions(constructor);
writer.preEnd();
- writer.dl();
+ assert !writer.getMemberDetailsListPrinted();
}
/**
@@ -158,12 +158,7 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter
* @param constructor the constructor being documented.
*/
public void writeDeprecated(ConstructorDoc constructor) {
- String output = ((TagletOutputImpl)
- (new DeprecatedTaglet()).getTagletOutput(constructor,
- writer.getTagletWriterInstance(false))).toString();
- if (output != null && output.trim().length() > 0) {
- writer.print(output);
- }
+ printDeprecated(constructor);
}
/**
@@ -172,10 +167,7 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter
* @param constructor the constructor being documented.
*/
public void writeComments(ConstructorDoc constructor) {
- if (constructor.inlineTags().length > 0) {
- writer.dd();
- writer.printInlineComment(constructor);
- }
+ printComment(constructor);
}
/**
@@ -191,7 +183,7 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter
* Write the constructor footer.
*/
public void writeConstructorFooter() {
- writer.dlEnd();
+ printMemberFooter();
}
/**
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java
index 226d9086eeb..1d5b4ffbd29 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java
@@ -25,13 +25,12 @@
package com.sun.tools.doclets.formats.html;
-import com.sun.tools.doclets.internal.toolkit.*;
-import com.sun.tools.doclets.internal.toolkit.taglets.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.javadoc.*;
-
import java.io.*;
+import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
+
/**
* Writes enum constant documentation in HTML format.
*
@@ -146,26 +145,21 @@ public class EnumConstantWriterImpl extends AbstractMemberWriter
strong(enumConstant.name());
}
writer.preEnd();
- writer.dl();
+ assert !writer.getMemberDetailsListPrinted();
}
/**
* {@inheritDoc}
*/
public void writeDeprecated(FieldDoc enumConstant) {
- print(((TagletOutputImpl)
- (new DeprecatedTaglet()).getTagletOutput(enumConstant,
- writer.getTagletWriterInstance(false))).toString());
+ printDeprecated(enumConstant);
}
/**
* {@inheritDoc}
*/
public void writeComments(FieldDoc enumConstant) {
- if (enumConstant.inlineTags().length > 0) {
- writer.dd();
- writer.printInlineComment(enumConstant);
- }
+ printComment(enumConstant);
}
/**
@@ -179,7 +173,7 @@ public class EnumConstantWriterImpl extends AbstractMemberWriter
* {@inheritDoc}
*/
public void writeEnumConstantFooter() {
- writer.dlEnd();
+ printMemberFooter();
}
/**
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java
index cf37e9ad958..bd97166b8ab 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java
@@ -25,13 +25,12 @@
package com.sun.tools.doclets.formats.html;
-import com.sun.tools.doclets.internal.toolkit.*;
-import com.sun.tools.doclets.internal.toolkit.taglets.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.javadoc.*;
-
import java.io.*;
+import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
+
/**
* Writes field documentation in HTML format.
*
@@ -156,7 +155,7 @@ public class FieldWriterImpl extends AbstractMemberWriter
strong(field.name());
}
writer.preEnd();
- writer.dl();
+ assert !writer.getMemberDetailsListPrinted();
}
/**
@@ -165,9 +164,7 @@ public class FieldWriterImpl extends AbstractMemberWriter
* @param field the field being documented.
*/
public void writeDeprecated(FieldDoc field) {
- print(((TagletOutputImpl)
- (new DeprecatedTaglet()).getTagletOutput(field,
- writer.getTagletWriterInstance(false))).toString());
+ printDeprecated(field);
}
/**
@@ -178,10 +175,12 @@ public class FieldWriterImpl extends AbstractMemberWriter
public void writeComments(FieldDoc field) {
ClassDoc holder = field.containingClass();
if (field.inlineTags().length > 0) {
+ writer.printMemberDetailsListStartTag();
if (holder.equals(classdoc) ||
(! (holder.isPublic() || Util.isLinkable(holder, configuration())))) {
writer.dd();
writer.printInlineComment(field);
+ writer.ddEnd();
} else {
String classlink = writer.codeText(
writer.getDocLink(LinkInfoImpl.CONTEXT_FIELD_DOC_COPY,
@@ -196,6 +195,7 @@ public class FieldWriterImpl extends AbstractMemberWriter
writer.ddEnd();
writer.dd();
writer.printInlineComment(field);
+ writer.ddEnd();
}
}
}
@@ -213,7 +213,7 @@ public class FieldWriterImpl extends AbstractMemberWriter
* Write the field footer.
*/
public void writeFieldFooter() {
- writer.dlEnd();
+ printMemberFooter();
}
/**
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
index 352eeb7010b..8f15eee3ab6 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
@@ -24,17 +24,16 @@
*/
package com.sun.tools.doclets.formats.html;
-import com.sun.tools.doclets.formats.html.markup.*;
-import com.sun.tools.doclets.internal.toolkit.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.tools.doclets.internal.toolkit.taglets.*;
-
-import com.sun.javadoc.*;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;
+import com.sun.javadoc.*;
+import com.sun.tools.doclets.formats.html.markup.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
+import com.sun.tools.doclets.internal.toolkit.taglets.*;
/**
* Class for the Html Format Code Generation specific to JavaDoc.
@@ -44,6 +43,7 @@ import java.util.*;
* @since 1.2
* @author Atul M Dambalkar
* @author Robert Field
+ * @author Bhavesh Patel (Modified)
*/
public class HtmlDocletWriter extends HtmlDocWriter {
@@ -205,7 +205,13 @@ public class HtmlDocletWriter extends HtmlDocWriter {
private void printMethodInfo(MethodDoc method) {
ClassDoc[] intfacs = method.containingClass().interfaces();
MethodDoc overriddenMethod = method.overriddenMethod();
- if (intfacs.length > 0 || overriddenMethod != null) {
+ // Check whether there is any implementation or overridden info to be
+ // printed. If no overridden or implementation info needs to be
+ // printed, do not print this section.
+ if ((intfacs.length > 0 &&
+ new ImplementedMethods(method, this.configuration).build().length > 0) ||
+ overriddenMethod != null) {
+ printMemberDetailsListStartTag();
dd();
printTagsInfoHeader();
MethodWriterImpl.printImplementsInfo(this, method);
@@ -216,7 +222,6 @@ public class HtmlDocletWriter extends HtmlDocWriter {
printTagsInfoFooter();
ddEnd();
}
- dd();
}
protected void printTags(Doc doc) {
@@ -230,41 +235,35 @@ public class HtmlDocletWriter extends HtmlDocWriter {
TagletWriter.genTagOuput(configuration.tagletManager, doc,
configuration.tagletManager.getCustomTags(doc),
getTagletWriterInstance(false), output);
- if (output.toString().trim().length() > 0) {
- printTagsInfoHeader();
- print(output.toString());
- printTagsInfoFooter();
- } else if (! (doc instanceof ConstructorDoc ||
- doc instanceof RootDoc || doc instanceof ClassDoc)) {
- //To be consistent with 1.4.2 output.
- //I hate to do this but we have to pass the diff test to prove
- //nothing has broken.
+ String outputString = output.toString().trim();
+ // For RootDoc and ClassDoc, this section is not the definition description
+ // but the start of definition list.
+ if (!outputString.isEmpty()) {
+ if (!(doc instanceof RootDoc || doc instanceof ClassDoc)) {
+ printMemberDetailsListStartTag();
+ dd();
+ }
printTagsInfoHeader();
+ print(outputString);
printTagsInfoFooter();
+ if (!(doc instanceof RootDoc || doc instanceof ClassDoc))
+ ddEnd();
}
}
/**
- * Check whether there are any tags to be printed.
+ * Check whether there are any tags for Serialization Overview
+ * section to be printed.
*
- * @param doc the Doc object to check for tags.
+ * @param field the FieldDoc object to check for tags.
* @return true if there are tags to be printed else return false.
*/
- protected boolean hasTagsToPrint(Doc doc) {
- if (doc instanceof MethodDoc) {
- ClassDoc[] intfacs = ((MethodDoc)doc).containingClass().interfaces();
- MethodDoc overriddenMethod = ((MethodDoc)doc).overriddenMethod();
- if ((intfacs.length > 0 &&
- new ImplementedMethods((MethodDoc)doc, this.configuration).build().length > 0) ||
- overriddenMethod != null) {
- return true;
- }
- }
+ protected boolean hasSerializationOverviewTags(FieldDoc field) {
TagletOutputImpl output = new TagletOutputImpl("");
- TagletWriter.genTagOuput(configuration.tagletManager, doc,
- configuration.tagletManager.getCustomTags(doc),
+ TagletWriter.genTagOuput(configuration.tagletManager, field,
+ configuration.tagletManager.getCustomTags(field),
getTagletWriterInstance(false), output);
- return (output.toString().trim().isEmpty());
+ return (!output.toString().trim().isEmpty());
}
/**
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java
index 3e84b00dbb6..15508ed643b 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java
@@ -25,11 +25,12 @@
package com.sun.tools.doclets.formats.html;
+import java.util.*;
+
+import com.sun.javadoc.*;
import com.sun.tools.doclets.internal.toolkit.*;
import com.sun.tools.doclets.internal.toolkit.taglets.*;
import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.javadoc.*;
-import java.util.*;
/**
* Generate serialized form for serializable fields.
@@ -37,6 +38,7 @@ import java.util.*;
* serialField
is processed.
*
* @author Joe Fialli
+ * @author Bhavesh Patel (Modified)
*/
public class HtmlSerialFieldWriter extends FieldWriterImpl
implements SerializedFormWriter.SerialFieldWriter {
@@ -75,7 +77,7 @@ public class HtmlSerialFieldWriter extends FieldWriterImpl
writer.println();
if (heading.equals(
configuration().getText("doclet.Serialized_Form_class"))) {
- writer.dl();
+ assert !writer.getMemberDetailsListPrinted();
}
} else {
writer.printTableHeadingBackground(heading);
@@ -102,7 +104,7 @@ public class HtmlSerialFieldWriter extends FieldWriterImpl
print(fieldDimensions + ' ');
strong(fieldName);
writer.preEnd();
- writer.dl();
+ assert !writer.getMemberDetailsListPrinted();
}
/**
@@ -111,9 +113,7 @@ public class HtmlSerialFieldWriter extends FieldWriterImpl
* @param field the field to document.
*/
public void writeMemberDeprecatedInfo(FieldDoc field) {
- print(((TagletOutputImpl)
- (new DeprecatedTaglet()).getTagletOutput(field,
- writer.getTagletWriterInstance(false))).toString());
+ printDeprecated(field);
}
/**
@@ -123,14 +123,17 @@ public class HtmlSerialFieldWriter extends FieldWriterImpl
*/
public void writeMemberDescription(FieldDoc field) {
if (field.inlineTags().length > 0) {
+ writer.printMemberDetailsListStartTag();
writer.dd();
writer.printInlineComment(field);
+ writer.ddEnd();
}
Tag[] tags = field.tags("serial");
if (tags.length > 0) {
- writer.dt();
+ writer.printMemberDetailsListStartTag();
writer.dd();
writer.printInlineComment(field, tags[0]);
+ writer.ddEnd();
}
}
@@ -140,9 +143,14 @@ public class HtmlSerialFieldWriter extends FieldWriterImpl
* @param serialFieldTag the field to document (represented by tag).
*/
public void writeMemberDescription(SerialFieldTag serialFieldTag) {
- writer.dd();
- writer.print(serialFieldTag.description());
- writer.dlEnd();
+ String serialFieldTagDesc = serialFieldTag.description().trim();
+ if (!serialFieldTagDesc.isEmpty()) {
+ writer.dl();
+ writer.dd();
+ writer.print(serialFieldTagDesc);
+ writer.ddEnd();
+ writer.dlEnd();
+ }
}
/**
@@ -151,33 +159,57 @@ public class HtmlSerialFieldWriter extends FieldWriterImpl
* @param field the field to document.
*/
public void writeMemberTags(FieldDoc field) {
- writer.dl();
TagletOutputImpl output = new TagletOutputImpl("");
TagletWriter.genTagOuput(configuration().tagletManager, field,
configuration().tagletManager.getCustomTags(field),
writer.getTagletWriterInstance(false), output);
- if (output.toString().length() > 0) {
- print(output.toString());
+ String outputString = output.toString().trim();
+ if (!outputString.isEmpty()) {
+ writer.printMemberDetailsListStartTag();
+ writer.dd();
+ writer.dl();
+ print(outputString);
+ writer.dlEnd();
+ writer.ddEnd();
}
- writer.dlEnd();
- }
- public void writeMemberFooter(FieldDoc member) {
- writer.dlEnd();
}
/**
- * Check to see if member details should be printed. If
+ * Check to see if overview details should be printed. If
* nocomment option set or if there is no text to be printed
- * for deprecation info, inline comment, no serial tag or inline tags,
- * do not print member details.
+ * for deprecation info, comment or tags, do not print overview details.
+ *
+ * @param field the field to check overview details for.
+ * @return true if overview details need to be printed
*/
- public boolean shouldPrintMemberDetails(FieldDoc field) {
- if (!configuration().nocomment)
- if((field.inlineTags().length > 0) ||
- (field.tags("serial").length > 0) || (writer.hasTagsToPrint(field)))
+ public boolean shouldPrintOverview(FieldDoc field) {
+ if (!configuration().nocomment) {
+ if(!field.commentText().isEmpty() ||
+ writer.hasSerializationOverviewTags(field))
return true;
- if (!Util.isDeprecated(field))
+ }
+ if (field.tags("deprecated").length > 0)
return true;
return false;
}
+
+ public void writeMemberFooter() {
+ printMemberFooter();
+ }
+
+ /**
+ * Write the footer information. If the serilization overview section was
+ * printed, check for definition list and close list tag.
+ *
+ * @param heading the heading that was written.
+ */
+ public void writeFooter(String heading) {
+ if (printedOverallAnchor) {
+ if (heading.equals(
+ configuration().getText("doclet.Serialized_Form_class"))) {
+ writer.printMemberDetailsListEndTag();
+ assert !writer.getMemberDetailsListPrinted();
+ }
+ }
+ }
}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java
index 9c0daf8e8cf..083ee7f25cd 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java
@@ -25,9 +25,9 @@
package com.sun.tools.doclets.formats.html;
+import com.sun.javadoc.*;
import com.sun.tools.doclets.internal.toolkit.*;
import com.sun.tools.doclets.internal.toolkit.taglets.*;
-import com.sun.javadoc.*;
/**
* Generate serialized form for Serializable/Externalizable methods.
@@ -66,14 +66,12 @@ public class HtmlSerialMethodWriter extends MethodWriterImpl implements
writeSignature(member);
}
- public void writeMemberFooter(MethodDoc member) {
- writer.dlEnd();
+ public void writeMemberFooter() {
+ printMemberFooter();
}
public void writeDeprecatedMemberInfo(MethodDoc member) {
- print(((TagletOutputImpl)
- (new DeprecatedTaglet()).getTagletOutput(member,
- writer.getTagletWriterInstance(false))).toString());
+ printDeprecated(member);
}
public void writeMemberDescription(MethodDoc member) {
@@ -81,23 +79,27 @@ public class HtmlSerialMethodWriter extends MethodWriterImpl implements
}
public void writeMemberTags(MethodDoc member) {
- writer.dd();
- writer.dl();
TagletOutputImpl output = new TagletOutputImpl("");
TagletManager tagletManager =
ConfigurationImpl.getInstance().tagletManager;
TagletWriter.genTagOuput(tagletManager, member,
tagletManager.getSerializedFormTags(),
writer.getTagletWriterInstance(false), output);
- print(output.toString());
+ String outputString = output.toString().trim();
+ if (!outputString.isEmpty()) {
+ writer.printMemberDetailsListStartTag();
+ writer.dd();
+ writer.dl();
+ print(outputString);
+ writer.dlEnd();
+ writer.ddEnd();
+ }
MethodDoc method = member;
if (method.name().compareTo("writeExternal") == 0
&& method.tags("serialData").length == 0) {
serialWarning(member.position(), "doclet.MissingSerialDataTag",
method.containingClass().qualifiedName(), method.name());
}
- writer.ddEnd();
- writer.dlEnd();
}
protected void printTypeLinkNoDimension(Type type) {
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java
index 7a4da14b0d6..a74283179b3 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java
@@ -25,13 +25,13 @@
package com.sun.tools.doclets.formats.html;
+import java.io.*;
+
+import com.sun.javadoc.*;
import com.sun.tools.doclets.internal.toolkit.*;
import com.sun.tools.doclets.internal.toolkit.util.*;
import com.sun.tools.doclets.internal.toolkit.taglets.*;
-import java.io.*;
-import com.sun.javadoc.*;
-
/**
* Writes method documentation in HTML format.
*
@@ -172,7 +172,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
writeParameters(method);
writeExceptions(method);
writer.preEnd();
- writer.dl();
+ assert !writer.getMemberDetailsListPrinted();
}
/**
@@ -181,12 +181,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
* @param method the method being documented.
*/
public void writeDeprecated(MethodDoc method) {
- String output = ((TagletOutputImpl)
- (new DeprecatedTaglet()).getTagletOutput(method,
- writer.getTagletWriterInstance(false))).toString();
- if (output != null && output.trim().length() > 0) {
- writer.print(output);
- }
+ printDeprecated(method);
}
/**
@@ -197,11 +192,13 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
public void writeComments(Type holder, MethodDoc method) {
ClassDoc holderClassDoc = holder.asClassDoc();
if (method.inlineTags().length > 0) {
+ writer.printMemberDetailsListStartTag();
if (holder.asClassDoc().equals(classdoc) ||
(! (holderClassDoc.isPublic() ||
Util.isLinkable(holderClassDoc, configuration())))) {
writer.dd();
writer.printInlineComment(method);
+ writer.ddEnd();
} else {
String classlink = writer.codeText(
writer.getDocLink(LinkInfoImpl.CONTEXT_METHOD_DOC_COPY,
@@ -217,6 +214,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
writer.ddEnd();
writer.dd();
writer.printInlineComment(method);
+ writer.ddEnd();
}
}
}
@@ -234,8 +232,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
* Write the method footer.
*/
public void writeMethodFooter() {
- writer.ddEnd();
- writer.dlEnd();
+ printMemberFooter();
}
/**
@@ -318,6 +315,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
String name = method.name();
writer.dt();
writer.strongText(label);
+ writer.dtEnd();
writer.dd();
String methLink = writer.codeText(
writer.getLink(
@@ -326,6 +324,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
writer.getAnchor(method), name, false)
));
writer.printText("doclet.in_class", methLink, overriddenTypeLink);
+ writer.ddEnd();
}
}
@@ -364,11 +363,13 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
LinkInfoImpl.CONTEXT_METHOD_SPECIFIED_BY, intfac)));
writer.dt();
writer.strongText("doclet.Specified_By");
+ writer.dtEnd();
writer.dd();
methlink = writer.codeText(writer.getDocLink(
LinkInfoImpl.CONTEXT_MEMBER, implementedMeth,
implementedMeth.name(), false));
writer.printText("doclet.in_interface", methlink, intfaclink);
+ writer.ddEnd();
}
}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java
index 2b3d2ea3709..23803455ad1 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java
@@ -25,11 +25,11 @@
package com.sun.tools.doclets.formats.html;
+import java.io.*;
+
+import com.sun.javadoc.*;
import com.sun.tools.doclets.internal.toolkit.*;
import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.javadoc.*;
-
-import java.io.*;
/**
* Writes nested class documentation in HTML format.
@@ -129,7 +129,6 @@ public class NestedClassWriterImpl extends AbstractMemberWriter
writer.println("");
}
writer.anchor(nestedClass.name());
- writer.dl();
writer.h3();
writer.print(nestedClass.name());
writer.h3End();
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java
index 638c6d4d75f..12f6d4e0466 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java
@@ -25,10 +25,11 @@
package com.sun.tools.doclets.formats.html;
-import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.javadoc.*;
import java.io.*;
+import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
+
/**
* Class to generate Tree page for a package. The name of the file generated is
* "package-tree.html" and it is generated in the respective package directory.
@@ -145,8 +146,10 @@ public class PackageTreeWriter extends AbstractTreeWriter {
dl();
dt();
strongText("doclet.Package_Hierarchies");
+ dtEnd();
dd();
navLinkMainTree(configuration.getText("doclet.All_Packages"));
+ ddEnd();
dlEnd();
hr();
}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java
index 353937f630a..e83e6f9bdfe 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java
@@ -25,17 +25,18 @@
package com.sun.tools.doclets.formats.html;
+import com.sun.javadoc.*;
import com.sun.tools.doclets.internal.toolkit.*;
import com.sun.tools.doclets.internal.toolkit.builders.SerializedFormBuilder;
import com.sun.tools.doclets.internal.toolkit.taglets.*;
import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.javadoc.*;
/**
* The taglet writer that writes HTML.
*
* @since 1.5
* @author Jamie Ho
+ * @author Bhavesh Patel (Modified)
*/
public class TagletWriterImpl extends TagletWriter {
@@ -99,11 +100,12 @@ public class TagletWriterImpl extends TagletWriter {
output.append(DocletConstants.NL + "" +
DocletConstants.NL);
}
+ output.append("");
} else {
if (Util.isDeprecated(member.containingClass())) {
output.append("
" +
ConfigurationImpl.getInstance().
- getText("doclet.Deprecated") + " ");
+ getText("doclet.Deprecated") + " ");
}
}
}
@@ -123,7 +125,7 @@ public class TagletWriterImpl extends TagletWriter {
public TagletOutput getParamHeader(String header) {
StringBuffer result = new StringBuffer();
result.append("");
- result.append("" + header + "");
+ result.append("" + header + "");
return new TagletOutputImpl(result.toString());
}
@@ -132,7 +134,7 @@ public class TagletWriterImpl extends TagletWriter {
*/
public TagletOutput paramTagOutput(ParamTag paramTag, String paramName) {
TagletOutput result = new TagletOutputImpl("" + paramName + "
"
- + " - " + htmlWriter.commentTagsToString(paramTag, null, paramTag.inlineTags(), false));
+ + " - " + htmlWriter.commentTagsToString(paramTag, null, paramTag.inlineTags(), false) + "");
return result;
}
@@ -142,9 +144,9 @@ public class TagletWriterImpl extends TagletWriter {
public TagletOutput returnTagOutput(Tag returnTag) {
TagletOutput result = new TagletOutputImpl(DocletConstants.NL + "" +
"" + htmlWriter.configuration.getText("doclet.Returns") +
- "" + "" +
+ "" + "" + "" +
htmlWriter.commentTagsToString(returnTag, null, returnTag.inlineTags(),
- false));
+ false) + "");
return result;
}
@@ -174,22 +176,21 @@ public class TagletWriterImpl extends TagletWriter {
}
if (holder.isClass() && ((ClassDoc)holder).isSerializable()) {
//Automatically add link to serialized form page for serializable classes.
- if (!(SerializedFormBuilder.serialInclude(holder) &&
+ if ((SerializedFormBuilder.serialInclude(holder) &&
SerializedFormBuilder.serialInclude(((ClassDoc)holder).containingPackage()))) {
- return result.equals("") ? null : new TagletOutputImpl(result);
+ result = addSeeHeader(result);
+ result += htmlWriter.getHyperLink(htmlWriter.relativePath + "serialized-form.html",
+ ((ClassDoc)holder).qualifiedName(), htmlWriter.configuration.getText("doclet.Serialized_Form"), false);
}
- result = addSeeHeader(result);
- result += htmlWriter.getHyperLink(htmlWriter.relativePath + "serialized-form.html",
- ((ClassDoc)holder).qualifiedName(), htmlWriter.configuration.getText("doclet.Serialized_Form"), false);
}
- return result.equals("") ? null : new TagletOutputImpl(result);
+ return result.equals("") ? null : new TagletOutputImpl(result + "");
}
private String addSeeHeader(String result) {
if (result != null && result.length() > 0) {
return result + ", " + DocletConstants.NL;
} else {
- return "" + htmlWriter.configuration().getText("doclet.See_Also") + "";
+ return "" + htmlWriter.configuration().getText("doclet.See_Also") + "";
}
}
@@ -205,7 +206,8 @@ public class TagletWriterImpl extends TagletWriter {
}
result += htmlWriter.commentTagsToString(simpleTags[i], null, simpleTags[i].inlineTags(), false);
}
- return new TagletOutputImpl(result + "" + DocletConstants.NL);
+ result += "" + DocletConstants.NL;
+ return new TagletOutputImpl(result);
}
/**
@@ -222,7 +224,7 @@ public class TagletWriterImpl extends TagletWriter {
*/
public TagletOutput getThrowsHeader() {
return new TagletOutputImpl(DocletConstants.NL + "" + "" +
- htmlWriter.configuration().getText("doclet.Throws") + "");
+ htmlWriter.configuration().getText("doclet.Throws") + "");
}
/**
@@ -241,6 +243,7 @@ public class TagletWriterImpl extends TagletWriter {
if (text != null && text.toString().length() > 0) {
result += " - " + text;
}
+ result += "";
return new TagletOutputImpl(result);
}
@@ -250,7 +253,7 @@ public class TagletWriterImpl extends TagletWriter {
public TagletOutput throwsTagOutput(Type throwsType) {
return new TagletOutputImpl(DocletConstants.NL + "" +
htmlWriter.codeText(htmlWriter.getLink(
- new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER, throwsType))));
+ new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER, throwsType))) + "");
}
/**
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java
index 669cd1c86a1..7760df955d9 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java
@@ -25,9 +25,11 @@
package com.sun.tools.doclets.formats.html;
-import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.javadoc.*;
import java.io.*;
+
+import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
+
/**
* Generate Class Hierarchy page for all the Classes in this run. Use
* ClassTree for building the Tree. The name of
@@ -120,6 +122,7 @@ public class TreeWriter extends AbstractTreeWriter {
dl();
dt();
strongText("doclet.Package_Hierarchies");
+ dtEnd();
dd();
for (int i = 0; i < packages.length; i++) {
if (packages[i].name().length() == 0) {
@@ -131,6 +134,7 @@ public class TreeWriter extends AbstractTreeWriter {
print(", ");
}
}
+ ddEnd();
dlEnd();
hr();
}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java
index d4cdd39b1ce..64cfd6aba92 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java
@@ -244,6 +244,31 @@ public abstract class HtmlDocWriter extends HtmlWriter {
return "";
}
+ /**
+ * Keep track of member details list. Print the definition list start tag
+ * if it is not printed yet.
+ */
+ public void printMemberDetailsListStartTag () {
+ if (!getMemberDetailsListPrinted()) {
+ dl();
+ memberDetailsListPrinted = true;
+ }
+ }
+
+ /**
+ * Print the definition list end tag if the list start tag was printed.
+ */
+ public void printMemberDetailsListEndTag () {
+ if (getMemberDetailsListPrinted()) {
+ dlEnd();
+ memberDetailsListPrinted = false;
+ }
+ }
+
+ public boolean getMemberDetailsListPrinted() {
+ return memberDetailsListPrinted;
+ }
+
/**
* Print the frameset version of the Html file header.
* Called only when generating an HTML frameset file.
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
index cdafe1be907..60e4c2fb0ac 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
@@ -25,9 +25,10 @@
package com.sun.tools.doclets.formats.html.markup;
+import java.io.*;
+
import com.sun.tools.doclets.internal.toolkit.*;
import com.sun.tools.doclets.internal.toolkit.util.*;
-import java.io.*;
/**
* Class for the Html format code generation.
@@ -60,6 +61,11 @@ public class HtmlWriter extends PrintWriter {
*/
protected Configuration configuration;
+ /**
+ * The flag to indicate whether a member details list is printed or not.
+ */
+ protected boolean memberDetailsListPrinted;
+
/**
* Constructor.
*
@@ -79,6 +85,7 @@ public class HtmlWriter extends PrintWriter {
super(Util.genWriter(configuration, path, filename, docencoding));
this.configuration = configuration;
htmlFilename = filename;
+ this.memberDetailsListPrinted = false;
}
/**
@@ -529,7 +536,14 @@ public class HtmlWriter extends PrintWriter {
}
/**
- * Print <DT> tag.
+ * Print </DT> tag.
+ */
+ public void dtEnd() {
+ print("");
+ }
+
+ /**
+ * Print <DD> tag.
*/
public void dd() {
print("");
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/SerializedFormWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/SerializedFormWriter.java
index d1de4df22dd..9104a5e4b8f 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/SerializedFormWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/SerializedFormWriter.java
@@ -25,9 +25,10 @@
package com.sun.tools.doclets.internal.toolkit;
-import com.sun.javadoc.*;
import java.io.*;
+import com.sun.javadoc.*;
+
/**
* The interface for writing serialized form output.
*
@@ -147,22 +148,27 @@ public interface SerializedFormWriter {
String fieldDimensions, String fieldName);
/**
- * Write the footer.
- *
- * @param member the member to write the header for.
+ * Write the member footer.
*/
- public void writeMemberFooter(FieldDoc member);
+ public void writeMemberFooter();
/**
- * Check to see if member details should be printed. If
+ * Check to see if overview details should be printed. If
* nocomment option set or if there is no text to be printed
- * for deprecation info, inline comment, no serial tag or inline tags,
- * do not print member details.
+ * for deprecation info, inline comment or tags,
+ * do not print overview details.
*
- * @param member the member to check details for.
- * @return true if details need to be printed
+ * @param field the field to check overview details for.
+ * @return true if overview details need to be printed
*/
- public boolean shouldPrintMemberDetails(FieldDoc member);
+ public boolean shouldPrintOverview(FieldDoc field);
+
+ /**
+ * Write the footer.
+ *
+ * @param heading the heading that was written.
+ */
+ public void writeFooter (String heading);
}
/**
@@ -193,10 +199,8 @@ public interface SerializedFormWriter {
/**
* Write the footer.
- *
- * @param member the member to write the header for.
*/
- public void writeMemberFooter(MethodDoc member);
+ public void writeMemberFooter();
/**
* Write the deprecated information for this member.
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java
index 1434bc0cd0a..8275da40dfa 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java
@@ -25,13 +25,14 @@
package com.sun.tools.doclets.internal.toolkit.builders;
-import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.tools.doclets.internal.toolkit.*;
-import com.sun.javadoc.*;
import java.io.*;
import java.lang.reflect.*;
import java.util.*;
+import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+
/**
* Builds the serialized form.
*
@@ -40,6 +41,7 @@ import java.util.*;
* Do not use it as an API
*
* @author Jamie Ho
+ * @author Bhavesh Patel (Modified)
* @since 1.5
*/
public class SerializedFormBuilder extends AbstractBuilder {
@@ -379,7 +381,7 @@ public class SerializedFormBuilder extends AbstractBuilder {
* Build the method footer.
*/
public void buildMethodFooter() {
- methodWriter.writeMemberFooter((MethodDoc) currentMember);
+ methodWriter.writeMemberFooter();
}
/**
@@ -405,15 +407,18 @@ public class SerializedFormBuilder extends AbstractBuilder {
Util.asList(classDoc.serializableFields()).get(0);
// Check to see if there are inline comments, tags or deprecation
// information to be printed.
- if (fieldWriter.shouldPrintMemberDetails(serialPersistentField)) {
+ if (fieldWriter.shouldPrintOverview(serialPersistentField)) {
fieldWriter.writeHeader(
- configuration.getText("doclet.Serialized_Form_class"));
+ configuration.getText("doclet.Serialized_Form_class"));
fieldWriter.writeMemberDeprecatedInfo(serialPersistentField);
if (!configuration.nocomment) {
fieldWriter.writeMemberDescription(serialPersistentField);
fieldWriter.writeMemberTags(serialPersistentField);
}
- fieldWriter.writeMemberFooter(serialPersistentField);
+ // Footer required to close the definition list tag
+ // for serialization overview.
+ fieldWriter.writeFooter(
+ configuration.getText("doclet.Serialized_Form_class"));
}
}
}
@@ -476,11 +481,11 @@ public class SerializedFormBuilder extends AbstractBuilder {
}
/**
- * Build the field footer.
+ * Build the field sub footer.
*/
- public void buildFieldFooter() {
+ public void buildFieldSubFooter() {
if (! currentClass.definesSerializableFields()) {
- fieldWriter.writeMemberFooter((FieldDoc) currentMember);
+ fieldWriter.writeMemberFooter();
}
}
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml
index 8eaa2d77abc..9c4d93a1761 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml
@@ -1,205 +1,205 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/langtools/test/com/sun/javadoc/AuthorDD/AuthorDD.java b/langtools/test/com/sun/javadoc/AuthorDD/AuthorDD.java
index 68d4f9ce596..0c5d56e811f 100644
--- a/langtools/test/com/sun/javadoc/AuthorDD/AuthorDD.java
+++ b/langtools/test/com/sun/javadoc/AuthorDD/AuthorDD.java
@@ -91,7 +91,7 @@ public class AuthorDD
// Test multiple @author tags:
- { "Author:"+NL+" Doug Kramer, Jamie, Neal"+NL,
+ { "Author:"+NL+" Doug Kramer, Jamie, Neal",
BUGID + FS + "p1" + FS + "C1.html" },
};
diff --git a/langtools/test/com/sun/javadoc/testClassCrossReferences/TestClassCrossReferences.java b/langtools/test/com/sun/javadoc/testClassCrossReferences/TestClassCrossReferences.java
index ced91ed79c1..51a488322a2 100644
--- a/langtools/test/com/sun/javadoc/testClassCrossReferences/TestClassCrossReferences.java
+++ b/langtools/test/com/sun/javadoc/testClassCrossReferences/TestClassCrossReferences.java
@@ -48,7 +48,7 @@ public class TestClassCrossReferences extends JavadocTester {
"Link to external member gcd
"},
{BUG_ID + FS + "C.html",
- "Overrides:toString
in class java.lang.Object
"}
+ "Overrides:toString
in class java.lang.Object
"}
};
private static final String[][] NEGATED_TEST = NO_TEST;
private static final String[] ARGS =
diff --git a/langtools/test/com/sun/javadoc/testConstructorIndent/TestConstructorIndent.java b/langtools/test/com/sun/javadoc/testConstructorIndent/TestConstructorIndent.java
index cd892a4e31d..ed27a7b4bac 100644
--- a/langtools/test/com/sun/javadoc/testConstructorIndent/TestConstructorIndent.java
+++ b/langtools/test/com/sun/javadoc/testConstructorIndent/TestConstructorIndent.java
@@ -45,9 +45,10 @@ public class TestConstructorIndent extends JavadocTester {
//Input for string search tests.
private static final String[][] TEST = {
- {BUG_ID + FS + "C.html", ""+NL+"- This is just a simple constructor."+ NL +
- "
"+NL+"
"+NL+"- Parameters:
i
- a param.
"+NL +
- "
"
+ {BUG_ID + FS + "C.html", "" + NL + "- This is just a simple constructor." + NL +
+ "
" + NL + "
" + NL + "" + NL + "- Parameters:" +
+ "
i
- a param.
" + NL +
+ " " + NL + "
"
}
};
private static final String[][] NEGATED_TEST = NO_TEST;
diff --git a/langtools/test/com/sun/javadoc/testDeprecatedDocs/TestDeprecatedDocs.java b/langtools/test/com/sun/javadoc/testDeprecatedDocs/TestDeprecatedDocs.java
index ab11813e95e..ef36c8c03bf 100644
--- a/langtools/test/com/sun/javadoc/testDeprecatedDocs/TestDeprecatedDocs.java
+++ b/langtools/test/com/sun/javadoc/testDeprecatedDocs/TestDeprecatedDocs.java
@@ -78,13 +78,12 @@ public class TestDeprecatedDocs extends JavadocTester {
{TARGET_FILE2, "Deprecated." + NL +
"" + NL +
- "
" + NL +
- "@Deprecated" + NL +
+ "@Deprecated" + NL +
"public class DeprecatedClassByAnnotation"},
{TARGET_FILE2, "public int field
" + NL +
"" + NL +
- "- Deprecated.
"},
+ "- Deprecated.
"},
{TARGET_FILE2, "@Deprecated" + NL +
"public DeprecatedClassByAnnotation()
" + NL +
diff --git a/langtools/test/com/sun/javadoc/testExternalOverridenMethod/TestExternalOverridenMethod.java b/langtools/test/com/sun/javadoc/testExternalOverridenMethod/TestExternalOverridenMethod.java
index 4308ccfe27f..204b1a9772e 100644
--- a/langtools/test/com/sun/javadoc/testExternalOverridenMethod/TestExternalOverridenMethod.java
+++ b/langtools/test/com/sun/javadoc/testExternalOverridenMethod/TestExternalOverridenMethod.java
@@ -39,13 +39,13 @@ public class TestExternalOverridenMethod extends JavadocTester {
private static final String BUG_ID = "4857717";
private static final String[][] TEST = {
{BUG_ID + FS + "pkg" + FS + "XReader.html",
- "Overrides:Overrides:read
in class " +
"FilterReader"},
{BUG_ID + FS + "pkg" + FS + "XReader.html",
- "Specified by:Specified by:readInt
in interface " +
"- "
+ "See Also:
- "
},
//Header does not link to the page itself.
diff --git a/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java b/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java
new file mode 100644
index 00000000000..5fa8db63ca5
--- /dev/null
+++ b/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java
@@ -0,0 +1,370 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6786690
+ * @summary This test verifies the nesting of definition list tags.
+ * @author Bhavesh Patel
+ * @library ../lib/
+ * @build JavadocTester
+ * @build TestHtmlDefinitionListTag
+ * @run main TestHtmlDefinitionListTag
+ */
+
+public class TestHtmlDefinitionListTag extends JavadocTester {
+
+ private static final String BUG_ID = "6786690";
+
+ // Test common to all runs of javadoc. The class signature should print
+ // properly enclosed definition list tags and the Annotation Type
+ // Optional Element should print properly nested definition list tags
+ // for default value.
+ private static final String[][] TEST_ALL = {
+ {BUG_ID + FS + "pkg1" + FS + "C1.html", "
public class " +
+ "C1" + NL + "extends " +
+ "java.lang.Object" + NL + "implements " +
+ "java.io.Serializable
"},
+ {BUG_ID + FS + "pkg1" + FS + "C4.html", "" + NL + "" + NL +
+ "- Default:
- true
" + NL +
+ "
" + NL + " " + NL + "
"}};
+
+ // Test for normal run of javadoc in which various ClassDocs and
+ // serialized form should have properly nested definition list tags
+ // enclosing comments, tags and deprecated information.
+ private static final String[][] TEST_CMNT_DEPR = {
+ {BUG_ID + FS + "pkg1" + FS + "C1.html", "" + NL +
+ "- Since:
" + NL +
+ " - JDK1.0
" + NL + "- See Also:
- " +
+ "" +
+ "
C2
, " + NL +
+ "" +
+ "Serialized Form
"},
+ {BUG_ID + FS + "pkg1" + FS + "C1.html", "" + NL +
+ "- Deprecated. As of JDK version" +
+ " 1.5, replaced by" + NL +
+ " " +
+ "
setUndecorated(boolean)
. " +
+ "- This field indicates whether the C1 is undecorated." + NL +
+ "
" + NL + "
" + NL + "" + NL + "- " +
+ "Since:
" + NL + " - 1.4
" + NL + "- " +
+ "See Also:
- " +
+ "
" +
+ "setUndecorated(boolean)
" + NL +" " + NL +
+ "
"},
+ {BUG_ID + FS + "pkg1" + FS + "C1.html", "" + NL +
+ "- Constructor." + NL + "
" + NL + "
" + NL +
+ "" + NL + "- Parameters:
- " +
+ "
title
- the title test
" +
+ " - boolean value " + NL + "- Throws:
" + NL +
+ "java.lang.IllegalArgumentException
" +
+ " - if the owner
's" + NL + " GraphicsConfiguration" +
+ "
is not from a screen device " + NL +"" +
+ "HeadlessException
" + NL + " " + NL +
+ "
"},
+ {BUG_ID + FS + "pkg1" + FS + "C1.html", "" + NL +
+ "- Method comments." + NL + "
" + NL +
+ "
" + NL + "" + NL + "- Parameters:" +
+ "
undecorated
- true
" +
+ " if no decorations are" + NL + " to be enabled;" + NL +
+ " false
if decorations are to be enabled." +
+ "- Since:
" + NL +
+ " - 1.4
" + NL + "- See Also:
" +
+ "" +
+ "readObject()
" + NL + " " + NL +
+ "
"},
+ {BUG_ID + FS + "pkg1" + FS + "C1.html", "" + NL + "" + NL +
+ "- Throws:
" + NL + "" +
+ "java.io.IOException
- See Also:" +
+ "
- " +
+ "" +
+ "
setUndecorated(boolean)
" + NL +
+ " " + NL + "
"},
+ {BUG_ID + FS + "pkg1" + FS + "C1.ModalExclusionType.html", "" + NL +
+ "- No modal exclusion." + NL + "
" + NL +"
" + NL +
+ "
"},
+ {BUG_ID + FS + "pkg1" + FS + "C2.html", "" + NL + "- Constructor." + NL +
+ "
" + NL +"
" + NL + "
"},
+ {BUG_ID + FS + "pkg1" + FS + "C2.html", "" + NL + "- " +
+ "Deprecated. As of JDK version 1.5, replaced " +
+ "by" + NL + " " +
+ "
setUndecorated(boolean)
." + NL + "" + NL +
+ "
- Set visible." + NL + "
" + NL + "
" +NL +
+ "" + NL + "- Parameters:
- " +
+ "
set
- boolean - Since:
" + NL +
+ " - 1.4
" + NL + " " + NL + "
"},
+ {BUG_ID + FS + "pkg1" + FS + "C3.html", "" + NL + "- Comment." + NL +
+ "
" + NL + "
" + NL + "
"},
+ {BUG_ID + FS + "serialized-form.html", "" + NL + "" + NL +
+ "- Throws:
" + NL + "" +
+ "java.io.IOException
- See Also:" +
+ "
- " +
+ "
C1.setUndecorated(boolean)
" + NL +
+ " " + NL + "
"},
+ {BUG_ID + FS + "serialized-form.html", "" + NL +
+ "- Deprecated. As of JDK version " +
+ "1.5, replaced by" + NL +
+ " " +
+ "
setUndecorated(boolean)
. " +
+ "- This field indicates whether the C1 is undecorated." + NL +
+ "
" + NL + "
" + NL + "-
" + NL +
+ "" + NL + "- Since:
" + NL +
+ " - 1.4
" + NL + "- See Also:" +
+ "
- " +
+ "
C1.setUndecorated(boolean)
" + NL +
+ " " + NL + "
"},
+ {BUG_ID + FS + "serialized-form.html", "" + NL +
+ "- Deprecated. As of JDK version" +
+ " 1.5, replaced by" + NL +
+ " " +
+ "
setUndecorated(boolean)
." + NL + "" + NL +
+ "
- Reads the object stream." + NL + "
" + NL +
+ "
" + NL + "" + NL + "- Throws:" +
+ "
" + NL + "" +
+ "IOException
" + NL +
+ "java.io.IOException
" + NL +
+ " " + NL + "
"},
+ {BUG_ID + FS + "serialized-form.html", "" + NL +
+ "- Deprecated.
- " +
+ "The name for this class." + NL + "
" + NL + "
" + NL +
+ "-
" + NL + "
"}};
+
+ // Test with -nocomment option. The ClassDocs and serialized form should
+ // have properly nested definition list tags enclosing deprecated
+ // information and should not display definition lists for comments
+ // and tags.
+ private static final String[][] TEST_NOCMNT = {
+ {BUG_ID + FS + "pkg1" + FS + "C1.html", "" + NL + "- " +
+ "Deprecated. As of JDK version 1.5, replaced by" + NL +
+ "
" +
+ "setUndecorated(boolean)
.
"},
+ {BUG_ID + FS + "pkg1" + FS + "C2.html", "" + NL +
+ "- Deprecated. As of JDK version" +
+ " 1.5, replaced by" + NL +
+ " " +
+ "
setUndecorated(boolean)
." + NL + "" + NL +
+ "
"},
+ {BUG_ID + FS + "pkg1" + FS + "C5.html", "" + NL +
+ "protected C5()
" + NL + "" + NL +
+ "- Deprecated.
"},
+ {BUG_ID + FS + "pkg1" + FS + "C5.html", "" + NL +
+ "public void printInfo()
" + NL + "" + NL +
+ "- Deprecated.
"},
+ {BUG_ID + FS + "serialized-form.html", "" + NL + "boolean " +
+ "undecorated
" + NL + "" + NL + "- " +
+ "Deprecated. As of JDK version 1.5, replaced by" + NL +
+ "
" +
+ "setUndecorated(boolean)
.
"},
+ {BUG_ID + FS + "serialized-form.html", "" + NL + "- " +
+ "Deprecated. As of JDK version" +
+ " 1.5, replaced by" + NL +
+ " " +
+ "
setUndecorated(boolean)
." + NL + "" + NL +
+ "
"},
+ {BUG_ID + FS + "serialized-form.html", "" + NL + "int " +
+ "publicKey
" + NL + "" + NL + "- " +
+ "Deprecated.
"}};
+
+ // Test with -nodeprecated option. The ClassDocs should have properly nested
+ // definition list tags enclosing comments and tags. The ClassDocs should not
+ // display definition list for deprecated information. The serialized form
+ // should display properly nested definition list tags for comments, tags
+ // and deprecated information.
+ private static final String[][] TEST_NODEPR = {
+ {BUG_ID + FS + "pkg1" + FS + "C1.html", "" + NL +
+ "- Since:
" + NL +
+ " - JDK1.0
" + NL + "- See Also:
- " +
+ "" +
+ "
C2
, " + NL +
+ "" +
+ "Serialized Form
"},
+ {BUG_ID + FS + "pkg1" + FS + "C1.html", "" + NL +
+ "- Constructor." + NL + "
" + NL + "
" + NL +
+ "" + NL + "- Parameters:
- " +
+ "
title
- the title test
" +
+ " - boolean value " + NL + "- Throws:
" + NL +
+ "java.lang.IllegalArgumentException
" +
+ " - if the owner
's" + NL + " GraphicsConfiguration" +
+ "
is not from a screen device " + NL +"" +
+ "HeadlessException
" + NL + " " + NL +
+ "
"},
+ {BUG_ID + FS + "pkg1" + FS + "C1.html", "" + NL +
+ "- Method comments." + NL + "
" + NL +
+ "
" + NL + "" + NL + "- Parameters:" +
+ "
undecorated
- true
" +
+ " if no decorations are" + NL + " to be enabled;" + NL +
+ " false
if decorations are to be enabled." +
+ "- Since:
" + NL +
+ " - 1.4
" + NL + "- See Also:
" +
+ "" +
+ "readObject()
" + NL + " " + NL +
+ "
"},
+ {BUG_ID + FS + "pkg1" + FS + "C1.html", "" + NL + "" + NL +
+ "- Throws:
" + NL + "" +
+ "java.io.IOException
- See Also:" +
+ "
- " +
+ "" +
+ "
setUndecorated(boolean)
" + NL +
+ " " + NL + "
"},
+ {BUG_ID + FS + "pkg1" + FS + "C1.ModalExclusionType.html", "" + NL +
+ "- No modal exclusion." + NL + "
" + NL +"
" + NL +
+ "
"},
+ {BUG_ID + FS + "pkg1" + FS + "C2.html", "" + NL + "- Constructor." + NL +
+ "
" + NL +"
" + NL + "
"},
+ {BUG_ID + FS + "pkg1" + FS + "C3.html", "" + NL + "- Comment." + NL +
+ "
" + NL + "
" + NL + "
"},
+ {BUG_ID + FS + "serialized-form.html", "" + NL + "" + NL +
+ "- Throws:
" + NL + "" +
+ "java.io.IOException
- See Also:" +
+ "
- " +
+ "
C1.setUndecorated(boolean)
" + NL +
+ " " + NL + "
"},
+ {BUG_ID + FS + "serialized-form.html", "" + NL +
+ "- Deprecated. As of JDK version " +
+ "1.5, replaced by" + NL +
+ " " +
+ "
setUndecorated(boolean)
. " +
+ "- This field indicates whether the C1 is undecorated." + NL +
+ "
" + NL + "
" + NL + "-
" + NL +
+ "" + NL + "- Since:
" + NL +
+ " - 1.4
" + NL + "- See Also:" +
+ "
- " +
+ "
C1.setUndecorated(boolean)
" + NL +
+ " " + NL + "
"},
+ {BUG_ID + FS + "serialized-form.html", "" + NL +
+ "- Deprecated. As of JDK version" +
+ " 1.5, replaced by" + NL +
+ " " +
+ "
setUndecorated(boolean)
." + NL + "" + NL +
+ "
- Reads the object stream." + NL + "
" + NL +
+ "
" + NL + "" + NL + "- Throws:" +
+ "
" + NL + "" +
+ "IOException
" + NL +
+ "java.io.IOException
" + NL +
+ " " + NL + "
"},
+ {BUG_ID + FS + "serialized-form.html", "" + NL +
+ "- Deprecated.
- " +
+ "The name for this class." + NL + "
" + NL + "
" + NL +
+ "-
" + NL + "
"}};
+
+ // Test with -nocomment and -nodeprecated options. The ClassDocs whould
+ // not display definition lists for any member details. The serialized
+ // form should display properly nested definition list tags for
+ // deprecated information only.
+ private static final String[][] TEST_NOCMNT_NODEPR = {
+ {BUG_ID + FS + "pkg1" + FS + "C1.html", "" + NL + "public void " +
+ "readObject()" + NL + " throws" +
+ " java.io.IOException
" + NL + "
"},
+ {BUG_ID + FS + "pkg1" + FS + "C2.html", "" +NL + "public " +
+ "C2()
" + NL + "
"},
+ {BUG_ID + FS + "pkg1" + FS + "C1.ModalExclusionType.html", "" + NL +
+ "public static final " +
+ "C1.ModalExclusionType " +
+ "APPLICATION_EXCLUDE
" + NL + "
"},
+ {BUG_ID + FS + "serialized-form.html", "" + NL + "boolean " +
+ "undecorated
" + NL + "" + NL + "- " +
+ "Deprecated. As of JDK version 1.5, replaced by" + NL +
+ "
" +
+ "setUndecorated(boolean)
.
"},
+ {BUG_ID + FS + "serialized-form.html", "" + NL + "- " +
+ "Deprecated. As of JDK version" +
+ " 1.5, replaced by" + NL +
+ " " +
+ "
setUndecorated(boolean)
." + NL + "" + NL +
+ "
"},
+ {BUG_ID + FS + "serialized-form.html", "" + NL + "int " +
+ "publicKey
" + NL + "" + NL + "- " +
+ "Deprecated.
"}};
+
+ // Test for valid HTML generation which should not comprise of empty
+ // definition list tags.
+ private static final String[][] NEGATED_TEST = {
+ {BUG_ID + FS + "pkg1" + FS + "C1.html", "
"},
+ {BUG_ID + FS + "pkg1" + FS + "C1.html", "" + NL + "
"},
+ {BUG_ID + FS + "pkg1" + FS + "C1.ModalExclusionType.html", "
"},
+ {BUG_ID + FS + "pkg1" + FS + "C1.ModalExclusionType.html", "" + NL + "
"},
+ {BUG_ID + FS + "pkg1" + FS + "C2.html", "
"},
+ {BUG_ID + FS + "pkg1" + FS + "C2.html", "" + NL + "
"},
+ {BUG_ID + FS + "pkg1" + FS + "C2.ModalType.html", "
"},
+ {BUG_ID + FS + "pkg1" + FS + "C2.ModalType.html", "" + NL + "
"},
+ {BUG_ID + FS + "pkg1" + FS + "C3.html", "
"},
+ {BUG_ID + FS + "pkg1" + FS + "C3.html", "" + NL + "
"},
+ {BUG_ID + FS + "pkg1" + FS + "C4.html", "
"},
+ {BUG_ID + FS + "pkg1" + FS + "C4.html", "" + NL + "
"},
+ {BUG_ID + FS + "pkg1" + FS + "C5.html", "
"},
+ {BUG_ID + FS + "pkg1" + FS + "C5.html", "" + NL + "
"},
+ {BUG_ID + FS + "overview-tree.html", "
"},
+ {BUG_ID + FS + "overview-tree.html", "" + NL + "
"},
+ {BUG_ID + FS + "serialized-form.html", "
"},
+ {BUG_ID + FS + "serialized-form.html", "" + NL + "
"}};
+
+ private static final String[] ARGS1 =
+ new String[] {
+ "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg1"};
+
+ private static final String[] ARGS2 =
+ new String[] {
+ "-d", BUG_ID, "-nocomment", "-sourcepath", SRC_DIR, "pkg1"};
+
+ private static final String[] ARGS3 =
+ new String[] {
+ "-d", BUG_ID, "-nodeprecated", "-sourcepath", SRC_DIR, "pkg1"};
+
+ private static final String[] ARGS4 =
+ new String[] {
+ "-d", BUG_ID, "-nocomment", "-nodeprecated", "-sourcepath", SRC_DIR, "pkg1"};
+
+ /**
+ * The entry point of the test.
+ * @param args the array of command line arguments.
+ */
+ public static void main(String[] args) {
+ TestHtmlDefinitionListTag tester = new TestHtmlDefinitionListTag();
+ run(tester, ARGS1, TEST_ALL, NEGATED_TEST);
+ run(tester, ARGS1, TEST_CMNT_DEPR, NEGATED_TEST);
+ run(tester, ARGS2, TEST_ALL, NEGATED_TEST);
+ run(tester, ARGS2, TEST_NOCMNT, TEST_CMNT_DEPR);
+ run(tester, ARGS3, TEST_ALL, NEGATED_TEST);
+ run(tester, ARGS3, TEST_NODEPR, TEST_NOCMNT_NODEPR);
+ run(tester, ARGS4, TEST_ALL, NEGATED_TEST);
+ run(tester, ARGS4, TEST_NOCMNT_NODEPR, TEST_CMNT_DEPR);
+ tester.printSummary();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getBugId() {
+ return BUG_ID;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getBugName() {
+ return getClass().getName();
+ }
+}
diff --git a/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C1.java b/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C1.java
new file mode 100644
index 00000000000..a3dbc13e629
--- /dev/null
+++ b/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C1.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package pkg1;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+/**
+ * A class comment for testing.
+ *
+ * @author Bhavesh Patel
+ * @see C2
+ * @since JDK1.0
+ */
+
+public class C1 implements Serializable {
+
+ /**
+ * This field indicates whether the C1 is undecorated.
+ *
+ * @see #setUndecorated(boolean)
+ * @since 1.4
+ * @serial
+ * @deprecated As of JDK version 1.5, replaced by
+ * {@link C1#setUndecorated(boolean) setUndecorated(boolean)}.
+ */
+ @Deprecated
+ public boolean undecorated = false;
+
+ private String title;
+
+ /**
+ * This enum specifies the possible modal exclusion types.
+ *
+ * @since 1.6
+ */
+ public static enum ModalExclusionType {
+ /**
+ * No modal exclusion.
+ */
+ NO_EXCLUDE,
+ /**
+ * APPLICATION_EXCLUDE
indicates that a top-level window
+ * won't be blocked by any application-modal dialogs. Also, it isn't
+ * blocked by document-modal dialogs from outside of its child hierarchy.
+ */
+ APPLICATION_EXCLUDE
+ };
+
+ /**
+ * Constructor.
+ *
+ * @param title the title
+ * @param test boolean value
+ * @exception IllegalArgumentException if the owner
's
+ * GraphicsConfiguration
is not from a screen device
+ * @exception HeadlessException
+ */
+ public C1(String title, boolean test) {
+
+ }
+
+ public C1(String title) {
+
+ }
+
+ /**
+ * Method comments.
+ * @param undecorated true
if no decorations are
+ * to be enabled;
+ * false
if decorations are to be enabled.
+ * @see #readObject()
+ * @since 1.4
+ */
+ public void setUndecorated(boolean undecorated) {
+ /* Make sure we don't run in the middle of peer creation.*/
+ }
+
+ /**
+ * @see #setUndecorated(boolean)
+ */
+ public void readObject() throws IOException {
+
+ }
+}
diff --git a/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C2.java b/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C2.java
new file mode 100644
index 00000000000..b0e098d1e63
--- /dev/null
+++ b/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C2.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package pkg1;
+
+import java.io.ObjectInputStream;
+import java.io.IOException;
+import java.io.Serializable;
+
+/**
+ * A class comment for testing.
+ *
+ * @author Bhavesh Patel
+ * @see C1
+ * @since JDK1.0
+ */
+
+public class C2 implements Serializable {
+
+ /**
+ * This field indicates title.
+ */
+ String title;
+
+ public static enum ModalType {
+ NO_EXCLUDE
+ };
+
+ /**
+ * Constructor.
+ *
+ */
+ public C2() {
+
+ }
+
+ public C2(String title) {
+
+ }
+
+ /**
+ * Set visible.
+ *
+ * @param set boolean
+ * @since 1.4
+ * @deprecated As of JDK version 1.5, replaced by
+ * {@link C1#setUndecorated(boolean) setUndecorated(boolean)}.
+ */
+ @Deprecated
+ public void setVisible(boolean set) {
+ }
+
+ /**
+ * Reads the object stream.
+ *
+ * @param s ObjectInputStream
+ * @throws IOException
+ * @deprecated As of JDK version 1.5, replaced by
+ * {@link C1#setUndecorated(boolean) setUndecorated(boolean)}.
+ */
+ @Deprecated
+ public void readObject(ObjectInputStream s) throws IOException {
+ }
+}
diff --git a/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C3.java b/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C3.java
new file mode 100644
index 00000000000..cf48cf1cb98
--- /dev/null
+++ b/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C3.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package pkg1;
+
+import java.lang.annotation.*;
+
+/**
+ * Test Annotation class.
+ *
+ * @author Bhavesh Patel
+ * @since 1.5
+ */
+@Retention(RetentionPolicy.SOURCE)
+public @interface C3 {
+ /**
+ * Comment.
+ */
+ String[] value();
+}
diff --git a/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C4.java b/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C4.java
new file mode 100644
index 00000000000..0a1fb611c28
--- /dev/null
+++ b/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C4.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package pkg1;
+
+import java.lang.annotation.*;
+
+/*
+ * The @Inherited annotation has no effect when applied to an interface.
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+@Inherited
+public @interface C4 {
+ boolean value() default true;
+}
diff --git a/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C5.java b/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C5.java
new file mode 100644
index 00000000000..00ccb7383af
--- /dev/null
+++ b/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C5.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package pkg1;
+
+import java.io.Serializable;
+
+/**
+ * Test for Serializable
+ *
+ * @author Bhavesh Patel
+ * @deprecated This class is no longer used.
+ */
+@Deprecated
+public abstract class C5 implements Serializable {
+
+ /**
+ * The name for this class.
+ *
+ * @serial
+ */
+ private String name;
+
+ /**
+ * @serial
+ */
+ private int publicKey;
+
+ /**
+ * Constructor for serialization only.
+ */
+ protected C5() {
+
+ }
+
+ /**
+ * Prints general information.
+ *
+ */
+ public void printInfo() {
+
+ }
+}
diff --git a/langtools/test/com/sun/javadoc/testIndex/TestIndex.java b/langtools/test/com/sun/javadoc/testIndex/TestIndex.java
index 0594d3d9371..52b61a06278 100644
--- a/langtools/test/com/sun/javadoc/testIndex/TestIndex.java
+++ b/langtools/test/com/sun/javadoc/testIndex/TestIndex.java
@@ -73,10 +73,10 @@ public class TestIndex extends JavadocTester {
{BUG_ID + FS + "index-all.html",
"- Java - " + NL +
"Static variable in class pkg.C" + NL +
- "
- " + NL +
+ "
-
" + NL + NL +
" - JDK - " + NL +
"Static variable in class pkg.C" + NL +
- "
- "},
+ "
-
"},
};
private static final String[][] NEGATED_TEST = NO_TEST;
diff --git a/langtools/test/com/sun/javadoc/testInterface/TestInterface.java b/langtools/test/com/sun/javadoc/testInterface/TestInterface.java
index 0dd3ebb9003..d5e33d72073 100644
--- a/langtools/test/com/sun/javadoc/testInterface/TestInterface.java
+++ b/langtools/test/com/sun/javadoc/testInterface/TestInterface.java
@@ -55,7 +55,7 @@ public class TestInterface extends JavadocTester {
// Make sure known implementing class list is correct and omits type parameters.
{BUG_ID + FS + "pkg" + FS + "Interface.html",
- " - All Known Implementing Classes: " +
+ "
- All Known Implementing Classes:
" +
" - Child, " +
"" +
@@ -63,7 +63,9 @@ public class TestInterface extends JavadocTester {
// Make sure "All Implemented Interfaces": has substituted type parameters
{BUG_ID + FS + "pkg" + FS + "Child.html",
- "All Implemented Interfaces:
- Interface<T>"
+ "All Implemented Interfaces:
- " +
+ "" +
+ "Interface<T>"
},
//Make sure Class Tree has substituted type parameters.
{BUG_ID + FS + "pkg" + FS + "Child.html",
@@ -75,15 +77,15 @@ public class TestInterface extends JavadocTester {
},
//Make sure "Direct Know Subclasses" omits type parameters
{BUG_ID + FS + "pkg" + FS + "Parent.html",
- "Direct Known Subclasses:
- Child"
+ "Direct Known Subclasses:
- Child"
},
//Make sure "Specified By" has substituted type parameters.
{BUG_ID + FS + "pkg" + FS + "Child.html",
- "Specified by:
method
in interface Interface<T>
"
+ "Specified by:method
in interface Interface<T>
"
},
//Make sure "Overrides" has substituted type parameters.
{BUG_ID + FS + "pkg" + FS + "Child.html",
- "Overrides:method
in class Parent<T>
"
+ "Overrides:method
in class Parent<T>
"
},
};
private static final String[][] NEGATED_TEST = {
diff --git a/langtools/test/com/sun/javadoc/testLinkOption/TestLinkOption.java b/langtools/test/com/sun/javadoc/testLinkOption/TestLinkOption.java
index 1a2156ee03c..37b4949a513 100644
--- a/langtools/test/com/sun/javadoc/testLinkOption/TestLinkOption.java
+++ b/langtools/test/com/sun/javadoc/testLinkOption/TestLinkOption.java
@@ -63,7 +63,8 @@ public class TestLinkOption extends JavadocTester {
"title=\"class or interface in java.lang\">Object p3)"
},
{BUG_ID + "-1" + FS + "java" + FS + "lang" + FS + "StringBuilderChild.html",
- "public abstract class StringBuilderChild - extends Object"
+ "public abstract class StringBuilderChild" + NL +
+ "extends Object"
},
};
diff --git a/langtools/test/com/sun/javadoc/testLinkTaglet/TestLinkTaglet.java b/langtools/test/com/sun/javadoc/testLinkTaglet/TestLinkTaglet.java
index 1eb2c998639..6983423f832 100644
--- a/langtools/test/com/sun/javadoc/testLinkTaglet/TestLinkTaglet.java
+++ b/langtools/test/com/sun/javadoc/testLinkTaglet/TestLinkTaglet.java
@@ -59,7 +59,7 @@ public class TestLinkTaglet extends JavadocTester {
" Link to another inner class:
C.InnerC2
"
},
{BUG_ID + FS + "pkg" + FS + "C.InnerC2.html",
- "Enclosing class: - C"
+ "Enclosing class:
- C"
},
};
private static final String[][] NEGATED_TEST = {
diff --git a/langtools/test/com/sun/javadoc/testMemberInheritence/TestMemberInheritence.java b/langtools/test/com/sun/javadoc/testMemberInheritence/TestMemberInheritence.java
index 15b9e343267..12da5956f0e 100644
--- a/langtools/test/com/sun/javadoc/testMemberInheritence/TestMemberInheritence.java
+++ b/langtools/test/com/sun/javadoc/testMemberInheritence/TestMemberInheritence.java
@@ -74,7 +74,7 @@ public class TestMemberInheritence extends JavadocTester {
// Test overriding/implementing methods with generic parameters.
{BUG_ID + FS + "pkg" + FS + "BaseClass.html",
- "
- Specified by:
getAnnotation
in interface BaseInterface
"},
+ "Specified by:getAnnotation
in interface BaseInterface
"+NL+""},
// Test diamond inheritence member summary (6256068)
{BUG_ID + FS + "diamond" + FS + "Z.html",
diff --git a/langtools/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java b/langtools/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java
index 1bc573d3950..17eac18887a 100644
--- a/langtools/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java
+++ b/langtools/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java
@@ -54,7 +54,7 @@ public class TestNewLanguageFeatures extends JavadocTester {
{BUG_ID + FS + "pkg" + FS + "Coin.html", "Enum Coin"},
//Make sure enum signature is correct.
{BUG_ID + FS + "pkg" + FS + "Coin.html", "public enum "+
- "Coinextends java.lang.Enum<" +
+ "Coin" + NL + "extends java.lang.Enum<" +
"Coin>"
},
//Check for enum constant section
@@ -79,20 +79,20 @@ public class TestNewLanguageFeatures extends JavadocTester {
"Class TypeParameters<E>"},
//Check class type parameters section.
{BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
- "Type Parameters:E
- " +
+ "Type Parameters:E
- " +
"the type parameter for this class."},
//Type parameters in @see/@link
{BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
- "See Also:TypeParameters
"},
+ "See Also:TypeParameters
"},
//Method that uses class type parameter.
{BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
"(E param)"},
//Method type parameter section.
{BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
- "Type Parameters:T
- This is the first " +
- "type parameter.V
- This is the second type " +
+ "Type Parameters:T
- This is the first " +
+ "type parameter.V
- This is the second type " +
"parameter."},
//Signature of method with type parameters
{BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
@@ -117,17 +117,17 @@ public class TestNewLanguageFeatures extends JavadocTester {
//Signature of subclass that has type parameters.
{BUG_ID + FS + "pkg" + FS + "TypeParameterSubClass.html",
"public class TypeParameterSubClass<T extends java.lang.String>" +
- "extends " + NL + "extends TypeParameterSuperClass<T>"},
//Interface generic parameter substitution
//Signature of subclass that has type parameters.
{BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
- "All Implemented Interfaces: SubInterface<E>, SuperInterface<E>"},
+ "All Implemented Interfaces: SubInterface<E>, SuperInterface<E>"},
{BUG_ID + FS + "pkg" + FS + "SuperInterface.html",
- "All Known Subinterfaces: SubInterface<V>"},
+ "All Known Subinterfaces: SubInterface<V>"},
{BUG_ID + FS + "pkg" + FS + "SubInterface.html",
- "All Superinterfaces: SuperInterface<V>"},
+ "All Superinterfaces: SuperInterface<V>"},
//=================================
// VAR ARG TESTING
@@ -166,7 +166,7 @@ public class TestNewLanguageFeatures extends JavadocTester {
"Element Detail"},
//Make sure default annotation type value is printed when necessary.
{BUG_ID + FS + "pkg" + FS + "AnnotationType.html",
- "Default:\"unknown\""},
+ "Default:\"unknown\""},
//=================================
// ANNOTATION TYPE USAGE TESTING
@@ -182,7 +182,8 @@ public class TestNewLanguageFeatures extends JavadocTester {
"" +
"@AnnotationType(optional=\"Class Annotation\","+NL +
" required=1994)"+NL +
- "public class AnnotationTypeUsageextends java.lang.Object"},
+ "public class AnnotationTypeUsage" + NL +
+ "extends java.lang.Object"},
//FIELD
{BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html",
@@ -270,8 +271,7 @@ public class TestNewLanguageFeatures extends JavadocTester {
{BUG_ID + FS + "pkg1" + FS + "B.html",
"@A"},
{BUG_ID + FS + "pkg1" + FS + "B.html",
- "public interface B" + NL +
- "
"},
+ "public interface B"},
//==============================================================
@@ -525,7 +525,7 @@ public class TestNewLanguageFeatures extends JavadocTester {
"" + NL +
"@AnnotationTypeUndocumented(optional=\"Class Annotation\"," + NL +
" required=1994)" + NL +
- "public class AnnotationTypeUsageextends java.lang.Object"},
+ "public class AnnotationTypeUsageextends java.lang.Object"},
//FIELD
{BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html",
diff --git a/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethods.java b/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethods.java
index 7c11f4bd70b..fa4e717eff8 100644
--- a/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethods.java
+++ b/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethods.java
@@ -40,11 +40,11 @@ public class TestOverridenPrivateMethods extends JavadocTester {
private static final String[][] TEST = {
//The public method should be overriden
{BUG_ID + FS + "pkg1" + FS + "SubClass.html",
- "Overrides: