当前位置: 首页>>代码示例>>Java>>正文


Java ECMAErrors.isScriptFrame方法代码示例

本文整理汇总了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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:31,代码来源:NashornException.java

示例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()]);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:NashornException.java

示例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]);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:NashornException.java

示例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()]);
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:26,代码来源:NashornException.java

示例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()]);
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:23,代码来源:NashornException.java

示例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;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:NashornException.java


注:本文中的jdk.nashorn.internal.runtime.ECMAErrors.isScriptFrame方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。