Java 15 support

84 views
Skip to first unread message

Jindrich Sarson

unread,
Jun 24, 2021, 9:26:56 AM6/24/21
to j2objc-discuss
Hi,

our Android devs told me today, that new version of Gradle build system will support Java 16. I am wondering, how is J2ObjC with those new java versions - we are interested especially about support for Records, Sealed classes, Switch expressions or Text block.

Is there a plan to support versions above Java 11?

Thanks,

Jindrich

Tom Ball

unread,
Jun 24, 2021, 12:38:15 PM6/24/21
to j2objc-...@googlegroups.com
You can now experiment with unsupported versions as of commit 69efaa6 by specifying the "-XDallVersions" flag along with a "-source" version through Java 17. Since j2objc uses javac for its front-end, many new language features are immediately available if they have no impact on generated code or add to the JRE. In Java 11, for example, the "var" keyword was free since javac handled it, whereas the "not" Predicate method wasn't since it was a JRE change. So try the features you're interested in, and let everyone know what works "out of the box."

The jre_emul library is largely a fork of the Android libcore library, so if a JRE feature isn't part of that library, it's unlikely to be in jre_emul. For example, in Java 11 readString() and writeString() methods were added to the Files class, but currently aren't in libcore. We could certainly use the OpenJDK version of that class, but won't because j2objc's primary purpose is to support cross-platform Java, especially on Android. That's also why there's no hurry to jump on new Android JRE classes, as Android teams need to write to the Android version that is available on all devices they support, and therefore won't be using the new API immediately.

One thing we don't currently support is javac's --enable-preview flag to try out preview features, but I'll be adding that soon pending code review.

--
You received this message because you are subscribed to the Google Groups "j2objc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to j2objc-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/j2objc-discuss/ab0cca7d-7d41-4e16-b84a-9fde2ca24689n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages