diff -r f5050f1da672 -r 04becd199f91 javaruntimes/starter/src/main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javaruntimes/starter/src/main.cpp Tue Apr 27 16:30:29 2010 +0300 @@ -0,0 +1,102 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This main entry point of Java processes. +* +*/ + + +#include +#include +#include + +#include "logger.h" +#include "javaoslayer.h" +#include "exceptionbase.h" +#include "dynamiclibloader.h" + +#include "javaprocessconstants.h" + +using namespace java::util; + +typedef int (*DllmainFunc)(int argc, const char *argv[]); + + +const char* allowedDlls[] = {java::runtime::JAVA_MIDP_STARTER_DLL, + java::runtime::JAVA_INSTALLER_STARTER_DLL, + java::runtime::JAVA_PREINSTALLER_STARTER_DLL, + java::runtime::JAVA_SIZE_HELPER_SERVER_DLL + }; + +const int tableSize = sizeof(allowedDlls) / sizeof(char*); +int main(int argc, const char *argv[]) +{ + JELOG(EJavaRuntime, "Java main()"); + LOG(EJavaRuntime, EInfo, "JAVA MAIN STARTED"); + JavaOsLayer::startUpTrace("Java main", -1, -1); + + int result = -1; + try + { + //Verifying that the dll name has been provided + if (argc > 1) + { + const char* libName = argv[1]; + for (int i = 0; i + lib(new DynamicLibLoader(libName)); // codescanner::nonleavenew + DllmainFunc dllMain = (DllmainFunc)(lib->getFunction("dllMain")); + + argv[1] = argv[0]; + + //Calling the main entry point. + result = dllMain(argc-1, &argv[1]); // codescanner::accessArrayElementWithoutCheck2 + lib->closeLib(); + } + else + { + ELOG(EJavaRuntime, "Not enough arguments for loading the runtime " + "dll."); + } + } + + catch (ExceptionBase& e) + { + ELOG1(EJavaRuntime, "Java main() ExceptionBase catched: %s ", + e.toString().c_str()); + } + + catch (std::exception& e) + { + + ELOG1(EJavaRuntime, "Java main() Exception %s catched", e.what()); + } + + LOG1(EJavaRuntime, EInfo, "JAVA MAIN EXIT = %d", result); + return result; +}