[java][frontend] Skip concrete method capture in Kotlin classes

Summary:
Capture of certain Kotlin files fails at the javalib level (probably,
some unanticipated bytecode pattern). We however can't just completely
skip Kotlin class-files during capture as those have NotNull/Nullable
annotations on methods/params that are important for Java <- Kotlin
interop (using Kt classes from Java).

Instead we can skip translation of concrete methods from Kotlin classes
while retaining method signatures with annots in the TEnv.

Reviewed By: ngorogiannis

Differential Revision: D22897638

fbshipit-source-id: 67909aa43
master
Artem Pianykh 4 years ago committed by Facebook GitHub Bot
parent 72d45672d8
commit ea8f9c9e91

@ -186,6 +186,8 @@ let smt_output = false
let source_file_extentions = [".java"; ".m"; ".mm"; ".c"; ".cc"; ".cpp"; ".h"] let source_file_extentions = [".java"; ".m"; ".mm"; ".c"; ".cc"; ".cpp"; ".h"]
let kotlin_source_extension = ".kt"
let specs_files_suffix = ".specs" let specs_files_suffix = ".specs"
(** Enable detailed tracing information during array abstraction *) (** Enable detailed tracing information during array abstraction *)

@ -126,6 +126,8 @@ val smt_output : bool
val source_file_extentions : string list val source_file_extentions : string list
val kotlin_source_extension : string
val sourcepath : string option val sourcepath : string option
val sources : string list val sources : string list

@ -73,6 +73,8 @@ let to_string =
else path else path
let has_extension t ~ext = String.is_suffix (to_string t) ~suffix:ext
let pp fmt fname = Format.pp_print_string fmt (to_string fname) let pp fmt fname = Format.pp_print_string fmt (to_string fname)
let to_abs_path fname = let to_abs_path fname =

@ -62,4 +62,7 @@ val to_string : ?force_relative:bool -> t -> string
(** convert a source file to a string WARNING: result may not be valid file path, do not use this (** convert a source file to a string WARNING: result may not be valid file path, do not use this
function to perform operations on filenames *) function to perform operations on filenames *)
val has_extension : t -> ext:string -> bool
(** returns whether the source file has provided extension *)
module SQLite : SqliteUtils.Data with type t = t module SQLite : SqliteUtils.Data with type t = t

@ -89,8 +89,10 @@ let add_edges (context : JContext.t) start_node exn_node exit_nodes method_body_
(** Add a concrete method. *) (** Add a concrete method. *)
let add_cmethod source_file program icfg cm proc_name = let add_cmethod source_file program icfg cm proc_name =
let cn, _ = JBasics.cms_split cm.Javalib.cm_class_method_signature in let cn, _ = JBasics.cms_split cm.Javalib.cm_class_method_signature in
if Inferconfig.skip_implementation_matcher source_file proc_name then if
ignore (JTrans.create_empty_procdesc source_file program icfg cm proc_name) Inferconfig.skip_implementation_matcher source_file proc_name
|| SourceFile.has_extension source_file ~ext:Config.kotlin_source_extension
then ignore (JTrans.create_empty_procdesc source_file program icfg cm proc_name)
else else
match JTrans.create_cm_procdesc source_file program icfg cm proc_name with match JTrans.create_cm_procdesc source_file program icfg cm proc_name with
| None -> | None ->

Loading…
Cancel
Save