本文整理汇总了Java中jdk.nashorn.internal.runtime.ECMAErrors.isScriptFrame方法的典型用法代码示例。如果您正苦于以下问题:Java ECMAErrors.isScriptFrame方法的具体用法?Java ECMAErrors.isScriptFrame怎么用?Java ECMAErrors.isScriptFrame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jdk.nashorn.internal.runtime.ECMAErrors
的用法示例。
在下文中一共展示了ECMAErrors.isScriptFrame方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: NashornException
import jdk.nashorn.internal.runtime.ECMAErrors; //导入方法依赖的package包/类
/**
* 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;
}
示例2: getScriptFrames
import jdk.nashorn.internal.runtime.ECMAErrors; //导入方法依赖的package包/类
/**
* 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()]);
}
示例3: getScriptFrames
import jdk.nashorn.internal.runtime.ECMAErrors; //导入方法依赖的package包/类
/**
* 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]);
}
示例4: getScriptFrames
import jdk.nashorn.internal.runtime.ECMAErrors; //导入方法依赖的package包/类
/**
* 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()]);
}
示例5: getScriptFrames
import jdk.nashorn.internal.runtime.ECMAErrors; //导入方法依赖的package包/类
/**
* 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()]);
}
示例6: ensureLineAndFileName
import jdk.nashorn.internal.runtime.ECMAErrors; //导入方法依赖的package包/类
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;
}
}