本文整理汇总了Java中org.codehaus.janino.ClassLoaderIClassLoader类的典型用法代码示例。如果您正苦于以下问题:Java ClassLoaderIClassLoader类的具体用法?Java ClassLoaderIClassLoader怎么用?Java ClassLoaderIClassLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClassLoaderIClassLoader类属于org.codehaus.janino包,在下文中一共展示了ClassLoaderIClassLoader类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: compile
import org.codehaus.janino.ClassLoaderIClassLoader; //导入依赖的package包/类
public UnaryDoubleFunction compile(String expression) throws Exception {
if (!java.util.regex.Pattern.matches(
"^[a-zA-Z0-9+\\-()/\\* \t^%\\.\\?]+$", expression)) {
throw new SecurityException();
}
String classPackage = getClass().getPackage().getName() + ".compiled";
String className = "JaninoCompiledFastexpr"
+ COMPILED_CLASS_INDEX.incrementAndGet();
String source = "package " + classPackage + ";\n"
+ "import static java.lang.Math.*;\n" + "public final class "
+ className + " implements "
+ UnaryDoubleFunction.class.getCanonicalName() + " {\n"
+ "public double evaluate(double x) {\n"
+ "return (" + expression + ");\n" + "}\n" + "}";
Scanner scanner = new Scanner(null, new ByteArrayInputStream(
source.getBytes("UTF-8")), "UTF-8");
JaninoRestrictedClassLoader cl = new JaninoRestrictedClassLoader();
UnitCompiler unitCompiler = new UnitCompiler(
new Parser(scanner).parseCompilationUnit(),
new ClassLoaderIClassLoader(cl));
ClassFile[] classFiles = unitCompiler.compileUnit(true, true, true);
Class<?> clazz = cl.defineClass(classPackage + "." + className,
classFiles[0].toByteArray());
return (UnaryDoubleFunction) clazz.newInstance();
}
开发者ID:cdman,项目名称:fast-java-expr-eval,代码行数:29,代码来源:JaninoFastexpr.java
示例2: JaninoClassCompiler
import org.codehaus.janino.ClassLoaderIClassLoader; //导入依赖的package包/类
public JaninoClassCompiler(ClassLoader parentClassLoader, boolean debug) {
super(debug);
this.compilationClassLoader = new ClassLoaderIClassLoader(parentClassLoader);
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:5,代码来源:JaninoClassCompiler.java
示例3: JaninoClassCompiler
import org.codehaus.janino.ClassLoaderIClassLoader; //导入依赖的package包/类
@VisibleForTesting
JaninoClassCompiler(ClassLoader parentClassLoader) {
this.compilationClassLoader = new ClassLoaderIClassLoader(parentClassLoader);
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:5,代码来源:JaninoClassCompiler.java
注:本文中的org.codehaus.janino.ClassLoaderIClassLoader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论