diff --git a/.hgtags b/.hgtags index a204003dd7fddbf8e818c3a28d400b6253600c02..cf44fdc38c7209d7ceb6190e8aab50a69c65a009 100644 --- a/.hgtags +++ b/.hgtags @@ -147,3 +147,4 @@ dda27c73d8db4a9c7a23872b6f0c5106edcb2021 jdk8-b22 54202e0148ec7d4570cab5bc9b00d216a7677569 jdk8-b23 34029a0c69bba882264a29fc822f8283fd15f104 jdk8-b24 ec17fbe5b8fbc52da070eec43b4711d9354b2ab8 jdk8-b25 +5aca406e87cb9144a9405be312dadd728a9c6fe2 jdk8-b26 diff --git a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java index 8fb15f9492d040366f4f6af584984ea8b4e627f0..302b6bc565dd980b043618c80b6e1378ce0b9edd 100644 --- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java +++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java @@ -137,6 +137,11 @@ public class WindowsProgressBarUI extends BasicProgressBarUI g.setColor(progressBar.getForeground()); barRectHeight -= 2; barRectWidth -= 2; + + if (barRectWidth <= 0 || barRectHeight <= 0) { + return; + } + Graphics2D g2 = (Graphics2D)g; g2.setStroke(new BasicStroke((float)(vertical ? barRectWidth : barRectHeight), BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); diff --git a/src/share/classes/java/awt/List.java b/src/share/classes/java/awt/List.java index 917977b157ea13775e4ab704efa5d1b2b6c44026..d5b60ae56c6bb599049ffe543720a0c47ef29f44 100644 --- a/src/share/classes/java/awt/List.java +++ b/src/share/classes/java/awt/List.java @@ -115,7 +115,7 @@ public class List extends Component implements ItemSelectable, Accessible { * @see #addItem(String) * @see #getItem(int) */ - Vector items = new Vector(); + Vector items = new Vector<>(); /** * This field will represent the number of visible rows in the @@ -306,7 +306,7 @@ public class List extends Component implements ItemSelectable, Accessible { // to insure that it cannot be overridden by client subclasses. // DO NOT INVOKE CLIENT CODE ON THIS THREAD! final String getItemImpl(int index) { - return (String)items.elementAt(index); + return items.elementAt(index); } /** @@ -415,7 +415,7 @@ public class List extends Component implements ItemSelectable, Accessible { if (peer != null) { peer.removeAll(); } - items = new Vector(); + items = new Vector<>(); selected = new int[0]; } @@ -490,9 +490,9 @@ public class List extends Component implements ItemSelectable, Accessible { public synchronized int[] getSelectedIndexes() { ListPeer peer = (ListPeer)this.peer; if (peer != null) { - selected = ((ListPeer)peer).getSelectedIndexes(); + selected = peer.getSelectedIndexes(); } - return (int[])selected.clone(); + return selected.clone(); } /** @@ -908,7 +908,7 @@ public class List extends Component implements ItemSelectable, Accessible { * @since 1.4 */ public synchronized ItemListener[] getItemListeners() { - return (ItemListener[])(getListeners(ItemListener.class)); + return getListeners(ItemListener.class); } /** @@ -975,7 +975,7 @@ public class List extends Component implements ItemSelectable, Accessible { * @since 1.4 */ public synchronized ActionListener[] getActionListeners() { - return (ActionListener[])(getListeners(ActionListener.class)); + return getListeners(ActionListener.class); } /** diff --git a/src/share/classes/java/awt/Window.java b/src/share/classes/java/awt/Window.java index d2c97dbf8ab47d7feced5590fceb80ae0a495dfe..646d9ded822188950cf1d04f196782fa2b0f2966 100644 --- a/src/share/classes/java/awt/Window.java +++ b/src/share/classes/java/awt/Window.java @@ -398,10 +398,10 @@ public class Window extends Container implements Accessible { initIDs(); } - String s = (String) java.security.AccessController.doPrivileged( + String s = java.security.AccessController.doPrivileged( new GetPropertyAction("java.awt.syncLWRequests")); systemSyncLWRequests = (s != null && s.equals("true")); - s = (String) java.security.AccessController.doPrivileged( + s = java.security.AccessController.doPrivileged( new GetPropertyAction("java.awt.Window.locationByPlatform")); locationByPlatformProp = (s != null && s.equals("true")); } @@ -1378,7 +1378,7 @@ public class Window extends Container implements Accessible { // make sure the privileged action is only // for getting the property! We don't want the // above checkTopLevelWindow call to always succeed! - warningString = (String) AccessController.doPrivileged( + warningString = AccessController.doPrivileged( new GetPropertyAction("awt.appletWarning", "Java Applet Window")); } diff --git a/src/share/classes/java/awt/color/ICC_Profile.java b/src/share/classes/java/awt/color/ICC_Profile.java index 81212fbfeaf141dff32acb1c6f88a3a8c6cda374..c06ddf61c9772229b52f7df103c06f601f7942a4 100644 --- a/src/share/classes/java/awt/color/ICC_Profile.java +++ b/src/share/classes/java/awt/color/ICC_Profile.java @@ -921,9 +921,9 @@ public class ICC_Profile implements Serializable { */ private static ICC_Profile getStandardProfile(final String name) { - return (ICC_Profile) AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { + return AccessController.doPrivileged( + new PrivilegedAction() { + public ICC_Profile run() { ICC_Profile p = null; try { p = getInstance (name); diff --git a/src/share/classes/java/awt/event/InputEvent.java b/src/share/classes/java/awt/event/InputEvent.java index c98c872ed8be859373bc766499961661bb8664c9..f645c3a10a67512a41315d5efc36c92300ddfe19 100644 --- a/src/share/classes/java/awt/event/InputEvent.java +++ b/src/share/classes/java/awt/event/InputEvent.java @@ -321,14 +321,15 @@ public abstract class InputEvent extends ComponentEvent { * @param when a long int that gives the time the event occurred. * Passing negative or zero value * is not recommended - * @param modifiers the modifier keys down during event (e.g. shift, ctrl, - * alt, meta) - * Passing negative parameter is not recommended. - * Zero value means no modifiers. - * Either extended _DOWN_MASK or old _MASK modifiers - * should be used, but both models should not be mixed - * in one event. Use of the extended modifiers is - * preferred + * @param modifiers a modifier mask describing the modifier keys and mouse + * buttons (for example, shift, ctrl, alt, and meta) that + * are down during the event. + * Only extended modifiers are allowed to be used as a + * value for this parameter (see the {@link InputEvent#getModifiersEx} + * class for the description of extended modifiers). + * Passing negative parameter + * is not recommended. + * Zero value means that no modifiers were passed * @throws IllegalArgumentException if source is null * @see #getSource() * @see #getID() @@ -416,9 +417,13 @@ public abstract class InputEvent extends ComponentEvent { /** * Returns the extended modifier mask for this event. + *

+ * Extended modifiers are the modifiers that ends with the _DOWN_MASK suffix, + * such as ALT_DOWN_MASK, BUTTON1_DOWN_MASK, and others. + *

* Extended modifiers represent the state of all modal keys, * such as ALT, CTRL, META, and the mouse buttons just after - * the event occurred + * the event occurred. *

* For example, if the user presses button 1 followed by * button 2, and then releases them in the same order, diff --git a/src/share/classes/java/awt/event/MouseEvent.java b/src/share/classes/java/awt/event/MouseEvent.java index 988eda60a8bb8e70858287cc8651e48f42a26b7a..15cb6ee0309ef11dd2803697a42f2898e698019e 100644 --- a/src/share/classes/java/awt/event/MouseEvent.java +++ b/src/share/classes/java/awt/event/MouseEvent.java @@ -488,14 +488,15 @@ public class MouseEvent extends InputEvent { * @param when A long integer that gives the time the event occurred. * Passing negative or zero value * is not recommended - * @param modifiers The modifier keys down during event (e.g. shift, ctrl, - * alt, meta) + * @param modifiers a modifier mask describing the modifier keys and mouse + * buttons (for example, shift, ctrl, alt, and meta) that + * are down during the event. + * Only extended modifiers are allowed to be used as a + * value for this parameter (see the {@link InputEvent#getModifiersEx} + * class for the description of extended modifiers). * Passing negative parameter * is not recommended. - * Zero value means that no modifiers were passed. - * Use either an extended _DOWN_MASK or old _MASK modifiers, - * however do not mix models in the one event. - * The extended modifiers are preferred for using + * Zero value means that no modifiers were passed * @param x The horizontal x coordinate for the mouse location. * It is allowed to pass negative values * @param y The vertical y coordinate for the mouse location. @@ -586,14 +587,15 @@ public class MouseEvent extends InputEvent { * @param when A long integer that gives the time the event occurred. * Passing negative or zero value * is not recommended - * @param modifiers The modifier keys down during event (e.g. shift, ctrl, - * alt, meta) + * @param modifiers a modifier mask describing the modifier keys and mouse + * buttons (for example, shift, ctrl, alt, and meta) that + * are down during the event. + * Only extended modifiers are allowed to be used as a + * value for this parameter (see the {@link InputEvent#getModifiersEx} + * class for the description of extended modifiers). * Passing negative parameter * is not recommended. - * Zero value means that no modifiers were passed. - * Use either an extended _DOWN_MASK or old _MASK modifiers, - * however do not mix models in the one event. - * The extended modifiers are preferred for using + * Zero value means that no modifiers were passed * @param x The horizontal x coordinate for the mouse location. * It is allowed to pass negative values * @param y The vertical y coordinate for the mouse location. @@ -657,14 +659,15 @@ public class MouseEvent extends InputEvent { * @param when A long integer that gives the time the event occurred. * Passing negative or zero value * is not recommended - * @param modifiers The modifier keys down during event (e.g. shift, ctrl, - * alt, meta) + * @param modifiers a modifier mask describing the modifier keys and mouse + * buttons (for example, shift, ctrl, alt, and meta) that + * are down during the event. + * Only extended modifiers are allowed to be used as a + * value for this parameter (see the {@link InputEvent#getModifiersEx} + * class for the description of extended modifiers). * Passing negative parameter * is not recommended. - * Zero value means that no modifiers were passed. - * Use either an extended _DOWN_MASK or old _MASK modifiers, - * however do not mix models in the one event. - * The extended modifiers are preferred for using + * Zero value means that no modifiers were passed * @param x The horizontal x coordinate for the mouse location. * It is allowed to pass negative values * @param y The vertical y coordinate for the mouse location. diff --git a/src/share/classes/javax/print/attribute/standard/PrinterStateReasons.java b/src/share/classes/javax/print/attribute/standard/PrinterStateReasons.java index f49210d081d9080040ecf5a171c348e7dff4ca84..339be3621d95d00fc75fa24a5a33214b9f0a0d78 100644 --- a/src/share/classes/javax/print/attribute/standard/PrinterStateReasons.java +++ b/src/share/classes/javax/print/attribute/standard/PrinterStateReasons.java @@ -180,8 +180,7 @@ public final class PrinterStateReasons if (severity == null) { throw new NullPointerException("severity is null"); } - return super.put((PrinterStateReason) reason, - (Severity) severity); + return super.put(reason, severity); } /** diff --git a/src/share/classes/javax/print/attribute/standard/ReferenceUriSchemesSupported.java b/src/share/classes/javax/print/attribute/standard/ReferenceUriSchemesSupported.java index 70d09510de259a9e2c96152f39370740dddc477b..b52b2abbca0c54076365f31999c8251e267dbaaf 100644 --- a/src/share/classes/javax/print/attribute/standard/ReferenceUriSchemesSupported.java +++ b/src/share/classes/javax/print/attribute/standard/ReferenceUriSchemesSupported.java @@ -141,7 +141,7 @@ public class ReferenceUriSchemesSupported * Returns the string table for class ReferenceUriSchemesSupported. */ protected String[] getStringTable() { - return (String[])myStringTable.clone(); + return myStringTable.clone(); } /** diff --git a/src/share/classes/javax/swing/JOptionPane.java b/src/share/classes/javax/swing/JOptionPane.java index 9849c37b1ee0d6bcb6a996703e223dc68bb6cf62..c532cf619c001a2d59a87901cda9bd8320d6a39b 100644 --- a/src/share/classes/javax/swing/JOptionPane.java +++ b/src/share/classes/javax/swing/JOptionPane.java @@ -34,7 +34,6 @@ import java.awt.KeyboardFocusManager; import java.awt.Frame; import java.awt.Point; import java.awt.HeadlessException; -import java.awt.Toolkit; import java.awt.Window; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; @@ -994,8 +993,7 @@ public class JOptionPane extends JComponent implements Accessible // if the user closed the window without selecting a button // (newValue = null in that case). Otherwise, close the dialog. if (dialog.isVisible() && event.getSource() == JOptionPane.this && - (event.getPropertyName().equals(VALUE_PROPERTY) || - event.getPropertyName().equals(INPUT_VALUE_PROPERTY)) && + (event.getPropertyName().equals(VALUE_PROPERTY)) && event.getNewValue() != null && event.getNewValue() != JOptionPane.UNINITIALIZED_VALUE) { dialog.setVisible(false); diff --git a/src/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java b/src/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java index 6a0b024ceebdd40aa80fe31e6eb11ae4bce80e37..444b903dd33d640eda2cc23f3f88bf0fcab12f2e 100644 --- a/src/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java +++ b/src/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java @@ -1236,6 +1236,7 @@ public class BasicOptionPaneUI extends OptionPaneUI { int index = list.locationToIndex(e.getPoint()); optionPane.setInputValue(list.getModel().getElementAt(index)); + optionPane.setValue(JOptionPane.OK_OPTION); } } diff --git a/src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java b/src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java index e7a684e66a7abfb9277ff78b9c9e5e1e9c8f5c4f..f1a9b15f862e59f150dc2a41a9a07520d4e336d5 100644 --- a/src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java +++ b/src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java @@ -434,6 +434,8 @@ public class SynthTreeUI extends BasicTreeUI // Empty out the renderer pane, allowing renderers to be gc'ed. rendererPane.removeAll(); + + paintContext = null; } private void configureRenderer(SynthContext context) { diff --git a/src/share/classes/javax/swing/tree/DefaultTreeCellRenderer.java b/src/share/classes/javax/swing/tree/DefaultTreeCellRenderer.java index ed4e00dfc7df205233a4aee375ba0fcdcef552f3..d8b261c3f28c97a62a4fdcf944f89efde450a77d 100644 --- a/src/share/classes/javax/swing/tree/DefaultTreeCellRenderer.java +++ b/src/share/classes/javax/swing/tree/DefaultTreeCellRenderer.java @@ -156,7 +156,7 @@ public class DefaultTreeCellRenderer extends JLabel implements TreeCellRenderer protected Color borderSelectionColor; private boolean isDropCell; - private boolean fillBackground = true; + private boolean fillBackground; /** * Set to true after the constructor has run. diff --git a/src/share/classes/sun/awt/image/OffScreenImageSource.java b/src/share/classes/sun/awt/image/OffScreenImageSource.java index 2b85b6b6d8439ffb201de88aa5618f11833331b5..c1b0453a65be4f98b94f98c465fd27ab19be8a65 100644 --- a/src/share/classes/sun/awt/image/OffScreenImageSource.java +++ b/src/share/classes/sun/awt/image/OffScreenImageSource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -185,6 +185,7 @@ public class OffScreenImageSource implements ImageProducer { theConsumer.setDimensions(image.getWidth(), image.getHeight()); theConsumer.setProperties(properties); sendPixels(); + theConsumer.imageComplete(ImageConsumer.SINGLEFRAMEDONE); theConsumer.imageComplete(ImageConsumer.STATICIMAGEDONE); } catch (NullPointerException e) { if (theConsumer != null) { diff --git a/src/share/classes/sun/beans/infos/ComponentBeanInfo.java b/src/share/classes/sun/beans/infos/ComponentBeanInfo.java index e16511f98544a9e7e18db11019beecbf0d88f1b5..ae6631f1f3149670292c099da4e96413b248ed4e 100644 --- a/src/share/classes/sun/beans/infos/ComponentBeanInfo.java +++ b/src/share/classes/sun/beans/infos/ComponentBeanInfo.java @@ -32,7 +32,7 @@ import java.beans.*; */ public class ComponentBeanInfo extends SimpleBeanInfo { - private static final Class beanClass = java.awt.Component.class; + private static final Class beanClass = java.awt.Component.class; public PropertyDescriptor[] getPropertyDescriptors() { try { diff --git a/src/share/classes/sun/font/FileFont.java b/src/share/classes/sun/font/FileFont.java index adce6d94e5d176806ad12465376b45bf0bfb0980..9c72251dffc81644c23f386bb4441f6bf1364f2d 100644 --- a/src/share/classes/sun/font/FileFont.java +++ b/src/share/classes/sun/font/FileFont.java @@ -163,7 +163,9 @@ public abstract class FileFont extends PhysicalFont { } } } - scaler.dispose(); + if (scaler != null) { + scaler.dispose(); + } scaler = FontScaler.getNullScaler(); } diff --git a/src/share/classes/sun/font/StandardGlyphVector.java b/src/share/classes/sun/font/StandardGlyphVector.java index c452dd97c1d9a0b7402f0b0962dd8ee01f9068aa..66001682dffce7ac3abd2a6d2a99140fe1a57085 100644 --- a/src/share/classes/sun/font/StandardGlyphVector.java +++ b/src/share/classes/sun/font/StandardGlyphVector.java @@ -1740,8 +1740,9 @@ public class StandardGlyphVector extends GlyphVector { tx, sgv.font.getStyle(), aa, fm); - - FontStrike strike = sgv.font2D.getStrike(desc); // !!! getStrike(desc, false) + // Get the strike via the handle. Shouldn't matter + // if we've invalidated the font but its an extra precaution. + FontStrike strike = sgv.font2D.handle.font2D.getStrike(desc); // !!! getStrike(desc, false) return new GlyphStrike(sgv, strike, dx, dy); } diff --git a/src/share/classes/sun/font/SunFontManager.java b/src/share/classes/sun/font/SunFontManager.java index bd55f8bbd9c29a45e1771b3d803e246b8352cd88..bb069a3a06ca672e510ab7aa4f1e964035dd9bac 100644 --- a/src/share/classes/sun/font/SunFontManager.java +++ b/src/share/classes/sun/font/SunFontManager.java @@ -2619,6 +2619,9 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE { physicalFonts.remove(oldFont.fullName); fullNameToFont.remove(oldFont.fullName.toLowerCase(Locale.ENGLISH)); FontFamily.remove(oldFont); + if (oldFont instanceof FileFont) { + ((FileFont)oldFont).deregisterFontAndClearStrikeCache(); + } if (localeFullNamesToFont != null) { Map.Entry[] mapEntries = diff --git a/src/share/classes/sun/font/TrueTypeFont.java b/src/share/classes/sun/font/TrueTypeFont.java index e60a74b7b055edb8498a7cc2a490c7ef78a260e7..5a3180e154662663b08aa03d731a7e13040ac964 100644 --- a/src/share/classes/sun/font/TrueTypeFont.java +++ b/src/share/classes/sun/font/TrueTypeFont.java @@ -1037,6 +1037,9 @@ public class TrueTypeFont extends FileFont { if (head_Table != null && head_Table.capacity() >= 18) { ShortBuffer sb = head_Table.asShortBuffer(); upem = sb.get(9) & 0xffff; + if (upem < 16 || upem > 16384) { + upem = 2048; + } } ByteBuffer os2_Table = getTableBuffer(os_2Tag); diff --git a/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c b/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c index 403a16e0311fcfaf4a0954cc6f65c34f2e263620..66dca0d60dbdc186f13901ed6d8433996fc337f2 100644 --- a/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c +++ b/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c @@ -171,6 +171,53 @@ static jobjectArray toFilenamesArray(JNIEnv *env, GSList* list) return array; } +/** + * Convert a GSList to an array of filenames (with the parent folder) + */ +static jobjectArray toPathAndFilenamesArray(JNIEnv *env, GSList* list) +{ + jstring str; + jclass stringCls; + GSList *iterator; + jobjectArray array; + int i; + char* entry; + + + if (list == NULL) { + return NULL; + } + + stringCls = (*env)->FindClass(env, "java/lang/String"); + if (stringCls == NULL) { + JNU_ThrowInternalError(env, "Could not get java.lang.String class"); + return NULL; + } + + array = (*env)->NewObjectArray(env, fp_gtk_g_slist_length(list), stringCls, + NULL); + if (array == NULL) { + JNU_ThrowInternalError(env, "Could not instantiate array files array"); + return NULL; + } + + i = 0; + for (iterator = list; iterator; iterator = iterator->next) { + entry = (char*) iterator->data; + + //check for leading slash. + if (entry[0] == '/') { + entry++; + } + + str = (*env)->NewStringUTF(env, entry); + (*env)->SetObjectArrayElement(env, array, i, str); + i++; + } + + return array; +} + static void handle_response(GtkWidget* aDialog, gint responseId, gpointer obj) { JNIEnv *env; @@ -183,16 +230,25 @@ static void handle_response(GtkWidget* aDialog, gint responseId, gpointer obj) env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2); current_folder = NULL; filenames = NULL; + gboolean full_path_names = FALSE; if (responseId == GTK_RESPONSE_ACCEPT) { current_folder = fp_gtk_file_chooser_get_current_folder( GTK_FILE_CHOOSER(aDialog)); + if (current_folder == NULL) { + full_path_names = TRUE; + } filenames = fp_gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(aDialog)); } - - jcurrent_folder = (*env)->NewStringUTF(env, current_folder); - jfilenames = toFilenamesArray(env, filenames); - + if (full_path_names) { + //This is a hack for use with "Recent Folders" in gtk where each + //file could have its own directory. + jcurrent_folder = (*env)->NewStringUTF(env, "/"); + jfilenames = toPathAndFilenamesArray(env, filenames); + } else { + jcurrent_folder = (*env)->NewStringUTF(env, current_folder); + jfilenames = toFilenamesArray(env, filenames); + } (*env)->CallVoidMethod(env, obj, setFileInternalMethodID, jcurrent_folder, jfilenames); fp_g_free(current_folder); diff --git a/test/java/awt/Choice/ChoiceMouseWheelTest/ChoiceMouseWheelTest.java b/test/java/awt/Choice/ChoiceMouseWheelTest/ChoiceMouseWheelTest.java index 2c147102bcc3e2061fbb34951527e493c08c3026..e545b08fea0469b6b24ae99d18d75a7c4767bdab 100644 --- a/test/java/awt/Choice/ChoiceMouseWheelTest/ChoiceMouseWheelTest.java +++ b/test/java/awt/Choice/ChoiceMouseWheelTest/ChoiceMouseWheelTest.java @@ -96,7 +96,10 @@ public class ChoiceMouseWheelTest extends Frame { // Test mouse wheel over the choice String name = Toolkit.getDefaultToolkit().getClass().getName(); - if(!name.equals("sun.awt.X11.XToolkit")) { // mouse wheel doesn't work for the choice on X11, so skip it + + // mouse wheel doesn't work for the choice on X11 and Mac, so skip it + if(!name.equals("sun.awt.X11.XToolkit") + && !name.equals("sun.lwawt.macosx.LWCToolkit")) { robot.mouseWheel(1); Util.waitForIdle(robot); diff --git a/test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java b/test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java index 294f455567b86deaa028a46e6e34c74d4db19287..595cfc99cb34ec1e2e89745187e1a677402355a6 100644 --- a/test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java +++ b/test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java @@ -54,9 +54,12 @@ public class PaintSetEnabledDeadlock extends Frame { Util.clickOnComp(frame.button, robot); } - frame.panel.stop(); + boolean ret = frame.panel.stop(); frame.dispose(); + if (!ret) { + throw new RuntimeException("Test failed!"); + } System.out.println("Test passed."); } @@ -140,17 +143,19 @@ class TestPanel extends Panel implements Runnable { } } - public void stop() { + public boolean stop() { active = false; try { - synchronized (sync) { - sync.notify(); - } - synchronized (thread) { - thread.wait(); + sync(); + thread.join(1000); + if (thread.isAlive()) { + thread.interrupt(); + return false; } } catch (InterruptedException ex) { + return false; } + return true; } public void draw() { diff --git a/test/javax/swing/JFileChooser/6396844/TwentyThousandTest.java b/test/javax/swing/JFileChooser/6396844/TwentyThousandTest.java index 2e244a380d66a411004edee795b0eb8ac50d95b3..a4df9535d97a57722266730d512063927c20f23b 100644 --- a/test/javax/swing/JFileChooser/6396844/TwentyThousandTest.java +++ b/test/javax/swing/JFileChooser/6396844/TwentyThousandTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,29 +26,30 @@ * @bug 6396844 * @summary Tests memory leak for 20000 files * @author Sergey Malenkov - * @run main/othervm/timeout=1000 -mx256m TwentyThousandTest + * @library ../../regtesthelpers + * @build Util + * @run main/othervm/timeout=1000 -mx128m TwentyThousandTest */ +import sun.java2d.Disposer; +import sun.java2d.DisposerRecord; + import javax.swing.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; +import java.awt.event.HierarchyEvent; +import java.awt.event.HierarchyListener; import java.io.File; import java.io.FileWriter; -public class TwentyThousandTest implements ActionListener, Runnable { +public class TwentyThousandTest { private static final int FILES = 20000; - private static final int ATTEMPTS = 100; + private static final int ATTEMPTS = 20; private static final int INTERVAL = 100; - private static final boolean ALWAYS_NEW_INSTANCE = false; - private static final boolean UPDATE_UI_EACH_INTERVAL = true; - private static final boolean AUTO_CLOSE_DIALOG = true; - - private static JFileChooser CHOOSER; - private static String tmpDir; + private static volatile boolean disposerComplete; + public static void main(String[] args) throws Exception { tmpDir = System.getProperty("java.io.tmpdir"); @@ -77,15 +78,13 @@ public class TwentyThousandTest implements ActionListener, Runnable { System.out.println("Do " + ATTEMPTS + " attempts for " + laf.getClassName()); - for ( int i = 0; i < ATTEMPTS; i++ ) { + for (int i = 0; i < ATTEMPTS; i++) { System.out.print(i + " "); doAttempt(); } System.out.println(); - - CHOOSER = null; } System.out.println("Removing " + FILES + " files"); @@ -94,7 +93,7 @@ public class TwentyThousandTest implements ActionListener, Runnable { getTempFile(i).delete(); } - System.out.println( "Test passed successfully" ); + System.out.println("Test passed successfully"); } private static File getTempFile(int i) { @@ -104,48 +103,55 @@ public class TwentyThousandTest implements ActionListener, Runnable { private static void doAttempt() throws Exception { SwingUtilities.invokeAndWait(new Runnable() { public void run() { - if ( ALWAYS_NEW_INSTANCE || ( CHOOSER == null ) ) - CHOOSER = new JFileChooser(tmpDir); - - if ( UPDATE_UI_EACH_INTERVAL ) - CHOOSER.updateUI(); - - if ( AUTO_CLOSE_DIALOG ) { - Thread t = new Thread( new TwentyThousandTest( CHOOSER ) ); - t.start(); - CHOOSER.showOpenDialog( null ); - } else { - CHOOSER.showOpenDialog( null ); - } + final JFileChooser chooser = new JFileChooser(tmpDir); + + chooser.updateUI(); + + // Postpone JFileChooser closing until it becomes visible + chooser.addHierarchyListener(new HierarchyListener() { + @Override + public void hierarchyChanged(HierarchyEvent e) { + if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) { + if (chooser.isShowing()) { + Thread thread = new Thread(new Runnable() { + public void run() { + try { + Thread.sleep(INTERVAL); + + // Close JFileChooser + SwingUtilities.invokeLater(new Runnable() { + public void run() { + chooser.cancelSelection(); + } + }); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + }); + + thread.start(); + } + } + } + }); + + chooser.showOpenDialog(null); } }); - // Allow to collect garbage by GC - Thread.sleep(1000); - - System.gc(); - } + DisposerRecord disposerRecord = new DisposerRecord() { + public void dispose() { + disposerComplete = true; + } + }; - private final JFileChooser chooser; + disposerComplete = false; - TwentyThousandTest( JFileChooser chooser ) { - this.chooser = chooser; - } + Disposer.addRecord(new Object(), disposerRecord); - public void run() { - while ( !this.chooser.isShowing() ) { - try { - Thread.sleep( 30 ); - } catch ( InterruptedException exception ) { - exception.printStackTrace(); - } + while (!disposerComplete) { + Util.generateOOME(); } - Timer timer = new Timer( INTERVAL, this ); - timer.setRepeats( false ); - timer.start(); - } - - public void actionPerformed( ActionEvent event ) { - this.chooser.cancelSelection(); } } diff --git a/test/javax/swing/JOptionPane/7138665/bug7138665.java b/test/javax/swing/JOptionPane/7138665/bug7138665.java new file mode 100644 index 0000000000000000000000000000000000000000..44d4084536b9af85a4eeecfd5ed1cec4e5d82775 --- /dev/null +++ b/test/javax/swing/JOptionPane/7138665/bug7138665.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + @bug 7138665 + @summary JOptionPane.getValue() unexpected change between JRE 1.6 and JRE 1.7 + @author Pavel Porvatov +*/ + +import sun.awt.SunToolkit; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.KeyEvent; + +public class bug7138665 { + public static void main(String[] args) throws Exception { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + JOptionPane pane = new JOptionPane("Enter value", JOptionPane.QUESTION_MESSAGE, + JOptionPane.OK_CANCEL_OPTION, null, null, null); + pane.setWantsInput(true); + + JDialog dialog = pane.createDialog(null, "My Dialog"); + dialog.setVisible(true); + + Object result = pane.getValue(); + + if (result == null || ((Integer) result).intValue() != JOptionPane.OK_OPTION) { + throw new RuntimeException("Invalid result: " + result); + } + + System.out.println("Test bug7138665 passed"); + } + }); + + SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + + toolkit.realSync(); + + Robot robot = new Robot(); + + robot.setAutoDelay(100); + robot.keyPress(KeyEvent.VK_ENTER); + robot.keyRelease(KeyEvent.VK_ENTER); + + toolkit.realSync(); + } +} diff --git a/test/javax/swing/JProgressBar/7141573/bug7141573.java b/test/javax/swing/JProgressBar/7141573/bug7141573.java new file mode 100644 index 0000000000000000000000000000000000000000..d26161ee1887304bfc55dfdaa927f6aa7e44c70a --- /dev/null +++ b/test/javax/swing/JProgressBar/7141573/bug7141573.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + @bug 7141573 + @summary JProgressBar resize exception, if setStringPainted in Windows LAF + @author Pavel Porvatov +*/ + +import javax.swing.*; +import java.awt.image.BufferedImage; + +public class bug7141573 { + public static void main(String[] args) throws Exception { + try { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); + } catch (Exception e) { + System.out.println("WindowsLookAndFeel is not supported. The test bug7141573 is skipped."); + + return; + } + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + BufferedImage image = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB); + + JProgressBar bar = new JProgressBar(); + + bar.setStringPainted(true); + + bar.setSize(100, 1); + bar.paint(image.getGraphics()); + + bar.setSize(1, 100); + bar.paint(image.getGraphics()); + + System.out.println("The test bug7141573 is passed."); + } + }); + } +} diff --git a/test/javax/swing/JTree/4314199/bug4314199.html b/test/javax/swing/JTree/4314199/bug4314199.html new file mode 100644 index 0000000000000000000000000000000000000000..b1fb60e48962209cc79743ac8eb71cb3cd872639 --- /dev/null +++ b/test/javax/swing/JTree/4314199/bug4314199.html @@ -0,0 +1,8 @@ + + +Select the last tree node (marked "Here") and click on the menu. +Look at the vertical line connecting nodes "Bug" and "Here". If +this line disappears when the menu drops down, test fails. + + + diff --git a/test/javax/swing/JTree/4314199/bug4314199.java b/test/javax/swing/JTree/4314199/bug4314199.java new file mode 100644 index 0000000000000000000000000000000000000000..ecf0dabb3429a01d513a0b810b9df34106944ff1 --- /dev/null +++ b/test/javax/swing/JTree/4314199/bug4314199.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +/* + * @test + * @bug 4314199 + * @summary Tests that JTree repaints correctly in a container with a JMenu + * @author Peter Zhelezniakov + * @run applet/manual=yesno bug4314199.html + */ + +import javax.swing.*; +import javax.swing.tree.*; + +public class bug4314199 extends JApplet { + + public void init() { + + try { + UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); + SwingUtilities.invokeAndWait(new Runnable() { + + public void run() { + createAndShowGUI(); + } + }); + } catch (final Exception e) { + SwingUtilities.invokeLater(new Runnable() { + + public void run() { + createAndShowMessage("Test fails because of exception: " + + e.getMessage()); + } + }); + } + + } + + private void createAndShowMessage(String message) { + getContentPane().add(new JLabel(message)); + } + + private void createAndShowGUI() { + JMenuBar mb = new JMenuBar(); + + // needed to exactly align left edge of menu and angled line of tree + mb.add(Box.createHorizontalStrut(27)); + + JMenu mn = new JMenu("Menu"); + JMenuItem mi = new JMenuItem("MenuItem"); + mn.add(mi); + mb.add(mn); + setJMenuBar(mb); + + DefaultMutableTreeNode n1 = new DefaultMutableTreeNode("Root"); + DefaultMutableTreeNode n2 = new DefaultMutableTreeNode("Duke"); + n1.add(n2); + DefaultMutableTreeNode n3 = new DefaultMutableTreeNode("Bug"); + n2.add(n3); + n3.add(new DefaultMutableTreeNode("Blah")); + n3.add(new DefaultMutableTreeNode("Blah")); + n3.add(new DefaultMutableTreeNode("Blah")); + DefaultMutableTreeNode n4 = new DefaultMutableTreeNode("Here"); + n2.add(n4); + + JTree tree = new JTree(new DefaultTreeModel(n1)); + tree.putClientProperty("JTree.lineStyle", "Angled"); + tree.expandPath(new TreePath(new Object[]{n1, n2, n3})); + setContentPane(tree); + } +} diff --git a/test/javax/swing/tree/DefaultTreeCellRenderer/7142955/bug7142955.java b/test/javax/swing/tree/DefaultTreeCellRenderer/7142955/bug7142955.java new file mode 100644 index 0000000000000000000000000000000000000000..40eadaa99b8659e26d2e47ea5a8c6b774b5a7993 --- /dev/null +++ b/test/javax/swing/tree/DefaultTreeCellRenderer/7142955/bug7142955.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + @bug 7142955 + @summary DefaultTreeCellRenderer doesn't honor 'Tree.rendererFillBackground' LAF property + @author Pavel Porvatov +*/ + +import javax.swing.*; +import javax.swing.tree.DefaultTreeCellRenderer; +import java.awt.*; +import java.awt.image.BufferedImage; + +public class bug7142955 { + private static final Color TEST_COLOR = Color.RED; + + public static void main(String[] args) throws Exception { + UIManager.put("Tree.rendererFillBackground", Boolean.FALSE); + UIManager.put("Tree.textBackground", TEST_COLOR); + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + int w = 200; + int h = 100; + + BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); + + Graphics g = image.getGraphics(); + + g.setColor(Color.WHITE); + g.fillRect(0, 0, image.getWidth(), image.getHeight()); + + DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer(); + + renderer.setSize(w, h); + renderer.paint(g); + + for (int y = 0; y < h; y++) { + for (int x = 0; x < w; x++) { + if (image.getRGB(x, y) == TEST_COLOR.getRGB()) { + throw new RuntimeException("Test bug7142955 failed"); + } + } + } + + System.out.println("Test bug7142955 passed."); + } + }); + } +}