Friday, October 28, 2011

[android-developers] FindBugs detector for Android

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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate