[jboss-cvs] JBossAS SVN: r95447 - in projects/jboss-reflect/trunk/src: main/java/org/jboss/reflect/plugins/introspection and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Oct 22 16:42:16 EDT 2009
Author: flavia.rainone at jboss.com
Date: 2009-10-22 16:42:15 -0400 (Thu, 22 Oct 2009)
New Revision: 95447
Modified:
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/AnnotationHelper.java
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/InheritableAnnotationHolder.java
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/introspection/IntrospectionAnnotationHelper.java
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactoryImpl.java
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistAnnotationHelper.java
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactoryImpl.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/test/AnnotatedClassInfoTest.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/test/JavassistAnnotatedClassInfoTestCase.java
Log:
[JBREFLECT-63] Reverting previous commit.
Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/AnnotationHelper.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/AnnotationHelper.java 2009-10-22 20:37:45 UTC (rev 95446)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/AnnotationHelper.java 2009-10-22 20:42:15 UTC (rev 95447)
@@ -28,7 +28,6 @@
* AnnotationHelper.
*
* @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
* @version $Revision$
*/
public interface AnnotationHelper
@@ -40,14 +39,6 @@
* @return the annotations
*/
AnnotationValue[] getAnnotations(Object object);
-
- /**
- * Get the declared annotations for the annotated object
- *
- * @param object the annotated object
- * @return the declared annotations
- */
- AnnotationValue[] getDeclaredAnnotations(Object object);
/**
* Create an annotation from the underlying implementation and its info type
Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/InheritableAnnotationHolder.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/InheritableAnnotationHolder.java 2009-10-22 20:37:45 UTC (rev 95446)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/InheritableAnnotationHolder.java 2009-10-22 20:42:15 UTC (rev 95447)
@@ -34,9 +34,6 @@
* @author <a href="mailto:bill at jboss.org">Bill Burke</a>
* @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
* @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
- *
- * @version $Revision$
*/
public abstract class InheritableAnnotationHolder extends AbstractAnnotatedInfo
{
@@ -95,7 +92,7 @@
protected AnnotationValue[] getDeclaredAnnotations()
{
if (declaredAnnotationsArray == UNKNOWN_ANNOTATIONS)
- setupAnnotations();
+ setupAnnotations(annotationHelper.getAnnotations(annotatedElement));
return declaredAnnotationsArray;
}
@@ -108,7 +105,7 @@
protected AnnotationValue getDeclaredAnnotation(String name)
{
if (declaredAnnotations == UNKNOWN_ANNOTATIONS_MAP)
- setupAnnotations();
+ setupAnnotations(annotationHelper.getAnnotations(annotatedElement));
return declaredAnnotations.get(name);
}
@@ -121,7 +118,7 @@
protected boolean isDeclaredAnnotationPresent(String name)
{
if (declaredAnnotations == UNKNOWN_ANNOTATIONS_MAP)
- setupAnnotations();
+ setupAnnotations(annotationHelper.getAnnotations(annotatedElement));
return declaredAnnotations.containsKey(name);
}
@@ -133,51 +130,54 @@
protected Map<String, AnnotationValue> getAllAnnotations()
{
if (allAnnotations == UNKNOWN_ANNOTATIONS_MAP)
- setupAnnotations();
+ setupAnnotations(annotationHelper.getAnnotations(annotatedElement));
return allAnnotations;
}
public AnnotationValue[] getAnnotations()
{
if (allAnnotationsArray == UNKNOWN_ANNOTATIONS)
- setupAnnotations();
+ setupAnnotations(annotationHelper.getAnnotations(annotatedElement));
return allAnnotationsArray;
}
public AnnotationValue getAnnotation(String name)
{
if (allAnnotations == UNKNOWN_ANNOTATIONS_MAP)
- setupAnnotations();
+ setupAnnotations(annotationHelper.getAnnotations(annotatedElement));
return allAnnotations.get(name);
}
public boolean isAnnotationPresent(String name)
{
if (allAnnotations == UNKNOWN_ANNOTATIONS_MAP)
- setupAnnotations();
+ setupAnnotations(annotationHelper.getAnnotations(annotatedElement));
return allAnnotations.containsKey(name);
}
/**
- * Set up the declaredAnnotations and allAnnotations fields.
+ * Set up the annotations
+ *
+ * @param annotations the annotations
*/
- private void setupAnnotations()
+ public void setupAnnotations(AnnotationValue[] annotations)
{
- declaredAnnotationsArray = annotationHelper.getDeclaredAnnotations(annotatedElement);
InheritableAnnotationHolder superHolder = getSuperHolder();
AnnotationValue[] superAllAnnotations = (superHolder != null) ? superHolder.getAnnotations() : null;
- if (declaredAnnotationsArray != null && declaredAnnotationsArray.length > 0)
+ if (annotations != null && annotations.length > 0)
{
declaredAnnotations = new HashMap<String, AnnotationValue>();
- for (AnnotationValue annotation: declaredAnnotationsArray)
- declaredAnnotations.put(annotation.getAnnotationType().getName(), annotation);
+ declaredAnnotationsArray = annotations;
+ for (int i = 0; i < annotations.length; i++)
+ declaredAnnotations.put(annotations[i].getAnnotationType().getName(), annotations[i]);
allAnnotations = new HashMap<String, AnnotationValue>();
if (superHolder != null && superAllAnnotations != null && superAllAnnotations.length != 0)
{
- for (AnnotationValue av: superAllAnnotations)
+ for (int i = 0; i < superAllAnnotations.length; i++)
{
+ AnnotationValue av = superAllAnnotations[i];
if (av.getAnnotationType().isAnnotationPresent(INHERITED_NAME))
{
allAnnotations.put(av.getAnnotationType().getName(), av);
@@ -187,8 +187,8 @@
else
allAnnotationsArray = declaredAnnotationsArray;
- for (AnnotationValue annotation: declaredAnnotationsArray)
- allAnnotations.put(annotation.getAnnotationType().getName(), annotation);
+ for (int i = 0; i < annotations.length; i++)
+ allAnnotations.put(annotations[i].getAnnotationType().getName(), annotations[i]);
allAnnotationsArray = allAnnotations.values().toArray(new AnnotationValue[allAnnotations.size()]);
}
Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/introspection/IntrospectionAnnotationHelper.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/introspection/IntrospectionAnnotationHelper.java 2009-10-22 20:37:45 UTC (rev 95446)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/introspection/IntrospectionAnnotationHelper.java 2009-10-22 20:42:15 UTC (rev 95447)
@@ -35,9 +35,6 @@
* simplifies usage when TIF must also be used as AnnotationHelper.
*
* @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
- *
- * @version $Revision$
*/
public class IntrospectionAnnotationHelper extends IntrospectionTypeInfoFactory implements AnnotationHelper
{
@@ -45,11 +42,6 @@
{
return delegate.getAnnotations(object);
}
-
- public AnnotationValue[] getDeclaredAnnotations(Object object)
- {
- return delegate.getDeclaredAnnotations(object);
- }
public AnnotationValue createAnnotationValue(AnnotationInfo info, Object ann)
{
Property changes on: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/introspection/IntrospectionAnnotationHelper.java
___________________________________________________________________
Name: svn:keywords
- Author Date Id Revision
Name: svn:eol-style
- native
Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactoryImpl.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactoryImpl.java 2009-10-22 20:37:45 UTC (rev 95446)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactoryImpl.java 2009-10-22 20:42:15 UTC (rev 95447)
@@ -53,6 +53,7 @@
import org.jboss.reflect.spi.ArrayInfo;
import org.jboss.reflect.spi.ClassInfo;
import org.jboss.reflect.spi.InterfaceInfo;
+import org.jboss.reflect.spi.ModifierInfo;
import org.jboss.reflect.spi.NumberInfo;
import org.jboss.reflect.spi.PrimitiveInfo;
import org.jboss.reflect.spi.TypeInfo;
@@ -63,8 +64,6 @@
* An introspection type factory.
*
* @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
- * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
- * @version $Revision$
*/
public class IntrospectionTypeInfoFactoryImpl extends WeakTypeCache<TypeInfo> implements TypeInfoFactory, AnnotationHelper, ClassInfoHelper
{
@@ -123,28 +122,7 @@
{
return NO_ANNOTATIONS;
}
- return createAnnotationValues(annotations);
- }
-
- public AnnotationValue[] getDeclaredAnnotations(Object obj)
- {
- Annotation[] annotations;
- if (obj instanceof AnnotatedElement)
- annotations = readDeclaredAnnotations((AnnotatedElement)obj);
- else
- {
- throw new RuntimeException("Attempt was made to read annotations from unsupported type " + obj.getClass().getName() + ": " + obj);
- }
- if (annotations.length == 0)
- {
- return NO_ANNOTATIONS;
- }
- return createAnnotationValues(annotations);
- }
-
- private AnnotationValue[] createAnnotationValues(Annotation[] annotations)
- {
AnnotationValue[] annotationValues = new AnnotationValue[annotations.length];
for (int i = 0 ; i < annotations.length ; i++)
{
@@ -578,31 +556,18 @@
return AccessController.doPrivileged(action);
}
}
-
- private Annotation[] readDeclaredAnnotations(final AnnotatedElement ao)
- {
- if (System.getSecurityManager() == null)
- return ao.getDeclaredAnnotations();
- else
- {
- PrivilegedAction<Annotation[]> action = new PrivilegedAction<Annotation[]>()
- {
- public Annotation[] run()
- {
- return ao.getDeclaredAnnotations();
- }
- };
-
- return AccessController.doPrivileged(action);
- }
- }
protected AnnotationValue[][] getParameterAnnotations(Annotation[][] annotations)
{
AnnotationValue[][] annotationValues = new AnnotationValue[annotations.length][];
for (int param = 0 ; param < annotations.length ; param++)
{
- annotationValues[param] = createAnnotationValues(annotations[param]);
+ annotationValues[param] = new AnnotationValue[annotations[param].length];
+ for (int ann = 0 ; ann < annotations[param].length ; ann++)
+ {
+ AnnotationInfo info = (AnnotationInfo)getTypeInfo(annotations[param][ann].annotationType());
+ annotationValues[param][ann] = createAnnotationValue(info, annotations[param][ann]);
+ }
}
return annotationValues;
}
@@ -660,7 +625,7 @@
type = ((ParameterizedClassInfo) classInfo).parameterizedType;
Type result = locateActualType(reference, parameter, classInfo.getType(), type);
- if (result instanceof TypeVariable<?>)
+ if (result instanceof TypeVariable)
{
TypeVariable<?> typeVariable = (TypeVariable<?>) result;
result = typeVariable.getBounds()[0];
Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistAnnotationHelper.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistAnnotationHelper.java 2009-10-22 20:37:45 UTC (rev 95446)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistAnnotationHelper.java 2009-10-22 20:42:15 UTC (rev 95447)
@@ -35,9 +35,6 @@
* simplifies usage when TIF must also be used as AnnotationHelper.
*
* @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
- *
- * @version $Revision$
*/
public class JavassistAnnotationHelper extends JavassistTypeInfoFactory implements AnnotationHelper
{
@@ -45,11 +42,6 @@
{
return delegate.getAnnotations(object);
}
-
- public AnnotationValue[] getDeclaredAnnotations(Object object)
- {
- return delegate.getDeclaredAnnotations(object);
- }
public AnnotationValue createAnnotationValue(AnnotationInfo info, Object ann)
{
Property changes on: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistAnnotationHelper.java
___________________________________________________________________
Name: svn:keywords
- Author Date Id Revision
Name: svn:eol-style
- native
Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactoryImpl.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactoryImpl.java 2009-10-22 20:37:45 UTC (rev 95446)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactoryImpl.java 2009-10-22 20:42:15 UTC (rev 95447)
@@ -552,12 +552,6 @@
throw new RuntimeException(t);
}
}
-
- // FIXME JBREFLECT-63 fix this method
- public AnnotationValue[] getDeclaredAnnotations(Object object)
- {
- return getAnnotations(object);
- }
public AnnotationValue createAnnotationValue(AnnotationInfo info, Object ann)
{
Modified: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/test/AnnotatedClassInfoTest.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/test/AnnotatedClassInfoTest.java 2009-10-22 20:37:45 UTC (rev 95446)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/test/AnnotatedClassInfoTest.java 2009-10-22 20:42:15 UTC (rev 95447)
@@ -21,6 +21,8 @@
*/
package org.jboss.test.classinfo.test;
+import java.util.HashSet;
+
import org.jboss.reflect.spi.AnnotatedInfo;
import org.jboss.reflect.spi.AnnotationInfo;
import org.jboss.reflect.spi.AnnotationValue;
@@ -54,7 +56,6 @@
/**
*
* @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
* @version $Revision$
*/
public abstract class AnnotatedClassInfoTest extends ContainerTest
@@ -172,12 +173,20 @@
System.out.println("---> Getting annotations");
AnnotationValue[] annotations = info.getAnnotations();
- assertEquals(1, annotations.length);
+ assertEquals(2, annotations.length);
AnnotationValue anotherAnnotation = getAnnotationCheckTypeAndName(info, AnotherAnnotation.class.getName());
- assertNull(info.getAnnotation(SimpleAnnotation.class.getName()));
- assertFalse(info.isAnnotationPresent(SimpleAnnotation.class.getName()));
+ AnnotationValue simpleAnnotation = getAnnotationCheckTypeAndName(info, SimpleAnnotation.class.getName());
- assertSame("Not found annotation " + anotherAnnotation, anotherAnnotation, annotations[0]);
+ HashSet<AnnotationValue> set = new HashSet<AnnotationValue>();
+ set.add(anotherAnnotation);
+ set.add(simpleAnnotation);
+
+ for (int i = 0 ; i < annotations.length ; i++)
+ {
+ set.remove(annotations[i]);
+ }
+
+ assertTrue("Not found annotations " + set, set.isEmpty());
ConstructorInfo[] ctors = info.getDeclaredConstructors();
assertEquals(1, ctors.length);
@@ -220,12 +229,20 @@
ClassInfo componentInfo = (ClassInfo)((ArrayInfo)info).getComponentType();
AnnotationValue[] annotations = componentInfo.getAnnotations();
- assertEquals(1, annotations.length);
+ assertEquals(2, annotations.length);
AnnotationValue anotherAnnotation = getAnnotationCheckTypeAndName(componentInfo, AnotherAnnotation.class.getName());
- assertNull(componentInfo.getAnnotation(SimpleAnnotation.class.getName()));
- assertFalse(componentInfo.isAnnotationPresent(SimpleAnnotation.class.getName()));
+ AnnotationValue simpleAnnotation = getAnnotationCheckTypeAndName(componentInfo, SimpleAnnotation.class.getName());
- assertSame("Not found annotation " + anotherAnnotation, anotherAnnotation, annotations[0]);
+ HashSet<AnnotationValue> set = new HashSet<AnnotationValue>();
+ set.add(anotherAnnotation);
+ set.add(simpleAnnotation);
+
+ for (int i = 0 ; i < annotations.length ; i++)
+ {
+ set.remove(annotations[i]);
+ }
+
+ assertTrue("Not found annotations " + set, set.isEmpty());
}
Modified: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/test/JavassistAnnotatedClassInfoTestCase.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/test/JavassistAnnotatedClassInfoTestCase.java 2009-10-22 20:37:45 UTC (rev 95446)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/test/JavassistAnnotatedClassInfoTestCase.java 2009-10-22 20:42:15 UTC (rev 95447)
@@ -48,12 +48,4 @@
{
return new JavassistTypeInfoFactory();
}
-
- // FIXME JBREFLECT-63
- @Override
- public void testSubClassAnnotations() {}
-
- // FIXME JBREFLECT-63
- @Override
- public void testSubClassArrayAnnotations() {}
}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list