---
title: "Translating Java to Kotlin at Scale"
description: "Meta is translating roughly ten million lines of Android Java to Kotlin using the Kotlinator, an automated pipeline built around a headless version of JetBrains' J2K."
url: "https://swe.quest/articles/translating-java-to-kotlin-at-scale-3648a1737157b36f"
canonical: "https://engineering.fb.com/2024/12/18/android/translating-java-to-kotlin-at-scale/"
source: "Meta Engineering"
published: "2024-12-18"
difficulty: "medium"
kind: "Case study"
reading_minutes: 13
tags: ["jvm","refactoring","mobile","static-analysis","developer-tools"]
---

# Translating Java to Kotlin at Scale

A post on [Meta Engineering](https://swe.quest/sources/meta.md), published 2024-12-18, 13 min read, Case study. Original: [https://engineering.fb.com/2024/12/18/android/translating-java-to-kotlin-at-scale/](https://engineering.fb.com/2024/12/18/android/translating-java-to-kotlin-at-scale/)

## Summary

Meta is translating roughly ten million lines of Android Java to Kotlin using the Kotlinator, an automated pipeline built around a headless version of JetBrains' J2K. It runs six phases: a deep build, about 50 preprocessing steps, headless J2K, about 150 postprocessing steps, linters with autofixes, and fixes driven by compiler errors. A daily cron system produces the conversion diffs for human review. Null safety comes first, because Kotlin inserts runtime null checks at the Java interop boundary, so the Kotlinator errs toward nullable types to avoid introducing new NPEs. Meta is also working with JetBrains to add extension hooks to J2K for better symbol resolution and to open-source some of its steps.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Java & JVM](https://swe.quest/tags/jvm.md) (Languages)
- [Refactoring & migrations](https://swe.quest/tags/refactoring.md) (Engineering practices)
- [Mobile](https://swe.quest/tags/mobile.md) (Web & mobile)
- [Static analysis](https://swe.quest/tags/static-analysis.md) (Engineering practices)
- [Developer tools](https://swe.quest/tags/developer-tools.md) (Engineering practices)

## Prerequisites

- Java and Kotlin basics ([easy posts on Java & JVM](https://swe.quest/tags/jvm.md?difficulty=easy))
- Android development ([easy posts on Mobile](https://swe.quest/tags/mobile.md?difficulty=easy))
- nullability annotations

## Keywords

Kotlin, J2K, Kotlinator, IntelliJ, Nullsafe, NullAway, K2, JetBrains PSI

## Related posts

- [From zero to 10 million lines of Kotlin](https://swe.quest/articles/from-zero-to-10-million-lines-of-kotlin-e0f9a5140a87605f.md): Meta Engineering · 2022-10-24 · Medium · 13 min read · Java & JVM, Refactoring & migrations, Mobile, Developer tools
  Meta has converted its Android codebase to over 10 million lines of Kotlin by wrapping JetBrains' J2K converter in an automated pipeline called Kotlinator.
- [Retrofitting null-safety onto Java at Meta](https://swe.quest/articles/retrofitting-null-safety-onto-java-at-meta-9ef65f9615ca03e4.md): Meta Engineering · 2022-11-22 · Medium · 15 min read · Static analysis, Java & JVM, Type systems, Mobile
  Nullsafe is a static analyzer built at Meta to catch NullPointerExceptions in Java, implemented as an extra compiler pass via the JSR-199 compiler API.
- [How we use Kotlin for backend services at Zalando](https://swe.quest/articles/how-we-use-kotlin-for-backend-services-at-zalando-86a4c360d01f2393.md): Zalando Engineering · 2021-06-30 · Easy · 4 min read · Java & JVM, Engineering culture, API design
  Zalando moved Kotlin from TRIAL to ADOPT on its Tech Radar, making it the third supported JVM language alongside Java and Scala after 100+ new Kotlin applications were written in a year.
- [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.
- [It’s a non-transitive R class world](https://swe.quest/articles/it-s-a-non-transitive-r-class-world-dc7be71b63e01554.md): Slack Engineering · 2023-02-01 · Medium · 5 min read · Mobile, Build systems, Refactoring & migrations, Static analysis, Developer productivity
  Slack migrated its 400+ module Android codebase to non-transitive R classes, where each module's R class contains only its own resources, yielding ~14% faster incremental builds after resource or layout changes and an ~8.5% (about 5.5MB) APK/DEX size reduction.

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)
