[jboss-cvs] JBossAS SVN: r60812 - in projects/aop/trunk/aop: src/main/org/jboss/aop and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Feb 22 19:57:49 EST 2007


Author: kabir.khan at jboss.com
Date: 2007-02-22 19:57:49 -0500 (Thu, 22 Feb 2007)
New Revision: 60812

Added:
   projects/aop/trunk/aop/src/resources/test/postweavingmixins/
   projects/aop/trunk/aop/src/resources/test/postweavingmixins/jboss-aop.xml
   projects/aop/trunk/aop/src/resources/test/postweavingmixins/mixins-aop.xml
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/postweavingmixins/
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/postweavingmixins/MarkerInterface.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/postweavingmixins/Mixin.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/postweavingmixins/MixinInterface.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/postweavingmixins/PostWeavingMixinsTestCase.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/postweavingmixins/SanityInterceptor.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/postweavingmixins/WovenPOJO.java
Modified:
   projects/aop/trunk/aop/build-tests-jdk50.xml
   projects/aop/trunk/aop/src/main/org/jboss/aop/ClassAdvisor.java
Log:
[JBAOP-365] Fix error populating mixin methods when intitialising the advisor for an already woven class, that has extra mixin information available at runtime

Modified: projects/aop/trunk/aop/build-tests-jdk50.xml
===================================================================
--- projects/aop/trunk/aop/build-tests-jdk50.xml	2007-02-23 00:36:05 UTC (rev 60811)
+++ projects/aop/trunk/aop/build-tests-jdk50.xml	2007-02-23 00:57:49 UTC (rev 60812)
@@ -95,7 +95,7 @@
          <path refid="xdoclet.xdoclet.classpath"/>
       </path>
 
-      <!-- 
+      <!--
       		Settable in local.properties:
       			-jrockit.home: location of JRockit JVM
       			-jdk14.executable: Full path to a JDK 1.4 java.exe (Needed for the JDK 1.4 tests)
@@ -103,7 +103,7 @@
       			-debug: if set, -Djboss.aop.debug.classes=true for the tests; otherwise it is false
        -->
       <property file="local.properties"/>
-		
+
    <available file="${jrockit.home}/jre/lib/managementapi.jar" property="JROCKIT_API_AVAILABLE" value="managementapi.jar"/>
    <available file="${jrockit.home}/jre/lib/management-agent.jar" property="JROCKIT_API_AVAILABLE" value="rt.jar"/>
 	   <condition property="jboss.aop.debug.classes" value="true">
@@ -232,7 +232,7 @@
         basedir="${build.tests.classes}" includes="org/jboss/test/aop/jdk15/dynamic/common/scenario/**"/>
       <delete dir="${build.tests.classes}/org/jboss/test/aop/jdk15/dynamic/common/scenario"/>
    </target>
-   
+
    <!-- ================================================================== -->
    <!-- Cleaning                                                           -->
    <!-- ================================================================== -->
@@ -471,6 +471,11 @@
          <param name="caller" value="precompiled-tests"/>
          <param name="exclude" value="**/GenAdvisorOverrideTestCase.class"/>
       </antcall>
+
+      <antcall target="_run-precompiled-test" inheritRefs="true">
+         <param name="test" value="postweavingmixins"/>
+         <param name="caller" value="precompiled-tests"/>
+      </antcall>
    </target>
 
    <!-- ==================================================================================== -->
@@ -497,8 +502,14 @@
          <param name="caller" value="non-optimized-precompiled-tests"/>
          <param name="exclude" value="**/GenAdvisorOverrideTestCase.class"/>
       </antcall>
+
+       <!-- This should only be run using compile-time weaving -->
+      <antcall target="_run-precompiled-test" inheritRefs="true">
+         <param name="test" value="postweavingmixins"/>
+         <param name="caller" value="non-optimized-precompiled-tests"/>
+      </antcall>
    </target>
-   
+
    <target name="non-optimized-precompiled-test" depends="init">
       <taskdef name="aopc" classname="org.jboss.aop.ant.AopC" classpathref="jboss.aop.classpath"/>
       <antcall target="_run-precompiled-test" inheritRefs="true">
