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

Deprecate for removal java.awt.Window.getWarningString()

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 24
    • client-libs
    • None
    • source, binary, behavioral
    • low
    • Hide
      The deprecation in itself does not present any risk.
      There is a small chance that some code is reliant on the exact content of the serialized form.
      Show
      The deprecation in itself does not present any risk. There is a small chance that some code is reliant on the exact content of the serialized form.
    • Java API, System or security property, File or wire format
    • SE

      Summary

      Deprecate for removal java.awt.Window.getWarningString() and javax.swing.JInternalFrame.getWarningString() because disabling of the SecurityManager has made them obsolete. Supporting permissions and Serializable fields are removed immediately

      Problem

      java.awt.Window.getWarningString() was introduced to (1) provide the warning text to be displayed prominently alongside untrusted windows, alongside a warning icon, and (2) if non-null indicate the need to display warnings on a window.

      Untrusted windows are those created by untrusted code, however after permanent disabling of the SecurityManager by JEP 486 [See https://bugs.openjdk.org/browse/JDK-8338411] no SecurityManager can be installed meaning the warning string and warning icons can never be displayed.

      Historically the text of the String would be set as the value of the System Property "awt.appletWarning", but applets are also obsolete, and reference to this System Property was already removed by JEP 486 so the text of the String can not be set.

      java.awt.Window stores the value in a field "private String warningString" which is part of the serialized form of java.awt.Window. That field is obsolete as a consequence of warning strings being obsolete.

      A java.awt.AWTPermission : "showWindowWithoutWarningBanner" could be used to indicate to a SecurityManager that the window should be trusted. This Permission is also obsolete since all SM related checks are no-ops. Public documentation of it was already removed by JEP 486

      javax.swing.JInternalFrame.getWarningString() has never been used to display warning strings, and existed only for symmetry with java.awt.Window.getWarningString() so it is no longer serving any purpose - it should be deprecated alongside java.awt.Window.getWarningString()

      Solution

      The methods java.awt.Window.getWarningString() and javax.swing.JInternalFrame.getWarningString() will be deprecated for removal. And will always return null.

      The serializable field warningString on java.awt.Window is obsolete and removed from the specification

      The use of the System property "awt.appletWarning" was already removed from the specification by JEP 486

      The AWTPermission : "showWindowWithoutWarningBanner" is obsolete and checks based on it are removed. Public documentation was already removed by JEP 486

      Specification

      
      java.awt.Window :
      
            /**
             * Gets the warning string that is displayed with this window.
             * 

      * Warning strings are no longer applicable, - * so this method always returns {@code null}. + * so this method always returns {@code null} and may be + * removed in a future release. * @return null + * @deprecated since JDK 24 */ + @Deprecated(since="24", forRemoval=true) public final String getWarningString() { - return warningString; + return null; } - /** - * This represents the warning message that is - * to be displayed in a non secure window. ie : - * a window that has a security manager installed that denies - * {@code AWTPermission("showWindowWithoutWarningBanner")}. - * This message can be displayed anywhere in the window. - * - * @serial - * @see #getWarningString - */ - String warningString; Remove all code that follows this protocol :- - * If there is a security manager, then it is invoked to check - * {@code AWTPermission("showWindowWithoutWarningBanner")} - * to determine whether or not the window must be displayed with - * a warning banner. javax.swing.JInternalFrame /** * Gets the warning string that is displayed with this internal frame. - * Since an internal frame is always secure (since it's fully - * contained within a window that might need a warning string) - * this method always returns null. + * This method always returns null. + * Warning strings are no longer applicable, even to top-level + * windows, so this method may be removed in a future release * @return null * @see java.awt.Window#getWarningString + * @deprecated since JDK 24 */ + @Deprecated(since="24", forRemoval=true) @BeanProperty(bound = false) public final String getWarningString() { return null; }

            prr Philip Race
            prr Philip Race
            Alexander Zuev
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: