Skip to content

Upgrade to Gradle 8.14 and Java 24 minimum #14533

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

Merged
merged 8 commits into from
Apr 29, 2025
Merged

Conversation

dweiss
Copy link
Contributor

@dweiss dweiss commented Apr 22, 2025

This is an initial set of changes that:

  • update gradle to 8.14 (rc2), supporting Java 24,
  • bump minimum Java version to Java 24 (build support: java 24 #14379)
  • upgrade to an ECJ version that supports Java 24 (none yet) and revert the enabled=false from the patch
  • upgrade to gradle 8.14 (final)

Showstoppers for now:

  • ECJ doesn't have a version that supports Java 24 yet. I disabled ecj checks for now to verify other things work.
  • we should probably wait for the final version of gradle 8.14.

This was referenced Apr 22, 2025
@dweiss dweiss linked an issue Apr 22, 2025 that may be closed by this pull request
@rmuir
Copy link
Member

rmuir commented Apr 23, 2025

  • upgrade to an ECJ version that supports Java 24 (none yet) and revert the enabled=false from the patch

I don't understand this one: their language server works fine with java 24 and i'm able to navigate the new JDK24 classfile api, etc. I guess I haven't used it extensively, due to the gradle issue, and they've got some bugfixes since the last release.

@dweiss
Copy link
Contributor Author

dweiss commented Apr 23, 2025

I don't understand this one: their language server works fine with java 24 and i'm able to navigate the new JDK24 classfile api, etc. I guess I haven't used it extensively, due to the gradle issue, and they've got some bugfixes since the last release.

I don't fully understand it either - the latest artifact for the batch ecj compiler (what we use) seems to be from march:
https://repo1.maven.org/maven2/org/eclipse/jdt/ecj/3.41.0/

this doesn't support Java 24. I've just downloaded the latest Eclipse and it seems to contain the same batch compiler. Their website says this:

image

There are some marketplace extensions to support Java 24 but these seem to be external - so... I don't think Eclipse supports Java 24 yet?

@rmuir
Copy link
Member

rmuir commented Apr 23, 2025

I'm using https://github.com/eclipse-jdtls/eclipse.jdt.ls which, is just this same eclipse stuff packaged in a different way?

Screen_Shot_2025-04-23_at_05 09 47

It had the java 24 support like a week after the java 24 release. Sorry, I don't understand eclipse ecosystem.

@dweiss
Copy link
Contributor Author

dweiss commented Apr 23, 2025

I've no idea either. All I know is that if I download eclipse-jdt, it doesn't have support for Java 24 yet. There is a milestone version which supposedly has it - but not an official stable version, as far as I can see. And the maven repo definitely doesn't have the batch compiler supporting java24. That eclipse-jdls has a fork of jdt... which is also weird.

@dweiss
Copy link
Contributor Author

dweiss commented Apr 23, 2025

Eclipse 4.36M1 seems to have Java 24 support in the batch compiler. This is marked as "stable" but artifacts for this release are not on maven central yet.

@rmuir
Copy link
Member

rmuir commented Apr 23, 2025

Yeah I think "big old eclipse" lags behind, whereas the jdtls is "the latest" and sees more usage (e.g. all VSCode users and other editors).

There's even a plugin to allow use of jdtls in "big old eclipse": https://github.com/redhat-developer/eclipseide-jdtls/

very confusing ecosystem, but that's my read on it.

@dweiss
Copy link
Contributor Author

dweiss commented Apr 23, 2025

I believe they use p2 repositories for interim releases and only do a maven push once in a quarter for stable final releases.

If this becomes a problem, we can pull ecj directly from p2 drops, like here:
https://www.eclipse.org/downloads/download.php?file=/eclipse/downloads/drops4/S-4.36M1-202504031800/ecj-4.36M1.jar&r=1

@dweiss dweiss changed the title Initial upgrade to Gradle 8.14 (rc2) Upgrade to Gradle 8.14 Apr 29, 2025
@dweiss
Copy link
Contributor Author

dweiss commented Apr 29, 2025

I've replaced ecj batch compiler dependency with a direct download from Eclipse's p2 drop repositories. I don't think anybody will even notice the difference and p2 repositories seem to have a lot eager release cadence compared to maven eclipse artifacts (~3 months).

@uschindler
Copy link
Contributor

Please give a short notice to me directly before your merge this to main branch so I can update Jenkins Jobs on Policeman.

@uschindler
Copy link
Contributor

I am not really happy about downloading from the non-maven repo, but as this won't affect any release, I am fine. If we release main branch we should rellay switch to an offical Maven artifact for ECJ.

@dweiss
Copy link
Contributor Author

dweiss commented Apr 29, 2025

Please give a short notice to me directly before your merge this to main branch so I can update Jenkins Jobs on Policeman.

We can update anytime, really. I don't have the pressure to do this but everything seems to work fine so why wait.

@dweiss dweiss marked this pull request as ready for review April 29, 2025 09:15
@uschindler
Copy link
Contributor

Thats fine, we should just make sure (by comment or wahtever) that we can easily switch back in a documented way to official Maven artifacts before we release Main branch.

@@ -365,7 +365,9 @@ private static <A> MMapIndexInputProvider<A> lookupProvider() {
// access through the lookup:
final var constr = lookup.findConstructor(cls, MethodType.methodType(void.class, int.class));
try {
return (MMapIndexInputProvider<A>) constr.invoke(maxPermits);
@SuppressWarnings("unchecked")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL, whats the reason for this?

We should anways get rid on the whole code here in main branch and merge all files to the main compilation unit (except vectors, of course).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The compiler complains about it. Try reverting and see for yourself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does look odd, I agree.

Execution failed for task ':lucene:core:compileJava'.
> Compilation failed; see the compiler output below.
  Note: Recompile with -Xlint:deprecation for details.
  error: warnings found and -Werror specified
  /home/.../lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java:368: warning: [unchecked] unchecked cast
          return (MMapIndexInputProvider<A>) constr.invoke(maxPermits);
                                                          ^
    required: MMapIndexInputProvider<A>
    found:    MMapIndexInputProvider
    where A is a type-variable:
      A extends Object declared in method <A>lookupProvider()
  Note: Some input files use or override a deprecated API.
  1 error
  1 warning

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opened #14564 to get rid of all this shit.

At moment the other PR is based on Java 23, but it is easy to update to 24. At moment we forgot to change the code, so Java 21 was still in business in Main!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In future, when we update Java version we also need the updates in build system and sourcesets for vectors. So we need to change the mrJarVersions property in Gradle build, too and rename the sourceset folder java23 -> java24

@uschindler uschindler changed the title Upgrade to Gradle 8.14 Upgrade to Gradle 8.14 and Java 24 minimum Apr 29, 2025
@uschindler
Copy link
Contributor

@dweiss: I opened #14564 to get rid of MMapDirexctoy abstractions. I can wait with merging this until this one is merged. The update to Java 24 will be done before I commit.

For the future: Whenever we update Java versions, we also need to make sure to update the minimal versions in the mrJar code parts. At moment, it produces a MR-JAR file with Java 21.... (because that's the version where the APIJARs were extracted from). I fixed this in the other PR, no need to take care of it here. But for the update to Java 25 we should make sure that we update the APIJAR stub extraction also to Java 25.

@dweiss dweiss merged commit 9c67088 into apache:main Apr 29, 2025
10 checks passed
@dweiss
Copy link
Contributor Author

dweiss commented Apr 29, 2025

Ok, I've applied this to main. I will backport gradle upgrade selectively to 10x tomorrow (can't be cherry picked automatically).

@dweiss dweiss deleted the gradle-8.14 branch April 29, 2025 19:18
@dweiss
Copy link
Contributor Author

dweiss commented Apr 29, 2025

Ok, I've applied this to main. I will backport gradle upgrade selectively to 10x tomorrow (can't be cherry picked automatically).

2 similar comments
@dweiss
Copy link
Contributor Author

dweiss commented Apr 29, 2025

Ok, I've applied this to main. I will backport gradle upgrade selectively to 10x tomorrow (can't be cherry picked automatically).

@dweiss
Copy link
Contributor Author

dweiss commented Apr 29, 2025

Ok, I've applied this to main. I will backport gradle upgrade selectively to 10x tomorrow (can't be cherry picked automatically).

