[java] kill ZipLib (aka specs-in-a-jar)

Summary:
Simplifies the models story. The model jar is still needed to look up
fields in modelled classes (we save the .class of each model!). This is
sad as we should be able to get these from the models' tenv, which
should be more compact, but that's a bigger change.

Reviewed By: skcho

Differential Revision: D20891117

fbshipit-source-id: fcb5104ae
master
Jules Villard 5 years ago committed by Facebook GitHub Bot
parent 224e0b7c52
commit 79c5cceecf

@ -165,10 +165,6 @@ module OnDisk = struct
(** Load procedure summary for the given procedure name and update spec table *)
let load_summary_to_spec_table =
let load_summary_ziplibs zip_specs_filename =
let zip_specs_path = Filename.concat Config.specs_dir_name zip_specs_filename in
ZipLib.load summary_serializer zip_specs_path
in
let or_from f_load f_filenames proc_name summ_opt =
match summ_opt with Some _ -> summ_opt | None -> f_load (f_filenames proc_name)
in
@ -176,7 +172,6 @@ module OnDisk = struct
let summ_opt =
load_from_file (specs_filename_of_procname proc_name)
|> or_from load_biabduction_model Fn.id proc_name
|> or_from load_summary_ziplibs specs_filename proc_name
in
Option.iter ~f:(add proc_name) summ_opt ;
summ_opt

@ -124,8 +124,6 @@ let costs_report_json = "costs-report.json"
let default_failure_name = "ASSERTION_FAILURE"
let default_in_zip_results_dir = "infer"
(** Dotty output filename **)
let dotty_frontend_output = "proc_cfgs_frontend.dot"

@ -73,8 +73,6 @@ val costs_report_json : string
val default_failure_name : string
val default_in_zip_results_dir : string
val dotty_frontend_output : string
val duplicates_filename : string

@ -11,9 +11,7 @@ module L = Logging
(** Generic serializer *)
type 'a serializer =
{ read_from_string: string -> 'a option
; read_from_file: DB.filename -> 'a option
; write_to_file: data:'a -> DB.filename -> unit }
{read_from_file: DB.filename -> 'a option; write_to_file: data:'a -> DB.filename -> unit}
module Key = struct
type t =
@ -49,9 +47,6 @@ let create_serializer (key : Key.t) : 'a serializer =
None )
else Some value
in
let read_from_string (str : string) : 'a option =
read_data (Marshal.from_string str 0) "string"
in
let read_from_file (fname : DB.filename) : 'a option =
(* The serialization is based on atomic file renames,
so the deserialization cannot read a file while it is being written. *)
@ -73,10 +68,8 @@ let create_serializer (key : Key.t) : 'a serializer =
Marshal.to_channel outc (key.key, version, data) [] ) ;
PerfEvent.(log (fun logger -> log_end_event logger ()))
in
{read_from_string; read_from_file; write_to_file}
{read_from_file; write_to_file}
let read_from_string s = s.read_from_string
let read_from_file s = s.read_from_file
@ -88,4 +81,4 @@ let generate_keys () =
Random.self_init () ;
let max_rand_int = 0x3FFFFFFF (* determined by Rand library *) in
let gen () = Random.int max_rand_int in
(gen (), gen (), gen (), gen (), gen ())
(gen (), gen (), gen ())

@ -33,12 +33,9 @@ val create_serializer : Key.t -> 'a serializer
val read_from_file : 'a serializer -> DB.filename -> 'a option
(** Deserialize a file and check the keys *)
val read_from_string : 'a serializer -> string -> 'a option
(** Deserialize a string and check the keys *)
val write_to_file : 'a serializer -> data:'a -> DB.filename -> unit
(** Serialize into a file writing value *)
val generate_keys : unit -> int * int * int * int * int
val generate_keys : unit -> int * int * int
[@@warning "-32"]
(** Generate new (random) serialization keys, to be used in an ocaml toplevel *)

@ -1,48 +0,0 @@
(*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
open! IStd
open PolyVariantEqual
type zip_library = {zip_filename: string; zip_channel: Zip.in_file Lazy.t}
let load_from_zip serializer zip_path zip_library =
let (lazy zip_channel) = zip_library.zip_channel in
let deserialize = Serialization.read_from_string serializer in
match deserialize (Zip.read_entry zip_channel (Zip.find_entry zip_channel zip_path)) with
| Some data ->
Some data
| None ->
None
| exception Caml.Not_found ->
None
let load_data serializer path zip_library =
let zip_path = Filename.concat Config.default_in_zip_results_dir path in
load_from_zip serializer zip_path zip_library
(** list of the zip files to search for specs files *)
let zip_libraries =
(* delay until load is called, to avoid stating/opening files at init time *)
lazy
(let mk_zip_lib zip_filename = {zip_filename; zip_channel= lazy (Zip.open_in zip_filename)} in
if
Config.is_checker_enabled Biabduction
&& (not Config.biabduction_models_mode)
&& Sys.file_exists Config.biabduction_models_jar = `Yes
then Some (mk_zip_lib Config.biabduction_models_jar)
else None )
let load serializer path =
(* NOTE: This and [zib_libraries] used to also work with a list of where to find "zip libraries"
but now this only handles at most one such library: the biabduction models. There's a chance
that this code looks weirder than it should as a result. *)
Option.bind (Lazy.force zip_libraries) ~f:(fun zip_library ->
load_data serializer path zip_library )

@ -1,13 +0,0 @@
(*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
open! IStd
val load : 'a Serialization.serializer -> string -> 'a option
(** [load serializer path] searches for the file at the given path in the zip libraries. If
Config.infer_cache is set, already deserialized data will be saved there and [path] will be
searched from the cache first. *)
Loading…
Cancel
Save