< prev index next >

src/jdk.incubator.jpackage/macosx/native/applauncher/MacLauncher.cpp

Print this page




  35 
  36 void launchJvm() {
  37     // On Mac JLI_Launch() spawns a new thread that actually starts the JVM.
  38     // This new thread simply re-runs launcher's main() function with
  39     // arguments passed into JLI_Launch() call.
  40     // Jvm::launch() calls JLI_Launch() triggering thread spawning.
  41     jvmLauncher->launch();
  42 }
  43 
  44 void initJvmLauncher() {
  45     const tstring launcherPath = SysInfo::getProcessModulePath();
  46 
  47     // Launcher should be in "Contents/MacOS" subdirectory of app image.
  48     const tstring appImageRoot = FileUtils::dirname(FileUtils::dirname(
  49             FileUtils::dirname(launcherPath)));
  50 
  51     // Create JVM launcher and save in global variable.
  52     jvmLauncher = AppLauncher()
  53         .setImageRoot(appImageRoot)
  54         .addJvmLibName(_T("Contents/Home/lib/libjli.dylib"))


  55         .setAppDir(FileUtils::mkpath() << appImageRoot << _T("Contents/app"))
  56         .setDefaultRuntimePath(FileUtils::mkpath() << appImageRoot
  57                 << _T("Contents/runtime"))
  58         .createJvmLauncher();
  59 
  60     // Kick start JVM launching. The function wouldn't return!
  61     launchJvm();
  62 }
  63 
  64 } // namespace
  65 
  66 
  67 int main(int argc, char *argv[]) {
  68     setlocale(LC_ALL, "en_US.utf8");
  69     if (jvmLauncher) {
  70         // This is the call from the thread spawned by JVM.
  71         // Skip initialization phase as we have done this already in the first
  72         // call of main().
  73         // Besides we should ignore main() arguments because these are the
  74         // arguments passed into JLI_Launch() call and not the arguments with


  35 
  36 void launchJvm() {
  37     // On Mac JLI_Launch() spawns a new thread that actually starts the JVM.
  38     // This new thread simply re-runs launcher's main() function with
  39     // arguments passed into JLI_Launch() call.
  40     // Jvm::launch() calls JLI_Launch() triggering thread spawning.
  41     jvmLauncher->launch();
  42 }
  43 
  44 void initJvmLauncher() {
  45     const tstring launcherPath = SysInfo::getProcessModulePath();
  46 
  47     // Launcher should be in "Contents/MacOS" subdirectory of app image.
  48     const tstring appImageRoot = FileUtils::dirname(FileUtils::dirname(
  49             FileUtils::dirname(launcherPath)));
  50 
  51     // Create JVM launcher and save in global variable.
  52     jvmLauncher = AppLauncher()
  53         .setImageRoot(appImageRoot)
  54         .addJvmLibName(_T("Contents/Home/lib/libjli.dylib"))
  55         // add backup - older version such as JDK11 have it in jli sub-dir
  56         .addJvmLibName(_T("Contents/Home/lib/jli/libjli.dylib"))
  57         .setAppDir(FileUtils::mkpath() << appImageRoot << _T("Contents/app"))
  58         .setDefaultRuntimePath(FileUtils::mkpath() << appImageRoot
  59                 << _T("Contents/runtime"))
  60         .createJvmLauncher();
  61 
  62     // Kick start JVM launching. The function wouldn't return!
  63     launchJvm();
  64 }
  65 
  66 } // namespace
  67 
  68 
  69 int main(int argc, char *argv[]) {
  70     setlocale(LC_ALL, "en_US.utf8");
  71     if (jvmLauncher) {
  72         // This is the call from the thread spawned by JVM.
  73         // Skip initialization phase as we have done this already in the first
  74         // call of main().
  75         // Besides we should ignore main() arguments because these are the
  76         // arguments passed into JLI_Launch() call and not the arguments with
< prev index next >