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

java.awt.desktop.*Event classes could not be instantiated if Desktop feature is not supported

    XMLWordPrintable

Details

    • CSR
    • Resolution: Approved
    • P2
    • 11
    • client-libs
    • None
    • behavioral
    • minimal
    • Java API
    • SE

    Description

      Summary

      The specification of some classes in "java.awt.desktop" package should specify possible exceptions.

      Problem

      Some unspecified exceptions are thrown in "java.awt.desktop"

      Solution

      Update the spec according the implementation.

      Specification

      src/java.desktop/share/classes/java/awt/desktop/AboutEvent.java
           /**
      +     * @throws HeadlessException if {@link GraphicsEnvironment#isHeadless()}
      +     *         returns {@code true}
      +     * @throws UnsupportedOperationException if Desktop API is not supported on
      +     *         the current platform
      +     * @see Desktop#isDesktopSupported()
      +     * @see java.awt.GraphicsEnvironment#isHeadless
            */
           public AboutEvent() {
      
      src/java.desktop/share/classes/java/awt/desktop/AppForegroundEvent.java
           /**
      +     * @throws HeadlessException if {@link GraphicsEnvironment#isHeadless()}
      +     *         returns {@code true}
      +     * @throws UnsupportedOperationException if Desktop API is not supported on
      +     *         the current platform
      +     * @see Desktop#isDesktopSupported()
      +     * @see java.awt.GraphicsEnvironment#isHeadless
            */
           public AppForegroundEvent() {
      
      src/java.desktop/share/classes/java/awt/desktop/AppHiddenEvent.java
           /**
      +     * @throws HeadlessException if {@link GraphicsEnvironment#isHeadless()}
      +     *         returns {@code true}
      +     * @throws UnsupportedOperationException if Desktop API is not supported on
      +     *         the current platform
      +     * @see Desktop#isDesktopSupported()
      +     * @see java.awt.GraphicsEnvironment#isHeadless
            */
           public AppHiddenEvent() {
      
      src/java.desktop/share/classes/java/awt/desktop/AppReopenedEvent.java
           /**
      +     * @throws HeadlessException if {@link GraphicsEnvironment#isHeadless()}
      +     *         returns {@code true}
      +     * @throws UnsupportedOperationException if Desktop API is not supported on
      +     *         the current platform
      +     * @see Desktop#isDesktopSupported()
      +     * @see java.awt.GraphicsEnvironment#isHeadless
            */
           public AppReopenedEvent() {
      
      src/java.desktop/share/classes/java/awt/desktop/OpenFilesEvent.java
           /**
      -     * Constructs an {@code OpenFilesEvent}
      -     * @param files files
      -     * @param searchTerm searchTerm
      +     * Constructs an {@code OpenFilesEvent}.
      +     *
      +     * @param  files the list of files
      +     * @param  searchTerm the search term
      +     * @throws HeadlessException if {@link GraphicsEnvironment#isHeadless()}
      +     *         returns {@code true}
      +     * @throws UnsupportedOperationException if Desktop API is not supported on
      +     *         the current platform
      +     * @see Desktop#isDesktopSupported()
      +     * @see java.awt.GraphicsEnvironment#isHeadless
            */
          public OpenFilesEvent(final List<File> files, final String searchTerm) {
      
      src/java.desktop/share/classes/java/awt/desktop/OpenURIEvent.java
           /**
      -     * Constructs an {@code OpenURIEvent}
      -     * @param uri {@code URI}
      +     * Constructs an {@code OpenURIEvent}.
      +     *
      +     * @param  uri the {@code URI} the app was asked to open
      +     * @throws HeadlessException if {@link GraphicsEnvironment#isHeadless()}
      +     *         returns {@code true}
      +     * @throws UnsupportedOperationException if Desktop API is not supported on
      +     *         the current platform
      +     * @see Desktop#isDesktopSupported()
      +     * @see java.awt.GraphicsEnvironment#isHeadless
            */
           public OpenURIEvent(final URI uri) {
      
      src/java.desktop/share/classes/java/awt/desktop/PreferencesEvent.java
           /**
      +     * @throws HeadlessException if {@link GraphicsEnvironment#isHeadless()}
      +     *         returns {@code true}
      +     * @throws UnsupportedOperationException if Desktop API is not supported on
      +     *         the current platform
      +     * @see Desktop#isDesktopSupported()
      +     * @see java.awt.GraphicsEnvironment#isHeadless
            */
           public PreferencesEvent() {
      
      src/java.desktop/share/classes/java/awt/desktop/PrintFilesEvent.java
           /**
      -     * Constructs a {@code PrintFilesEvent}
      -     * @param files files
      +     * Constructs a {@code PrintFilesEvent}.
      +     *
      +     * @param  files the list of files
      +     * @throws HeadlessException if {@link GraphicsEnvironment#isHeadless()}
      +     *         returns {@code true}
      +     * @throws UnsupportedOperationException if Desktop API is not supported on
      +     *         the current platform
      +     * @see Desktop#isDesktopSupported()
      +     * @see java.awt.GraphicsEnvironment#isHeadless
            */
           public PrintFilesEvent(final List<File> files) {
      
      src/java.desktop/share/classes/java/awt/desktop/QuitEvent.java
           /**
      +     * @throws HeadlessException if {@link GraphicsEnvironment#isHeadless()}
      +     *         returns {@code true}
      +     * @throws UnsupportedOperationException if Desktop API is not supported on
      +     *         the current platform
      +     * @see Desktop#isDesktopSupported()
      +     * @see java.awt.GraphicsEnvironment#isHeadless
            */
           public QuitEvent() {
      
      src/java.desktop/share/classes/java/awt/desktop/ScreenSleepEvent.java
           /**
      +     * @throws HeadlessException if {@link GraphicsEnvironment#isHeadless()}
      +     *         returns {@code true}
      +     * @throws UnsupportedOperationException if Desktop API is not supported on
      +     *         the current platform
      +     * @see Desktop#isDesktopSupported()
      +     * @see java.awt.GraphicsEnvironment#isHeadless
            */
           public ScreenSleepEvent() {
      
      src/java.desktop/share/classes/java/awt/desktop/SystemSleepEvent.java
           /**
      +     * @throws HeadlessException if {@link GraphicsEnvironment#isHeadless()}
      +     *         returns {@code true}
      +     * @throws UnsupportedOperationException if Desktop API is not supported on
      +     *         the current platform
      +     * @see Desktop#isDesktopSupported()
      +     * @see java.awt.GraphicsEnvironment#isHeadless
            */
           public SystemSleepEvent() {
      
      src/java.desktop/share/classes/java/awt/desktop/UserSessionEvent.java
           /**
      -     * @param reason of session change
      +     * @param  reason the reason of the user session change
      +     * @throws HeadlessException if {@link GraphicsEnvironment#isHeadless()}
      +     *         returns {@code true}
      +     * @throws UnsupportedOperationException if Desktop API is not supported on
      +     *         the current platform
      +     * @see Desktop#isDesktopSupported()
      +     * @see java.awt.GraphicsEnvironment#isHeadless
            */
           public UserSessionEvent(Reason reason) {

      webrev for convenience : http://cr.openjdk.java.net/~serb/8203224/webrev.00/

      Attachments

        Issue Links

          Activity

            People

              serb Sergey Bylokhov
              dbessono Dmitry Bessonov
              Philip Race
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: