BT

Google’s J2ObjC 1.0 Translates Java into Objective-C

by Abel Avram on Feb 05, 2016 |

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

Relevance
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss
General Feedback
Bugs
Advertising
Editorial
Marketing
InfoQ.com and all content copyright © 2006-2016 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT

We notice you’re using an ad blocker

We understand why you use ad blockers. However to keep InfoQ free we need your support. InfoQ will not provide your data to third parties without individual opt-in consent. We only work with advertisers relevant to our readers. Please consider whitelisting us.