facebook / infer

A static analyzer for Java, C, C++, and Objective-C
http://fbinfer.com/
MIT License
14.81k stars 2k forks source link

Java - Dynamic Dispatch Analysis #603

Open xennygrimmato opened 7 years ago

xennygrimmato commented 7 years ago

How does Infer treat cases in which an anonymous class is extended and a method is over-ridden?

For example:

new JdbcQuery(context) {
       @Override
       protected Object query(Connection conn) throws SQLException {
             func(conn);
             return null;
       }
}.execute();

Function query(...) is called inside execute(), but Infer does not go inside the execute() method for analysis. Is this the expected behaviour?

Due to this, I am encountering a false positive, so I want to understand why Infer does not visit execute(). I'll be happy to share more information if required. Thanks!

jvillard commented 6 years ago

Sorry for the very late response. Can you please provide a self-contained example for your issue? That would make it easier for me to see what infer does with it. Unless @jeremydubreil knows what's going to happen in that case at the top of his head.

jeremydubreil commented 6 years ago

Is execute() defined within the code being analyzed or it is part of some library?