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


Java GeneratedClassLoader类代码示例

本文整理汇总了Java中org.mozilla.javascript.GeneratedClassLoader的典型用法代码示例。如果您正苦于以下问题:Java GeneratedClassLoader类的具体用法?Java GeneratedClassLoader怎么用?Java GeneratedClassLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GeneratedClassLoader类属于org.mozilla.javascript包,在下文中一共展示了GeneratedClassLoader类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadCompiledScript

import org.mozilla.javascript.GeneratedClassLoader; //导入依赖的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: if

import org.mozilla.javascript.GeneratedClassLoader; //导入依赖的package包/类
/**
 * Default constructor
 */
public GeneratedClassLoader createClassLoader
    (final ClassLoader parentLoader, Object securityDomain) {

    if (securityDomain instanceof RhinoClassLoader) {
        return (RhinoClassLoader)securityDomain;
    }

    // FIXX: This should be supported by intersecting perms.
    // Calling var script = Script(source); script(); is not supported
    throw new SecurityException("Script() objects are not supported");
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:15,代码来源:BatikSecurityController.java

示例3: loadCompiledScript

import org.mozilla.javascript.GeneratedClassLoader; //导入依赖的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:CyboticCatfish,项目名称:code404,代码行数:39,代码来源:Main.java

示例4: createClassLoader

import org.mozilla.javascript.GeneratedClassLoader; //导入依赖的package包/类
@Override
public GeneratedClassLoader createClassLoader(ClassLoader classLoader, Object o) {
    return Context.getCurrentContext().createClassLoader(classLoader);
}
 
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:5,代码来源:NoSecurityController.java

示例5: loadCompiledScript

import org.mozilla.javascript.GeneratedClassLoader; //导入依赖的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

示例6: createClassLoader

import org.mozilla.javascript.GeneratedClassLoader; //导入依赖的package包/类
@Override
protected GeneratedClassLoader createClassLoader(ClassLoader parent) {
  return (GeneratedClassLoader) new AndroidContextFactory(new File(System.getProperty("java.io.tmpdir", "."), "classes")).getApplicationClassLoader();
}
 
开发者ID:F43nd1r,项目名称:rhino-android,代码行数:5,代码来源:JavaAcessibilityTest.java

示例7: createClassLoader

import org.mozilla.javascript.GeneratedClassLoader; //导入依赖的package包/类
@Override
public GeneratedClassLoader createClassLoader(ClassLoader parent, Object staticDomain) {
	return new LocalSecureClassLoader(parent, codesource);
}
 
开发者ID:oswetto,项目名称:LoboEvolution,代码行数:5,代码来源:SecurityControllerImpl.java


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