Testsuite PoC - Allow inner classes for config to be non-public (#31656)

Signed-off-by: stianst <stianst@gmail.com>
This commit is contained in:
Stian Thorgersen 2024-07-26 12:02:41 +02:00 committed by GitHub
parent 227c71f7f0
commit 63c9fc52e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,10 +1,14 @@
package org.keycloak.test.framework.injection;
import java.lang.reflect.Constructor;
public class SupplierHelpers {
public static <T> T getInstance(Class<T> clazz) {
try {
return clazz.getDeclaredConstructor().newInstance();
Constructor<T> declaredConstructor = clazz.getDeclaredConstructor();
declaredConstructor.setAccessible(true);
return declaredConstructor.newInstance();
} catch (Exception e) {
throw new RuntimeException(e);
}