Fix IllegalStateException: WELD-001578 (Jersey 6000) on JDK 24+.

Signed-off-by: jansupol <jan.supol@oracle.com>
diff --git a/incubator/cdi-inject-weld/src/main/java/org/glassfish/jersey/inject/weld/internal/bean/JerseyBean.java b/incubator/cdi-inject-weld/src/main/java/org/glassfish/jersey/inject/weld/internal/bean/JerseyBean.java
index 66594f9..b5f4a01 100644
--- a/incubator/cdi-inject-weld/src/main/java/org/glassfish/jersey/inject/weld/internal/bean/JerseyBean.java
+++ b/incubator/cdi-inject-weld/src/main/java/org/glassfish/jersey/inject/weld/internal/bean/JerseyBean.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021, 2023 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021, 2025 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -172,7 +172,7 @@
 
     @Override
     public Class<?> getBeanClass() {
-        return Object.class;
+        return getClass();
     }
 
     @Override
diff --git a/inject/cdi2-se/src/main/java/org/glassfish/jersey/inject/cdi/se/bean/JerseyBean.java b/inject/cdi2-se/src/main/java/org/glassfish/jersey/inject/cdi/se/bean/JerseyBean.java
index 8f3fc55..5f68c59 100644
--- a/inject/cdi2-se/src/main/java/org/glassfish/jersey/inject/cdi/se/bean/JerseyBean.java
+++ b/inject/cdi2-se/src/main/java/org/glassfish/jersey/inject/cdi/se/bean/JerseyBean.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2023 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2025 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -163,7 +163,7 @@
 
     @Override
     public Class<?> getBeanClass() {
-        return Object.class;
+        return getClass();
     }
 
     @Override
diff --git a/tests/e2e-inject/cdi2-se/src/main/java/org/glassfish/jersey/tests/e2e/inject/cdi/se/j6000/PingService.java b/tests/e2e-inject/cdi2-se/src/main/java/org/glassfish/jersey/tests/e2e/inject/cdi/se/j6000/PingService.java
new file mode 100644
index 0000000..e42df16
--- /dev/null
+++ b/tests/e2e-inject/cdi2-se/src/main/java/org/glassfish/jersey/tests/e2e/inject/cdi/se/j6000/PingService.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.jersey.tests.e2e.inject.cdi.se.j6000;
+
+import jakarta.ws.rs.core.Response;
+
+public interface PingService {
+    String HELLO_WORLD = "Hello world!";
+
+    Response ping();
+}
diff --git a/tests/e2e-inject/cdi2-se/src/main/java/org/glassfish/jersey/tests/e2e/inject/cdi/se/j6000/PingServiceImpl.java b/tests/e2e-inject/cdi2-se/src/main/java/org/glassfish/jersey/tests/e2e/inject/cdi/se/j6000/PingServiceImpl.java
new file mode 100644
index 0000000..c99f423
--- /dev/null
+++ b/tests/e2e-inject/cdi2-se/src/main/java/org/glassfish/jersey/tests/e2e/inject/cdi/se/j6000/PingServiceImpl.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2025 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.jersey.tests.e2e.inject.cdi.se.j6000;
+
+import jakarta.enterprise.context.RequestScoped;
+import jakarta.ws.rs.core.Response;
+
+@RequestScoped
+public class PingServiceImpl implements PingService {
+    @Override
+    public Response ping() {
+        Package pkg = getClass().getPackage();
+        String str = HELLO_WORLD //
+                + "\n\nImplementation-Title:   " + pkg.getImplementationTitle() //
+                + "\nImplementation-Version: " + pkg.getImplementationVersion() //
+                + "\nImplementation-Vendor:  " + pkg.getImplementationVendor();
+
+        return Response.ok().entity(str).build();
+    }
+}
\ No newline at end of file
diff --git a/tests/e2e-inject/cdi2-se/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/se/j6000/PingApi.java b/tests/e2e-inject/cdi2-se/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/se/j6000/PingApi.java
new file mode 100644
index 0000000..e389cff
--- /dev/null
+++ b/tests/e2e-inject/cdi2-se/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/se/j6000/PingApi.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.jersey.tests.e2e.inject.cdi.se.j6000;
+
+import jakarta.inject.Inject;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
+
+@Path("/ping")
+public class PingApi {
+    private @Inject PingService delegate;
+
+    @GET
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response ping() {
+        return this.delegate.ping();
+    }
+}
\ No newline at end of file
diff --git a/tests/e2e-inject/cdi2-se/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/se/j6000/TestServer.java b/tests/e2e-inject/cdi2-se/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/se/j6000/TestServer.java
new file mode 100644
index 0000000..d1d9c54
--- /dev/null
+++ b/tests/e2e-inject/cdi2-se/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/se/j6000/TestServer.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2025 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.jersey.tests.e2e.inject.cdi.se.j6000;
+
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.ws.rs.ApplicationPath;
+import jakarta.ws.rs.SeBootstrap;
+import jakarta.ws.rs.client.ClientBuilder;
+import jakarta.ws.rs.core.Application;
+import jakarta.ws.rs.core.Response;
+import org.glassfish.jersey.server.spi.WebServer;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import java.util.Set;
+import java.util.concurrent.CompletionStage;
+import java.util.concurrent.ExecutionException;
+
+@ApplicationPath("/")
+@ApplicationScoped
+public class TestServer extends Application implements AutoCloseable {
+
+    private CompletionStage<SeBootstrap.Instance> instance;
+
+    public CompletionStage<SeBootstrap.Instance> startServer(int port) throws GeneralSecurityException, IOException {
+        jakarta.ws.rs.SeBootstrap.Configuration.Builder builder = SeBootstrap.Configuration.builder()
+                .port(port)
+                .rootPath("/")
+                .protocol("HTTP");
+
+        this.instance = SeBootstrap.start(this, builder.build());
+        this.instance.thenAccept(i -> {
+            System.out.println("server started");
+        });
+        return this.instance;
+    }
+
+    @Override
+    public Set<Class<?>> getClasses() {
+        return Set.of(PingApi.class);
+    }
+
+    @Override
+    public void close() throws Exception {
+    }
+
+    @Test
+    void testJerseyBeanGetBeanClass() throws GeneralSecurityException, IOException, ExecutionException, InterruptedException {
+        final String sPort = System.getProperty("jersey.config.test.container.port");
+        int port = sPort == null || sPort.isEmpty() ? 8080 : Integer.parseInt(sPort);
+        TestServer server = new TestServer();
+        SeBootstrap.Instance instance = server.startServer(port).toCompletableFuture().get();
+        try {
+            port = instance.unwrap(WebServer.class).port();
+            try (Response response = ClientBuilder.newClient().target("http://localhost:" + port + "/ping").request().get()) {
+                Assertions.assertEquals(200, response.getStatus());
+            }
+        } finally {
+            instance.stop();
+        }
+    }
+}