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

Java Bean Introspection changed in JDK 1.4.2_12

XMLWordPrintable

    • sparc
    • solaris_8

      My customer has experienced a difference in behaviour in how Java Beans are handled between JDK 1.4.2_05 and JDK1.4.2_12

      Below are two example of how to reproduce this behaviour:

      Generic Reproducer:

      public class Test {
               class MyBean extends TestBean {
                   public String getMyValue(int i){
                      return "abab";
                  }
               }

               class TestBean {
                  private String myvalue="bla";


               /* public String getMyValue(){
                      return myvalue;
                  }*/

                  public void setMyValue(String my){
                      myvalue = my;
                  }

              }

              public static void main(String[] args) throws Exception{


                  BeanInfo beanInfo = Introspector.getBeanInfo(MyBean.class);
                  PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();

                  for (int i = 0; i < descriptors.length; i++) {
                      System.out.println(i);
                      System.out.println(descriptors[i].getName());
                      System.out.println(descriptors[i].getPropertyType());
                      System.out.println(descriptors[i].getReadMethod());
                      System.out.println(descriptors[i].getWriteMethod());
                      System.out.println();
                  }
              }
          }


      Ouput using JDK 1.4.2_05:
      0
      class
      class java.lang.Class
      public final native java.lang.Class java.lang.Object.getClass()
      null

      1
      myValue
      class java.lang.String
      null
      public void Test$TestBean.setMyValue(java.lang.String)

      Ouput using JDK 1.4.2_12:
      0
      class
      class java.lang.Class
      public final native java.lang.Class java.lang.Object.getClass()
      null

      1
      myValue
      null
      null
      null

      As you can see the result of the introspection is different.

      I'll also show you the Web App, which resembles the behaviour we have initially identified:

      Deploy this war file to your application server:

      <<struts-test.ZIP>>

      Call the localhost:<yourport>/struts-test/forms/register3.jsp page, enter a valid email address and leave the pasword blank, click submit.

      Running the application server with JDK 1.4.2_05 will show you an error page saying that the pwd is invalid. If you run the application server with JDK 1.4.2_12 you will get a JspException, saying that the property "level" cannot be found.

      The offending Java Bean looks like this:

      public class Level1 {
          public String getLevel(){
              return "level1";
          }

          public String getLevel(int dummy){
              return "int method level1";
          }
      }

      From speaking with several engineers, I believe that this problem is similar (and related to) bug 4867168, which in turn, was caused by a regression introduced by the fix for 4750368.

      The problem was initially introduced in 1.4.2_06, but my customer has only just noticed as they are upgrading from 1.4.2_05 to 1.4.2_12. This issue does appear to be fixed in 1.5, but my customer is unable to move to this version at present.

            malenkov Sergey Malenkov (Inactive)
            arfox Andrew Fox (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: