openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwsut...@apache.org
Subject svn commit: r686069 - /openjpa/branches/1.2.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/TemporaryClassLoader.java
Date Thu, 14 Aug 2008 22:36:22 GMT
Author: kwsutter
Date: Thu Aug 14 15:36:22 2008
New Revision: 686069

URL: http://svn.apache.org/viewvc?rev=686069&view=rev
Log:
OPENJPA-646.  Integrating the original patch which bypasses the enum types in our TemporaryClassLoader.

Modified:
    openjpa/branches/1.2.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/TemporaryClassLoader.java

Modified: openjpa/branches/1.2.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/TemporaryClassLoader.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.2.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/TemporaryClassLoader.java?rev=686069&r1=686068&r2=686069&view=diff
==============================================================================
--- openjpa/branches/1.2.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/TemporaryClassLoader.java
(original)
+++ openjpa/branches/1.2.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/TemporaryClassLoader.java
Thu Aug 14 15:36:22 2008
@@ -70,7 +70,10 @@
                 bout.write(b, 0, n))
                 ;
             byte[] classBytes = bout.toByteArray();
-            if (isAnnotation(classBytes))
+            // To avoid classloader issues with the JVM (Sun and IBM), we
+            // will not load Enums via the TemporaryClassLoader either.
+            // Reference JIRA Issue OPENJPA-646 for more information.
+            if (isAnnotation(classBytes) || isEnum(classBytes))
                 return Class.forName(name, resolve, getClass().
                     getClassLoader());
 
@@ -97,4 +100,16 @@
         int access = ConstantPoolTable.readUnsignedShort(b, idx);
         return (access & 0x2000) != 0; // access constant for annotation type
     }
+
+    /**
+     * Fast-parse the given class bytecode to determine if it is an
+     * enum class.
+     */
+    private static boolean isEnum(byte[] b) {
+        if (JavaVersions.VERSION < 5)
+            return false;
+        int idx = ConstantPoolTable.getEndIndex(b);
+        int access = ConstantPoolTable.readUnsignedShort(b, idx);
+        return (access & 0x4000) != 0; // access constant for enum type
+    }
 }



Mime
View raw message