@@ -537,16 +548,22 @@
          <param name="caller" value="precompiled-genadvisor-tests"/>
          <param name="exclude" value="**/OverrideTestCase.class"/>
       </antcall>
-      <antcall target="_run-javaagent-test" inheritRefs="true">
+      <antcall target="_run-precompiled-test" inheritRefs="true">
          <param name="test" value="nameddomain"/>
-         <param name="caller" value="javaagent-genadvisor-tests"/>
+         <param name="caller" value="precompiled-genadvisor-tests"/>
       </antcall>
+       <!-- This should only be run using compile-time weaving -->
+      <antcall target="_run-precompiled-test" inheritRefs="true">
+         <param name="test" value="postweavingmixins"/>
+         <param name="caller" value="precompiled-genadvisor-tests"/>
+      </antcall>
 
       <!-- Add tests in _base-precompiled-tests unless they should only be run in this weaving mode -->
       <antcall target="_base-jdk50-tests" inheritRefs="true">
          <param name="caller" value="precompiled-genadvisor-tests"/>
          <param name="test-target" value="_run-precompiled-test"/>
       </antcall>
+
    </target>
 
    <target name="precompiled-test" depends="init">
@@ -636,7 +653,7 @@
             <isset property="use.annotations"/>
          </not>
       </condition>
- 
+
       <!-- determine output directory from weaving mode -->
       <mkdir dir="${build.reports}"/>
 
@@ -735,7 +752,7 @@
 
       <property name="report.dir" value="${build.reports}"/>
       <mkdir dir="${report.dir}"/>
-      
+
       <junit printsummary="yes" fork="yes" haltonfailure="no">
          <sysproperty key="jboss.aop.path" value="${source.res}/test/jdk15/jboss-aop.xml"/>
          <sysproperty key="jboss.aop.class.path" value="${build.tests.classes}"/>
@@ -754,7 +771,7 @@
          <test todir="${report.dir}" name="org.jboss.test.aop.jdk15.AOPTester"/>
          <test todir="${report.dir}" name="org.jboss.test.aop.jdk15annotated.AnnotatedTestCase"/>
       </junit>
-   
+
       <junit printsummary="yes" fork="yes" haltonfailure="no">
          <sysproperty key="jboss.aop.path" value="${source.res}/test/jdk15/dynamic/prepareAll/jboss-aop.xml"/>
          <sysproperty key="scenario.jar" value="${build.tests.classes}/org/jboss/test/aop/jdk15/dynamic/common/scenario.jar"/>
@@ -1191,7 +1208,7 @@
       </antcall>
 
    </target>
-   
+
    <target name="jrockit-test" depends="compile-test-classes" if="JROCKIT_API_AVAILABLE">
          <antcall target="_run-jrockit-test" inheritRefs="true">
             <param name="test" value="${test}"/>

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/ClassAdvisor.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/ClassAdvisor.java	2007-02-23 00:36:05 UTC (rev 60811)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/ClassAdvisor.java	2007-02-23 00:57:49 UTC (rev 60812)
@@ -117,11 +117,11 @@
    /** @deprecated Use fieldWriteInfos instead */
    private Interceptor[][] fieldWriteInterceptors;
    private FieldInfo[] fieldWriteInfos;
-   
-   
+
+
    protected Field[] advisedFields;
    //PER_JOINPOINT aspects for static fields or PER_CLASS_JOINPOINT aspects
-   //all apply to fields, and we need this since the same aspect should be used for 
+   //all apply to fields, and we need this since the same aspect should be used for
    //read and write
    private HashMap fieldAspectsWithNoInstance = new HashMap();
 
@@ -164,7 +164,7 @@
             }
          }
       }
-      
+
       Object aspect = map.get(joinpoint);
       if (aspect == null)
       {
@@ -178,7 +178,7 @@
             }
          }
       }
-      
+
       return aspect;
    }
 
@@ -248,13 +248,13 @@
    {
       return fieldWriteInfos;
    }
-   
+
    public TLongObjectHashMap getMethodInterceptors()
    {
       return methodInterceptors;
    }
 
-   
+
    /**
     * Constructs a new helper.
     */
