Java Code Examples for jdk.nashorn.internal.runtime.logging.DebugLogger#isEnabled()

The following examples show how to use jdk.nashorn.internal.runtime.logging.DebugLogger#isEnabled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MethodHandleFactory.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 2
Source File: MethodHandleFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 3
Source File: MethodHandleFactory.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 4
Source File: MethodHandleFactory.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 5
Source File: MethodHandleFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 6
Source File: MethodHandleFactory.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 7
Source File: MethodHandleFactory.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 8
Source File: Context.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
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;
    // Don't use code store if optimistic types is enabled but lazy compilation is not.
    // This would store a full script compilation with many wrong optimistic assumptions that would
    // do more harm than good on later runs with both optimistic types and lazy compilation enabled.
    final boolean useCodeStore = codeStore != null && !env._parse_only && (!env._optimistic_types || env._lazy_compilation);
    final String cacheKey = useCodeStore ? CodeStore.getCacheKey("script", null) : null;

    if (useCodeStore) {
        storedScript = codeStore.load(source, cacheKey);
    }

    if (storedScript == null) {
        if (env._dest_dir != null) {
            source.dump(env._dest_dir);
        }

        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 installer = new ContextCodeInstaller(this, loader, cs);

    if (storedScript == null) {
        final CompilationPhases phases = Compiler.CompilationPhases.COMPILE_ALL;

        final Compiler compiler = Compiler.forInitialCompilation(
                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 = storedScript.installScript(source, installer);
    }

    cacheClass(source, script);
    return script;
}
 
Example 9
Source File: CompilationPhase.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@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);
}
 
Example 10
Source File: Context.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
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;
    // Don't use code store if optimistic types is enabled but lazy compilation is not.
    // This would store a full script compilation with many wrong optimistic assumptions that would
    // do more harm than good on later runs with both optimistic types and lazy compilation enabled.
    final boolean useCodeStore = codeStore != null && !env._parse_only && (!env._optimistic_types || env._lazy_compilation);
    final String cacheKey = useCodeStore ? CodeStore.getCacheKey("script", null) : null;

    if (useCodeStore) {
        storedScript = codeStore.load(source, cacheKey);
    }

    if (storedScript == null) {
        if (env._dest_dir != null) {
            source.dump(env._dest_dir);
        }

        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 = storedScript.installScript(source, installer);
    }

    cacheClass(source, script);
    return script;
}
 
Example 11
Source File: CompilationPhase.java    From jdk8u_nashorn with GNU General Public License v2.0 4 votes vote down vote up
@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       codeInstaller = compiler.getCodeInstaller();
    final Map<String, byte[]> bytecode      = compiler.getBytecode();

    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);
}
 
Example 12
Source File: Context.java    From jdk8u_nashorn with GNU General Public License v2.0 4 votes vote down vote up
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;
    // Don't use code store if optimistic types is enabled but lazy compilation is not.
    // This would store a full script compilation with many wrong optimistic assumptions that would
    // do more harm than good on later runs with both optimistic types and lazy compilation enabled.
    final boolean useCodeStore = codeStore != null && !env._parse_only && (!env._optimistic_types || env._lazy_compilation);
    final String cacheKey = useCodeStore ? CodeStore.getCacheKey("script", null) : null;

    if (useCodeStore) {
        storedScript = codeStore.load(source, cacheKey);
    }

    if (storedScript == null) {
        if (env._dest_dir != null) {
            source.dump(env._dest_dir);
        }

        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 installer = new ContextCodeInstaller(this, loader, cs);

    if (storedScript == null) {
        final CompilationPhases phases = Compiler.CompilationPhases.COMPILE_ALL;

        final Compiler compiler = Compiler.forInitialCompilation(
                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 = storedScript.installScript(source, installer);
    }

    cacheClass(source, script);
    return script;
}
 
Example 13
Source File: Context.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
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;
    // Don't use code store if optimistic types is enabled but lazy compilation is not.
    // This would store a full script compilation with many wrong optimistic assumptions that would
    // do more harm than good on later runs with both optimistic types and lazy compilation enabled.
    final boolean useCodeStore = codeStore != null && !env._parse_only && (!env._optimistic_types || env._lazy_compilation);
    final String cacheKey = useCodeStore ? CodeStore.getCacheKey("script", null) : null;

    if (useCodeStore) {
        storedScript = codeStore.load(source, cacheKey);
    }

    if (storedScript == null) {
        if (env._dest_dir != null) {
            source.dump(env._dest_dir);
        }

        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 installer = new ContextCodeInstaller(this, loader, cs);

    if (storedScript == null) {
        final CompilationPhases phases = Compiler.CompilationPhases.COMPILE_ALL;

        final Compiler compiler = Compiler.forInitialCompilation(
                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 = storedScript.installScript(source, installer);
    }

    cacheClass(source, script);
    return script;
}
 
Example 14
Source File: CompilationPhase.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@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       codeInstaller = compiler.getCodeInstaller();
    final Map<String, byte[]> bytecode      = compiler.getBytecode();

    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);
}
 
Example 15
Source File: Context.java    From jdk8u_nashorn with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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;
}
 
Example 16
Source File: Context.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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;
}
 
Example 17
Source File: Context.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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;
}
 
Example 18
Source File: Context.java    From jdk8u60 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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;
}
 
Example 19
Source File: Context.java    From hottub with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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;
}
 
Example 20
Source File: Context.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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;
}