{"id":989,"date":"2018-06-19T20:53:39","date_gmt":"2018-06-19T19:53:39","guid":{"rendered":"http:\/\/hirt.se\/blog\/?p=989"},"modified":"2019-01-28T14:12:49","modified_gmt":"2019-01-28T13:12:49","slug":"developing-openjdk-mission-control","status":"publish","type":"post","link":"https:\/\/hirt.se\/blog\/?p=989","title":{"rendered":"Developing OpenJDK Mission Control"},"content":{"rendered":"<p>The last blog (about <a title=\"https:\/\/hirt.se\/blog\/?p=947\" href=\"https:\/\/hirt.se\/blog\/?p=947\">Fetching and Building OpenJDK Mission Control<\/a>) earned me questions on how to get the source into Eclipse to start playing around with it. This blog post will assume that you have first successfully completed the steps in the <a title=\"https:\/\/hirt.se\/blog\/?p=947\" href=\"https:\/\/hirt.se\/blog\/?p=947\">Fetching and Building OpenJDK Mission Control<\/a> blog post.<\/p>\n<h3>Getting Eclipse<\/h3>\n<p>First of all you should download the latest version of Eclipse. JMC is an RCP application, and thus, the easiest way to make changes to it, is to use the Eclipse IDE.<\/p>\n<p>There are various Eclipse bundles out there. Get (at least) the <font>Eclipse IDE for Eclipse Committers<\/font>. It adds some useful things, like PDE (the Plugin Development Environment), Git, the Marketplace client and more. You can also use the Eclipse IDE for Java Enterprise Developers.<\/p>\n<p>You will need an Eclipse 2018-12 or later!<\/p>\n<p>To get to the screen where you can select another packaging than the standard, click on the <a href=\"https:\/\/www.eclipse.org\/downloads\/eclipse-packages\">Download Packages<\/a> link on the Eclipse download page.<\/p>\n<p><a href=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image.png\"><br \/>\n<\/a><\/p>\n<p>Install it, start it and create a new workspace for your JMC work. Creating a new workspace is as easy as picking a new name when starting up your Eclipse in the dialog asking for a directory for the workspace:<br \/>\n<a href=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"620\" height=\"283\" title=\"image\" alt=\"image\" src=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image_thumb.png\" border=\"0\"><\/a><\/p>\n<h2>Installing JDKs<\/h2>\n<p>Since you\u2019ve already built JMC outside of the IDE, you already have a JDK 8. You probably also want to have a JDK 11 set up in your Eclipse.<\/p>\n<p>Download and install a JDK11, then open <font color=\"#ff0000\">Window | Preferences <\/font><font color=\"#000000\">and then select<font color=\"#ff0000\"> Java \/ Installed JREs<\/font>. Add your favourite JKD 8 and JDK 11 JDKs (<font color=\"#ff0000\">Add\u2026<\/font>) and then use <font color=\"#ff0000\">Java \/ Installed JREs \/ Execution Environments <\/font>to set them as defaults for the JDK 8 and JDK 11 execution environments.<\/font><\/p>\n<blockquote><p><font color=\"#000000\">Note to JMC lovers:<\/font><\/p>\n<p><font color=\"#000000\"><font color=\"#000000\"><font color=\"#000000\">You may want to ensure that a JDK is used to run your Eclipse, and not a jre. A JDK is needed for JMC to find the tools.jar, where the classes required for JMC to discover locally running JVMs are located. Simply add the \u2013vm flag in your eclipse.ini file, and point it to your JDK:<\/font><\/font><\/font><\/p>\n<p><font color=\"#000000\"><font color=\"#000000\"><font color=\"#000000\"><a href=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"244\" height=\"167\" title=\"image\" style=\"margin: 0px\" alt=\"image\" src=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image_thumb-1.png\" border=\"0\"><\/a><\/font><\/font><\/font><\/p>\n<p><font color=\"#000000\"><font color=\"#000000\"><font color=\"#000000\"><br \/>\n<\/font><\/font><\/font><font color=\"#000000\"><font color=\"#000000\"><font color=\"#000000\"><\/font><\/font><\/font><font color=\"#000000\"><font color=\"#000000\"><font color=\"#000000\"><\/font><\/font><\/font><\/p><\/blockquote>\n<p><font color=\"#000000\"><font color=\"#000000\"><font color=\"#000000\"><font color=\"#000000\"><\/font><\/font><\/font><\/font><\/p>\n<p><font color=\"#000000\"><font color=\"#000000\"><font color=\"#000000\">Setting installed JREs:<\/font><\/font><\/font><\/p>\n<p><font color=\"#000000\"><font color=\"#000000\"><font color=\"#000000\"><a href=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image-3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"763\" height=\"570\" title=\"image\" alt=\"image\" src=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image_thumb-2.png\" border=\"0\"><\/a><\/font><\/font><\/font><\/p>\n<p><font color=\"#000000\"><font color=\"#000000\"><font color=\"#000000\">Setting execution environments:<\/font><\/font><\/font><\/p>\n<p><font color=\"#000000\"><font color=\"#000000\"><font color=\"#000000\"><a href=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image-4.png\"><img loading=\"lazy\" decoding=\"async\" width=\"763\" height=\"570\" title=\"image\" alt=\"image\" src=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image_thumb-3.png\" border=\"0\"><\/a><\/font><\/font><\/font><\/p>\n<p><font color=\"#000000\"><font color=\"#000000\"><font color=\"#000000\">Okay, we now have our JDKs set up. Next step is to set up a user library for things that JMC will need from the JDK. This is directly from the JMC readme:<\/font><\/font><\/font><\/p>\n<p><font color=\"#000000\"><font color=\"#000000\"><font color=\"#000000\"><\/font><\/font><\/font><\/p>\n<p><font color=\"#000000\"><font color=\"#000000\"><font color=\"#000000\"><\/font><\/font><\/font><\/p>\n<p><font color=\"#000000\"><font color=\"#000000\"><font color=\"#000000\"><\/font><\/font><\/font><\/p>\n<p><font color=\"#000000\"><font color=\"#000000\"><font color=\"#000000\"><\/font><\/font><\/font><\/p>\n<p><font color=\"#000000\"><font color=\"#000000\"><font color=\"#000000\"><\/font><\/font><\/font><\/p>\n<p><font color=\"#000000\"><font color=\"#000000\"><font color=\"#000000\"><\/font><\/font><\/font><\/p>\n<p><font color=\"#000000\"><font color=\"#000000\"><font color=\"#000000\"><\/font><\/font><\/font><\/p>\n<p><font color=\"#000000\"><font color=\"#000000\"><font color=\"#000000\"><\/font><\/font><\/font><\/p>\n<p><font color=\"#000000\"><font color=\"#000000\"><font color=\"#000000\"><\/p>\n<blockquote><p>If importing the application projects, make sure you create a user library (Preferences | Java\/Build Path\/User Libraries) named JMC_JDK, and add (Add External JARs&#8230;) the following JARs from a JDK 8 (u40 or above) to the User Library: tools.jar (\/lib\/tools.jar), jconsole.jar (\/lib\/jconsole.jar), jfxswt.jar (\/jre\/lib\/jfxswt.jar), and finally the jfxrt.jar (\/jre\/lib\/ext\/jfxrt.jar).<\/p><\/blockquote>\n<p>Creating the user library:<\/p>\n<p><a href=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image-5.png\"><img loading=\"lazy\" decoding=\"async\" width=\"244\" height=\"183\" title=\"image\" style=\"margin: 0px\" alt=\"image\" src=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image_thumb-4.png\" border=\"0\"><\/a><\/p>\n<p>Adding the jars:<\/p>\n<p><a href=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image-6.png\"><img loading=\"lazy\" decoding=\"async\" width=\"244\" height=\"183\" title=\"image\" alt=\"image\" src=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image_thumb-5.png\" border=\"0\"><\/a><\/p>\n<p>Now we need to check a few things\u2026<\/p>\n<h2><\/h2>\n<h3>Checkpoint<\/h3>\n<p>Is the Jetty server from the previous blog up and running?<br \/>\n<a href=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image-7.png\"><img loading=\"lazy\" decoding=\"async\" width=\"644\" height=\"339\" title=\"image\" alt=\"image\" src=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image_thumb-6.png\" border=\"0\"><\/a><\/p>\n<p>If yes, go ahead and open up the target file available under releng\/platform-definitions\/platform-definition-photon (<font color=\"#ff0000\">File | Open File<\/font>). You should see something like this:<\/p>\n<p><a href=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image-8.png\"><img loading=\"lazy\" decoding=\"async\" width=\"644\" height=\"452\" title=\"image\" alt=\"image\" src=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image_thumb-7.png\" border=\"0\"><\/a><\/p>\n<p>Click the<font color=\"#ff0000\"> Set as Active Target<\/font> Platform link in the upper right corner.<\/p>\n<p>Now there is one final preparation for the import \u2013 we need to turn of certain Maven settings. Go to the preferences, and select <font color=\"#ff0000\">Maven \/ Errors\/Warnings<\/font>. Set <font color=\"#ff0000\">Plugin execution not covered by lifecycle configuration<\/font> to <font color=\"#ff0000\">Ignore<font color=\"#000000\">, and also<\/font> Out-of-date project configuration<font color=\"#000000\"> to<\/font> Ignore<\/font><\/p>\n<p><a href=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image-9.png\"><img loading=\"lazy\" decoding=\"async\" width=\"244\" height=\"199\" title=\"image\" alt=\"image\" src=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image_thumb-8.png\" border=\"0\"><\/a><\/p>\n<p>Now the preparations are done, and we can start importing the projects. Woho!<\/p>\n<h2><\/h2>\n<h2>Importing the Projects<\/h2>\n<p>First we will have to import the core projects, since they are built separately from the rest. Select File | Import\u2026 and select Maven \/ Existing Maven Project.<br \/>\n<a href=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image-10.png\"><img loading=\"lazy\" decoding=\"async\" width=\"230\" height=\"244\" title=\"image\" style=\"margin: 0px\" alt=\"image\" src=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image_thumb-9.png\" border=\"0\"><\/a><\/p>\n<p>Click next, and browse into the jmc\/core folder. Select all the core projects and import them. (You may want to skip the top level poms.)<\/p>\n<p>Next select File | Import\u2026 and select Maven \/ Existing Maven Project again, but this time from the root:<\/p>\n<p>Again, you may want to skip the top level poms (\/pom.xml, application\/pom.xml etc), and the uitests (at least until we fix so that the jemmy dependency can be downloaded from Maven Central).<br \/>\n<a href=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image-11.png\"><img loading=\"lazy\" decoding=\"async\" width=\"230\" height=\"244\" title=\"image\" style=\"margin: 0px\" alt=\"image\" src=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image_thumb-10.png\" border=\"0\"><\/a><\/p>\n<p>Next we will import the project which contains the launchers. Select <font color=\"#ff0000\">File | Import\u2026<\/font> and then select <font color=\"#ff0000\">Existing Projects into Workspace<font color=\"#000000\">. Find the configuration\/ide\/eclipse folder and click <font color=\"#ff0000\">Ok<\/font>.<\/font><\/font><\/p>\n<p><a href=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image-12.png\"><img loading=\"lazy\" decoding=\"async\" width=\"244\" height=\"214\" title=\"image\" alt=\"image\" src=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image_thumb-11.png\" border=\"0\"><\/a><\/p>\n<p>After importing that project, we can now launch JMC from within Eclipse:<\/p>\n<p><a href=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image-13.png\"><img loading=\"lazy\" decoding=\"async\" width=\"244\" height=\"93\" title=\"image\" style=\"margin: 0px\" alt=\"image\" src=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image_thumb-12.png\" border=\"0\"><\/a><\/p>\n<p>Or run it in debug mode:<\/p>\n<p><a href=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image-14.png\"><img loading=\"lazy\" decoding=\"async\" width=\"244\" height=\"121\" title=\"image\" style=\"margin: 0px\" alt=\"image\" src=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image_thumb-13.png\" border=\"0\"><\/a><\/p>\n<h3>Configuring Development Settings<\/h3>\n<p>If you don\u2019t plan on submitting any changes, then this step is optional. The team use shared settings for formatter and macros. Go to the preferences and then to <font color=\"#ff0000\">Java \/ Code Style \/ Formatter<\/font>. Then click <font color=\"#ff0000\">Import\u2026<\/font> and select the configuration\/ide\/eclipse\/formatting\/formatting.xml. You should now have the Mission Control formatting settings active:<\/p>\n<p><a href=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image-15.png\"><img loading=\"lazy\" decoding=\"async\" width=\"644\" height=\"452\" title=\"image\" alt=\"image\" src=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image_thumb-14.png\" border=\"0\"><\/a><\/p>\n<p><strong>Optional:<\/strong><\/p>\n<p>If you have the spotbugs plug-in installed, you should also import the spotbugs excludes (configuration\/spotbugs\/spotbugs-exclude.xml). There is also a common dictionary (configuration\/ide\/eclipse\/dictionary\/dictionary.txt) and templates (configuration\/ide\/eclipse\/templates\/JMC templates.xml) which you may find useful.<\/p>\n<h2>Adding (and Launching with) Some Custom Plug-in<\/h2>\n<p>The flame graph view may be included in JMC at some point. If so, then there will probably be some other plug-in somewhere that will serve as an example.<\/p>\n<p>First install Git. If you, on the command line, can run <font face=\"Courier New\">git &#8211;version<\/font>, you\u2019re all set.<\/p>\n<p>Next go to your git folder (or wherever you keep your git projects) and clone the jmc-flame-view repo:<\/p>\n<p><\/font><\/font><font color=\"#000000\"><font color=\"#000000\"><\/font><\/font><font color=\"#000000\"><font color=\"#000000\"><\/font><\/font><font color=\"#000000\"><font color=\"#000000\"><\/font><\/font><font color=\"#000000\"><font color=\"#000000\"><\/font><\/font><font color=\"#000000\"><font color=\"#000000\"><\/font><\/font><font color=\"#000000\"><font color=\"#000000\"><\/font><\/font><font color=\"#000000\"><font color=\"#000000\"><\/font><\/font><font color=\"#000000\"><font color=\"#000000\"><\/font><\/font><font color=\"#000000\"><font color=\"#000000\"><\/font><\/font><font color=\"#000000\"><font color=\"#000000\"><\/font><\/font><font color=\"#000000\"><font color=\"#000000\"><\/font><\/font><font color=\"#000000\"><font color=\"#000000\"><\/font><\/font><font color=\"#000000\"><font color=\"#000000\"><\/font><\/font><font color=\"#000000\"><font color=\"#000000\"><\/font><\/font><\/p>\n<blockquote><p><font color=\"#000000\"><font color=\"#000000\">git clone <a title=\"https:\/\/github.com\/thegreystone\/jmc-flame-view\" href=\"https:\/\/github.com\/thegreystone\/jmc-flame-view\">https:\/\/github.com\/thegreystone\/jmc-flame-view<\/a><\/font><\/font><\/p><\/blockquote>\n<p><font color=\"#000000\">Next go to Eclipse and do<font color=\"#ff0000\"> File | Import\u2026<\/font>, and select <font color=\"#ff0000\">Existing Projects into Workspace<\/font>. Select your jmc-flame-view folder, and click <font color=\"#ff0000\">Finish<\/font>:<\/font><\/p>\n<p><a href=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image-16.png\"><img loading=\"lazy\" decoding=\"async\" width=\"644\" height=\"372\" title=\"image\" alt=\"image\" src=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image_thumb-15.png\" border=\"0\"><\/a><\/p>\n<p>Next we need a launcher which includes this new feature. Go to the <font color=\"#ff0000\">org.openjdk.jmc.eclipseonfig<\/font> project and open the <font color=\"#ff0000\">launchers<\/font> folder. Copy and paste the <font color=\"#ff0000\">JMC RCP plug-ins.launch<\/font> file. Name the copy something.<\/p>\n<p><a href=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image-17.png\"><img loading=\"lazy\" decoding=\"async\" width=\"244\" height=\"201\" title=\"image\" alt=\"image\" src=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image_thumb-16.png\" border=\"0\"><\/a><\/p>\n<p>Click the run dropdown and select <font color=\"#ff0000\">Run Configurations\u2026<\/font>.<\/p>\n<p><a href=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image-18.png\"><img loading=\"lazy\" decoding=\"async\" width=\"244\" height=\"122\" title=\"image\" style=\"margin: 0px\" alt=\"image\" src=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image_thumb-17.png\" border=\"0\"><\/a><\/p>\n<p>Select your new launcher, and click the Plug-ins tab. Add the new Flame Graph feature:<\/p>\n<p><a href=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image-19.png\"><img loading=\"lazy\" decoding=\"async\" width=\"450\" height=\"484\" title=\"image\" alt=\"image\" src=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2018\/06\/image_thumb-18.png\" border=\"0\"><\/a><\/p>\n<p>Click <font color=\"#ff0000\">Apply<\/font> and <font color=\"#ff0000\">Run<\/font>. Mission Control will start, with your new plug-in available. In the started JMC, go to <font color=\"#ff0000\">Window | Show View | Other\u2026<\/font>. Select<font color=\"#ff0000\"> Mission Control \/ Flame Graph<\/font> in the <font color=\"#ff0000\">Show View<\/font> dialog. Open a Flight Recording, and click on something that would yield an aggregated stack trace, such as something in the Method Profiling page, or a class in the Memory page \u2013 you should now see a Flame Graph of your selection.<\/p>\n<iframe loading=\"lazy\"  style=\"display: block; margin: 0px auto;\"  id=\"_ytid_61350\"  width=\"560\" height=\"315\"  data-origwidth=\"560\" data-origheight=\"315\" src=\"https:\/\/www.youtube.com\/embed\/vVh_z34Gtn8?enablejsapi=1&autoplay=1&cc_load_policy=0&cc_lang_pref=&iv_load_policy=1&loop=1&playlist=vVh_z34Gtn8&rel=1&fs=1&playsinline=0&autohide=2&theme=dark&color=red&controls=1&disablekb=0&\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe>\n<h2>Summary<\/h2>\n<p>This blog post explained, in some detail, how to import the OpenJDK Mission Control project into Eclipse, and how to set up the workspace to work on the code. It also explained how to run the code with an additional plug-in from a separate repo.<\/p>\n<p>As always, please let me know if I forgot to mention something (except for the agent, which I will deal with in a separate post)!<\/p>\n<p><\/font><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The last blog (about Fetching and Building OpenJDK Mission Control) earned me questions on how to get the source into Eclipse to start playing around with it. This blog post will assume that you have first successfully completed the steps in the Fetching and Building OpenJDK Mission Control blog post. Getting Eclipse First of all [&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":[16,18,19,20],"class_list":["post-989","post","type-post","status-publish","format-standard","hentry","category-java-mission-control-fair-dj","tag-java-mission-control","tag-jdk-mission-control","tag-jdk-mission-control-7","tag-openjdk-mission-control"],"_links":{"self":[{"href":"https:\/\/hirt.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/989","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=989"}],"version-history":[{"count":10,"href":"https:\/\/hirt.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/989\/revisions"}],"predecessor-version":[{"id":1139,"href":"https:\/\/hirt.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/989\/revisions\/1139"}],"wp:attachment":[{"href":"https:\/\/hirt.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=989"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hirt.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=989"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hirt.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=989"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}