3 Replies Latest reply on Sep 20, 2012 8:42 AM by Kabir Khan

    org.apache.xml excluded from precompilation?

    Tom Cunningham Master

      I'm trying to patch over a bug in XMLBeans ( https://issues.apache.org/jira/browse/XMLBEANS-328 ) using pointcuts.       I've been struggling over the past couple of days to try to get aopc working on my class, even building a stub class that models the class structure of the class I'm trying to advise, which worked fine, but I still get a "no comp needed" when trying to aopc org.apache.xmlbeans.impl.store.Xobj.

       

      Today I set some breakpoints and discovered that it is being rejected because of the package name of the class :

       

      (from AspectManager.class)

      public boolean isNonAdvisableClassName(String classname)

         {

            if (ignoreClass(classname)) return true;

            if (includeClass(classname)) return false;

            if (excludeClass(classname)) return true;

            return (classname.startsWith("org.jboss.aop.") ||

                    classname.endsWith("$aop") ||

                    classname.startsWith("javassist") ||

                    classname.startsWith("org.jboss.util.") ||

                    classname.startsWith("gnu.trove.") ||

                    classname.startsWith("EDU.oswego.cs.dl.util.concurrent.") ||

                    classname.contains('.' + JoinPointGenerator.JOINPOINT_CLASS_PREFIX) ||

            // System classes

                    classname.startsWith("org.apache.tools.ant") ||

                    classname.startsWith("org.apache.crimson") ||

                    classname.startsWith("org.apache.xalan") ||

                    classname.startsWith("org.apache.xml") ||

      ....

       

      Everything starting with org.apache.xml seems to be filtered out - which org.apache.xmlbeans.impl.store would fall under.     Is there a reason why "org.apache.xmlbeans" should be blocked, and not just "org.apache.xml."?       Is there a way I can short circuit this by getting includeClass(classname) to return true?     I'm calling aopc through the ant task :

       

                  <aopc compilerclasspathref="build.classpath" verbose="true">
                              <classpath path="${aopc.xbean.classes.dir}"/>
                              <src path="${aopc.xbean.classes.dir}"/>
                              <include name="Foo.class"/>
                              <include name="org/apache/xmlbeans/impl/store/Xobj$SoapBodyXobj.class"/>
                              <include name="org/apache/xmlbeans/impl/store/Xobj.class"/>
                              <aoppath path="${aop.resources.dir}/META-INF/jboss-aop.xml"/>
                              <aopclasspath path="${aop.classes.dir}"/>
                      </aopc>
      
        • 1. Re: org.apache.xml excluded from precompilation?
          Kabir Khan Master

          It has been some years since looking at this code but you're right. The reason org.apache.xml and other bits are excluded is they are things used by jboss aop internally. However there should be a '.' after the package names. It looks like a include should work, but that you are using the wrong format. Looking at https://svn.jboss.org/repos/jbossas/tags/JBPAPP_4_2_0_GA/aspects/src/resources/META-INF/jboss-service.xml (from jboss 4.2) to refresh my memory I think it should be:

           

          <include name="org.apache.xmlbeans.impl.store.Xobj$SoapBodyXobj"/>

           

          There should not be a '.class' at the end, and the separator is '.'.

          • 2. Re: org.apache.xml excluded from precompilation?
            Tom Cunningham Master

            Kabir,

             

            Thanks for the reply - I took a look, and I'm pretty sure the format I'm using is correct for an ant build.xml - it doesn't work the other way around and I see the code in AopC.java (logAndAddFilesToCompile) where it is specifically looking for file names ending in .class rather than package name/class name.

             

            Just in case anyone runs into something like this in the future where they want to advise a class that's in the list of packages that are specifically excluded, here's how I solved it :

             

                            <aopc compilerclasspathref="build.classpath" verbose="true">
                                    <classpath path="${aopc.xbean.classes.dir}"/>
                                    <src path="${aopc.xbean.classes.dir}"/>
                                    <include name="org/apache/xmlbeans/impl/store/Xobj.class"/>
                                    <sysproperty key="jboss.aop.include" value="org.apache.xmlbeans.impl.store.Xobj"/>
            
                                    <aoppath path="${aop.resources.dir}/META-INF/jboss-aop.xml"/>
                                    <aopclasspath path="${aop.classes.dir}"/>
                            </aopc>
            

             

            Adding the <sysproperty/> line gets the jboss.aop.include passed into AopC.java's system property which are passed through java on to Compiler.java and then into AspectManager.java's list of specifically included classes.

            • 3. Re: org.apache.xml excluded from precompilation?
              Kabir Khan Master

              Apologies, I didn't see that you were using aopc, and confused it with the loadtime weaving configuration of the aspect manager in AS 4/5.

              What you did is correct, that system property has the effect of doing what you describe.

               

              Hope I didn't confuse you too much!