Author: djencks
Date: Tue Nov 23 00:08:17 2010
New Revision: 1037951

URL: http://svn.apache.org/viewvc?rev=1037951&view=rev
Log:
OWB-497 Warn but don't break deployment if annotation scanning throws an 
ArrayStoreException

Modified:
    
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java
    
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java

Modified: 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java
URL: 
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java?rev=1037951&r1=1037950&r2=1037951&view=diff
==============================================================================
--- 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java
 (original)
+++ 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java
 Tue Nov 23 00:08:17 2010
@@ -105,18 +105,18 @@ public final class AnnotatedElementFacto
                     AnnotatedField<X> af = new AnnotatedFieldImpl<X>(f, 
annotatedType);
                     annotatedType.addAnnotatedField(af);
                 }
-                
+
                 for(Method m : methods)
                 {
                     AnnotatedMethod<X> am = new 
AnnotatedMethodImpl<X>(m,annotatedType);
                     annotatedType.addAnnotatedMethod(am);
                 }
-                
+
                 for(Constructor<X> ct : ctxs)
                 {
                     AnnotatedConstructor<X> ac = new 
AnnotatedConstructorImpl<X>(ct,annotatedType);
                     annotatedType.addAnnotatedConstructor(ac);
-                }        
+                }
                 
                 AnnotatedTypeImpl<X> oldType = 
(AnnotatedTypeImpl<X>)annotatedTypeCache.putIfAbsent(annotatedClass, 
annotatedType);
                 if(oldType != null)
@@ -127,7 +127,7 @@ public final class AnnotatedElementFacto
             } 
             catch (Exception e)
             {
-                if (e instanceof ClassNotFoundException)
+                if (e instanceof ClassNotFoundException || e instanceof 
ArrayStoreException)
                 {
                     if (logger.wblWillLogError())
                     {

Modified: 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
URL: 
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java?rev=1037951&r1=1037950&r2=1037951&view=diff
==============================================================================
--- 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
 (original)
+++ 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
 Tue Nov 23 00:08:17 2010
@@ -91,7 +91,7 @@ public final class AnnotationUtil
      * Return true if exist false otherwise.
      * 
      * @param method method
-     * @param annotation checking annotation
+     * @param clazz checking annotation
      * @return true or false
      */
     public static boolean hasMethodParameterAnnotation(Method method, Class<? 
extends Annotation> clazz)
@@ -207,7 +207,7 @@ public final class AnnotationUtil
      * method. Return true if exist false otherwise.
      * 
      * @param method method
-     * @param annotation checking annotation
+     * @param clazz checking annotation
      * @return true or false
      */
     public static boolean hasMethodMultipleParameterAnnotation(Method method, 
Class<? extends Annotation> clazz)
@@ -274,7 +274,7 @@ public final class AnnotationUtil
      * given annotation.
      * 
      * @param method method
-     * @param annotation checking annotation
+     * @param clazz checking annotation
      * @return type
      */
     public static Type getMethodFirstParameterWithAnnotation(Method method, 
Class<? extends Annotation> clazz)
@@ -368,7 +368,7 @@ public final class AnnotationUtil
      * Gets the method first found parameter qualifiers.
      * 
      * @param method method
-     * @param annotation checking annotation
+     * @param clazz checking annotation
      * @return annotation array
      */
     public static Annotation[] 
getMethodFirstParameterQualifierWithGivenAnnotation(Method method, Class<? 
extends Annotation> clazz)
@@ -455,7 +455,7 @@ public final class AnnotationUtil
      * Gets the method first found parameter annotation with given type.
      * 
      * @param method method
-     * @param annotation checking annotation
+     * @param clazz checking annotation
      * @return annotation
      */
     public static <T extends Annotation> T 
getMethodFirstParameterAnnotation(Method method, Class<T> clazz)
@@ -506,7 +506,7 @@ public final class AnnotationUtil
      * method. Return true if exist false otherwise.
      * 
      * @param method method
-     * @param annotation checking annotation
+     * @param clazz checking annotation
      * @return true or false
      */
     public static boolean hasMethodParameterAnnotationCrossRef(Method method, 
Class<? extends Annotation> clazz)
@@ -799,21 +799,23 @@ public final class AnnotationUtil
     {
         Asserts.nullCheckForClass(clazz);
         Asserts.assertNotNull(annotation, "Annotation argument can not be 
null");
-
-        Method[] methods = SecurityUtil.doPrivilegedGetDeclaredMethods(clazz);
         List<Method> list = new ArrayList<Method>();
-        Method[] rMethod = null;
 
-        for (Method m : methods)
+        do
         {
-            if (hasMethodParameterAnnotation(m, annotation))
+            Method[] methods = 
SecurityUtil.doPrivilegedGetDeclaredMethods(clazz);
+
+            for (Method m : methods)
             {
-                list.add(m);
+                if (hasMethodParameterAnnotation(m, annotation))
+                {
+                    list.add(m);
+                }
             }
-        }
+            clazz = clazz.getSuperclass();
+        } while (clazz != null && clazz != Object.class);
 
-        rMethod = new Method[list.size()];
-        rMethod = list.toArray(rMethod);
+        Method[] rMethod = list.toArray(new Method[list.size()]);
 
         return rMethod;
     }
@@ -860,11 +862,18 @@ public final class AnnotationUtil
         Asserts.nullCheckForClass(clazz);
         Asserts.assertNotNull(annotation, "Annotation argument can not be 
null");
 
-        Annotation a = clazz.getAnnotation(annotation);
+        try
+        {
+            Annotation a = clazz.getAnnotation(annotation);
 
-        if (a != null)
+            if (a != null)
+            {
+                return true;
+            }
+        }
+        catch (ArrayStoreException e)
         {
-            return true;
+            //log this?  It is probably already logged in 
AnnotatedElementFactory
         }
 
         return false;


Reply via email to