Paul Krill
Editor at Large

Ahead-of-time class loading proposal would speed Java startups

OpenJDK proposal would boost Java application startup speed by having classes made available in a loaded and linked state when the JVM starts.

speed fast race car shutterstock 1168856884
Credit: Jamesboy Nuchaikong / Shutterstock

Java application startup times would be improved by making classes of an application instantly available, under a proposal being floated in the OpenJDK community.

The JEP (JDK Enhancement Proposal) at openjdk.org, titled โ€œAhead-of-Time Class Loading & Linking,โ€ would boost application startup speed by having these classes made available in a loaded and linked state when the HotSpot JVM starts. This would be achieved by monitoring the application during one run and storing loaded and linked forms of all classes in a cache for use in subsequent runs. This in turn would lay a foundation for future improvements to both startup and warmup times, the proposal states.

Created early last September, the proposal was updated August 4. The proposal currently does not list a specific time for the capability to arrive in Java.

Motivating the proposal is the desire to preserve the dynamism of the Java platform while reducing the cost of that dynamism, which must be paid every time an application starts, the proposal says. The highly dynamic Java platform has features such as dynamic class loading, dynamic linkage, and dynamic reflection, which give expressive power to developers. Java developers can, for example, write libraries that dynamically load and then link to plug-in components at run time, or assemble applications by composing libraries that dynamically link to other libraries. However, all that dynamism comes at a price, meaning the JVM does a lot of work during the startup of a typical server application, such as scanning JAR files on disk and loading parsed data into class objects. And it does this work on demand, lazily, just in time. As a result, a large server application may require seconds or even minutes to start up.

The key to improving startup time is to do some of this work ahead of time, rather than just in time. A specific goal of the proposal is improving startup time by exploiting the fact that most applications start up in roughly the same way every time they run. Other goals include:

  • Not requiring any changes to the code applications, libraries or frameworks.
  • Not requiring any change to how applications are started from the command line with the Java launcher, beyond the command-line options related directly to this feature.
  • Not requiring the use of the jlink or jpackage tools.
  • Laying a foundation for continued improvements to startup time and also to warmup time, i.e., the time needed for the HotSpot JVM to optimize an applicationโ€™s code for peak performance.

The ahead-of-time proposal for class-loading and linking follows a previous proposal for ahead-of-time compilation for the JVM. That proposal is listed as being in draft status.ย ย 

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorldโ€™s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorldโ€™s audience of software developers and other information technology professionals. Paul has won a โ€œBest Technology News Coverageโ€ award from IDG.

More from this author