本文整理汇总了Java中jdk.nashorn.internal.runtime.logging.DebugLogger.fine方法的典型用法代码示例。如果您正苦于以下问题:Java DebugLogger.fine方法的具体用法?Java DebugLogger.fine怎么用?Java DebugLogger.fine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jdk.nashorn.internal.runtime.logging.DebugLogger
的用法示例。
在下文中一共展示了DebugLogger.fine方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compile
import jdk.nashorn.internal.runtime.logging.DebugLogger; //导入方法依赖的package包/类
private synchronized Class<?> compile(final Source source, final ErrorManager errMan, final boolean strict) {
// start with no errors, no warnings.
errMan.reset();
Class<?> script = findCachedClass(source);
if (script != null) {
final DebugLogger log = getLogger(Compiler.class);
if (log.isEnabled()) {
log.fine(new RuntimeEvent<>(Level.INFO, source), "Code cache hit for ", source, " avoiding recompile.");
}
return script;
}
StoredScript storedScript = null;
FunctionNode functionNode = null;
// We only use the code store here if optimistic types are disabled. With optimistic types, initial compilation
// just creates a thin wrapper, and actual code is stored per function in RecompilableScriptFunctionData.
final boolean useCodeStore = codeStore != null && !env._parse_only && !env._optimistic_types;
final String cacheKey = useCodeStore ? CodeStore.getCacheKey(0, null) : null;
if (useCodeStore) {
storedScript = codeStore.load(source, cacheKey);
}
if (storedScript == null) {
functionNode = new Parser(env, source, errMan, strict, getLogger(Parser.class)).parse();
if (errMan.hasErrors()) {
return null;
}
if (env._print_ast || functionNode.getFlag(FunctionNode.IS_PRINT_AST)) {
getErr().println(new ASTWriter(functionNode));
}
if (env._print_parse || functionNode.getFlag(FunctionNode.IS_PRINT_PARSE)) {
getErr().println(new PrintVisitor(functionNode, true, false));
}
}
if (env._parse_only) {
return null;
}
final URL url = source.getURL();
final ScriptLoader loader = env._loader_per_compile ? createNewLoader() : scriptLoader;
final CodeSource cs = new CodeSource(url, (CodeSigner[])null);
final CodeInstaller<ScriptEnvironment> installer = new ContextCodeInstaller(this, loader, cs);
if (storedScript == null) {
final CompilationPhases phases = Compiler.CompilationPhases.COMPILE_ALL;
final Compiler compiler = new Compiler(
this,
env,
installer,
source,
errMan,
strict | functionNode.isStrict());
final FunctionNode compiledFunction = compiler.compile(functionNode, phases);
if (errMan.hasErrors()) {
return null;
}
script = compiledFunction.getRootClass();
compiler.persistClassInfo(cacheKey, compiledFunction);
} else {
Compiler.updateCompilationId(storedScript.getCompilationId());
script = install(storedScript, source, installer);
}
cacheClass(source, script);
return script;
}
示例2: transform
import jdk.nashorn.internal.runtime.logging.DebugLogger; //导入方法依赖的package包/类
@Override
FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) {
final DebugLogger log = compiler.getLogger();
final Map<String, Class<?>> installedClasses = new LinkedHashMap<>();
boolean first = true;
Class<?> rootClass = null;
long length = 0L;
final CodeInstaller origCodeInstaller = compiler.getCodeInstaller();
final Map<String, byte[]> bytecode = compiler.getBytecode();
final CodeInstaller codeInstaller = bytecode.size() > 1 ? origCodeInstaller.getMultiClassCodeInstaller() : origCodeInstaller;
for (final Entry<String, byte[]> entry : bytecode.entrySet()) {
final String className = entry.getKey();
//assert !first || className.equals(compiler.getFirstCompileUnit().getUnitClassName()) : "first=" + first + " className=" + className + " != " + compiler.getFirstCompileUnit().getUnitClassName();
final byte[] code = entry.getValue();
length += code.length;
final Class<?> clazz = codeInstaller.install(className, code);
if (first) {
rootClass = clazz;
first = false;
}
installedClasses.put(className, clazz);
}
if (rootClass == null) {
throw new CompilationException("Internal compiler error: root class not found!");
}
final Object[] constants = compiler.getConstantData().toArray();
codeInstaller.initialize(installedClasses.values(), compiler.getSource(), constants);
// initialize transient fields on recompilable script function data
for (final Object constant: constants) {
if (constant instanceof RecompilableScriptFunctionData) {
((RecompilableScriptFunctionData)constant).initTransients(compiler.getSource(), codeInstaller);
}
}
// initialize function in the compile units
for (final CompileUnit unit : compiler.getCompileUnits()) {
if (!unit.isUsed()) {
continue;
}
unit.setCode(installedClasses.get(unit.getUnitClassName()));
unit.initializeFunctionsCode();
}
if (log.isEnabled()) {
final StringBuilder sb = new StringBuilder();
sb.append("Installed class '").
append(rootClass.getSimpleName()).
append('\'').
append(" [").
append(rootClass.getName()).
append(", size=").
append(length).
append(" bytes, ").
append(compiler.getCompileUnits().size()).
append(" compile unit(s)]");
log.fine(sb.toString());
}
return fn.setRootClass(null, rootClass);
}