[infer][java] log the failures happening when the frontend fails to load a class from the classpath

Summary: This will make it easier to detect regressions, until we can completely solve the issue with the classpath and change the `No_class_found` exception into a hard failure.

Reviewed By: sblackshear

Differential Revision: D7307464

fbshipit-source-id: eab67fb
master
Jeremy Dubreil 7 years ago committed by Facebook Github Bot
parent 6d46b0c7be
commit 9acfcc815e

@ -231,15 +231,19 @@ type callee_status = Translated | Missing of JBasics.class_name * JBasics.method
type classmap = JCode.jcode Javalib.interface_or_class JBasics.ClassMap.t type classmap = JCode.jcode Javalib.interface_or_class JBasics.ClassMap.t
type classpath = {path: string; channel: Javalib.class_path}
type program = type program =
{ classpath: Javalib.class_path { classpath: classpath
; models: classmap ; models: classmap
; mutable classmap: classmap ; mutable classmap: classmap
; callees: callee_status Typ.Procname.Hash.t } ; callees: callee_status Typ.Procname.Hash.t }
let get_classmap program = program.classmap let get_classmap program = program.classmap
let get_classpath program = program.classpath let get_classpath_channel program = program.classpath.channel
let get_classpath program = program.classpath.path
let get_models program = program.models let get_models program = program.models
@ -261,15 +265,20 @@ let iter_missing_callees program ~f =
Typ.Procname.Hash.iter select program.callees Typ.Procname.Hash.iter select program.callees
let cleanup program = Javalib.close_class_path program.classpath let cleanup program = Javalib.close_class_path program.classpath.channel
let lookup_node cn program = let lookup_node cn program =
try Some (JBasics.ClassMap.find cn (get_classmap program)) with Not_found -> try Some (JBasics.ClassMap.find cn (get_classmap program)) with Not_found ->
try try
let jclass = javalib_get_class (get_classpath program) cn in let jclass = javalib_get_class (get_classpath_channel program) cn in
add_class cn jclass program ; Some jclass add_class cn jclass program ; Some jclass
with with
| JBasics.No_class_found _ | JBasics.Class_structure_error _ | Invalid_argument _ -> | JBasics.No_class_found class_name ->
L.internal_error "ERROR: class \"%s\" not found with classpath %s@." class_name
(get_classpath program) ;
None
| (JBasics.Class_structure_error _ | Invalid_argument _) as exn ->
L.internal_error "ERROR: %s@." (Exn.to_string exn) ;
None None
@ -291,7 +300,7 @@ let load_program classpath classes =
else collect_classes JBasics.ClassMap.empty !models_jar else collect_classes JBasics.ClassMap.empty !models_jar
in in
let program = let program =
{ classpath= Javalib.class_path classpath { classpath= {path= classpath; channel= Javalib.class_path classpath}
; models ; models
; classmap= JBasics.ClassMap.empty ; classmap= JBasics.ClassMap.empty
; callees= Typ.Procname.Hash.create 128 } ; callees= Typ.Procname.Hash.create 128 }

Loading…
Cancel
Save