Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit

…ing the

associated methods and functions use the enum typedefs instead of plain
integer types. Adds a new NS_ENUM for the proto enum values (getNumber, etc.)
and comments attempting to explain the distinction in the header.

To prevent the transpiled types from being more restrictive for transpiled Java than
native Java, the generated headers declare a different interface for the enums
depending on whether the code is imported from transpiled code vs hand-written
Obj-C and Swift.

Ideally this should enable the compiler to warn about conversions between types,
incomplete switch coverage, etc. at transitions between transpiled and
hand-written code.

Since warnings from transpiled code on unimplemented switch cases appear to be
often wrong, suppress them with new clang flags in implementation files.
Instead turn the -Wreturn-type warning into an error, which is closer to what
the Java compiler would do.

Unfortunately, native code using the proto enums still has cases where enum
type conversions generate no clang warning, which should happen with
-Wenum-compare-switch and similar. It appears this is because Xcode's clang
has several of enum-related warnings turned permanently off.

However, some mistakes on enum usage with these APIs do warn, so on balance
this still seems like an improvement.

PiperOrigin-RevId: 506093169

Git stats


Failed to load latest commit information.
Latest commit message
Commit time

J2ObjC: Java to Objective-C Translator and Runtime

Project site:
J2ObjC blog:
Questions and discussion:

What J2ObjC Is

J2ObjC is an open-source command-line tool from Google that translates Java source code to Objective-C for the iOS (iPhone/iPad) platform. This tool enables Java source to be part of an iOS application's build, as no editing of the generated files is necessary. The goal is to write an app's non-UI code (such as application logic and data models) in Java, which is then shared by web apps (using GWT), Android apps, and iOS apps.

J2ObjC supports most Java language and runtime features required by client-side application developers, including exceptions, inner and anonymous classes, generic types, threads and reflection. JUnit test translation and execution is also supported.

J2ObjC is currently beta quality. Several Google projects rely on it, but when new projects first start working with it, they usually find new bugs to be fixed. If you run into issues with your project, please report them!

What J2ObjC isn't

J2ObjC does not provide any sort of platform-independent UI toolkit, nor are there any plans to do so in the future. We believe that iOS UI code needs to be written in Objective-C, Objective-C++ or Swift using Apple's iOS SDK (Android UIs using Android's API, web app UIs using GWT, etc.).

J2ObjC cannot convert Android binary applications. Developers must have source code for their Android app, which they either own or are licensed to use.



This library is distributed under the Apache 2.0 license found in the LICENSE file. The protocol buffers library is distributed under the same BSD license as Google's protocol buffers. See its README and LICENSE.

Running on GNU/Linux

To build and run on GNU/Linux, install the Darling project, then following its Compile and Run a Program example. Please note that j2objc is only supported on iOS/macOS.