Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#61 find instantiations of Boolean

release_2.3
closed
Lars Kühne
None
5
2012-10-10
2002-04-29
Lars Kühne
No

I often see code like this

boolean x = ...
Boolean y = new Boolean(x);

This is usually an error, because it wastes space and
time (instantiation and garbage collection). The second
line of the above code should normally be replaced by

Boolean y = x ? Boolean.TRUE : Boolean.FALSE;

or (JDK 1.4)

Boolean y = Boolean.valueOf(x);

It would be great if checkstyle could find and report
occurences of Boolean instantiations, i.e. "new
Boolean(something)"

Discussion

  • Lars Kühne
    Lars Kühne
    2002-05-10

    Logged In: YES
    user_id=401384

    I have an preliminary implementation at hand, just waiting
    for release 2.2 before committing it.

     
  • Lars Kühne
    Lars Kühne
    2002-05-15

    Logged In: YES
    user_id=401384

    initial support is now implemented in CVS, but needs some polish

     
  • Lars Kühne
    Lars Kühne
    2002-05-30

    Logged In: YES
    user_id=401384

    done