From 3ddc23d7e54c628f778cbdfc338149c0e7044326 Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Sat, 1 Oct 2016 12:32:23 -0700 Subject: [PATCH] [IR] Do not use JBasics.java_lang_object in IR/backend Summary: In order to have only InferJava depend on JBasics, do not use JBasics.java_lang_object in the IR or backend. Note that this implies that the Java frontend should ideally translate JBasics.java_lang_object to Typename.Java.java_lang_Object. Reviewed By: jeremydubreil Differential Revision: D3956468 fbshipit-source-id: def64dd --- infer/src/IR/Typename.re | 1 + infer/src/IR/Typename.rei | 1 + infer/src/backend/prover.ml | 2 +- infer/src/backend/taint.ml | 8 ++++---- infer/src/checkers/patternMatch.ml | 2 +- infer/src/checkers/printfArgs.ml | 2 +- infer/src/java/jConfig.ml | 2 -- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/infer/src/IR/Typename.re b/infer/src/IR/Typename.re index 30e21e2ab..4b00c1ebf 100644 --- a/infer/src/IR/Typename.re +++ b/infer/src/IR/Typename.re @@ -48,6 +48,7 @@ let module Java = { fun | TN_csu (Class Java) _ => true | _ => false; + let java_lang_Object = from_string "java.lang.Object"; }; type typename_t = t; diff --git a/infer/src/IR/Typename.rei b/infer/src/IR/Typename.rei index 810521db1..0962f5683 100644 --- a/infer/src/IR/Typename.rei +++ b/infer/src/IR/Typename.rei @@ -40,6 +40,7 @@ let module Java: { /** [is_class name] holds if [name] names a Java class */ let is_class: t => bool; + let java_lang_Object: t; }; let module Set: Set.S with type elt = t; diff --git a/infer/src/backend/prover.ml b/infer/src/backend/prover.ml index fa21bbda4..9f121b97f 100644 --- a/infer/src/backend/prover.ml +++ b/infer/src/backend/prover.ml @@ -1524,7 +1524,7 @@ let expand_hpred_pointer = module Subtyping_check = struct - let object_type = Typename.Java.from_string JConfig.object_cl + let object_type = Typename.Java.java_lang_Object let serializable_type = Typename.Java.from_string "java.io.Serializable" diff --git a/infer/src/backend/taint.ml b/infer/src/backend/taint.ml index f80501a65..73dd123ae 100644 --- a/infer/src/backend/taint.ml +++ b/infer/src/backend/taint.ml @@ -19,7 +19,7 @@ let sources0 = [ { classname = "com.facebook.infer.builtins.InferTaint"; method_name = "inferSecretSource"; - ret_type = JConfig.object_cl; + ret_type = "java.lang.Object"; params = []; is_static = true; taint_kind = Tk_unknown; @@ -28,7 +28,7 @@ let sources0 = [ { classname = "com.facebook.infer.builtins.InferTaint"; method_name = "inferSecretSourceUndefined"; - ret_type = JConfig.object_cl; + ret_type = "java.lang.Object"; params = []; is_static = true; taint_kind = Tk_unknown; @@ -66,7 +66,7 @@ let sinks = [ classname = "com.facebook.infer.builtins.InferTaint"; method_name = "inferSensitiveSink"; ret_type = "void"; - params = [JConfig.object_cl]; + params = ["java.lang.Object"]; is_static = true; taint_kind = Tk_unknown; language = Config.Java @@ -75,7 +75,7 @@ let sinks = [ classname = "com.facebook.infer.builtins.InferTaint"; method_name = "inferSensitiveSinkUndefined"; ret_type = "void"; - params = [JConfig.object_cl]; + params = ["java.lang.Object"]; is_static = true; taint_kind = Tk_unknown; language = Config.Java diff --git a/infer/src/checkers/patternMatch.ml b/infer/src/checkers/patternMatch.ml index 7a3ad7861..f1f59d925 100644 --- a/infer/src/checkers/patternMatch.ml +++ b/infer/src/checkers/patternMatch.ml @@ -26,7 +26,7 @@ type taint_spec = { let type_is_object typ = match typ with - | Typ.Tptr (Tstruct name, _) -> string_equal (Typename.name name) JConfig.object_cl + | Typ.Tptr (Tstruct name, _) -> Typename.equal name Typename.Java.java_lang_Object | _ -> false let java_proc_name_with_class_method pn_java class_with_path method_name = diff --git a/infer/src/checkers/printfArgs.ml b/infer/src/checkers/printfArgs.ml index 896054109..a4fd372bc 100644 --- a/infer/src/checkers/printfArgs.ml +++ b/infer/src/checkers/printfArgs.ml @@ -61,7 +61,7 @@ let default_format_type_name | "c" -> "java.lang.Character" | "b" -> "java.lang.Boolean" | "s" -> "java.lang.String" - | "h" | "H" -> JConfig.object_cl + | "h" | "H" -> "java.lang.Object" | _ -> "unknown" let format_type_matches_given_type diff --git a/infer/src/java/jConfig.ml b/infer/src/java/jConfig.ml index 076cca195..44e804b48 100644 --- a/infer/src/java/jConfig.ml +++ b/infer/src/java/jConfig.ml @@ -22,8 +22,6 @@ let infer_array_cl = builtins_package ^ ".InferArray" let infer_undefined_cl = builtins_package ^ ".InferUndefined" -let object_cl = JBasics.cn_name JBasics.java_lang_object - let obj_type = (JBasics.TObject (JBasics.TClass JBasics.java_lang_object)) let bool_type = JBasics.TBasic `Bool