Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8278555

java/awt/dnd/BadSerializationTest/BadSerializationTest.java failed: ClassNotFoundException: com.apple.laf.AquaImageFactory$SystemColorProxy

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Withdrawn
    • Icon: P3 P3
    • 19
    • client-libs
    • None
    • minimal
    • Hide
      This change adds two new static methods. The compatibility risk seems low. Behavioural compatibility could be affected for example of code is using reflection to examine the list of declared methods in LookAndFeel. Source compatibility could be impacted if a file static wildcard imports members of LookAndFeel and also declares methods with names that clash with the new methods.
      Show
      This change adds two new static methods. The compatibility risk seems low. Behavioural compatibility could be affected for example of code is using reflection to examine the list of declared methods in LookAndFeel. Source compatibility could be impacted if a file static wildcard imports members of LookAndFeel and also declares methods with names that clash with the new methods.
    • Java API

      Summary

      This change adds two methods to javax.swing.LookAndFeel, uninstallColors and uninstallColorsAndFont, which correspond to the existing installColors and installColorsAndFont methods.

      Problem

      installColors and installColorsAndFont can be used to install properties that may implement UIResource, and which should be uninstalled at uninstall time. Many of the current callers of the methods fail to uninstall them.

      Solution

      The solution is to add uninstallColors and uninstallColorsAndFont which uninstall any UIResource properties installed by installColors and installColorsAndFont, to make it easy to callers of those methods to correctly handle uninstallation.

      Specification

          diff --git a/src/java.desktop/share/classes/javax/swing/LookAndFeel.java b/src/java.desktop/share/classes/javax/swing/LookAndFeel.java
      index 830fadb1c0c..b2a907da307 100644
      --- a/src/java.desktop/share/classes/javax/swing/LookAndFeel.java
      +++ b/src/java.desktop/share/classes/javax/swing/LookAndFeel.java
      @@ -187,6 +187,25 @@ public abstract class LookAndFeel
           }
      
      
      +    /**
      +     * Convenience method for uninstalling a component's foreground
      +     * and background color properties. If the properties are
      +     * {@code UIResource}s, they are set to {@code null}.
      +     *
      +     * @param c component to uninstall the properties from
      +     * @see #uninstallColorsAndFont
      +     * @throws NullPointerException if {@code c} is {@code null}
      +     */
      +    public static void uninstallColors(JComponent c) {
      +        if (c.getForeground() instanceof UIResource) {
      +            c.setForeground(null);
      +        }
      +        if (c.getBackground() instanceof UIResource) {
      +            c.setBackground(null);
      +        }
      +    }
      +
      +
           /**
            * Convenience method for setting a component's foreground,
            * background and font properties with values from the
      @@ -217,6 +236,22 @@ public abstract class LookAndFeel
           }
      
      
      +    /**
      +     * Convenience method for uninstalling a component's foreground,
      +     * background, and font properties. If the properties are
      +     * {@code UIResource}s, they are set to {@code null}.
      +     *
      +     * @param c component to uninstall the properties from
      +     * @throws NullPointerException if {@code c} is {@code null}
      +     */
      +    public static void uninstallColorsAndFont(JComponent c) {
      +        if (c.getFont() instanceof UIResource) {
      +            c.setFont(null);
      +        }
      +        uninstallColors(c);
      +    }
      +
      +
           /**
            * Convenience method for setting a component's border property with
            * a value from the defaults. The border is only set if the border is

            cushon Liam Miller-Cushon
            dholmes David Holmes
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: