Skip to main content

How should I exit the java application??

1 reply [Last post]
jacobsq
Offline
Joined: 2007-11-21

I use the Invocation API to call the CVM in the native application.
When the java application's key event listener that I implement call the "System.exit(0)" to exit java application,it will cause the native application process to exit.But I don't want the native application process to be exited when the java application exit.

I find the "Sytem.exit(0)" will call the native function as follows:

CVMBool
CVMsafeExit(CVMExecEnv *ee, CVMInt32 status)
{
/*
* If "safeExit" has been enabled, then treat a "safe" System.exit()
* by the main thread the same as returning from the main method.
*/
{
/*
* Safe exit is only supported for the main thread.
*/
if (ee == &CVMglobals.mainEE) {
/*
* %comment d007
*/

if (CVMglobals.safeExitHook != NULL) {
void (*fn)(int) = (void (*)(int))CVMglobals.safeExitHook;
JavaVM *jvm = &CVMglobals.javaVM.vector;

(*jvm)->DestroyJavaVM(jvm);

(*fn)(status);
/* safeExit() shouldn't return */
CVMassert(CVM_FALSE);
return CVM_TRUE;
}
}
}
return CVM_FALSE;
}

In fact, "ee" is not equal "&CVMglobals.mainEE",so it return CVM_FALSE,then Shutdown.exit() will be called.Then the following function will be called:

void
CVMhalt(CVMInt32 status)
{
exit(status);
}

The C library function exit() will cause the process to be terminated.

How could I to terminate the CVM without exit the process??

Message was edited by: jacobsq

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
xyzzy
Offline
Joined: 2006-08-30

If you really need to use "safeExit", then try calling exit() from the main thread.