[jboss-cvs] JBossAS SVN: r96763 - projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Nov 23 17:18:34 EST 2009


Author: alesj
Date: 2009-11-23 17:18:34 -0500 (Mon, 23 Nov 2009)
New Revision: 96763

Modified:
   projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/AnnotationValueImpl.java
Log:
[JBREFLECT-71]; fix Annotation::equals bug.

Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/AnnotationValueImpl.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/AnnotationValueImpl.java	2009-11-23 21:40:41 UTC (rev 96762)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/AnnotationValueImpl.java	2009-11-23 22:18:34 UTC (rev 96763)
@@ -24,6 +24,8 @@
 import java.lang.annotation.Annotation;
 import java.util.HashMap;
 import java.util.Map;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 
 import org.jboss.reflect.spi.AbstractValue;
 import org.jboss.reflect.spi.AnnotationInfo;
@@ -137,16 +139,27 @@
       if (o == null || !(o instanceof AnnotationValue)) return false;
 
       final AnnotationValue annotationValue = (AnnotationValue) o;
-
       if (!annotationType.equals(annotationValue.getAnnotationType())) return false;
       if (!attributeValues.equals(annotationValue.getValues())) return false;
 
-      Annotation otherUnderlying = annotationValue.getUnderlyingAnnotation();
+      final Annotation otherUnderlying = annotationValue.getUnderlyingAnnotation();
       if (underlying == null && otherUnderlying != null)
          return false;
       if (underlying != null && otherUnderlying == null)
          return false;
-      return underlying.equals(otherUnderlying);
+
+      // Workaround for JDK bug -- should be fixed in 5 update and 6
+      SecurityManager sm = System.getSecurityManager();
+      if (sm != null)
+         return AccessController.doPrivileged(new PrivilegedAction<Boolean>()
+         {
+            public Boolean run()
+            {
+               return underlying.equals(otherUnderlying);
+            }
+         });
+      else
+         return underlying.equals(otherUnderlying);
    }
 
    @Override




More information about the jboss-cvs-commits mailing list