Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Java 17 #31

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

Upgrade to Java 17 #31

wants to merge 5 commits into from

Conversation

j-mao
Copy link
Member

@j-mao j-mao commented Jan 1, 2022

Upgrades JDK version from 1.8 to 1.17. This PR is incomplete: if you have ideas on how to elegantly resolve the remaining tasks below, we'd greatly appreciate your contribution!

Completed tasks:

  • Upgrade to more recent Gradle version.
  • Rewrite Javadoc to remove dependence on deprecated and/or obsolete packages.
  • Upgrade instrumenter to use ASM9 instead of ASM5.

Remaining tasks todo:

  • Allow access to jdk.internal package, specifically the jdk.internal.misc.Unsafe class. If rewritten to instrumented.jdk.internal, the native linkage fails. If left untouched, the "modules" feature from Java 9 blocks access from rewritten packages such as instrumented.java.util.Random. One choice that works is to add the JVM arguments --add-opens java.base/jdk.internal.misc=ALL-UNNAMED, I'm not sure what other implications this may have. Another option may be to investigate how to use the ModuleLayer class.
  • Resolve other IllegalAccessExceptions. For example, java.util.Arrays.sort reads private members of java.util.Arrays.LegacyMergeSort. Somewhere during classloading, Java has come to believe that the latter is not nested in the former, and rejects this read.
  • Confirm that Javadoc rewrite is correct; it has not yet been tested.
  • Do other generic testing.

@j-mao j-mao added the help wanted Extra attention is needed label Jan 4, 2022
@djkeyes
Copy link

djkeyes commented Mar 28, 2023

Hi! Is this still in the works?

I was playing around with upgrading the java version using the battlecode23 engine over here.

I've run into most of the same issues that you have. That is:

  • Several public java packages require opens-access to packages in java.internal.*. So far, I think the --add-opens java.base/jdk.internal.misc=ALL-UNNAMED approach seems reasonable, although I've noticed that there are more packages than just jdk.internal.misc that need to be imported in order to support everything in java.util, and I do not have a good way to enumerate them.
  • There's some bug in instrumenting java.util.Arrays.Sort(Object[]) Edit: this is due to the Java 11 nest-based access control. The latest versions of ASM have an easy way to fix it.
  • A few new java features require some updates to the instrumenter. Specifically the record keyword makes use of the invokedynamic instruction in a way that the code was not originally designed to handle. (There's also a known issue with using invokedynamic for method references, I'm not sure if this is related.)

I've noticed some built-in Java containers use less bytecodes in Java 17 than before, which is neat (assuming that's not a bug), so I think an upgrade would be really valuable for competitors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants