On Mon, Oct 8, 2018 at 9:38 AM Luke Hutchison <luke.hu...@gmail.com> wrote: > On Mon, Oct 8, 2018 at 7:27 AM David Lloyd <david.ll...@redhat.com> wrote: >> I think a single clear >> behavior plus a documentation note would result in a better user >> experience than falling back through multiple potentially differing >> behaviors based on run time factors which may not be immediately clear >> to the user. > > You make good points about predictability and expectations, although in my > current implementation the series of fallbacks is mostly intended to support > both JDK 9+ and JDK 7/8. (I implemented the StackWalker code using reflection > so that the code can be compiled for JDK 7.) The last > `Exception#getStackTrace()` fallback is there in case the main mechanism for > JDK 9+ or 7/8 doesn't work due to a SecurityException, so maybe that's the > case that should be removed in favor of clear documentation about the need > for runtime permissions if a SecurityManager is installed.
You might want to consider doing a multi-release JAR instead. Your base image could support Java 7, and there could be a Java 9-specific layer which implements just the StackWalker stuff, overlaying the legacy code. The reflection approach works in a pinch, but it gets unwieldy pretty quickly as the differences mount. -- - DML