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

Frame.setTitle(null) - inconsisten behaviour

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 1.4.0
    • Fix Version/s: 1.4.2
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      mantis
    • CPU:
      sparc
    • OS:
      solaris_2.5
    • Verification:
      Verified

      Description



      Name: apR10100 Date: 02/06/2002



      Methods:

      Frame.setTitle incorrectly and
      inconsistently handles null as parameter.

      JDK1.4 spec states:

      ------------------
      public String getTitle()
      Gets the title of the frame. The title is displayed in the frame's border.

      Returns:
      the title of this frame, or an empty string ("") if this frame doesn't have a title.

      ...

      public void setTitle(String title)
      Sets the title for this frame to the specified string.
      ...
      --------------------------------------------------------------------------------

      Handling of null is not specified and should be default (throwing NPE).
      getTitle should never return null - it should be some String, possibly
      empty.

      However jdk1.4 takes null as parameter for setTitle without any
      exception and returns null from getTitle() after that:

      --------- TestTitle.java
      import java.awt.*;

      public class TestTitle {

        public static void main (String [] args) {
          
              Frame f = new Frame();
              f.show();
          
              try {
                  f.setTitle(null);
                  System.out.println("Unexpectedly set title to: '"+f.getTitle()+"'");
              } catch (NullPointerException npe) {
                 npe.printStackTrace();
              } finally {
                  f.dispose();
              }
          }

      --------- Output
      3,~/tmp;
      /set/java/jdk1.4/solaris/bin/java TestTitle
      Unexpectedly set title to: 'null'
      3,~/tmp;
      ---------

      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              son Oleg Sukhodolsky (Inactive)
              Reporter:
              avpsunw Avp Avp (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: