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


Java ClassCompiler类代码示例

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


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

示例1: RhinoAdapter

import org.mozilla.javascript.optimizer.ClassCompiler; //导入依赖的package包/类
/**
 * Constructor.
 * 
 * @throws LanguageAdapterException
 *         In case of an initialization error
 */
public RhinoAdapter() throws LanguageAdapterException
{
	super( "Rhino", getImplementationVersion(), "JavaScript", getLanguageVersion(), Arrays.asList( "js", "javascript", "rhino" ), "js", Arrays.asList( "javascript", "js", "rhino" ), "rhino" );

	CompilerEnvirons compilerEnvirons = new CompilerEnvirons();
	compilerEnvirons.setOptimizationLevel( getOptimizationLevel() );
	classCompiler = new ClassCompiler( compilerEnvirons );
	Context context = enterContext();
	try
	{
		generatedClassLoader = context.createClassLoader( RhinoAdapter.class.getClassLoader() );
	}
	finally
	{
		Context.exit();
	}
}
 
开发者ID:tliron,项目名称:scripturian,代码行数:24,代码来源:RhinoAdapter.java

示例2: Main

import org.mozilla.javascript.optimizer.ClassCompiler; //导入依赖的package包/类
public Main()
{
    reporter = new ToolErrorReporter(true);
    compilerEnv = new CompilerEnvirons();
    compilerEnv.setErrorReporter(reporter);
    compiler = new ClassCompiler(compilerEnv);
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:8,代码来源:Main.java

示例3: compileScripts

import org.mozilla.javascript.optimizer.ClassCompiler; //导入依赖的package包/类
protected void compileScripts(JRCompilationUnit unit, CompilerEnvirons compilerEnv, 
		CompileSources compileSources, JavaScriptCompiledData compiledData)
{
	List<String> scripts = compileSources.getScripts();
	int scriptIndex = 0;
	for (String scriptSource : scripts)
	{
		String scriptClassName = unit.getName() + "_" + scriptIndex;
		
		if (log.isTraceEnabled())
		{
			log.trace("compiling script with name " + scriptClassName
					+ "\n" + scriptSource);
		}
		
		ClassCompiler compiler = new ClassCompiler(compilerEnv);
		// this should not fail since we've already separately compiled the default expression
		Object[] compilationResult = compiler.compileToClassFiles(scriptSource, unit.getName(), 0, scriptClassName);
		if (compilationResult.length != 2)
		{
			throw 
				new JRRuntimeException(
					EXCEPTION_MESSAGE_KEY_UNEXPECTED_CLASSES_LENGTH,
					new Object[]{compilationResult.length});
		}
		if (!scriptClassName.equals(compilationResult[0]))
		{
			throw 
				new JRRuntimeException(
					EXCEPTION_MESSAGE_KEY_UNEXPECTED_CLASS_NAME,
					new Object[]{compilationResult[0], scriptClassName});
		}
		
		byte[] compiledClass = (byte[]) compilationResult[1];
		compiledData.addClass(scriptClassName, compiledClass);
		
		++scriptIndex;
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:40,代码来源:JavaScriptClassCompiler.java


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