title: Speed up application start by adding own application classes to classes.jsa
body: <p>To speed up the startup time of the JVM, the Sun developers decided it is a good idea to precompile the standard runtime classes for a platform during installation of the JVM. These precompiled classes can be found e.g. at:</p>
  
  <p>$JAVA_HOME\jre\bin\client\classes.jsa</p>
  
  <p>My company currently develops a Java standalone application which brings its own JRE, so it would be a fantastic option to speed up our application start time by adding our own application classes to this jsa file, too.</p>
  
  <p>I don't believe the JSA file was created by magic, so: How is it created? And how can I trick the JVM into incorporating my own classes?</p>
  
  <p><strong>EDIT</strong>: I already found out the following:</p>
  
  <p>The classes.jsa is created by the command</p>
  
  <pre><code>java -Xshare:dump
  </code></pre>
  
  <p>The list of classes to incorporate in the dump can be found in <code>$JAVA_HOME/jre/lib/classlist</code>.</p>
  
  <p>I even managed to add my own classes here (and to add them into the rt.jar for java to find them), and to generate my own checksum below the classlist file.</p>
  
  <p>The final problem is: Only classes in the packages java, com.sun, and org.w3c seem to be recognized, if I leave the same classes in their original packages, they won't be loaded. I searched the whole OpenJDK source for pointer about this, but it seems to have something to do with protection domains. If someone is interested enough in this topic and knowledgeable enough, please add some pointers for me to investigaete further.</p>