编程语言
首页 > 编程语言> > 《jdk8u源码分析》4.DumpState

《jdk8u源码分析》4.DumpState

作者:互联网

src/share/bin/java.c::DumpState

static void
DumpState()
{
    if (!JLI_IsTraceLauncher()) return ;
    /**
     * Launcher state:
     * debug:on
     * javargs:off
     * program name:java
     * launcher name:java
     * javaw:off
     * fullversion:1.8.0_202-ea-b03
     * dotversion:1.8
     * ergo_policy:DEFAULT_ERGONOMICS_POLICY
     **/
    printf("Launcher state:\n");
    printf("\tdebug:%s\n", (JLI_IsTraceLauncher() == JNI_TRUE) ? "on" : "off");
    printf("\tjavargs:%s\n", (_is_java_args == JNI_TRUE) ? "on" : "off");
    printf("\tprogram name:%s\n", GetProgramName());
    printf("\tlauncher name:%s\n", GetLauncherName());
    printf("\tjavaw:%s\n", (IsJavaw() == JNI_TRUE) ? "on" : "off");
    printf("\tfullversion:%s\n", GetFullVersion());
    printf("\tdotversion:%s\n", GetDotVersion());
    printf("\tergo_policy:");
    switch(GetErgoPolicy()) {
        case NEVER_SERVER_CLASS:
            printf("NEVER_ACT_AS_A_SERVER_CLASS_MACHINE\n");
            break;
        case ALWAYS_SERVER_CLASS:
            printf("ALWAYS_ACT_AS_A_SERVER_CLASS_MACHINE\n");
            break;
        default:
            printf("DEFAULT_ERGONOMICS_POLICY\n");
    }
}

如果添加了环境变量:_JAVA_LAUNCHER_DEBUG=1 则可通过该方法打印启动时的部分系统状态参数,其中ErgoPolicy包含以下几种取值:

src/share/bin/java.h::ergo_policy

enum ergo_policy {
   DEFAULT_POLICY = 0,
   NEVER_SERVER_CLASS,
   ALWAYS_SERVER_CLASS
};

标签:java,SERVER,DumpState,源码,jdk8u,printf,policy,off,CLASS
来源: https://blog.csdn.net/weixin_37477523/article/details/88117197