void walk() { Stream.of(0).forEach(i -> walker.walk(s -> { s.forEach(this::checkFrame); return null; })); // only check hidden frames but not reflection frames // walk is not invoked via reflection if (option == null && !lambdas.isEmpty()) { throw new RuntimeException("Hidden frames are shown"); } if (option == Option.SHOW_HIDDEN_FRAMES && lambdas.isEmpty()) { throw new RuntimeException("No hidden Lambda frame"); } }
void walkFromReflection() throws Exception { Method m = HiddenFrames.class.getDeclaredMethod("walk"); m.invoke(this); if (option == null && !lambdas.isEmpty()) { throw new RuntimeException("Hidden frames are shown"); } if (option == Option.SHOW_HIDDEN_FRAMES && lambdas.isEmpty()) { throw new RuntimeException("No hidden Lambda frame"); } if (option != null && reflects.isEmpty()) { throw new RuntimeException("No reflection frame"); } }
private int toStackWalkMode(StackWalker walker, int mode) { int newMode = mode; if (walker.hasOption(Option.SHOW_HIDDEN_FRAMES) && (mode & FILL_CLASS_REFS_ONLY) != FILL_CLASS_REFS_ONLY) newMode |= SHOW_HIDDEN_FRAMES; if (walker.hasLocalsOperandsOption()) newMode |= FILL_LIVE_STACK_FRAMES; return newMode; }
private boolean skipReflectionFrames() { return !walker.hasOption(Option.SHOW_REFLECT_FRAMES) && !walker.hasOption(Option.SHOW_HIDDEN_FRAMES); }
public StackRecorderUtil(Set<StackWalker.Option> swOptions) { compareClasses = swOptions.contains(Option.RETAIN_CLASS_REFERENCE); compareSTEs = true; }
public static void main(String... args) throws Exception { new HiddenFrames().test(); new HiddenFrames(Option.SHOW_REFLECT_FRAMES).test(); new HiddenFrames(Option.SHOW_HIDDEN_FRAMES).test(); }
HiddenFrames(Option option) { this.option = option; this.walker = StackWalker.getInstance(option); }
NativeMethod() { this.walker = StackWalker.getInstance(Option.SHOW_REFLECT_FRAMES); }