What is the launcher?

One surprisingly tricky piece of the Java platform is the launcher, the set of C code that uses the JNI invocation API to get the JVM started and begin running the main class. While conceptually simple, the launcher is complicated by straddling the boundary between the host system and the JVM, often wrestling with native platform issues like thread configuration that need to be managed before starting the JVM. The launcher's tasks include selecting which VM to run (client, server, etc.) and running in the requested data model, 32-bit or 64-bit.

In the jdk Mercurial repository, the source code of the launcher is primarily composed of:

  • src/share/bin/java.{c, h}

  • Other files in the src/share/bin directory, including the Java launcher infrastructure utilties, jli_util.{c, h}.

  • src/solaris/bin/java_md.{c, h} (covers both Solaris and Linux using #defines)

  • src/windows/bin/java_md.{c, h} (covers various and sundry versions of MS Windows)

The launcher code is used to build the executables in the JDK bin directory; every invocation of java and commands like javac first executes through the launcher. Consequently mistakes in the launcher can cause severe build problems and cross-platform testing is especially important. On doing numerical work, Prof. Kahan has advised "The best you can hope for is that if you do your job very well, no one will notice" and working on the launcher has a similar flavor; you don't want your work to get noticed!

From JDK 1.4.2 through JDK 6 I was the lead launcher maintainer, amongst other responsibilities. When I first took over launcher maintenance, I introduced regression tests and performed several rounds of refactoring. Over time, my launcher activities shifting to reviewing and advising others on their launcher-related projects including:

  • In JDK 5, multiple JRE support (java -version:foo to invoke Java version foo from some other version) and ergonomics to provide better out-of-the-box tuned performance.

  • In JDK 6, the splashscreen functionality and classpath wildcards.

Since JDK 6 first shipped, I've happily handed over the reigns of primary launcher care and feeding to Kumar, while still being involved in code reviews and writing the occasional blog entry. Kumar moved common functinality of the launcher into a shared library to make the source more robust and speed up the builds.

In the near future I'll be writing about a long-standing launcher flaw concerning the Unix exec system call and LD_LIBRARY_PATH Kumar has fixed in JDK 7.

Comments:

Hello,

I was wondering why the Windows launcher has never been aware of the Windows Service API.

It would have simplify a lot the deployment of Java servers on Windows.

It there a specific reason?

Thanks for your insights,
Serge

Posted by Serge on January 25, 2010 at 02:54 AM PST #

I had fun and games when implementing my own launcher as part of my microkernel project.

There's not much out there about starting a JVM with JNI probably as not many people do it. I found both the source to the standard launcher and strangely Apple's own documentation to be the best resources.

It's going to be interesting to see what Kumar has fixed, didn't know of that Unix exec flaw.

Posted by Peter Mount on January 25, 2010 at 05:32 PM PST #

Post a Comment:
Comments are closed for this entry.
About

Darcy-Oracle

Search

Archives
« September 2015
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today
News

No bookmarks in folder

Blogroll