當前位置: 首頁>>代碼示例>>Java>>正文


Java Context.reportRuntimeError方法代碼示例

本文整理匯總了Java中org.mozilla.javascript.Context.reportRuntimeError方法的典型用法代碼示例。如果您正苦於以下問題:Java Context.reportRuntimeError方法的具體用法?Java Context.reportRuntimeError怎麽用?Java Context.reportRuntimeError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.mozilla.javascript.Context的用法示例。


在下文中一共展示了Context.reportRuntimeError方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadCompiledScript

import org.mozilla.javascript.Context; //導入方法依賴的package包/類
private static Script loadCompiledScript(Context cx, String path,
                                         byte[] data, Object securityDomain)
        throws FileNotFoundException {
    if (data == null) {
        throw new FileNotFoundException(path);
    }
    // XXX: For now extract class name of compiled Script from path
    // instead of parsing class bytes
    int nameStart = path.lastIndexOf('/');
    if (nameStart < 0) {
        nameStart = 0;
    } else {
        ++nameStart;
    }
    int nameEnd = path.lastIndexOf('.');
    if (nameEnd < nameStart) {
        // '.' does not exist in path (nameEnd < 0)
        // or it comes before nameStart
        nameEnd = path.length();
    }
    String name = path.substring(nameStart, nameEnd);
    try {
        GeneratedClassLoader loader = SecurityController.createLoader(cx.getApplicationClassLoader(), securityDomain);
        Class<?> clazz = loader.defineClass(name, data);
        loader.linkClass(clazz);
        if (!Script.class.isAssignableFrom(clazz)) {
            throw Context.reportRuntimeError("msg.must.implement.Script");
        }
        return (Script) clazz.newInstance();
    } catch (IllegalAccessException iaex) {
        Context.reportError(iaex.toString());
        throw new RuntimeException(iaex);
    } catch (InstantiationException inex) {
        Context.reportError(inex.toString());
        throw new RuntimeException(inex);
    }
}
 
開發者ID:feifadaima,項目名稱:https-github.com-hyb1996-NoRootScriptDroid,代碼行數:38,代碼來源:Main.java

示例2: addIndex

import org.mozilla.javascript.Context; //導入方法依賴的package包/類
private static int addIndex(byte[] array, int pc, int index)
{
    if (index < 0) throw Kit.codeBug();
    if (index > 0xFFFF)
        throw Context.reportRuntimeError("Too complex regexp");
    array[pc] = (byte)(index >> 8);
    array[pc + 1] = (byte)(index);
    return pc + 2;
}
 
開發者ID:MikaGuraN,項目名稱:HL4A,代碼行數:10,代碼來源:NativeRegExp.java

示例3: loadCompiledScript

import org.mozilla.javascript.Context; //導入方法依賴的package包/類
private static Script loadCompiledScript(Context cx, String path,
                                         byte[] data, Object securityDomain)
{
    if (data == null) {
        exitCode = EXITCODE_FILE_NOT_FOUND;
        return null;
    }
    // XXX: For now extract class name of compiled Script from path
    // instead of parsing class bytes
    int nameStart = path.lastIndexOf('/');
    if (nameStart < 0) {
        nameStart = 0;
    } else {
        ++nameStart;
    }
    int nameEnd = path.lastIndexOf('.');
    if (nameEnd < nameStart) {
        // '.' does not exist in path (nameEnd < 0)
        // or it comes before nameStart
        nameEnd = path.length();
    }
    String name = path.substring(nameStart, nameEnd);
    try {
        GeneratedClassLoader loader = SecurityController.createLoader(cx.getApplicationClassLoader(), securityDomain);
        Class<?> clazz = loader.defineClass(name, data);
        loader.linkClass(clazz);
        if (!Script.class.isAssignableFrom(clazz)) {
            throw Context.reportRuntimeError("msg.must.implement.Script");
        }
        return (Script) clazz.newInstance();
     } catch (RhinoException rex) {
        ToolErrorReporter.reportException(
            cx.getErrorReporter(), rex);
        exitCode = EXITCODE_RUNTIME_ERROR;
    } catch (IllegalAccessException iaex) {
        exitCode = EXITCODE_RUNTIME_ERROR;
        Context.reportError(iaex.toString());
    } catch (InstantiationException inex) {
        exitCode = EXITCODE_RUNTIME_ERROR;
        Context.reportError(inex.toString());
    }
    return null;
}
 
開發者ID:middle2tw,項目名稱:whackpad,代碼行數:44,代碼來源:Main.java


注:本文中的org.mozilla.javascript.Context.reportRuntimeError方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。