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

Verify AnkiDroid works with JDK16 for development #8434

Closed
mikehardy opened this issue Apr 2, 2021 · 12 comments · Fixed by #8634
Closed

Verify AnkiDroid works with JDK16 for development #8434

mikehardy opened this issue Apr 2, 2021 · 12 comments · Fixed by #8634
Labels
Dev Development, testing & CI
Milestone

Comments

@mikehardy
Copy link
Member

Currently JDK16 is the most up to date JDK version available (https://adoptopenjdk.net/archive.html?variant=openjdk16&jvmVariant=hotspot)

AnkiDroid has a test in build.gradle to make sure only JDKs we have verified are used (there have been problems in the past...) So JDK16 is not currently allowed, the most recent allowed is JDK14

The task here is to:

  • install JDK16 (adoptopenjdk.net is highly recommended - and their builds are typically available via a package manager on your machine, like brew for macos, apt for ubuntu, possibly choco for windows, etc)

  • alter the build.gradle test so it allows JDK16 then verify when you build AnkiDroid that it is using the JDK16 binary

  • run ./gradlew clean jacocoTestReport lintRelease to make sure everything is working

Post a PR with the change the build.gradle test so it allows JDK8 and JDK11 (the two LTS versions of the JDK) as well as 16 (the current version)

Originally posted by @mikehardy in #8387 (comment)

@mikehardy
Copy link
Member Author

Oh - I should say sometimes there are errors! JDK11 did not work until we fixed a few things. If there are problems, correcting them as either as independent clean commits on the PR as separate PRs would work

@ritvij14
Copy link
Contributor

ritvij14 commented Apr 3, 2021

@mikehardy can I work on this?
I have gone through the issue description (and also the comment that you linked) and understood what needs to be done.

If there are problems, correcting them as either as independent clean commits on the PR as separate PRs would work

If there are many problems that require changes, I will send separate PRs from my branch and link them all to this issue.

@mikehardy
Copy link
Member Author

Please do! Thank you @ritvij14 - hopefully it's a quick one, there ...should not be problems? You just never know until you try though :-)

@ritvij14
Copy link
Contributor

ritvij14 commented Apr 3, 2021

@mikehardy after following the above tests, I got this result on running the command:

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':api:compileDebugJavaWithJavac'.
> java.lang.IllegalAccessError: class org.gradle.internal.compiler.java.ClassNameCollector (in unnamed module @0x40668c7d) cannot access class com.sun.tools.javac.code.Symbol$TypeSymbol (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.code to unnamed module @0x40668c7d

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':lint-rules:compileJava'.
> java.lang.IllegalAccessError: class org.gradle.internal.compiler.java.ClassNameCollector (in unnamed module @0xe8b0f4d) cannot access class com.sun.tools.javac.code.Symbol$TypeSymbol (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.code to unnamed module @0xe8b0f4d

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.8.3/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1m 24s
20 actionable tasks: 6 executed, 14 from cache

I haven't worked with multiple jdk versions on the same project before so will need some help in understanding what needs to be resolved 😅

@mikehardy
Copy link
Member Author

I'm not sure we can resolve it! Wow, that's a very low level 💥

Probably best to wait for the underlying tools to handle JDK16 and until then, our build.gradle warning is valid, we work with 8, 11 and 14 (although it does say latest - and 14 is no longer latest, it's not worth changing at the moment)

I'll label this one as blocked on dependency

Although if you search in stackoverflow or gradle issue tracker for issues with JDK16 you may find people already discussing the underlying cause

@mikehardy mikehardy added Blocked by dependency Currently blocked by some other dependent / related change and removed Good First Issue! labels Apr 3, 2021
@mikehardy
Copy link
Member Author

Note: seeing discussion of the underlying cause would just be for interest - sometimes I find that stuff interesting? - you might

And regardless, I appreciate that you gave it a spin, now we know it does not work and all knowledge has some value

@ritvij14
Copy link
Contributor

ritvij14 commented Apr 3, 2021

Ok understood. I will give them a read, they do sound interesting, and will move onto another issue for now.

@mikehardy
Copy link
Member Author

Gradle 7 will support JDK16
gradle/gradle@181b126

It's on RC2 right now so I imagine it will come soon. This is not a high priority item I was just reading other things, noticed it and am persisting the knowledge as a comment here

@mikehardy
Copy link
Member Author

gradle 7 is out and has the support https://docs.gradle.org/7.0/release-notes.html#java-16
this is blocked by #5634

@mikehardy mikehardy mentioned this issue Apr 16, 2021
7 tasks
@mikehardy
Copy link
Member Author

I gave this an attempt now that we have Gradle 7 working, but the android gradle plugin is the current blocker for JDK16. This isn't a priority but I was in the area. No JDK16 for now, keep using 8 or 11

@github-actions
Copy link
Contributor

Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically

@github-actions github-actions bot added the Stale label Jun 15, 2021
@mikehardy
Copy link
Member Author

Looked at this again as it went stale.
Apparently it is possible (and arguably best practice?) to specify a language toolchain for java in gradle so that PATH controls how gradle executes, but the gradle toolchain spec instructs gradle to use a specific (maybe different) JDK for app compilation / execution

https://melix.github.io/blog/2021/03/gradle-java16.html

I'm not saying I want to do this as our Java requirements are dominated by the Java requirements of Android devices, but it's a thing.

Going to set this to sleep again and wait for "Arctic Fox" to come out to see if it just resolves itself from our perspective via updated major releases (it should)

@mikehardy mikehardy removed the Stale label Jun 15, 2021
@mikehardy mikehardy removed the Blocked by dependency Currently blocked by some other dependent / related change label Aug 5, 2021
@mikehardy mikehardy added this to the 2.16 release milestone Aug 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dev Development, testing & CI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants