svn commit: r702377 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r702377 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java

jleroux@apache.org
Author: jleroux
Date: Tue Oct  7 01:01:50 2008
New Revision: 702377

URL: http://svn.apache.org/viewvc?rev=702377&view=rev
Log:
A patch from Michael Imhof "ObjectType does not recognize arrays" (https://issues.apache.org/jira/browse/OFBIZ-1008) - OFBIZ-1008

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java?rev=702377&r1=702376&r2=702377&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/ObjectType.java Tue Oct  7 01:01:50 2008
@@ -70,6 +70,23 @@
      * @throws ClassNotFoundException
      */
     public static Class<?> loadClass(String className, ClassLoader loader) throws ClassNotFoundException {
+        // Handle array classes. Details in http://java.sun.com/j2se/1.5.0/docs/guide/jni/spec/types.html#wp16437
+        if (className.endsWith("[]")) {
+            if (Character.isLowerCase(className.charAt(0)) && className.indexOf(".") < 0) {
+               String prefix = className.substring(0, 1).toUpperCase();
+               // long and boolean have other prefix than first letter
+               if (className.startsWith("long")) {
+                   prefix = "J";
+               } else if (className.startsWith("boolean")) {
+                   prefix = "Z";
+               }
+               className = "[" + prefix;
+            } else {
+                Class arrayClass = loadClass(className.replace("[]", ""), loader);
+                className = "[L" + arrayClass.getName().replace("[]", "") + ";";
+            }
+        }
+        
         // small block to speed things up by putting using preloaded classes for common objects, this turns out to help quite a bit...
         Class<?> theClass = CachedClassLoader.globalClassNameClassMap.get(className);