How does java.c determine which to call since there are three function implementations for different systems in Jdk8?

78 Views Asked by At

What puzzles me is how it determines which to call when entering the function JVMInit(as well as LoadJavaVM) in jdk/src/share/bin/java.c since there are three function implementations in different files, namely jdk/src/windows/bin/java_md.c, jdk/src/solaris/ bin/java_md_solinux.c, jdk/src/macosx/bin/java_md_macosx.c

Part code in java.c:

int
JLI_Launch(int argc, char ** argv,              /* main argc, argc */
        int jargc, const char** jargv,          /* java args */
        int appclassc, const char** appclassv,  /* app classpath */
        const char* fullversion,                /* full version defined */
        const char* dotversion,                 /* dot version defined */
        const char* pname,                      /* program name */
        const char* lname,                      /* launcher name */
        jboolean javaargs,                      /* JAVA_ARGS */
        jboolean cpwildcard,                    /* classpath wildcard*/
        jboolean javaw,                         /* windows-only javaw */
        jint ergo                               /* ergonomics class policy */
)
{
    int mode = LM_UNKNOWN;
    char *what = NULL;
    char *cpath = 0;
    char *main_class = NULL;
    int ret;
    InvocationFunctions ifn;
    jlong start = 0, end = 0;
    char jvmpath[MAXPATHLEN];
    char jrepath[MAXPATHLEN];
    char jvmcfg[MAXPATHLEN];

    ...

    if (!LoadJavaVM(jvmpath, &ifn)) {
        return(6);
    }

    ...

    return JVMInit(&ifn, threadStackSize, argc, argv, mode, what, ret);
}

I was only able to find the corresponding function implementations in the three files, and due to my unfamiliarity with C/C++, I was unable to find how it determines which one to enter in the jdk8 source code.

I hope someone can help point out how it works.

P.S. The jdk8 source code I've been reading comes from https://github.com/openjdk/jdk8u/releases/tag/jdk8u392-ga.zip

0

There are 0 best solutions below