public static String getStackTrace(Thread thread) {
        return getStackTrace(thread, 3);
    }
@Test
    public void testGetStackTrace() {
        String stackTrace = ReflectionUtils.getStackTrace(Thread.currentThread());
        String[] stackTraceLines = stackTrace.split(System.lineSeparator());

        // Because the stack trace contains line numbers, and those are implementation specific (i.e. within the
        // ReflectionUtils or ReflectionUtilsTest classes, or even in the JVM, we can't use a typical assertion

        // Instead assert the first and last elements look as expected
        assertThat(stackTraceLines[0]).startsWith("com.hazelcast.jet.impl.util.ReflectionUtilsTest.testGetStackTrace");
        assertThat(stackTraceLines[stackTraceLines.length - 1]).startsWith("\tjava.base/java.lang.Thread.run");
    }