Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.


#1240 False positive BC_UNCONFIRMED_CAST with multiple generics

William Pugh

Steps to reproduce:
1. Expand the attached .tgz file.
2. Edit build.xml and point findbugs-home at a FindBugs installation.
3. ant findbugs.
4. Produces findbugs.xml with one bug reported.

The 'bug' is supposedly an unconfirmed cast on line 5 of FindBugs claims that value is an Enum, and therefore we can't call a method from Displayable without an implied cast.

However, the generics in the definition of the type param T at the beginning of the class state that T extends Enum<T> & Displayable, and therefore the value passed into the method in question must be both an Enum and a Displayable -- therefore calling the method from Displayable is safe.

By comparison, doing exactly the same thing with FindBugs 1.3.9 does not produce any bug warnings.

Java Versions: reproduced with both 1.7.0_45 and 1.6.0_65
OS: Mac OS X 10.8.5

1 Attachments


  • William Pugh
    William Pugh

    • labels: --> false positive
    • status: open --> open-accepted
    • assigned_to: William Pugh
    • Group: 2.0.3 --> 3.0.0
  • William Pugh
    William Pugh

    Reproduced as a low priority warning, correct?

    • Yes, that's right -- as with [#1242], not a very common scenario, but I felt worth logging given the change in behaviour from 1.3.9.

      Thanks William,




      Bugs: #1242

    • Group: 3.0.0 --> 3.0.1