BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Google’s J2ObjC 1.0 Translates Java into Objective-C

Google’s J2ObjC 1.0 Translates Java into Objective-C

This item in japanese

Bookmarks

J2ObjC is an open source tool created by Google to translate Java code into corrresponding Objective-C code that can be run on iOS. The idea is to reuse Java business code between Android, web and iOS. For the web the translation is done with GWT. This tool does not deal with UI code which needs to be written separately for each platform.

We announced J2ObjC back in 2012 when it was an alpha release, presenting some details on how it works. Slowly, J2ObjC has reached the stable version 1.0, being used by several mobile applications ported by Google for iOS: Inbox, Calendar, Docs, Sheets, Slides and Google My Business. In the meantime, J2ObjC has been upgraded from using Java 6 to Java 7 and 8, their intent being to “support the current and previous major releases of Java, iOS, and Xcode,” according to Tom Ball, a Google Engineer working on the project. J2ObjC is integrated with JUnit, Mockito, Gradle and Maven.  It also supports embedding Objective-C code into Java code through native methods.

When asked how much of Java 8 is supported, Ball told us:

That depends how "Java 8" is defined. :-) We added support for the new Java 8 language features like lambda expressions and method references; however, since our JRE runtime is based on Android's libcore library, we don't yet support any of the new APIs introduced in Java 8. We plan on regularly syncing with the libcore team, so all Java 8 support they add will then shortly added to J2ObjC's runtime.

Regarding future development, Ball added:

J2ObjC is primarily a build tool, so all our future plans are driven by the needs of the app developers who use it. What we're currently hearing is that they need us to continue supporting new iOS features as soon as Apple releases them, better Swift interoperability, Java 8 API support, better tool integration, and reduced build times. As compiler engineers, we're also always focused on optimizing generated code and fixing reported bugs quickly.

J2ObjC has been licensed under the Apache License 2.0.

Rate this Article

Adoption
Style

BT