javatools/tckrunner/starter/src/main.cpp
branchRCL_3
changeset 19 04becd199f91
child 50 023eef975703
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Main program for the TCK Runner process
       
    15 *
       
    16 */
       
    17 
       
    18 #include <memory>
       
    19 #include <unistd.h>
       
    20 /*
       
    21 #ifdef __WINS__
       
    22 #include <e32ldr.h>
       
    23 #endif //__WINS__
       
    24 */
       
    25 #include "logger.h"
       
    26 #include "exceptionbase.h"
       
    27 #include "runtimeexception.h"
       
    28 #include "javacommonutils.h"
       
    29 #include "runtimestarterutils.h"
       
    30 #include "jvmstarter.h"
       
    31 
       
    32 using namespace java::runtime;
       
    33 using namespace java::util;
       
    34 
       
    35 int startJvm(int argc, char *argv[]);
       
    36 const wchar_t* const TCK_RUNNER_MAIN_CLASS = L"com.nokia.mj.impl.tckrunner.TckRunnerMain";
       
    37 
       
    38 int main(int argc, char *argv[])
       
    39 {
       
    40     LOG(ETckRunner, EInfo, "TCK RUNNER main()");
       
    41     /*
       
    42     #ifdef __WINS__
       
    43         RLoader loader;
       
    44         TInt status = loader.Connect();
       
    45         if (status == KErrNone)
       
    46         {
       
    47             loader.CancelLazyDllUnload();
       
    48             loader.Close();
       
    49         }
       
    50     #endif //__WINS__
       
    51     */
       
    52     int result = -1;
       
    53     try
       
    54     {
       
    55         result = startJvm(argc, argv);
       
    56     }
       
    57     catch (RuntimeException& e)
       
    58     {
       
    59         ELOG1(ETckRunner, "TCK RUNNER main() RuntimeException caught: %s ",
       
    60               e.toString().c_str());
       
    61     }
       
    62 
       
    63     catch (ExceptionBase& e)
       
    64     {
       
    65         ELOG1(ETckRunner, "TCK RUNNER main() ExceptionBase caught: %s ",
       
    66               e.toString().c_str());
       
    67     }
       
    68 
       
    69     catch (std::exception& e)
       
    70     {
       
    71         ELOG1(ETckRunner, "TCK RUNNER main() Exception %s caught", e.what());
       
    72     }
       
    73 
       
    74     LOG1(ETckRunner, EInfo, "TCK RUNNER EXIT = %d", result);
       
    75     return result;
       
    76 }
       
    77 
       
    78 int startJvm(int argc, char *argv[])
       
    79 {
       
    80     JELOG2(ETckRunner);
       
    81 
       
    82     // Create instance of RuntimeStarterUtils for thread supervisioning.
       
    83     std::auto_ptr<RuntimeStarterUtils> starterUtils(new RuntimeStarterUtils());
       
    84     starterUtils->startThreadSupervisor();
       
    85 
       
    86     // Create starter for starting the JVM
       
    87     std::auto_ptr<JvmStarter>
       
    88     jvm(JvmStarter::getJvmStarterInstance(JvmStarter::CLDC,
       
    89                                           L"TCK_runner"));
       
    90 
       
    91     // Set the debugging features available provided by the captain.
       
    92     // starterUtils->enableDevelopmentFeatures(*jvm.get());
       
    93     // jvm->enableThreadDumping();
       
    94 
       
    95     jvm->appendSystemProperty(L"-Dcom.nokia.rt.port=tckrunner");
       
    96 
       
    97     jvm->setMainClass(TCK_RUNNER_MAIN_CLASS);
       
    98 
       
    99     for (int i = 1; i < argc; ++i)
       
   100     {
       
   101         jvm->appendApplicationArgument(
       
   102             JavaCommonUtils::utf8ToWstring(argv[i]));
       
   103     }
       
   104 
       
   105     // Start the JVM.
       
   106     return jvm->startJvm();
       
   107 }