Menu

#1331 False positive VA_FORMAT_STRING_BAD_CONVERSION

3.0.1
closed-fixed
None
5
2014-11-20
2014-11-20
Paul Krause
No

FindBugs 3.0.0 reports LocalDateFormat.java:6 Argument of type java.time.LocalDate can't be handled by format specifier %1$tm in LocalDateFormat.main(String[]) [Scary(7), High confidence] when run on the attached program

1 Attachments

Discussion

  • Tagir Valeev

    Tagir Valeev - 2014-11-20

    As Java8 documentation states: Date/Time - may be applied to Java types which are capable of encoding a date or time: long, Long, Calendar, Date and TemporalAccessor.

    We are not handling TemporalAccessor types right now. This can be easily fixed (FormatStringChecker, line#163), but I'm not sure about committing the test case. Andrey, Bill, can we commit test cases which require Java8 to compile?

     
  • Andrey Loskutov

    Andrey Loskutov - 2014-11-20

    Yes, you can, but for the bug examples project only.
    Check last build.xml changes: you should add local.properties in this project and then the build will compile and execute with two different JVM's.
    I have no code access right now, if you need nore details, just ask.
    CU
    Andrey

     
  • Tagir Valeev

    Tagir Valeev - 2014-11-20
    • status: open --> open-accepted
    • assigned_to: Tagir Valeev
     
  • Tagir Valeev

    Tagir Valeev - 2014-11-20

    Fix and test for this bug is also committed:
    https://code.google.com/p/findbugs/source/detail?r=d266ad234942e23ed2e19145a68ec51a13a9ad16

    There's a problem in checking Java8 code with FindBugs running on jre7: it cannot access proper JRE libraries, thus cannot build a class hierarchy. For example, Hierarchy.isSubtype('java.time.LocalDate', java.util.Date.class.getName()) causes ClassNotFoundException. For now I added an explicit check for java.time.LocalDate, just to make tests working. Probably we should consider checking Java8 code with jre8.

     
  • Tagir Valeev

    Tagir Valeev - 2014-11-20
    • status: open-accepted --> closed-fixed
     
  • Andrey Loskutov

    Andrey Loskutov - 2014-11-20
    • Group: 3.x --> 3.0.1
     
  • Andrey Loskutov

    Andrey Loskutov - 2014-11-20

    Thanks Tagir,
    looks good.

    CU
    Andrey

     

Log in to post a comment.