[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: aop-mc-int tests failing on annotation parsing

kabir.khan@jboss.com do-not-reply at jboss.com
Wed Mar 5 15:07:09 EST 2008


For http://jira.jboss.com/jira/browse/JBMICROCONT-250 the problem is that we are getting a proxy created although there are no aspects. Proxies cannot have their fields set. The reason the proxy is created is that the bean used in MapAnnotationTestCase.testCustomMapPreInstantiated() has method level annotations on the bean class


  | public class FromPreinstMapSimpleBean extends SimpleBean
  | {
  |    /** The serialVersionUID */
  |    private static final long serialVersionUID = 1L;
  | 
  |    @MapValue(
  |          value = {
  |             @EntryValue(
  |                   key=@Value(string = @StringValue("string1")),
  |                   value=@Value(string = @StringValue("string2"))
  |             ),
  |             @EntryValue(
  |                   key=@Value(string = @StringValue("string2")),
  |                   value=@Value(string = @StringValue("string1"))
  |             )
  |          },
  |          keyClass = "java.lang.String",
  |          valueClass = "java.lang.String"
  |    )
  |    public void setPreInstantiatedMap(CustomMap preInstantiatedMap)
  |    {
  |       super.setPreInstantiatedMap(preInstantiatedMap);
  |    }
  | ...
  | }
  | 

When AOPConstructorJoinPoint does its check to see if instance-level metadata exists

  |    private boolean hasMethodMetaData(MetaData metaData)
  |    {
  |       //Check for method annotations
  |       ClassInfo info = constructorInfo.getDeclaringClass();
  |       while (info != null)
  |       {
  |          MethodInfo[] methods = info.getDeclaredMethods();
  |          if (methods != null)
  |          {
  |             for (MethodInfo mi : methods)
  |             {
  |                if (methodHasAnnotations(metaData, mi))
  |                {
  |                   return true;
  |                }
  |             }
  |          }
  |          info = info.getSuperclass();
  |       }
  |       
  |       return false;
  |    }
  |    
  |    private boolean methodHasAnnotations(MetaData metaData, MethodInfo mi)
  |    {
  |       MethodSignature sig = new MethodSignature(mi);
  |       MetaData methodMD = metaData.getComponentMetaData(sig);
  |       if (methodMD != null)
  |       {
  |          return methodMD.getAnnotations() != MetaData.NO_ANNOTATIONS;
  |       }
  |       return false;
  |    }
  | 

methodHasAnnotations returns true. The methodMD contains only one retrieval, of type AnnotatedElementMetaDataLoader, which has annotations since they exist in the class itself. It should only return true if these annotations exist at instance level or lower


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4134391#4134391

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4134391



More information about the jboss-dev-forums mailing list