--- old/src/share/native/sun/awt/image/jpeg/imageioJPEG.c 2009-07-29 13:28:11.272200000 +0400 +++ openjdk/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c 2009-07-29 13:28:10.710600000 +0400 @@ -685,6 +685,10 @@ #ifdef DEBUG printf("in setQTables, qlen = %d, write is %d\n", qlen, write); #endif + if (qlen > NUM_QUANT_TBLS) { + /* Ignore extra qunterization tables. */ + qlen = NUM_QUANT_TBLS; + } for (i = 0; i < qlen; i++) { table = (*env)->GetObjectArrayElement(env, qtables, i); qdata = (*env)->GetObjectField(env, table, JPEGQTable_tableID); @@ -736,6 +740,11 @@ hlensBody = (*env)->GetShortArrayElements(env, huffLens, NULL); + if (hlensLen > 16) { + /* Ignore extra elements of bits array. Only 16 elements can be + stored. 0-th element is not used. (see jpeglib.h, line 107) */ + hlensLen = 16; + } for (i = 1; i <= hlensLen; i++) { huff_ptr->bits[i] = (UINT8)hlensBody[i-1]; } @@ -752,6 +761,11 @@ huffValues, NULL); + if (hvalsLen > 256) { + /* Ignore extra elements of hufval array. Only 256 elements + can be stored. (see jpeglib.h, line 109) */ + hlensLen = 256; + } for (i = 0; i < hvalsLen; i++) { huff_ptr->huffval[i] = (UINT8)hvalsBody[i]; } @@ -772,6 +786,11 @@ j_compress_ptr comp; j_decompress_ptr decomp; jsize hlen = (*env)->GetArrayLength(env, DCHuffmanTables); + + if (hlen > NUM_HUFF_TBLS) { + /* Ignore extra DC huffman tables. */ + hlen = NUM_HUFF_TBLS; + } for (i = 0; i < hlen; i++) { if (cinfo->is_decompressor) { decomp = (j_decompress_ptr) cinfo; @@ -793,6 +812,10 @@ huff_ptr->sent_table = !write; } hlen = (*env)->GetArrayLength(env, ACHuffmanTables); + if (hlen > NUM_HUFF_TBLS) { + /* Ignore extra AC huffman tables. */ + hlen = NUM_HUFF_TBLS; + } for (i = 0; i < hlen; i++) { if (cinfo->is_decompressor) { decomp = (j_decompress_ptr) cinfo; --- old/src/share/classes/java/security/MessageDigest.java Thu Sep 24 22:22:15 2009 +++ openjdk/jdk/src/share/classes/java/security/MessageDigest.java Thu Sep 24 22:22:15 2009 @@ -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 @@ -414,16 +414,17 @@ * * @return true if the digests are equal, false otherwise. */ - public static boolean isEqual(byte digesta[], byte digestb[]) { - if (digesta.length != digestb.length) + public static boolean isEqual(byte[] digesta, byte[] digestb) { + if (digesta.length != digestb.length) { return false; + } + int result = 0; + // time-constant comparison for (int i = 0; i < digesta.length; i++) { - if (digesta[i] != digestb[i]) { - return false; - } + result |= digesta[i] ^ digestb[i]; } - return true; + return result == 0; } /** --- old/src/share/classes/com/sun/jndi/ldap/Connection.java 2009-08-18 09:35:56.595709900 +0800 +++ openjdk/jdk/src/share/classes/com/sun/jndi/ldap/Connection.java 2009-08-18 09:35:56.087195700 +0800 @@ -32,12 +32,8 @@ import java.io.OutputStream; import java.io.InputStream; import java.net.Socket; -import java.util.Vector; -import java.util.Hashtable; import javax.naming.CommunicationException; -import javax.naming.AuthenticationException; -import javax.naming.AuthenticationNotSupportedException; import javax.naming.ServiceUnavailableException; import javax.naming.NamingException; import javax.naming.InterruptedNamingException; @@ -47,6 +43,8 @@ import java.lang.reflect.Method; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; +import sun.misc.IOUtils; //import javax.net.SocketFactory; /** @@ -799,7 +797,6 @@ byte inbuf[]; // Buffer for reading incoming bytes int inMsgId; // Message id of incoming response int bytesread; // Number of bytes in inbuf - int bytesleft; // Number of bytes that need to read for completing resp int br; // Temp; number of bytes read from stream int offset; // Offset of where to store bytes in inbuf int seqlen; // Length of ASN sequence @@ -811,7 +808,7 @@ try { while (true) { try { - inbuf = new byte[2048]; + inbuf = new byte[10]; offset = 0; seqlen = 0; @@ -871,19 +868,10 @@ } // read in seqlen bytes - bytesleft = seqlen; - if ((offset + bytesleft) > inbuf.length) { - byte nbuf[] = new byte[offset + bytesleft]; - System.arraycopy(inbuf, 0, nbuf, 0, offset); - inbuf = nbuf; - } - while (bytesleft > 0) { - bytesread = in.read(inbuf, offset, bytesleft); - if (bytesread < 0) - break; // EOF - offset += bytesread; - bytesleft -= bytesread; - } + byte[] left = IOUtils.readFully(in, seqlen, false); + inbuf = Arrays.copyOf(inbuf, offset + left.length); + System.arraycopy(left, 0, inbuf, offset, left.length); + offset += left.length; /* if (dump > 0) { System.err.println("seqlen: " + seqlen); --- old/src/share/classes/sun/applet/AppletClassLoader.java 2009-08-18 09:36:00.901075900 +0800 +++ openjdk/jdk/src/share/classes/sun/applet/AppletClassLoader.java 2009-08-18 09:35:59.999916100 +0800 @@ -51,6 +51,7 @@ import java.security.PermissionCollection; import sun.awt.AppContext; import sun.awt.SunToolkit; +import sun.misc.IOUtils; import sun.net.www.ParseUtil; import sun.security.util.SecurityConstants; @@ -314,36 +315,7 @@ byte[] b; try { - if (len != -1) { - // Read exactly len bytes from the input stream - b = new byte[len]; - while (len > 0) { - int n = in.read(b, b.length - len, len); - if (n == -1) { - throw new IOException("unexpected EOF"); - } - len -= n; - } - } else { - // Read until end of stream is reached - use 8K buffer - // to speed up performance [stanleyh] - b = new byte[8192]; - int total = 0; - while ((len = in.read(b, total, b.length - total)) != -1) { - total += len; - if (total >= b.length) { - byte[] tmp = new byte[total * 2]; - System.arraycopy(b, 0, tmp, 0, total); - b = tmp; - } - } - // Trim array to correct size, if necessary - if (total != b.length) { - byte[] tmp = new byte[total]; - System.arraycopy(b, 0, tmp, 0, total); - b = tmp; - } - } + b = IOUtils.readFully(in, len, true); } finally { in.close(); } --- old/src/share/classes/sun/misc/Resource.java 2009-08-18 09:36:03.965921700 +0800 +++ openjdk/jdk/src/share/classes/sun/misc/Resource.java 2009-08-18 09:36:03.449689900 +0800 @@ -25,14 +25,15 @@ package sun.misc; +import java.io.EOFException; import java.net.URL; import java.io.IOException; import java.io.InterruptedIOException; import java.io.InputStream; import java.security.CodeSigner; import java.util.jar.Manifest; -import java.util.jar.Attributes; import java.nio.ByteBuffer; +import java.util.Arrays; import sun.nio.ByteBuffered; /** @@ -105,49 +106,37 @@ } try { - if (len != -1) { - // Read exactly len bytes from the input stream - b = new byte[len]; - while (len > 0) { - int n = 0; - try { - n = in.read(b, b.length - len, len); - } catch (InterruptedIOException iioe) { - Thread.interrupted(); - isInterrupted = true; + b = new byte[0]; + if (len == -1) len = Integer.MAX_VALUE; + int pos = 0; + while (pos < len) { + int bytesToRead; + if (pos >= b.length) { // Only expand when there's no room + bytesToRead = Math.min(len - pos, b.length + 1024); + if (b.length < pos + bytesToRead) { + b = Arrays.copyOf(b, pos + bytesToRead); } - if (n == -1) { - throw new IOException("unexpected EOF"); - } - len -= n; + } else { + bytesToRead = b.length - pos; } - } else { - // Read until end of stream is reached - b = new byte[1024]; - int total = 0; - for (;;) { - len = 0; - try { - len = in.read(b, total, b.length - total); - if (len == -1) - break; - } catch (InterruptedIOException iioe) { - Thread.interrupted(); - isInterrupted = true; - } - total += len; - if (total >= b.length) { - byte[] tmp = new byte[total * 2]; - System.arraycopy(b, 0, tmp, 0, total); - b = tmp; - } + int cc = 0; + try { + cc = in.read(b, pos, bytesToRead); + } catch (InterruptedIOException iioe) { + Thread.interrupted(); + isInterrupted = true; } - // Trim array to correct size, if necessary - if (total != b.length) { - byte[] tmp = new byte[total]; - System.arraycopy(b, 0, tmp, 0, total); - b = tmp; + if (cc < 0) { + if (len != Integer.MAX_VALUE) { + throw new EOFException("Detect premature EOF"); + } else { + if (b.length != pos) { + b = Arrays.copyOf(b, pos); + } + break; + } } + pos += cc; } } finally { try { --- old/src/share/classes/sun/reflect/misc/MethodUtil.java 2009-08-18 09:36:07.067128400 +0800 +++ openjdk/jdk/src/share/classes/sun/reflect/misc/MethodUtil.java 2009-08-18 09:36:06.464179700 +0800 @@ -44,6 +44,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map; +import sun.misc.IOUtils; import sun.net.www.ParseUtil; import sun.security.util.SecurityConstants; @@ -375,34 +376,7 @@ byte[] b; try { - if (len != -1) { - // Read exactly len bytes from the input stream - b = new byte[len]; - while (len > 0) { - int n = in.read(b, b.length - len, len); - if (n == -1) { - throw new IOException("unexpected EOF"); - } - len -= n; - } - } else { - b = new byte[8192]; - int total = 0; - while ((len = in.read(b, total, b.length - total)) != -1) { - total += len; - if (total >= b.length) { - byte[] tmp = new byte[total * 2]; - System.arraycopy(b, 0, tmp, 0, total); - b = tmp; - } - } - // Trim array to correct size, if necessary - if (total != b.length) { - byte[] tmp = new byte[total]; - System.arraycopy(b, 0, tmp, 0, total); - b = tmp; - } - } + b = IOUtils.readFully(in, len, true); } finally { in.close(); } --- old/src/share/classes/sun/security/provider/certpath/OCSPChecker.java 2009-08-18 09:36:10.684391400 +0800 +++ openjdk/jdk/src/share/classes/sun/security/provider/certpath/OCSPChecker.java 2009-08-18 09:36:10.088986300 +0800 @@ -36,6 +36,7 @@ import java.net.*; import javax.security.auth.x500.X500Principal; +import sun.misc.IOUtils; import sun.security.util.*; import sun.security.x509.*; @@ -344,17 +345,7 @@ in = con.getInputStream(); int contentLength = con.getContentLength(); - if (contentLength == -1) { - contentLength = Integer.MAX_VALUE; - } - - byte[] response = new byte[contentLength]; - int total = 0; - int count = 0; - while (count != -1 && total < contentLength) { - count = in.read(response, total, response.length - total); - total += count; - } + byte[] response = IOUtils.readFully(in, contentLength, false); OCSPResponse ocspResponse = new OCSPResponse(response, pkixParams, responderCert); --- old/src/share/classes/sun/security/timestamp/HttpTimestamper.java 2009-08-18 09:36:13.859436200 +0800 +++ openjdk/jdk/src/share/classes/sun/security/timestamp/HttpTimestamper.java 2009-08-18 09:36:13.165978900 +0800 @@ -33,6 +33,7 @@ import java.util.Iterator; import java.util.Set; +import sun.misc.IOUtils; import sun.security.pkcs.*; /** @@ -138,19 +139,9 @@ System.out.println(); } int contentLength = connection.getContentLength(); - if (contentLength == -1) { - contentLength = Integer.MAX_VALUE; - } verifyMimeType(connection.getContentType()); + replyBuffer = IOUtils.readFully(input, contentLength, false); - replyBuffer = new byte[contentLength]; - int total = 0; - int count = 0; - while (count != -1 && total < contentLength) { - count = input.read(replyBuffer, total, - replyBuffer.length - total); - total += count; - } if (DEBUG) { System.out.println("received timestamp response (length=" + replyBuffer.length + ")"); --- old/src/share/classes/sun/security/util/DerValue.java 2009-08-18 09:36:18.392602400 +0800 +++ openjdk/jdk/src/share/classes/sun/security/util/DerValue.java 2009-08-18 09:36:17.617711400 +0800 @@ -28,6 +28,7 @@ import java.io.*; import java.math.BigInteger; import java.util.Date; +import sun.misc.IOUtils; /** * Represents a single DER-encoded value. DER encoding rules are a subset @@ -384,12 +385,8 @@ if (fullyBuffered && in.available() != length) throw new IOException("extra data given to DerValue constructor"); - byte[] bytes = new byte[length]; + byte[] bytes = IOUtils.readFully(in, length, true); - // n.b. readFully not needed in normal fullyBuffered case - DataInputStream dis = new DataInputStream(in); - - dis.readFully(bytes); buffer = new DerInputBuffer(bytes); return new DerInputStream(buffer); } --- /dev/null 2009-07-23 00:25:50.000000000 +0800 +++ openjdk/jdk/src/share/classes/sun/misc/IOUtils.java 2009-08-18 09:36:21.385422200 +0800 @@ -0,0 +1,80 @@ +/* + * 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. + */ + +/** + * IOUtils: A collection of IO-related public static methods. + */ + +package sun.misc; + +import java.io.EOFException; +import java.io.IOException; +import java.io.InputStream; +import java.util.Arrays; + +public class IOUtils { + + /** + * Read up to <code>length</code> of bytes from <code>in</code> + * until EOF is detected. + * @param in input stream, must not be null + * @param length number of bytes to read, -1 or Integer.MAX_VALUE means + * read as much as possible + * @param readAll if true, an EOFException will be thrown if not enough + * bytes are read. Ignored when length is -1 or Integer.MAX_VALUE + * @return bytes read + * @throws IOException Any IO error or a premature EOF is detected + */ + public static byte[] readFully(InputStream is, int length, boolean readAll) + throws IOException { + byte[] output = {}; + if (length == -1) length = Integer.MAX_VALUE; + int pos = 0; + while (pos < length) { + int bytesToRead; + if (pos >= output.length) { // Only expand when there's no room + bytesToRead = Math.min(length - pos, output.length + 1024); + if (output.length < pos + bytesToRead) { + output = Arrays.copyOf(output, pos + bytesToRead); + } + } else { + bytesToRead = output.length - pos; + } + int cc = is.read(output, pos, bytesToRead); + if (cc < 0) { + if (readAll && length != Integer.MAX_VALUE) { + throw new EOFException("Detect premature EOF"); + } else { + if (output.length != pos) { + output = Arrays.copyOf(output, pos); + } + break; + } + } + pos += cc; + } + return output; + } +} --- old/src/share/native/sun/awt/image/awt_ImageRep.c Mon Sep 7 14:46:10 2009 +++ openjdk/jdk/src/share/native/sun/awt/image/awt_ImageRep.c Mon Sep 7 14:46:09 2009 @@ -266,6 +266,14 @@ jnewlut = (*env)->GetObjectField(env, jicm, g_ICMrgbID); mapSize = (*env)->GetIntField(env, jicm, g_ICMmapSizeID); + if (numLut < 0 || numLut > 256 || mapSize < 0 || mapSize > 256) { + /* Ether old or new ICM has a palette that exceeds capacity + of byte data type, so we have to convert the image data + to default representation. + */ + return 0; + } + srcLUT = (unsigned int *) (*env)->GetPrimitiveArrayCritical(env, jlut, NULL); if (srcLUT == NULL) { --- old/make/sun/awt/mapfile-vers Wed Sep 9 17:45:20 2009 +++ openjdk/jdk/make/sun/awt/mapfile-vers Wed Sep 9 17:45:19 2009 @@ -53,7 +53,6 @@ Java_sun_awt_image_GifImageDecoder_initIDs; Java_sun_awt_image_GifImageDecoder_parseImage; Java_sun_awt_image_ImageRepresentation_initIDs; - Java_sun_awt_image_ImageRepresentation_setBytePixels; Java_sun_awt_image_ImageRepresentation_setDiffICM; Java_sun_awt_image_ImageRepresentation_setICMpixels; Java_sun_awt_image_ImagingLib_convolveBI; --- old/make/sun/awt/mapfile-vers-linux Wed Sep 9 17:45:23 2009 +++ openjdk/jdk/make/sun/awt/mapfile-vers-linux Wed Sep 9 17:45:22 2009 @@ -55,7 +55,6 @@ Java_sun_awt_image_GifImageDecoder_parseImage; Java_sun_awt_image_Image_initIDs; Java_sun_awt_image_ImageRepresentation_initIDs; - Java_sun_awt_image_ImageRepresentation_setBytePixels; Java_sun_awt_image_ImageRepresentation_setDiffICM; Java_sun_awt_image_ImageRepresentation_setICMpixels; Java_sun_awt_image_ImagingLib_convolveBI; --- old/src/share/classes/sun/awt/image/ImageRepresentation.java Wed Sep 9 17:45:26 2009 +++ openjdk/jdk/src/share/classes/sun/awt/image/ImageRepresentation.java Wed Sep 9 17:45:25 2009 @@ -336,10 +336,6 @@ public native void setICMpixels(int x, int y, int w, int h, int[] lut, byte[] pix, int off, int scansize, IntegerComponentRaster ict); - - public native void setBytePixels(int x, int y, int w, int h, byte[] pix, - int off, int scansize, - ByteComponentRaster bct, int chanOff); public native int setDiffICM(int x, int y, int w, int h, int[] lut, int transPix, int numLut, IndexColorModel icm, byte[] pix, int off, int scansize, @@ -450,27 +446,17 @@ (biRaster instanceof ByteComponentRaster) && (biRaster.getNumDataElements() == 1)){ ByteComponentRaster bt = (ByteComponentRaster) biRaster; - if (w*h > 200) { - if (off == 0 && scansize == w) { - bt.putByteData(x, y, w, h, pix); - } - else { - byte[] bpix = new byte[w]; - poff = off; - for (int yoff=y; yoff < y+h; yoff++) { - System.arraycopy(pix, poff, bpix, 0, w); - bt.putByteData(x, yoff, w, 1, bpix); - poff += scansize; - } - } + if (off == 0 && scansize == w) { + bt.putByteData(x, y, w, h, pix); } else { - // Only is faster if #pixels - // Note that setBytePixels modifies the raster directly - // so we must mark it as changed afterwards - setBytePixels(x, y, w, h, pix, off, scansize, bt, - bt.getDataOffset(0)); - bt.markDirty(); + byte[] bpix = new byte[w]; + poff = off; + for (int yoff=y; yoff < y+h; yoff++) { + System.arraycopy(pix, poff, bpix, 0, w); + bt.putByteData(x, yoff, w, 1, bpix); + poff += scansize; + } } } else { --- old/src/share/native/sun/awt/image/awt_ImageRep.c Wed Sep 9 17:45:28 2009 +++ openjdk/jdk/src/share/native/sun/awt/image/awt_ImageRep.c Wed Sep 9 17:45:28 2009 @@ -142,84 +142,6 @@ } -JNIEXPORT void JNICALL -Java_sun_awt_image_ImageRepresentation_setBytePixels(JNIEnv *env, jclass cls, - jint x, jint y, jint w, - jint h, jbyteArray jpix, - jint off, jint scansize, - jobject jbct, - jint chanOffs) -{ - int sStride; - int pixelStride; - jobject jdata; - unsigned char *srcData; - unsigned char *dstData; - unsigned char *dataP; - unsigned char *pixP; - int i; - int j; - - - if (JNU_IsNull(env, jpix)) { - JNU_ThrowNullPointerException(env, "NullPointerException"); - return; - } - - sStride = (*env)->GetIntField(env, jbct, g_BCRscanstrID); - pixelStride = (*env)->GetIntField(env, jbct, g_BCRpixstrID); - jdata = (*env)->GetObjectField(env, jbct, g_BCRdataID); - - srcData = (unsigned char *) (*env)->GetPrimitiveArrayCritical(env, jpix, - NULL); - if (srcData == NULL) { - /* out of memory error already thrown */ - return; - } - - dstData = (unsigned char *) (*env)->GetPrimitiveArrayCritical(env, jdata, - NULL); - if (dstData == NULL) { - /* out of memory error already thrown */ - (*env)->ReleasePrimitiveArrayCritical(env, jpix, srcData, JNI_ABORT); - return; - } - - dataP = dstData + chanOffs + y*sStride + x*pixelStride; - pixP = srcData + off; - if (pixelStride == 1) { - if (sStride == scansize && scansize == w) { - memcpy(dataP, pixP, w*h); - } - else { - for (i=0; i < h; i++) { - memcpy(dataP, pixP, w); - dataP += sStride; - pixP += scansize; - } - } - } - else { - unsigned char *ydataP = dataP; - unsigned char *ypixP = pixP; - - for (i=0; i < h; i++) { - dataP = ydataP; - pixP = ypixP; - for (j=0; j < w; j++) { - *dataP = *pixP++; - dataP += pixelStride; - } - ydataP += sStride; - ypixP += scansize; - } - } - - (*env)->ReleasePrimitiveArrayCritical(env, jpix, srcData, JNI_ABORT); - (*env)->ReleasePrimitiveArrayCritical(env, jdata, dstData, JNI_ABORT); - -} - JNIEXPORT jint JNICALL Java_sun_awt_image_ImageRepresentation_setDiffICM(JNIEnv *env, jclass cls, jint x, jint y, jint w, --- old/src/share/native/sun/awt/image/jpeg/imageioJPEG.c Mon Sep 7 13:25:13 2009 +++ openjdk/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c Mon Sep 7 13:25:12 2009 @@ -1837,6 +1837,13 @@ return JNI_FALSE; } + if (stepX > cinfo->image_width) { + stepX = cinfo->image_width; + } + if (stepY > cinfo->image_height) { + stepY = cinfo->image_height; + } + /* * First get the source bands array and copy it to our local array * so we don't have to worry about pinning and unpinning it again. --- old/src/share/classes/java/awt/color/ICC_Profile.java 2009-07-29 13:31:14.948600000 +0400 +++ openjdk/jdk/src/share/classes/java/awt/color/ICC_Profile.java 2009-07-29 13:31:14.153000000 +0400 @@ -944,15 +944,15 @@ * and it does not permit read access to the given file. */ public static ICC_Profile getInstance(String fileName) throws IOException { - ICC_Profile thisProfile; - FileInputStream fis; + ICC_Profile thisProfile; + FileInputStream fis = null; - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkRead(fileName); - } - if ((fis = openProfile(fileName)) == null) { + File f = getProfileFile(fileName); + if (f != null) { + fis = new FileInputStream(f); + } + if (fis == null) { throw new IOException("Cannot open file " + fileName); } @@ -1064,13 +1064,24 @@ void activateDeferredProfile() { - byte profileData[]; - FileInputStream fis; - String fileName = deferralInfo.filename; + byte profileData[]; + FileInputStream fis; + final String fileName = deferralInfo.filename; profileActivator = null; deferralInfo = null; - if ((fis = openProfile(fileName)) == null) { + PrivilegedAction<FileInputStream> pa = new PrivilegedAction<FileInputStream>() { + public FileInputStream run() { + File f = getStandardProfileFile(fileName); + if (f != null) { + try { + return new FileInputStream(f); + } catch (FileNotFoundException e) {} + } + return null; + } + }; + if ((fis = AccessController.doPrivileged(pa)) == null) { throw new IllegalArgumentException("Cannot open file " + fileName); } try { @@ -1765,66 +1776,88 @@ * available, such as a profile for sRGB. Built-in profiles use .pf as * the file name extension for profiles, e.g. sRGB.pf. */ - private static FileInputStream openProfile(final String fileName) { - return (FileInputStream)java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { - return privilegedOpenProfile(fileName); - } - }); - } - - /* - * this version is called from doPrivileged in privilegedOpenProfile. - * the whole method is privileged! - */ - private static FileInputStream privilegedOpenProfile(String fileName) { - FileInputStream fis = null; + private static File getProfileFile(String fileName) { String path, dir, fullPath; File f = new File(fileName); /* try absolute file name */ - + if (f.isAbsolute()) { + /* Rest of code has little sense for an absolute pathname, + so return here. */ + return f.isFile() ? f : null; + } if ((!f.isFile()) && ((path = System.getProperty("java.iccprofile.path")) != null)){ /* try relative to java.iccprofile.path */ - StringTokenizer st = - new StringTokenizer(path, File.pathSeparator); - while (st.hasMoreTokens() && (!f.isFile())) { - dir = st.nextToken(); - fullPath = dir + File.separatorChar + fileName; - f = new File(fullPath); + StringTokenizer st = + new StringTokenizer(path, File.pathSeparator); + while (st.hasMoreTokens() && ((f == null) || (!f.isFile()))) { + dir = st.nextToken(); + fullPath = dir + File.separatorChar + fileName; + f = new File(fullPath); + if (!isChildOf(f, dir)) { + f = null; } } + } - if ((!f.isFile()) && + if (((f == null) || (!f.isFile())) && ((path = System.getProperty("java.class.path")) != null)) { /* try relative to java.class.path */ - StringTokenizer st = - new StringTokenizer(path, File.pathSeparator); - while (st.hasMoreTokens() && (!f.isFile())) { - dir = st.nextToken(); - fullPath = dir + File.separatorChar + fileName; - f = new File(fullPath); - } - } - - if (!f.isFile()) { /* try the directory of built-in profiles */ - dir = System.getProperty("java.home") + - File.separatorChar + "lib" + File.separatorChar + "cmm"; + StringTokenizer st = + new StringTokenizer(path, File.pathSeparator); + while (st.hasMoreTokens() && ((f == null) || (!f.isFile()))) { + dir = st.nextToken(); fullPath = dir + File.separatorChar + fileName; f = new File(fullPath); + if (!isChildOf(f, dir)) { + f = null; + } } + } + if ((f == null) || (!f.isFile())) { + /* try the directory of built-in profiles */ + f = getStandardProfileFile(fileName); + } + if (f != null && f.isFile()) { + return f; + } + return null; + } - if (f.isFile()) { - try { - fis = new FileInputStream(f); - } catch (FileNotFoundException e) { + /** + * Returns a file object corresponding to a built-in profile + * specified by fileName. + * If there is no built-in profile with such name, then the method + * returns null. + */ + private static File getStandardProfileFile(String fileName) { + String dir = System.getProperty("java.home") + + File.separatorChar + "lib" + File.separatorChar + "cmm"; + String fullPath = dir + File.separatorChar + fileName; + File f = new File(fullPath); + return (f.isFile() && isChildOf(f, dir)) ? f : null; + } + + /** + * Checks whether given file resides inside give directory. + */ + private static boolean isChildOf(File f, String dirName) { + try { + File dir = new File(dirName); + String canonicalDirName = dir.getCanonicalPath(); + if (!canonicalDirName.endsWith(File.separator)) { + canonicalDirName += File.separator; } + String canonicalFileName = f.getCanonicalPath(); + return canonicalFileName.startsWith(canonicalDirName); + } catch (IOException e) { + /* we do not expect the IOException here, because invocation + * of this function is always preceeded by isFile() call. + */ + return false; } - return fis; } - /* * Serialization support. * --- old/src/share/classes/javax/swing/ToolTipManager.java 2009-08-11 12:05:32.501050200 +0400 +++ openjdk/jdk/src/share/classes/javax/swing/ToolTipManager.java 2009-08-11 12:05:31.670050200 +0400 @@ -1,5 +1,5 @@ /* - * Copyright 1997-2006 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,10 +27,7 @@ package javax.swing; import java.awt.event.*; -import java.applet.*; import java.awt.*; -import java.io.Serializable; -import sun.swing.UIAction; /** * Manages all the <code>ToolTips</code> in the system. @@ -60,7 +57,7 @@ JComponent insideComponent; MouseEvent mouseEvent; boolean showImmediately; - final static ToolTipManager sharedInstance = new ToolTipManager(); + private static final Object TOOL_TIP_MANAGER_KEY = new Object(); transient Popup tipWindow; /** The Window tip is being displayed in. This will be non-null if * the Window tip is in differs from that of insideComponent's Window. @@ -345,7 +342,13 @@ * @return a shared <code>ToolTipManager</code> object */ public static ToolTipManager sharedInstance() { - return sharedInstance; + Object value = SwingUtilities.appContextGet(TOOL_TIP_MANAGER_KEY); + if (value instanceof ToolTipManager) { + return (ToolTipManager) value; + } + ToolTipManager manager = new ToolTipManager(); + SwingUtilities.appContextPut(TOOL_TIP_MANAGER_KEY, manager); + return manager; } // add keylistener here to trigger tip for access --- old/src/share/classes/javax/swing/UIManager.java 2009-08-11 12:05:43.423050200 +0400 +++ openjdk/jdk/src/share/classes/javax/swing/UIManager.java 2009-08-11 12:05:42.671050200 +0400 @@ -1,5 +1,5 @@ /* - * Copyright 1997-2006 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 @@ -194,6 +194,8 @@ Vector auxLookAndFeels = null; SwingPropertyChangeSupport changeSupport; + LookAndFeelInfo[] installedLAFs; + UIDefaults getLookAndFeelDefaults() { return tables[0]; } void setLookAndFeelDefaults(UIDefaults x) { tables[0] = x; } @@ -224,18 +226,6 @@ */ private static final Object classLock = new Object(); - - /* Cache the last referenced LAFState to improve performance - * when accessing it. The cache is based on last thread rather - * than last AppContext because of the cost of looking up the - * AppContext each time. Since most Swing UI work is on the - * EventDispatchThread, this hits often enough to justify the - * overhead. (4193032) - */ - private static Thread currentLAFStateThread = null; - private static LAFState currentLAFState = null; - - /** * Return the <code>LAFState</code> object, lazily create one if necessary. * All access to the <code>LAFState</code> fields is done via this method, @@ -245,13 +235,6 @@ * </pre> */ private static LAFState getLAFState() { - // First check whether we're running on the same thread as - // the last request. - Thread thisThread = Thread.currentThread(); - if (thisThread == currentLAFStateThread) { - return currentLAFState; - } - LAFState rv = (LAFState)SwingUtilities.appContextGet( SwingUtilities2.LAF_STATE_KEY); if (rv == null) { @@ -265,10 +248,6 @@ } } } - - currentLAFStateThread = thisThread; - currentLAFState = rv; - return rv; } @@ -427,7 +406,10 @@ */ public static LookAndFeelInfo[] getInstalledLookAndFeels() { maybeInitialize(); - LookAndFeelInfo[] ilafs = installedLAFs; + LookAndFeelInfo[] ilafs = getLAFState().installedLAFs; + if (ilafs == null) { + ilafs = installedLAFs; + } LookAndFeelInfo[] rv = new LookAndFeelInfo[ilafs.length]; System.arraycopy(ilafs, 0, rv, 0, ilafs.length); return rv; @@ -449,9 +431,10 @@ public static void setInstalledLookAndFeels(LookAndFeelInfo[] infos) throws SecurityException { + maybeInitialize(); LookAndFeelInfo[] newInfos = new LookAndFeelInfo[infos.length]; System.arraycopy(infos, 0, newInfos, 0, infos.length); - installedLAFs = newInfos; + getLAFState().installedLAFs = newInfos; } @@ -1304,10 +1287,11 @@ } } - installedLAFs = new LookAndFeelInfo[ilafs.size()]; + LookAndFeelInfo[] installedLAFs = new LookAndFeelInfo[ilafs.size()]; for(int i = 0; i < ilafs.size(); i++) { installedLAFs[i] = (LookAndFeelInfo)(ilafs.elementAt(i)); } + getLAFState().installedLAFs = installedLAFs; } - --- old/src/share/classes/javax/swing/plaf/metal/MetalBorders.java 2009-08-11 12:05:53.917050200 +0400 +++ openjdk/jdk/src/share/classes/javax/swing/plaf/metal/MetalBorders.java 2009-08-11 12:05:53.184050200 +0400 @@ -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 @@ -33,14 +33,11 @@ import java.awt.Component; import java.awt.Insets; -import java.awt.Dimension; -import java.awt.Rectangle; import java.awt.Color; import java.awt.Dialog; import java.awt.Frame; import java.awt.Graphics; import java.awt.Window; -import java.io.Serializable; import sun.swing.StringUIClientPropertyKey; @@ -62,8 +59,6 @@ public static class Flush3DBorder extends AbstractBorder implements UIResource{ - private static final Insets insets = new Insets(2, 2, 2, 2); - public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { if (c.isEnabled()) { @@ -73,13 +68,13 @@ } } public Insets getBorderInsets(Component c) { - return insets; + return new Insets(2, 2, 2, 2); } public Insets getBorderInsets(Component c, Insets newInsets) { - newInsets.top = insets.top; - newInsets.left = insets.left; - newInsets.bottom = insets.bottom; - newInsets.right = insets.right; + newInsets.top = 2; + newInsets.left = 2; + newInsets.bottom = 2; + newInsets.right = 2; return newInsets; } } @@ -190,21 +185,19 @@ } public Insets getBorderInsets( Component c ) { - return borderInsets; + return new Insets(3, 3, 3, 3); } public Insets getBorderInsets(Component c, Insets newInsets) { - newInsets.top = borderInsets.top; - newInsets.left = borderInsets.left; - newInsets.bottom = borderInsets.bottom; - newInsets.right = borderInsets.right; + newInsets.top = 3; + newInsets.left = 3; + newInsets.bottom = 3; + newInsets.right = 3; return newInsets; } } public static class InternalFrameBorder extends AbstractBorder implements UIResource { - private static final Insets insets = new Insets(5, 5, 5, 5); - private static final int corner = 14; public void paintBorder(Component c, Graphics g, int x, int y, @@ -256,13 +249,13 @@ } public Insets getBorderInsets(Component c) { - return insets; + return new Insets(5, 5, 5, 5); } public Insets getBorderInsets(Component c, Insets newInsets) { - newInsets.top = insets.top; - newInsets.left = insets.left; - newInsets.bottom = insets.bottom; - newInsets.right = insets.right; + newInsets.top = 5; + newInsets.left = 5; + newInsets.bottom = 5; + newInsets.right = 5; return newInsets; } } @@ -273,8 +266,6 @@ */ static class FrameBorder extends AbstractBorder implements UIResource { - private static final Insets insets = new Insets(5, 5, 5, 5); - private static final int corner = 14; public void paintBorder(Component c, Graphics g, int x, int y, @@ -326,15 +317,15 @@ } public Insets getBorderInsets(Component c) { - return insets; + return new Insets(5, 5, 5, 5); } public Insets getBorderInsets(Component c, Insets newInsets) { - newInsets.top = insets.top; - newInsets.left = insets.left; - newInsets.bottom = insets.bottom; - newInsets.right = insets.right; + newInsets.top = 5; + newInsets.left = 5; + newInsets.bottom = 5; + newInsets.right = 5; return newInsets; } } @@ -345,7 +336,6 @@ */ static class DialogBorder extends AbstractBorder implements UIResource { - private static final Insets insets = new Insets(5, 5, 5, 5); private static final int corner = 14; protected Color getActiveBackground() @@ -427,15 +417,15 @@ } public Insets getBorderInsets(Component c) { - return insets; + return new Insets(5, 5, 5, 5); } public Insets getBorderInsets(Component c, Insets newInsets) { - newInsets.top = insets.top; - newInsets.left = insets.left; - newInsets.bottom = insets.bottom; - newInsets.right = insets.right; + newInsets.top = 5; + newInsets.left = 5; + newInsets.bottom = 5; + newInsets.right = 5; return newInsets; } } @@ -482,7 +472,6 @@ * @since 1.3 */ public static class PaletteBorder extends AbstractBorder implements UIResource { - private static final Insets insets = new Insets(1, 1, 1, 1); int titleHeight = 0; public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) { @@ -499,20 +488,19 @@ } public Insets getBorderInsets(Component c) { - return insets; + return new Insets(1, 1, 1, 1); } public Insets getBorderInsets(Component c, Insets newInsets) { - newInsets.top = insets.top; - newInsets.left = insets.left; - newInsets.bottom = insets.bottom; - newInsets.right = insets.right; + newInsets.top = 1; + newInsets.left = 1; + newInsets.bottom = 1; + newInsets.right = 1; return newInsets; } } public static class OptionDialogBorder extends AbstractBorder implements UIResource { - private static final Insets insets = new Insets(3, 3, 3, 3); int titleHeight = 0; public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) { @@ -568,14 +556,14 @@ } public Insets getBorderInsets(Component c) { - return insets; + return new Insets(3, 3, 3, 3); } public Insets getBorderInsets(Component c, Insets newInsets) { - newInsets.top = insets.top; - newInsets.left = insets.left; - newInsets.bottom = insets.bottom; - newInsets.right = insets.right; + newInsets.top = 3; + newInsets.left = 3; + newInsets.bottom = 3; + newInsets.right = 3; return newInsets; } } @@ -615,10 +603,10 @@ newInsets.set(0, 0, 2, 0); } else { - newInsets.top = borderInsets.top; - newInsets.left = borderInsets.left; - newInsets.bottom = borderInsets.bottom; - newInsets.right = borderInsets.right; + newInsets.top = 1; + newInsets.left = 0; + newInsets.bottom = 1; + newInsets.right = 0; } return newInsets; } @@ -663,14 +651,14 @@ } public Insets getBorderInsets( Component c ) { - return borderInsets; + return new Insets(2, 2, 2, 2); } public Insets getBorderInsets(Component c, Insets newInsets) { - newInsets.top = borderInsets.top; - newInsets.left = borderInsets.left; - newInsets.bottom = borderInsets.bottom; - newInsets.right = borderInsets.right; + newInsets.top = 2; + newInsets.left = 2; + newInsets.bottom = 2; + newInsets.right = 2; return newInsets; } } @@ -694,14 +682,14 @@ } public Insets getBorderInsets( Component c ) { - return borderInsets; + return new Insets(3, 1, 2, 1); } public Insets getBorderInsets(Component c, Insets newInsets) { - newInsets.top = borderInsets.top; - newInsets.left = borderInsets.left; - newInsets.bottom = borderInsets.bottom; - newInsets.right = borderInsets.right; + newInsets.top = 3; + newInsets.left = 1; + newInsets.bottom = 2; + newInsets.right = 1; return newInsets; } } @@ -911,8 +899,6 @@ public static class ScrollPaneBorder extends AbstractBorder implements UIResource { - private static final Insets insets = new Insets(1, 1, 2, 2); - public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { @@ -946,7 +932,7 @@ } public Insets getBorderInsets(Component c) { - return insets; + return new Insets(1, 1, 2, 2); } } --- old/src/share/classes/javax/swing/plaf/metal/MetalBumps.java 2009-08-11 12:06:04.423050200 +0400 +++ openjdk/jdk/src/share/classes/javax/swing/plaf/metal/MetalBumps.java 2009-08-11 12:06:03.678050200 +0400 @@ -1,5 +1,5 @@ /* - * Copyright 1998-2003 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 @@ -25,11 +25,22 @@ package javax.swing.plaf.metal; -import java.awt.*; -import java.awt.image.*; -import javax.swing.*; -import java.io.*; -import java.util.*; +import sun.awt.AppContext; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GraphicsConfiguration; +import java.awt.Image; +import java.awt.Transparency; +import java.awt.image.BufferedImage; +import java.awt.image.DataBuffer; +import java.awt.image.IndexColorModel; +import java.util.ArrayList; +import java.util.List; +import javax.swing.Icon; /** * Implements the bumps used throughout the Metal Look and Feel. @@ -49,19 +60,9 @@ protected Color shadowColor; protected Color backColor; - protected static Vector buffers = new Vector(); + private static final Object METAL_BUMPS = new Object(); protected BumpBuffer buffer; - public MetalBumps( Dimension bumpArea ) { - this( bumpArea.width, bumpArea.height ); - } - - public MetalBumps( int width, int height ) { - this(width, height, MetalLookAndFeel.getPrimaryControlHighlight(), - MetalLookAndFeel.getPrimaryControlDarkShadow(), - MetalLookAndFeel.getPrimaryControlShadow()); - } - /** * Creates MetalBumps of the specified size with the specified colors. * If <code>newBackColor</code> is null, the background will be @@ -73,29 +74,22 @@ setBumpColors( newTopColor, newShadowColor, newBackColor ); } - private BumpBuffer getBuffer(GraphicsConfiguration gc, Color aTopColor, - Color aShadowColor, Color aBackColor) { - if (buffer != null && buffer.hasSameConfiguration( - gc, aTopColor, aShadowColor, aBackColor)) { - return buffer; - } - BumpBuffer result = null; - - Enumeration elements = buffers.elements(); - - while ( elements.hasMoreElements() ) { - BumpBuffer aBuffer = (BumpBuffer)elements.nextElement(); - if ( aBuffer.hasSameConfiguration(gc, aTopColor, aShadowColor, - aBackColor)) { - result = aBuffer; - break; + private static BumpBuffer createBuffer(GraphicsConfiguration gc, + Color topColor, Color shadowColor, Color backColor) { + AppContext context = AppContext.getAppContext(); + List<BumpBuffer> buffers = (List<BumpBuffer>) context.get(METAL_BUMPS); + if (buffers == null) { + buffers = new ArrayList<BumpBuffer>(); + context.put(METAL_BUMPS, buffers); + } + for (BumpBuffer buffer : buffers) { + if (buffer.hasSameConfiguration(gc, topColor, shadowColor, backColor)) { + return buffer; } } - if (result == null) { - result = new BumpBuffer(gc, topColor, shadowColor, backColor); - buffers.addElement(result); - } - return result; + BumpBuffer buffer = new BumpBuffer(gc, topColor, shadowColor, backColor); + buffers.add(buffer); + return buffer; } public void setBumpArea( Dimension bumpArea ) { @@ -123,10 +117,12 @@ (GraphicsConfiguration)((Graphics2D)g). getDeviceConfiguration() : null; - buffer = getBuffer(gc, topColor, shadowColor, backColor); + if ((buffer == null) || !buffer.hasSameConfiguration(gc, topColor, shadowColor, backColor)) { + buffer = createBuffer(gc, topColor, shadowColor, backColor); + } - int bufferWidth = buffer.getImageSize().width; - int bufferHeight = buffer.getImageSize().height; + int bufferWidth = BumpBuffer.IMAGE_SIZE; + int bufferHeight = BumpBuffer.IMAGE_SIZE; int iconWidth = getIconWidth(); int iconHeight = getIconHeight(); int x2 = x + iconWidth; @@ -159,7 +155,6 @@ class BumpBuffer { static final int IMAGE_SIZE = 64; - static Dimension imageSize = new Dimension( IMAGE_SIZE, IMAGE_SIZE ); transient Image image; Color topColor; @@ -201,10 +196,6 @@ return image; } - public Dimension getImageSize() { - return imageSize; - } - /** * Paints the bumps into the current image. */ --- old/src/share/classes/javax/swing/plaf/metal/MetalInternalFrameUI.java 2009-08-11 12:06:14.763050200 +0400 +++ openjdk/jdk/src/share/classes/javax/swing/plaf/metal/MetalInternalFrameUI.java 2009-08-11 12:06:14.053050200 +0400 @@ -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 @@ -31,10 +31,8 @@ import javax.swing.event.*; import javax.swing.border.*; import javax.swing.plaf.basic.*; -import java.util.EventListener; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeEvent; -import java.beans.PropertyVetoException; import javax.swing.plaf.*; /** @@ -51,7 +49,7 @@ private static final Border handyEmptyBorder = new EmptyBorder(0,0,0,0); protected static String IS_PALETTE = "JInternalFrame.isPalette"; - + private static String IS_PALETTE_KEY = "JInternalFrame.isPalette"; private static String FRAME_TYPE = "JInternalFrame.frameType"; private static String NORMAL_FRAME = "normal"; private static String PALETTE_FRAME = "palette"; @@ -68,7 +66,7 @@ public void installUI(JComponent c) { super.installUI(c); - Object paletteProp = c.getClientProperty( IS_PALETTE ); + Object paletteProp = c.getClientProperty(IS_PALETTE_KEY); if ( paletteProp != null ) { setPalette( ((Boolean)paletteProp).booleanValue() ); } @@ -187,7 +185,7 @@ ui.setFrameType( (String) e.getNewValue() ); } } - else if ( name.equals( IS_PALETTE ) ) + else if ( name.equals(IS_PALETTE_KEY) ) { if ( e.getNewValue() != null ) { --- old/src/share/classes/javax/swing/plaf/metal/MetalSliderUI.java 2009-08-11 12:06:25.043050200 +0400 +++ openjdk/jdk/src/share/classes/javax/swing/plaf/metal/MetalSliderUI.java 2009-08-11 12:06:24.344050200 +0400 @@ -1,5 +1,5 @@ /* - * Copyright 1998-2005 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 @@ -27,23 +27,12 @@ import javax.swing.plaf.basic.BasicSliderUI; -import java.awt.Component; -import java.awt.Container; import java.awt.Graphics; import java.awt.Dimension; import java.awt.Rectangle; -import java.awt.Point; -import java.awt.Insets; import java.awt.Color; -import java.io.Serializable; -import java.awt.IllegalComponentStateException; -import java.awt.Polygon; import java.beans.*; - -import javax.swing.border.AbstractBorder; - import javax.swing.*; -import javax.swing.event.*; import javax.swing.plaf.*; /** @@ -64,12 +53,13 @@ protected final int TICK_BUFFER = 4; protected boolean filledSlider = false; - // NOTE: these next three variables are currently unused. + // NOTE: these next five variables are currently unused. protected static Color thumbColor; protected static Color highlightColor; protected static Color darkShadowColor; protected static int trackWidth; protected static int tickLength; + private int safeLength; /** * A default horizontal thumb <code>Icon</code>. This field might not be @@ -117,7 +107,7 @@ public void installUI( JComponent c ) { trackWidth = ((Integer)UIManager.get( "Slider.trackWidth" )).intValue(); - tickLength = ((Integer)UIManager.get( "Slider.majorTickLength" )).intValue(); + tickLength = safeLength = ((Integer)UIManager.get( "Slider.majorTickLength" )).intValue(); horizThumbIcon = SAFE_HORIZ_THUMB_ICON = UIManager.getIcon( "Slider.horizontalThumbIcon" ); vertThumbIcon = SAFE_VERT_THUMB_ICON = @@ -465,8 +455,8 @@ * determine the tick area rectangle. */ public int getTickLength() { - return slider.getOrientation() == JSlider.HORIZONTAL ? tickLength + TICK_BUFFER + 1 : - tickLength + TICK_BUFFER + 3; + return slider.getOrientation() == JSlider.HORIZONTAL ? safeLength + TICK_BUFFER + 1 : + safeLength + TICK_BUFFER + 3; } /** @@ -511,22 +501,22 @@ protected void paintMinorTickForHorizSlider( Graphics g, Rectangle tickBounds, int x ) { g.setColor( slider.isEnabled() ? slider.getForeground() : MetalLookAndFeel.getControlShadow() ); - g.drawLine( x, TICK_BUFFER, x, TICK_BUFFER + (tickLength / 2) ); + g.drawLine( x, TICK_BUFFER, x, TICK_BUFFER + (safeLength / 2) ); } protected void paintMajorTickForHorizSlider( Graphics g, Rectangle tickBounds, int x ) { g.setColor( slider.isEnabled() ? slider.getForeground() : MetalLookAndFeel.getControlShadow() ); - g.drawLine( x, TICK_BUFFER , x, TICK_BUFFER + (tickLength - 1) ); + g.drawLine( x, TICK_BUFFER , x, TICK_BUFFER + (safeLength - 1) ); } protected void paintMinorTickForVertSlider( Graphics g, Rectangle tickBounds, int y ) { g.setColor( slider.isEnabled() ? slider.getForeground() : MetalLookAndFeel.getControlShadow() ); if (MetalUtils.isLeftToRight(slider)) { - g.drawLine( TICK_BUFFER, y, TICK_BUFFER + (tickLength / 2), y ); + g.drawLine( TICK_BUFFER, y, TICK_BUFFER + (safeLength / 2), y ); } else { - g.drawLine( 0, y, tickLength/2, y ); + g.drawLine( 0, y, safeLength/2, y ); } } @@ -534,10 +524,10 @@ g.setColor( slider.isEnabled() ? slider.getForeground() : MetalLookAndFeel.getControlShadow() ); if (MetalUtils.isLeftToRight(slider)) { - g.drawLine( TICK_BUFFER, y, TICK_BUFFER + tickLength, y ); + g.drawLine( TICK_BUFFER, y, TICK_BUFFER + safeLength, y ); } else { - g.drawLine( 0, y, tickLength, y ); + g.drawLine( 0, y, safeLength, y ); } } } - --- old/src/share/classes/javax/swing/plaf/basic/BasicSplitPaneUI.java 2009-08-11 12:06:35.519050200 +0400 +++ openjdk/jdk/src/share/classes/javax/swing/plaf/basic/BasicSplitPaneUI.java 2009-08-11 12:06:34.752050200 +0400 @@ -1,5 +1,5 @@ /* - * Copyright 1997-2006 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 @@ -31,14 +31,12 @@ import sun.swing.UIAction; import javax.swing.*; import javax.swing.border.Border; -import javax.swing.event.*; import java.awt.*; import java.awt.event.*; import java.awt.peer.ComponentPeer; import java.awt.peer.LightweightPeer; import java.beans.*; import java.util.*; -import javax.swing.plaf.ActionMapUIResource; import javax.swing.plaf.SplitPaneUI; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.UIResource; @@ -106,13 +104,13 @@ * Keys to use for forward focus traversal when the JComponent is * managing focus. */ - private static Set managingFocusForwardTraversalKeys; + private Set managingFocusForwardTraversalKeys; /** * Keys to use for backward focus traversal when the JComponent is * managing focus. */ - private static Set managingFocusBackwardTraversalKeys; + private Set managingFocusBackwardTraversalKeys; /** @@ -674,7 +672,7 @@ * @return increment via keyboard methods. */ int getKeyboardMoveIncrement() { - return KEYBOARD_DIVIDER_MOVE_OFFSET; + return 3; } /** --- old/src/share/classes/javax/swing/plaf/basic/BasicLabelUI.java 2009-08-11 12:06:46.036050200 +0400 +++ openjdk/jdk/src/share/classes/javax/swing/plaf/basic/BasicLabelUI.java 2009-08-11 12:06:45.272050200 +0400 @@ -65,6 +65,9 @@ protected static BasicLabelUI labelUI = new BasicLabelUI(); private final static BasicLabelUI SAFE_BASIC_LABEL_UI = new BasicLabelUI(); + private Rectangle paintIconR = new Rectangle(); + private Rectangle paintTextR = new Rectangle(); + static void loadActionMap(LazyActionMap map) { map.put(new Actions(Actions.PRESS)); map.put(new Actions(Actions.RELEASE)); @@ -135,17 +138,6 @@ textX, textY); } - - /* These rectangles/insets are allocated once for this shared LabelUI - * implementation. Re-using rectangles rather than allocating - * them in each paint call halved the time it took paint to run. - */ - private static Rectangle paintIconR = new Rectangle(); - private static Rectangle paintTextR = new Rectangle(); - private static Rectangle paintViewR = new Rectangle(); - private static Insets paintViewInsets = new Insets(0, 0, 0, 0); - - /** * Paint the label text in the foreground color, if the label * is opaque then paint the entire background with the background @@ -194,10 +186,11 @@ private String layout(JLabel label, FontMetrics fm, int width, int height) { - Insets insets = label.getInsets(paintViewInsets); + Insets insets = label.getInsets(null); String text = label.getText(); Icon icon = (label.isEnabled()) ? label.getIcon() : label.getDisabledIcon(); + Rectangle paintViewR = new Rectangle(); paintViewR.x = insets.left; paintViewR.y = insets.top; paintViewR.width = width - (insets.left + insets.right); @@ -208,24 +201,13 @@ paintTextR); } - - /* These rectangles/insets are allocated once for this shared LabelUI - * implementation. Re-using rectangles rather than allocating - * them in each getPreferredSize call sped up the method substantially. - */ - private static Rectangle iconR = new Rectangle(); - private static Rectangle textR = new Rectangle(); - private static Rectangle viewR = new Rectangle(); - private static Insets viewInsets = new Insets(0, 0, 0, 0); - - public Dimension getPreferredSize(JComponent c) { JLabel label = (JLabel)c; String text = label.getText(); Icon icon = (label.isEnabled()) ? label.getIcon() : label.getDisabledIcon(); - Insets insets = label.getInsets(viewInsets); + Insets insets = label.getInsets(null); Font font = label.getFont(); int dx = insets.left + insets.right; @@ -243,6 +225,9 @@ else { FontMetrics fm = label.getFontMetrics(font); + Rectangle iconR = new Rectangle(); + Rectangle textR = new Rectangle(); + Rectangle viewR = new Rectangle(); iconR.x = iconR.y = iconR.width = iconR.height = 0; textR.x = textR.y = textR.width = textR.height = 0; viewR.x = dx; --- old/src/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java 2009-08-11 12:06:52.019050200 +0400 +++ openjdk/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java 2009-08-11 12:06:51.308050200 +0400 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 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 @@ -27,7 +27,6 @@ import java.awt.*; import java.lang.reflect.*; -import java.security.*; import java.util.*; import javax.swing.*; import javax.swing.plaf.*; @@ -908,7 +907,7 @@ static class GTKStockIconInfo { private static Map<String,Integer> ICON_TYPE_MAP; - private static final Object ICON_SIZE_KEY = new StringBuffer("IconSize"); + private static final Object ICON_SIZE_KEY = new Object(); // IconSize private static Dimension[] getIconSizesMap() { AppContext appContext = AppContext.getAppContext(); --- old/src/share/classes/javax/swing/JComponent.java 2009-08-11 12:06:58.204050200 +0400 +++ openjdk/jdk/src/share/classes/javax/swing/JComponent.java 2009-08-11 12:06:57.513050200 +0400 @@ -1,5 +1,5 @@ /* - * Copyright 1997-2006 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,22 +27,15 @@ import java.util.HashSet; import java.util.Hashtable; -import java.util.Dictionary; import java.util.Enumeration; import java.util.Locale; import java.util.Vector; import java.util.EventListener; import java.util.Set; -import java.util.Map; -import java.util.HashMap; import java.awt.*; import java.awt.event.*; -import java.awt.image.VolatileImage; -import java.awt.Graphics2D; import java.awt.peer.LightweightPeer; -import java.awt.dnd.DropTarget; -import java.awt.font.FontRenderContext; import java.beans.*; import java.applet.Applet; @@ -220,8 +213,7 @@ * indicates the EDT is calling into the InputVerifier from the * returned component. */ - private static final Object INPUT_VERIFIER_SOURCE_KEY = - new StringBuilder("InputVerifierSourceKey"); + private static final Object INPUT_VERIFIER_SOURCE_KEY = new Object(); // InputVerifierSourceKey /* The following fields support set methods for the corresponding * java.awt.Component properties. @@ -369,8 +361,7 @@ private static final String defaultLocale = "JComponent.defaultLocale"; private static Component componentObtainingGraphicsFrom; - private static Object componentObtainingGraphicsFromLock = new - StringBuilder("componentObtainingGraphicsFrom"); + private static Object componentObtainingGraphicsFromLock = new Object(); // componentObtainingGraphicsFrom /** * AA text hints. --- old/src/share/classes/javax/swing/JDialog.java 2009-08-11 12:07:04.991050200 +0400 +++ openjdk/jdk/src/share/classes/javax/swing/JDialog.java 2009-08-11 12:07:04.288050200 +0400 @@ -1,5 +1,5 @@ /* - * Copyright 1997-2006 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,12 +26,7 @@ import java.awt.*; import java.awt.event.*; -import java.beans.PropertyChangeListener; -import java.util.Locale; -import java.util.Vector; -import java.io.Serializable; import javax.accessibility.*; -import java.applet.Applet; /** * The main class for creating a dialog window. You can use this class @@ -108,8 +103,7 @@ * Key into the AppContext, used to check if should provide decorations * by default. */ - private static final Object defaultLookAndFeelDecoratedKey = - new StringBuffer("JDialog.defaultLookAndFeelDecorated"); + private static final Object defaultLookAndFeelDecoratedKey = new Object(); // JDialog.defaultLookAndFeelDecorated private int defaultCloseOperation = HIDE_ON_CLOSE; --- old/src/share/classes/javax/swing/JEditorPane.java 2009-08-11 12:07:11.080050200 +0400 +++ openjdk/jdk/src/share/classes/javax/swing/JEditorPane.java 2009-08-11 12:07:10.427050200 +0400 @@ -1,5 +1,5 @@ /* - * Copyright 1997-2006 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,12 +25,10 @@ package javax.swing; import java.awt.*; -import java.awt.event.*; import java.lang.reflect.*; import java.net.*; import java.util.*; import java.io.*; -import java.util.*; import javax.swing.plaf.*; import javax.swing.text.*; @@ -1598,12 +1596,9 @@ /* * Private AppContext keys for this class's static variables. */ - private static final Object kitRegistryKey = - new StringBuffer("JEditorPane.kitRegistry"); - private static final Object kitTypeRegistryKey = - new StringBuffer("JEditorPane.kitTypeRegistry"); - private static final Object kitLoaderRegistryKey = - new StringBuffer("JEditorPane.kitLoaderRegistry"); + private static final Object kitRegistryKey = new Object(); // JEditorPane.kitRegistry + private static final Object kitTypeRegistryKey = new Object(); // JEditorPane.kitTypeRegistry + private static final Object kitLoaderRegistryKey = new Object(); // JEditorPane.kitLoaderRegistry /** * @see #getUIClassID --- old/src/share/classes/javax/swing/JFrame.java 2009-08-11 12:07:17.419050200 +0400 +++ openjdk/jdk/src/share/classes/javax/swing/JFrame.java 2009-08-11 12:07:16.686050200 +0400 @@ -1,5 +1,5 @@ /* - * Copyright 1997-2006 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,11 +26,6 @@ import java.awt.*; import java.awt.event.*; -import java.beans.PropertyChangeListener; -import java.util.Locale; -import java.util.Vector; -import java.io.Serializable; - import javax.accessibility.*; @@ -130,8 +125,7 @@ * Key into the AppContext, used to check if should provide decorations * by default. */ - private static final Object defaultLookAndFeelDecoratedKey = - new StringBuffer("JFrame.defaultLookAndFeelDecorated"); + private static final Object defaultLookAndFeelDecoratedKey = new Object(); // JFrame.defaultLookAndFeelDecorated private int defaultCloseOperation = HIDE_ON_CLOSE; --- old/src/share/classes/javax/swing/JInternalFrame.java 2009-08-11 12:07:23.366050200 +0400 +++ openjdk/jdk/src/share/classes/javax/swing/JInternalFrame.java 2009-08-11 12:07:22.658050200 +0400 @@ -1,5 +1,5 @@ /* - * Copyright 1997-2006 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,13 +26,10 @@ package javax.swing; import java.awt.*; -import java.awt.event.*; import java.beans.PropertyVetoException; import java.beans.PropertyChangeEvent; -import java.util.EventListener; -import javax.swing.border.Border; import javax.swing.event.InternalFrameEvent; import javax.swing.event.InternalFrameListener; import javax.swing.plaf.*; @@ -40,9 +37,7 @@ import javax.accessibility.*; import java.io.ObjectOutputStream; -import java.io.ObjectInputStream; import java.io.IOException; -import java.lang.StringBuilder; import java.beans.PropertyChangeListener; import sun.awt.AppContext; import sun.swing.SwingUtilities2; @@ -226,8 +221,7 @@ /** Constrained property name indicating that the internal frame is iconified. */ public final static String IS_ICON_PROPERTY = "icon"; - private static final Object PROPERTY_CHANGE_LISTENER_KEY = - new StringBuilder("InternalFramePropertyChangeListener"); + private static final Object PROPERTY_CHANGE_LISTENER_KEY = new Object(); // InternalFramePropertyChangeListener private static void addPropertyChangeListenerIfNecessary() { if (AppContext.getAppContext().get(PROPERTY_CHANGE_LISTENER_KEY) == --- old/src/share/classes/javax/swing/JPopupMenu.java 2009-08-11 12:07:29.900050200 +0400 +++ openjdk/jdk/src/share/classes/javax/swing/JPopupMenu.java 2009-08-11 12:07:29.192050200 +0400 @@ -1,5 +1,5 @@ /* - * Copyright 1997-2006 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 @@ -33,17 +33,12 @@ import java.io.Serializable; import java.beans.*; -import java.util.Locale; import java.util.Vector; -import java.util.Hashtable; import javax.accessibility.*; import javax.swing.plaf.PopupMenuUI; -import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicComboPopup; import javax.swing.event.*; -import java.applet.Applet; - /** * An implementation of a popup menu -- a small window that pops up * and displays a series of choices. A <code>JPopupMenu</code> is used for the @@ -91,8 +86,7 @@ /** * Key used in AppContext to determine if light way popups are the default. */ - private static final Object defaultLWPopupEnabledKey = - new StringBuffer("JPopupMenu.defaultLWPopupEnabledKey"); + private static final Object defaultLWPopupEnabledKey = new Object(); // JPopupMenu.defaultLWPopupEnabledKey /** Bug#4425878-Property javax.swing.adjustPopupLocationToFit introduced */ static boolean popupPostionFixDisabled = false; --- old/src/share/classes/javax/swing/MenuSelectionManager.java 2009-08-11 12:07:36.023050200 +0400 +++ openjdk/jdk/src/share/classes/javax/swing/MenuSelectionManager.java 2009-08-11 12:07:35.359050200 +0400 @@ -1,5 +1,5 @@ /* - * Copyright 1997-2006 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 @@ -44,8 +44,7 @@ private static final boolean VERBOSE = false; // show reuse hits/misses private static final boolean DEBUG = false; // show bad params, misc. - private static final StringBuilder MENU_SELECTION_MANAGER_KEY = - new StringBuilder("javax.swing.MenuSelectionManager"); + private static final Object MENU_SELECTION_MANAGER_KEY = new Object(); // javax.swing.MenuSelectionManager /** * Returns the default menu selection manager. --- old/src/share/classes/javax/swing/PopupFactory.java 2009-08-11 12:07:42.008050200 +0400 +++ openjdk/jdk/src/share/classes/javax/swing/PopupFactory.java 2009-08-11 12:07:41.328050200 +0400 @@ -1,5 +1,5 @@ /* - * Copyright 1999-2006 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,7 @@ * <code>AppContext</code>. This is the key used in the * <code>AppContext</code> to locate the <code>PopupFactory</code>. */ - private static final Object SharedInstanceKey = - new StringBuffer("PopupFactory.SharedInstanceKey"); + private static final Object SharedInstanceKey = new Object(); // PopupFactory.SharedInstanceKey /** * Max number of items to store in any one particular cache. @@ -291,8 +290,7 @@ * Popup implementation that uses a Window as the popup. */ private static class HeavyWeightPopup extends Popup { - private static final Object heavyWeightPopupCacheKey = - new StringBuffer("PopupFactory.heavyWeightPopupCache"); + private static final Object heavyWeightPopupCacheKey = new Object(); // PopupFactory.heavyWeightPopupCache /** * Returns either a new or recycled <code>Popup</code> containing @@ -641,8 +639,7 @@ * Popup implementation that uses a JPanel as the popup. */ private static class LightWeightPopup extends ContainerPopup { - private static final Object lightWeightPopupCacheKey = - new StringBuffer("PopupFactory.lightPopupCache"); + private static final Object lightWeightPopupCacheKey = new Object(); // PopupFactory.lightPopupCache /** * Returns a light weight <code>Popup</code> implementation. If @@ -796,8 +793,7 @@ * Popup implementation that uses a Panel as the popup. */ private static class MediumWeightPopup extends ContainerPopup { - private static final Object mediumWeightPopupCacheKey = - new StringBuffer("PopupFactory.mediumPopupCache"); + private static final Object mediumWeightPopupCacheKey = new Object(); // PopupFactory.mediumPopupCache /** Child of the panel. The contents are added to this. */ private JRootPane rootPane; --- old/src/share/classes/javax/swing/SwingUtilities.java 2009-08-11 12:07:48.053050200 +0400 +++ openjdk/jdk/src/share/classes/javax/swing/SwingUtilities.java 2009-08-11 12:07:47.366050200 +0400 @@ -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 @@ -33,9 +33,6 @@ import java.awt.event.*; import java.awt.dnd.DropTarget; -import java.util.Vector; -import java.util.Hashtable; - import java.lang.reflect.*; import javax.accessibility.*; @@ -1750,8 +1747,7 @@ // Don't use String, as it's not guaranteed to be unique in a Hashtable. - private static final Object sharedOwnerFrameKey = - new StringBuffer("SwingUtilities.sharedOwnerFrame"); + private static final Object sharedOwnerFrameKey = new Object(); // SwingUtilities.sharedOwnerFrame static class SharedOwnerFrame extends Frame implements WindowListener { public void addNotify() { --- old/src/share/classes/javax/swing/SwingWorker.java 2009-08-11 12:07:54.496050200 +0400 +++ openjdk/jdk/src/share/classes/javax/swing/SwingWorker.java 2009-08-11 12:07:53.575050200 +0400 @@ -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 @@ -28,16 +28,12 @@ import java.beans.PropertyChangeSupport; import java.beans.PropertyChangeEvent; import java.util.List; -import java.util.ArrayList; -import java.util.Collections; import java.util.concurrent.*; import java.util.concurrent.locks.*; import java.awt.event.*; -import javax.swing.SwingUtilities; - import sun.awt.AppContext; import sun.swing.AccumulativeRunnable; @@ -860,7 +856,7 @@ return (ExecutorService)obj; } - private static final Object DO_SUBMIT_KEY = new StringBuilder("doSubmit"); + private static final Object DO_SUBMIT_KEY = new Object(); // doSubmit private static AccumulativeRunnable<Runnable> getDoSubmit() { synchronized (DO_SUBMIT_KEY) { final AppContext appContext = AppContext.getAppContext(); --- old/src/share/classes/javax/swing/TimerQueue.java 2009-08-11 12:08:00.562050200 +0400 +++ openjdk/jdk/src/share/classes/javax/swing/TimerQueue.java 2009-08-11 12:07:59.868050200 +0400 @@ -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 @@ -29,7 +29,6 @@ -import java.util.*; import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicLong; import sun.awt.AppContext; @@ -46,10 +45,7 @@ */ class TimerQueue implements Runnable { - private static final Object sharedInstanceKey = - new StringBuffer("TimerQueue.sharedInstanceKey"); - private static final Object expiredTimersKey = - new StringBuffer("TimerQueue.expiredTimersKey"); + private static final Object sharedInstanceKey = new Object(); // TimerQueue.sharedInstanceKey private final DelayQueue<DelayedTimer> queue; volatile boolean running; --- old/src/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java 2009-08-11 12:08:06.552050200 +0400 +++ openjdk/jdk/src/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java 2009-08-11 12:08:05.879050200 +0400 @@ -1,5 +1,5 @@ /* - * Copyright 1997-2006 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 @@ -29,9 +29,7 @@ import java.awt.event.*; import javax.swing.*; import javax.accessibility.*; -import javax.swing.FocusManager; import javax.swing.plaf.*; -import javax.swing.border.*; import javax.swing.text.*; import javax.swing.event.*; import java.beans.PropertyChangeListener; @@ -176,11 +174,9 @@ private Dimension cachedDisplaySize = new Dimension( 0, 0 ); // Key used for lookup of the DefaultListCellRenderer in the AppContext. - private static final Object COMBO_UI_LIST_CELL_RENDERER_KEY = - new StringBuffer("DefaultListCellRendererKey"); + private static final Object COMBO_UI_LIST_CELL_RENDERER_KEY = new Object(); // DefaultListCellRendererKey - static final StringBuffer HIDE_POPUP_KEY - = new StringBuffer("HidePopupKey"); + static final Object HIDE_POPUP_KEY = new Object(); // HidePopupKey /** * Whether or not all cells have the same baseline. --- old/src/share/classes/javax/swing/plaf/basic/BasicListUI.java 2009-08-11 12:08:12.745050200 +0400 +++ openjdk/jdk/src/share/classes/javax/swing/plaf/basic/BasicListUI.java 2009-08-11 12:08:12.055050200 +0400 @@ -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 @@ -56,8 +56,7 @@ */ public class BasicListUI extends ListUI { - private static final StringBuilder BASELINE_COMPONENT_KEY = - new StringBuilder("List.baselineComponent"); + private static final Object BASELINE_COMPONENT_KEY = new Object(); // List.baselineComponent protected JList list = null; protected CellRendererPane rendererPane; --- old/src/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java 2009-08-11 12:08:19.099050200 +0400 +++ openjdk/jdk/src/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java 2009-08-11 12:08:18.377050200 +0400 @@ -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 @@ -28,26 +28,18 @@ import javax.swing.*; import javax.swing.event.*; import javax.swing.plaf.*; -import javax.swing.plaf.basic.*; -import javax.swing.border.*; import java.applet.Applet; import java.awt.Component; -import java.awt.Container; -import java.awt.Dimension; import java.awt.KeyboardFocusManager; import java.awt.Window; import java.awt.event.*; import java.awt.AWTEvent; import java.awt.Toolkit; -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeEvent; - import java.util.*; -import sun.swing.DefaultLookup; import sun.swing.UIAction; import sun.awt.AppContext; @@ -61,10 +53,8 @@ * @author Arnaud Weber */ public class BasicPopupMenuUI extends PopupMenuUI { - static final StringBuilder MOUSE_GRABBER_KEY = new StringBuilder( - "javax.swing.plaf.basic.BasicPopupMenuUI.MouseGrabber"); - static final StringBuilder MENU_KEYBOARD_HELPER_KEY = new StringBuilder( - "javax.swing.plaf.basic.BasicPopupMenuUI.MenuKeyboardHelper"); + static final Object MOUSE_GRABBER_KEY = new Object(); // javax.swing.plaf.basic.BasicPopupMenuUI.MouseGrabber + static final Object MENU_KEYBOARD_HELPER_KEY = new Object(); // javax.swing.plaf.basic.BasicPopupMenuUI.MenuKeyboardHelper protected JPopupMenu popupMenu = null; private transient PopupMenuListener popupMenuListener = null; --- old/src/share/classes/javax/swing/plaf/basic/BasicTableUI.java 2009-08-11 12:08:25.175050200 +0400 +++ openjdk/jdk/src/share/classes/javax/swing/plaf/basic/BasicTableUI.java 2009-08-11 12:08:24.502050200 +0400 @@ -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 @@ -27,16 +27,11 @@ import java.awt.*; import java.awt.datatransfer.*; -import java.awt.dnd.*; import java.awt.event.*; import java.util.Enumeration; -import java.util.EventObject; -import java.util.Hashtable; -import java.util.TooManyListenersException; import javax.swing.*; import javax.swing.event.*; import javax.swing.plaf.*; -import javax.swing.text.*; import javax.swing.table.*; import javax.swing.plaf.basic.DragRecognitionSupport.BeforeDrag; import sun.swing.SwingUtilities2; @@ -56,8 +51,7 @@ */ public class BasicTableUI extends TableUI { - private static final StringBuilder BASELINE_COMPONENT_KEY = - new StringBuilder("Table.baselineComponent"); + private static final Object BASELINE_COMPONENT_KEY = new Object(); // Table.baselineComponent // // Instance Variables --- old/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java 2009-08-11 12:08:32.053050200 +0400 +++ openjdk/jdk/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java 2009-08-11 12:08:30.695050200 +0400 @@ -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 @@ -30,16 +30,12 @@ import java.awt.*; import java.awt.event.*; import java.awt.datatransfer.*; -import java.awt.dnd.*; import java.beans.*; -import java.io.*; import java.util.Enumeration; import java.util.Hashtable; -import java.util.TooManyListenersException; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; -import javax.swing.plaf.ActionMapUIResource; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.UIResource; import javax.swing.plaf.TreeUI; @@ -61,8 +57,7 @@ public class BasicTreeUI extends TreeUI { - private static final StringBuilder BASELINE_COMPONENT_KEY = - new StringBuilder("Tree.baselineComponent"); + private static final Object BASELINE_COMPONENT_KEY = new Object(); // Tree.baselineComponent // Old actions forward to an instance of this. static private final Actions SHARED_ACTION = new Actions(); --- old/src/share/classes/javax/swing/plaf/synth/ImagePainter.java 2009-08-11 12:08:38.675050200 +0400 +++ openjdk/jdk/src/share/classes/javax/swing/plaf/synth/ImagePainter.java 2009-08-11 12:08:37.988050200 +0400 @@ -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 @@ -41,8 +41,7 @@ * @author Scott Violet */ class ImagePainter extends SynthPainter { - private static final StringBuffer CACHE_KEY = - new StringBuffer("SynthCacheKey"); + private static final Object CACHE_KEY = new Object(); // SynthCacheKey private Image image; private Insets sInsets; --- old/src/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java 2009-08-11 12:08:44.720050200 +0400 +++ openjdk/jdk/src/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java 2009-08-11 12:08:44.005050200 +0400 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2006 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 @@ -73,8 +73,7 @@ /** * AppContext key to get the current SynthStyleFactory. */ - private static final Object STYLE_FACTORY_KEY = - new StringBuffer("com.sun.java.swing.plaf.gtk.StyleCache"); + private static final Object STYLE_FACTORY_KEY = new Object(); // com.sun.java.swing.plaf.gtk.StyleCache /** * The last SynthStyleFactory that was asked for from AppContext --- old/src/share/classes/javax/swing/text/JTextComponent.java 2009-08-11 12:08:50.823050200 +0400 +++ openjdk/jdk/src/share/classes/javax/swing/text/JTextComponent.java 2009-08-11 12:08:50.146050200 +0400 @@ -1,5 +1,5 @@ /* - * Copyright 1997-2006 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,10 +34,7 @@ import java.util.Hashtable; import java.util.Enumeration; import java.util.Vector; -import java.util.Iterator; import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; import java.util.concurrent.*; @@ -4041,8 +4038,7 @@ return modifiers; } - private static final Object KEYMAP_TABLE = - new StringBuilder("JTextComponent_KeymapTable"); + private static final Object KEYMAP_TABLE = new Object(); // JTextComponent_KeymapTable private JTextComponent editor; // // member variables used for on-the-spot input method @@ -4376,8 +4372,7 @@ } } - private static final Object FOCUSED_COMPONENT = - new StringBuilder("JTextComponent_FocusedComponent"); + private static final Object FOCUSED_COMPONENT = new Object(); // JTextComponent_FocusedComponent /** * The default keymap that will be shared by all --- old/src/share/classes/sun/swing/DefaultLookup.java 2009-08-11 12:08:57.514050200 +0400 +++ openjdk/jdk/src/share/classes/sun/swing/DefaultLookup.java 2009-08-11 12:08:56.800050200 +0400 @@ -46,8 +46,7 @@ /** * Key used to store DefaultLookup for AppContext. */ - private static final Object DEFAULT_LOOKUP_KEY = new - StringBuffer("DefaultLookup"); + private static final Object DEFAULT_LOOKUP_KEY = new Object(); // DefaultLookup /** * Thread that last asked for a default. */ --- old/src/share/classes/sun/swing/SwingUtilities2.java 2009-08-11 12:09:03.402050200 +0400 +++ openjdk/jdk/src/share/classes/sun/swing/SwingUtilities2.java 2009-08-11 12:09:02.664050200 +0400 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 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 @@ -32,25 +32,18 @@ import static java.awt.RenderingHints.*; import java.awt.event.*; import java.awt.font.*; -import java.awt.geom.*; import java.awt.print.PrinterGraphics; -import java.text.Bidi; import java.text.AttributedCharacterIterator; import java.text.AttributedString; import javax.swing.*; -import javax.swing.plaf.*; import javax.swing.text.Highlighter; import javax.swing.text.JTextComponent; import javax.swing.text.DefaultHighlighter; import javax.swing.text.DefaultCaret; import javax.swing.table.TableCellRenderer; -import sun.swing.PrintColorUIResource; -import sun.swing.ImageIconUIResource; import sun.print.ProxyPrintGraphics; import sun.awt.*; -import sun.security.action.GetPropertyAction; -import sun.security.util.SecurityConstants; import java.io.*; import java.util.*; import sun.font.FontDesignMetrics; @@ -74,8 +67,7 @@ * The <code>AppContext</code> key for our one <code>LAFState</code> * instance. */ - public static final Object LAF_STATE_KEY = - new StringBuffer("LookAndFeel State"); + public static final Object LAF_STATE_KEY = new Object(); // LookAndFeel State // Most of applications use 10 or less fonts simultaneously private static final int STRONG_BEARING_CACHE_SIZE = 10; @@ -97,15 +89,13 @@ * To avoid having this property persist between look and feels changes * the value of the property is set to null in JComponent.setUI */ - public static final Object AA_TEXT_PROPERTY_KEY = - new StringBuffer("AATextInfoPropertyKey"); + public static final Object AA_TEXT_PROPERTY_KEY = new Object(); // AATextInfoPropertyKey /** * Used to tell a text component, being used as an editor for table * or tree, how many clicks it took to start editing. */ - private static final StringBuilder SKIP_CLICK_COUNT = - new StringBuilder("skipClickCount"); + private static final Object SKIP_CLICK_COUNT = new Object(); // skipClickCount /* Presently this class assumes default fractional metrics. * This may need to change to emulate future platform L&Fs. @@ -165,8 +155,7 @@ * Key used in client properties used to indicate that the * <code>ComponentUI</code> of the JComponent instance should be returned. */ - public static final Object COMPONENT_UI_PROPERTY_KEY = - new StringBuffer("ComponentUIPropertyKey"); + public static final Object COMPONENT_UI_PROPERTY_KEY = new Object(); // ComponentUIPropertyKey /** Client Property key for the text maximal offsets for BasicMenuItemUI */ public static final StringUIClientPropertyKey BASICMENUITEMUI_MAX_TEXT_OFFSET = --- old/src/share/classes/javax/swing/plaf/basic/BasicButtonUI.java Tue Jul 14 16:21:58 2009 +++ openjdk/jdk/src/share/classes/javax/swing/plaf/basic/BasicButtonUI.java Tue Jul 14 16:21:58 2009 @@ -8,6 +8,8 @@ package javax.swing.plaf.basic; import sun.swing.SwingUtilities2; +import sun.awt.AppContext; + import java.awt.*; import java.awt.event.*; import java.io.Serializable; @@ -27,9 +29,6 @@ * @author Jeff Dinkins */ public class BasicButtonUI extends ButtonUI{ - // Shared UI object - private final static BasicButtonUI buttonUI = new BasicButtonUI(); - // Visual constants // NOTE: This is not used or set any where. Were we allowed to remove // fields, this would be removed. @@ -43,11 +42,20 @@ protected int defaultTextShiftOffset; private final static String propertyPrefix = "Button" + "."; + + private static final Object BASIC_BUTTON_UI_KEY = new Object(); // ******************************** // Create PLAF // ******************************** public static ComponentUI createUI(JComponent c) { + AppContext appContext = AppContext.getAppContext(); + BasicButtonUI buttonUI = + (BasicButtonUI) appContext.get(BASIC_BUTTON_UI_KEY); + if (buttonUI == null) { + buttonUI = new BasicButtonUI(); + appContext.put(BASIC_BUTTON_UI_KEY, buttonUI); + } return buttonUI; } --- old/src/share/classes/javax/swing/plaf/basic/BasicToggleButtonUI.java Tue Jul 14 16:21:58 2009 +++ openjdk/jdk/src/share/classes/javax/swing/plaf/basic/BasicToggleButtonUI.java Tue Jul 14 16:21:58 2009 @@ -7,6 +7,8 @@ package javax.swing.plaf.basic; +import sun.awt.AppContext; + import java.awt.*; import java.awt.event.*; @@ -26,7 +28,7 @@ */ public class BasicToggleButtonUI extends BasicButtonUI { - private final static BasicToggleButtonUI toggleButtonUI = new BasicToggleButtonUI(); + private static final Object BASIC_TOGGLE_BUTTON_UI_KEY = new Object(); private final static String propertyPrefix = "ToggleButton" + "."; @@ -34,6 +36,13 @@ // Create PLAF // ******************************** public static ComponentUI createUI(JComponent b) { + AppContext appContext = AppContext.getAppContext(); + BasicToggleButtonUI toggleButtonUI = + (BasicToggleButtonUI) appContext.get(BASIC_TOGGLE_BUTTON_UI_KEY); + if (toggleButtonUI == null) { + toggleButtonUI = new BasicToggleButtonUI(); + appContext.put(BASIC_TOGGLE_BUTTON_UI_KEY, toggleButtonUI); + } return toggleButtonUI; } --- old/src/share/classes/javax/swing/plaf/basic/BasicCheckBoxUI.java Tue Jul 14 16:21:59 2009 +++ openjdk/jdk/src/share/classes/javax/swing/plaf/basic/BasicCheckBoxUI.java Tue Jul 14 16:21:59 2009 @@ -7,6 +7,8 @@ package javax.swing.plaf.basic; +import sun.awt.AppContext; + import javax.swing.*; import java.awt.*; @@ -32,7 +34,7 @@ */ public class BasicCheckBoxUI extends BasicRadioButtonUI { - private final static BasicCheckBoxUI checkboxUI = new BasicCheckBoxUI(); + private static final Object BASIC_CHECK_BOX_UI_KEY = new Object(); private final static String propertyPrefix = "CheckBox" + "."; @@ -40,6 +42,13 @@ // Create PLAF // ******************************** public static ComponentUI createUI(JComponent b) { + AppContext appContext = AppContext.getAppContext(); + BasicCheckBoxUI checkboxUI = + (BasicCheckBoxUI) appContext.get(BASIC_CHECK_BOX_UI_KEY); + if (checkboxUI == null) { + checkboxUI = new BasicCheckBoxUI(); + appContext.put(BASIC_CHECK_BOX_UI_KEY, checkboxUI); + } return checkboxUI; } --- old/src/share/classes/javax/swing/plaf/basic/BasicRadioButtonUI.java Tue Jul 14 16:21:59 2009 +++ openjdk/jdk/src/share/classes/javax/swing/plaf/basic/BasicRadioButtonUI.java Tue Jul 14 16:21:59 2009 @@ -14,6 +14,7 @@ import javax.swing.plaf.*; import javax.swing.text.View; import sun.swing.SwingUtilities2; +import sun.awt.AppContext; /** @@ -24,7 +25,7 @@ */ public class BasicRadioButtonUI extends BasicToggleButtonUI { - private final static BasicRadioButtonUI radioButtonUI = new BasicRadioButtonUI(); + private static final Object BASIC_RADIO_BUTTON_UI_KEY = new Object(); protected Icon icon; @@ -36,6 +37,13 @@ // Create PLAF // ******************************** public static ComponentUI createUI(JComponent b) { + AppContext appContext = AppContext.getAppContext(); + BasicRadioButtonUI radioButtonUI = + (BasicRadioButtonUI) appContext.get(BASIC_RADIO_BUTTON_UI_KEY); + if (radioButtonUI == null) { + radioButtonUI = new BasicRadioButtonUI(); + appContext.put(BASIC_RADIO_BUTTON_UI_KEY, radioButtonUI); + } return radioButtonUI; } --- old/src/share/classes/javax/swing/plaf/basic/BasicLabelUI.java Tue Jul 14 16:22:00 2009 +++ openjdk/jdk/src/share/classes/javax/swing/plaf/basic/BasicLabelUI.java Tue Jul 14 16:22:00 2009 @@ -10,6 +10,8 @@ import sun.swing.SwingUtilities2; import sun.swing.DefaultLookup; import sun.swing.UIAction; +import sun.awt.AppContext; + import javax.swing.*; import javax.swing.plaf.*; import javax.swing.text.View; @@ -46,7 +48,8 @@ * name in defaults table under the key "LabelUI". */ protected static BasicLabelUI labelUI = new BasicLabelUI(); - private final static BasicLabelUI SAFE_BASIC_LABEL_UI = new BasicLabelUI(); + + private static final Object BASIC_LABEL_UI_KEY = new Object(); static void loadActionMap(LazyActionMap map) { map.put(new Actions(Actions.PRESS)); @@ -392,10 +395,16 @@ public static ComponentUI createUI(JComponent c) { if (System.getSecurityManager() != null) { - return SAFE_BASIC_LABEL_UI; - } else { - return labelUI; - } + AppContext appContext = AppContext.getAppContext(); + BasicLabelUI safeBasicLabelUI = + (BasicLabelUI) appContext.get(BASIC_LABEL_UI_KEY); + if (safeBasicLabelUI == null) { + safeBasicLabelUI = new BasicLabelUI(); + appContext.put(BASIC_LABEL_UI_KEY, safeBasicLabelUI); + } + return safeBasicLabelUI; + } + return labelUI; } public void propertyChange(PropertyChangeEvent e) { --- old/src/share/classes/javax/swing/plaf/metal/MetalToggleButtonUI.java Tue Jul 14 16:22:01 2009 +++ openjdk/jdk/src/share/classes/javax/swing/plaf/metal/MetalToggleButtonUI.java Tue Jul 14 16:22:01 2009 @@ -8,6 +8,8 @@ package javax.swing.plaf.metal; import sun.swing.SwingUtilities2; +import sun.awt.AppContext; + import java.awt.*; import java.awt.event.*; import java.lang.ref.*; @@ -38,7 +40,7 @@ */ public class MetalToggleButtonUI extends BasicToggleButtonUI { - private static final MetalToggleButtonUI metalToggleButtonUI = new MetalToggleButtonUI(); + private static final Object METAL_TOGGLE_BUTTON_UI_KEY = new Object(); protected Color focusColor; protected Color selectColor; @@ -50,6 +52,13 @@ // Create PLAF // ******************************** public static ComponentUI createUI(JComponent b) { + AppContext appContext = AppContext.getAppContext(); + MetalToggleButtonUI metalToggleButtonUI = + (MetalToggleButtonUI) appContext.get(METAL_TOGGLE_BUTTON_UI_KEY); + if (metalToggleButtonUI == null) { + metalToggleButtonUI = new MetalToggleButtonUI(); + appContext.put(METAL_TOGGLE_BUTTON_UI_KEY, metalToggleButtonUI); + } return metalToggleButtonUI; } --- old/src/share/classes/javax/swing/plaf/metal/MetalCheckBoxUI.java Tue Jul 14 16:22:01 2009 +++ openjdk/jdk/src/share/classes/javax/swing/plaf/metal/MetalCheckBoxUI.java Tue Jul 14 16:22:01 2009 @@ -7,6 +7,8 @@ package javax.swing.plaf.metal; +import sun.awt.AppContext; + import javax.swing.*; import javax.swing.plaf.basic.BasicCheckBoxUI; @@ -38,7 +40,7 @@ // of BasicCheckBoxUI because we want to pick up all the // painting changes made in MetalRadioButtonUI. - private final static MetalCheckBoxUI checkboxUI = new MetalCheckBoxUI(); + private static final Object METAL_CHECK_BOX_UI_KEY = new Object(); private final static String propertyPrefix = "CheckBox" + "."; @@ -48,6 +50,13 @@ // Create PlAF // ******************************** public static ComponentUI createUI(JComponent b) { + AppContext appContext = AppContext.getAppContext(); + MetalCheckBoxUI checkboxUI = + (MetalCheckBoxUI) appContext.get(METAL_CHECK_BOX_UI_KEY); + if (checkboxUI == null) { + checkboxUI = new MetalCheckBoxUI(); + appContext.put(METAL_CHECK_BOX_UI_KEY, checkboxUI); + } return checkboxUI; } --- old/src/share/classes/javax/swing/plaf/metal/MetalRadioButtonUI.java Tue Jul 14 16:22:02 2009 +++ openjdk/jdk/src/share/classes/javax/swing/plaf/metal/MetalRadioButtonUI.java Tue Jul 14 16:22:01 2009 @@ -8,6 +8,8 @@ package javax.swing.plaf.metal; import sun.swing.SwingUtilities2; +import sun.awt.AppContext; + import java.awt.*; import java.awt.event.*; import javax.swing.*; @@ -36,7 +38,7 @@ */ public class MetalRadioButtonUI extends BasicRadioButtonUI { - private static final MetalRadioButtonUI metalRadioButtonUI = new MetalRadioButtonUI(); + private static final Object METAL_RADIO_BUTTON_UI_KEY = new Object(); protected Color focusColor; protected Color selectColor; @@ -48,6 +50,13 @@ // Create PlAF // ******************************** public static ComponentUI createUI(JComponent c) { + AppContext appContext = AppContext.getAppContext(); + MetalRadioButtonUI metalRadioButtonUI = + (MetalRadioButtonUI) appContext.get(METAL_RADIO_BUTTON_UI_KEY); + if (metalRadioButtonUI == null) { + metalRadioButtonUI = new MetalRadioButtonUI(); + appContext.put(METAL_RADIO_BUTTON_UI_KEY, metalRadioButtonUI); + } return metalRadioButtonUI; } --- old/src/share/classes/javax/swing/plaf/metal/MetalLabelUI.java Tue Jul 14 16:22:05 2009 +++ openjdk/jdk/src/share/classes/javax/swing/plaf/metal/MetalLabelUI.java Tue Jul 14 16:22:05 2009 @@ -8,6 +8,8 @@ package javax.swing.plaf.metal; import sun.swing.SwingUtilities2; +import sun.awt.AppContext; + import javax.swing.*; import javax.swing.plaf.*; import javax.swing.plaf.basic.*; @@ -34,15 +36,21 @@ * name in defaults table under the key "LabelUI". */ protected static MetalLabelUI metalLabelUI = new MetalLabelUI(); - private final static MetalLabelUI SAFE_METAL_LABEL_UI = new MetalLabelUI(); + + private static final Object METAL_LABEL_UI_KEY = new Object(); - public static ComponentUI createUI(JComponent c) { if (System.getSecurityManager() != null) { - return SAFE_METAL_LABEL_UI; - } else { - return metalLabelUI; - } + AppContext appContext = AppContext.getAppContext(); + MetalLabelUI safeMetalLabelUI = + (MetalLabelUI) appContext.get(METAL_LABEL_UI_KEY); + if (safeMetalLabelUI == null) { + safeMetalLabelUI = new MetalLabelUI(); + appContext.put(METAL_LABEL_UI_KEY, safeMetalLabelUI); + } + return safeMetalLabelUI; + } + return metalLabelUI; } /** --- old/src/share/classes/com/sun/java/swing/plaf/motif/MotifLabelUI.java Tue Jul 14 16:22:09 2009 +++ openjdk/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifLabelUI.java Tue Jul 14 16:22:09 2009 @@ -7,6 +7,8 @@ package com.sun.java.swing.plaf.motif; +import sun.awt.AppContext; + import javax.swing.*; import javax.swing.plaf.basic.BasicLabelUI; import javax.swing.plaf.ComponentUI; @@ -27,9 +29,16 @@ */ public class MotifLabelUI extends BasicLabelUI { - static MotifLabelUI sharedInstance = new MotifLabelUI(); + private static final Object MOTIF_LABEL_UI_KEY = new Object(); public static ComponentUI createUI(JComponent c) { - return sharedInstance; + AppContext appContext = AppContext.getAppContext(); + MotifLabelUI motifLabelUI = + (MotifLabelUI) appContext.get(MOTIF_LABEL_UI_KEY); + if (motifLabelUI == null) { + motifLabelUI = new MotifLabelUI(); + appContext.put(MOTIF_LABEL_UI_KEY, motifLabelUI); + } + return motifLabelUI; } } --- old/jdk/src/share/classes/javax/swing/plaf/metal/MetalButtonUI.java 2008-04-11 04:16:09.000000000 -0400 +++ openjdk/jdk/src/share/classes/javax/swing/plaf/metal/MetalButtonUI.java 2009-11-11 13:36:45.000000000 -0500 @@ -26,6 +26,8 @@ package javax.swing.plaf.metal; import sun.swing.SwingUtilities2; +import sun.awt.AppContext; + import javax.swing.*; import javax.swing.border.*; import javax.swing.plaf.basic.*; @@ -50,19 +52,26 @@ */ public class MetalButtonUI extends BasicButtonUI { - private final static MetalButtonUI metalButtonUI = new MetalButtonUI(); - // NOTE: These are not really needed, but at this point we can't pull // them. Their values are updated purely for historical reasons. protected Color focusColor; protected Color selectColor; protected Color disabledTextColor; + private static final Object METAL_BUTTON_UI_KEY = new Object(); + // ******************************** // Create PLAF // ******************************** public static ComponentUI createUI(JComponent c) { - return metalButtonUI; + AppContext appContext = AppContext.getAppContext(); + MetalButtonUI metalButtonUI = + (MetalButtonUI) appContext.get(METAL_BUTTON_UI_KEY); + if (metalButtonUI == null) { + metalButtonUI = new MetalButtonUI(); + appContext.put(METAL_BUTTON_UI_KEY, metalButtonUI); + } + return metalButtonUI; } // ******************************** --- openjdk-orig/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsButtonUI.java 2008-04-11 04:14:41.000000000 -0400 +++ openjdk/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsButtonUI.java 2009-11-11 13:48:37.000000000 -0500 @@ -35,6 +35,7 @@ import static com.sun.java.swing.plaf.windows.TMSchema.*; import static com.sun.java.swing.plaf.windows.TMSchema.Part.*; import static com.sun.java.swing.plaf.windows.XPStyle.Skin; +import sun.awt.AppContext; /** @@ -52,8 +53,6 @@ */ public class WindowsButtonUI extends BasicButtonUI { - private final static WindowsButtonUI windowsButtonUI = new WindowsButtonUI(); - protected int dashedRectGapX; protected int dashedRectGapY; protected int dashedRectGapWidth; @@ -64,11 +63,20 @@ private boolean defaults_initialized = false; + private static final Object WINDOWS_BUTTON_UI_KEY = new Object(); + // ******************************** // Create PLAF // ******************************** public static ComponentUI createUI(JComponent c){ - return windowsButtonUI; + AppContext appContext = AppContext.getAppContext(); + WindowsButtonUI windowsButtonUI = + (WindowsButtonUI) appContext.get(WINDOWS_BUTTON_UI_KEY); + if (windowsButtonUI == null) { + windowsButtonUI = new WindowsButtonUI(); + appContext.put(WINDOWS_BUTTON_UI_KEY, windowsButtonUI); + } + return windowsButtonUI; } @@ -151,7 +159,7 @@ * allocating them in each paint call substantially reduced the time * it took paint to run. Obviously, this method can't be re-entered. */ - private static Rectangle viewRect = new Rectangle(); + private Rectangle viewRect = new Rectangle(); public void paint(Graphics g, JComponent c) { if (XPStyle.getXP() != null) { --- openjdk-orig/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsToggleButtonUI.java 2008-04-11 04:14:41.000000000 -0400 +++ openjdk/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsToggleButtonUI.java 2009-11-11 13:54:39.000000000 -0500 @@ -25,6 +25,8 @@ package com.sun.java.swing.plaf.windows; +import sun.awt.AppContext; + import javax.swing.plaf.basic.*; import javax.swing.border.*; import javax.swing.plaf.*; @@ -49,19 +51,26 @@ */ public class WindowsToggleButtonUI extends BasicToggleButtonUI { - protected static int dashedRectGapX; - protected static int dashedRectGapY; - protected static int dashedRectGapWidth; - protected static int dashedRectGapHeight; + protected int dashedRectGapX; + protected int dashedRectGapY; + protected int dashedRectGapWidth; + protected int dashedRectGapHeight; protected Color focusColor; - private final static WindowsToggleButtonUI windowsToggleButtonUI = new WindowsToggleButtonUI(); + private static final Object WINDOWS_TOGGLE_BUTTON_UI_KEY = new Object(); private boolean defaults_initialized = false; public static ComponentUI createUI(JComponent b) { - return windowsToggleButtonUI; + AppContext appContext = AppContext.getAppContext(); + WindowsToggleButtonUI windowsToggleButtonUI = + (WindowsToggleButtonUI) appContext.get(WINDOWS_TOGGLE_BUTTON_UI_KEY); + if (windowsToggleButtonUI == null) { + windowsToggleButtonUI = new WindowsToggleButtonUI(); + appContext.put(WINDOWS_TOGGLE_BUTTON_UI_KEY, windowsToggleButtonUI); + } + return windowsToggleButtonUI; } --- openjdk-orig/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxUI.java 2008-04-11 04:14:41.000000000 -0400 +++ openjdk/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxUI.java 2009-11-11 13:57:54.000000000 -0500 @@ -25,6 +25,8 @@ package com.sun.java.swing.plaf.windows; +import sun.awt.AppContext; + import javax.swing.plaf.basic.*; import javax.swing.*; import javax.swing.plaf.*; @@ -49,7 +51,7 @@ // of BasicCheckBoxUI because we want to pick up all the // painting changes made in MetalRadioButtonUI. - private static final WindowsCheckBoxUI windowsCheckBoxUI = new WindowsCheckBoxUI(); + private static final Object WINDOWS_CHECK_BOX_UI_KEY = new Object(); private final static String propertyPrefix = "CheckBox" + "."; @@ -59,6 +61,13 @@ // Create PLAF // ******************************** public static ComponentUI createUI(JComponent c) { + AppContext appContext = AppContext.getAppContext(); + WindowsCheckBoxUI windowsCheckBoxUI = + (WindowsCheckBoxUI) appContext.get(WINDOWS_CHECK_BOX_UI_KEY); + if (windowsCheckBoxUI == null) { + windowsCheckBoxUI = new WindowsCheckBoxUI(); + appContext.put(WINDOWS_CHECK_BOX_UI_KEY, windowsCheckBoxUI); + } return windowsCheckBoxUI; } --- openjdk-orig/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonUI.java 2008-04-11 04:14:41.000000000 -0400 +++ openjdk/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonUI.java 2009-11-11 14:04:04.000000000 -0500 @@ -25,6 +25,8 @@ package com.sun.java.swing.plaf.windows; +import sun.awt.AppContext; + import javax.swing.plaf.basic.*; import javax.swing.*; import javax.swing.plaf.*; @@ -44,7 +46,7 @@ */ public class WindowsRadioButtonUI extends BasicRadioButtonUI { - private static final WindowsRadioButtonUI windowsRadioButtonUI = new WindowsRadioButtonUI(); + private static final Object WINDOWS_RADIO_BUTTON_UI_KEY = new Object(); protected int dashedRectGapX; protected int dashedRectGapY; @@ -59,6 +61,13 @@ // Create PLAF // ******************************** public static ComponentUI createUI(JComponent c) { + AppContext appContext = AppContext.getAppContext(); + WindowsRadioButtonUI windowsRadioButtonUI = + (WindowsRadioButtonUI) appContext.get(WINDOWS_RADIO_BUTTON_UI_KEY); + if (windowsRadioButtonUI == null) { + windowsRadioButtonUI = new WindowsRadioButtonUI(); + appContext.put(WINDOWS_RADIO_BUTTON_UI_KEY, windowsRadioButtonUI); + } return windowsRadioButtonUI; } --- openjdk-orig/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLabelUI.java 2008-04-11 04:14:41.000000000 -0400 +++ openjdk/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLabelUI.java 2009-11-11 14:09:34.000000000 -0500 @@ -26,6 +26,8 @@ package com.sun.java.swing.plaf.windows; import sun.swing.SwingUtilities2; +import sun.awt.AppContext; + import java.awt.Color; import java.awt.Graphics; @@ -51,12 +53,19 @@ */ public class WindowsLabelUI extends BasicLabelUI { - private final static WindowsLabelUI windowsLabelUI = new WindowsLabelUI(); + private static final Object WINDOWS_LABEL_UI_KEY = new Object(); // ******************************** // Create PLAF // ******************************** public static ComponentUI createUI(JComponent c){ + AppContext appContext = AppContext.getAppContext(); + WindowsLabelUI windowsLabelUI = + (WindowsLabelUI) appContext.get(WINDOWS_LABEL_UI_KEY); + if (windowsLabelUI == null) { + windowsLabelUI = new WindowsLabelUI(); + appContext.put(WINDOWS_LABEL_UI_KEY, windowsLabelUI); + } return windowsLabelUI; } --- openjdk-orig/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifButtonUI.java 2008-04-11 04:14:39.000000000 -0400 +++ openjdk/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifButtonUI.java 2009-11-11 14:11:48.000000000 -0500 @@ -25,6 +25,8 @@ package com.sun.java.swing.plaf.motif; +import sun.awt.AppContext; + import javax.swing.*; import javax.swing.border.*; import javax.swing.plaf.basic.*; @@ -46,7 +48,7 @@ */ public class MotifButtonUI extends BasicButtonUI { - private final static MotifButtonUI motifButtonUI = new MotifButtonUI(); + private static final Object MOTIF_BUTTON_UI_KEY = new Object(); protected Color selectColor; @@ -56,6 +58,13 @@ // Create PLAF // ******************************** public static ComponentUI createUI(JComponent c){ + AppContext appContext = AppContext.getAppContext(); + MotifButtonUI motifButtonUI = + (MotifButtonUI) appContext.get(MOTIF_BUTTON_UI_KEY); + if (motifButtonUI == null) { + motifButtonUI = new MotifButtonUI(); + appContext.put(MOTIF_BUTTON_UI_KEY, motifButtonUI); + } return motifButtonUI; } --- openjdk-orig/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifToggleButtonUI.java 2008-04-11 04:14:40.000000000 -0400 +++ openjdk/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifToggleButtonUI.java 2009-11-11 14:15:18.000000000 -0500 @@ -25,6 +25,8 @@ package com.sun.java.swing.plaf.motif; +import sun.awt.AppContext; + import java.awt.*; import java.awt.event.*; @@ -48,7 +50,7 @@ */ public class MotifToggleButtonUI extends BasicToggleButtonUI { - private final static MotifToggleButtonUI motifToggleButtonUI = new MotifToggleButtonUI(); + private static final Object MOTIF_TOGGLE_BUTTON_UI_KEY = new Object(); protected Color selectColor; @@ -57,7 +59,14 @@ // ******************************** // Create PLAF // ******************************** - public static ComponentUI createUI(JComponent b) { + public static ComponentUI createUI(JComponent b) { + AppContext appContext = AppContext.getAppContext(); + MotifToggleButtonUI motifToggleButtonUI = + (MotifToggleButtonUI) appContext.get(MOTIF_TOGGLE_BUTTON_UI_KEY); + if (motifToggleButtonUI == null) { + motifToggleButtonUI = new MotifToggleButtonUI(); + appContext.put(MOTIF_TOGGLE_BUTTON_UI_KEY, motifToggleButtonUI); + } return motifToggleButtonUI; } --- openjdk-orig/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifCheckBoxUI.java 2008-04-11 04:14:39.000000000 -0400 +++ openjdk/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifCheckBoxUI.java 2009-11-11 14:20:05.000000000 -0500 @@ -25,6 +25,8 @@ package com.sun.java.swing.plaf.motif; +import sun.awt.AppContext; + import javax.swing.*; import javax.swing.plaf.*; @@ -45,7 +47,7 @@ */ public class MotifCheckBoxUI extends MotifRadioButtonUI { - private static final MotifCheckBoxUI motifCheckBoxUI = new MotifCheckBoxUI(); + private static final Object MOTIF_CHECK_BOX_UI_KEY = new Object(); private final static String propertyPrefix = "CheckBox" + "."; @@ -56,6 +58,13 @@ // Create PLAF // ******************************** public static ComponentUI createUI(JComponent c){ + AppContext appContext = AppContext.getAppContext(); + MotifCheckBoxUI motifCheckBoxUI = + (MotifCheckBoxUI) appContext.get(MOTIF_CHECK_BOX_UI_KEY); + if (motifCheckBoxUI == null) { + motifCheckBoxUI = new MotifCheckBoxUI(); + appContext.put(MOTIF_CHECK_BOX_UI_KEY, motifCheckBoxUI); + } return motifCheckBoxUI; } --- openjdk-orig/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifRadioButtonUI.java 2008-04-11 04:14:40.000000000 -0400 +++ openjdk/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifRadioButtonUI.java 2009-11-11 14:23:14.000000000 -0500 @@ -25,6 +25,8 @@ package com.sun.java.swing.plaf.motif; +import sun.awt.AppContext; + import javax.swing.*; import javax.swing.border.*; import javax.swing.plaf.basic.BasicRadioButtonUI; @@ -47,7 +49,7 @@ */ public class MotifRadioButtonUI extends BasicRadioButtonUI { - private static final MotifRadioButtonUI motifRadioButtonUI = new MotifRadioButtonUI(); + private static final Object MOTIF_RADIO_BUTTON_UI_KEY = new Object(); protected Color focusColor; @@ -57,6 +59,13 @@ // Create PLAF // ******************************** public static ComponentUI createUI(JComponent c) { + AppContext appContext = AppContext.getAppContext(); + MotifRadioButtonUI motifRadioButtonUI = + (MotifRadioButtonUI) appContext.get(MOTIF_RADIO_BUTTON_UI_KEY); + if (motifRadioButtonUI == null) { + motifRadioButtonUI = new MotifRadioButtonUI(); + appContext.put(MOTIF_RADIO_BUTTON_UI_KEY, motifRadioButtonUI); + } return motifRadioButtonUI; } --- old/src/solaris/classes/sun/awt/X11GraphicsDevice.java 2009-07-28 16:57:02.545000000 +0400 +++ openjdk/jdk/src/solaris/classes/sun/awt/X11GraphicsDevice.java 2009-07-28 16:57:01.921000000 +0400 @@ -134,7 +134,7 @@ makeConfigurations(); } } - return configs; + return configs.clone(); } private void makeConfigurations() { --- old/src/windows/classes/sun/awt/Win32GraphicsDevice.java 2009-07-28 16:57:08.184000000 +0400 +++ openjdk/jdk/src/windows/classes/sun/awt/Win32GraphicsDevice.java 2009-07-28 16:57:07.557000000 +0400 @@ -170,7 +170,7 @@ if (defaultConfig != null) { configs = new GraphicsConfiguration[1]; configs[0] = defaultConfig; - return configs; + return configs.clone(); } } @@ -202,7 +202,7 @@ configs = new GraphicsConfiguration[v.size()]; v.copyInto(configs); } - return configs; + return configs.clone(); } /** --- old/src/share/classes/sun/util/calendar/ZoneInfoFile.java 2009-08-28 12:32:15.000000000 +0900 +++ openjdk/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java 2009-08-28 12:32:14.000000000 +0900 @@ -1,5 +1,5 @@ /* - * Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2000-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 @@ -472,6 +472,19 @@ private static Map<String, ZoneInfo> zoneInfoObjects = null; + private static final String ziDir; + static { + String zi = (String) AccessController.doPrivileged( + new sun.security.action.GetPropertyAction("java.home")) + + File.separator + "lib" + File.separator + "zi"; + try { + zi = new File(zi).getCanonicalPath(); + } catch (Exception e) { + } + ziDir = zi; + } + + /** * Converts the given time zone ID to a platform dependent path * name. For example, "America/Los_Angeles" is converted to @@ -576,20 +589,7 @@ return null; } - int index; - for (index = 0; index < JAVAZI_LABEL.length; index++) { - if (buf[index] != JAVAZI_LABEL[index]) { - System.err.println("ZoneInfo: wrong magic number: " + id); - return null; - } - } - - if (buf[index++] > JAVAZI_VERSION) { - System.err.println("ZoneInfo: incompatible version (" - + buf[index - 1] + "): " + id); - return null; - } - + int index=0; int filesize = buf.length; int rawOffset = 0; int dstSavings = 0; @@ -600,6 +600,19 @@ int[] simpleTimeZoneParams = null; try { + for (index = 0; index < JAVAZI_LABEL.length; index++) { + if (buf[index] != JAVAZI_LABEL[index]) { + System.err.println("ZoneInfo: wrong magic number: " + id); + return null; + } + } + if (buf[index++] > JAVAZI_VERSION) { + System.err.println("ZoneInfo: incompatible version (" + + buf[index - 1] + "): " + id); + return null; + } + + while (index < filesize) { byte tag = buf[index++]; int len = ((buf[index++] & 0xFF) << 8) + (buf[index++] & 0xFF); @@ -1018,7 +1018,7 @@ * Reads the specified file under <java.home>/lib/zi into a buffer. * @return the buffer, or null if any I/O error occurred. */ - private static byte[] readZoneInfoFile(String fileName) { + private static byte[] readZoneInfoFile(final String fileName) { byte[] buffer = null; try { @@ -1046,20 +1046,28 @@ final String fname = zi_dir + File.separator + fileName; buffer = (byte[]) AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws IOException { - File file = new File(fname); - if (!file.canRead()) { + File file = new File(ziDir, fileName); + if (!file.exists() || !file.isFile()) { return null; } - int filesize = (int)file.length(); - byte[] buf = new byte[filesize]; + file = file.getCanonicalFile(); + String path = file.getCanonicalPath(); + byte[] buf = null; + if (path != null && path.startsWith(ziDir)) { + int filesize = (int)file.length(); + if (filesize > 0) { + FileInputStream fis = new FileInputStream(file); + buf = new byte[filesize]; + try { + if (fis.read(buf) != filesize) { + throw new IOException("read error on " + fileName); + } + } finally { + fis.close(); + } + } + } - FileInputStream fis = new FileInputStream(file); - - if (fis.read(buf) != filesize) { - fis.close(); - throw new IOException("read error on " + fname); - } - fis.close(); return buf; } }); --- old/src/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java Tue Sep 22 05:44:00 2009 +++ openjdk/jdk/src/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java Tue Sep 22 05:43:59 2009 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 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 @@ -308,6 +308,16 @@ X500Name certIssuer = (X500Name) certImpl.getIssuerDN(); X500Name crlIssuer = (X500Name) crlImpl.getIssuerDN(); + // check the crl signature algorithm + try { + AlgorithmChecker.check(crl); + } catch (CertPathValidatorException cpve) { + if (debug != null) { + debug.println("CRL signature algorithm check failed: " + cpve); + } + return false; + } + // if crlIssuer is set, verify that it matches the issuer of the // CRL and the CRL contains an IDP extension with the indirectCRL // boolean asserted. Otherwise, verify that the CRL issuer matches the --- old/src/share/classes/sun/security/provider/certpath/ForwardBuilder.java Tue Sep 22 05:44:02 2009 +++ openjdk/jdk/src/share/classes/sun/security/provider/certpath/ForwardBuilder.java Tue Sep 22 05:44:01 2009 @@ -1,5 +1,5 @@ /* - * Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2000-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 @@ -676,6 +676,11 @@ /* we don't perform any validation of the trusted cert */ if (!isTrustedCert) { /* + * check that the signature algorithm is not disabled. + */ + AlgorithmChecker.check(cert); + + /* * Check CRITICAL private extensions for user checkers that * support forward checking (forwardCheckers) and remove * ones we know how to check. --- old/src/share/classes/sun/security/provider/certpath/OCSPChecker.java Tue Sep 22 05:44:05 2009 +++ openjdk/jdk/src/share/classes/sun/security/provider/certpath/OCSPChecker.java Tue Sep 22 05:44:04 2009 @@ -290,12 +290,29 @@ } if (filter != null) { List<CertStore> certStores = pkixParams.getCertStores(); + AlgorithmChecker algChecker= + AlgorithmChecker.getInstance(); for (CertStore certStore : certStores) { - Iterator i = - certStore.getCertificates(filter).iterator(); - if (i.hasNext()) { - responderCert = (X509Certificate) i.next(); - seekResponderCert = false; // done + for (Certificate selected : + certStore.getCertificates(filter)) { + try { + // don't bother to trust algorithm disabled + // certificate as responder + algChecker.check(selected); + + responderCert = (X509Certificate)selected; + seekResponderCert = false; // done + break; + } catch (CertPathValidatorException cpve) { + if (DEBUG != null) { + DEBUG.println( + "OCSP responder certificate " + + "algorithm check failed: " + cpve); + } + } + } + + if (!seekResponderCert) { break; } } --- old/src/share/classes/sun/security/provider/certpath/OCSPResponse.java Tue Sep 22 05:44:07 2009 +++ openjdk/jdk/src/share/classes/sun/security/provider/certpath/OCSPResponse.java Tue Sep 22 05:44:07 2009 @@ -1,5 +1,5 @@ /* - * Copyright 2003-2006 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 @@ -222,6 +222,10 @@ new DerInputStream(derIn.getOctetString()); DerValue[] seqTmp = basicOCSPResponse.getSequence(2); + if (seqTmp.length < 3) { + throw new IOException("Unexpected BasicOCSPResponse value"); + } + DerValue responseData = seqTmp[0]; // Need the DER encoded ResponseData to verify the signature later @@ -304,6 +308,9 @@ // signatureAlgorithmId sigAlgId = AlgorithmId.parse(seqTmp[1]); + // check that the signature algorithm is not disabled. + AlgorithmChecker.check(sigAlgId); + // signature byte[] signature = seqTmp[2].getBitString(); X509CertImpl[] x509Certs = null; @@ -337,6 +344,9 @@ } else if (cert.getIssuerDN().equals( responderCert.getSubjectDN())) { + // check the certificate algorithm + AlgorithmChecker.check(cert); + // Check for the OCSPSigning key purpose List<String> keyPurposes = cert.getExtendedKeyUsage(); if (keyPurposes == null || --- old/src/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java Tue Sep 22 05:44:09 2009 +++ openjdk/jdk/src/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java Tue Sep 22 05:44:09 2009 @@ -1,5 +1,5 @@ /* - * Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2000-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 @@ -268,6 +268,7 @@ int certPathLen = certList.size(); basicChecker = new BasicChecker(anchor, testDate, sigProvider, false); + AlgorithmChecker algorithmChecker= AlgorithmChecker.getInstance(); KeyChecker keyChecker = new KeyChecker(certPathLen, pkixParam.getTargetCertConstraints()); ConstraintsChecker constraintsChecker = @@ -282,6 +283,7 @@ rootNode); // add standard checkers that we will be using + certPathCheckers.add(algorithmChecker); certPathCheckers.add(keyChecker); certPathCheckers.add(constraintsChecker); certPathCheckers.add(policyChecker); --- old/src/share/classes/sun/security/provider/certpath/ReverseBuilder.java Tue Sep 22 05:44:11 2009 +++ openjdk/jdk/src/share/classes/sun/security/provider/certpath/ReverseBuilder.java Tue Sep 22 05:44:11 2009 @@ -1,5 +1,5 @@ /* - * Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2000-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 @@ -346,6 +346,9 @@ return; } + /* check that the signature algorithm is not disabled. */ + AlgorithmChecker.check(cert); + /* * check for looping - abort a loop if * ((we encounter the same certificate twice) AND --- old/src/share/classes/sun/security/validator/SimpleValidator.java Tue Sep 22 05:44:14 2009 +++ openjdk/jdk/src/share/classes/sun/security/validator/SimpleValidator.java Tue Sep 22 05:44:13 2009 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2006 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 @@ -40,6 +40,8 @@ import sun.security.util.DerOutputStream; import sun.security.util.ObjectIdentifier; +import sun.security.provider.certpath.AlgorithmChecker; + /** * A simple validator implementation. It is based on code from the JSSE * X509TrustManagerImpl. This implementation is designed for compatibility with @@ -133,6 +135,13 @@ X509Certificate issuerCert = chain[i + 1]; X509Certificate cert = chain[i]; + // check certificate algorithm + try { + AlgorithmChecker.check(cert); + } catch (CertPathValidatorException cpve) { + throw new ValidatorException + (ValidatorException.T_ALGORITHM_DISABLED, cert, cpve); + } // no validity check for code signing certs if ((variant.equals(VAR_CODE_SIGNING) == false) --- old/src/share/classes/sun/security/validator/ValidatorException.java Tue Sep 22 05:44:16 2009 +++ openjdk/jdk/src/share/classes/sun/security/validator/ValidatorException.java Tue Sep 22 05:44:15 2009 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2003 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 @@ -55,6 +55,9 @@ public final static Object T_NAME_CHAINING = "Certificate chaining error"; + public final static Object T_ALGORITHM_DISABLED = + "Certificate signature algorithm disabled"; + private Object type; private X509Certificate cert; --- /dev/null Tue Sep 22 05:44:18 2009 +++ openjdk/jdk/src/share/classes/sun/security/provider/certpath/AlgorithmChecker.java Tue Sep 22 05:44:17 2009 @@ -0,0 +1,119 @@ +/* + * 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 sun.security.provider.certpath; + +import java.util.Set; +import java.util.Collection; +import java.util.Locale; +import java.security.cert.Certificate; +import java.security.cert.X509Certificate; +import java.security.cert.X509CRL; +import java.security.cert.CertPathValidatorException; +import java.security.cert.PKIXCertPathChecker; + +import sun.security.x509.AlgorithmId; + +/** + * AlgorithmChecker is a <code>PKIXCertPathChecker</code> that checks that + * the signature algorithm of the specified certificate is not disabled. + * + * @author Xuelei Fan + */ +final public class AlgorithmChecker extends PKIXCertPathChecker { + + // the disabled algorithms + private static final String[] disabledAlgorithms = new String[] {"md2"}; + + // singleton instance + static final AlgorithmChecker INSTANCE = new AlgorithmChecker(); + + /** + * Default Constructor + */ + private AlgorithmChecker() { + // do nothing + } + + /** + * Return a AlgorithmChecker instance. + */ + static AlgorithmChecker getInstance() { + return INSTANCE; + } + + /** + * Initializes the internal state of the checker from parameters + * specified in the constructor. + */ + public void init(boolean forward) throws CertPathValidatorException { + // do nothing + } + + public boolean isForwardCheckingSupported() { + return false; + } + + public Set<String> getSupportedExtensions() { + return null; + } + + /** + * Checks the signature algorithm of the specified certificate. + */ + public void check(Certificate cert, Collection<String> unresolvedCritExts) + throws CertPathValidatorException { + check(cert); + } + + public static void check(Certificate cert) + throws CertPathValidatorException { + X509Certificate xcert = (X509Certificate)cert; + check(xcert.getSigAlgName()); + } + + static void check(AlgorithmId aid) throws CertPathValidatorException { + check(aid.getName()); + } + + static void check(X509CRL crl) throws CertPathValidatorException { + check(crl.getSigAlgName()); + } + + private static void check(String algName) + throws CertPathValidatorException { + + String lowerCaseAlgName = algName.toLowerCase(Locale.ENGLISH); + + for (String disabled : disabledAlgorithms) { + // checking the signature algorithm name + if (lowerCaseAlgName.indexOf(disabled) != -1) { + throw new CertPathValidatorException( + "algorithm check failed: " + algName + " is disabled"); + } + } + } + +} --- old/src/share/classes/com/sun/imageio/plugins/bmp/BMPImageReader.java 2009-07-28 17:06:52.144000000 +0400 +++ openjdk/jdk/src/share/classes/com/sun/imageio/plugins/bmp/BMPImageReader.java 2009-07-28 17:06:51.488000000 +0400 @@ -62,6 +62,8 @@ import java.io.*; import java.nio.*; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Iterator; import java.util.StringTokenizer; @@ -502,12 +504,18 @@ iis.reset(); try { - if (metadata.colorSpace == PROFILE_LINKED) + if (metadata.colorSpace == PROFILE_LINKED && + isLinkedProfileAllowed() && + !isUncOrDevicePath(profile)) + { + String path = new String(profile, "windows-1252"); + colorSpace = - new ICC_ColorSpace(ICC_Profile.getInstance(new String(profile))); - else + new ICC_ColorSpace(ICC_Profile.getInstance(path)); + } else { colorSpace = new ICC_ColorSpace(ICC_Profile.getInstance(profile)); + } } catch (Exception e) { colorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB); } @@ -1745,4 +1753,69 @@ public void sequenceStarted(ImageReader src, int minIndex) {} public void readAborted(ImageReader src) {} } + + private static Boolean isLinkedProfileDisabled = null; + + private static boolean isLinkedProfileAllowed() { + if (isLinkedProfileDisabled == null) { + PrivilegedAction<Boolean> a = new PrivilegedAction<Boolean>() { + public Boolean run() { + return Boolean.getBoolean("sun.imageio.plugins.bmp.disableLinkedProfiles"); + } + }; + isLinkedProfileDisabled = AccessController.doPrivileged(a); + } + return !isLinkedProfileDisabled; + } + + private static Boolean isWindowsPlatform = null; + + /** + * Verifies whether the byte array contans a unc path. + * Non-UNC path examples: + * c:\path\to\file - simple notation + * \\?\c:\path\to\file - long notation + * + * UNC path examples: + * \\server\share - a UNC path in simple notation + * \\?\UNC\server\share - a UNC path in long notation + * \\.\some\device - a path to device. + */ + private static boolean isUncOrDevicePath(byte[] p) { + if (isWindowsPlatform == null) { + PrivilegedAction<Boolean> a = new PrivilegedAction<Boolean>() { + public Boolean run() { + String osname = System.getProperty("os.name"); + return (osname != null && + osname.toLowerCase().startsWith("win")); + } + }; + isWindowsPlatform = AccessController.doPrivileged(a); + } + + if (!isWindowsPlatform) { + /* no need for the check on platforms except windows */ + return false; + } + + /* normalize prefix of the path */ + if (p[0] == '/') p[0] = '\\'; + if (p[1] == '/') p[1] = '\\'; + if (p[3] == '/') p[3] = '\\'; + + + if ((p[0] == '\\') && (p[1] == '\\')) { + if ((p[2] == '?') && (p[3] == '\\')) { + // long path: whether unc or local + return ((p[4] == 'U' || p[4] == 'u') && + (p[5] == 'N' || p[5] == 'n') && + (p[6] == 'C' || p[6] == 'c')); + } else { + // device path or short unc notation + return true; + } + } else { + return false; + } + } } --- old/src/share/classes/java/lang/ClassLoader.java Fri Jul 31 15:59:47 2009 +++ openjdk/jdk/src/share/classes/java/lang/ClassLoader.java Fri Jul 31 15:59:46 200 @@ -163,11 +163,6 @@ registerNatives(); } - // If initialization succeed this is set to true and security checks will - // succeed. Otherwise the object is not initialized and the object is - // useless. - private boolean initialized = false; - // The parent class loader for delegation private ClassLoader parent; @@ -193,6 +188,18 @@ // to its corresponding Package object. private HashMap packages = new HashMap(); + private static Void checkCreateClassLoader() { + SecurityManager security = System.getSecurityManager(); + if (security != null) { + security.checkCreateClassLoader(); + } + return null; + } + + private ClassLoader(Void unused, ClassLoader parent) { + this.parent = parent; + } + /** * Creates a new class loader using the specified parent class loader for * delegation. @@ -213,12 +220,7 @@ * @since 1.2 */ protected ClassLoader(ClassLoader parent) { - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkCreateClassLoader(); - } - this.parent = parent; - initialized = true; + this(checkCreateClassLoader(), parent); } /** @@ -237,15 +239,9 @@ * of a new class loader. */ protected ClassLoader() { - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkCreateClassLoader(); - } - this.parent = getSystemClassLoader(); - initialized = true; + this(checkCreateClassLoader(), getSystemClassLoader()); } - // -- Class -- /** @@ -627,7 +623,6 @@ ProtectionDomain protectionDomain) throws ClassFormatError { - check(); protectionDomain = preDefineClass(name, protectionDomain); Class c = null; @@ -709,8 +704,6 @@ ProtectionDomain protectionDomain) throws ClassFormatError { - check(); - int len = b.remaining(); // Use byte[] if not a direct ByteBufer: @@ -858,7 +851,6 @@ * @see #defineClass(String, byte[], int, int) */ protected final void resolveClass(Class<?> c) { - check(); resolveClass0(c); } @@ -889,7 +881,6 @@ protected final Class<?> findSystemClass(String name) throws ClassNotFoundException { - check(); ClassLoader system = getSystemClassLoader(); if (system == null) { if (!checkName(name)) @@ -902,7 +893,6 @@ private Class findBootstrapClass0(String name) throws ClassNotFoundException { - check(); if (!checkName(name)) throw new ClassNotFoundException(name); return findBootstrapClass(name); @@ -911,13 +901,6 @@ private native Class findBootstrapClass(String name) throws ClassNotFoundException; - // Check to make sure the class loader has been initialized. - private void check() { - if (!initialized) { - throw new SecurityException("ClassLoader object not initialized"); - } - } - /** * Returns the class with the given <a href="#name">binary name</a> if this * loader has been recorded by the Java virtual machine as an initiating @@ -933,7 +916,6 @@ * @since 1.1 */ protected final Class<?> findLoadedClass(String name) { - check(); if (!checkName(name)) return null; return findLoadedClass0(name); @@ -954,11 +936,9 @@ * @since 1.1 */ protected final void setSigners(Class<?> c, Object[] signers) { - check(); c.setSigners(signers); } - // -- Resource -- /** --- old/src/share/classes/java/awt/Component.java 2009-07-23 13:47:51.000000000 +0400 +++ openjdk/jdk/src/share/classes/java/awt/Component.java 2009-07-23 13:47:51.000000000 +0400 @@ -4307,7 +4307,7 @@ } if (eventLog.isLoggable(Level.FINEST)) { - eventLog.log(Level.FINEST, "{0}", e); + eventLog.log(Level.FINEST, "{0}", String.valueOf(e)); } /* --- old/src/share/classes/java/awt/DefaultKeyboardFocusManager.java 2009-07-23 13:47:53.000000000 +0400 +++ openjdk/jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java 2009-07-23 13:47:53.000000000 +0400 @@ -379,7 +379,7 @@ // should receive focus first if (focusLog.isLoggable(Level.FINER)) { focusLog.log(Level.FINER, "tempLost {0}, toFocus {1}", - new Object[]{tempLost, toFocus}); + new Object[]{String.valueOf(tempLost), String.valueOf(toFocus)}); } if (tempLost != null) { tempLost.requestFocusInWindow(CausedFocusEvent.Cause.ACTIVATION); @@ -447,7 +447,8 @@ Component newFocusOwner = fe.getComponent(); if (oldFocusOwner == newFocusOwner) { if (focusLog.isLoggable(Level.FINE)) { - focusLog.log(Level.FINE, "Skipping {0} because focus owner is the same", new Object[] {e}); + focusLog.log(Level.FINE, "Skipping {0} because focus owner is the same", + new Object[] {String.valueOf(e)}); } // We can't just drop the event - there could be // type-ahead markers associated with it. @@ -554,16 +555,20 @@ FocusEvent fe = (FocusEvent)e; Component currentFocusOwner = getGlobalFocusOwner(); if (currentFocusOwner == null) { - if (focusLog.isLoggable(Level.FINE)) focusLog.log(Level.FINE, "Skipping {0} because focus owner is null", - new Object[] {e}); + if (focusLog.isLoggable(Level.FINE)) { + focusLog.log(Level.FINE, "Skipping {0} because focus owner is null", + new Object[] {String.valueOf(e)}); + } break; } // Ignore cases where a Component loses focus to itself. // If we make a mistake because of retargeting, then the // FOCUS_GAINED handler will correct it. if (currentFocusOwner == fe.getOppositeComponent()) { - if (focusLog.isLoggable(Level.FINE)) focusLog.log(Level.FINE, "Skipping {0} because current focus owner is equal to opposite", - new Object[] {e}); + if (focusLog.isLoggable(Level.FINE)) { + focusLog.log(Level.FINE, "Skipping {0} because current focus owner is equal to opposite", + new Object[] {String.valueOf(e)}); + } break; } @@ -631,9 +636,11 @@ Window losingFocusWindow = we.getWindow(); Window activeWindow = getGlobalActiveWindow(); Window oppositeWindow = we.getOppositeWindow(); - if (focusLog.isLoggable(Level.FINE)) focusLog.log(Level.FINE, "Active {0}, Current focused {1}, losing focus {2} opposite {3}", - new Object[] {activeWindow, currentFocusedWindow, - losingFocusWindow, oppositeWindow}); + if (focusLog.isLoggable(Level.FINE)) { + focusLog.log(Level.FINE, "Active {0}, Current focused {1}, losing focus {2} opposite {3}", + new Object[] {String.valueOf(activeWindow), String.valueOf(currentFocusedWindow), + String.valueOf(losingFocusWindow), String.valueOf(oppositeWindow)}); + } if (currentFocusedWindow == null) { break; } @@ -818,7 +825,10 @@ } } if (ke != null) { - focusLog.log(Level.FINER, "Pumping approved event {0}", new Object[] {ke}); + if (focusLog.isLoggable(Level.FINER)) { + focusLog.log(Level.FINER, "Pumping approved event {0}", + new Object[] {String.valueOf(ke)}); + } enqueuedKeyEvents.removeFirst(); } } @@ -840,7 +850,7 @@ Iterator iter = typeAheadMarkers.iterator(); while (iter.hasNext()) { TypeAheadMarker marker = (TypeAheadMarker)iter.next(); - focusLog.log(Level.FINEST, " {0}", marker); + focusLog.log(Level.FINEST, " {0}", String.valueOf(marker)); } } } @@ -868,7 +878,10 @@ // The fix is rolled out. if (ke.getWhen() > marker.after) { - focusLog.log(Level.FINER, "Storing event {0} because of marker {1}", new Object[] {ke, marker}); + if (focusLog.isLoggable(Level.FINER)) { + focusLog.log(Level.FINER, "Storing event {0} because of marker {1}", + new Object[] {String.valueOf(ke), String.valueOf(marker)}); + } enqueuedKeyEvents.addLast(ke); return true; } @@ -880,7 +893,10 @@ } case FocusEvent.FOCUS_GAINED: - focusLog.log(Level.FINEST, "Markers before FOCUS_GAINED on {0}", new Object[] {target}); + if (focusLog.isLoggable(Level.FINEST)) { + focusLog.log(Level.FINEST, "Markers before FOCUS_GAINED on {0}", + new Object[] {String.valueOf(target)}); + } dumpMarkers(); // Search the marker list for the first marker tied to // the Component which just gained focus. Then remove @@ -909,7 +925,9 @@ } } else { // Exception condition - event without marker - focusLog.log(Level.FINER, "Event without marker {0}", e); + if (focusLog.isLoggable(Level.FINER)) { + focusLog.log(Level.FINER, "Event without marker {0}", String.valueOf(e)); + } } } focusLog.log(Level.FINEST, "Markers after FOCUS_GAINED"); @@ -1146,8 +1164,10 @@ return; } - focusLog.log(Level.FINER, "Enqueue at {0} for {1}", - new Object[] {after, untilFocused}); + if (focusLog.isLoggable(Level.FINER)) { + focusLog.log(Level.FINER, "Enqueue at {0} for {1}", + new Object[] {after, String.valueOf(untilFocused)}); + } int insertionIndex = 0, i = typeAheadMarkers.size(); @@ -1186,8 +1206,10 @@ return; } - focusLog.log(Level.FINER, "Dequeue at {0} for {1}", - new Object[] {after, untilFocused}); + if (focusLog.isLoggable(Level.FINER)) { + focusLog.log(Level.FINER, "Dequeue at {0} for {1}", + new Object[] {after, String.valueOf(untilFocused)}); + } TypeAheadMarker marker; ListIterator iter = typeAheadMarkers.listIterator --- old/src/share/classes/java/awt/KeyboardFocusManager.java 2009-07-23 13:47:54.000000000 +0400 +++ openjdk/jdk/src/share/classes/java/awt/KeyboardFocusManager.java 2009-07-23 13:47:54.000000000 +0400 @@ -586,7 +586,7 @@ void setNativeFocusOwner(Component comp) { if (focusLog.isLoggable(Level.FINEST)) { focusLog.log(Level.FINEST, "Calling peer {0} setCurrentFocusOwner for {1}", - new Object[] {peer, comp}); + new Object[] {String.valueOf(peer), String.valueOf(comp)}); } peer.setCurrentFocusOwner(comp); } @@ -2338,20 +2338,20 @@ Window nativeFocusedWindow = thisManager.getNativeFocusedWindow(); if (focusLog.isLoggable(Level.FINER)) { focusLog.log(Level.FINER, "SNFH for {0} in {1}", - new Object[] {descendant, heavyweight}); + new Object[] {String.valueOf(descendant), String.valueOf(heavyweight)}); } if (focusLog.isLoggable(Level.FINEST)) { focusLog.log(Level.FINEST, "0. Current focus owner {0}", - currentFocusOwner); + String.valueOf(currentFocusOwner)); focusLog.log(Level.FINEST, "0. Native focus owner {0}", - nativeFocusOwner); + String.valueOf(nativeFocusOwner)); focusLog.log(Level.FINEST, "0. Native focused window {0}", - nativeFocusedWindow); + String.valueOf(nativeFocusedWindow)); } synchronized (heavyweightRequests) { HeavyweightFocusRequest hwFocusRequest = getLastHWRequest(); if (focusLog.isLoggable(Level.FINEST)) { - focusLog.log(Level.FINEST, "Request {0}", hwFocusRequest); + focusLog.log(Level.FINEST, "Request {0}", String.valueOf(hwFocusRequest)); } if (hwFocusRequest == null && heavyweight == nativeFocusOwner) @@ -2360,7 +2360,7 @@ // Redundant request. if (focusLog.isLoggable(Level.FINEST)) focusLog.log(Level.FINEST, "1. SNFH_FAILURE for {0}", - descendant); + String.valueOf(descendant)); return SNFH_FAILURE; } @@ -2393,7 +2393,7 @@ SunToolkit.postEvent(descendant.appContext, newFocusOwnerEvent); if (focusLog.isLoggable(Level.FINEST)) - focusLog.log(Level.FINEST, "2. SNFH_HANDLED for {0}", descendant); + focusLog.log(Level.FINEST, "2. SNFH_HANDLED for {0}", String.valueOf(descendant)); return SNFH_SUCCESS_HANDLED; } else if (hwFocusRequest != null && hwFocusRequest.heavyweight == heavyweight) { @@ -2900,11 +2900,11 @@ KeyboardFocusManager manager = getCurrentKeyboardFocusManager(); if (focusLog.isLoggable(Level.FINER)) { if (event instanceof FocusEvent || event instanceof WindowEvent) { - focusLog.log(Level.FINER, ">>> {0}", new Object[] {event}); + focusLog.log(Level.FINER, ">>> {0}", new Object[] {String.valueOf(event)}); } if (focusLog.isLoggable(Level.FINER) && event instanceof KeyEvent) { - focusLog.log(Level.FINER, " focus owner is {0}", new Object[] {manager.getGlobalFocusOwner()}); - focusLog.log(Level.FINER, ">>> {0}", new Object[] {event}); + focusLog.log(Level.FINER, " focus owner is {0}", new Object[] {String.valueOf(manager.getGlobalFocusOwner())}); + focusLog.log(Level.FINER, ">>> {0}", new Object[] {String.valueOf(event)}); } } --- old/src/share/classes/sun/awt/DebugSettings.java 2009-07-23 13:47:56.000000000 +0400 +++ openjdk/jdk/src/share/classes/sun/awt/DebugSettings.java 2009-07-23 13:47:56.000000000 +0400 @@ -129,7 +129,7 @@ // echo the initial property settings to stdout if (log.isLoggable(Level.FINE)) { - log.log(Level.FINE, "DebugSettings:\n{0}", this); + log.log(Level.FINE, "DebugSettings:\n{0}", String.valueOf(this)); } } --- old/src/solaris/classes/sun/awt/X11/XBaseWindow.java 2009-07-23 13:47:57.000000000 +0400 +++ openjdk/jdk/src/solaris/classes/sun/awt/X11/XBaseWindow.java 2009-07-23 13:47:57.000000000 +0400 @@ -824,7 +824,9 @@ * The active grab overrides activated automatic grab. */ public boolean grabInput() { - grabLog.log(Level.FINE, "Grab input on {0}", new Object[] {this}); + if (grabLog.isLoggable(Level.FINE)) { + grabLog.log(Level.FINE, "Grab input on {0}", new Object[] {String.valueOf(this)}); + } XToolkit.awtLock(); try { @@ -879,7 +881,10 @@ XToolkit.awtLock(); try { XBaseWindow grabWindow = XAwtState.getGrabWindow(); - grabLog.log(Level.FINE, "UnGrab input on {0}", new Object[] {grabWindow}); + if (grabLog.isLoggable(Level.FINE)) { + grabLog.log(Level.FINE, "UnGrab input on {0}", + new Object[] {String.valueOf(grabWindow)}); + } if (grabWindow != null) { grabWindow.ungrabInputImpl(); XlibWrapper.XUngrabPointer(XToolkit.getDisplay(), CurrentTime); @@ -930,7 +935,7 @@ XPropertyCache.clearCache(window, XAtom.get(msg.get_atom())); } if (eventLog.isLoggable(Level.FINER)) { - eventLog.log(Level.FINER, "{0}", new Object[] {msg}); + eventLog.log(Level.FINER, "{0}", new Object[] {String.valueOf(msg)}); } } @@ -1000,8 +1005,10 @@ } public void handleConfigureNotifyEvent(XEvent xev) { XConfigureEvent xe = xev.get_xconfigure(); - insLog.log(Level.FINER, "Configure, {0}", - new Object[] {xe}); + if (insLog.isLoggable(Level.FINER)) { + insLog.log(Level.FINER, "Configure, {0}", + new Object[] {String.valueOf(xe)}); + } x = xe.get_x(); y = xe.get_y(); width = xe.get_width(); --- old/src/solaris/classes/sun/awt/X11/XCheckboxMenuItemPeer.java 2009-07-23 13:47:59.000000000 +0400 +++ openjdk/jdk/src/solaris/classes/sun/awt/X11/XCheckboxMenuItemPeer.java 2009-07-23 13:47:58.000000000 +0400 @@ -29,8 +29,6 @@ import java.awt.peer.*; import java.awt.event.*; -import java.util.logging.*; - import java.lang.reflect.Field; import sun.awt.SunToolkit; @@ -42,8 +40,6 @@ * ************************************************/ - private static Logger log = Logger.getLogger("sun.awt.X11.XCheckboxMenuItemPeer"); - /* * CheckboxMenuItem's fields */ --- old/src/solaris/classes/sun/awt/X11/XComponentPeer.java 2009-07-23 13:48:00.000000000 +0400 +++ openjdk/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java 2009-07-23 13:47:59.000000000 +0400 @@ -261,7 +261,9 @@ * Called when component receives focus */ public void focusGained(FocusEvent e) { - focusLog.log(Level.FINE, "{0}", new Object[] {e}); + if (focusLog.isLoggable(Level.FINER)) { + focusLog.log(Level.FINER, "{0}", new Object[] {String.valueOf(e)}); + } bHasFocus = true; } @@ -269,7 +271,9 @@ * Called when component loses focus */ public void focusLost(FocusEvent e) { - focusLog.log(Level.FINE, "{0}", new Object[] {e}); + if (focusLog.isLoggable(Level.FINE)) { + focusLog.log(Level.FINE, "{0}", new Object[] {String.valueOf(e)}); + } bHasFocus = false; } @@ -511,7 +515,10 @@ * @see java.awt.peer.ComponentPeer */ public void setEnabled(boolean value) { - enableLog.log(Level.FINE, "{0}ing {1}", new Object[] {(value?"Enabl":"Disabl"), this}); + if (enableLog.isLoggable(Level.FINE)) { + enableLog.log(Level.FINE, "{0}ing {1}", + new Object[] {(value?"Enabl":"Disabl"), String.valueOf(this)}); + } boolean repaintNeeded = (enabled != value); enabled = value; if (target instanceof Container) { @@ -1346,7 +1353,10 @@ * ButtonPress, ButtonRelease, KeyPress, KeyRelease, EnterNotify, LeaveNotify, MotionNotify */ protected boolean isEventDisabled(XEvent e) { - enableLog.log(Level.FINEST, "Component is {1}, checking for disabled event {0}", new Object[] {e, (isEnabled()?"enabled":"disable")}); + if (enableLog.isLoggable(Level.FINEST)) { + enableLog.log(Level.FINEST, "Component is {1}, checking for disabled event {0}", + new Object[] {String.valueOf(e), (isEnabled()?"enabled":"disable")}); + } if (!isEnabled()) { switch (e.get_type()) { case ButtonPress: @@ -1356,7 +1366,9 @@ case EnterNotify: case LeaveNotify: case MotionNotify: - enableLog.log(Level.FINER, "Event {0} is disable", new Object[] {e}); + if (enableLog.isLoggable(Level.FINER)) { + enableLog.log(Level.FINER, "Event {0} is disable", new Object[] {String.valueOf(e)}); + } return true; } } --- old/src/solaris/classes/sun/awt/X11/XContentWindow.java 2009-07-23 13:48:01.000000000 +0400 +++ openjdk/jdk/src/solaris/classes/sun/awt/X11/XContentWindow.java 2009-07-23 13:48:01.000000000 +0400 @@ -98,8 +98,10 @@ if (in != null) { newBounds.setLocation(-in.left, -in.top); } - if (insLog.isLoggable(Level.FINE)) insLog.log(Level.FINE, "Setting content bounds {0}, old bounds {1}", - new Object[] {newBounds, getBounds()}); + if (insLog.isLoggable(Level.FINE)) { + insLog.log(Level.FINE, "Setting content bounds {0}, old bounds {1}", + new Object[] {String.valueOf(newBounds), String.valueOf(getBounds())}); + } // Fix for 5023533: // Change in the size of the content window means, well, change of the size // Change in the location of the content window means change in insets --- old/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java 2009-07-23 13:48:02.000000000 +0400 +++ openjdk/jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java 2009-07-23 13:48:02.000000000 +0400 @@ -84,7 +84,11 @@ Rectangle bounds = (Rectangle)params.get(BOUNDS); dimensions = new WindowDimensions(bounds, getRealInsets(), false); params.put(BOUNDS, dimensions.getClientRect()); - insLog.log(Level.FINE, "Initial dimensions {0}", new Object[] { dimensions }); + + if (insLog.isLoggable(Level.FINE)) { + insLog.log(Level.FINE, "Initial dimensions {0}", + new Object[] { String.valueOf(dimensions) }); + } // Deny default processing of these events on the shell - proxy will take care of // them instead @@ -313,7 +317,10 @@ // Check if we have insets provided by the WM Insets correctWM = getWMSetInsets(null); if (correctWM != null) { - insLog.log(Level.FINER, "wm-provided insets {0}", new Object[]{correctWM}); + if (insLog.isLoggable(Level.FINER)) { + insLog.log(Level.FINER, "wm-provided insets {0}", + new Object[]{String.valueOf(correctWM)}); + } // If these insets are equal to our current insets - no actions are necessary Insets dimInsets = dimensions.getInsets(); if (correctWM.equals(dimInsets)) { @@ -327,7 +334,10 @@ correctWM = XWM.getWM().getInsets(this, xe.get_window(), xe.get_parent()); if (correctWM != null) { - insLog.log(Level.FINER, "correctWM {0}", new Object[] {correctWM}); + if (insLog.isLoggable(Level.FINER)) { + insLog.log(Level.FINER, "correctWM {0}", + new Object[] {String.valueOf(correctWM)}); + } } else { insLog.log(Level.FINER, "correctWM insets are not available, waiting for configureNotify"); } @@ -350,7 +360,9 @@ * initial insets were wrong (most likely they were). */ Insets correction = difference(correctWM, currentInsets); - insLog.log(Level.FINEST, "Corrention {0}", new Object[] {correction}); + if (insLog.isLoggable(Level.FINEST)) { + insLog.log(Level.FINEST, "Corrention {0}", new Object[] {String.valueOf(correction)}); + } if (!isNull(correction)) { /* * Actual insets account for menubar/warning label, @@ -440,7 +452,10 @@ public Insets getInsets() { Insets in = copy(getRealInsets()); in.top += getMenuBarHeight() + getWarningWindowHeight(); - if (insLog.isLoggable(Level.FINEST)) insLog.log(Level.FINEST, "Get insets returns {0}", new Object[] {in}); + if (insLog.isLoggable(Level.FINEST)) { + insLog.log(Level.FINEST, "Get insets returns {0}", + new Object[] {String.valueOf(in)}); + } return in; } @@ -589,8 +604,10 @@ dims.setSize(width, height); break; } - if (insLog.isLoggable(Level.FINE)) insLog.log(Level.FINE, "For the operation {0} new dimensions are {1}", - new Object[] {operationToString(operation), dims}); + if (insLog.isLoggable(Level.FINE)) { + insLog.log(Level.FINE, "For the operation {0} new dimensions are {1}", + new Object[] {operationToString(operation), String.valueOf(dims)}); + } reshape(dims, operation, userReshape); } @@ -660,7 +677,10 @@ public void handleConfigureNotifyEvent(XEvent xev) { assert (SunToolkit.isAWTLockHeldByCurrentThread()); XConfigureEvent xe = xev.get_xconfigure(); - insLog.log(Level.FINE, "Configure notify {0}", new Object[] {xe}); + if (insLog.isLoggable(Level.FINE)) { + insLog.log(Level.FINE, "Configure notify {0}", + new Object[] {String.valueOf(xe)}); + } // XXX: should really only consider synthetic events, but if (isReparented()) { @@ -752,7 +772,9 @@ case XWM.SAWFISH_WM: { Point xlocation = queryXLocation(); - if (log.isLoggable(Level.FINE)) log.log(Level.FINE, "New X location: {0}", new Object[]{xlocation}); + if (log.isLoggable(Level.FINE)) { + log.log(Level.FINE, "New X location: {0}", new Object[]{String.valueOf(xlocation)}); + } if (xlocation != null) { newLocation = xlocation; } @@ -769,8 +791,10 @@ copy(currentInsets), true); - insLog.log(Level.FINER, "Insets are {0}, new dimensions {1}", - new Object[] {currentInsets, newDimensions}); + if (insLog.isLoggable(Level.FINER)) { + insLog.log(Level.FINER, "Insets are {0}, new dimensions {1}", + new Object[] {String.valueOf(currentInsets), String.valueOf(newDimensions)}); + } checkIfOnNewScreen(newDimensions.getBounds()); @@ -935,7 +959,7 @@ Point location = target.getLocation(); if (insLog.isLoggable(Level.FINE)) insLog.log(Level.FINE, "getLocationOnScreen {0} not reparented: {1} ", - new Object[] {this, location}); + new Object[] {String.valueOf(this), String.valueOf(location)}); return location; } } finally { @@ -972,7 +996,10 @@ } public void setVisible(boolean vis) { - log.log(Level.FINER, "Setting {0} to visible {1}", new Object[] {this, Boolean.valueOf(vis)}); + if (log.isLoggable(Level.FINER)) { + log.log(Level.FINER, "Setting {0} to visible {1}", + new Object[] {String.valueOf(this), Boolean.valueOf(vis)}); + } if (vis && !isVisible()) { XWM.setShellDecor(this); super.setVisible(vis); @@ -1027,7 +1054,10 @@ } private void handleWmTakeFocus(XClientMessageEvent cl) { - focusLog.log(Level.FINE, "WM_TAKE_FOCUS on {0}", new Object[]{this}); + if (focusLog.isLoggable(Level.FINE)) { + focusLog.log(Level.FINE, "WM_TAKE_FOCUS on {0}", + new Object[]{String.valueOf(this)}); + } requestWindowFocus(cl.get_data(1), true); } --- old/src/solaris/classes/sun/awt/X11/XDropTargetProtocol.java 2009-07-23 13:48:04.000000000 +0400 +++ openjdk/jdk/src/solaris/classes/sun/awt/X11/XDropTargetProtocol.java 2009-07-23 13:48:03.000000000 +0400 @@ -117,7 +117,7 @@ EmbedderRegistryEntry entry = getEmbedderRegistryEntry(toplevel); if (logger.isLoggable(Level.FINEST)) { - logger.log(Level.FINEST, " entry={0}", new Object[] {entry}); + logger.log(Level.FINEST, " entry={0}", new Object[] {String.valueOf(entry)}); } // Window not registered as an embedder for this protocol. if (entry == null) { @@ -138,7 +138,8 @@ long proxy = entry.getProxy(); if (logger.isLoggable(Level.FINEST)) { - logger.log(Level.FINEST, " proxy={0} toplevel={1}", new Object[] {proxy, toplevel}); + logger.log(Level.FINEST, " proxy={0} toplevel={1}", + new Object[] {String.valueOf(proxy), String.valueOf(toplevel)}); } if (proxy == 0) { proxy = toplevel; --- old/src/solaris/classes/sun/awt/X11/XFocusProxyWindow.java 2009-07-23 13:48:05.000000000 +0400 +++ openjdk/jdk/src/solaris/classes/sun/awt/X11/XFocusProxyWindow.java 2009-07-23 13:48:05.000000000 +0400 @@ -34,7 +34,6 @@ * and therefore X doesn't control focus after we have set it to proxy. */ public class XFocusProxyWindow extends XBaseWindow { - private static final Logger focusLog = Logger.getLogger("sun.awt.X11.focus.XFocusProxyWindow"); XWindowPeer owner; public XFocusProxyWindow(XWindowPeer owner) { --- old/src/solaris/classes/sun/awt/X11/XFramePeer.java 2009-07-23 13:48:06.000000000 +0400 +++ openjdk/jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java 2009-07-23 13:48:06.000000000 +0400 @@ -281,7 +281,10 @@ super.handlePropertyNotify(xev); XPropertyEvent ev = xev.get_xproperty(); - log.log(Level.FINER, "Property change {0}", new Object[] {ev}); + if (log.isLoggable(Level.FINER)) { + log.log(Level.FINER, "Property change {0}", new Object[] {String.valueOf(ev)}); + } + /* * Let's see if this is a window state protocol message, and * if it is - decode a new state in terms of java constants. --- old/src/solaris/classes/sun/awt/X11/XIconWindow.java 2009-07-23 13:48:08.000000000 +0400 +++ openjdk/jdk/src/solaris/classes/sun/awt/X11/XIconWindow.java 2009-07-23 13:48:07.000000000 +0400 @@ -75,7 +75,10 @@ XIconSize[] res = new XIconSize[count]; for (int i = 0; i < count; i++, sizes_ptr += XIconSize.getSize()) { res[i] = new XIconSize(sizes_ptr); - log.log(Level.FINEST, "sizes_ptr[{1}] = {0}", new Object[] {res[i], Integer.valueOf(i)}); + if (log.isLoggable(Level.FINEST)) { + log.log(Level.FINEST, "sizes_ptr[{1}] = {0}", + new Object[] {String.valueOf(res[i]), Integer.valueOf(i)}); + } } return res; } finally { @@ -92,7 +95,9 @@ } XIconSize[] sizeList = getIconSizes(); - log.log(Level.FINEST, "Icon sizes: {0}", new Object[] {sizeList}); + if (log.isLoggable(Level.FINEST)) { + log.log(Level.FINEST, "Icon sizes: {0}", new Object[] {String.valueOf(sizeList)}); + } if (sizeList == null) { // No icon sizes so we simply fall back to 16x16 return new Dimension(16, 16); @@ -444,7 +449,9 @@ } Dimension iconSize = getIconSize(width, height); if (iconSize != null) { - log.log(Level.FINEST, "Icon size: {0}", iconSize); + if (log.isLoggable(Level.FINEST)) { + log.log(Level.FINEST, "Icon size: {0}", String.valueOf(iconSize)); + } iconWidth = iconSize.width; iconHeight = iconSize.height; } else { --- old/src/solaris/classes/sun/awt/X11/XInputMethod.java 2009-07-23 13:48:09.000000000 +0400 +++ openjdk/jdk/src/solaris/classes/sun/awt/X11/XInputMethod.java 2009-07-23 13:48:08.000000000 +0400 @@ -108,8 +108,10 @@ client = getParent(client); peer = (XComponentPeer)XToolkit.targetToPeer(client); } - log.log(Level.FINE, "Peer is {0}, client is {1}", new Object[] {peer, client}); - + if (log.isLoggable(Level.FINE)) { + log.log(Level.FINE, "Peer is {0}, client is {1}", + new Object[] {String.valueOf(peer), String.valueOf(client)}); + } if (peer != null) return peer; --- old/src/solaris/classes/sun/awt/X11/XMenuItemPeer.java 2009-07-23 13:48:10.000000000 +0400 +++ openjdk/jdk/src/solaris/classes/sun/awt/X11/XMenuItemPeer.java 2009-07-23 13:48:10.000000000 +0400 @@ -43,8 +43,6 @@ * ************************************************/ - private static Logger log = Logger.getLogger("sun.awt.X11.XMenuItemPeer"); - /* * Primary members */ --- old/src/solaris/classes/sun/awt/X11/XNETProtocol.java 2009-07-23 13:48:11.000000000 +0400 +++ openjdk/jdk/src/solaris/classes/sun/awt/X11/XNETProtocol.java 2009-07-23 13:48:11.000000000 +0400 @@ -56,7 +56,11 @@ private void setInitialState(XWindowPeer window, int state) { XAtomList old_state = window.getNETWMState(); - log.log(Level.FINE, "Current state of the window {0} is {1}", new Object[] {window, old_state}); + + if (log.isLoggable(Level.FINE)) { + log.log(Level.FINE, "Current state of the window {0} is {1}", + new Object[] {String.valueOf(window), String.valueOf(old_state)}); + } if ((state & Frame.MAXIMIZED_VERT) != 0) { old_state.add(XA_NET_WM_STATE_MAXIMIZED_VERT); } else { @@ -67,7 +71,10 @@ } else { old_state.remove(XA_NET_WM_STATE_MAXIMIZED_HORZ); } - log.log(Level.FINE, "Setting initial state of the window {0} to {1}", new Object[] {window, old_state}); + if (log.isLoggable(Level.FINE)) { + log.log(Level.FINE, "Setting initial state of the window {0} to {1}", + new Object[] {String.valueOf(window), String.valueOf(old_state)}); + } window.setNETWMState(old_state); } @@ -191,7 +198,10 @@ req.set_format(32); req.set_data(0, (!set) ? _NET_WM_STATE_REMOVE : _NET_WM_STATE_ADD); req.set_data(1, state.getAtom()); - log.log(Level.FINE, "Setting _NET_STATE atom {0} on {1} for {2}", new Object[] {state, window, Boolean.valueOf(set)}); + if (log.isLoggable(Level.FINE)) { + log.log(Level.FINE, "Setting _NET_STATE atom {0} on {1} for {2}", + new Object[] {String.valueOf(state), String.valueOf(window), Boolean.valueOf(set)}); + } XToolkit.awtLock(); try { XlibWrapper.XSendEvent(XToolkit.getDisplay(), @@ -208,13 +218,19 @@ } } else { XAtomList net_wm_state = window.getNETWMState(); - log.log(Level.FINE, "Current state on {0} is {1}", new Object[] {window, net_wm_state}); + if (log.isLoggable(Level.FINE)) { + log.log(Level.FINE, "Current state on {0} is {1}", + new Object[] {String.valueOf(window), String.valueOf(net_wm_state)}); + } if (!set) { net_wm_state.remove(state); } else { net_wm_state.add(state); } - log.log(Level.FINE, "Setting states on {0} to {1}", new Object[] {window, net_wm_state}); + if (log.isLoggable(Level.FINE)) { + log.log(Level.FINE, "Setting states on {0} to {1}", + new Object[] {String.valueOf(window), String.valueOf(net_wm_state)}); + } window.setNETWMState(net_wm_state); } XToolkit.XSync(); --- old/src/solaris/classes/sun/awt/X11/XProtocol.java 2009-07-23 13:48:13.000000000 +0400 +++ openjdk/jdk/src/solaris/classes/sun/awt/X11/XProtocol.java 2009-07-23 13:48:12.000000000 +0400 @@ -68,7 +68,10 @@ } finally { if (firstCheck) { firstCheck = false; - log.log(Level.FINE, "{0}:{1} supports {2}", new Object[] {this, listName, protocols}); + if (log.isLoggable(Level.FINE)) { + log.log(Level.FINE, "{0}:{1} supports {2}", + new Object[] {String.valueOf(this), String.valueOf(listName), String.valueOf(protocols)}); + } } } } --- old/src/solaris/classes/sun/awt/X11/XQueryTree.java 2009-07-23 13:48:14.000000000 +0400 +++ openjdk/jdk/src/solaris/classes/sun/awt/X11/XQueryTree.java 2009-07-23 13:48:13.000000000 +0400 @@ -32,7 +32,6 @@ public class XQueryTree { private static Unsafe unsafe = XlibWrapper.unsafe; - private static final Logger log = Logger.getLogger("sun.awt.X11.XQueryTree"); private boolean __executed = false; long _w; long root_ptr = unsafe.allocateMemory(Native.getLongSize()); --- old/src/solaris/classes/sun/awt/X11/XToolkit.java 2009-07-23 13:48:15.000000000 +0400 +++ openjdk/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java 2009-07-23 13:48:15.000000000 +0400 @@ -555,7 +555,7 @@ } if (eventLog.isLoggable(Level.FINER)) { - eventLog.log(Level.FINER, "{0}", ev); + eventLog.log(Level.FINER, "{0}", String.valueOf(ev)); } // Check if input method consumes the event @@ -1668,8 +1668,10 @@ if (timeoutTaskLog.isLoggable(Level.FINER)) { timeoutTaskLog.log(Level.FINER, "XToolkit.schedule(): current time={0}" + "; interval={1}" + - "; task being added={2}" + "; tasks before addition={3}", new Object[] { - Long.valueOf(System.currentTimeMillis()), Long.valueOf(interval), task, timeoutTasks}); + "; task being added={2}" + "; tasks before addition={3}", + new Object[] { Long.valueOf(System.currentTimeMillis()), + Long.valueOf(interval), String.valueOf(task), + String.valueOf(timeoutTasks)}); } if (timeoutTasks == null) { @@ -1714,7 +1716,8 @@ private static void callTimeoutTasks() { if (timeoutTaskLog.isLoggable(Level.FINER)) { timeoutTaskLog.log(Level.FINER, "XToolkit.callTimeoutTasks(): current time={0}" + - "; tasks={1}", new Object[] {Long.valueOf(System.currentTimeMillis()), timeoutTasks}); + "; tasks={1}", new Object[] {Long.valueOf(System.currentTimeMillis()), + String.valueOf(timeoutTasks)}); } if (timeoutTasks == null || timeoutTasks.isEmpty()) { @@ -1732,7 +1735,8 @@ if (timeoutTaskLog.isLoggable(Level.FINER)) { timeoutTaskLog.log(Level.FINER, "XToolkit.callTimeoutTasks(): current time={0}" + - "; about to run task={1}", new Object[] {Long.valueOf(currentTime), task}); + "; about to run task={1}", + new Object[] {Long.valueOf(currentTime), String.valueOf(task)}); } try { --- old/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java 2009-07-23 13:48:16.000000000 +0400 +++ openjdk/jdk/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java 2009-07-23 13:48:16.000000000 +0400 @@ -106,10 +106,11 @@ } XConfigureEvent ce = ev.get_xconfigure(); - - ctrLog.log(Level.FINE, "ConfigureNotify on parent of {0}: {1}x{2}+{3}+{4} (old: {5}+{6})", - new Object[] { XTrayIconPeer.this, ce.get_width(), ce.get_height(), - ce.get_x(), ce.get_y(), old_x, old_y }); + if (ctrLog.isLoggable(Level.FINE)) { + ctrLog.log(Level.FINE, "ConfigureNotify on parent of {0}: {1}x{2}+{3}+{4} (old: {5}+{6})", + new Object[] { String.valueOf(XTrayIconPeer.this), ce.get_width(), ce.get_height(), + ce.get_x(), ce.get_y(), old_x, old_y }); + } // A workaround for Gnome/Metacity (it doesn't affect the behaviour on KDE). // On Metacity the EmbeddedFrame's parent window bounds are larger @@ -129,15 +130,17 @@ // If both the height and the width differ from the fixed size then WM // must level at least one side to the fixed size. For some reason it may take // a few hops (even after reparenting) and we have to skip the intermediate ones. - ctrLog.log(Level.FINE, "ConfigureNotify on parent of {0}. Skipping as intermediate resizing.", - XTrayIconPeer.this); + if (ctrLog.isLoggable(Level.FINE)) { + ctrLog.log(Level.FINE, "ConfigureNotify on parent of {0}. Skipping as intermediate resizing.", + String.valueOf(XTrayIconPeer.this)); + } return; } else if (ce.get_height() > TRAY_ICON_HEIGHT) { - - ctrLog.log(Level.FINE, "ConfigureNotify on parent of {0}. Centering by \"Y\".", - XTrayIconPeer.this); - + if (ctrLog.isLoggable(Level.FINE)) { + ctrLog.log(Level.FINE, "ConfigureNotify on parent of {0}. Centering by \"Y\".", + String.valueOf(XTrayIconPeer.this)); + } XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(), eframeParentID, ce.get_x(), ce.get_y()+ce.get_height()/2-TRAY_ICON_HEIGHT/2, @@ -147,10 +150,10 @@ ex_width = 0; } else if (ce.get_width() > TRAY_ICON_WIDTH) { - - ctrLog.log(Level.FINE, "ConfigureNotify on parent of {0}. Centering by \"X\".", - XTrayIconPeer.this); - + if (ctrLog.isLoggable(Level.FINE)) { + ctrLog.log(Level.FINE, "ConfigureNotify on parent of {0}. Centering by \"X\".", + String.valueOf(XTrayIconPeer.this)); + } XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(), eframeParentID, ce.get_x()+ce.get_width()/2 - TRAY_ICON_WIDTH/2, ce.get_y(), @@ -165,25 +168,27 @@ // In this case the parent window also lose centering. We have to restore it. if (ex_height != 0) { - - ctrLog.log(Level.FINE, "ConfigureNotify on parent of {0}. Move detected. Centering by \"Y\".", - XTrayIconPeer.this); - + if (ctrLog.isLoggable(Level.FINE)) { + ctrLog.log(Level.FINE, "ConfigureNotify on parent of {0}. Move detected. Centering by \"Y\".", + String.valueOf(XTrayIconPeer.this)); + } XlibWrapper.XMoveWindow(XToolkit.getDisplay(), eframeParentID, ce.get_x(), ce.get_y() + ex_height/2 - TRAY_ICON_HEIGHT/2); } else if (ex_width != 0) { - - ctrLog.log(Level.FINE, "ConfigureNotify on parent of {0}. Move detected. Centering by \"X\".", - XTrayIconPeer.this); - + if (ctrLog.isLoggable(Level.FINE)) { + ctrLog.log(Level.FINE, "ConfigureNotify on parent of {0}. Move detected. Centering by \"X\".", + String.valueOf(XTrayIconPeer.this)); + } XlibWrapper.XMoveWindow(XToolkit.getDisplay(), eframeParentID, ce.get_x() + ex_width/2 - TRAY_ICON_WIDTH/2, ce.get_y()); } else { - ctrLog.log(Level.FINE, "ConfigureNotify on parent of {0}. Move detected. Skipping.", - XTrayIconPeer.this); + if (ctrLog.isLoggable(Level.FINE)) { + ctrLog.log(Level.FINE, "ConfigureNotify on parent of {0}. Move detected. Skipping.", + String.valueOf(XTrayIconPeer.this)); + } } } old_x = ce.get_x(); --- old/src/solaris/classes/sun/awt/X11/XWM.java 2009-07-23 13:48:18.000000000 +0400 +++ openjdk/jdk/src/solaris/classes/sun/awt/X11/XWM.java 2009-07-23 13:48:17.000000000 +0400 @@ -398,7 +398,10 @@ static boolean isCDE() { if (!XA_DT_SM_WINDOW_INFO.isInterned()) { - log.log(Level.FINER, "{0} is not interned", new Object[] {XA_DT_SM_WINDOW_INFO}); + if (log.isLoggable(Level.FINER)) { + log.log(Level.FINER, "{0} is not interned", + new Object[] {String.valueOf(XA_DT_SM_WINDOW_INFO)}); + } return false; } @@ -429,7 +432,10 @@ /* Now check that this window has _DT_SM_STATE_INFO (ignore contents) */ if (!XA_DT_SM_STATE_INFO.isInterned()) { - log.log(Level.FINER, "{0} is not interned", new Object[] {XA_DT_SM_STATE_INFO}); + if (log.isLoggable(Level.FINER)) { + log.log(Level.FINER, "{0} is not interned", + new Object[] {String.valueOf(XA_DT_SM_STATE_INFO)}); + } return false; } WindowPropertyGetter getter2 = @@ -608,7 +614,10 @@ */ if (!XA_ICEWM_WINOPTHINT.isInterned()) { - log.log(Level.FINER, "{0} is not interned", new Object[] {XA_ICEWM_WINOPTHINT}); + if (log.isLoggable(Level.FINER)) { + log.log(Level.FINER, "{0} is not interned", + new Object[] {String.valueOf(XA_ICEWM_WINOPTHINT)}); + } return false; } @@ -641,7 +650,10 @@ */ static boolean isIceWM() { if (!XA_ICEWM_WINOPTHINT.isInterned()) { - log.log(Level.FINER, "{0} is not interned", new Object[] {XA_ICEWM_WINOPTHINT}); + if (log.isLoggable(Level.FINER)) { + log.log(Level.FINER, "{0} is not interned", + new Object[] {String.valueOf(XA_ICEWM_WINOPTHINT)}); + } return false; } @@ -1376,8 +1388,9 @@ XNETProtocol net_protocol = getWM().getNETProtocol(); if (net_protocol != null && net_protocol.active()) { Insets insets = getInsetsFromProp(window, XA_NET_FRAME_EXTENTS); - insLog.log(Level.FINE, "_NET_FRAME_EXTENTS: {0}", insets); - + if (insLog.isLoggable(Level.FINE)) { + insLog.log(Level.FINE, "_NET_FRAME_EXTENTS: {0}", String.valueOf(insets)); + } if (insets != null) { return insets; } @@ -1515,7 +1528,9 @@ * [mwm, e!, kwin, fvwm2 ... ] */ Insets correctWM = XWM.getInsetsFromExtents(window); - insLog.log(Level.FINER, "Got insets from property: {0}", correctWM); + if (insLog.isLoggable(Level.FINER)) { + insLog.log(Level.FINER, "Got insets from property: {0}", String.valueOf(correctWM)); + } if (correctWM == null) { correctWM = new Insets(0,0,0,0); @@ -1576,7 +1591,10 @@ } case XWM.OTHER_WM: default: { /* this is very similar to the E! case above */ - insLog.log(Level.FINEST, "Getting correct insets for OTHER_WM/default, parent: {0}", parent); + if (insLog.isLoggable(Level.FINEST)) { + insLog.log(Level.FINEST, "Getting correct insets for OTHER_WM/default, parent: {0}", + String.valueOf(parent)); + } syncTopLevelPos(parent, lwinAttr); int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(), window, lwinAttr.pData); @@ -1603,8 +1621,11 @@ && lwinAttr.get_width()+2*lwinAttr.get_border_width() == pattr.get_width() && lwinAttr.get_height()+2*lwinAttr.get_border_width() == pattr.get_height()) { - insLog.log(Level.FINEST, "Double reparenting detected, pattr({2})={0}, lwinAttr({3})={1}", - new Object[] {lwinAttr, pattr, parent, window}); + if (insLog.isLoggable(Level.FINEST)) { + insLog.log(Level.FINEST, "Double reparenting detected, pattr({2})={0}, lwinAttr({3})={1}", + new Object[] {String.valueOf(lwinAttr), String.valueOf(pattr), + String.valueOf(parent), String.valueOf(window)}); + } lwinAttr.set_x(pattr.get_x()); lwinAttr.set_y(pattr.get_y()); lwinAttr.set_border_width(lwinAttr.get_border_width()+pattr.get_border_width()); @@ -1631,8 +1652,11 @@ * widths and inner/outer distinction, so for the time * being, just ignore it. */ - insLog.log(Level.FINEST, "Attrs before calculation: pattr({2})={0}, lwinAttr({3})={1}", - new Object[] {lwinAttr, pattr, parent, window}); + if (insLog.isLoggable(Level.FINEST)) { + insLog.log(Level.FINEST, "Attrs before calculation: pattr({2})={0}, lwinAttr({3})={1}", + new Object[] {String.valueOf(lwinAttr), String.valueOf(pattr), + String.valueOf(parent), String.valueOf(window)}); + } correctWM = new Insets(lwinAttr.get_y() + lwinAttr.get_border_width(), lwinAttr.get_x() + lwinAttr.get_border_width(), pattr.get_height() - (lwinAttr.get_y() + lwinAttr.get_height() + 2*lwinAttr.get_border_width()), --- old/src/solaris/classes/sun/awt/X11/XWindow.java 2009-07-23 13:48:19.000000000 +0400 +++ openjdk/jdk/src/solaris/classes/sun/awt/X11/XWindow.java 2009-07-23 13:48:19.000000000 +0400 @@ -901,8 +901,10 @@ Rectangle oldBounds = getBounds(); super.handleConfigureNotifyEvent(xev); - insLog.log(Level.FINER, "Configure, {0}, event disabled: {1}", - new Object[] {xev, isEventDisabled(xev)}); + if (insLog.isLoggable(Level.FINER)) { + insLog.log(Level.FINER, "Configure, {0}, event disabled: {1}", + new Object[] {String.valueOf(xev), isEventDisabled(xev)}); + } if (isEventDisabled(xev)) { return; } @@ -923,7 +925,9 @@ public void handleMapNotifyEvent(XEvent xev) { super.handleMapNotifyEvent(xev); - log.log(Level.FINE, "Mapped {0}", new Object[] {this}); + if (log.isLoggable(Level.FINE)) { + log.log(Level.FINE, "Mapped {0}", new Object[] {String.valueOf(this)}); + } if (isEventDisabled(xev)) { return; } @@ -1151,10 +1155,14 @@ void updateSizeHints(int x, int y, int width, int height) { long flags = XlibWrapper.PSize | (isLocationByPlatform() ? 0 : (XlibWrapper.PPosition | XlibWrapper.USPosition)); if (!isResizable()) { - log.log(Level.FINER, "Window {0} is not resizable", new Object[] {this}); + if (log.isLoggable(Level.FINER)) { + log.log(Level.FINER, "Window {0} is not resizable", new Object[] {String.valueOf(this)}); + } flags |= XlibWrapper.PMinSize | XlibWrapper.PMaxSize; } else { - log.log(Level.FINER, "Window {0} is resizable", new Object[] {this}); + if (log.isLoggable(Level.FINER)) { + log.log(Level.FINER, "Window {0} is resizable", new Object[] {String.valueOf(this)}); + } } setSizeHints(flags, x, y, width, height); } @@ -1162,10 +1170,14 @@ void updateSizeHints(int x, int y) { long flags = isLocationByPlatform() ? 0 : (XlibWrapper.PPosition | XlibWrapper.USPosition); if (!isResizable()) { - log.log(Level.FINER, "Window {0} is not resizable", new Object[] {this}); + if (log.isLoggable(Level.FINER)) { + log.log(Level.FINER, "Window {0} is not resizable", new Object[] {String.valueOf(this)}); + } flags |= XlibWrapper.PMinSize | XlibWrapper.PMaxSize | XlibWrapper.PSize; } else { - log.log(Level.FINER, "Window {0} is resizable", new Object[] {this}); + if (log.isLoggable(Level.FINER)) { + log.log(Level.FINER, "Window {0} is resizable", new Object[] {String.valueOf(this)}); + } } setSizeHints(flags, x, y, width, height); } --- old/src/solaris/classes/sun/awt/X11/XWindowPeer.java 2009-07-23 13:48:21.000000000 +0400 +++ openjdk/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java 2009-07-23 13:48:20.000000000 +0400 @@ -376,7 +376,7 @@ if (iconLog.isLoggable(Level.FINEST)) { iconLog.log(Level.FINEST, ">>> Sizes of icon images:"); for (Iterator<XIconInfo> i = icons.iterator(); i.hasNext(); ) { - iconLog.log(Level.FINEST, " {0}", i.next()); + iconLog.log(Level.FINEST, " {0}", String.valueOf(i.next())); } } } @@ -826,7 +826,9 @@ public void handleFocusEvent(XEvent xev) { XFocusChangeEvent xfe = xev.get_xfocus(); FocusEvent fe; - focusLog.log(Level.FINE, "{0}", new Object[] {xfe}); + if (focusLog.isLoggable(Level.FINER)) { + focusLog.log(Level.FINER, "{0}", new Object[] {String.valueOf(xfe)}); + } if (isEventDisabled(xev)) { return; } @@ -1438,7 +1440,10 @@ synchronized(getStateLock()) { XDialogPeer blockerPeer = (XDialogPeer) ComponentAccessor.getPeer(d); if (blocked) { - log.log(Level.FINE, "{0} is blocked by {1}", new Object[] { this, blockerPeer}); + if (log.isLoggable(Level.FINE)) { + log.log(Level.FINE, "{0} is blocked by {1}", + new Object[] { String.valueOf(this), String.valueOf(blockerPeer)}); + } modalBlocker = d; if (isReparented() || XWM.isNonReparentingWM()) { @@ -1899,7 +1904,9 @@ wm_set_insets = XWM.getInsetsFromProp(getWindow(), changedAtom); } - insLog.log(Level.FINER, "FRAME_EXTENTS: {0}", new Object[]{wm_set_insets}); + if (insLog.isLoggable(Level.FINER)) { + insLog.log(Level.FINER, "FRAME_EXTENTS: {0}", new Object[]{String.valueOf(wm_set_insets)}); + } if (wm_set_insets != null) { handleWMSetInsets(wm_set_insets); @@ -1942,7 +1949,8 @@ XCrossingEvent xce = xev.get_xcrossing(); if (grabLog.isLoggable(Level.FINE)) { grabLog.log(Level.FINE, "{0}, when grabbed {1}, contains {2}", - new Object[] {xce, isGrabbed(), containsGlobal(xce.get_x_root(), xce.get_y_root())}); + new Object[] {String.valueOf(xce), isGrabbed(), + containsGlobal(xce.get_x_root(), xce.get_y_root())}); } if (isGrabbed()) { // When window is grabbed, all events are dispatched to @@ -1953,7 +1961,10 @@ // since it generates MOUSE_ENTERED/MOUSE_EXITED for frame and dialog. // (fix for 6390326) XBaseWindow target = XToolkit.windowToXWindow(xce.get_window()); - grabLog.log(Level.FINER, " - Grab event target {0}", new Object[] {target}); + if (grabLog.isLoggable(Level.FINER)) { + grabLog.log(Level.FINER, " - Grab event target {0}", + new Object[] {String.valueOf(target)}); + } if (target != null && target != this) { target.dispatchEvent(xev); return; @@ -1966,7 +1977,8 @@ XMotionEvent xme = xev.get_xmotion(); if (grabLog.isLoggable(Level.FINE)) { grabLog.log(Level.FINER, "{0}, when grabbed {1}, contains {2}", - new Object[] {xme, isGrabbed(), containsGlobal(xme.get_x_root(), xme.get_y_root())}); + new Object[] {String.valueOf(xme), isGrabbed(), + containsGlobal(xme.get_x_root(), xme.get_y_root())}); } if (isGrabbed()) { boolean dragging = (xme.get_state() & (Button1Mask | Button2Mask | Button3Mask)) != 0; @@ -1986,7 +1998,10 @@ xme.set_x(xme.get_x_root() - target.getX()); xme.set_y(xme.get_y_root() - target.getY()); } - grabLog.log(Level.FINER, " - Grab event target {0}", new Object[] {target}); + if (grabLog.isLoggable(Level.FINER)) { + grabLog.log(Level.FINER, " - Grab event target {0}", + new Object[] {String.valueOf(target)}); + } if (target != null) { if (target != getContentXWindow() && target != this) { target.dispatchEvent(xev); @@ -2011,7 +2026,8 @@ XButtonEvent xbe = xev.get_xbutton(); if (grabLog.isLoggable(Level.FINE)) { grabLog.log(Level.FINE, "{0}, when grabbed {1}, contains {2} ({3}, {4}, {5}x{6})", - new Object[] {xbe, isGrabbed(), containsGlobal(xbe.get_x_root(), xbe.get_y_root()), getAbsoluteX(), getAbsoluteY(), getWidth(), getHeight()}); + new Object[] {String.valueOf(xbe), isGrabbed(), containsGlobal(xbe.get_x_root(), + xbe.get_y_root()), getAbsoluteX(), getAbsoluteY(), getWidth(), getHeight()}); } if (isGrabbed()) { // When window is grabbed, all events are dispatched to @@ -2020,7 +2036,10 @@ // translation) XBaseWindow target = XToolkit.windowToXWindow(xbe.get_window()); try { - grabLog.log(Level.FINER, " - Grab event target {0} (press target {1})", new Object[] {target, pressTarget}); + if (grabLog.isLoggable(Level.FINER)) { + grabLog.log(Level.FINER, " - Grab event target {0} (press target {1})", + new Object[] {String.valueOf(target), String.valueOf(pressTarget)}); + } if (xbe.get_type() == XConstants.ButtonPress && xbe.get_button() == XlibWrapper.Button1) { @@ -2052,7 +2071,10 @@ // Outside this toplevel hierarchy // According to the specification of UngrabEvent, post it // when press occurs outside of the window and not on its owned windows - grabLog.log(Level.FINE, "Generating UngrabEvent on {0} because not inside of shell", this); + if (grabLog.isLoggable(Level.FINE)) { + grabLog.log(Level.FINE, "Generating UngrabEvent on {0} because not inside of shell", + String.valueOf(this)); + } postEventToEventQueue(new sun.awt.UngrabEvent(getEventSource())); return; } @@ -2070,18 +2092,27 @@ // toplevel == null - outside of // hierarchy, toplevel is Dialog - should // send ungrab (but shouldn't for Window) - grabLog.log(Level.FINE, "Generating UngrabEvent on {0} because hierarchy ended", this); + if (grabLog.isLoggable(Level.FINE)) { + grabLog.log(Level.FINE, "Generating UngrabEvent on {0} because hierarchy ended", + String.valueOf(this)); + } postEventToEventQueue(new sun.awt.UngrabEvent(getEventSource())); } } else { // toplevel is null - outside of hierarchy - grabLog.log(Level.FINE, "Generating UngrabEvent on {0} because toplevel is null", this); + if (grabLog.isLoggable(Level.FINE)) { + grabLog.log(Level.FINE, "Generating UngrabEvent on {0} because toplevel is null", + String.valueOf(this)); + } postEventToEventQueue(new sun.awt.UngrabEvent(getEventSource())); return; } } else { // target doesn't map to XAWT window - outside of hierarchy - grabLog.log(Level.FINE, "Generating UngrabEvent on because target is null {0}", this); + if (grabLog.isLoggable(Level.FINE)) { + grabLog.log(Level.FINE, "Generating UngrabEvent on because target is null {0}", + String.valueOf(this)); + } postEventToEventQueue(new sun.awt.UngrabEvent(getEventSource())); return; } --- old/src/solaris/classes/sun/awt/X11InputMethod.java 2009-07-23 13:48:22.000000000 +0400 +++ openjdk/jdk/src/solaris/classes/sun/awt/X11InputMethod.java 2009-07-23 13:48:22.000000000 +0400 @@ -324,8 +324,11 @@ return; if (lastXICFocussedComponent != null){ - if (log.isLoggable(Level.FINE)) log.log(Level.FINE, "XICFocused {0}, AWTFocused {1}", new Object[] { - lastXICFocussedComponent, awtFocussedComponent}); + if (log.isLoggable(Level.FINE)) { + log.log(Level.FINE, "XICFocused {0}, AWTFocused {1}", + new Object[] { String.valueOf(lastXICFocussedComponent), + String.valueOf(awtFocussedComponent)}); + } } if (pData == 0) {