{"id":1365,"date":"2021-10-14T00:07:48","date_gmt":"2021-10-13T23:07:48","guid":{"rendered":"http:\/\/hirt.se\/blog\/?p=1365"},"modified":"2024-08-26T19:16:57","modified_gmt":"2024-08-26T18:16:57","slug":"contributing-to-openjdk-mission-control","status":"publish","type":"post","link":"https:\/\/hirt.se\/blog\/?p=1365","title":{"rendered":"Contributing to OpenJDK Mission Control"},"content":{"rendered":"<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/q9HbASovVu0zhWiEJ5PbG8BxzM2xs8ONd1A3SRmcZ4IpbR86RcsRqOi8dks7cmKzKJYZbmcmsAnaCoDBbXGV1SPVL4VJjn6q0x4jP0msEHWZ-DpPfqjXA1aPzjoq_ioXRGYsIb21=s0\" alt=\"Hacktoberfest Banner\" title=\"\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Since this month is <a href=\"https:\/\/hacktoberfest.digitalocean.com\/\">Hacktoberfest<\/a>, I thought it would be a good idea to talk a bit about how to contribute to the OpenJDK Mission Control project. Some of the content of this blog post will be applicable to any of the OpenJDK projects, especially the Skara (OpenJDK on Git) bits.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The OpenJDK Mission Control Project<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The OpenJDK Mission Control project is the observability tools suite for OpenJDK. It contains a JMX Console, <img loading=\"lazy\" decoding=\"async\" style=\"float: right; display: inline;\" src=\"https:\/\/lh6.googleusercontent.com\/NU__YI9_5Nu5RIH_RX-iwEcr6kSWH2DtNmAMrEqvDQnmGLtVAH_4LQx7uJKYbPziCSNudEYu8YttVAggTeKclmLrE8mJobayNAJFh8XNXk19ZcVgZGwiDOruaWlSaUCrSNa0fiJs=s0\" width=\"130\" height=\"130\" align=\"right\">a JFR visualizer and analyzer, a heap waste analysis tool, and many other little useful tools and utilities. Since it is all open source, pretty much anyone can contribute to the project.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The project is on GitHub:<br><a href=\"https:\/\/github.com\/openjdk\/jmc\">https:\/\/github.com\/openjdk\/jmc<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The first step to contribute to JDK Mission Control is to simply <a href=\"https:\/\/docs.github.com\/en\/get-started\/quickstart\/fork-a-repo\">fork the repository<\/a> on GitHub. This establishes a copy of the repository where you can freely make changes as you please. Whilst it is technically possible to make the changes in the master branch, it will save time and effort if you later want to contribute the effort to <a href=\"https:\/\/docs.github.com\/en\/get-started\/quickstart\/github-flow\">make the changes in a branch<\/a>:<br><span style=\"font-family: Courier New;\">git checkout -b my-jmc-test<\/span><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Building JMC<\/h2>\n\n\n<p>First of all, ensure that you have <a href=\"https:\/\/sdkman.io\/\">jdk11 active<\/a> in your shell, and verify that this is the case using:<br \/><span style=\"font-family: Courier New;\">java -version<\/span><\/p>\n\n\n<p class=\"wp-block-paragraph\">There are multiple ways to build JMC. The easiest way is to simply use the build script (don\u2019t do this just yet):<br><span style=\"font-family: Courier New;\">.\/build.sh \u2013packageJmc<\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There is also a way to build JMC using Docker (don\u2019t do this just yet either):<br><span style=\"font-family: Courier New;\">docker-compose -f docker\/docker-compose.yml run jmc<\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">These are however not the best ways when you\u2019re developing JMC using an IDE. The third party dependencies for JMC need to be available through a p2 repository, and you want to install a build of the JMC core libraries into your maven cache.<\/p>\n\n\n<p>So, to set things properly up for development, it is better to first install the core libraries:<\/p>\n<pre><pre class=\"brush: bash; title: ; notranslate\" title=\"\">cd $JMC_ROOT\/core\nmvn install<\/pre><\/pre>\n<p>Next, build the p2 site and start jetty to expose it on a well known port:<\/p>\n<pre><pre class=\"brush: bash; title: ; notranslate\" title=\"\">cd $JMC_ROOT\/releng\/third-party\nmvn p2:site\nmvn jetty:run<\/pre><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Then leave jetty running for as long as you are developing JMC. You will need it up and running so that it can be found both when building from the command line, as well as when compiling JMC from within the Eclipse development environment.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To build the JMC application, next do the following in a separate shell (since you have jetty with the p2 site for the third-party dependencies up and running in the previous one):<br>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">cd $JMC_ROOT\nmvn package<\/pre><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After this, you can use the build script to run the built JMC product:<br><span style=\"font-family: Courier New;\">.\/build.sh &#8211;run<\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For alternative ways of launching JMC, see the platform specific documentation in the <a href=\"https:\/\/github.com\/openjdk\/jmc\/blob\/master\/README.md#running-the-locally-built-jmc\">README.md<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Developing JMC<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Many that I\u2019ve talked to, especially when JMC was shipped with the Oracle JDK, believed that JMC is a native application. If you\u2019ve browsed the repo, you\u2019ve already seen that it is a Java application, more specifically an Eclipse RCP application. Since it is an Eclipse RCP application, it\u2019s easiest to develop JMC using Eclipse.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First set up your development environment, following the <a href=\"https:\/\/github.com\/openjdk\/jmc\/blob\/master\/docs\/devguide\/README.md\">Developer Guide<\/a>. It is slightly involved, but luckily does not need to happen very often.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Next, in your branch in your fork, commit the changes you want to contribute, and create a pull request, just like you would for any other open source project on GitHub.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now, if this is your first OpenJDK PR, the OpenJDK bot will likely complain about a few different things, for example:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You need to have your GitHub account associated with a company that has a signed Oracle Contributor Agreement (OCA), or you must have signed an OCA yourself.<\/li>\n\n\n\n<li>The PR needs to have an associated issue in the <a href=\"https:\/\/bugs.openjdk.java.net\/secure\/RapidBoard.jspa?rapidView=1341&amp;view=planning.nodetail&amp;issueLimit=100\">Java Bug System<\/a>.<\/li>\n\n\n\n<li>There is some problem with the testing or formatting of your code.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s take a quick look at these three problems.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The Oracle Contributor Agreement<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Like all open source projects, there needs to be a Contributor Agreement in place. This is to protect everyone backing the project, as well as the customers depending on the project. For example, the contributor agreement ensures that the source code you\u2019re contributing isn\u2019t violating any patent rights, and that the source code you\u2019re contributing is yours to contribute.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Many larger companies already have an OCA signed, so the first step might be to check with your company if one is already signed. In my case, I both have a personal OCA signed (since I was contributing before Datadog signed an OCA), and one signed by my employer, <a href=\"https:\/\/www.datadoghq.com\/dg\/apm\/profiler\/continuous-profiler\">Datadog<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You will know that the OCA status is not properly set up for your GitHub account when the OCA label is set in the PR, and the following text can be found in the PR:<br><b> \u26a0\ufe0f OCA signatory status must be verified<br><\/b><br>The OpenJDK bot will write helpful messages in the PR to help guide you through getting your OCA status verified.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The Java Bug System<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Once you have a few commits under your belt, and become an OpenJDK author, you have access to the Java Bug System (JBS): <a href=\"https:\/\/bugs.openjdk.java.net\/\">https:\/\/bugs.openjdk.java.net\/<\/a>. So, what do you do before then? If the PR passes a first cursory check by the reviewers, a reviewer will simply create an Issue in JBS for you.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Fixing Issues<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If you end up having an issue, the details of the test run in the PR will hopefully be enough to sort it out. If not, you can run <span style=\"font-family: Courier New;\">mvn verify<\/span> locally and look at the test logs. If it is formatting, then check if the formatting problem was in core or not, and either run <span style=\"font-family: Courier New;\">mvn spotless:apply<\/span> in core or in the root of the project.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Skara &#8211; the OpenJDK Git Tooling<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Skara is the project name for the tooling around developing OpenJDK on Git(Hub). It actually insulates a lot of the GitHub specifics, making it possible, should the need ever arise, to move the development and development process somewhere else. The project also contains the aforementioned bot that helps, for example, to verify that there is a related JBS issue, and that there is a signed OCA. Skara also contains some useful git extensions which make working with OpenJDK on GitHub smoother.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To set things up, do the following:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Clone Skara:<br><span style=\"font-family: Courier New;\">git clone <\/span><a href=\"https:\/\/github.com\/openjdk\/skara\"><span style=\"font-family: Courier New;\">https:\/\/github.com\/openjdk\/skara<\/span><\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Build it:<br><span style=\"font-family: Courier New;\">gradlew<\/span> (win) or <span style=\"font-family: Courier New;\">sh gradlew<\/span> (mac\/linux)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Install it:<br><span style=\"font-family: Courier New;\">git config &#8211;global include.path &#8220;%CD%\/skara.gitconfig&#8221;<\/span> (win), or <br><span style=\"font-family: Courier New;\">git config &#8211;global include.path &#8220;$PWD\/skara.gitconfig&#8221;<\/span> (mac\/linux)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Set where to sync your forks from:<br><span style=\"font-family: Courier New;\">git config &#8211;global sync.from upstream<\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here are some examples:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To sync your fork with upstream and pull the changes:<br><span style=\"font-family: Courier New;\">git sync &#8211;pull<\/span><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">Note: if the sync fails with the error message \u201cNo remote provided to fetch from, please set the \u2013from flag\u201d or &#8220;error: upstream is not a known git remote, nor a proper git URI&#8221;, remember to set the remote for your repo, e.g.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><span style=\"font-family: Courier New;\">git remote add upstream https:\/\/github.com\/openjdk\/jmc<\/span><\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">To list the open PRs:<br><span style=\"font-family: Courier New;\">git pr list<\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To create a PR:<br><span style=\"font-family: Courier New;\">git pr create<\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To push your committed changes in your branch to your fork, creating the remote branch:<br><span style=\"font-family: Courier New;\">git publish<\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So, the normal workflow when working with OpenJDK JMC using the Skara tooling becomes:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">Note: First ensure that you have a fork of JMC, and that your current directory is the root of that fork. You typically just create that one fork and stick with it.<\/p>\n<\/blockquote>\n\n\n\n<ol class=\"wp-block-list\">\n<li>(Optional) Sync up your fork with upstream:<br><span style=\"font-family: Courier New;\">git sync \u2013pull<\/span><\/li>\n\n\n\n<li>Create a branch to work on, with a name you pick, typically related to the work you plan on doing:<br><span style=\"font-family: Courier New;\">git checkout \u2013b &lt;branchname><\/span><\/li>\n\n\n\n<li>Make your changes \/ fix your bug \/ add amazing stuff<\/li>\n\n\n\n<li>(Optional) Run jcheck locally:<br><span style=\"font-family: Courier New;\">git jcheck local<\/span><\/li>\n\n\n\n<li>Push your changes to the new branch on your fork:<br><span style=\"font-family: Courier New;\">git publish<\/span> (which is pretty much git push &#8211;set-upstream origin &lt;branchname>)<\/li>\n\n\n\n<li>Create the PR, either on GitHub, or from the command line:<br><span style=\"font-family: Courier New;\">git pr create<\/span><\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Once the PR is created, the bot will check that everything is okay, and the PR will be reviewed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Interacting with the Skara Bot<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Getting the PR merged is handled a bit differently in OpenJDK compared to normal GitHub projects. First of all, all the prerequisites must first be fulfilled, like the OCA status of the contributor being verified, the change being properly reviewed, jcheck passing, the tests passing, the PR having a matching issue in JBS etc. Once that is all taken care of, the bot will helpfully ask, in a message in the PR, for the author of the PR to integrate the changes. This is simply done by typing <span style=\"font-family: Courier New;\">\/integrate<\/span> in message in the PR. The bot will automatically rebase on the latest changes in the target branch (normally master) and squash your commits. In other words, it is perfectly fine to have multiple fixes and other commits happening in the PR after the initial commit for the PR. It is actually <em><strong>much preferred<\/strong><\/em> to force-updating the PR, as it\u2019s easier to follow along with the review.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the PR author is not a committer on the project, the bot will inform that the PR is ready to be sponsored by a committer, which is normally done by the reviewer of the PR. This is done by writing <span style=\"font-family: Courier New;\">\/sponsor<\/span> in a separate message in the PR.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When the PR is merged, the corresponding JBS issue is automatically closed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Other Related Repos<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">There are a few additional repos that are related to the OpenJDK JMC project, but that aren\u2019t currently OpenJDK projects. Two examples are the <a href=\"https:\/\/github.com\/thegreystone\/jmc-jshell\">jmc-jshell<\/a> and the <a href=\"https:\/\/github.com\/thegreystone\/jmc-tutorial\">jmc-tutorial<\/a> repositories. The <a href=\"https:\/\/github.com\/thegreystone\/jmc-tutorial\">jmc-tutorial<\/a> is a good resource for learning about JDK Mission Control. Even though it is not officially an OpenJDK repository, it can still be a good place to start contributing to the OpenJDK JMC community.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Contributing to OpenJDK is easier than ever before now that it\u2019s on GitHub.<\/li>\n\n\n\n<li><a href=\"https:\/\/wiki.openjdk.java.net\/display\/SKARA\">Skara<\/a> makes it even easier.<\/li>\n\n\n\n<li>It\u2019s <a href=\"https:\/\/hacktoberfest.digitalocean.com\/\">Hacktoberfest<\/a> &#8211; commits to the JMC project (and related repos) count!<\/li>\n\n\n\n<li>JBS is a good source for <a href=\"https:\/\/bugs.openjdk.java.net\/secure\/Dashboard.jspa?selectPageId=19538\">JMC starter bugs<\/a>.<\/li>\n\n\n\n<li>If you need any help, the JDK Mission Control slack is a good place for asking questions! Ping <a href=\"https:\/\/twitter.com\/hirt\">me<\/a> or any of the <a href=\"https:\/\/openjdk.java.net\/census#jmc\">JMC folks<\/a> for an invite. \ud83d\ude42<\/li>\n\n\n\n<li>Finally, here&#8217;s a practical guide to OpenJDK projects and the roles:<br><a href=\"https:\/\/openjdk.java.net\/projects\/\">OpenJDK Projects (java.net)<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Since this month is Hacktoberfest, I thought it would be a good idea to talk a bit about how to contribute to the OpenJDK Mission Control project. Some of the content of this blog post will be applicable to any of the OpenJDK projects, especially the Skara (OpenJDK on Git) bits. The OpenJDK Mission Control [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[27,46,20,47],"class_list":["post-1365","post","type-post","status-publish","format-standard","hentry","category-java-mission-control-fair-dj","tag-mission-control","tag-openjdk","tag-openjdk-mission-control","tag-skara"],"_links":{"self":[{"href":"https:\/\/hirt.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1365","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hirt.se\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hirt.se\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hirt.se\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hirt.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1365"}],"version-history":[{"count":13,"href":"https:\/\/hirt.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1365\/revisions"}],"predecessor-version":[{"id":1492,"href":"https:\/\/hirt.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1365\/revisions\/1492"}],"wp:attachment":[{"href":"https:\/\/hirt.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1365"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hirt.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1365"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hirt.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1365"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}