4 Replies Latest reply on Apr 9, 2012 8:33 PM by larry_west

    Field visibility and aspect

    mane81

      Hi,
      if I have a class with an enclosed class like this

      Class POJO {
      private String aField;

      ...

      class AnotherClass {
      public void someMethod() {
      aField = "something";
      }
      }
      }

      and I add an aspect at runtime through these instructions:
      AdviceBinding binding = new AdviceBinding("execution(public boolean Pojo>getCond())", null);
      binding.addInterceptor(SimpleAspect.class);
      AspectManager.instance().addBinding(binding);

      An exception is thrown:
      Exception in thread "main" java.lang.NullPointerException
      at org.jboss.aop.pointcut.MethodMatcher.(MethodMatcher.java:72)
      at org.jboss.aop.pointcut.ExecutionMethodMatcher.(ExecutionMethodMatcher.java:53)
      at org.jboss.aop.pointcut.PointcutExpression.matchesExecution(PointcutExpression.java:118)
      at org.jboss.aop.Advisor.resolveMethodPointcut(Advisor.java:1333)
      at org.jboss.aop.GeneratedClassAdvisor.resolveMethodPointcut(GeneratedClassAdvisor.java:309)
      at org.jboss.aop.ClassAdvisor.resolvePointcuts(ClassAdvisor.java:751)
      at org.jboss.aop.ClassAdvisor.doRebuildInterceptorsForAddedBinding(ClassAdvisor.java:1160)
      at org.jboss.aop.ClassAdvisor$RebuildInterceptorsAction$2.rebuildInterceptorsForAddedBinding(ClassAdvisor.java:2348)
      at org.jboss.aop.ClassAdvisor.rebuildInterceptorsForAddedBinding(ClassAdvisor.java:1139)
      at org.jboss.aop.GeneratedClassAdvisor.access$1501(GeneratedClassAdvisor.java:65)
      at org.jboss.aop.GeneratedClassAdvisor$ClassAdvisorStrategy.rebuildInterceptorsForAddedBinding(GeneratedClassAdvisor.java:1538)
      at org.jboss.aop.GeneratedClassAdvisor.rebuildInterceptorsForAddedBinding(GeneratedClassAdvisor.java:244)
      at org.jboss.aop.Advisor.newBindingAdded(Advisor.java:1124)
      at org.jboss.aop.AspectManager.updateAdvisorsForAddedBinding(AspectManager.java:1498)
      at org.jboss.aop.AspectManager.updateAdvisorsForAddedBinding(AspectManager.java:1521)
      at org.jboss.aop.AspectManager.addBinding(AspectManager.java:1456)
      at Caller.run(Caller.java:36)
      at Caller.main(Caller.java:57)

      If the field visibility is public the exception is not thrown anymore.
      Can someone tell me why?

        • 1. Re: Field visibility and aspect
          kabirkhan

          Can you create a JIRA issue with an example based on one of the aop examples, and we can investigate?
          https://jira.jboss.org/jira/browse/JBAOP

          • 2. Re: Field visibility and aspect
            mane81

            Yes, as soon as possible.
            I forget to mention that this behaviour happens with jboss-aop-2.0.0.GA. Using jboss-aop_1.5.6.GA it's all okay (apart from other problems using hotswap and the javaassist library bundled with this version :) )

            • 3. Field visibility and aspect
              andrewwot

              Hi Kabir,

              We've stepped into the same issue with AOP 2.1.6.GA. Any ETA on fix, is there a JIRA we can use to track the issue?

               

              Thanks

              • 4. Re: Field visibility and aspect
                larry_west

                Also see the same issue with AOP 2.1.6GA, also when adding static nested classes.   I see nothing relevant in the JIRA area for AOP, is this still undocumented?

                 

                java.lang.NullPointerException

                    at org.jboss.aop.pointcut.MethodMatcher.<init>(MethodMatcher.java:72)

                    at org.jboss.aop.pointcut.ExecutionMethodMatcher.<init>(ExecutionMethodMatcher.java:53)

                    at org.jboss.aop.pointcut.PointcutExpression.matchesExecution(PointcutExpression.java:118)

                    at org.jboss.aop.Advisor.resolveMethodPointcut(Advisor.java:1343)

                    at org.jboss.aop.GeneratedClassAdvisor.resolveMethodPointcut(GeneratedClassAdvisor.java:312)

                    at org.jboss.aop.ClassAdvisor.resolveBindings(ClassAdvisor.java:668)

                    at org.jboss.aop.ClassAdvisor.createInterceptorChains(ClassAdvisor.java:607)

                    at org.jboss.aop.GeneratedClassAdvisor.access$201(GeneratedClassAdvisor.java:65)

                    at org.jboss.aop.GeneratedClassAdvisor$ClassAdvisorStrategy.createInterceptorChains(GeneratedClassAdvisor.java:1306)

                    at org.jboss.aop.GeneratedClassAdvisor.createInterceptorChains(GeneratedClassAdvisor.java:410)

                    at org.jboss.aop.ClassAdvisor$1.run(ClassAdvisor.java:306)

                    at java.security.AccessController.doPrivileged(Native Method)

                    at org.jboss.aop.ClassAdvisor.attachClass(ClassAdvisor.java:276)

                    at org.jboss.aop.AspectManager.initialiseClassAdvisor(AspectManager.java:754)

                    at org.jboss.aop.GeneratedClassAdvisor$ClassAdvisorStrategy.initialise(GeneratedClassAdvisor.java:1294)

                    at org.jboss.aop.GeneratedClassAdvisor.initialise(GeneratedClassAdvisor.java:146)

                    at com.intuit.cg.services.ds.ofx.service.resource.ProxyResourceImpl$ProxyResourceImplAdvisor.initialise(ProxyResourceImpl$ProxyResourceImplAdvisor.java)

                    at com.intuit.cg.services.ds.ofx.service.resource.ProxyResourceImpl$ProxyResourceImplAdvisor.<init>(ProxyResourceImpl$ProxyResourceImplAdvisor.java)

                    at com.intuit.cg.services.ds.ofx.service.resource.ProxyResourceImpl.<clinit>(ProxyResourceImpl.java)

                    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

                    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

                    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

                    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)

                    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)

                    ...