6 Replies Latest reply on Jul 27, 2005 6:29 AM by Kabir Khan

    Exception instrumenting

    Ben Livshits Newbie

       

      Exception in thread "main" java.lang.ExceptionInInitializerError
       at sun.misc.Unsafe.ensureClassInitialized(Native Method)
       at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
       at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
       at java.lang.reflect.Field.acquireFieldAccessor(Field.java:917)
       at java.lang.reflect.Field.getFieldAccessor(Field.java:898)
       at java.lang.reflect.Field.get(Field.java:357)
       at org.jboss.aop.AspectManager.getTempClassAdvisorIfNotExist(AspectManager.java:930)
       at org.jboss.aop.pointcut.CallMatcher.visit(CallMatcher.java:53)
       at org.jboss.aop.pointcut.ast.ASTCall.jjtAccept(ASTCall.java:21)
       at org.jboss.aop.pointcut.MatcherHelper.visit(MatcherHelper.java:103)
       at org.jboss.aop.pointcut.ast.ASTSub.jjtAccept(ASTSub.java:17)
       at org.jboss.aop.pointcut.MatcherHelper.visit(MatcherHelper.java:83)
       at org.jboss.aop.pointcut.ast.ASTBoolean.jjtAccept(ASTBoolean.java:17)
       at org.jboss.aop.pointcut.MatcherHelper.visit(MatcherHelper.java:73)
       at org.jboss.aop.pointcut.MatcherHelper.matches(MatcherHelper.java:68)
       at org.jboss.aop.pointcut.PointcutExpression.matchesCall(PointcutExpression.java:205)
       at org.jboss.aop.ClassAdvisor.resolveCallerMethodInfo(ClassAdvisor.java:1293)
       at org.jgap.Chromosome.<clinit>(Unknown Source)
       at sun.misc.Unsafe.ensureClassInitialized(Native Method)
       at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
       at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
       at java.lang.reflect.Field.acquireFieldAccessor(Field.java:917)
       at java.lang.reflect.Field.getFieldAccessor(Field.java:898)
       at java.lang.reflect.Field.get(Field.java:357)
       at org.jboss.aop.AspectManager.getTempClassAdvisorIfNotExist(AspectManager.java:930)
       at org.jboss.aop.pointcut.CallMatcher.visit(CallMatcher.java:53)
       at org.jboss.aop.pointcut.ast.ASTCall.jjtAccept(ASTCall.java:21)
       at org.jboss.aop.pointcut.MatcherHelper.visit(MatcherHelper.java:103)
       at org.jboss.aop.pointcut.ast.ASTSub.jjtAccept(ASTSub.java:17)
       at org.jboss.aop.pointcut.MatcherHelper.visit(MatcherHelper.java:83)
       at org.jboss.aop.pointcut.ast.ASTBoolean.jjtAccept(ASTBoolean.java:17)
       at org.jboss.aop.pointcut.MatcherHelper.visit(MatcherHelper.java:73)
       at org.jboss.aop.pointcut.MatcherHelper.matches(MatcherHelper.java:68)
       at org.jboss.aop.pointcut.PointcutExpression.matchesCall(PointcutExpression.java:205)
       at org.jboss.aop.ClassAdvisor.resolveCallerMethodInfo(ClassAdvisor.java:1293)
       at org.jgap.Configuration.<clinit>(Unknown Source)
       at sun.misc.Unsafe.ensureClassInitialized(Native Method)
       at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
       at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
       at java.lang.reflect.Field.acquireFieldAccessor(Field.java:917)
       at java.lang.reflect.Field.getFieldAccessor(Field.java:898)
       at java.lang.reflect.Field.get(Field.java:357)
       at org.jboss.aop.AspectManager.getTempClassAdvisorIfNotExist(AspectManager.java:930)
       at org.jboss.aop.pointcut.CallMatcher.visit(CallMatcher.java:53)
       at org.jboss.aop.pointcut.ast.ASTCall.jjtAccept(ASTCall.java:21)
       at org.jboss.aop.pointcut.MatcherHelper.visit(MatcherHelper.java:103)
       at org.jboss.aop.pointcut.ast.ASTSub.jjtAccept(ASTSub.java:17)
       at org.jboss.aop.pointcut.MatcherHelper.visit(MatcherHelper.java:83)
       at org.jboss.aop.pointcut.ast.ASTBoolean.jjtAccept(ASTBoolean.java:17)
       at org.jboss.aop.pointcut.MatcherHelper.visit(MatcherHelper.java:73)
       at org.jboss.aop.pointcut.MatcherHelper.matches(MatcherHelper.java:68)
       at org.jboss.aop.pointcut.PointcutExpression.matchesCall(PointcutExpression.java:205)
       at org.jboss.aop.ClassAdvisor.resolveCallerMethodInfo(ClassAdvisor.java:1293)
       at examples.MinimizingMakeChange.<clinit>(Unknown Source)
      Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Unable to figure out calledmethod of a caller pointcut
       at org.jboss.aop.ClassAdvisor.resolveCallerMethodInfo(ClassAdvisor.java:1307)
       at org.jgap.Genotype.<clinit>(Unknown Source)
       ... 54 more
      Caused by: java.lang.RuntimeException: Unable to figure out calledmethod of a caller pointcut
       at org.jboss.aop.ClassAdvisor.resolveCallerMethodInfo(ClassAdvisor.java:1286)
       ... 55 more
      


        • 1. Re: Exception instrumenting
          Ben Livshits Newbie

          Can anyone explain why this exception is happening? Thanks.

          • 2. Re: Exception instrumenting
            Ryan McDonough Newbie

            What's your jboss-aop.xml look like? It's hard to tell what the issue is by just looking at bunch of stack trace. Other than trying to run an AO app, what and how are your trying to apply your aspects?

            Ryan-

            • 3. Re: Exception instrumenting
              Ben Livshits Newbie

              A wide pointcut like this yields this problem:

              <bind pointcut="call(* org.jgap.*->*(..)) AND !within(CallerInterceptor) AND !within(StackTraceCatcher)">
               <interceptor class="CallerInterceptor"/>
               </bind>
              


              Similarly, if I were to have call(* *->*(..)) as the matching expression, the same issue would arise.

              • 4. Re: Exception instrumenting
                Kabir Khan Master

                We do have some isues with wide pointcuts like these, and opinion is divided whether this is by design or not.

                Assuming your CallerInterceptor and StackTraceCatcher classes are not within the default package, try fully qualifying their names. Otherwise try narrowing down the pointcut

                • 5. Re: Exception instrumenting
                  Ben Livshits Newbie

                  Kabir, thanks for your reply. Yeah, those belong to the default package.

                  Those pointcuts are intentially wide, narrowing them down is not really an option. Should I assume that matching on every method or even every constructor call is not likely to work? What exactly are the issues you're referring to?..

                  On a related note, I was talking to JBossProfiler folks and was given the impression that they succeed with using AOP for getting profile information. Getting profile info most definitely requires having a large number of pointcuts...

                  I wouldn't be surpised if these same issues arose for even a small application. I should probably double-check with a smaller test case.

                  • 6. Re: Exception instrumenting
                    Kabir Khan Master

                    The issues are that infinite recursion can take place, since interceptors/aspects themselves can be weaved.

                    I tried something similar to what you describe above based on one of the examples in our tutorials, but could not reproduce your problem.

                     <bind pointcut="call(* *->*(..))">
                     <interceptor class="SimpleInterceptor"/>
                     </bind>
                    


                    causes recursion as expected

                     <bind pointcut="call(* *->*(..)) AND !within(SimpleInterceptor)">
                     <interceptor class="SimpleInterceptor"/>
                     </bind>
                    


                    was fine.

                    Do you have other bindings declared in your jboss-aop.xml file? If you do, and haven't already, make sure that all your interceptors/aspects are included in !within() clauses