@@ -388,15 +388,18 @@
             for (int j = 0; j < interfaces.length; j++)
             {
                Class intf = Thread.currentThread().getContextClassLoader().loadClass(interfaces[j]);
-               Method[] methods = intf.getMethods();
-               for (int k = 0; k < methods.length; k++)
+               if (intf.isAssignableFrom(clazz))//This is a fix for JBAOP-365. Class may have been woven, with the extra mixin information only available at init time
                {
-                  //Put wrapped method in the class itself into the unadvisedMethods map
-                  //   String wrappedName = ClassAdvisor.notAdvisedMethodName(clazz.getName(), methods[k].getName());
-                  //   Method method = clazz.getMethod(wrappedName, methods[k].getParameterTypes());
-                  Method method = getMethod(clazz, methods[k]);
-                  long hash = MethodHashing.methodHash(method);
-                  unadvisedMethods.put(hash, method);
+                  Method[] methods = intf.getMethods();
+                  for (int k = 0; k < methods.length; k++)
+                  {
+                     //Put wrapped method in the class itself into the unadvisedMethods map
+                     //   String wrappedName = ClassAdvisor.notAdvisedMethodName(clazz.getName(), methods[k].getName());
+                     //   Method method = clazz.getMethod(wrappedName, methods[k].getParameterTypes());
+                     Method method = getMethod(clazz, methods[k]);
+                     long hash = MethodHashing.methodHash(method);
+                     unadvisedMethods.put(hash, method);
+                  }
                }
             }
          }
@@ -427,7 +430,7 @@
       for (int i = 0; i < advisedFields.length; i++)
       {
          Field field = advisedFields[i];
-         
+
          if ((!write && binding.getPointcut().matchesGet(this, field))
          || (write && binding.getPointcut().matchesSet(this, field)))
          {
@@ -435,7 +438,7 @@
             adviceBindings.add(binding);
             binding.addAdvisor(this);
             FieldInfo info = (FieldInfo)newFieldInfos.get(i);
-            pointcutResolved(info, binding, new FieldJoinpoint(field));         
+            pointcutResolved(info, binding, new FieldJoinpoint(field));
          }
       }
    }
@@ -496,7 +499,7 @@
          }
 
          chain.add(info);
-         
+
          try
          {
             Field infoField = clazz.getDeclaredField(FieldAccessTransformer.getFieldReadInfoFieldName(advisedFields[i].getName()));
@@ -511,7 +514,7 @@
          {
             throw new RuntimeException(e);
          }
-         
+
       }
       return chain;
    }
@@ -538,7 +541,7 @@
          }
 
          chain.add(info);
-         
+
          try
          {
             Field infoField = clazz.getDeclaredField(FieldAccessTransformer.getFieldWriteInfoFieldName(advisedFields[i].getName()));
@@ -553,7 +556,7 @@
          {
             throw new RuntimeException(e);
          }
-         
+
       }
       return chain;
    }
