SkillAgentSearch skills...

Jmc

https://openjdk.org/projects/jmc OpenJDK Mission Control, a production time profiling and diagnostics tools suite.

Install / Use

/learn @openjdk/Jmc
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Mission Control

Mission Control is an open source production time profiling and diagnostics tool for Java.

Builds of Mission Control can currently be found in the Oracle JDK on supported platforms and in the Eclipse Marketplace.

For more information on Mission Control, see https://www.oracle.com/missioncontrol.

Downloading Builds

Binary distributions of JDK Mission Control are provided by different downstream vendors.

Eclipse Adoptium

  • Released version
  • EA builds of upcoming release
  • Downloadable Eclipse update site archive

https://adoptium.net/jmc

Azul (Zulu Mission Control)

  • Released version

https://www.azul.com/products/zulu-mission-control

Bell-Soft (Liberica Mission Control)

  • Released version

https://bell-sw.com/pages/lmc

Oracle

  • Released version
  • Integrated (in-app) update site
  • Eclipse update site

https://www.oracle.com/java/technologies/jdk-mission-control.html

Red Hat

  • Released version

Red Hat distributes JDK Mission Control in Red Hat Enterprise Linux (RHEL). JMC is available in RHEL 7 as the rh-jmc Software Collection, and is provided in RHEL 8 by the jmc:rhel8 module stream. JMC is also included in the OpenJDK developer builds for Windows.

Mission Control Features

Application Features

  • A framework for hosting various useful Java tools

  • A tool for visualizing the contents of Java flight recordings, and the results of an automated analysis of the contents

  • A JMX Console

  • A tool for heap waste analysis

Core API Features

  • Core APIs for parsing and processing Java flight recordings

  • Core API can read recordings from JDK 7 and above

  • Core API can run on JDK 8 and above

  • Core API contains a framework for handling units of measurement and physical quantities

  • Core API supports headless analysis of Java flight recordings

Core API Example

Example for producing an HTML report from the command line:

java -cp <the built core jars> org.openjdk.jmc.flightrecorder.rules.report.html.JfrHtmlRulesReport <file> [<outputfile>]

Example for finding the standard deviation for the java monitor events in a recording:

import java.io.File;
 
import org.openjdk.jmc.common.IDisplayable;
import org.openjdk.jmc.common.item.Aggregators;
import org.openjdk.jmc.common.item.IItemCollection;
import org.openjdk.jmc.common.item.ItemFilters;
import org.openjdk.jmc.common.unit.IQuantity;
import org.openjdk.jmc.flightrecorder.JfrAttributes;
import org.openjdk.jmc.flightrecorder.JfrLoaderToolkit;
import org.openjdk.jmc.flightrecorder.jdk.JdkTypeIDs;
 
/**
 * Finds out the standard deviation for the java monitor enter events.
 */
public class LoadRecording {
    public static void main(String[] args) throws Exception {         
        IItemCollection events = JfrLoaderToolkit.loadEvents(new File(args[0]));
        IQuantity aggregate = events.apply(ItemFilters.type(JdkTypeIDs.MONITOR_ENTER))
                .getAggregate(Aggregators.stddev(JfrAttributes.DURATION));
         
        System.out.println("The standard deviation for the Java monitor enter events was "
                + aggregate.displayUsing(IDisplayable.AUTO));
    }
}

Example for programmatically running the rules:

import java.io.File;
import java.util.concurrent.RunnableFuture;
 
import org.example.util.DemoToolkit;
import org.openjdk.jmc.common.item.IItemCollection;
import org.openjdk.jmc.common.util.IPreferenceValueProvider;
import org.openjdk.jmc.flightrecorder.JfrLoaderToolkit;
import org.openjdk.jmc.flightrecorder.rules.IRule;
import org.openjdk.jmc.flightrecorder.rules.Result;
import org.openjdk.jmc.flightrecorder.rules.RuleRegistry;
 
public class RunRulesOnFileSimple {
    public static void main(String[] args) throws Exception {
        File recording = DemoToolkit.verifyRecordingArgument(RunRulesOnFileSimple.class, args);
        IItemCollection events = JfrLoaderToolkit.loadEvents(recording);
         
        for (IRule rule : RuleRegistry.getRules()) {
            RunnableFuture<Result> future = rule.evaluate(events, IPreferenceValueProvider.DEFAULT_VALUES);
            future.run();
            Result result = future.get();
            if (result.getScore() > 50) {
                System.out.println(String.format("[Score: %3.0f] Rule ID: %s, Rule name: %s, Short description: %s",
                        result.getScore(), result.getRule().getId(), result.getRule().getName(),
                        result.getShortDescription()));
            }
        }
    }
}

Example for programmatically running rules in parallel:

import java.io.File;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.RunnableFuture;
import java.util.stream.Collectors;
import java.util.stream.Stream;
 
