本文整理匯總了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);
}
}
示例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;
}
示例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;
}