geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r1073673 - /geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/classloader/TemporaryClassLoader.java
Date Wed, 23 Feb 2011 10:20:14 GMT
Author: xuhaihong
Date: Wed Feb 23 10:20:13 2011
New Revision: 1073673

URL: http://svn.apache.org/viewvc?rev=1073673&view=rev
Log:
GERONIMO-4945 Load enum with normal classloader

Modified:
    geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/classloader/TemporaryClassLoader.java

Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/classloader/TemporaryClassLoader.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/classloader/TemporaryClassLoader.java?rev=1073673&r1=1073672&r2=1073673&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/classloader/TemporaryClassLoader.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/classloader/TemporaryClassLoader.java
Wed Feb 23 10:20:13 2011
@@ -100,7 +100,7 @@ public class TemporaryClassLoader extend
        }
 
        // Annotation classes must be loaded by the normal classloader
-       if (isAnnotationClass(bytes)) {
+        if (isAnnotationClass(bytes) || isEnum(bytes)) {
            return super.loadClass(name, resolve);
        }
 
@@ -141,5 +141,26 @@ public class TemporaryClassLoader extend
        }
 
    }
+
+    /**
+         * Fast-parse the given class bytecode to determine if it is an
+       * enum class.
+         */
+    private static boolean isEnum(byte[] bytes) {
+        IsEnumVisitor isEnumVisitor = new IsEnumVisitor();
+        ClassReader classReader = new ClassReader(bytes);
+        classReader.accept(isEnumVisitor, ClassReader.SKIP_DEBUG);
+        return isEnumVisitor.isEnum;
+    }
+
+    public static class IsEnumVisitor extends EmptyVisitor {
+
+        public boolean isEnum = false;
+
+        public void visit(int version, int access, String name, String signature, String
superName, String[] interfaces) {
+            isEnum = (access & Opcodes.ACC_ENUM) != 0;
+        }
+
+    }
 }
 



Mime
View raw message