import org.openjdk.jmc.common.item.IItemCollection;
import org.openjdk.jmc.common.util.IPreferenceValueProvider;
import org.openjdk.jmc.flightrecorder.JfrLoaderToolkit;
import org.openjdk.jmc.flightrecorder.rules.IRule;
import org.openjdk.jmc.flightrecorder.rules.Result;
import org.openjdk.jmc.flightrecorder.rules.RuleRegistry;
 
/**
 * Runs the rules on the events in the specified file in parallel, then prints
 * them in order of descending score.
 */
public class RunRulesOnFile {
    private final static Executor EXECUTOR = Executors
            .newFixedThreadPool(Runtime.getRuntime().availableProcessors() - 1);
    private static int limit;
 
    public static void main(String[] args) throws Exception {
        if (args.length == 0) {
            System.out.println(
                    "Usage: RunRulesOnFile <recording file> [<limit>]\n\tThe recording file must be a flight recording from JDK 7 or above. The limit, if set, will only report rules triggered with a score higher or equal than the limit.");
            System.exit(2);
        }
        IItemCollection events = JfrLoaderToolkit.loadEvents(new File(args[0]));
        if (args.length > 1) {
            limit = Integer.parseInt(args[1]);
        }
        Stream<RunnableFuture<Result>> resultFutures = RuleRegistry.getRules().stream()
                .map((IRule r) -> evaluate(r, events));
        List<Result> results = resultFutures.parallel().map((RunnableFuture<Result> runnable) -> get(runnable))
                .collect(Collectors.toList());
        results.sort((Result r1, Result r2) -> Double.compare(r2.getScore(), r1.getScore()));
        results.stream().forEach(RunRulesOnFile::printResult);
    }
 
    public static RunnableFuture<Result> evaluate(IRule rule, IItemCollection events) {
        RunnableFuture<Result> evaluation = rule.evaluate(events, IPreferenceValueProvider.DEFAULT_VALUES);
        EXECUTOR.execute(evaluation);
        return evaluation;
    }
 
    public static Result get(RunnableFuture<Result> resultFuture) {
        try {
            return resultFuture.get();
        } catch (InterruptedException | ExecutionException e) {
            e.printStackTrace();
        }
        return null;
    }
 
    private static void printResult(Result result) {
        if (result.getScore() >= limit) {
            System.out.printf("(%.0f) [%s]: %s\nDetails:\n%s\n============<End of Result>============\n",
                    result.getScore(), result.getRule().getId(), result.getShortDescription(),
                    result.getLongDescription() == null ? "<no description>" : result.getLongDescription());
        }
    }
}

Building Mission Control from Source

Prerequisites for building Mission Control:

  1. Install a JDK 17 distribution and make sure it is declared in the local maven toolchain ~/.m2/toolchains.xml

  2. Install a JDK 21 distribution and make sure that it too is declared in the local maven toolchain.

  3. Install Maven (version 3.5.x or above)

On Linux or macOS you can use the build.sh script to build JMC:

usage: call ./build.sh with the following options:
   --installCore to install the core artifacts
   --test        to run the tests
   --testUi      to run the tests including UI tests
   --packageJmc  to package JMC
   --clean       to run maven clean

Otherwise follow the steps manually.

Building JMC Step-by-Step

Here are the individual steps:

  1. Get the third-party dependencies into a local p2 repo and make it available on localhost.

  2. Build and install the core libraries.

  3. Build the JMC application.

First, if on Mac / Linux:

mvn p2:site --file releng/third-party/pom.xml; mvn jetty:run --file releng/third-party/pom.xml

Or, if on Windows:

mvn p2:site --file releng\third-party\pom.xml && mvn jetty:run --file releng\third-party\pom.xml

Then in another terminal (in the project root):

mvn clean install --file core/pom.xml # Install JMC's flight recorder libraries
mvn package # Package JMC

If maven reports a toolchain error, e.g. :

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-toolchains-plugin:3.0.0:toolchain (default) on project missioncontrol: Cannot find matching toolchain definitions for the following toolchain types:
[ERROR] jdk [ version='17' ]
[ERROR] Please make sure you define the required toolchains in your ~/.m2/toolchains.xml file.

Create or amend the local maven toolchain file by pointing to any JDK 17 installation.

<details><summary><code>~/.m2/toolchains.xml</code></summary>
<?xml version="1.0" encoding="UTF-8"?>
<toolchains>
  <!-- JDK toolchains -->
  <!-- 
    Declare the JDK 17 toolchain installed on the local machine, 
    make sure the id is : JavaSE-17

    Tycho needs this to find the right _execution environment_.
  -->
  <toolchain>
    <type>jdk</type>
    <prov
View on GitHub
GitHub Stars966
CategoryDevelopment
Updated1d ago
Forks201

Languages

Java

Security Score

85/100

Audited on Mar 26, 2026

No findings