JDK-4632623 : java.awt.Checkbox.getLabel() returns "" if no label
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.0,5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_7,solaris_10
  • CPU: sparc
  • Submitted: 2002-02-04
  • Updated: 2017-05-16
  • Resolved: 2003-05-25
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 tigerFixed
Description
Name: sdR10048			Date: 02/04/2002


JDK1.4rc92
java.awt.Checkbox method 

public String getLabel()

returns "" string if checkbox has no label.
But null is expected here as spec says.
See demo test.


Spec says:
----------
public String getLabel()

    Gets the label of this check box.
Returns:
    the label of this check box, or null if this check box has no label.
See_Also:
    setLabel(java.lang.String)


Demo test:
----------
import java.awt.*;
public class Test {
    public static void main(String[] args) {
        System.out.println("\""+(new Checkbox()).getLabel()+"\"");
    }
}


Demo output:
----------
[archer] ~/tmp
% java Test 
""
        
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b08 VERIFIED IN: 1.5
15-09-2004

EVALUATION We should update the spec, and be clear about null vs. empty string for ctors, setLabel, getLabel, etc. ###@###.### 2002-02-04 Unfortunately, the spec explicitly says null, while we believe that the current behaviour is more correct than the spec. Moreover, if we change the behaviour now to match the spec, existing apps can start throwing NPEs. We can't chnage the spec this way in update release, too, so we have to commit this bug to tiger instead. ###@###.### 2002-09-12 Name: rpR10076 Date: 07/10/2003 The decision was to change the documentation rather than the implementation. CCC-daemon announcement from 2003/04/28 says about the approval. So the behaviour is now correct. Please see diffs to Checkbox.java doc in suggested fix section. ======================================================================
15-09-2004

SUGGESTED FIX Name: rpR10076 Date: 07/10/2003 *************** *** 68,76 **** /** * The label of the Checkbox. ! * This field can be null. If a label is not specified it ! * defaults to null or "". ! * @serial * @see #getLabel() * @see #setLabel(label) */ --- 68,75 ---- /** * The label of the Checkbox. ! * This field can be null. ! * @serial * @see #getLabel() * @see #setLabel(label) */ *************** *** 117,125 **** } /** ! * Creates a check box with no label. The state of this ! * check box is set to "off," and it is not part of any ! * check box group. * @exception HeadlessException if GraphicsEnvironment.isHeadless() * returns true * @see java.awt.GraphicsEnvironment#isHeadless --- 116,124 ---- } /** ! * Creates a check box with an empty string for its label. ! * The state of this check box is set to "off," and it is not ! * part of any check box group. * @exception HeadlessException if GraphicsEnvironment.isHeadless() * returns true * @see java.awt.GraphicsEnvironment#isHeadless ======================================================================
15-09-2004