You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xbean-scm@geronimo.apache.org by ri...@apache.org on 2011/01/13 14:34:55 UTC

svn commit: r1058546 - /geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AbstractFinder.java

Author: rickmcguire
Date: Thu Jan 13 13:34:55 2011
New Revision: 1058546

URL: http://svn.apache.org/viewvc?rev=1058546&view=rev
Log:
GERONIMO-5751 LinkageError running CDI TCK


Modified:
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AbstractFinder.java

Modified: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AbstractFinder.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AbstractFinder.java?rev=1058546&r1=1058545&r2=1058546&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AbstractFinder.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AbstractFinder.java Thu Jan 13 13:34:55 2011
@@ -572,7 +572,7 @@ public abstract class AbstractFinder {
         private final List<AnnotationInfo> annotations = new ArrayList<AnnotationInfo>();
 
         public Annotatable(AnnotatedElement element) {
-            for (Annotation annotation : element.getAnnotations()) {
+            for (Annotation annotation : getAnnotations(element)) {
                 annotations.add(new AnnotationInfo(annotation.annotationType().getName()));
             }
         }
@@ -583,6 +583,32 @@ public abstract class AbstractFinder {
         public List<AnnotationInfo> getAnnotations() {
             return annotations;
         }
+        
+        /**
+         * Utility method to get around some errors caused by 
+         * interactions between the Equinox class loaders and 
+         * the OpenJPA transformation process.  There is a window 
+         * where the OpenJPA transformation process can cause 
+         * an annotation being processed to get defined in a 
+         * classloader during the actual defineClass call for 
+         * that very class (e.g., recursively).  This results in 
+         * a LinkageError exception.  If we see one of these, 
+         * retry the request.  Since the annotation will be 
+         * defined on the second pass, this should succeed.  If 
+         * we get a second exception, then it's likely some 
+         * other problem. 
+         * 
+         * @param element The AnnotatedElement we need information for.
+         * 
+         * @return An array of the Annotations defined on the element. 
+         */
+        private Annotation[] getAnnotations(AnnotatedElement element) {
+            try {
+                return element.getAnnotations();
+            } catch (LinkageError e) {
+                return element.getAnnotations();
+            }
+        }
 
     }