@@ -563,7 +566,7 @@
       for (int i = 0; i < newFieldInfos.size(); i++)
       {
          FieldInfo info = (FieldInfo)newFieldInfos.get(i);
-         ArrayList list = info.getInterceptorChain();        
+         ArrayList list = info.getInterceptorChain();
          Interceptor[] interceptors = null;
          if (list.size() > 0)
          {
@@ -578,7 +581,7 @@
       for (int i = 0; i < newFieldInfos.size(); i++)
       {
          FieldInfo info = (FieldInfo)newFieldInfos.get(i);
-         ArrayList list = info.getInterceptorChain();        
+         ArrayList list = info.getInterceptorChain();
          Interceptor[] interceptors = null;
          if (list.size() > 0)
          {
@@ -596,7 +599,7 @@
       ArrayList newFieldWriteInfos = initializeFieldWriteChain();
       ArrayList newConstructorInfos = initializeConstructorChain();
       ArrayList newConstructionInfos = initializeConstructionChain();
-      
+
       synchronized (manager.getBindings())
       {
          Iterator it = manager.getBindings().values().iterator();
@@ -620,9 +623,9 @@
       fieldWriteInfos = (FieldInfo[]) newFieldWriteInfos.toArray(new FieldInfo[newFieldWriteInfos.size()]);
       constructorInfos = (ConstructorInfo[]) newConstructorInfos.toArray(new ConstructorInfo[newConstructorInfos.size()]);
       constructionInfos = (ConstructionInfo[]) newConstructionInfos.toArray(new ConstructionInfo[newConstructionInfos.size()]);
-      
+
       populateInterceptorsFromInfos();
-      
+
       doesHaveAspects = adviceBindings.size() > 0;
       // Notify observer about this change
       if (this.interceptorChainObserver != null)
@@ -631,7 +634,7 @@
                constructorInterceptors, methodInterceptors);
       }
    }
-   
+
    private MethodByMethodInfo initializeCallerInterceptorsMap(long callingMethodHash, String calledClass, long calledMethodHash, Method callingMethod, Method calledMethod) throws Exception
    {
       HashMap calledClassesMap = (HashMap) methodCalledByMethodInterceptors.get(callingMethodHash);
@@ -648,7 +651,7 @@
       }
       //The standard MethodCalledByXXXXInvocation class calls by reflection and needs access
       calledMethod.setAccessible(true);
-      
+
       Class calledClazz = Thread.currentThread().getContextClassLoader().loadClass(calledClass);
       MethodByMethodInfo info = new MethodByMethodInfo(this, calledClazz, calledMethod, callingMethodHash, calledMethodHash, null);
       calledMethodsMap.put(calledMethodHash, info);
@@ -656,7 +659,7 @@
    }
 
    private ConByMethodInfo initializeConCalledByMethodInterceptorsMap(long callingMethodHash, String calledClass, long calledConHash, Constructor calledCon) throws Exception
-   {       
+   {
       HashMap calledClassesMap = (HashMap) conCalledByMethodInterceptors.get(callingMethodHash);
       if (calledClassesMap == null)
       {
@@ -755,7 +758,7 @@
          return new ConByConInfo(this, calledClazz, callingIndex, calledCon, calledConHash, null, null);
       }
    }
-   
+
    protected void rebuildCallerInterceptors() throws Exception
    {
       long[] callingKeys = methodCalledByMethodInterceptors.keys();
@@ -879,7 +882,7 @@
       }
       finalizeMethodCalledByMethodInterceptorChain(info);
    }
-   
+
    protected void finalizeMethodCalledByMethodInterceptorChain(MethodByMethodInfo info)
    {
       ArrayList list = info.getInterceptorChain();
@@ -903,7 +906,7 @@
       }
       finalizeConCalledByMethodInterceptorChain(info);
    }
-   
+
    protected void finalizeConCalledByMethodInterceptorChain(ConByMethodInfo info)
    {
       ArrayList list = info.getInterceptorChain();
@@ -951,7 +954,7 @@
       }
       finalizeMethodCalledByConInterceptorChain(info);
    }
-   
+
    protected void finalizeMethodCalledByConInterceptorChain(MethodByConInfo info)
    {
       ArrayList list = info.getInterceptorChain();
@@ -1027,7 +1030,7 @@
          ClassMetaDataBinding data = (ClassMetaDataBinding) classMetaDataBindings.get(i);
          bindClassMetaData(data);
       }
-      
+
       deployAnnotationOverrides();
    }
 
@@ -1055,8 +1058,8 @@
          doesHaveAspects = false;
          rebuildInterceptors();
       }
-      
-      
+
+
    }
 
    private void initializeEmptyCallerChain(long callingMethodHash, String calledClass, long calledMethodHash) throws Exception
@@ -1339,20 +1342,20 @@
       !isWithoutAdvisement(method.getName()) &&
       !Modifier.isAbstract(modifiers) &&
       !Modifier.isNative(modifiers) &&
