check for "invoke" in getCallerMethodName() Java 21 has same "shorter" stacktrace same as Mac OS X. The method name in the trace is "invoke" instead of "invoke0". This is a bit brittle, but since this approach is already used in the project, I have just updated the condition. Probably the better way would be to check the environment.