Right, the issue has been solved.

 

The library ended up on the classpath, because the module descriptor could not 
be read (Classfile API will solve this in the future).

Plexus-java is the library responsible for this.

The latest version op plexus-java supports Java 23, and based on the 
documentation of the maven-surefire-plugin it should be using the latest 
version of plexus-java.

What I didn’t notice is that the maven-plugin *overview* says 3.5.0 is the 
latest maven-surefire-plugin version, whereas the documentation was generated 
for *3.5.1*.

 

So it was a mismatch in the documentation that confused me.

 

Sorry for the noise,

Robert

 

From: Alan Bateman <alan.bate...@oracle.com> 
Sent: maandag 14 oktober 2024 18:09
To: rfscho...@apache.org; core-libs-dev@openjdk.org
Subject: Re: ServiceLoader fails for Java 23 with preview enabled

 


Christian Stein mentioned that this is something to due with Surefire not 
supporting JDK 23 class files, is that right?

-Alan

On 13/10/2024 12:53, Robert Scholte wrote:

Hi,

 

It seems there’s a change in the ServiceLoader, and it looks like regression to 
me.

I’ve created a small project to reproduce it (I can provide it if wanted and 
confirmed this is indeed a bug).

 

What it basically does is just: 

ServiceLoader.load(Car.class).findFirst().orElseThrow();

 

This succeeds with OpenJDK 22 (with and without preview enabled flag)

 

It also succeeds with OpenJDK 23 without the preview flag.

 

However, when adding the preview flag I get:

 

java.util.NoSuchElementException: No value present

        at java.base/java.util.Optional.orElseThrow(Optional.java:377)

        at nl.sourcegrounds.serviceloader.tck.CarTest.<init>(CarTest.java:16)

 

Anyone who can already explain this with this small amount of information?

 

Thanks,

Robert Scholte

 

These are the details for both versions (Windows OS)

 

openjdk version "22" 2024-03-19

OpenJDK Runtime Environment (build 22+36-2370)

OpenJDK 64-Bit Server VM (build 22+36-2370, mixed mode, sharing)

 

 

openjdk version "23" 2024-09-17

OpenJDK Runtime Environment (build 23+37-2369)

OpenJDK 64-Bit Server VM (build 23+37-2369, mixed mode, sharing)

 

 

 

 

Reply via email to