Hello Robert,

This certainly looks like a behavioural change that would need investigation. So yes, a reproducer will be helpful.

-Jaikiran

On 13/10/24 5:23 pm, 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