@uschindler
Copy link
Contributor

I disabled Policeman Jenkins Main Jobs, working on Upgrade. Can you take care of ASF Jenkins?

@uschindler
Copy link
Contributor

When testing this I figured out the following warning when starting with Java 24:

WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::load has been called by net.rubygrapefruit.platform.internal.NativeLibraryLoader in an unnamed module (file:/C:/Users/Uwe%20Schindler/.gradle/wrapper/dists/gradle-8.14-bin/38aieal9i53h9rfe7vjup95b9/gradle-8.14/lib/native-platform-0.22-milestone-28.jar)
WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module
WARNING: Restricted methods will be blocked in a future release unless native access is enabled

I think we need to change the gradlew / gradlew.cmd files to pass the additional command line option --enable-native-access=ALL-UNNAMED

@uschindler
Copy link
Contributor

I updated the other PR and generated the APIJAR for 24. For the next update, basically the same linke this commit needs to be done: 2ad382a

@dweiss
Copy link
Contributor Author

dweiss commented Apr 29, 2025

I think we need to change the gradlew / gradlew.cmd files to pass the additional command line option --enable-native-access=ALL-UNNAMED

I didn't touch the launcher scripts... could be that the latest from gradle already does it but we have quite a few tweaks in there that'd have to be ported. I'll look into this tomorrow, hopefully.

