I've shared the beginnings of a FindBugs plugin for Android:

https://bitbucket.org/joebowbeer/findbugsandroidplugin

To use: hg clone, mvn package, and copy the .jar to your FindBugs
plugin folder.

Currently, the plugin contains a single detector, which finds (non-
static) android.os.Handler inner classes that may leak memory.

Memory leaks are a recurring problem for long running processes.  This
detector could, for example, replace the following debug code in the
Handler constructor:

if (FIND_POTENTIAL_LEAKS) {
  final Class<? extends Handler> klass = getClass();
  if ((klass.isAnonymousClass() || klass.isMemberClass() ||
klass.isLocalClass()) &&
      (klass.getModifiers() & Modifier.STATIC) == 0) {
    Log.w(TAG, "The following Handler class should be static or leaks
might occur: " +
      klass.getCanonicalName());
  }
}

Is anyone else writing custom detectors for Android apps?  I think
that a handful, at least, that would be very useful.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to