/*
* this file contains the main entry point into the launcher code
* this is the only file which will be repeatedly compiled by other
* tools. the rest of the files will be linked in.
*/
#include "defines.h"
#ifdef _msc_ver
#if _msc_ver > 1400 && _msc_ver < 1600
/*
* when building for microsoft windows, main has a dependency on msvcr??.dll.
*
* when using visual studio 2005 or 2008, that must be recorded in
* the [java,javaw].exe.manifest file.
*
* as of vs2010 (ver=1600), the runtimes again no longer need manifests.
*
* reference:
* c:/program files/microsoft sdks/windows/v6.1/include/crtdefs.h
*/
#include <crtassem.h>
#ifdef _m_ix86
#pragma comment(linker,"/manifestdependency:"type='win32' " \
"name='" __libraries_assembly_name_prefix ".crt' " \
"version='" _crt_assembly_version "' " \
"processorarchitecture='x86' " \
"publickeytoken='" _vc_assembly_publickeytoken "'"")
#endif /* _m_ix86 */
//this may not be necessary yet for the windows 64-bit build, but it
//will be when that build environment is updated. need to test to see
//if it is harmless:
#ifdef _m_amd64
#pragma comment(linker,"/manifestdependency:"type='win32' " \
"name='" __libraries_assembly_name_prefix ".crt' " \
"version='" _crt_assembly_version "' " \
"processorarchitecture='amd64' " \
"publickeytoken='" _vc_assembly_publickeytoken "'"")
#endif /* _m_amd64 */
#endif /* _msc_ver > 1400 && _msc_ver < 1600 */
#endif /* _msc_ver */
/*
* entry point.
*/
// 定义入口函数,javaw模式下使用 winmain(), 否则使用 main()
#ifdef javaw
char **__initenv;
int winapi
winmain(hinstance inst, hinstance previnst, lpstr cmdline, int cmdshow)
{
int margc;
char** margv;
const jboolean const_javaw = jni_true;
__initenv = _environ;
#else /* javaw */
int
main(int argc, char **argv)
{
int margc;
char** margv;
const jboolean const_javaw = jni_false;
#endif /* javaw */
#ifdef _win32
// windows下的参数获取
{
int i = 0;
if (getenv(jldebug_env_entry) != null) {
printf("windows original main args:\n");
for (i = 0 ; i < __argc ; i++) {
printf("wwwd_args[%d] = %s\n", i, __argv[i]);
}
}
}
jli_cmdtoargs(getcommandline());
margc = jli_getstdargc();
// add one more to mark the end
margv = (char **)jli_memalloc((margc + 1) * (sizeof(char *)));
{
int i = 0;
stdarg *stdargs = jli_getstdargs();
for (i = 0 ; i < margc ; i++) {
margv[i] = stdargs[i].arg;
}
margv[i] = null;
}
#else /* *nixes */
// 各种linux平台上的参数,直接取自main入参
margc = argc;
margv = argv;
#endif /* win32 */
// 核心: 重新定义入口方法为: jli_launch()
return jli_launch(margc, margv,
sizeof(const_jargs) / sizeof(char *), const_jargs,
sizeof(const_appclasspath) / sizeof(char *), const_appclasspath,
full_version,
dot_version,
(const_progname != null) ? const_progname : *margv,
(const_launcher != null) ? const_launcher : *margv,
(const_jargs != null) ? jni_true : jni_false,
const_cpwildcard, const_javaw, const_ergo_class);
}
// share/bin/java.c
/*
* entry point.
*/
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, end;
char jvmpath[maxpathlen];
char jrepath[maxpathlen];
char jvmcfg[maxpathlen];
_fversion = fullversion;
_dversion = dotversion;
_launcher_name = lname;
_program_name = pname;
_is_java_args = javaargs;
_wc_enabled = cpwildcard;
_ergo_policy = ergo;
// 初始化启动器
initlauncher(javaw);
// 打印状态
dumpstate();
// 跟踪调用启动
if (jli_istracelauncher()) {
int i;
printf("command line args:\n");
for (i = 0; i < argc ; i++) {
printf("argv[%d] = %s\n", i, argv[i]);
}
addoption("-dsun.java.launcher.diag=true", null);
}
/*
* make sure the specified version of the jre is running.
*
* there are three things to note about the selectversion() routine:
* 1) if the version running isn't correct, this routine doesn't
* return (either the correct version has been exec'd or an error
* was issued).
* 2) argc and argv in this scope are *not* altered by this routine.
* it is the responsibility of subsequent code to ignore the
* arguments handled by this routine.
* 3) as a side-effect, the variable "main_class" is guaranteed to
* be set (if it should ever be set). this isn't exactly the
* poster child for structured programming, but it is a small
* price to pay for not processing a jar file operand twice.
* (note: this side effect has been disabled. see comment on
* bugid 5030265 below.)
*/
// 解析命令行参数,选择一jre版本
selectversion(argc, argv, &main_class);
createexecutionenvironment(&argc, &argv,
jrepath, sizeof(jrepath),
jvmpath, sizeof(jvmpath),
jvmcfg, sizeof(jvmcfg));
if (!isjavaargs()) {
// 设置一些特殊的环境变量
setjvmenvironment(argc,argv);
}
ifn.createjavavm = 0;
ifn.getdefaultjavavminitargs = 0;
if (jli_istracelauncher()) {
start = counterget(); // 记录启动时间
}
// 加载vm, 重中之重
if (!loadjavavm(jvmpath, &ifn)) {
return(6);
}
if (jli_istracelauncher()) {
end = counterget();
}
jli_tracelauncher("%ld micro seconds to loadjavavm\n",
(long)(jint)counter2micros(end-start));
++argv;
--argc;
// 解析更多参数信息
if (isjavaargs()) {
/* preprocess wrapper arguments */
translateapplicationargs(jargc, jargv, &argc, &argv);
if (!addapplicationoptions(appclassc, appclassv)) {
return(1);
}
} else {
/* set default classpath */
cpath = getenv("classpath");
if (cpath == null) {
cpath = ".";
}
setclasspath(cpath);
}
/* parse command line options; if the return value of
* parsearguments is false, the program should exit.
*/
// 解析参数
if (!parsearguments(&argc, &argv, &mode, &what, &ret, jrepath))
{
return(ret);
}
/* override class path if -jar flag was specified */
if (mode == lm_jar) {
setclasspath(what); /* override class path */
}
/* set the -dsun.java.command pseudo property */
setjavacommandlineprop(what, argc, argv);
/* set the -dsun.java.launcher pseudo property */
setjavalauncherprop();
/* set the -dsun.java.launcher.* platform properties */
setjavalauncherplatformprops();
// 初始化jvm,即加载java程序开始,应用表演时间到
return jvminit(&ifn, threadstacksize, argc, argv, mode, what, ret);
}
// java.c
/*
* the selectversion() routine ensures that an appropriate version of
* the jre is running. the specification for the appropriate version
* is obtained from either the manifest of a jar file (preferred) or
* from command line options.
* the routine also parses splash screen command line options and
* passes on their values in private environment variables.
*/
static void
selectversion(int argc, char **argv, char **main_class)
{
char *arg;
char **new_argv;
char **new_argp;
char *operand;
char *version = null;
char *jre = null;
int jarflag = 0;
int headlessflag = 0;
int restrict_search = -1; /* -1 implies not known */
manifest_info info;
char env_entry[maxnamelen + 24] = env_entry "=";
char *splash_file_name = null;
char *splash_jar_name = null;
char *env_in;
int res;
/*
* if the version has already been selected, set *main_class
* with the value passed through the environment (if any) and
* simply return.
*/
// _java_version_set=
if ((env_in = getenv(env_entry)) != null) {
if (*env_in != '\0')
*main_class = jli_stringdup(env_in);
return;
}
/*
* scan through the arguments for options relevant to multiple jre
* support. for reference, the command line syntax is defined as:
*
* synopsis
* java [options] class [argument...]
*
* java [options] -jar file.jar [argument...]
*
* as the scan is performed, make a copy of the argument list with
* the version specification options (new to 1.5) removed, so that
* a version less than 1.5 can be exec'd.
*
* note that due to the syntax of the native windows interface
* createprocess(), processing similar to the following exists in
* the windows platform specific routine execjre (in java_md.c).
* changes here should be reproduced there.
*/
new_argv = jli_memalloc((argc + 1) * sizeof(char*));
new_argv[0] = argv[0];
new_argp = &new_argv[1];
argc--;
argv++;
while ((arg = *argv) != 0 && *arg == '-') {
if (jli_strccmp(arg, "-version:") == 0) {
version = arg + 9;
} else if (jli_strcmp(arg, "-jre-restrict-search") == 0) {
restrict_search = 1;
} else if (jli_strcmp(arg, "-no-jre-restrict-search") == 0) {
restrict_search = 0;
} else {
if (jli_strcmp(arg, "-jar") == 0)
jarflag = 1;
/* deal with "unfortunate" classpath syntax */
if ((jli_strcmp(arg, "-classpath") == 0 || jli_strcmp(arg, "-cp") == 0) &&
(argc >= 2)) {
*new_argp++ = arg;
argc--;
argv++;
arg = *argv;
}
/*
* checking for headless toolkit option in the some way as awt does:
* "true" means true and any other value means false
*/
if (jli_strcmp(arg, "-djava.awt.headless=true") == 0) {
headlessflag = 1;
} else if (jli_strccmp(arg, "-djava.awt.headless=") == 0) {
headlessflag = 0;
} else if (jli_strccmp(arg, "-splash:") == 0) {
splash_file_name = arg+8;
}
*new_argp++ = arg;
}
argc--;
argv++;
}
if (argc <= 0) { /* no operand? possibly legit with -[full]version */
operand = null;
} else {
argc--;
*new_argp++ = operand = *argv++;
}
while (argc-- > 0) /* copy over [argument...] */
*new_argp++ = *argv++;
*new_argp = null;
/*
* if there is a jar file, read the manifest. if the jarfile can't be
* read, the manifest can't be read from the jar file, or the manifest
* is corrupt, issue the appropriate error messages and exit.
*
* even if there isn't a jar file, construct a manifest_info structure
* containing the command line information. it's a convenient way to carry
* this data around.
*/
if (jarflag && operand) {
if ((res = jli_parsemanifest(operand, &info)) != 0) {
if (res == -1)
jli_reporterrormessage(jar_error2, operand);
else
jli_reporterrormessage(jar_error3, operand);
exit(1);
}
/*
* command line splash screen option should have precedence
* over the manifest, so the manifest data is used only if
* splash_file_name has not been initialized above during command
* line parsing
*/
if (!headlessflag && !splash_file_name && info.splashscreen_image_file_name) {
splash_file_name = info.splashscreen_image_file_name;
splash_jar_name = operand;
}
} else {
info.manifest_version = null;
info.main_class = null;
info.jre_version = null;
info.jre_restrict_search = 0;
}
/*
* passing on splash screen info in environment variables
*/
if (splash_file_name && !headlessflag) {
char* splash_file_entry = jli_memalloc(jli_strlen(splash_file_env_entry "=")+jli_strlen(splash_file_name)+1);
jli_strcpy(splash_file_entry, splash_file_env_entry "=");
jli_strcat(splash_file_entry, splash_file_name);
putenv(splash_file_entry);
}
if (splash_jar_name && !headlessflag) {
char* splash_jar_entry = jli_memalloc(jli_strlen(splash_jar_env_entry "=")+jli_strlen(splash_jar_name)+1);
jli_strcpy(splash_jar_entry, splash_jar_env_entry "=");
jli_strcat(splash_jar_entry, splash_jar_name);
putenv(splash_jar_entry);
}
/*
* the jre-version and jre-restrict-search values (if any) from the
* manifest are overwritten by any specified on the command line.
*/
if (version != null)
info.jre_version = version;
if (restrict_search != -1)
info.jre_restrict_search = restrict_search;
/*
* "valid" returns (other than unrecoverable errors) follow. set
* main_class as a side-effect of this routine.
*/
if (info.main_class != null)
*main_class = jli_stringdup(info.main_class);
/*
* if no version selection information is found either on the command
* line or in the manifest, simply return.
*/
if (info.jre_version == null) {
jli_freemanifest();
jli_memfree(new_argv);
return;
}
/*
* check for correct syntax of the version specification (jsr 56).
*/
if (!jli_validversionstring(info.jre_version)) {
jli_reporterrormessage(spc_error1, info.jre_version);
exit(1);
}
/*
* find the appropriate jvm on the system. just to be as forgiving as
* possible, if the standard algorithms don't locate an appropriate
* jre, check to see if the one running will satisfy the requirements.
* this can happen on systems which haven't been set-up for multiple
* jre support.
*/
jre = locatejre(&info);
jli_tracelauncher("jre-version = %s, jre-restrict-search = %s selected = %s\n",
(info.jre_version?info.jre_version:"null"),
(info.jre_restrict_search?"true":"false"), (jre?jre:"null"));
if (jre == null) {
if (jli_acceptablerelease(getfullversion(), info.jre_version)) {
jli_freemanifest();
jli_memfree(new_argv);
return;
} else {
jli_reporterrormessage(cfg_error4, info.jre_version);
exit(1);
}
}
/*
* if i'm not the chosen one, exec the chosen one. returning from
* execjre indicates that i am indeed the chosen one.
*
* the private environment variable _java_version_set is used to
* prevent the chosen one from re-reading the manifest file and
* using the values found within to override the (potential) command
* line flags stripped from argv (because the target may not
* understand them). passing the mainclass value is an optimization
* to avoid locating, expanding and parsing the manifest extra
* times.
*/
if (info.main_class != null) {
if (jli_strlen(info.main_class) <= maxnamelen) {
(void)jli_strcat(env_entry, info.main_class);
} else {
jli_reporterrormessage(cls_error5, maxnamelen);
exit(1);
}
}
(void)putenv(env_entry);
execjre(jre, new_argv);
jli_freemanifest();
jli_memfree(new_argv);
return;
}
// share/windows/bin/java_md.c
/*
* load a jvm from "jvmpath" and initialize the invocation functions.
*/
jboolean
loadjavavm(const char *jvmpath, invocationfunctions *ifn)
{
hinstance handle;
jli_tracelauncher("jvm path is %s\n", jvmpath);
/*
* the microsoft c runtime library needs to be loaded first. a copy is
* assumed to be present in the "jre path" directory. if it is not found
* there (or "jre path" fails to resolve), skip the explicit load and let
* nature take its course, which is likely to be a failure to execute.
*
*/
loadmsvcrt();
// windows 中是通过路径加载dll文件实现
/* load the java vm dll */
if ((handle = loadlibrary(jvmpath)) == 0) {
jli_reporterrormessage(dll_error4, (char *)jvmpath);
return jni_false;
}
/* now get the function addresses */
// 获取虚拟机操作内存地址
ifn->createjavavm =
(void *)getprocaddress(handle, "jni_createjavavm");
ifn->getdefaultjavavminitargs =
(void *)getprocaddress(handle, "jni_getdefaultjavavminitargs");
if (ifn->createjavavm == 0 || ifn->getdefaultjavavminitargs == 0) {
jli_reporterrormessage(jni_error1, (char *)jvmpath);
return jni_false;
}
return jni_true;
}
// 实际就是语法规范
/*
* parses command line arguments. returns jni_false if launcher
* should exit without starting vm, returns jni_true if vm needs
* to be started to process given options. *pret (the launcher
* process return value) is set to 0 for a normal exit.
*/
static jboolean
parsearguments(int *pargc, char ***pargv,
int *pmode, char **pwhat,
int *pret, const char *jrepath)
{
int argc = *pargc;
char **argv = *pargv;
int mode = lm_unknown;
char *arg;
*pret = 0;
while ((arg = *argv) != 0 && *arg == '-') {
argv++; --argc;
if (jli_strcmp(arg, "-classpath") == 0 || jli_strcmp(arg, "-cp") == 0) {
arg_check (argc, arg_error1, arg);
setclasspath(*argv);
mode = lm_class;
argv++; --argc;
} else if (jli_strcmp(arg, "-jar") == 0) {
arg_check (argc, arg_error2, arg);
mode = lm_jar;
} else if (jli_strcmp(arg, "-help") == 0 ||
jli_strcmp(arg, "-h") == 0 ||
jli_strcmp(arg, "-?") == 0) {
printusage = jni_true;
return jni_true;
} else if (jli_strcmp(arg, "-version") == 0) {
printversion = jni_true;
return jni_true;
} else if (jli_strcmp(arg, "-showversion") == 0) {
showversion = jni_true;
} else if (jli_strcmp(arg, "-x") == 0) {
printxusage = jni_true;
return jni_true;
/*
* the following case checks for -xshowsettings or -xshowsetting:subopt.
* in the latter case, any subopt value not recognized will default to "all"
*/
} else if (jli_strcmp(arg, "-xshowsettings") == 0 ||
jli_strccmp(arg, "-xshowsettings:") == 0) {
showsettings = arg;
} else if (jli_strcmp(arg, "-xdiag") == 0) {
addoption("-dsun.java.launcher.diag=true", null);
/*
* the following case provide backward compatibility with old-style
* command line options.
*/
} else if (jli_strcmp(arg, "-fullversion") == 0) {
jli_reportmessage("%s full version "%s"", _launcher_name, getfullversion());
return jni_false;
} else if (jli_strcmp(arg, "-verbosegc") == 0) {
addoption("-verbose:gc", null);
} else if (jli_strcmp(arg, "-t") == 0) {
addoption("-xt", null);
} else if (jli_strcmp(arg, "-tm") == 0) {
addoption("-xtm", null);
} else if (jli_strcmp(arg, "-debug") == 0) {
addoption("-xdebug", null);
} else if (jli_strcmp(arg, "-noclassgc") == 0) {
addoption("-xnoclassgc", null);
} else if (jli_strcmp(arg, "-xfuture") == 0) {
addoption("-xverify:all", null);
} else if (jli_strcmp(arg, "-verify") == 0) {
addoption("-xverify:all", null);
} else if (jli_strcmp(arg, "-verifyremote") == 0) {
addoption("-xverify:remote", null);
} else if (jli_strcmp(arg, "-noverify") == 0) {
addoption("-xverify:none", null);
} else if (jli_strccmp(arg, "-prof") == 0) {
char *p = arg + 5;
char *tmp = jli_memalloc(jli_strlen(arg) + 50);
if (*p) {
sprintf(tmp, "-xrunhprof:cpu=old,file=%s", p + 1);
} else {
sprintf(tmp, "-xrunhprof:cpu=old,file=java.prof");
}
addoption(tmp, null);
} else if (jli_strccmp(arg, "-ss") == 0 ||
jli_strccmp(arg, "-oss") == 0 ||
jli_strccmp(arg, "-ms") == 0 ||
jli_strccmp(arg, "-mx") == 0) {
char *tmp = jli_memalloc(jli_strlen(arg) + 6);
sprintf(tmp, "-x%s", arg + 1); /* skip '-' */
addoption(tmp, null);
} else if (jli_strcmp(arg, "-checksource") == 0 ||
jli_strcmp(arg, "-cs") == 0 ||
jli_strcmp(arg, "-noasyncgc") == 0) {
/* no longer supported */
jli_reporterrormessage(arg_warn, arg);
} else if (jli_strccmp(arg, "-version:") == 0 ||
jli_strcmp(arg, "-no-jre-restrict-search") == 0 ||
jli_strcmp(arg, "-jre-restrict-search") == 0 ||
jli_strccmp(arg, "-splash:") == 0) {
; /* ignore machine independent options already handled */
} else if (processplatformoption(arg)) {
; /* processing of platform dependent options */
} else if (removableoption(arg)) {
; /* do not pass option to vm. */
} else {
addoption(arg, null);
}
}
if (--argc >= 0) {
*pwhat = *argv++;
}
if (*pwhat == null) {
*pret = 1;
} else if (mode == lm_unknown) {
/* default to lm_class if -jar and -cp option are
* not specified */
mode = lm_class;
}
if (argc >= 0) {
*pargc = argc;
*pargv = argv;
}
*pmode = mode;
return jni_true;
}
/*
* inject the -dsun.java.command pseudo property into the args structure
* this pseudo property is used in the hotspot vm to expose the
* java class name and arguments to the main method to the vm. the
* hotspot vm uses this pseudo property to store the java class name
* (or jar file name) and the arguments to the class's main method
* to the instrumentation memory region. the sun.java.command pseudo
* property is not exported by hotspot to the java layer.
*/
void
setjavacommandlineprop(char *what, int argc, char **argv)
{
int i = 0;
size_t len = 0;
char* javacommand = null;
char* dashdstr = "-dsun.java.command=";
if (what == null) {
/* unexpected, one of these should be set. just return without
* setting the property
*/
return;
}
/* determine the amount of memory to allocate assuming
* the individual components will be space separated
*/
len = jli_strlen(what);
for (i = 0; i < argc; i++) {
len += jli_strlen(argv[i]) + 1;
}
/* allocate the memory */
javacommand = (char*) jli_memalloc(len + jli_strlen(dashdstr) + 1);
/* build the -d string */
*javacommand = '\0';
jli_strcat(javacommand, dashdstr);
jli_strcat(javacommand, what);
for (i = 0; i < argc; i++) {
/* the components of the string are space separated. in
* the case of embedded white space, the relationship of
* the white space separated components to their true
* positional arguments will be ambiguous. this issue may
* be addressed in a future release.
*/
jli_strcat(javacommand, " ");
jli_strcat(javacommand, argv[i]);
}
addoption(javacommand, null);
}
// 设置 classpath
static void
setclasspath(const char *s)
{
char *def;
const char *orig = s;
static const char format[] = "-djava.class.path=%s";
/*
* usually we should not get a null pointer, but there are cases where
* we might just get one, in which case we simply ignore it, and let the
* caller deal with it
*/
if (s == null)
return;
s = jli_wildcardexpandclasspath(s);
if (sizeof(format) - 2 + jli_strlen(s) < jli_strlen(s))
// s is corrupted after wildcard expansion
return;
def = jli_memalloc(sizeof(format)
- 2 /* strlen("%s") */
+ jli_strlen(s));
sprintf(def, format, s);
addoption(def, null);
if (s != orig)
jli_memfree((char *) s);
}
// java.c
jvminit(invocationfunctions* ifn, jlong threadstacksize,
int argc, char **argv,
int mode, char *what, int ret)
{
showsplashscreen();
return continueinnewthread(ifn, threadstacksize, argc, argv, mode, what, ret);
}
/*
* displays the splash screen according to the jar file name
* and image file names stored in environment variables
*/
void
showsplashscreen()
{
const char *jar_name = getenv(splash_jar_env_entry);
const char *file_name = getenv(splash_file_env_entry);
int data_size;
void *image_data = null;
float scale_factor = 1;
char *scaled_splash_name = null;
if (file_name == null){
return;
}
scaled_splash_name = dosplashgetscaledimagename(
jar_name, file_name, &scale_factor);
if (jar_name) {
if (scaled_splash_name) {
image_data = jli_jarunpackfile(
jar_name, scaled_splash_name, &data_size);
}
if (!image_data) {
scale_factor = 1;
image_data = jli_jarunpackfile(
jar_name, file_name, &data_size);
}
if (image_data) {
dosplashinit();
dosplashsetscalefactor(scale_factor);
dosplashloadmemory(image_data, data_size);
jli_memfree(image_data);
}
} else {
dosplashinit();
if (scaled_splash_name) {
dosplashsetscalefactor(scale_factor);
dosplashloadfile(scaled_splash_name);
} else {
dosplashloadfile(file_name);
}
}
if (scaled_splash_name) {
jli_memfree(scaled_splash_name);
}
dosplashsetfilejarname(file_name, jar_name);
/*
* done with all command line processing and potential re-execs so
* clean up the environment.
*/
(void)unsetenv(env_entry);
(void)unsetenv(splash_file_env_entry);
(void)unsetenv(splash_jar_env_entry);
jli_memfree(splash_jar_entry);
jli_memfree(splash_file_entry);
}
int
continueinnewthread(invocationfunctions* ifn, jlong threadstacksize,
int argc, char **argv,
int mode, char *what, int ret)
{
/*
* if user doesn't specify stack size, check if vm has a preference.
* note that hotspot no longer supports jni_version_1_1 but it will
* return its default stack size through the init args structure.
*/
if (threadstacksize == 0) {
struct jdk1_1initargs args1_1;
memset((void*)&args1_1, 0, sizeof(args1_1));
args1_1.version = jni_version_1_1;
ifn->getdefaultjavavminitargs(&args1_1); /* ignore return value */
if (args1_1.javastacksize > 0) {
threadstacksize = args1_1.javastacksize;
}
}
{ /* create a new thread to create jvm and invoke main method */
javamainargs args;
int rslt;
args.argc = argc;
args.argv = argv;
args.mode = mode;
args.what = what;
args.ifn = *ifn;
rslt = continueinnewthread0(javamain, threadstacksize, (void*)&args);
/* if the caller has deemed there is an error we
* simply return that, otherwise we return the value of
* the callee
*/
return (ret != 0) ? ret : rslt;
}
}