-      !(method.getName().equals("_getAdvisor") && 
-            method.getParameterTypes().length == 0 && 
+      !(method.getName().equals("_getAdvisor") &&
+            method.getParameterTypes().length == 0 &&
             method.getReturnType().equals(Advisor.class)) &&
-      !(method.getName().equals("_getClassAdvisor") && 
-            method.getParameterTypes().length == 0 && 
+      !(method.getName().equals("_getClassAdvisor") &&
+            method.getParameterTypes().length == 0 &&
             method.getReturnType().equals(Advisor.class)) &&
-      !(method.getName().equals("_getInstanceAdvisor") && 
+      !(method.getName().equals("_getInstanceAdvisor") &&
             method.getParameterTypes().length == 0 &&
             method.getReturnType().equals(InstanceAdvisor.class)) &&
-      !(method.getName().equals("_setInstanceAdvisor") && 
-            method.getParameterTypes().length == 1 && 
+      !(method.getName().equals("_setInstanceAdvisor") &&
+            method.getParameterTypes().length == 1 &&
             method.getParameterTypes()[0].equals(InstanceAdvisor.class)));
    }
-   
+
    private void populateFieldTable(ArrayList fields, Class superclass)
    throws Exception
    {
@@ -1515,7 +1518,7 @@
       //Javassist doesn't like this in a field initialiser hence this method
       return new WeakReference(resolveCallerMethodInfo(callingMethodHash, calledClass, calledMethodHash));
    }
-   
+
    public ConByMethodInfo resolveCallerConstructorInfo(long callingMethodHash, String calledClass, long calledConHash)
    {
       if (System.getSecurityManager() == null)
@@ -1563,7 +1566,7 @@
          throw new RuntimeException(x);
       }
    }
-   
+
    public WeakReference resolveCallerConstructorInfoAsWeakReference(long callingMethodHash, String calledClass, long calledConHash)
    {
       //Javassist doesn't like this in a field initialiser hence this method
@@ -1593,7 +1596,7 @@
          if (calledMethod == null) throw new RuntimeException("Unable to figure out calledmethod of a caller pointcut");
 
          boolean matched = false;
-         
+
          synchronized (manager.getBindings())
          {
             Iterator it = manager.getBindings().values().iterator();
@@ -1625,7 +1628,7 @@
       //Javassist doesn't like this in a field initialiser hence this method
       return new WeakReference(resolveConstructorCallerMethodInfo(callingIndex, calledClass, calledMethodHash));
    }
-   
+
    public ConByConInfo resolveConstructorCallerConstructorInfo(int callingIndex, String calledClass, long calledConHash)
    {
       if (System.getSecurityManager() == null)
@@ -1788,14 +1791,14 @@
    {
       return invokeConCalledByMethod((ConByMethodInfo)info, callingObject, args);
    }
-   
+
    public Object invokeConCalledByMethod(ConByMethodInfo info, Object callingObject, Object[] args)
    throws Throwable
    {
       ConstructorCalledByMethodInvocation invocation = new ConstructorCalledByMethodInvocation(info, callingObject, args, info.getInterceptors());
       return invocation.invokeNext();
    }
-   
+
    /**
     *@deprecated
     */
@@ -1804,7 +1807,7 @@
    {
       return invokeConstructorCaller((MethodByConInfo)info, null, target, args);
    }
-   
+
    /**
     *@deprecated
     */
@@ -1813,13 +1816,13 @@
    {
       return invokeConstructorCaller((MethodByConInfo)info, callingObject, target, args);
    }
-   
+
    /**
     * @deprecated
-    * 
+    *
     * Prefer using the version with <code>callingObject</code> instead of this one,
     * since this object is available for call invocations made inside constructors.
-    * 
+    *
     * @see #invokeConstructorCaller(MethodByConInfo, Object, Object, Object[])
     */
    public Object invokeConstructorCaller(MethodByConInfo info, Object target, Object[] args)
@@ -1827,7 +1830,7 @@
    {
       return this.invokeConstructorCaller(info, null, target, args);
    }
-   
+
    public Object invokeConstructorCaller(MethodByConInfo info, Object callingObject, Object target, Object[] args)
    throws Throwable
    {
@@ -1844,7 +1847,7 @@
    {
       return invokeConCalledByCon((ConByConInfo)info, null, args);
    }
-   
+
    /**
     *@deprecated
     */
@@ -1853,13 +1856,13 @@
    {
       return invokeConCalledByCon((ConByConInfo)info, callingObject, args);
    }
-   
+
    /**
     * @deprecated
-    * 
+    *
     * Prefer using the version with <code>callingObject</code> instead of this one,
     * since this object is available for call invocations made inside constructors.
-    * 
+    *
     * @see #invokeConCalledByCon(ConByConInfo, Object, Object[])
     */
    public Object invokeConCalledByCon(ConByConInfo info, Object[] args)
@@ -1867,7 +1870,7 @@
    {
       return invokeConCalledByCon(info, null, args);
    }
-   
+
    public Object invokeConCalledByCon(ConByConInfo info, Object callingObject, Object[] args)
    throws Throwable
    {
@@ -2011,7 +2014,7 @@
 
    // interceptor chain observer
    private InterceptorChainObserver interceptorChainObserver;
-   
+
    /**
     * Returns the interceptor chain observer associated with this advisor.
     */
@@ -2019,7 +2022,7 @@
    {
       return this.interceptorChainObserver;
    }
-   
+
    /**
     * Defines the interceptor chain observer associated with this advisor.
     * @param observer the interceptor chain observer.
@@ -2046,20 +2049,20 @@
       fieldWriteInterceptors = new Interceptor[fieldWriteInfos.length][];
       for (int i = 0 ; i < fieldWriteInfos.length ; i++)
       {
-         fieldWriteInterceptors[i] = fieldWriteInfos[i].getInterceptors(); 
+         fieldWriteInterceptors[i] = fieldWriteInfos[i].getInterceptors();
       }
       constructionInterceptors = new Interceptor[constructionInfos.length][];
       for (int i = 0 ; i < constructionInfos.length ; i++)
       {
-         constructionInterceptors[i] = constructionInfos[i].getInterceptors(); 
+         constructionInterceptors[i] = constructionInfos[i].getInterceptors();
       }
 
    }
-   
+
    interface ResolveCallerConstuctorInfoAction
    {
       ConByMethodInfo resolveInfo(ClassAdvisor advisor, long callingMethodHash, String calledClass, long calledConHash);
-      
+
       ResolveCallerConstuctorInfoAction PRIVILEGED = new ResolveCallerConstuctorInfoAction()
       {
          public ConByMethodInfo resolveInfo(final ClassAdvisor advisor, final long callingMethodHash, final String calledClass, final long calledConHash)
@@ -2077,8 +2080,8 @@
             catch (PrivilegedActionException e)
             {
                Exception ex = e.getException();
-               if (ex instanceof RuntimeException) 
-               { 
+               if (ex instanceof RuntimeException)
+               {
                   throw (RuntimeException)ex;
                }
                throw new RuntimeException(ex);
@@ -2098,7 +2101,7 @@
    interface ResolveCallerMethodInfoAction
    {
       MethodByMethodInfo resolveInfo(ClassAdvisor advisor, long callingMethodHash, String calledClass, long calledMethodHash);
-      
+
       ResolveCallerMethodInfoAction PRIVILEGED = new ResolveCallerMethodInfoAction()
       {
          public MethodByMethodInfo resolveInfo(final ClassAdvisor advisor, final long callingMethodHash, final String calledClass, final long calledMethodHash)
@@ -2116,8 +2119,8 @@
             catch (PrivilegedActionException e)
             {
                Exception ex = e.getException();
-               if (ex instanceof RuntimeException) 
-               { 
+               if (ex instanceof RuntimeException)
+               {
                   throw (RuntimeException)ex;
                }
                throw new RuntimeException(ex);
@@ -2137,7 +2140,7 @@
    interface ResolveConstructorCallerMethodInfoAction
    {
       MethodByConInfo resolveInfo(ClassAdvisor advisor, int callingIndex, String calledClass, long calledMethodHash);
-      
+
       ResolveConstructorCallerMethodInfoAction PRIVILEGED = new ResolveConstructorCallerMethodInfoAction()
       {
          public MethodByConInfo resolveInfo(final ClassAdvisor advisor, final int callingIndex, final String calledClass, final long calledMethodHash)
@@ -2155,8 +2158,8 @@
             catch (PrivilegedActionException e)
             {
                Exception ex = e.getException();
-               if (ex instanceof RuntimeException) 
-               { 
+               if (ex instanceof RuntimeException)
+               {
                   throw (RuntimeException)ex;
                }
                throw new RuntimeException(ex);
@@ -2176,7 +2179,7 @@
    interface ResolveConstructorCallerConstructorInfoAction
    {
       ConByConInfo resolveInfo(ClassAdvisor advisor, int callingIndex, String calledClass, long calledConHash);
-      
+
       ResolveConstructorCallerConstructorInfoAction PRIVILEGED = new ResolveConstructorCallerConstructorInfoAction()
       {
          public ConByConInfo resolveInfo(final ClassAdvisor advisor, final int callingIndex, final String calledClass, final long calledConHash)
@@ -2194,8 +2197,8 @@
             catch (PrivilegedActionException e)
             {
                Exception ex = e.getException();
-               if (ex instanceof RuntimeException) 
-               { 
+               if (ex instanceof RuntimeException)
+               {
                   throw (RuntimeException)ex;
                }
                throw new RuntimeException(ex);
@@ -2214,7 +2217,7 @@
    interface RebuildInterceptorsAction
    {
       void rebuildInterceptors(ClassAdvisor advisor);
-      
+
       RebuildInterceptorsAction PRIVILEGED = new RebuildInterceptorsAction()
       {
          public void rebuildInterceptors(final ClassAdvisor advisor)
@@ -2233,8 +2236,8 @@
             catch (PrivilegedActionException e)
             {
                Exception ex = e.getException();
-               if (ex instanceof RuntimeException) 
-               { 
+               if (ex instanceof RuntimeException)
+               {
                   throw (RuntimeException)ex;
                }
                throw new RuntimeException(ex);

Added: projects/aop/trunk/aop/src/resources/test/postweavingmixins/jboss-aop.xml
===================================================================
--- projects/aop/trunk/aop/src/resources/test/postweavingmixins/jboss-aop.xml	                        (rev 0)
+++ projects/aop/trunk/aop/src/resources/test/postweavingmixins/jboss-aop.xml	2007-02-23 00:57:49 UTC (rev 60812)
@@ -0,0 +1,5 @@
+<aop>
+   <bind pointcut="execution(* org.jboss.test.aop.postweavingmixins.WovenPOJO->method())">
+      <interceptor class="org.jboss.test.aop.postweavingmixins.SanityInterceptor"/>
+   </bind>
+</aop>
\ No newline at end of file

Added: projects/aop/trunk/aop/src/resources/test/postweavingmixins/mixins-aop.xml
===================================================================
--- projects/aop/trunk/aop/src/resources/test/postweavingmixins/mixins-aop.xml	                        (rev 0)
+++ projects/aop/trunk/aop/src/resources/test/postweavingmixins/mixins-aop.xml	2007-02-23 00:57:49 UTC (rev 60812)
@@ -0,0 +1,16 @@
+<aop>
+   <introduction class="org.jboss.test.aop.postweavingmixins.WovenPOJO">
+      <mixin>
+         <interfaces>
+            org.jboss.test.aop.postweavingmixins.MixinInterface
+         </interfaces>
+         <class>org.jboss.test.aop.postweavingmixins.Mixin</class>
+      </mixin>
+   </introduction>
+   
+   <introduction class="org.jboss.test.aop.postweavingmixins.WovenPOJO">
+      <interfaces>
+         org.jboss.test.aop.postweavingmixins.MarkerInterface
+      </interfaces>
+   </introduction>
+</aop>
\ No newline at end of file

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/postweavingmixins/MarkerInterface.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/postweavingmixins/MarkerInterface.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/postweavingmixins/MarkerInterface.java	2007-02-23 00:57:49 UTC (rev 60812)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.aop.postweavingmixins;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface MarkerInterface
+{
+
+}

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/postweavingmixins/Mixin.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/postweavingmixins/Mixin.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/postweavingmixins/Mixin.java	2007-02-23 00:57:49 UTC (rev 60812)
@@ -0,0 +1,40 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.aop.postweavingmixins;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class Mixin implements MixinInterface
+{
+   public Mixin(WovenPOJO pojo)
+   {
+      
+   }
+   
+   public void mixinMethod()
+   {
+   }
+
+}

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/postweavingmixins/MixinInterface.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/postweavingmixins/MixinInterface.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/postweavingmixins/MixinInterface.java	2007-02-23 00:57:49 UTC (rev 60812)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.aop.postweavingmixins;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface MixinInterface
+{
+   void mixinMethod();
+}

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/postweavingmixins/PostWeavingMixinsTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/postweavingmixins/PostWeavingMixinsTestCase.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/postweavingmixins/PostWeavingMixinsTestCase.java	2007-02-23 00:57:49 UTC (rev 60812)
@@ -0,0 +1,108 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.aop.postweavingmixins;
+
+import java.net.URL;
+
+import org.jboss.test.aop.AOPTestWithSetup;
+import org.jboss.aop.AspectXmlLoader;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Test for JBAOP-365. Only for use with compile-time weaving, and then checking that when making
+ * mixins/introductions available at runtime we do not fail
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class PostWeavingMixinsTestCase extends AOPTestWithSetup
+{
+   public static void main(String[] args)
+   {
+      junit.textui.TestRunner.run(PostWeavingMixinsTestCase.class);
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("PostWeavingMixinsTestCase");
+      suite.addTestSuite(PostWeavingMixinsTestCase.class);
+      return suite;
+   }
+   // Constants ----------------------------------------------------
+   // Attributes ---------------------------------------------------
+
+   // Static -------------------------------------------------------
+
+   // Constructors -------------------------------------------------
+   public PostWeavingMixinsTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testMixinsInRuntimeConfig() throws Exception
+   {
+      //Deploy the mixins-aop.xml file before loading our woven pojo classs
+      //we deploy it programatically simply to keep the build.xml tidy
+      URL url = getUrl();
+      AspectXmlLoader.deployXML(url);
+
+      WovenPOJO pojo;
+      try
+      {
+         pojo = new WovenPOJO();
+      }
+      catch (Throwable e)
+      {
+         throw new RuntimeException("CLass could not be loaded", e);
+      }
+
+      SanityInterceptor.invoked = false;
+      pojo.method();
+      assertTrue(SanityInterceptor.invoked);
+
+      if (pojo instanceof MarkerInterface)
+      {
+         fail("WovenPOJO should not implement MarkerInterface. This test should ONLY be run with compile time weaving");
+      }
+
+      if (pojo instanceof MixinInterface)
+      {
+         fail("WovenPOJO should not implement MarkerInterface. This test should ONLY be run with compile time weaving");
+      }
+   }
+
+   private URL getUrl() throws Exception
+   {
+      URL url = this.getClass().getProtectionDomain().getCodeSource().getLocation();
+      System.out.println("class url: " + url);
+      String location = url.toString();
+      int index = location.indexOf("/output/tests.classes");
+      location = location.substring(0, index);
+
+      location = location + "/src/resources/test/postweavingmixins/mixins-aop.xml";
+      url = new URL(location);
+      System.out.println("xml url:   " + url);
+      return url;
+   }
+
+}
\ No newline at end of file

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/postweavingmixins/SanityInterceptor.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/postweavingmixins/SanityInterceptor.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/postweavingmixins/SanityInterceptor.java	2007-02-23 00:57:49 UTC (rev 60812)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.aop.postweavingmixins;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class SanityInterceptor implements Interceptor
+{
+   public static boolean invoked;
+   public String getName()
+   {
+      return null;
+   }
+
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+      invoked = true;
+      return invocation.invokeNext();
+   }
+
+}

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/postweavingmixins/WovenPOJO.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/postweavingmixins/WovenPOJO.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/postweavingmixins/WovenPOJO.java	2007-02-23 00:57:49 UTC (rev 60812)
@@ -0,0 +1,33 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.aop.postweavingmixins;
+
+/**
+ * This is a POJO that has been woven, but with no introductions/mixins
+ * We will make the mixins/introductions available at runtime to test JBAOP-365
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class WovenPOJO
+{
+   public void method() {}
+}




More information about the jboss-cvs-commits mailing list