[java] get rid of unused models tenv

Summary: The models tenv is loaded inside a global variable that is never used.

Reviewed By: jeremydubreil

Differential Revision: D6692656

fbshipit-source-id: 4166a22
master
Jules Villard 7 years ago committed by Facebook Github Bot
parent a0dfd699a8
commit 52f7253d61

@ -20,35 +20,6 @@ let models_specs_filenames = ref String.Set.empty
let models_jar = ref ""
let models_tenv = ref (Tenv.create ())
let load_models_tenv zip_channel =
let models_tenv_filename_in_jar =
let root = Filename.concat Config.default_in_zip_results_dir Config.captured_dir_name in
Filename.concat root Config.global_tenv_filename
in
let temp_tenv_filename =
DB.filename_from_string (Filename.temp_file "tmp_" Config.global_tenv_filename)
in
let entry = Zip.find_entry zip_channel models_tenv_filename_in_jar in
let temp_tenv_file = DB.filename_to_string temp_tenv_filename in
let models_tenv =
try
Zip.copy_entry_to_file zip_channel entry temp_tenv_file ;
match Tenv.load_from_file temp_tenv_filename with
| None ->
L.(die InternalError) "Models tenv file could not be loaded"
| Some tenv ->
tenv
with
| Not_found ->
L.(die InternalError) "Models tenv not found in jar file"
| Sys_error msg ->
L.(die InternalError) "Models jar could not be opened: %s" msg
in
DB.file_remove temp_tenv_filename ; models_tenv
let collect_specs_filenames jar_filename =
let zip_channel = Zip.open_in jar_filename in
let collect set e =
@ -60,7 +31,6 @@ let collect_specs_filenames jar_filename =
in
models_specs_filenames
:= List.fold ~f:collect ~init:!models_specs_filenames (Zip.entries zip_channel) ;
models_tenv := load_models_tenv zip_channel ;
Zip.close_in zip_channel

@ -14,9 +14,6 @@ open Javalib_pack
val models_jar : string ref
(** Jar file containing the models *)
val models_tenv : Tenv.t ref
(** Type environment of the models *)
val add_models : string -> unit
(** Adds the set of procnames for the models of Java libraries so that methods
with similar names are skipped during the capture *)

@ -491,10 +491,3 @@ let rec expr_type (context: JContext.t) expr =
specified in ms. *)
let return_type program tenv ms =
match JBasics.ms_rtype ms with None -> Typ.mk Tvoid | Some vt -> value_type program tenv vt
let add_models_types tenv =
let add_type t typename struct_typ =
if not (Tenv.mem t typename) then Tenv.add tenv typename struct_typ
in
Tenv.iter (add_type tenv) !JClasspath.models_tenv

@ -89,6 +89,3 @@ val object_type_to_string : JBasics.object_type -> string
val vt_to_java_type : JBasics.value_type -> Typ.Procname.java_type
val cn_to_java_type : JBasics.class_name -> Typ.Procname.java_type
val add_models_types : Tenv.t -> unit
(** Add the types of the models to the type environment passed as parameter *)

Loading…
Cancel
Save