@dweiss
Copy link
Contributor Author

dweiss commented Apr 29, 2025

I disabled Policeman Jenkins Main Jobs, working on Upgrade. Can you take care of ASF Jenkins?

I've switched all jobs on asf jenkins to Java 24. Hopefully didn't miss anything.

@uschindler
Copy link
Contributor

I think we need to change the gradlew / gradlew.cmd files to pass the additional command line option --enable-native-access=ALL-UNNAMED

I didn't touch the launcher scripts... could be that the latest from gradle already does it but we have quite a few tweaks in there that'd have to be ported. I'll look into this tomorrow, hopefully.

I think adding that as command line option should be easy to do. Basically the parameter is available since Java 20 or 21 (since Panama exists), so it should also work with launching from older java versions and it won't fail with error message before ours.

@uschindler
Copy link
Contributor

Policeman Jenkins was also updated. I hope the randomization and RUNTIME_JAVA_HOME with 25 works, too. If something breaks, I will keep an eye on it.

@uschindler
Copy link
Contributor

I also updated the 10.x release tester job to use Java 24, too. This will affect the next release. Of course Gradle backport is needed.

@dweiss
Copy link
Contributor Author

dweiss commented Apr 30, 2025

I think we need to change the gradlew / gradlew.cmd files to pass the additional command line option --enable-native-access=ALL-UNNAMED

gradle is now launched with --jar and contains a manifest entry for this (no need to tweak the scripts). Should be fine with #14592

@uschindler
Copy link
Contributor

I got a strange error:

  • What went wrong:
    Execution failed for task ':downloadEcjDrop'.

A failure occurred while executing de.undercouch.gradle.tasks.download.internal.DefaultWorkerExecutorHelper$DefaultWorkAction
javax.net.ssl.SSLHandshakeException: (certificate_unknown) PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

But on second try it worked.

Another problem is that the ECJ compiler config is not using 24 but still 23 in this PR. I will fix this in a commit.

@uschindler
Copy link
Contributor

Fixed: 0550cc6

@uschindler
Copy link
Contributor

One information about Exclipse: With the recent commit all works fine. It just sometimes fails with a compilation error (but that's not new) regarding: "Permitted type LeafReaderContext does not declare org.apache.lucene.index.IndexReaderContext as a direct supertype"

This error is bullshit but something seems to confuse the compile inside the Eclipse IDE.

Anyways: If you want to use exclipse, you need to install the Milestone 1 of 2025-06 release, otherwise it won't work (same reason like discussed above). Luckily on starting Eclipse it asks you if you want to try the milestone release.

weizijun added a commit to weizijun/lucene that referenced this pull request Apr 30, 2025
* main: (51 commits)
  Fix ECJ compiler config for Java 24 (also affects Eclipse IDE)
  Correct shebang in gradlew. apache#14592
  Overwrite gradlew scripts with up-to-date ones and apply Lucene customizations. (apache#14592)
  Remove abstractions of MMapDirectory and its "fake" MR-JAR support and move it to main sourceSet (vectors untouched) (apache#14564)
  deps(java): bump org.gradle.toolchains.foojay-resolver-convention (apache#14573)
  deps(java): bump com.gradle.develocity from 3.18.2 to 4.0.1 (apache#14585)
  deps(java): bump nl.littlerobots.version-catalog-update (apache#14568)
  Bump expected base Java version to 24. apache#14533
  Create file open hints on IOContext to replace ReadAdvice (apache#14482)
  deps(java): bump com.github.ben-manes.versions from 0.51.0 to 0.52.0 (apache#14574)
  deps(java): bump org.owasp.dependencycheck from 7.2.0 to 12.1.1 (apache#14584)
  deps(java): bump org.eclipse.jgit:org.eclipse.jgit (apache#14579)
  deps(java): bump com.diffplug.spotless from 6.9.1 to 7.0.3 (apache#14588)
  deps(java): bump com.gradle.common-custom-user-data-gradle-plugin (apache#14587)
  deps(java): bump net.ltgt.errorprone from 4.1.0 to 4.2.0 (apache#14567)
  deps(java): bump org.locationtech.jts:jts-core from 1.17.0 to 1.20.0 (apache#14586)
  deps(java): bump org.apache.opennlp:opennlp-tools from 2.5.3 to 2.5.4 (apache#14580)
  deps(java): bump asm from 9.6 to 9.8 (apache#14578)
  deps(java): bump commons-codec:commons-codec from 1.17.2 to 1.18.0 (apache#14581)
  deps(java): bump net.java.dev.javacc:javacc from 7.0.12 to 7.0.13 (apache#14576)
  ...

# Conflicts:
#	lucene/CHANGES.txt
@dweiss
Copy link
Contributor Author

dweiss commented Apr 30, 2025

Thank you, Uwe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

build support: java 24
3 participants