Java Code Examples for java.lang.StackWalker.StackFrame#getClassName()
The following examples show how to use
java.lang.StackWalker.StackFrame#getClassName() .
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: SimpleConsoleLogger.java From Bytecoder with Apache License 2.0 | 5 votes |
static boolean isFilteredFrame(StackFrame st) { // skip logging/logger infrastructure if (System.Logger.class.isAssignableFrom(st.getDeclaringClass())) { return true; } // fast escape path: all the prefixes below start with 's' or 'j' and // have more than 12 characters. final String cname = st.getClassName(); char c = cname.length() < 12 ? 0 : cname.charAt(0); if (c == 's') { // skip internal machinery classes if (cname.startsWith("sun.util.logging.")) return true; if (cname.startsWith("sun.rmi.runtime.Log")) return true; } else if (c == 'j') { // Message delayed at Bootstrap: no need to go further up. if (cname.startsWith("jdk.internal.logger.BootstrapLogger$LogEvent")) return false; // skip public machinery classes if (cname.startsWith("jdk.internal.logger.")) return true; if (cname.startsWith("java.util.logging.")) return true; if (cname.startsWith("java.lang.invoke.MethodHandle")) return true; if (cname.startsWith("java.security.AccessController")) return true; } // check additional prefixes if any are specified. if (skips.length > 0) { for (int i=0; i<skips.length; i++) { if (!skips[i].isEmpty() && cname.startsWith(skips[i])) { return true; } } } return false; }
Example 2
Source File: SimpleConsoleLogger.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
static boolean isFilteredFrame(StackFrame st) { // skip logging/logger infrastructure if (System.Logger.class.isAssignableFrom(st.getDeclaringClass())) { return true; } // fast escape path: all the prefixes below start with 's' or 'j' and // have more than 12 characters. final String cname = st.getClassName(); char c = cname.length() < 12 ? 0 : cname.charAt(0); if (c == 's') { // skip internal machinery classes if (cname.startsWith("sun.util.logging.")) return true; if (cname.startsWith("sun.rmi.runtime.Log")) return true; } else if (c == 'j') { // Message delayed at Bootstrap: no need to go further up. if (cname.startsWith("jdk.internal.logger.BootstrapLogger$LogEvent")) return false; // skip public machinery classes if (cname.startsWith("jdk.internal.logger.")) return true; if (cname.startsWith("java.util.logging.")) return true; if (cname.startsWith("java.lang.invoke.MethodHandle")) return true; if (cname.startsWith("java.security.AccessController")) return true; } // check additional prefixes if any are specified. if (skips.length > 0) { for (int i=0; i<skips.length; i++) { if (!skips[i].isEmpty() && cname.startsWith(skips[i])) { return true; } } } return false; }
Example 3
Source File: HiddenFrames.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
void checkFrame(StackFrame frame) { String cn = frame.getClassName(); if (cn.startsWith("java.lang.reflect.") || cn.startsWith("jdk.internal.reflect.")) { reflects.add(frame); } if (cn.contains("$$Lambda$")) { lambdas.add(frame); } }
Example 4
Source File: Basic.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public String frame(StackFrame f) { return f.getClassName() + "::" + f.getMethodName(); }
Example 5
Source File: StackRecorderUtil.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * Compare the given StackFrame returned from the StackWalker to the * recorded frame at the given index. * * Tests for equality, as well as functional correctness with respect to * the StackWalker's options (e.g. throws or doesn't throw exceptions) */ public void compareFrame(int index, StackFrame sf) { TestFrame tf = testFrames.get(index); if (compareClasses) { if (!tf.declaringClass.equals(sf.getDeclaringClass())) { throw new RuntimeException("Expected class: " + tf.declaringClass.toString() + ", but got: " + sf.getDeclaringClass().toString()); } } else { boolean caught = false; try { sf.getDeclaringClass(); } catch (UnsupportedOperationException e) { caught = true; } if (!caught) { throw new RuntimeException("StackWalker did not have " + "RETAIN_CLASS_REFERENCE Option, but did not throw " + "UnsupportedOperationException"); } } if (compareClassNames && !tf.className().equals(sf.getClassName())) { throw new RuntimeException("Expected class name: " + tf.className() + ", but got: " + sf.getClassName()); } if (compareMethodNames && !tf.methodName.equals(sf.getMethodName())) { throw new RuntimeException("Expected method name: " + tf.methodName + ", but got: " + sf.getMethodName()); } if (compareSTEs) { StackTraceElement ste = sf.toStackTraceElement(); if (!(ste.getClassName().equals(tf.className()) && ste.getMethodName().equals(tf.methodName)) && ste.getFileName().equals(tf.fileName)) { throw new RuntimeException("Expected StackTraceElement info: " + tf + ", but got: " + ste); } if (!Objects.equals(ste.getClassName(), sf.getClassName()) || !Objects.equals(ste.getMethodName(), sf.getMethodName()) || !Objects.equals(ste.getFileName(), sf.getFileName()) || !Objects.equals(ste.getLineNumber(), sf.getLineNumber()) || !Objects.equals(ste.isNativeMethod(), sf.isNativeMethod())) { throw new RuntimeException("StackFrame and StackTraceElement differ: " + "sf=" + sf + ", ste=" + ste); } } }
Example 6
Source File: ReflectionFrames.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public String frame(StackFrame f) { return f.getClassName() + "::" + f.getMethodName(); }
Example 7
Source File: TestSecurityManager.java From lucene-solr with Apache License 2.0 | 4 votes |
private static boolean isExitStackFrame(StackFrame f) { final String methodName = f.getMethodName(), className = f.getClassName(); return ("exit".equals(methodName) || "halt".equals(methodName)) && (SYSTEM_CLASS_NAME.equals(className) || RUNTIME_CLASS_NAME.equals(className)); }