javaandroidcode-analysisruntime-environment

How to determine Java Version per Android OS version


I was looking (hoping) for a simple mapping from each android OS version to a version of Java.

More specifically. I am focusing on the Android OS side (not the application side), the ART: what version of the JVM does it uses.

I still have some hope due to source code diving seems to relate it to the java supported by dx (I guess now d8 and r8), the dex compiler.

In libcore/libart/src/main/java/java/lang/AndroidHardcodedSystemProperties.java:

final static String[][] STATIC_PROPERTIES = {
// None of these four are meaningful on Android, but these keys are guaranteed
// to be present for System.getProperty. For java.class.version, we use the maximum
// class file version that dx currently supports.
{ "java.class.version", "50.0" },
{ "java.version", JAVA_VERSION },

But the android developer blog may rather imply the library of java used is ad hoc/custom (blogpost) with a mix of versions: First openjdk 1.7 with desugared features of openjdk 1.8 Now more like 8 (but not all features) with desugared features of Java 8+.


Solution

  • Thanks all for your help.

    To whomever might be interested, I analysed the openjdk java classes in each release version of libcore, from Android 7 to 13. I compared to which version of openJDK each class is closer to (post android dev team modifications).

    The results are published in this article (repository link in the article): https://www.abartel.net/static/p/secdev2023-AndroidJCL.pdf