JDK-4653179 : LTP: java.beans.Statement compares Strings "by reference" instead of "by value"
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 1.4.0,1.4.2
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_98,windows_2000
  • CPU: x86
  • Submitted: 2002-03-15
  • Updated: 2003-09-26
  • Resolved: 2003-09-26
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
Related Reports
Duplicate :  
Relates :  
Relates :  
Description

Name: jl125535			Date: 03/14/2002


FULL PRODUCT VERSION :
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

FULL OPERATING SYSTEM VERSION :
Windows 2000

A DESCRIPTION OF THE PROBLEM :
There are cases when test 'methodname == "get"' returns
false despite the fact that methodname actually
contains "get".

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.Execute Test
2.
3.

EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected:
Running Statement with a naked string
Running Statement with a constructed String

Actual: (see ERROR MESSAGES/STACK TRACES below)

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Running Statement with a naked string
Running Statement with a constructed String
java.lang.NoSuchMethodException: StringArray0.get(Integer0);
        at java.beans.Statement.invoke(Statement.java:489)
        at java.beans.Statement.execute(Statement.java:119)
        at Test.main(Test.java:19)

This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.beans.Statement;

public class Test {
    public static void main(String[] args) {
        String [] array = {"Philip Milne", "Steve Langley"};
        System.out.println("Running Statement with a naked string");
        Statement st = new Statement(array, "get",
                       new Object []{new Integer (0)});
        try {
            st.execute();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        
        System.out.println("Running Statement with a constructed String");
        st = new Statement(array, new String("get"),
                           new Object []{new Integer (0)});
        try {
            st.execute();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}


---------- END SOURCE ----------

(Review ID: 143848) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b22
14-06-2004

EVALUATION This is a valid concern. We cant guarantee that the Strings are interned. ###@###.### 2003-09-08
08-09-2003