diff --git a/infer/src/concurrency/RacerDFileAnalysis.ml b/infer/src/concurrency/RacerDFileAnalysis.ml index e35e5ddb6..33e171121 100644 --- a/infer/src/concurrency/RacerDFileAnalysis.ml +++ b/infer/src/concurrency/RacerDFileAnalysis.ml @@ -362,6 +362,7 @@ let should_report_on_proc tenv procdesc = requested via @ThreadSafe in java *) RacerDModels.is_thread_safe_method proc_name tenv || (not (PredSymb.equal_access (Procdesc.get_access procdesc) Private)) + && (not (Procname.Java.is_class_initializer java_pname)) && (not (Procname.Java.is_autogen_method java_pname)) && not (Annotations.pdesc_return_annot_ends_with procdesc Annotations.visibleForTesting) | ObjC_Cpp objc_cpp when Procname.ObjC_Cpp.is_cpp_lambda objc_cpp -> diff --git a/infer/src/concurrency/RacerDModels.ml b/infer/src/concurrency/RacerDModels.ml index 84be865a8..263c85099 100644 --- a/infer/src/concurrency/RacerDModels.ml +++ b/infer/src/concurrency/RacerDModels.ml @@ -343,8 +343,7 @@ let should_analyze_proc tenv pn = (not ( match pn with | Procname.Java java_pname -> - Procname.Java.is_class_initializer java_pname - || Typ.Name.Java.is_external (Procname.Java.get_class_type_name java_pname) + Typ.Name.Java.is_external (Procname.Java.get_class_type_name java_pname) (* third party code may be hard to change, not useful to report races there *) | _ -> false )) diff --git a/infer/tests/codetoanalyze/java/racerd/Containers.java b/infer/tests/codetoanalyze/java/racerd/Containers.java index 83ad44da4..d647203b3 100644 --- a/infer/tests/codetoanalyze/java/racerd/Containers.java +++ b/infer/tests/codetoanalyze/java/racerd/Containers.java @@ -386,4 +386,10 @@ class Containers { byte[] raceOnMacDoFinalBad() { return mac.doFinal(); } + + static Set staticSyncSet = new ConcurrentSkipListSet(); + + static void staticAddToSyncIntegerSetOk(int s) { + staticSyncSet.add(s); + } }