Anda di halaman 1dari 9

J2ObjC

iOS App Access to Java Libraries


Tom Ball, Google Senior Software Engineer http://j2objc.googlecode.com

"Google, why on earth?"


- First day tweet Frustration developing multi-platform application GWT app leading development, with Android/iOS doing
catch-up

Java-based client-server service layer


Only shared by GWT and Android clients Protocol changes needed fast turnaround

Crazy idea: write translator


"Okay, but it won't work ..."

Projects Evaluated
FlexyCore/in-the-box
iOS port of Dalvik VM and Android APIs Rejected: non-standard L&F, iOS license conflicts

XMLVM
Many translation bugs Significant pieces of JRE missing Java -> ObjC translation no longer supported

java2objc (code.google.com)
Syntax translation only, output won't build Project in early dev., abandoned

J2ObjC
J2ObjC is a new source translator/compiler. Converts Java source code to Objective C
Foundation Framework focus No editing needed

Has an open-source JRE (subset) runtime Translates, builds and links with iOS app Run within Xcode or on command-line
Debug with Xcode or GDB

What J2ObjC Isn't


J2ObjC is not a cross-platform application tool
No cross-platform UI support

J2ObjC is not a Java emulator


Objective C code is generated Compiled to object files, linked into app Debug using Xcode or GDB

J2ObjC is not for one-time source translation


Comments removed, output reformatted

What is Supported?
Full Java 6 syntax (Java 7 coming) Inner and anonymous classes Exceptions, try/catch/finally Static variables Enums Autoboxing Synchronization Fields use Objective C properties JSNI-style native code embedding Java collections JUnit test translation ...

JRE
Based on Apache Harmony, Android source Similar subset as GWT
java.lang, java.lang.reflect java.io (subset) java.util, java.util.logging, java.util.concurrent java.math, java.nio (subset)

Apache Harmony tests used for verification

Three Memory Options


Resource Counting (default)
retain, release, and autorelease calls added dealloc method generated Autorelease pool added to main method

Automatic Resource Counting (ARC)


Full runtime support requires iOS 5

Garbage Collection
finalize method mapped or generated Not supported on iOS

More Information
Project site: http://j2objc.googlecode.com
Downloads Documentation wiki Full source code Issues

Email: j2objc-discuss@googlegroups.com Thanks for listening!

Anda mungkin juga menyukai