《jdk8u源码分析》16.2.2.InitializeJVM

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

/*
 * Initializes the Java Virtual Machine. Also frees options array when
 * finished.
 */
static jboolean
InitializeJVM(JavaVM **pvm, JNIEnv **penv, InvocationFunctions *ifn)
{
    JavaVMInitArgs args;
    jint r;

    memset(&args, 0, sizeof(args));
    args.version  = JNI_VERSION_1_2;
    //@see: 10.AddApplicationOptions
    //@see: 12.ParseArguments
    args.nOptions = numOptions;
    args.options  = options;
    args.ignoreUnrecognized = JNI_FALSE;

    if (JLI_IsTraceLauncher()) {
        int i = 0;
        //JavaVM args:
        //    version 0x00010002, ignoreUnrecognized is JNI_FALSE, nOptions is 5
        //    option[ 0] = '-Dsun.java.launcher.diag=true'
        //    option[ 1] = '-Djava.class.path=.;C:\Tools\Java\jdk1.8.0_191\lib;C:\Tools\Java\jdk1.8.0_191\lib\tools.jar'
        //    option[ 2] = '-Djava.class.path=test.jar'
        //    option[ 3] = '-Dsun.java.command=test.jar'
        //    option[ 4] = '-Dsun.java.launcher=SUN_STANDARD'
        printf("JavaVM args:\n    ");
        printf("version 0x%08lx, ", (long)args.version);
        printf("ignoreUnrecognized is %s, ",
               args.ignoreUnrecognized ? "JNI_TRUE" : "JNI_FALSE");
        printf("nOptions is %ld\n", (long)args.nOptions);
        for (i = 0; i < numOptions; i++)
            printf("    option[%2d] = '%s'\n",
                   i, args.options[i].optionString);
    }
	
	//@see: 8.LoadJavaVM
    r = ifn->CreateJavaVM(pvm, (void **)penv, &args);
    JLI_MemFree(options);
    return r == JNI_OK;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值