org.mozilla.javascript.RhinoException.getScriptStack()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 JavaScript  
字(5.4k)|赞(0)|评价(0)|浏览(105)

本文整理了Java中org.mozilla.javascript.RhinoException.getScriptStack方法的一些代码示例,展示了RhinoException.getScriptStack的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RhinoException.getScriptStack方法的具体详情如下:
包路径:org.mozilla.javascript.RhinoException
类名称:RhinoException
方法名:getScriptStack

RhinoException.getScriptStack介绍

[英]Get the script stack of this exception as an array of ScriptStackElements. If optimization is enabled, this includes java stack elements whose source and method names suggest they have been generated by the Rhino script compiler.
[中]以ScriptStackElements数组的形式获取此异常的脚本堆栈。如果启用了优化,这将包括java堆栈元素,其源代码和方法名称表明它们是由Rhino脚本编译器生成的。

代码示例

代码示例来源:origin: geogebra/geogebra

/**
 * Get the script stack of this exception as an array of
 * {@link ScriptStackElement}s.
 * If optimization is enabled, this includes java stack elements
 * whose source and method names suggest they have been generated
 * by the Rhino script compiler.
 * @return the script stack for this exception
 * @since 1.7R3
 */
public ScriptStackElement[] getScriptStack() {
  return getScriptStack(-1, null);
}

代码示例来源:origin: io.apigee/rhino

/**
 * Get a string representing the script stack in a way that is compatible with V8.
 * If the function "Error.prepareStackTrace" is defined, then call that function,
 * passing it an array of CallSite objects. Otherwise, behave as if "getScriptStackTrace"
 * was called instead.
 * @since 1.7R5
 */
public Object getPreparedScriptStackTrace(Context cx, Scriptable scope, Scriptable err)
{
  Scriptable top = ScriptableObject.getTopLevelScope(scope);
  Scriptable error = TopLevel.getBuiltinCtor(cx, top, TopLevel.Builtins.Error);
  Object prepare = error.get("prepareStackTrace", error);
  if (prepare instanceof Function) {
    Function prepareFunc = (Function)prepare;
    ScriptStackElement[] elts = getScriptStack();
    Object[] rawStack = new Object[elts.length];
    for (int i = 0; i < elts.length; i++) {
      rawStack[i] = cx.newObject(top, "CallSite");
      ((NativeCallSite)rawStack[i]).setElement(elts[i]);
    }
    return prepareFunc.call(cx, scope, null, new Object[] { err, cx.newArray(top, rawStack) });
  }
  return getScriptStackTrace();
}

代码示例来源:origin: io.apigee/rhino

/**
 * Get a string representing the script stack of this exception.
 * If optimization is enabled, this includes java stack elements
 * whose source and method names suggest they have been generated
 * by the Rhino script compiler.
 * @return a script stack dump
 * @since 1.6R6
 */
public String getScriptStackTrace()
{
  StringBuilder buffer = new StringBuilder();
  String lineSeparator = SecurityUtilities.getSystemProperty("line.separator");
  ScriptStackElement[] stack = getScriptStack();
  for (ScriptStackElement elem : stack) {
    elem.render(buffer);
    buffer.append(lineSeparator);
  }
  return buffer.toString();
}

代码示例来源:origin: geogebra/geogebra

/**
 * Get a string representing the script stack of this exception.
 * If optimization is enabled, this includes java stack elements
 * whose source and method names suggest they have been generated
 * by the Rhino script compiler.
 * The optional "limit" parameter limits the number of stack frames returned.
 * The "functionName" parameter will exclude any stack frames "below" the
 * specified function on the stack.
 *
 * @param limit the number of stack frames returned
 * @param functionName the name of a function on the stack -- frames below it will be ignored
 * @return a script stack dump
 * @since 1.8.0
 */
public String getScriptStackTrace(int limit, String functionName)
{
  ScriptStackElement[] stack = getScriptStack(limit, functionName);
  return formatStackTrace(stack, details());
}

代码示例来源:origin: ro.isdc.wro4j/rhino

/**
 * Get a string representing the script stack of this exception.
 * If optimization is enabled, this includes java stack elements
 * whose source and method names suggest they have been generated
 * by the Rhino script compiler.
 * @return a script stack dump
 * @since 1.6R6
 */
public String getScriptStackTrace()
{
  StringBuilder buffer = new StringBuilder();
  String lineSeparator = SecurityUtilities.getSystemProperty("line.separator");
  ScriptStackElement[] stack = getScriptStack();
  for (ScriptStackElement elem : stack) {
    if (useMozillaStackStyle) {
      elem.renderMozillaStyle(buffer);
    } else {
      elem.renderJavaStyle(buffer);
    }
    buffer.append(lineSeparator);
  }
  return buffer.toString();
}

代码示例来源:origin: com.github.tntim96/rhino

/**
 * Get a string representing the script stack of this exception.
 * If optimization is enabled, this includes java stack elements
 * whose source and method names suggest they have been generated
 * by the Rhino script compiler.
 * @return a script stack dump
 * @since 1.6R6
 */
public String getScriptStackTrace()
{
  StringBuilder buffer = new StringBuilder();
  String lineSeparator = SecurityUtilities.getSystemProperty("line.separator");
  ScriptStackElement[] stack = getScriptStack();
  for (ScriptStackElement elem : stack) {
    if (useMozillaStackStyle) {
      elem.renderMozillaStyle(buffer);
    } else {
      elem.renderJavaStyle(buffer);
    }
    buffer.append(lineSeparator);
  }
  return buffer.toString();
}

代码示例来源:origin: geogebra/geogebra

public Object getStackDelegated(Scriptable target) {
  if (stackProvider == null) {
    return NOT_FOUND;
  }
  // Get the object where prototype stuff is stored.
  int limit = DEFAULT_STACK_LIMIT;
  Function prepare = null;
  NativeError cons = (NativeError)getPrototype();
  ProtoProps pp = (ProtoProps)cons.getAssociatedValue(ProtoProps.KEY);
  if (pp != null) {
    limit = pp.getStackTraceLimit();
    prepare = pp.getPrepareStackTrace();
  }
  // This key is only set by captureStackTrace
  String hideFunc = (String)getAssociatedValue(STACK_HIDE_KEY);
  ScriptStackElement[] stack = stackProvider.getScriptStack(limit, hideFunc);
  // Determine whether to format the stack trace ourselves, or call the user's code to do it
  Object value;
  if (prepare == null) {
    value = RhinoException.formatStackTrace(stack, stackProvider.details());
  } else {
    value = callPrepareStack(prepare, stack);
  }
  // We store the stack as local property both to cache it
  // and to make the property writable
  setStackDelegated(target, value);
  return value;
}

相关文章