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


Java DebugLogger.isEnabled方法代码示例

本文整理汇总了Java中jdk.nashorn.internal.runtime.logging.DebugLogger.isEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java DebugLogger.isEnabled方法的具体用法?Java DebugLogger.isEnabled怎么用?Java DebugLogger.isEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jdk.nashorn.internal.runtime.logging.DebugLogger的用法示例。


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

示例1: traceReturn

import jdk.nashorn.internal.runtime.logging.DebugLogger; //导入方法依赖的package包/类
/**
 * Tracer that is applied before a value is returned from the traced function. It will output the return
 * value and its class
 *
 * @param value return value for filter
 * @return return value unmodified
 */
static Object traceReturn(final DebugLogger logger, final Object value) {
    final String str = "    return" +
            (VOID_TAG.equals(value) ?
                ";" :
                " " + stripName(value) + "; // [type=" + (value == null ? "null]" : stripName(value.getClass()) + ']'));
    if (logger == null) {
        err(str);
    } else if (logger.isEnabled()) {
        logger.log(TRACE_LEVEL, str);
    }

    return value;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:MethodHandleFactory.java

示例2: traceReturn

import jdk.nashorn.internal.runtime.logging.DebugLogger; //导入方法依赖的package包/类
/**
 * Tracer that is applied before a value is returned from the traced function. It will output the return
 * value and its class
 *
 * @param value return value for filter
 * @return return value unmodified
 */
static Object traceReturn(final DebugLogger logger, final Object value) {
    final String str = "    return" +
            (VOID_TAG.equals(value) ?
                    ";" :
                        " " + stripName(value) + "; // [type=" + (value == null ? "null]" : stripName(value.getClass()) + ']'));
    if (logger == null) {
        err(str);
    } else if (logger.isEnabled()) {
        logger.log(TRACE_LEVEL, str);
    }

    return value;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:MethodHandleFactory.java

示例3: 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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:75,代码来源:Context.java

示例4: 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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:71,代码来源:CompilationPhase.java

示例5: addLoggingToHandle

import jdk.nashorn.internal.runtime.logging.DebugLogger; //导入方法依赖的package包/类
/**
 * Given a Loggable class, weave debug info info a method handle for that logger.
 *
 * @param clazz            loggable
 * @param level            log level
 * @param mh               method handle
 * @param paramStart       first parameter to print
 * @param printReturnValue should we print the return vaulue?
 * @param text             debug printout to add
 *
 * @return instrumented method handle, or null if logger not enabled
 */
public MethodHandle addLoggingToHandle(final Class<? extends Loggable> clazz, final Level level, final MethodHandle mh, final int paramStart, final boolean printReturnValue, final Supplier<String> text) {
    final DebugLogger log = getLogger(clazz);
    if (log.isEnabled()) {
        return MethodHandleFactory.addDebugPrintout(log, level, mh, paramStart, printReturnValue, text.get());
    }
    return mh;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:Context.java

示例6: addLoggingToHandle

import jdk.nashorn.internal.runtime.logging.DebugLogger; //导入方法依赖的package包/类
/**
 * Given a Loggable class, weave debug info info a method handle for that logger.
 *
 * @param clazz            loggable
 * @param level            log level
 * @param mh               method handle
 * @param paramStart       first parameter to print
 * @param printReturnValue should we print the return value?
 * @param text             debug printout to add
 *
 * @return instrumented method handle, or null if logger not enabled
 */
public MethodHandle addLoggingToHandle(final Class<? extends Loggable> clazz, final Level level, final MethodHandle mh, final int paramStart, final boolean printReturnValue, final Supplier<String> text) {
    final DebugLogger log = getLogger(clazz);
    if (log.isEnabled()) {
        return MethodHandleFactory.addDebugPrintout(log, level, mh, paramStart, printReturnValue, text.get());
    }
    return mh;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:Context.java


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