OpenJPA
  1. OpenJPA
  2. OPENJPA-719

GeneralException in PCEnhancer during class transform in Turkish locale AppServer setting

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0.3, 1.0.4, 1.1.0, 1.1.1, 1.2.0, 1.2.1, 1.3.0
    • Fix Version/s: 1.2.1, 1.3.0
    • Component/s: kernel
    • Labels:
      None

      Description

      When Turkish locale is used in EE (AppServer) environment, entity class transformation failed with the following exception.

      org.apache.openjpa.util.GeneralException: An error occurred while enhancing
      itemejb3.ItemJPA. Exception message: org.apache.openjpa.enhance.StateManager.replace�ntField(org.apache.openjpa.enhance.PersistenceCapable, int)
      at org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:538)
      at org.apache.openjpa.enhance.PCClassFileTransformer.transform0(PCClassFileTransformer.java:146)
      at org.apache.openjpa.enhance.PCClassFileTransformer.transform(PCClassFileTransformer.java:120)
      at org.apache.openjpa.persistence.PersistenceProviderImpl$ClassTransformerImpl.transform(PersistenceProviderImpl.java:210)
      at com.ibm.ws.jpa.management.JPAPUnitInfo.transformClass(JPAPUnitInfo.java:1815)
      ......
      Caused by: java.lang.NoSuchMethodException:
      org.apache.openjpa.enhance.StateManager.replace�ntField(org.apache.openjpa.enhance.PersistenceCapable, int)
      at java.lang.Class.throwNoSuchMethodException(Class.java:283)
      at java.lang.Class.getDeclaredMethod(Class.java:609)
      at org.apache.openjpa.lib.util.J2DoPrivHelper$8.run(J2DoPrivHelper.java:288)
      at java.security.AccessController.doPrivileged(AccessController.java:251)
      at org.apache.openjpa.enhance.PCEnhancer.getMethod(PCEnhancer.java:2597)
      at org.apache.openjpa.enhance.PCEnhancer.getStateManagerMethod(PCEnhancer.java:2546)
      at org.apache.openjpa.enhance.PCEnhancer.addReplaceFieldsMethods(PCEnhancer.java:1338)
      at org.apache.openjpa.enhance.PCEnhancer.addPCMethods(PCEnhancer.java:1070)
      at org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:523)
      ... 33 more

      Albert Lee.

        Activity

        Hide
        Albert Lee added a comment -

        In Turkish locale, there are 2 forms of letter 'i'. A dotted 'i' and a non-dotted 'i'. Java String.toLowerCase and toUpperCase perform the following case transformation:

        toLowerCase( dotted 'i' (0x69) ) -> dotted 'i' (0x69)
        toUpperCase( dotted 'i' (0x69) ) -> dotted 'I' (0x130)
        toLowerCase( non-dotted 'I' (0x49) ) -> non-dotted 'i' (0x131)
        toUpperCase( non-dotted 'I' (0x49) ) -> non-dotted 'I' (0x49)

        toLowerCase( non-dotted 'i' (0x131) ) -> non-dotted 'i' (0x131)
        toUpperCase( non-dotted 'i' (0x131) ) -> non-dotted 'I' (0x49)
        toLowerCase( dotted 'I' (0x130) ) -> dotted 'i' (0x69)
        toUpperCase( dotted 'I' (0x130) ) -> dotted 'I' (0x130)

        In PCEnhance ( and most other OpenJPA code ), String.toUpperCase and toLowerCase are used regardless of this particularity, which translated the replaceIntField (and other variations of this method) to replace�ntField. Hence the observed exception.

        In this scenario, java fields and methods used for Reflection must not be locale sensitive, hence toLowerCase/toUpperCase(Locale.ENGLISH) should be used instead.

        There are other use cases in OpenJPA that should also consider to be locale insensitive, e.g. SQL reserved words should also use Locale.ENGLISH when toUpperCase/toLowerCase is called.

        Albert Lee.

        Show
        Albert Lee added a comment - In Turkish locale, there are 2 forms of letter 'i'. A dotted 'i' and a non-dotted 'i'. Java String.toLowerCase and toUpperCase perform the following case transformation: toLowerCase( dotted 'i' (0x69) ) -> dotted 'i' (0x69) toUpperCase( dotted 'i' (0x69) ) -> dotted 'I' (0x130) toLowerCase( non-dotted 'I' (0x49) ) -> non-dotted 'i' (0x131) toUpperCase( non-dotted 'I' (0x49) ) -> non-dotted 'I' (0x49) toLowerCase( non-dotted 'i' (0x131) ) -> non-dotted 'i' (0x131) toUpperCase( non-dotted 'i' (0x131) ) -> non-dotted 'I' (0x49) toLowerCase( dotted 'I' (0x130) ) -> dotted 'i' (0x69) toUpperCase( dotted 'I' (0x130) ) -> dotted 'I' (0x130) In PCEnhance ( and most other OpenJPA code ), String.toUpperCase and toLowerCase are used regardless of this particularity, which translated the replaceIntField (and other variations of this method) to replace�ntField. Hence the observed exception. In this scenario, java fields and methods used for Reflection must not be locale sensitive, hence toLowerCase/toUpperCase(Locale.ENGLISH) should be used instead. There are other use cases in OpenJPA that should also consider to be locale insensitive, e.g. SQL reserved words should also use Locale.ENGLISH when toUpperCase/toLowerCase is called. Albert Lee.

          People

          • Assignee:
            Albert Lee
            Reporter:
            Albert Lee
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development