@SuppressWarnings("removal")
    private static MethodHandles.Lookup performSafePrivateLookupIn(Class<?> targetClass) throws Throwable {
        // MethodHandles::privateLookupIn() throws SecurityException if denied by the security manager
        if (System.getSecurityManager() == null) {
            return (MethodHandles.Lookup) METHOD_HANDLES_PRIVATE_LOOKUP_IN_METHOD_HANDLE
                .invokeExact(targetClass, LOOKUP);
        } else {
            return java.security.AccessController.doPrivileged((PrivilegedExceptionAction<MethodHandles.Lookup>) () -> {
                try {
                    return (MethodHandles.Lookup) METHOD_HANDLES_PRIVATE_LOOKUP_IN_METHOD_HANDLE
                        .invokeExact(targetClass, LOOKUP);
                } catch (Throwable throwable) {
                    if (throwable instanceof Error) {
                        throw (Error) throwable;
                    } else {
                        throw (Exception) throwable;
                    }
                }
            });
        }
    }
Gets the {@link MethodHandles.Lookup} to use when performing reflective operations.
<p>
If Java 8 is being used this will always return {@link MethodHandles.Lookup#publicLookup()} as Java 8 doesn't
have module boundaries that will prevent reflective access to the {@code targetClass}.
<p>
If Java 9 or above is being used this will return a {@link MethodHandles.Lookup} based on whether the module
containing the {@code targetClass} exports the package containing the class. Otherwise, the
{@link MethodHandles.Lookup} associated to {@code com.azure.core} will attempt to read the module containing
{@code targetClass}.

@param targetClass The {@link Class} that will need to be reflectively accessed.
@return The {@link MethodHandles.Lookup} that will allow {@code com.azure.core} to access the {@code targetClass}
reflectively.
@throws Exception If the underlying reflective calls throw an exception.
chat2db-server/chat2db-server-web/chat2db-server-web-api/src/main/java/ai/chat2db/server/web/api/controller/ai/azure/util/AzureReflectionUtils.java