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

java.beans.Statement.invoke() uses incorrect string compare

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.2
    • client-libs
    • x86
    • windows_2000



      Name: gm110360 Date: 08/13/2003


      FULL PRODUCT VERSION :
      java version "1.4.0"
      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 :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      java.beans.Statement.invoke() contains conditional code to
      test if the method name is "new" or "newInstance". The code
      looks like:

      Statement.java:line 409:
                  if (methodName == "new") {
                      methodName = "newInstance";
                  }
                  // Provide a short form for array instantiation
      by faking an nary-constructor.
                  if (methodName == "newInstance" &&
      ((Class)target).isArray()) {

      This does not work correctly with my application because it
      is using a different string pool, thus the comparison is
      failing. When the comparison fails the constructor lookup
      fails, and the serialization fails.

      I believe that it would be more correct for the code to look
      like:

                 if (methodName.equals("new")) {
                      methodName = "newInstance";
                  }
                  // Provide a short form for array instantiation
      by faking an nary-constructor.
                  if (methodName.equals("newInstance") &&
      ((Class)target).isArray()) {

      then it woudl succeed regardless of the string origin.



      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Let me know if you want more details, but there are some
      rather obscure conditions that are causing the problem to
      appear.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      I expected the serialization scheme to work, and it dod not
      because it could not find my constructor, and instead was
      searching for a "new" method.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.lang.NoSuchMethodException: <unbound>=Wrapper.newInstance(Label0);
              at java.beans.Statement.invoke(Statement.java:489)
              at java.beans.Expression.getValue(Expression.java:101)
              at java.beans.Encoder.getValue(Encoder.java:84)
              at java.beans.Encoder.get(Encoder.java:186)
              at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:9
      7)
              at java.beans.Encoder.writeObject(Encoder.java:55)
              at java.beans.XMLEncoder.writeObject(XMLEncoder.java:250)
              at java.beans.Encoder.writeExpression(Encoder.java:260)
              at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:351)
              at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:1
      00)
              at java.beans.Encoder.writeObject(Encoder.java:55)
              at java.beans.XMLEncoder.writeObject(XMLEncoder.java:250)
              at java.beans.Encoder.writeObject1(Encoder.java:192)
              at java.beans.Encoder.cloneStatement(Encoder.java:205)
              at java.beans.Encoder.writeStatement(Encoder.java:236)
              at java.beans.XMLEncoder.writeStatement(XMLEncoder.java:320)
              at java.beans.DefaultPersistenceDelegate.invokeStatement(DefaultPersiste
      nceDelegate.java:242)
              at java.beans.java_awt_Container_PersistenceDelegate.initialize(MetaData


      etc....

      REPRODUCIBILITY :
      This bug can be reproduced always.
      (Incident Review ID: 173319)
      ======================================================================

            mdavidsosunw Mark Davidson (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: