• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DebugLogger类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Parser

import jdk.nashorn.internal.runtime.logging.DebugLogger; //导入依赖的package包/类
/**
 * Construct a parser.
 *
 * @param env     script environment
 * @param source  source to parse
 * @param errors  error manager
 * @param strict  parser created with strict mode enabled.
 * @param lineOffset line offset to start counting lines from
 * @param log debug logger if one is needed
 */
public Parser(final ScriptEnvironment env, final Source source, final ErrorManager errors, final boolean strict, final int lineOffset, final DebugLogger log) {
    super(source, errors, strict, lineOffset);
    this.env = env;
    this.namespace = new Namespace(env.getNamespace());
    this.scripting = env._scripting;
    if (this.scripting) {
        this.lineInfoReceiver = new Lexer.LineInfoReceiver() {
            @Override
            public void lineInfo(final int receiverLine, final int receiverLinePosition) {
                // update the parser maintained line information
                Parser.this.line = receiverLine;
                Parser.this.linePosition = receiverLinePosition;
            }
        };
    } else {
        // non-scripting mode script can't have multi-line literals
        this.lineInfoReceiver = null;
    }

    this.log = log == null ? DebugLogger.DISABLED_LOGGER : log;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:32,代码来源:Parser.java


示例2: CompiledFunction

import jdk.nashorn.internal.runtime.logging.DebugLogger; //导入依赖的package包/类
CompiledFunction(final MethodHandle invoker, final MethodHandle constructor, final int flags, final MethodType callSiteType, final Specialization specialization, final DebugLogger log) {
    this.specialization = specialization;
    if (specialization != null && specialization.isOptimistic()) {
        /*
         * An optimistic builtin with isOptimistic=true works like any optimistic generated function, i.e. it
         * can throw unwarranted optimism exceptions. As native functions trivially can't have parts of them
         * regenerated as restof methods, this only works if the methods are atomic/functional in their behavior
         * and doesn't modify state before an UOE can be thrown. If they aren't, we can reexecute a wider version
         * of the same builtin in a recompilation handler for FinalScriptFunctionData. There are several
         * candidate methods in Native* that would benefit from this, but I haven't had time to implement any
         * of them currently. In order to fit in with the relinking framework, the current thinking is
         * that the methods still take a program point to fit in with other optimistic functions, but
         * it is set to "first", which is the beginning of the method. The relinker can tell the difference
         * between builtin and JavaScript functions. This might change. TODO
         */
        this.invoker = MH.insertArguments(invoker, invoker.type().parameterCount() - 1, UnwarrantedOptimismException.FIRST_PROGRAM_POINT);
        throw new AssertionError("Optimistic (UnwarrantedOptimismException throwing) builtin functions are currently not in use");
    }
    this.invoker = invoker;
    this.constructor = constructor;
    this.flags = flags;
    this.callSiteType = callSiteType;
    this.log = log;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:CompiledFunction.java


示例3: hasApplies

import jdk.nashorn.internal.runtime.logging.DebugLogger; //导入依赖的package包/类
private boolean hasApplies(final FunctionNode functionNode) {
    try {
        functionNode.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) {
            @Override
            public boolean enterFunctionNode(final FunctionNode fn) {
                return fn == functionNode;
            }

            @Override
            public boolean enterCallNode(final CallNode callNode) {
                if (isApply(callNode)) {
                    throw HAS_APPLIES;
                }
                return true;
            }
        });
    } catch (final AppliesFoundException e) {
        return true;
    }

    log.fine("There are no applies in ", DebugLogger.quote(functionNode.getName()), " - nothing to do.");
    return false; // no applies
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:ApplySpecialization.java


示例4: Parser

import jdk.nashorn.internal.runtime.logging.DebugLogger; //导入依赖的package包/类
/**
 * Construct a parser.
 *
 * @param env     script environment
 * @param source  source to parse
 * @param errors  error manager
 * @param strict  parser created with strict mode enabled.
 * @param lineOffset line offset to start counting lines from
 * @param log debug logger if one is needed
 */
public Parser(final ScriptEnvironment env, final Source source, final ErrorManager errors, final boolean strict, final int lineOffset, final DebugLogger log) {
    super(source, errors, strict, lineOffset);
    this.lc = new ParserContext();
    this.defaultNames = new ArrayDeque<>();
    this.env = env;
    this.namespace = new Namespace(env.getNamespace());
    this.scripting = env._scripting;
    if (this.scripting) {
        this.lineInfoReceiver = new Lexer.LineInfoReceiver() {
            @Override
            public void lineInfo(final int receiverLine, final int receiverLinePosition) {
                // update the parser maintained line information
                Parser.this.line = receiverLine;
                Parser.this.linePosition = receiverLinePosition;
            }
        };
    } else {
        // non-scripting mode script can't have multi-line literals
        this.lineInfoReceiver = null;
    }

    this.log = log == null ? DebugLogger.DISABLED_LOGGER : log;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:Parser.java


示例5: hasApplies

import jdk.nashorn.internal.runtime.logging.DebugLogger; //导入依赖的package包/类
private boolean hasApplies(final FunctionNode functionNode) {
    try {
        functionNode.accept(new SimpleNodeVisitor() {
            @Override
            public boolean enterFunctionNode(final FunctionNode fn) {
                return fn == functionNode;
            }

            @Override
            public boolean enterCallNode(final CallNode callNode) {
                if (isApply(callNode)) {
                    throw HAS_APPLIES;
                }
                return true;
            }
        });
    } catch (final AppliesFoundException e) {
        return true;
    }

    log.fine("There are no applies in ", DebugLogger.quote(functionNode.getName()), " - nothing to do.");
    return false; // no applies
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:ApplySpecialization.java


示例6: ensureInitialized

import jdk.nashorn.internal.runtime.logging.DebugLogger; //导入依赖的package包/类
private DebugLogger ensureInitialized(final Context context) {
    //lazy init, as there is not necessarily a context available when
    //a ScriptEnvironment gets initialize
    if (isEnabled() && log == null) {
        log = initLogger(context);
        if (log.isEnabled()) {
            this.timeSupplier = new TimeSupplier();
            Runtime.getRuntime().addShutdownHook(
                    new Thread() {
                        @Override
                        public void run() {
                            //System.err.println because the context and the output streams may be gone
                            //when the shutdown hook executes
                            final StringBuilder sb = new StringBuilder();
                            for (final String str : timeSupplier.getStrings()) {
                                sb.append('[').
                                    append(Timing.getLoggerName()).
                                    append("] ").
                                    append(str).
                                    append('\n');
                            }
                            System.err.print(sb);
                        }
                    });
        }
    }
    return log;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:Timing.java


示例7: logRecompile

import jdk.nashorn.internal.runtime.logging.DebugLogger; //导入依赖的package包/类
private void logRecompile(final String reason, final FunctionNode fn, final MethodType type, final Map<Integer, Type> ipp) {
    if (log.isEnabled()) {
        log.info(reason, DebugLogger.quote(fn.getName()), " signature: ", type);
        log.indent();
        for (final String str : toStringInvalidations(ipp)) {
            log.fine(str);
        }
        log.unindent();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:CompiledFunction.java


示例8: 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


示例9: traceArgs

import jdk.nashorn.internal.runtime.logging.DebugLogger; //导入依赖的package包/类
/**
 * Tracer that is applied before a function is called, printing the arguments
 *
 * @param tag  tag to start the debug printout string
 * @param paramStart param index to start outputting from
 * @param args arguments to the function
 */
static void traceArgs(final DebugLogger logger, final String tag, final int paramStart, final Object... args) {
    final StringBuilder sb = new StringBuilder();

    sb.append(tag);

    for (int i = paramStart; i < args.length; i++) {
        if (i == paramStart) {
            sb.append(" => args: ");
        }

        sb.append('\'').
            append(stripName(argString(args[i]))).
            append('\'').
            append(' ').
            append('[').
            append("type=").
            append(args[i] == null ? "null" : stripName(args[i].getClass())).
            append(']');

        if (i + 1 < args.length) {
            sb.append(", ");
        }
    }

    if (logger == null) {
        err(sb.toString());
    } else {
        logger.log(TRACE_LEVEL, sb);
    }
    stacktrace(logger);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:39,代码来源:MethodHandleFactory.java


示例10: stacktrace

import jdk.nashorn.internal.runtime.logging.DebugLogger; //导入依赖的package包/类
private static void stacktrace(final DebugLogger logger) {
    if (!PRINT_STACKTRACE) {
        return;
    }
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final PrintStream ps = new PrintStream(baos);
    new Throwable().printStackTrace(ps);
    final String st = baos.toString();
    if (logger == null) {
        err(st);
    } else {
        logger.log(TRACE_LEVEL, st);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:MethodHandleFactory.java


示例11: addDebugPrintout

import jdk.nashorn.internal.runtime.logging.DebugLogger; //导入依赖的package包/类
/**
 * Add a debug printout to a method handle, tracing parameters and return values
 *
 * @param logger a specific logger to which to write the output
 * @param level level over which to print
 * @param mh  method handle to trace
 * @param paramStart first param to print/trace
 * @param printReturnValue should we print/trace return value if available?
 * @param tag start of trace message
 * @return  traced method handle
 */
public static MethodHandle addDebugPrintout(final DebugLogger logger, final Level level, final MethodHandle mh, final int paramStart, final boolean printReturnValue, final Object tag) {
    final MethodType type = mh.type();

    //if there is no logger, or if it's set to log only coarser events
    //than the trace level, skip and return
    if (logger != null && logger.levelCoarserThan(level)) {
        return mh;
    }

    assert TRACE != null;

    MethodHandle trace = MethodHandles.insertArguments(TRACE, 0, logger, tag, paramStart);

    trace = MethodHandles.foldArguments(
            mh,
            trace.asCollector(
                Object[].class,
                type.parameterCount()).
            asType(type.changeReturnType(void.class)));

    final Class<?> retType = type.returnType();
    if (printReturnValue) {
        if (retType != void.class) {
            final MethodHandle traceReturn = MethodHandles.insertArguments(TRACE_RETURN, 0, logger);
            trace = MethodHandles.filterReturnValue(trace,
                    traceReturn.asType(
                        traceReturn.type().changeParameterType(0, retType).changeReturnType(retType)));
        } else {
            trace = MethodHandles.filterReturnValue(trace, MethodHandles.insertArguments(TRACE_RETURN_VOID, 0, logger));
        }
    }

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


示例12: getLogger

import jdk.nashorn.internal.runtime.logging.DebugLogger; //导入依赖的package包/类
private static DebugLogger getLogger() {
    try {
        return Context.getContext().getLogger(RecompilableScriptFunctionData.class);
    } catch (final Exception e) {
        e.printStackTrace();
        return DebugLogger.DISABLED_LOGGER;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:OptimisticTypesPersistence.java


示例13: initLogger

import jdk.nashorn.internal.runtime.logging.DebugLogger; //导入依赖的package包/类
@Override
public DebugLogger initLogger(final Context ctxt) {
    final boolean optimisticTypes = env._optimistic_types;
    final boolean lazyCompilation = env._lazy_compilation;

    return ctxt.getLogger(this.getClass(), new Consumer<DebugLogger>() {
        @Override
        public void accept(final DebugLogger newLogger) {
            if (!lazyCompilation) {
                newLogger.warning("WARNING: Running with lazy compilation switched off. This is not a default setting.");
            }
            newLogger.warning("Optimistic types are ", optimisticTypes ? "ENABLED." : "DISABLED.");
        }
    });
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:Compiler.java


示例14: leaveCallNode

import jdk.nashorn.internal.runtime.logging.DebugLogger; //导入依赖的package包/类
@Override
public Node leaveCallNode(final CallNode callNode) {
    //apply needs to be a global symbol or we don't allow it

    final List<IdentNode> newParams = explodedArguments.peek();
    if (isApply(callNode)) {
        final List<Expression> newArgs = new ArrayList<>();
        for (final Expression arg : callNode.getArgs()) {
            if (arg instanceof IdentNode && ARGUMENTS.equals(((IdentNode)arg).getName())) {
                newArgs.addAll(newParams);
            } else {
                newArgs.add(arg);
            }
        }

        changed.add(lc.getCurrentFunction().getId());

        final CallNode newCallNode = callNode.setArgs(newArgs).setIsApplyToCall();

        if (log.isEnabled()) {
            log.fine("Transformed ",
                    callNode,
                    " from apply to call => ",
                    newCallNode,
                    " in ",
                    DebugLogger.quote(lc.getCurrentFunction().getName()));
        }

        return newCallNode;
    }

    return callNode;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:ApplySpecialization.java


示例15: 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


示例16: traceArgs

import jdk.nashorn.internal.runtime.logging.DebugLogger; //导入依赖的package包/类
/**
 * Tracer that is applied before a function is called, printing the arguments
 *
 * @param tag  tag to start the debug printout string
 * @param paramStart param index to start outputting from
 * @param args arguments to the function
 */
static void traceArgs(final DebugLogger logger, final String tag, final int paramStart, final Object... args) {
    final StringBuilder sb = new StringBuilder();

    sb.append(tag);

    for (int i = paramStart; i < args.length; i++) {
        if (i == paramStart) {
            sb.append(" => args: ");
        }

        sb.append('\'').
        append(stripName(argString(args[i]))).
        append('\'').
        append(' ').
        append('[').
        append("type=").
        append(args[i] == null ? "null" : stripName(args[i].getClass())).
        append(']');

        if (i + 1 < args.length) {
            sb.append(", ");
        }
    }

    if (logger == null) {
        err(sb.toString());
    } else {
        logger.log(TRACE_LEVEL, sb);
    }
    stacktrace(logger);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:39,代码来源:MethodHandleFactory.java


示例17: addDebugPrintout

import jdk.nashorn.internal.runtime.logging.DebugLogger; //导入依赖的package包/类
/**
 * Add a debug printout to a method handle, tracing parameters and return values
 *
 * @param logger a specific logger to which to write the output
 * @param level level over which to print
 * @param mh  method handle to trace
 * @param paramStart first param to print/trace
 * @param printReturnValue should we print/trace return value if available?
 * @param tag start of trace message
 * @return  traced method handle
 */
public static MethodHandle addDebugPrintout(final DebugLogger logger, final Level level, final MethodHandle mh, final int paramStart, final boolean printReturnValue, final Object tag) {
    final MethodType type = mh.type();

    //if there is no logger, or if it's set to log only coarser events
    //than the trace level, skip and return
    if (logger == null || !logger.isLoggable(level)) {
        return mh;
    }

    assert TRACE != null;

    MethodHandle trace = MethodHandles.insertArguments(TRACE, 0, logger, tag, paramStart);

    trace = MethodHandles.foldArguments(
            mh,
            trace.asCollector(
                    Object[].class,
                    type.parameterCount()).
                    asType(type.changeReturnType(void.class)));

    final Class<?> retType = type.returnType();
    if (printReturnValue) {
        if (retType != void.class) {
            final MethodHandle traceReturn = MethodHandles.insertArguments(TRACE_RETURN, 0, logger);
            trace = MethodHandles.filterReturnValue(trace,
                    traceReturn.asType(
                            traceReturn.type().changeParameterType(0, retType).changeReturnType(retType)));
        } else {
            trace = MethodHandles.filterReturnValue(trace, MethodHandles.insertArguments(TRACE_RETURN_VOID, 0, logger));
        }
    }

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


示例18: getLogger

import jdk.nashorn.internal.runtime.logging.DebugLogger; //导入依赖的package包/类
@Override
public DebugLogger getLogger() {
    return log;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:Parser.java


示例19: initLogger

import jdk.nashorn.internal.runtime.logging.DebugLogger; //导入依赖的package包/类
@Override
public DebugLogger initLogger(final Context context) {
    return context.getLogger(this.getClass());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:Parser.java


示例20: initLogger

import jdk.nashorn.internal.runtime.logging.DebugLogger; //导入依赖的package包/类
@Override
public DebugLogger initLogger(final Context context) {
    return DebugLogger.DISABLED_LOGGER;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:GlobalConstants.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DispatchMessages类代码示例发布时间:2022-05-23
下一篇:
Java EntityAIHarvestFarmland类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap