9 Replies Latest reply on Apr 2, 2008 4:14 PM by Kabir Khan

    AOPConstructorJoinpoint::methodHasAnnotations is wrong

    Ales Justin Master

      When doing a check if current underlying context needs to be instantiated as an AOP proxy, we were looking in both cases - class and methods - if there is an INSTANCE scope metadata present.

      But in case I have this, adding annotations to property:

       <bean name="Bean6" class="org.jboss.test.microcontainer.support.SimpleBeanImpl">
       <property name="property">
       <annotation>@org.jboss.test.microcontainer.support.SomeNonIA</annotation>
       <annotation>@org.jboss.test.microcontainer.support.ContainsIA</annotation>
       <value>123</value>
       </property>
       </bean>
      

      this is called - a place where this xml annotations get put into metadata:
      KernelScopeInfo
       /**
       * Add annotations for a method
       *
       * @param classloader the classloader
       * @param mutable the mutable metadata
       * @param methodInfo the method info
       * @param annotations the annotations
       */
       private void addAnnotations(ClassLoader classloader, MemoryMetaDataLoader mutable, MethodInfo methodInfo, Set<AnnotationMetaData> annotations)
       {
       ScopeKey scope = new ScopeKey(CommonLevels.JOINPOINT_OVERRIDE, methodInfo.getName());
       MemoryMetaDataLoader loader = new MemoryMetaDataLoader(scope);
       addAnnotations(classloader, loader, annotations);
       mutable.addComponentMetaDataRetrieval(new MethodSignature(methodInfo), loader);
       }
      

      Property annotations are added to JOINPOINT_OVERRIDE level, not to INSTANCE.

      So, this really never worked in AOPConstructorJoinpoint - to get a proxy for beans that have annotations added to methods via xml.

      Whether property annotations are put to the wrong place, or we are doing a wrong level lookup. I suspect the other. :-)

      I'll fix code to use JOINPOINT_OVERRIDE level when checking whether methods have 'instance' metadata.