Openj9: Convert modularity runtime checks to compile time

Created on 8 Jan 2019  路  10Comments  路  Source: eclipse/openj9

Beginner item

The J9_ARE_MODULES_ENABLED inspects the J9javaVM to determine if the JVM is modularity enable (Java 9+). Since we now have compilation flags distinguish the different Java levels this can now be turned into a compile time check

beginner

Most helpful comment

Java 9 is out of service and no longer supported.

All 10 comments

Will this cause problems if a JVM compiled for Java 9 is used for Java 8 JCL?

@pdbain-ibm Yes, that would be a problem. Are we doing this?

As I understand it, a Java version _N_ VM should be able to run as a previous version. Correct, @pshipton ?

a Java version N VM should be able to run as a previous version

It isn't something that is done. These days the code is compiled for a particular version. I think it is necessary now, because there is only a single jvm.so redirector created which matches the Java version being compiled. Although most everything else still uses runtime checks.

@tajila J9_ARE_MODULES_ENABLED is only used once in the codebase. Do you still want it to be removed?

Also, is there a reason why it is checking for versions >= 11, when modularity was introduced in 9?

@ShishirH The macro is only used once but we do the equivalent J2SE_VERSION(vm) >= J2SE_V11 check in many other places. My plan was to update this macro to be a compile time check so we can replace all the places where we manually check if modularity is enabled.

Also, is there a reason why it is checking for versions >= 11

I am not sure why this change was made. @JasonFengJ9 can you explain ?

Java 9 is out of service and no longer supported.

@tajila just as Pete stated above, J2SE_19 and J2SE_V10 have been removed, and all references to 9/10 were changed to 11.
Further more, we might use JAVA_SPEC_VERSION to replace J2SE_VERSION(vm) (https://github.com/eclipse/openj9/pull/5370).

Okay, then #5370 fixes this issue

5370 can simplify the runtime check via replacing the macro J9_ARE_MODULES_ENABLED with checking of JAVA_SPEC_VERSION.

It could become a compile time check if that's the direction to go.

Was this page helpful?
0 / 5 - 0 ratings