---
title: "An open source compositional deadlock detector for Android Java"
description: "Meta built a compositional static analyzer, now part of the open source Infer framework, that detects deadlocks in Android Java code without running it."
url: "https://swe.quest/articles/an-open-source-compositional-deadlock-detector-for-android-java-baaa0219c7853320"
canonical: "https://engineering.fb.com/2022/03/08/android/deadlock-detector-for-android-java/"
source: "Meta Engineering"
published: "2022-03-08"
difficulty: "hard"
kind: "Research"
reading_minutes: 2
tags: ["static-analysis","concurrency","jvm","mobile"]
---

# An open source compositional deadlock detector for Android Java

A post on [Meta Engineering](https://swe.quest/sources/meta.md), published 2022-03-08, 2 min read, Research. Original: [https://engineering.fb.com/2022/03/08/android/deadlock-detector-for-android-java/](https://engineering.fb.com/2022/03/08/android/deadlock-detector-for-android-java/)

## Summary

Meta built a compositional static analyzer, now part of the open source Infer framework, that detects deadlocks in Android Java code without running it. Using abstract interpretation, it summarizes each method once in terms of "critical pairs": which lock it acquires while already holding a given set of locks, plus whether it runs on the main or a background thread. To scale to codebases with hundreds of millions of lines, it analyzes only the methods in a revision's modified files, then uses a heuristic to find outside methods that could deadlock with them. Deployed in CI on every commit to Meta's Android apps, it has led to over 200 fixes at about a 54% fix rate, and the analysis is proven sound and complete for an abstract language with non-deterministic control.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Static analysis](https://swe.quest/tags/static-analysis.md) (Engineering practices)
- [Concurrency](https://swe.quest/tags/concurrency.md) (Compilers & runtimes)
- [Java & JVM](https://swe.quest/tags/jvm.md) (Languages)
- [Mobile](https://swe.quest/tags/mobile.md) (Web & mobile)

## Prerequisites

- abstract interpretation
- Java locks and threads ([easy posts on Java & JVM](https://swe.quest/tags/jvm.md?difficulty=easy))
- static analysis basics ([easy posts on Static analysis](https://swe.quest/tags/static-analysis.md?difficulty=easy))

## Keywords

Infer, abstract interpretation, Android, critical pairs

## Related posts

- [Open-sourcing Mariana Trench: Analyzing Android and Java app security in depth](https://swe.quest/articles/open-sourcing-mariana-trench-analyzing-android-and-java-app-security-in-depth-6f84a56369fe533f.md): Meta Engineering · 2021-09-29 · Easy · 6 min read · Static analysis, Application security, Mobile, Java & JVM, Open source
  Mariana Trench is Meta's open-sourced static taint-analysis tool for Android and Java apps that finds security and privacy bugs by tracing data flows from sources (e.g., Intent.getData) to sinks (e.g., Log.w, Runtime.exec).
- [Automating dead code cleanup](https://swe.quest/articles/automating-dead-code-cleanup-e03bc4ba07b5bf1c.md): Meta Engineering · 2023-10-24 · Medium · 7 min read · Static analysis, Refactoring & migrations, Developer productivity, Python
  Meta's SCARF framework finds dead code by building a cross-language, symbol-level dependency graph from Glean and augmenting it with runtime usage data such as API endpoint logs, URI dispatch tables and async job invocations, then garbage-collects unreachable nodes, subgraphs and cycles.
- [How we migrated our static analyzer from Java to Rust](https://swe.quest/articles/how-we-migrated-our-static-analyzer-from-java-to-rust-8d2e3080358d7827.md): Datadog Engineering · 2024-05-23 · Medium · 8 min read · Rust, Static analysis, Refactoring & migrations, Performance engineering, Java & JVM
  Datadog rewrote the Codiga static analyzer from Java to Rust after switching its parser from ANTLR to Tree-sitter, whose Java bindings lacked features like pattern matching.
- [The Sentry Android SDK is now 20-30% faster!](https://swe.quest/articles/the-sentry-android-sdk-is-now-20-30-faster-c43bd999f6f96999.md): Sentry · 2026-10-20 · Medium · 4 min read · Mobile, Performance engineering, Java & JVM
  Sentry's Android SDK init time dropped 20-30% between versions 8.43.0 and 8.54.0, alongside reduced memory allocation, fixed leaks and up to 10% less background CPU.
- [App stability at scale with a layered defense](https://swe.quest/articles/app-stability-at-scale-with-a-layered-defense-191103cbbe4ddc1a.md): Grab Engineering · 2026-10-21 · Medium · 15 min read · Mobile, Deployment, Static analysis, Observability, Testing
  Grab keeps its Android and iOS superapp stable with a layered, shift-left defense against crashes.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
