Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] In rare circumstances StackOverflows occur after aspecting Android projects

Hi all,

at work we are writing an analytics tool measuring network requests in
Android Applications leveraging AspectJ to measure them at runtime.

To that extend we have setup Aspects to run during a build of an Android
Application looking similar to the following:

pointcut URL_openConnection() : call(* java.net.URL.openConnection(..)) &&
  !within(org.example.metrics.android..*);

URLConnection around () : URL_openConnection()
{
  /* Do something interesting with this call */
  URLConnection connection = (URLConnection) proceed();

  /* Pass off the connection reference for internal bookkeeping */
  return connection;
}

In most cases this actually works flawlessly and has yet to result in a problem
in our test environment.

We do aspect both the build results (*.class-files) of the Application as well
as it's dependencies (ie. jars that the Android Application deems required at
compile/runtime to be available).

The problem begins when we received the report that this Aspect code resulted
in an unforeseen consequence of a StackOverflow (carefully reading the FAQ for
AspectJ and reviewing our Aspects I thought we would not have a similar case
to this one[0] at hand).

Receiving a compiled example of the project reporting the issue and not the code
I could clearly see in a decompiler 2 Aspects calling openConnection() where the
proceed() is and subsequently each other as aspect methods specifically.

This is curious to us and is something we have a hard time reproducing.

It would be of great help to us if someone from this forum who has more
experience could enlighten us as to what exactly is amiss here.

Thank you in advance,

Andreas Marschke

[0] http://www.eclipse.org/aspectj/doc/released/faq.php#q:infiniterecursion

Back to the top