[java][procname] always return pointer types to objects

Summary: `Procname.Java.get_return_typ` is buggy because whenever faced with an array of objects, it returns a type that implies the object is stored by value in the array (this is correct behaviour only when the element type is primitive, not when it's an object type).

Reviewed By: ezgicicek

Differential Revision: D20384403

fbshipit-source-id: d91322d3a
master
Nikos Gorogiannis 5 years ago committed by Facebook GitHub Bot
parent 544e4f2e6c
commit 8ede47649c

@ -145,12 +145,11 @@ module Java = struct
Typ.double Typ.double
| typ_str when String.contains typ_str '[' -> | typ_str when String.contains typ_str '[' ->
let stripped_typ = String.sub typ_str ~pos:0 ~len:(String.length typ_str - 2) in let stripped_typ = String.sub typ_str ~pos:0 ~len:(String.length typ_str - 2) in
Typ.mk (Tptr (Typ.mk_array (java_from_string stripped_typ), Pk_pointer)) Typ.(mk_ptr (mk_array (java_from_string stripped_typ)))
| typ_str -> | typ_str ->
Typ.mk (Tstruct (Typ.Name.Java.from_string typ_str)) Typ.(mk_ptr (mk_struct (Typ.Name.Java.from_string typ_str)))
in in
let typ = java_from_string (F.asprintf "%a" (pp_return_type Verbose) pname_java) in java_from_string (F.asprintf "%a" (pp_return_type Verbose) pname_java)
match typ.desc with Tstruct _ -> Typ.mk (Tptr (typ, Pk_pointer)) | _ -> typ
let is_close {method_name} = String.equal method_name "close" let is_close {method_name} = String.equal method_name "close"

Loading…
Cancel
Save