IBM Support

PM51629: Possible use of wrong operator to compare Strings

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • Abstract:
    
    Usage of the '==' operator to compare string values may be
    incorrect.  The equals() operation is more appropriate when
    comparing string values.
    
    Problem:
    
    Using '==' to compare two strings for equality or '!=' for
    inequality actually compares the object references rather than
    their values.
    
    Local fix:
    
    There is no known workaround at this time.
    

Local fix

Problem summary

  • ****************************************************************
    * USERS AFFECTED:                                              *
    ****************************************************************
    * PROBLEM DESCRIPTION:                                         *
    ****************************************************************
    * RECOMMENDATION:                                              *
    ****************************************************************
    Several comparisons of strings to the empty string, in the
    form s != "" and s == "" were present in the IBM JSF Widgets
    LIbrary (JWL) source code. This comparison will behave as
    the "equals" method in most cases as an effect of String
    caching in Java, but it will not work for Strings created
    with the "new" operator or the "String.intern()" method.
    
    So far, there are no known problems or side effects of this
    expressions in the JWL components but some static analysis
    tools will prompt warnings in this regard.
    

Problem conclusion

  • All String comparisons in the form s != "" and s == ""
    present in JWL source code were replaced by the safe and
    faster expressions s.length() != 0 and s.length() == 0
    respectively.
    
    Comparing the length is more efficient, in the case of empty
    strings, than using the equals method.
    
    The fix for this APAR is included in Rational Application
    Developer v7.5.5.5 iFix1.
    

Temporary fix

Comments

APAR Information

  • APAR number

    PM51629

  • Reported component name

    RATL APP DEV WI

  • Reported component ID

    5724J1901

  • Reported release

    700

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2011-11-04

  • Closed date

    2012-09-24

  • Last modified date

    2012-09-24

  • APAR is sysrouted FROM one or more of the following:

  • APAR is sysrouted TO one or more of the following:

Fix information

  • Fixed component name

    RATL APP DEV WI

  • Fixed component ID

    5724J1901

Applicable component levels

  • R700 PSN

       UP

[{"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Product":{"code":"SSRTLW","label":"Rational Application Developer for WebSphere Software"},"Component":"","ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"7.0","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
24 September 2012