java.lang.StackWalker.Option Java Examples

The following examples show how to use java.lang.StackWalker.Option. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HiddenFrames.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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");
    }
}
 
Example #2
Source File: HiddenFrames.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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");
    }
}
 
Example #3
Source File: StackStreamFactory.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #4
Source File: StackStreamFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #5
Source File: StackStreamFactory.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
private boolean skipReflectionFrames() {
    return !walker.hasOption(Option.SHOW_REFLECT_FRAMES) &&
               !walker.hasOption(Option.SHOW_HIDDEN_FRAMES);
}
 
Example #6
Source File: StackStreamFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private boolean skipReflectionFrames() {
    return !walker.hasOption(Option.SHOW_REFLECT_FRAMES) &&
               !walker.hasOption(Option.SHOW_HIDDEN_FRAMES);
}
 
Example #7
Source File: StackRecorderUtil.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public StackRecorderUtil(Set<StackWalker.Option> swOptions) {
    compareClasses = swOptions.contains(Option.RETAIN_CLASS_REFERENCE);
    compareSTEs = true;
}
 
Example #8
Source File: HiddenFrames.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
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();
}
 
Example #9
Source File: HiddenFrames.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
HiddenFrames(Option option) {
    this.option = option;
    this.walker = StackWalker.getInstance(option);
}
 
Example #10
Source File: NativeMethod.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
NativeMethod() {
    this.walker = StackWalker.getInstance(Option.SHOW_REFLECT_FRAMES);
}