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

LTP: java.beans.Statement compares Strings "by reference" instead of "by value"

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 1.4.0, 1.4.2
    • Fix Version/s: 5.0
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      tiger
    • CPU:
      x86
    • OS:
      windows_98, windows_2000

      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)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mdavidsosunw Mark Davidson (Inactive)
              Reporter:
              jleesunw Jon Lee (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: