Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Meta Engineering 13 min read Case study mediumAdept

Translating Java to Kotlin at Scale

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.

Assumes: Java and Kotlin basicsAndroid developmentnullability annotations

Related posts

  • From zero to 10 million lines of Kotlin

    Meta Engineering mediumAdept

    Meta has converted its Android codebase to over 10 million lines of Kotlin by wrapping JetBrains' J2K converter in an automated pipeline called Kotlinator. The pipeline preprocesses Java packages, runs J2K headlessly through Android Studio, then applies automated refactors and linters built on the Kotlin compiler's PSI AST. Those refactors fix issues such as JUnit @Rule annotations needing @JvmField or @get:Rule, and replace TextUtils.isEmpty with isNullOrEmpty. Meta chose a full conversion over Kotlin-for-new-code-only to avoid platform-type null risks from Java interop. Results: about 11% fewer lines, no runtime performance regression in A/B tests, negligible APK size impact after Proguard/Redex, and longer build times as the main cost.

  • Retrofitting null-safety onto Java at Meta

    Meta Engineering mediumAdept

    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. It runs flow-sensitive nullness type inference over a control flow graph, then type checks the AST against those results, with added support for nullness in generics despite complications from Java's target typing. A three-tier model (Nullsafe-compliant, optimistically checked first-party code, pessimistically checked third-party code) allowed gradual adoption across millions of lines of legacy code. On Instagram, production NPE crashes fell 27% over 18 months of code transformation.

  • How we use Kotlin for backend services at Zalando

    Zalando Engineering easyNovice

    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. A Kotlin Guild with 250+ members produced guidelines, templates and default tooling recommendations for backend services. These defaults include Spring Boot (with Ktor as a rising option), Gradle with Kotlin build scripts, ktlint, kotlin-logging, Lettuce for Redis, JPA or jOOQ for relational databases, and opentracing-toolbox. APIs are defined in OpenAPI and linted with Zally, and auth is handled at the Skipper ingress rather than with Spring Security.

  • How we migrated our static analyzer from Java to Rust

    Datadog Engineering mediumAdept

    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 rewrite ran analysis about 3x faster with roughly 10x less memory, which matters on small CI runners. Shipping a single binary also removed the JVM dependency, so the same analyzer now runs inside the IDE. The team replaced GraalVM with deno-core as a sandboxed JavaScript rule runtime and mapped Java libraries to serde_yaml, reqwest and rayon. Learning Rust and migrating took about a month, helped by parity tests, clippy and rustfmt.

  • It’s a non-transitive R class world

    Slack Engineering mediumAdept

    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. Because Android Studio's built-in migration refactor stalled at this scale, the team used regex find-and-replace on the two modules holding most resources, a script to add Kotlin import aliases (e.g. L10nR, SlackKitR), and then enabled android.nonTransitiveRClass and android.enableAppCompileTimeRClass. Shared live templates and three auto-fixing lint checks enforce consistent alias conventions, and the migration also exposed misplaced resources and made resource origins easier to trace.

The quest for software engineering knowledge.

Look:
Layout: