javaruntimes/standalone/src/javastarterimpl.cpp
branchRCL_3
changeset 19 04becd199f91
child 23 98ccebc37403
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  This class provides container for message.
       
    15 *
       
    16 */
       
    17 
       
    18 #include <string>
       
    19 #include <algorithm>
       
    20 #include <fstream>
       
    21 #include <list>
       
    22 
       
    23 #include "javacoreui.h"
       
    24 #include "javacoreuiparams.h"
       
    25 #include "runtimestarterutils.h"
       
    26 
       
    27 #include "dynamiclibloader.h"
       
    28 #include "javacommonutils.h"
       
    29 #include "javaoslayer.h"
       
    30 #include "logger.h"
       
    31 
       
    32 #ifdef __SYMBIAN32__
       
    33 #include "javasymbianoslayer.h"
       
    34 #else // __SYMBIAN32__
       
    35 #include <signal.h>
       
    36 
       
    37 #endif // __SYMBIAN32__
       
    38 
       
    39 #include "runtimeexception.h"
       
    40 
       
    41 #include "javastarter.h"
       
    42 #include "javastarterimpl.h"
       
    43 
       
    44 
       
    45 using namespace java::runtime;
       
    46 using namespace java::util;
       
    47 using namespace java::ui;
       
    48 using namespace java;
       
    49 
       
    50 const wchar_t* const NATIVE_RUNTIME_MAIN_CLASS  = L"com.nokia.mj.impl.rt.midp.Main";
       
    51 const wchar_t* const MAIN_RUNTIME_MAIN_CLASS    = L"com.nokia.mj.impl.rt.main.Main";
       
    52 
       
    53 const wchar_t* const ARG_CONF                   = L"-conf=";
       
    54 const wchar_t* const CONF_CDC                   = L"cdc";
       
    55 const wchar_t* const CONF_FOUNDATION            = L"foun";
       
    56 const wchar_t* const CONF_CLDC                  = L"cldc";
       
    57 
       
    58 const wchar_t* const ARG_PROFILE                = L"-profile=";
       
    59 const wchar_t* const PROFILE_MAIN               = L"main";
       
    60 const wchar_t* const PROFILE_STANDALONE_MIDLET  = L"standalonemidlet";
       
    61 const wchar_t* const ARG_STANDALONE             = L"-standalone";
       
    62 
       
    63 const wchar_t* const ARG_ORIENTATION            = L"-Dcom.nokia.startup.arg.orientation=";
       
    64 const wchar_t* const ORIENTATION_PORTRAIT       = L"portrait";
       
    65 const wchar_t* const ORIENTATION_LANDSCAPE      = L"landscape";
       
    66 
       
    67 const wchar_t* const ARG_START_SCREEN           = L"-Dcom.nokia.startup.arg.startscreen=";
       
    68 const wchar_t* const START_SCREEN_DEFAULT       = L"default";
       
    69 const wchar_t* const START_SCREEN_NO            = L"no";
       
    70 
       
    71 const wchar_t* const ARG_JAR                    = L"-jar";
       
    72 const wchar_t* const ARG_JAD                    = L"-jad";
       
    73 const wchar_t* const ARG_CP                     = L"-cp";
       
    74 const wchar_t* const ARG_CLASSPATH              = L"-classpath";
       
    75 const wchar_t* const ARG_MAIN                   = L"-main";
       
    76 const wchar_t* const ARG_UID                    = L"-uid";
       
    77 const wchar_t* const ARG_ROOT_PATH              = L"-rootpath";
       
    78 const wchar_t* const ARG_HANDLE                 = L"-handle";
       
    79 const wchar_t* const ARG_END                    = L"-interalArgEnd";
       
    80 const wchar_t* const ARG_EMPTY                  = L"";
       
    81 
       
    82 
       
    83 
       
    84 OS_EXPORT int java::start(int argc, const char** argv)
       
    85 {
       
    86     JELOG2(EJavaRuntime);
       
    87     LOG(EJavaRuntime, EInfo, "java::start(1)");
       
    88     int result = -1;
       
    89     try
       
    90     {
       
    91         int i = 0;
       
    92         if (argc > 0 && argv[0][0] != '-')
       
    93         {
       
    94             // Check if the first argument is the name of the exe. If so, skip it.
       
    95             std::string firstArg(argv[0]);
       
    96             std::transform(firstArg.begin(), firstArg.end(),
       
    97                            firstArg.begin(), tolower);
       
    98             size_t pos = firstArg.rfind(".exe");
       
    99             bool endsWithExe = (pos != std::string::npos) &&
       
   100                                (pos == (firstArg.length() - 4));
       
   101             if (endsWithExe)
       
   102             {
       
   103                 // It did end with .exe so ignoring the first argument.
       
   104                 i = 1;
       
   105             }
       
   106 
       
   107         }
       
   108 
       
   109         std::list<std::wstring> args;
       
   110         for (; i < argc; ++i)
       
   111         {
       
   112             args.push_back(JavaCommonUtils::utf8ToWstring(argv[i]));
       
   113         }
       
   114 
       
   115         std::auto_ptr<JavaStarterImpl> javaStarter(new JavaStarterImpl(args));
       
   116         result = javaStarter->start();
       
   117     }
       
   118     catch (RuntimeException& e)
       
   119     {
       
   120         ELOG1(EJavaRuntime, "java::start RuntimeException catched: %s ",
       
   121               e.toString().c_str());
       
   122     }
       
   123 
       
   124     catch (ExceptionBase& e)
       
   125     {
       
   126         ELOG1(EJavaRuntime, "java::start ExceptionBase catched: %s ",
       
   127               e.toString().c_str());
       
   128     }
       
   129 
       
   130     catch (std::exception& e)
       
   131     {
       
   132         ELOG1(EJavaRuntime, "java::start Exception %s catched", e.what());
       
   133     }
       
   134 
       
   135     LOG1(EJavaRuntime, EInfo, "java::start with status %d", result);
       
   136     return result;
       
   137 }
       
   138 
       
   139 OS_EXPORT int java::start(const char* fileName)
       
   140 {
       
   141     JELOG2(EJavaRuntime);
       
   142     LOG(EJavaRuntime, EInfo, "java::start(2)");
       
   143     int result = -1;
       
   144     try
       
   145     {
       
   146         std::list<std::wstring> args;
       
   147         JavaStarterImpl::getArgsFromFile(fileName, args);
       
   148         std::auto_ptr<JavaStarterImpl> javaStarter(new JavaStarterImpl(args));
       
   149         result = javaStarter->start();
       
   150     }
       
   151     catch (RuntimeException& e)
       
   152     {
       
   153         ELOG1(EJavaRuntime, "java::start(2) RuntimeException catched: %s ",
       
   154               e.toString().c_str());
       
   155     }
       
   156 
       
   157     catch (ExceptionBase& e)
       
   158     {
       
   159         ELOG1(EJavaRuntime, "java::start(2) ExceptionBase catched: %s ",
       
   160               e.toString().c_str());
       
   161     }
       
   162 
       
   163     catch (std::exception& e)
       
   164     {
       
   165         ELOG1(EJavaRuntime, "java::start(2) Exception %s catched", e.what());
       
   166     }
       
   167 
       
   168     LOG1(EJavaRuntime, EInfo, "java::start(2) exited with status %d", result);
       
   169 
       
   170     return result;
       
   171 }
       
   172 
       
   173 JavaStarterImpl::JavaStarterImpl(const std::list<std::wstring>& args):
       
   174         mJvmStarter(0),
       
   175         mRuntimeStarterUtils(0),
       
   176         mOriginalArgs(args),
       
   177         mShudownOk(false),
       
   178         mIsMainApp(true),
       
   179         mConfiguration(JvmStarter::UNDEFINED)
       
   180 
       
   181 {
       
   182     JELOG2(EJavaRuntime);
       
   183     mRuntimeStarterUtils = new RuntimeStarterUtils();
       
   184 }
       
   185 
       
   186 JavaStarterImpl::~JavaStarterImpl()
       
   187 {
       
   188     JELOG2(EJavaRuntime);
       
   189     delete mJvmStarter;
       
   190     mJvmStarter = 0;
       
   191 
       
   192     delete mRuntimeStarterUtils;
       
   193     mRuntimeStarterUtils = 0;
       
   194 }
       
   195 
       
   196 int JavaStarterImpl::start()
       
   197 {
       
   198     JELOG2(EJavaRuntime);
       
   199 
       
   200     // Start the thread supervisor for noticing crashes.
       
   201     mRuntimeStarterUtils = new RuntimeStarterUtils(); // codescanner::nonleavenew
       
   202     mRuntimeStarterUtils->startThreadSupervisor();
       
   203 
       
   204     // Parse args that starts with '-'.
       
   205     parseFlags();
       
   206 
       
   207     // Create JVM starter for selected runtime.
       
   208     createJvmStarter();
       
   209 
       
   210     // Solves the UID of the application and sets the root path.
       
   211     setUidAndRootPath();
       
   212 
       
   213     // Create the start screen and start it if needed.
       
   214     std::auto_ptr<java::util::DynamicLibLoader> coreUiLoader;
       
   215     CoreUi& coreUi = CoreUi::getUiInstance(coreUiLoader);
       
   216     if (mUiParams.getScreenMode() != NO_START_SCREEN)
       
   217     {
       
   218         LOG(EJavaRuntime, EInfo, "StartUI");
       
   219         coreUi.start(mAppUid, &mUiParams);
       
   220         LOG(EJavaRuntime, EInfo, "StartUI ok");
       
   221     }
       
   222 
       
   223     // Sets the -jar, -jad, -cp (or -classpath) args if were provided.
       
   224     // Also a main class is set if needed.
       
   225     handleJadJarCpArgs();
       
   226 
       
   227     // Adds a handle to this object in order to enable the callbacks
       
   228     // from runtime.
       
   229     addHandle();
       
   230 
       
   231     // Add the application arguments if provided.
       
   232     addApplicationArgs();
       
   233 
       
   234 #ifndef RD_JAVA_UI_QT
       
   235     // In Java 2.x we are using legacy UI.
       
   236     mJvmStarter->appendSystemProperty(L"-Dcom.nokia.legacy.support=symbian");
       
   237 #endif //RD_JAVA_HYBRID
       
   238 
       
   239     int result = mJvmStarter->startJvm();
       
   240     CoreUi::releaseUi(coreUiLoader);
       
   241     if (mMonitor.get())
       
   242     {
       
   243         mShudownOk = true;
       
   244         LOG(EJavaRuntime, EInfo, "Notifying.");
       
   245         mMonitor->notify();
       
   246     }
       
   247 
       
   248     LOG1(EJavaRuntime, EInfo, "Native exited with status %d", result);
       
   249 
       
   250     return result;
       
   251 
       
   252 }
       
   253 
       
   254 void JavaStarterImpl::parseFlags()
       
   255 {
       
   256     JELOG2(EJavaRuntime);
       
   257     for (mOriginalArgsIter = mOriginalArgs.begin();
       
   258             (mOriginalArgsIter != mOriginalArgs.end() && mOriginalArgsIter->at(0) == '-');
       
   259             ++mOriginalArgsIter)
       
   260     {
       
   261         LOG1(EJavaRuntime, EInfo, "Handling flags %S",  mOriginalArgsIter->c_str());
       
   262         if (*mOriginalArgsIter == ARG_JAR)
       
   263         {
       
   264             storeNextArgument(mJarFile);
       
   265             LOG1(EJavaRuntime, EInfo, "Jar file is %S",  mJarFile.c_str());
       
   266         }
       
   267         else if (*mOriginalArgsIter == ARG_JAD)
       
   268         {
       
   269             storeNextArgument(mJadFile);
       
   270             LOG1(EJavaRuntime, EInfo, "Jad file is %S",  mJadFile.c_str());
       
   271         }
       
   272         else if (*mOriginalArgsIter == ARG_CP || *mOriginalArgsIter == ARG_CLASSPATH)
       
   273         {
       
   274             storeNextArgument(mClassPath);
       
   275             LOG1(EJavaRuntime, EInfo, "Classpath is %S",  mClassPath.c_str());
       
   276         }
       
   277         else if (mOriginalArgsIter->find(ARG_CONF) == 0)
       
   278         {
       
   279             setConfigration(getArgValue(*mOriginalArgsIter));
       
   280         }
       
   281         else if (mOriginalArgsIter->find(ARG_PROFILE) == 0)
       
   282         {
       
   283             setProfile(getArgValue(*mOriginalArgsIter));
       
   284         }
       
   285         else if (mOriginalArgsIter->find(ARG_ORIENTATION) == 0)
       
   286         {
       
   287             setOrientation(getArgValue(*mOriginalArgsIter));
       
   288         }
       
   289         else if (mOriginalArgsIter->find(ARG_START_SCREEN) == 0)
       
   290         {
       
   291             setStartScreen(getArgValue(*mOriginalArgsIter));
       
   292         }
       
   293         else
       
   294         {
       
   295             mFlagArgs.push_back(*mOriginalArgsIter);
       
   296         }
       
   297     }
       
   298 }
       
   299 
       
   300 void JavaStarterImpl::setConfigration(const std::wstring& conf)
       
   301 {
       
   302     JELOG2(EJavaRuntime);
       
   303 
       
   304     if (conf == CONF_CLDC)
       
   305     {
       
   306         LOG(EJavaRuntime, EInfo, "Setting conf to CLDC");
       
   307         mConfiguration = JvmStarter::CLDC;
       
   308     }
       
   309     else if (conf == CONF_CDC)
       
   310     {
       
   311         LOG(EJavaRuntime, EInfo, "Setting conf to CDC");
       
   312         mConfiguration = JvmStarter::CDC;
       
   313     }
       
   314     else if (conf == CONF_FOUNDATION)
       
   315     {
       
   316         LOG(EJavaRuntime, EInfo, "Setting conf to FOUNDATION");
       
   317         mConfiguration = JvmStarter::FOUNDATION;
       
   318     }
       
   319     else
       
   320     {
       
   321         ELOG1(EJavaRuntime, "Unknown conf %S", conf.c_str());
       
   322     }
       
   323 }
       
   324 
       
   325 void JavaStarterImpl::setProfile(const std::wstring& profile)
       
   326 {
       
   327     JELOG2(EJavaRuntime);
       
   328 
       
   329     if (profile == PROFILE_STANDALONE_MIDLET)
       
   330     {
       
   331         LOG(EJavaRuntime, EInfo, "Setting profile to be standalone MIDlet");
       
   332         mIsMainApp = false;
       
   333     }
       
   334     else if (profile == PROFILE_MAIN)
       
   335     {
       
   336         LOG(EJavaRuntime, EInfo, "Setting profile to be main");
       
   337         mIsMainApp = true;
       
   338     }
       
   339     else
       
   340     {
       
   341         ELOG1(EJavaRuntime, "Unknown profile %S", profile.c_str());
       
   342     }
       
   343 }
       
   344 
       
   345 void JavaStarterImpl::setOrientation(const std::wstring& orientation)
       
   346 {
       
   347     JELOG2(EJavaRuntime);
       
   348 
       
   349     if (orientation == ORIENTATION_PORTRAIT)
       
   350     {
       
   351         LOG(EJavaRuntime, EInfo, "Setting orientation to portrait");
       
   352         mUiParams.setOrientation(PORTRAIT);
       
   353     }
       
   354     else if (orientation == ORIENTATION_LANDSCAPE)
       
   355     {
       
   356         LOG(EJavaRuntime, EInfo, "Setting orientation to landscape");
       
   357         mUiParams.setOrientation(LANDSCAPE);
       
   358     }
       
   359     else
       
   360     {
       
   361         ELOG1(EJavaRuntime, "Unknown orientation %S", orientation.c_str());
       
   362     }
       
   363 }
       
   364 
       
   365 void JavaStarterImpl::setStartScreen(const std::wstring& startscreen)
       
   366 {
       
   367     JELOG2(EJavaRuntime);
       
   368 
       
   369     if (startscreen == START_SCREEN_DEFAULT)
       
   370     {
       
   371         LOG(EJavaRuntime, EInfo, "Setting default start screen");
       
   372         mUiParams.setScreenMode(DEFAULT_START_SCREEN);
       
   373     }
       
   374     else if (startscreen == START_SCREEN_NO)
       
   375     {
       
   376         LOG(EJavaRuntime, EInfo, "Setting default start screen");
       
   377         mUiParams.setScreenMode(NO_START_SCREEN);
       
   378     }
       
   379     else
       
   380     {
       
   381         mUiParams.setScreenMode(USER_DEFINED_SCREEN);
       
   382         mUiParams.setImagePath(startscreen);
       
   383         LOG1(EJavaRuntime, EInfo, "Setting start screen from file %S", startscreen.c_str());
       
   384     }
       
   385 }
       
   386 
       
   387 void JavaStarterImpl::createJvmStarter()
       
   388 {
       
   389     JELOG2(EJavaRuntime);
       
   390     if (mIsMainApp)
       
   391     {
       
   392         // We are starting main app.
       
   393         if (mConfiguration == JvmStarter::UNDEFINED)
       
   394         {
       
   395             // If the user has not explicitely set the conf, CDC is default.
       
   396             mConfiguration = JvmStarter::CDC;
       
   397         }
       
   398         mJvmStarter = JvmStarter::getJvmStarterInstance(mConfiguration,
       
   399                       PROFILE_MAIN);
       
   400         mJvmStarter->appendSystemProperty(L"-Dcom.nokia.rt.port=main");
       
   401         mJvmStarter->setMainClass(MAIN_RUNTIME_MAIN_CLASS);
       
   402     }
       
   403     else
       
   404     {
       
   405         // We are starting standalone MIDlet.
       
   406         if (mConfiguration == JvmStarter::UNDEFINED)
       
   407         {
       
   408             // If the user has not explicitely set the conf, CLDC is default.
       
   409             mConfiguration = JvmStarter::CLDC;
       
   410         }
       
   411         mJvmStarter = JvmStarter::getJvmStarterInstance(mConfiguration,
       
   412                       PROFILE_STANDALONE_MIDLET);
       
   413         mJvmStarter->appendSystemProperty(L"-Dcom.nokia.rt.port=midp");
       
   414         mJvmStarter->setMainClass(NATIVE_RUNTIME_MAIN_CLASS);
       
   415         mJvmStarter->appendApplicationArgument(ARG_STANDALONE);
       
   416         mJvmStarter->appendApplicationArgument(ARG_EMPTY);
       
   417     }
       
   418 }
       
   419 
       
   420 void JavaStarterImpl::handleJadJarCpArgs()
       
   421 {
       
   422     JELOG2(EJavaRuntime);
       
   423     if (mJarFile.length() > 0)
       
   424     {
       
   425         // The -jar argument was provided. Appending it to classpath and
       
   426         // passing that as an argument to the runtime.
       
   427         mJvmStarter->appendClassPath(mJarFile);
       
   428         mJvmStarter->appendApplicationArgument(ARG_JAR);
       
   429         mJvmStarter->appendApplicationArgument(mJarFile);
       
   430     }
       
   431     else
       
   432     {
       
   433         // The -jar argument was not provided. We assume that the next argument
       
   434         // is the main class of the application in case of main app.
       
   435         // passing that as an argument to the runtime.
       
   436         if (mIsMainApp && mOriginalArgsIter != mOriginalArgs.end())
       
   437         {
       
   438             mJvmStarter->appendApplicationArgument(ARG_MAIN);
       
   439             mJvmStarter->appendApplicationArgument(*mOriginalArgsIter);
       
   440             ++mOriginalArgsIter;
       
   441         }
       
   442     }
       
   443 
       
   444     if (mJadFile.length() > 0)
       
   445     {
       
   446         mJvmStarter->appendApplicationArgument(ARG_JAD);
       
   447         mJvmStarter->appendApplicationArgument(mJadFile);
       
   448     }
       
   449 
       
   450     if (mClassPath.length() > 0)
       
   451     {
       
   452         mJvmStarter->appendClassPath(mClassPath);
       
   453     }
       
   454 }
       
   455 
       
   456 
       
   457 void JavaStarterImpl::setUidAndRootPath()
       
   458 {
       
   459     JELOG2(EJavaRuntime);
       
   460 #ifdef __SYMBIAN32__
       
   461     TUidToUid(RProcess().Type()[2], mAppUid);
       
   462     LOG1(EJavaRuntime, EInfo, "PROCESS UID %S",  mAppUid.toString().c_str());
       
   463 
       
   464 //    TUid tuid = uidType[1];
       
   465     TUid tuid(TUid::Uid(0x10005902));
       
   466 //    TUidToUid(tuid, mAppUid);
       
   467 //    LOG1(EJavaRuntime, EInfo, "TEMP UID %S",  mAppUid.toString().c_str());
       
   468 #else // __SYMBIAN32__
       
   469 //    mAppUid = Uid(L"java_standalone");
       
   470 
       
   471 #endif // __SYMBIAN32__
       
   472 
       
   473     mJvmStarter->appendApplicationArgument(ARG_UID);
       
   474     mJvmStarter->appendApplicationArgument(mAppUid.toString());
       
   475 
       
   476     std::wstring rooPath;
       
   477 #ifdef __SYMBIAN32__
       
   478     Uid uid;
       
   479     TUidToUid(RProcess().SecureId(), uid);
       
   480     rooPath += L"c:\\private\\";
       
   481     rooPath += uid.toString().substr(1,8);
       
   482     rooPath += L"\\";
       
   483 #else // __SYMBIAN32__
       
   484     rooPath += L"./";
       
   485 #endif // __SYMBIAN32__
       
   486     mJvmStarter->appendApplicationArgument(ARG_ROOT_PATH);
       
   487     mJvmStarter->appendApplicationArgument(rooPath);
       
   488 }
       
   489 
       
   490 void JavaStarterImpl::addHandle()
       
   491 {
       
   492     JELOG2(EJavaRuntime);
       
   493     // Provide access to this object by Java peer via delivering a pointer
       
   494     // to this object.
       
   495     mJvmStarter->appendApplicationArgument(ARG_HANDLE);
       
   496     MidpStarterInternalSupport* internalSupport = this;
       
   497     int handle = reinterpret_cast<int>(internalSupport);
       
   498     mJvmStarter->appendApplicationArgument(JavaCommonUtils::intToWstring(handle));
       
   499 }
       
   500 
       
   501 void JavaStarterImpl::addApplicationArgs()
       
   502 {
       
   503     JELOG2(EJavaRuntime);
       
   504     // Adding end mark of the runtime arguments.
       
   505     mJvmStarter->appendApplicationArgument(ARG_END);
       
   506 
       
   507     // What is left in the argument list is considered to be application arguments.
       
   508 
       
   509     for (; mOriginalArgsIter != mOriginalArgs.end(); ++mOriginalArgsIter)
       
   510     {
       
   511         LOG1(EJavaRuntime, EInfo, "Adding APP args %S", mOriginalArgsIter->c_str());
       
   512         mJvmStarter->appendApplicationArgument(*mOriginalArgsIter);
       
   513     }
       
   514 }
       
   515 
       
   516 void JavaStarterImpl::storeNextArgument(std::wstring& arg)
       
   517 {
       
   518     ++mOriginalArgsIter;
       
   519     if (mOriginalArgsIter != mOriginalArgs.end())
       
   520     {
       
   521         arg = *mOriginalArgsIter;
       
   522     }
       
   523 }
       
   524 
       
   525 std::wstring JavaStarterImpl::getArgValue(const std::wstring& arg)
       
   526 {
       
   527     JELOG2(EJavaRuntime);
       
   528     return arg.substr(arg.find(L"=") + 1);
       
   529 }
       
   530 
       
   531 
       
   532 void JavaStarterImpl::getArgsFromFile(const char* file, std::list<std::wstring>& args)
       
   533 {
       
   534     std::ifstream argsFile;
       
   535     try
       
   536     {
       
   537         argsFile.open(file, std::ifstream::in);
       
   538 
       
   539         std::string line;
       
   540 
       
   541         while (std::getline(argsFile, line))
       
   542         {
       
   543             size_t endln = line.find_last_not_of("\r\n");
       
   544             if (endln != std::string::npos)
       
   545             {
       
   546                 line.erase(endln+1);
       
   547             }
       
   548             args.push_back(JavaCommonUtils::utf8ToWstring(line.c_str()));
       
   549         }
       
   550     }
       
   551     catch (std::exception& e)
       
   552     {
       
   553         LOG2(EJavaRuntime, EInfo, "Not able to read from file %s. Error %s",
       
   554              file, e.what());
       
   555     }
       
   556     argsFile.close();
       
   557 }
       
   558 
       
   559 void* JavaStarterImpl::ensureExit(void* ptr)
       
   560 {
       
   561     JELOG2(EUtils);
       
   562 #ifdef __SYMBIAN32__
       
   563     RThread().SetPriority(EPriorityMore);
       
   564 #endif // __SYMBIAN32__
       
   565     JavaStarterImpl* starter = reinterpret_cast<JavaStarterImpl*>(ptr);
       
   566     LOG(EJavaRuntime, EInfo, "Starting to wait for the shutdown.");
       
   567     starter->mMonitor->wait(1200); // 1,2 seconds
       
   568     LOG(EJavaRuntime, EInfo, "woke up from monitor.");
       
   569     if (!starter->mShudownOk)
       
   570     {
       
   571         LOG(EJavaRuntime, EInfo, "Killing process.");
       
   572 #ifdef __SYMBIAN32__
       
   573         RProcess().Kill(0);
       
   574 #else
       
   575         kill(getpid(), SIGTERM);
       
   576 #endif // __SYMBIAN32__
       
   577     }
       
   578     LOG(EJavaRuntime, EInfo, "Not killing process.");
       
   579     return 0;
       
   580 }
       
   581 
       
   582 void JavaStarterImpl::closeRuntimeInd()
       
   583 {
       
   584     JELOG2(EJavaRuntime);
       
   585     LOG(EJavaRuntime, EInfo, "Starter got close indication from JVM");
       
   586     pthread_t tid;
       
   587     mMonitor.reset(Monitor::createMonitor());
       
   588     pthread_create(&tid, 0, ensureExit, this);
       
   589 }
       
   590 
       
   591 void JavaStarterImpl::setUids(const java::util::Uid& /*uid*/,
       
   592                               const java::util::Uid& /*suiteUid*/)
       
   593 {
       
   594     JELOG2(EJavaRuntime);
       
   595     // Not applicable in this case.
       
   596 }