From add9e476a3897d0c094c23c79ead0dedb3fee3e0 Mon Sep 17 00:00:00 2001 From: Jeremy Dubreil Date: Mon, 23 Jan 2017 15:21:58 -0800 Subject: [PATCH] [infer][java] more rebust detection of the class filenames Summary: The previous version of the code could fail if the class filename would contain "class" as part of the name and not be a valid class filename ending with the `.class` suffix Reviewed By: sblackshear Differential Revision: D4451859 fbshipit-source-id: 874832a --- infer/src/java/jClasspath.ml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/infer/src/java/jClasspath.ml b/infer/src/java/jClasspath.ml index 20c1515a9..8d1348320 100644 --- a/infer/src/java/jClasspath.ml +++ b/infer/src/java/jClasspath.ml @@ -203,10 +203,10 @@ let extract_classnames classnames jar_filename = let file_in = Zip.open_in jar_filename in let collect classes entry = let class_filename = entry.Zip.filename in - try - let () = ignore (Str.search_forward (Str.regexp "class") class_filename 0) in - (classname_of_class_filename (Filename.chop_extension class_filename) :: classes) - with Not_found -> classes in + match Filename.split_extension class_filename with + | basename, Some "class" -> + (classname_of_class_filename basename) :: classes + | _ -> classes in let classnames_after = IList.fold_left collect classnames (Zip.entries file_in) in Zip.close_in file_in; classnames_after