public static void handleReflectionException(Exception ex) {
        if (ex instanceof NoSuchMethodException) {
            throw new IllegalStateException("Method not found: " + ex.getMessage());
        }
        if (ex instanceof IllegalAccessException) {
            throw new IllegalStateException("Could not access method or field: " + ex.getMessage());
        }
        if (ex instanceof InvocationTargetException) {
            handleInvocationTargetException((InvocationTargetException) ex);
        }
        if (ex instanceof RuntimeException) {
            throw (RuntimeException) ex;
        }
        throw new UndeclaredThrowableException(ex);
    }
@Test
    void testHandleReflectionException() {
        assertThrows(UndeclaredThrowableException.class, () -> {
            try {
                NoSuchMethodException exception = new NoSuchMethodException("test");
                ReflectUtils.handleReflectionException(exception);
            } catch (Exception e) {
                assertEquals("Method not found: test", e.getMessage());
            }
            try {
                IllegalAccessException exception = new IllegalAccessException("test");
                ReflectUtils.handleReflectionException(exception);
            } catch (Exception e) {
                assertEquals("Could not access method or field: test", e.getMessage());
            }
            RuntimeException exception = new RuntimeException("test");
            try {
                ReflectUtils.handleReflectionException(exception);
            } catch (Exception e) {
                assertEquals(exception, e);
            }
            try {
                InvocationTargetException invocationTargetException = new InvocationTargetException(exception);
                ReflectUtils.handleReflectionException(invocationTargetException);
            } catch (Exception e) {
                assertEquals(exception, e);
            }
            ReflectUtils.handleReflectionException(new IOException());
        });
    }