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

REGRESSION: NameGenerator.captialize doesn't work properly with Turkish locale

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 5.0
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      FULL PRODUCT VERSION :
      java version "1.5.0_04"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
      Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP Version 5.1.2600

      A DESCRIPTION OF THE PROBLEM :
      The java.beans.NameGenerator's captialize method doesn't handle the problem with lowercase "i" characters when converting to upper case on a Turkish system. Calling String.toUpperCase on a lowercase "i" will convert that character to the Turkish "I" that has a dot above it, not the English uppercase "I"

      This is a major problem, since the PropertyDescriptor and FeatureDescriptor classes now use the NameGenerator to generate the names of the get/set methods for a given property. Calling the PropertyDescriptor constructor with a propertyName that begins with lowercase "i" will throw an IntrospectionException on Turkish systems, because the get/set methods are incorrectly named.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Create an instance of java.beans.PropertyDescriptor with a property name that begins with lowercase "i"
      e.g. new PropertyDescriptor("iTest", MyClass.class);

      This will throw an IntrospectionException with the message "Method not found: is?Test" Notice the dot above the I. This is a Turkish uppercase "I", which will not match the "is" method in the class.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      In previous versions (Java JDK 1.4.2_x), this worked properly. PropertyDescriptor captializes the propertyName string using Character.toUpperCase() on the first char. This will not change the lowercase "i" to the Turkish "?" character. This will cause the get/set methods to be correctly formulated for query by the java.beans.Introspector.
      ACTUAL -
      The propertyName's first character is converted to a Turkish upper case "?" character instead of the English "I". This causes the get/set methods for the property to be improperly formulated and an IntrospectionException will occur.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "main" java.lang.Error: java.beans.IntrospectionException: Method not found: istTest
              at TestTurkishUpper$TestTurkishUpperBeanInfo.getPropertyDescriptors(TestTurkishUpp
      er.java:35)
              at TestTurkishUpper.main(TestTurkishUpper.java:15)
      Caused by: java.beans.IntrospectionException: Method not found: isTest
              at java.beans.PropertyDescriptor.<init>(PropertyDescriptor.java:89)
              at java.beans.PropertyDescriptor.<init>(PropertyDescriptor.java:53)
              at TestTurkishUpper$TestTurkishUpperBeanInfo.getPropertyDescriptors(TestTurkishUpp
      er.java:32)
              ... 1 more

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.beans.BeanInfo;
      import java.beans.IntrospectionException;
      import java.beans.PropertyDescriptor;
      import java.beans.SimpleBeanInfo;


      public class TestTurkishUpper {
          
          private String iTest;
          /**
           * @param args
           */
          public static void main(String[] args) {
              BeanInfo bInfo = new TestTurkishUpper.TestTurkishUpperBeanInfo();
              PropertyDescriptor[] pds = bInfo.getPropertyDescriptors();
              System.out.println(pds[0].getName());
          }
          
          public String getITest() {
              return iTest;
          }
          
          public void setITest(String str) {
              iTest = str;
          }
          
          static class TestTurkishUpperBeanInfo extends SimpleBeanInfo {

              public PropertyDescriptor[] getPropertyDescriptors() {
                  try {
                      PropertyDescriptor[] pds = new PropertyDescriptor[1];
                      pds[0] = new PropertyDescriptor("iTest", TestTurkishUpper.class);
                      return pds;
                  } catch (IntrospectionException e) {
                      throw new Error(e);
                  }
              }
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      No workaround. Developers cannot alter bean property names based on runtime locale.

      Release Regression From : 1.4.2_10
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              malenkov Sergey Malenkov (Inactive)
              Reporter:
              ndcosta Nelson Dcosta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: