Watch Out For OpenJDK Differences on Android N

Android N is shipping with its java.* and javax.* classes derived from the OpenJDK, rather than from Apache Harmony. Many of the Harmony classes were modified in Android since Android 1.0, and the JDK itself has gone through a couple of major releases. So, while there are large test batteries designed to confirm that everything is compatible, some changes in behavior are likely to slip through the cracks.

For example, eagle-eyed developers have noted that java.io.File path normalization has changed and that java.text.DecimalFormat has changed. I have reproduced both of their test results and can confirm the differences.

It is entirely possible that these will be altered to be compatible with past versions of Android before Android N ships in final form. It is theoretically possible that these are the only two such differences, but that seems unlikely.

Hence, more so than with past developer previews, it is key for you to be testing your code early and thoroughly, to see whether you trip over similar sorts of JDK class differences. At minimum, you will have time to find a workaround. Even better, file an issue, and see if the incompatibilities can get fixed.


Find out about new posts on the CommonsBlog via the Atom feed, or follow @CommonsWare on Twitter!