Java Code Examples for jdk.nashorn.internal.runtime.ECMAErrors#isScriptFrame()
The following examples show how to use
jdk.nashorn.internal.runtime.ECMAErrors#isScriptFrame() .
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: NashornException.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Returns array javascript stack frames from the given exception object. * * @param exception exception from which stack frames are retrieved and filtered * @return array of javascript stack frames */ public static StackTraceElement[] getScriptFrames(final Throwable exception) { final StackTraceElement[] frames = exception.getStackTrace(); final List<StackTraceElement> filtered = new ArrayList<>(); for (final StackTraceElement st : frames) { if (ECMAErrors.isScriptFrame(st)) { final String className = "<" + st.getFileName() + ">"; String methodName = st.getMethodName(); if (methodName.equals(CompilerConstants.PROGRAM.symbolName())) { methodName = "<program>"; } if (methodName.contains(CompilerConstants.ANON_FUNCTION_PREFIX.symbolName())) { methodName = "<anonymous>"; } filtered.add(new StackTraceElement(className, methodName, st.getFileName(), st.getLineNumber())); } } return filtered.toArray(new StackTraceElement[filtered.size()]); }
Example 2
Source File: NashornException.java From nashorn with GNU General Public License v2.0 | 6 votes |
/** * Returns array javascript stack frames from the given exception object. * * @param exception exception from which stack frames are retrieved and filtered * @return array of javascript stack frames */ public static StackTraceElement[] getScriptFrames(final Throwable exception) { final StackTraceElement[] frames = exception.getStackTrace(); final List<StackTraceElement> filtered = new ArrayList<>(); for (final StackTraceElement st : frames) { if (ECMAErrors.isScriptFrame(st)) { final String className = "<" + st.getFileName() + ">"; String methodName = st.getMethodName(); if (methodName.equals(CompilerConstants.RUN_SCRIPT.symbolName())) { methodName = "<program>"; } filtered.add(new StackTraceElement(className, methodName, st.getFileName(), st.getLineNumber())); } } return filtered.toArray(new StackTraceElement[filtered.size()]); }
Example 3
Source File: NashornException.java From nashorn with GNU General Public License v2.0 | 6 votes |
/** * Constructor * * @param msg exception message * @param cause exception cause */ protected NashornException(final String msg, final Throwable cause) { super(msg, cause == null ? null : cause); // This is not so pretty - but it gets the job done. Note that the stack // trace has been already filled by "fillInStackTrace" call from // Throwable // constructor and so we don't pay additional cost for it. // Hard luck - no column number info this.column = -1; // Find the first JavaScript frame by walking and set file, line from it // Usually, we should be able to find it in just few frames depth. for (final StackTraceElement ste : getStackTrace()) { if (ECMAErrors.isScriptFrame(ste)) { // Whatever here is compiled from JavaScript code this.fileName = ste.getFileName(); this.line = ste.getLineNumber(); return; } } this.fileName = null; this.line = 0; }
Example 4
Source File: NashornException.java From jdk8u_nashorn with GNU General Public License v2.0 | 6 votes |
/** * Returns array javascript stack frames from the given exception object. * * @param exception exception from which stack frames are retrieved and filtered * @return array of javascript stack frames */ public static StackTraceElement[] getScriptFrames(final Throwable exception) { final StackTraceElement[] frames = exception.getStackTrace(); final List<StackTraceElement> filtered = new ArrayList<>(); for (final StackTraceElement st : frames) { if (ECMAErrors.isScriptFrame(st)) { final String className = "<" + st.getFileName() + ">"; String methodName = st.getMethodName(); if (methodName.equals(CompilerConstants.PROGRAM.symbolName())) { methodName = "<program>"; } else { methodName = stripMethodName(methodName); } filtered.add(new StackTraceElement(className, methodName, st.getFileName(), st.getLineNumber())); } } return filtered.toArray(new StackTraceElement[filtered.size()]); }
Example 5
Source File: NashornException.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Returns array javascript stack frames from the given exception object. * * @param exception exception from which stack frames are retrieved and filtered * @return array of javascript stack frames */ public static StackTraceElement[] getScriptFrames(final Throwable exception) { final StackTraceElement[] frames = exception.getStackTrace(); final List<StackTraceElement> filtered = new ArrayList<>(); for (final StackTraceElement st : frames) { if (ECMAErrors.isScriptFrame(st)) { final String className = "<" + st.getFileName() + ">"; String methodName = st.getMethodName(); if (methodName.equals(CompilerConstants.RUN_SCRIPT.symbolName())) { methodName = "<program>"; } filtered.add(new StackTraceElement(className, methodName, st.getFileName(), st.getLineNumber())); } } return filtered.toArray(new StackTraceElement[filtered.size()]); }
Example 6
Source File: NashornException.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Constructor * * @param msg exception message * @param cause exception cause */ protected NashornException(final String msg, final Throwable cause) { super(msg, cause == null ? null : cause); // This is not so pretty - but it gets the job done. Note that the stack // trace has been already filled by "fillInStackTrace" call from // Throwable // constructor and so we don't pay additional cost for it. // Hard luck - no column number info this.column = -1; // Find the first JavaScript frame by walking and set file, line from it // Usually, we should be able to find it in just few frames depth. for (final StackTraceElement ste : getStackTrace()) { if (ECMAErrors.isScriptFrame(ste)) { // Whatever here is compiled from JavaScript code this.fileName = ste.getFileName(); this.line = ste.getLineNumber(); return; } } this.fileName = null; this.line = 0; }
Example 7
Source File: NashornException.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Returns array javascript stack frames from the given exception object. * * @param exception exception from which stack frames are retrieved and filtered * @return array of javascript stack frames */ public static StackTraceElement[] getScriptFrames(final Throwable exception) { final StackTraceElement[] frames = exception.getStackTrace(); final List<StackTraceElement> filtered = new ArrayList<>(); for (final StackTraceElement st : frames) { if (ECMAErrors.isScriptFrame(st)) { final String className = "<" + st.getFileName() + ">"; String methodName = st.getMethodName(); if (methodName.equals(CompilerConstants.RUN_SCRIPT.symbolName())) { methodName = "<program>"; } filtered.add(new StackTraceElement(className, methodName, st.getFileName(), st.getLineNumber())); } } return filtered.toArray(new StackTraceElement[filtered.size()]); }
Example 8
Source File: NashornException.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Constructor * * @param msg exception message * @param cause exception cause */ protected NashornException(final String msg, final Throwable cause) { super(msg, cause == null ? null : cause); // This is not so pretty - but it gets the job done. Note that the stack // trace has been already filled by "fillInStackTrace" call from // Throwable // constructor and so we don't pay additional cost for it. // Hard luck - no column number info this.column = -1; // Find the first JavaScript frame by walking and set file, line from it // Usually, we should be able to find it in just few frames depth. for (final StackTraceElement ste : getStackTrace()) { if (ECMAErrors.isScriptFrame(ste)) { // Whatever here is compiled from JavaScript code this.fileName = ste.getFileName(); this.line = ste.getLineNumber(); return; } } this.fileName = null; this.line = 0; }
Example 9
Source File: NashornException.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Returns array javascript stack frames from the given exception object. * * @param exception exception from which stack frames are retrieved and filtered * @return array of javascript stack frames */ public static StackTraceElement[] getScriptFrames(final Throwable exception) { final StackTraceElement[] frames = exception.getStackTrace(); final List<StackTraceElement> filtered = new ArrayList<>(); for (final StackTraceElement st : frames) { if (ECMAErrors.isScriptFrame(st)) { final String className = "<" + st.getFileName() + ">"; String methodName = st.getMethodName(); if (methodName.equals(CompilerConstants.PROGRAM.symbolName())) { methodName = "<program>"; } else { methodName = stripMethodName(methodName); } filtered.add(new StackTraceElement(className, methodName, st.getFileName(), st.getLineNumber())); } } return filtered.toArray(new StackTraceElement[filtered.size()]); }
Example 10
Source File: NashornException.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Returns array javascript stack frames from the given exception object. * * @param exception exception from which stack frames are retrieved and filtered * @return array of javascript stack frames */ public static StackTraceElement[] getScriptFrames(final Throwable exception) { final StackTraceElement[] frames = exception.getStackTrace(); final List<StackTraceElement> filtered = new ArrayList<>(); for (final StackTraceElement st : frames) { if (ECMAErrors.isScriptFrame(st)) { final String className = "<" + st.getFileName() + ">"; String methodName = st.getMethodName(); if (methodName.equals(CompilerConstants.PROGRAM.symbolName())) { methodName = "<program>"; } else { methodName = stripMethodName(methodName); } filtered.add(new StackTraceElement(className, methodName, st.getFileName(), st.getLineNumber())); } } return filtered.toArray(new StackTraceElement[0]); }
Example 11
Source File: NashornException.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Returns array javascript stack frames from the given exception object. * * @param exception exception from which stack frames are retrieved and filtered * @return array of javascript stack frames */ public static StackTraceElement[] getScriptFrames(final Throwable exception) { final StackTraceElement[] frames = exception.getStackTrace(); final List<StackTraceElement> filtered = new ArrayList<>(); for (final StackTraceElement st : frames) { if (ECMAErrors.isScriptFrame(st)) { final String className = "<" + st.getFileName() + ">"; String methodName = st.getMethodName(); if (methodName.equals(CompilerConstants.PROGRAM.symbolName())) { methodName = "<program>"; } else { methodName = stripMethodName(methodName); } filtered.add(new StackTraceElement(className, methodName, st.getFileName(), st.getLineNumber())); } } return filtered.toArray(new StackTraceElement[filtered.size()]); }
Example 12
Source File: NashornException.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Returns array javascript stack frames from the given exception object. * * @param exception exception from which stack frames are retrieved and filtered * @return array of javascript stack frames */ public static StackTraceElement[] getScriptFrames(final Throwable exception) { final StackTraceElement[] frames = exception.getStackTrace(); final List<StackTraceElement> filtered = new ArrayList<>(); for (final StackTraceElement st : frames) { if (ECMAErrors.isScriptFrame(st)) { final String className = "<" + st.getFileName() + ">"; String methodName = st.getMethodName(); if (methodName.equals(CompilerConstants.PROGRAM.symbolName())) { methodName = "<program>"; } else { methodName = stripMethodName(methodName); } filtered.add(new StackTraceElement(className, methodName, st.getFileName(), st.getLineNumber())); } } return filtered.toArray(new StackTraceElement[filtered.size()]); }
Example 13
Source File: NashornException.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Returns array javascript stack frames from the given exception object. * * @param exception exception from which stack frames are retrieved and filtered * @return array of javascript stack frames */ public static StackTraceElement[] getScriptFrames(final Throwable exception) { final StackTraceElement[] frames = exception.getStackTrace(); final List<StackTraceElement> filtered = new ArrayList<>(); for (final StackTraceElement st : frames) { if (ECMAErrors.isScriptFrame(st)) { final String className = "<" + st.getFileName() + ">"; String methodName = st.getMethodName(); if (methodName.equals(CompilerConstants.PROGRAM.symbolName())) { methodName = "<program>"; } if (methodName.contains(CompilerConstants.ANON_FUNCTION_PREFIX.symbolName())) { methodName = "<anonymous>"; } filtered.add(new StackTraceElement(className, methodName, st.getFileName(), st.getLineNumber())); } } return filtered.toArray(new StackTraceElement[filtered.size()]); }
Example 14
Source File: NashornException.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Constructor * * @param msg exception message * @param cause exception cause */ protected NashornException(final String msg, final Throwable cause) { super(msg, cause == null ? null : cause); // This is not so pretty - but it gets the job done. Note that the stack // trace has been already filled by "fillInStackTrace" call from // Throwable // constructor and so we don't pay additional cost for it. // Hard luck - no column number info this.column = -1; // Find the first JavaScript frame by walking and set file, line from it // Usually, we should be able to find it in just few frames depth. for (final StackTraceElement ste : getStackTrace()) { if (ECMAErrors.isScriptFrame(ste)) { // Whatever here is compiled from JavaScript code this.fileName = ste.getFileName(); this.line = ste.getLineNumber(); return; } } this.fileName = null; this.line = 0; }
Example 15
Source File: NashornException.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private void ensureLineAndFileName() { if (lineAndFileNameUnknown) { for (final StackTraceElement ste : getStackTrace()) { if (ECMAErrors.isScriptFrame(ste)) { // Whatever here is compiled from JavaScript code fileName = ste.getFileName(); line = ste.getLineNumber(); return; } } lineAndFileNameUnknown = false; } }
Example 16
Source File: NashornException.java From hottub with GNU General Public License v2.0 | 5 votes |
private void ensureLineAndFileName() { if (lineAndFileNameUnknown) { for (final StackTraceElement ste : getStackTrace()) { if (ECMAErrors.isScriptFrame(ste)) { // Whatever here is compiled from JavaScript code fileName = ste.getFileName(); line = ste.getLineNumber(); return; } } lineAndFileNameUnknown = false; } }
Example 17
Source File: NashornException.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private void ensureLineAndFileName() { if (lineAndFileNameUnknown) { for (final StackTraceElement ste : getStackTrace()) { if (ECMAErrors.isScriptFrame(ste)) { // Whatever here is compiled from JavaScript code fileName = ste.getFileName(); line = ste.getLineNumber(); return; } } lineAndFileNameUnknown = false; } }
Example 18
Source File: NashornException.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private void ensureLineAndFileName() { if (lineAndFileNameUnknown) { for (final StackTraceElement ste : getStackTrace()) { if (ECMAErrors.isScriptFrame(ste)) { // Whatever here is compiled from JavaScript code fileName = ste.getFileName(); line = ste.getLineNumber(); return; } } lineAndFileNameUnknown = false; } }
Example 19
Source File: NashornException.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
private void ensureLineAndFileName() { if (lineAndFileNameUnknown) { for (final StackTraceElement ste : getStackTrace()) { if (ECMAErrors.isScriptFrame(ste)) { // Whatever here is compiled from JavaScript code fileName = ste.getFileName(); line = ste.getLineNumber(); return; } } lineAndFileNameUnknown = false; } }
Example 20
Source File: NashornException.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private void ensureLineAndFileName() { if (lineAndFileNameUnknown) { for (final StackTraceElement ste : getStackTrace()) { if (ECMAErrors.isScriptFrame(ste)) { // Whatever here is compiled from JavaScript code fileName = ste.getFileName(); line = ste.getLineNumber(); return; } } lineAndFileNameUnknown = false; } }