[infer][java] Always consider the close() method to be potentially closing a resource

Summary:
It seems that the `close()` method that should normally be called on an object `obj` of type `java.io.Closeable` is sometimes called on `obj` of type `java.lang.Object`. It did not fully understand in which case this happens but it could be coming from a bug in Sawja since the type of `obj` in the bytecode is correct, but the Sawja reciever expression given to the Java frontend has the type `java.lang.Object`.

In any case, it does not hurt to always consider that `obj.close()` will replace the `FILE` attribute on `obj` by a `MEM` attribute.

Reviewed By: sblackshear

Differential Revision: D4540627

fbshipit-source-id: 71f9c95
master
Jeremy Dubreil 8 years ago committed by Facebook Github Bot
parent 3f3b0e5fe1
commit ecfb00e068

@ -601,8 +601,7 @@ let method_invocation
call_instrs @ [set_file_attr]
(* remove file attribute when calling the close method of a subtype of Closeable *)
| (_, typ) as exp :: []
when Procname.java_is_close callee_procname && JTransType.is_closeable program tenv typ ->
| exp :: [] when Procname.java_is_close callee_procname ->
let set_mem_attr =
let set_builtin = Exp.Const (Const.Cfun BuiltinDecl.__set_mem_attribute) in
Sil.Call (None, set_builtin, [exp], loc, CallFlags.default) in

Loading…
Cancel
Save