diff --git a/infer/src/checkers/ThreadSafety.ml b/infer/src/checkers/ThreadSafety.ml index e76866a28..ed6b785bb 100644 --- a/infer/src/checkers/ThreadSafety.ml +++ b/infer/src/checkers/ThreadSafety.ml @@ -111,6 +111,7 @@ module ResultsTableType = Map.Make (struct let should_analyze_proc (_,_,proc_name,proc_desc) = not (Procname.is_constructor proc_name) && + not (Procname.is_class_initializer proc_name) && Cfg.Procdesc.get_access proc_desc <> PredSymb.Private (* creates a map from proc_envs to postconditions *) diff --git a/infer/tests/codetoanalyze/java/checkers/ThreadSafeExample.java b/infer/tests/codetoanalyze/java/checkers/ThreadSafeExample.java index 256c21550..27b78ea86 100644 --- a/infer/tests/codetoanalyze/java/checkers/ThreadSafeExample.java +++ b/infer/tests/codetoanalyze/java/checkers/ThreadSafeExample.java @@ -24,6 +24,9 @@ import java.lang.annotation.Target; @ThreadSafe public class ThreadSafeExample{ + /*Included to make sure infer does not report on class initializers*/ + static Class A = ThreadSafeExample.class; + Integer f; public ThreadSafeExample() {