you could also integrate this into your build with the findbugs maven plugin :)
http://mojo.codehaus.org/findbugs-maven-plugin/ jesse On Thu, Feb 14, 2008 at 9:49 AM, Kiran Ayyagari <[EMAIL PROTECTED]> wrote: > > how about using findbugs (http://findbugs.sourceforge.net/), a static > analysis tool. > > I just tried this now and found some issues for e.x > > ExpressionEnumerator.java line 135 > else if ( node instanceof ApproximateNode ) > { > list = enumEquality( ( EqualityNode ) node ); // line 135 This > cast will always throw a ClassCastException > } > > A possible return of null value in the below code > > public final boolean isValid() throws NamingException > { > if ( valid != null ) > { > return valid; > } > > return valid; > } > > and a possible NPE at line 963 of RdnParser.java (no null check while > calling this method) > > rdn.setUpName( StringTools.utf8ToString( dn, start, pos.end - start ) > ); > > There might be some false positives like the one given bellow but its > good in catching many valid cases like above. > > Example False Positive - > > It shows a warning for the below code at line 140 in HostAddresses.java > saying possible ClassCastException > but the variable addresses is of type List holding HostAddress objects > > HostAddress[] thisHostAddresses = ( HostAddress[] ) > addresses.toArray(); > > -Kiran Ayyagari > > Emmanuel Lecharny wrote: > > Icky Dude wrote: > >> Hi, > >> > >> Is there any way that the following code wouldn't produce a > >> ClassCastException? > >> > >> SearchResult result = new ServerSearchResult( "", null, ( Attributes ) > >> getRootDSE( null ).clone(), false ); > >> > > No. You will get a plain old ClassCastException ! > > > > Good catch. I will fix this bug. > > > > FYI, this went through the radar when I modified the getRootDSE > > method. This is why casts are wrong, too. > > > > Last, not least, we need a test case to catch such issues ... > > > -- jesse mcconnell [EMAIL PROTECTED]