Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] Parameter construction pointcut?

 

>  
> > Looking at the source code like this:
> > logger.debug("Entry number: " + i + " is " + 
> > String.valueOf(entry[i]));
> 
> In general, it's undecidable what might be a parameter for debug(..).
> Reachbility is not decidable for Turing complete languages.
> 

When looking at source code, it should be fairly easy to define a cutpoint that is "before anything is done inside the parentheses of this function call".  (Fairly easy probably means about as hard as the existing pointcut that captures a function call after argument creation.)  Given a function call of f(g(a+b),h()), beforeArgs(f) (with appropriate extras to match properly) would happen before a and b are added, g is called or h is called.  That would cover the case that the original poster was asking about.

Load time weaving is quite probably much more difficult.  I expect that is where the problem becomes undecidable.  Consider this snippet.

{
  String a = getA();
  String b = a + getB();
  System.out.println(b + getC());
}

In object code, this could easily be identical to

System.out.println(getA() + getB() + getC());

or 

{
  String s = getA() + getB() + getC();
  System.out.println(s);
}

In all three cases, a string is built up from the results of three function calls and never used again.  Unless there are extra markings in the object code, the location of the open parenthesis has been lost.  

Speaking with the blissful ignorance of someone totally unfamiliar with the AspectJ source, I expect that it would be possible to create such a point cut, but it would only work for compile-time weaving.  If the ApsectJ team is committed to having compile-time and run-time weaving be interchangeable, that means this type of cutpoint is not doable.

Troy

> Eric
> 
> --
> Eric Bodden
> Sable Research Group
> McGill University, Montréal, Canada
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
> 


Back to the top