From 2601af5adeaecb3870fca3d2cf9f304ebc3f1ca4 Mon Sep 17 00:00:00 2001 From: Peter O'Hearn Date: Tue, 18 Oct 2016 08:46:25 -0700 Subject: [PATCH] [threadsafety] don't report on class initializers Reviewed By: sblackshear Differential Revision: D4032522 fbshipit-source-id: 1bb10a7 --- infer/src/checkers/ThreadSafety.ml | 1 + infer/tests/codetoanalyze/java/checkers/ThreadSafeExample.java | 3 +++ 2 files changed, 4 insertions(+) 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() {