Code Tools: jol

jol (Java Object Layout) is the tiny toolbox to analyze object layout schemes in JVMs. These tools are using Unsafe heavily to deduce the actual object layout and footprint. This makes the tools much more accurate than others relying on heap dumps, specification assumptions, etc.


  1. Check out the jol source with Mercurial:
    $ hg clone jol
  2. Build jol with Maven:
    $ cd jol/
    $ mvn clean install

    You only need to do this step once, and Maven will deploy jol into your local repo. If you have the Maven repository manager installed, it might be a good idea to deploy the artifact there. If not, you can just go with the local build.

After the build is done, you can start using the project. You might want to review JOL Samples before using the tool at its full capacity.

There are two major ways to use this project.

Usage #1: Library Dependency

You need to have jol-core in classpath to access the library. In Maven world, it is as simple as adding the compile dependency:
For non-Maven world, you may want to add jol-core/target/jol-core-1.0-SNAPSHOT.jar to the classpath with the tooling you have. See the command line tools code, or JOL Samples, or Javadocs to understand how to use jol via Java APIs.

Usage #2: Command Line Tools

Build produces the self-contained executable JARs in jol-cli/target/. The brief list of the command line tools we have goes below: