<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Naman Nigam on Medium]]></title>
        <description><![CDATA[Stories by Naman Nigam on Medium]]></description>
        <link>https://medium.com/@nigamnaman?source=rss-27c49ca9b242------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*1aGLtaN_RjJ5iaBPw8gz2A.jpeg</url>
            <title>Stories by Naman Nigam on Medium</title>
            <link>https://medium.com/@nigamnaman?source=rss-27c49ca9b242------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 16:13:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nigamnaman/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Contributions — A learning]]></title>
            <link>https://medium.com/@nigamnaman/contributions-an-inspiration-651085b2fac0?source=rss-27c49ca9b242------2</link>
            <guid isPermaLink="false">https://medium.com/p/651085b2fac0</guid>
            <category><![CDATA[feedback]]></category>
            <category><![CDATA[inspiration]]></category>
            <category><![CDATA[stackoverflow]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[contribution]]></category>
            <dc:creator><![CDATA[Naman Nigam]]></dc:creator>
            <pubDate>Tue, 30 Jun 2020 20:16:11 GMT</pubDate>
            <atom:updated>2020-07-03T01:49:11.297Z</atom:updated>
            <content:encoded><![CDATA[<h3>Contributions — A learning</h3><p>In the interest of contributing and getting back to learn as much as that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/261/1*jSKbZ_r-V32DSOW6BbdWsw.jpeg" /><figcaption>credits: google search</figcaption></figure><p>Just because you are here, you are simply a genius and the world out there needs your contribution.</p><p>I wouldn’t have thought otherwise more stupidly before I stepped into actually trying to contribute what I could and in any manner. As an example, when I started to contribute to StackOverflow, it was in order to <em>gain few badges and reputation </em>in the community and then I’d switched to a different mode for possibly learning the <em>latest feature development in a language</em> and currently I am into a mode where I <em>help people solve their production incidences</em>, <em>explore features in-depth</em> and link contributions through varied sources.</p><p>To all the people who reach out to this post,<em> </em>believe this,<em> </em><strong><em>if I could you can.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*KsmRY_J1RUvOb8wXKJ6Q0A.jpeg" /><figcaption>credits: google search</figcaption></figure><p>Additionally, this article is a pause note to think about the contributions that I have made, how they have helped others, and further, a chance for myself to learn, and to improve.</p><p>a. I believe that would bring back the revived forces for active and progressive development the next time, I consider contributing.</p><p>b. It would be an insight for me to understand the impact of those contributions and the changes I should bring in the way I contribute.</p><p>S.O has been one such place since long where I actively contribute, and that is the reason I have selectively chosen few Q&amp;A from my account and added a brief over them as the meta with the hyperlinks in the sections below. The details mention what I could learn from or share with others.</p><p>Feel free to make use of it, leave comments, provide substantial feedback, and shout out to any other type of contributions that you have made and/or are planning for. They have just been an inspiration for me as to how much there is to learn. Cheers to the cycle of learning and contributing. 🍻</p><h3>Up and Above ☝️ ⏫</h3><p><strong><em>Importance of the contributions </em></strong>—</p><ul><li><a href="https://stackoverflow.com/questions/46501388/unable-to-derive-module-descriptor-for-auto-generated-module-names-in-java-9/46501811#46501811">Unable to derive module descriptor for auto generated module names in Java 9?</a></li><li><a href="https://stackoverflow.com/questions/46494112/classloaders-hierarchy-in-java-9/46494370#46494370">Classloaders hierarchy in Java 9</a></li><li><a href="https://stackoverflow.com/questions/46244724/jdk-dateformatter-parsing-dayofweek-in-german-locale-java8-vs-java9/46245412#46245412">JDK dateformatter parsing DayOfWeek in German locale, java8 vs java9</a></li><li><a href="https://stackoverflow.com/questions/54144713/is-there-a-replacement-for-the-garbage-collection-jvm-args-in-java-11/54145207#54145207">Is there a replacement for the garbage collection JVM args in Java 11?</a></li></ul><p><strong><em>Details of the contributions —</em></strong></p><ul><li><a href="https://stackoverflow.com/questions/46230413/jdk9-an-illegal-reflective-access-operation-has-occurred-org-python-core-pysys/46230678#46230678">JDK9: An illegal reflective access operation has occurred. org.python.core.PySystemState</a></li><li><a href="https://stackoverflow.com/questions/50251798/what-is-an-illegal-reflective-access/50259167#50259167">what is an illegal reflective access</a></li><li><a href="https://stackoverflow.com/questions/46537415/is-string-deduplication-feature-of-the-g1-garbage-collector-enabled-by-default/46537937#46537937">Is String Deduplication feature of the G1 garbage collector enabled by default?</a></li><li><a href="https://stackoverflow.com/questions/53867043/what-are-the-limits-to-jshell/53868373#53868373">What are the limits to JShell?</a></li></ul><p><strong><em>Responses from the audience —</em></strong></p><ul><li><a href="https://stackoverflow.com/questions/49398894/unable-to-compile-simple-java-10-java-11-project-with-maven/51586202#51586202">Unable to compile simple Java 10 / Java 11 project with Maven</a></li><li><a href="https://stackoverflow.com/questions/46118716/fatal-error-compiling-invalid-flag-module-path/46119209#46119209">fatal error compiling invalid flag --module-path</a></li><li><a href="https://stackoverflow.com/questions/50122696/the-jdk-incubator-httpclient-module-not-found-in-java11">The jdk.incubator.httpclient module not found in Java11</a></li></ul><p><strong><em>Convenience to use </em></strong>—</p><ul><li><a href="https://stackoverflow.com/questions/41918934/what-is-the-point-of-overloaded-convenience-factory-methods-for-collections-in-j/41918976#41918976">What is the point of overloaded Convenience Factory Methods for Collections in Java 9</a></li><li><a href="https://stackoverflow.com/questions/48273090/how-to-apply-filtering-on-groupby-in-java-streams/48273152#48273152">How to apply Filtering on groupBy in java streams</a></li><li><a href="https://stackoverflow.com/questions/46930040/how-to-quit-the-jshell-and-go-back-to-the-command-line/46930091#46930091">How to quit the JShell and go back to the command-line?</a></li><li><a href="https://stackoverflow.com/questions/48661902/what-is-the-difference-between-jdeps-jdeprscan/48662241#48662241">What is the difference between Jdeps &amp; Jdeprscan?</a></li></ul><h3>Diamond Inference and LVTI 🔹</h3><p><a href="https://stackoverflow.com/questions/48428434/java-10-will-java-7s-diamond-inference-work-with-local-type-inference/48429067#48429067">Java 10: Will Java 7&#39;s Diamond Inference Work with Local Type Inference?</a></p><h3>Switch Expressions 😑 🙂 😠 😞 😆</h3><p><a href="https://stackoverflow.com/questions/16706716/using-two-values-for-one-switch-case-statement/52238221#52238221">Using two values for one switch case statement</a></p><h3>Preview Feature 🚩</h3><p><a href="https://stackoverflow.com/questions/52232681/compile-and-execute-a-jdk-preview-feature-with-maven">Compile and execute a JDK preview feature with Maven</a></p><h3>Records!? ⏺</h3><ul><li><a href="https://stackoverflow.com/questions/60796961/compatibility-issues-while-converting-classes-to-records">Compatibility issues while converting Classes to Records</a></li><li><a href="https://stackoverflow.com/questions/61152337/define-default-constructor-for-record/61152780#61152780">Define default constructor for record</a></li><li><a href="https://stackoverflow.com/questions/60795837/java-records-and-lombok-annotation-intellij">Java Records and Lombok annotation - IntelliJ</a></li><li><a href="https://stackoverflow.com/questions/61208493/do-java-14-records-actually-save-memory-over-a-similar-class-declaration-or-are/61211332#61211332">Do Java 14 records actually save memory over a similar class declaration or are they more like syntactic sugar?</a></li></ul><h3>At work 💻</h3><p><a href="https://stackoverflow.com/questions/54547078/alternative-to-jmxreporter-in-dropwizard-metricsmetrics-core-latest-release">Alternative to JmxReporter in dropwizard.metrics:metrics-core latest release</a></p><h3>Time complexity 🕕</h3><p><a href="https://stackoverflow.com/questions/54067216/is-it-possible-to-compare-two-binary-trees-in-less-than-on-log-n-time/54067497#54067497">Is it possible to compare two binary trees in less than O(n log n) time?</a></p><h3>Previous reads 📗</h3><ul><li><a href="https://medium.com/@nigamnaman/introduction-to-java-simplified-56c8b887a799">Introduction to Java  - Simplified</a></li><li><a href="https://medium.com/@nigamnaman/compiler-interface-and-experimentations-f511e34b2b6b">Compiler Interface and Experimentations</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=651085b2fac0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Veteran]]></title>
            <link>https://medium.com/@nigamnaman/the-veteran-65371d68100?source=rss-27c49ca9b242------2</link>
            <guid isPermaLink="false">https://medium.com/p/65371d68100</guid>
            <category><![CDATA[jenkins]]></category>
            <dc:creator><![CDATA[Naman Nigam]]></dc:creator>
            <pubDate>Sun, 02 Sep 2018 04:33:09 GMT</pubDate>
            <atom:updated>2018-09-02T04:33:09.175Z</atom:updated>
            <content:encoded><![CDATA[<p>Here is a story of an old lady I am sure people equal ad above of my age of experience would be aware of.</p><p>His name — Mrs. Jenkins. It was about time since the lady was living the above moderate life.</p><p>With more than usual crowd contributing to the blank pages in her life with their stories</p><p>What took me by surprise was that she ended up <br>For her ofcourse nothing has changed meanwhile and she has been as adaptive as a liquid in its container.</p><p>On our first meet, I should confess there was nothing I could have grasped from what she talked. <br>All seemed Greek to me when she was already prepared for yet another encounter to the excavation from the book of her intellect.</p><p>When after the first meetup thoughts pulled me on the bean and the next made my shoulders droop off with the evaluated number of chapters.<br>I could not simply give up on understanding and completing the prose I came up with after digesting the first lesson of many.</p><p>—</p><p>During the reign of Mrs Jenkins, there was also no other befitted Asst. as GHPRB was at that point of time.</p><p>Though Mr. Travis and Miss Coverall pitched in effectively for the rest of the world, Mrs Jenkins and I were already into conversations trying to form another good leaf along with her assistant to encourage others to live on.</p><p>—</p><p>Nexus, I remember vaguely was one of our primary clients and so we tended to nurture it as much as possible.<br>All that we could facilitate it with and make us…<br>Not that it was me and the great lady now, we had our client work along with us as well. <br>Willing to be bring out an article that could be followed by others.</p><p>—</p><p>Gradually Jenkins was back to her day to day routine and so were we with our day to day busy life.</p><p>Now when I have been a integrated particle of that primary client turned into a service. We often talk to Jenkins while we onboard clients to walk hand in hand in the journey.</p><p>You know what we ended up naming the article we wrote the last season? Guess!</p><p>Our philosophy is build it, break it and then rebuild it better.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65371d68100" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Java  - Simplified]]></title>
            <link>https://medium.com/@nigamnaman/introduction-to-java-simplified-56c8b887a799?source=rss-27c49ca9b242------2</link>
            <guid isPermaLink="false">https://medium.com/p/56c8b887a799</guid>
            <category><![CDATA[java11]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Naman Nigam]]></dc:creator>
            <pubDate>Fri, 13 Jul 2018 05:14:40 GMT</pubDate>
            <atom:updated>2018-07-13T05:14:40.011Z</atom:updated>
            <content:encoded><![CDATA[<p>Introduction to Java — Simplified</p><p>In the learning phase, Java has always been introduced to the audience via “Hello World!”. Gradually as time progresses, programs with small utilities of more importance are developed. Eventually after sometime a person learns more about build tools, packaging multiple classes and compiling projects instead of just a simple class, yet the importance of those utils never fall short.</p><p>The motivation behind the <a href="http://openjdk.java.net/jeps/330">JEP — Launch Single-File Source-Code Programs</a> seems quite similar to the intent of creating those utilities and testing them out to merge them to the larger set of classes eventually. Those utilities are mostly a single-file programs — where the whole program fits in a single source file.</p><blockquote>As of JDK 10, the java launcher operates in three modes: launching a class file, launching the main class of a JAR file, or launching the main class of a module. Here we add a new, fourth mode: launching a class declared in a source file.</blockquote><p>The effect of this is as if the source file is compiled into memory, and the first class found in the source file is executed. For example, if a file called HelloWorld.java contains a class called hello.World, then the command</p><pre>java HelloWorld.java</pre><p>is informally equivalent to</p><pre>javac -d &lt;memory&gt; HelloWorld.java<br>java -cp &lt;memory&gt; hello.World</pre><p>With the JDK-11 (build 11-ea+21) , one can now make use of the JEP being integrated into the source code. A sample execution depicted in the screenshot below :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wCCu-rnsEr9ssdOVfyOmPw.png" /><figcaption>Sample Execution — Different World</figcaption></figure><p>Any arguments placed after the name of the source file in the original command line are passed to the compiled class when it is executed. For example, if a file called Factorial.java contains a class called Factorial to calculate the factorials of its arguments, then the command to execute this would be -</p><pre>java Factorial.java 3 4 5</pre><p>Further more the JEP documents the details of the different processes like compilation and execution in such source file mode. These includes the following:</p><p><strong><em>Compilation Mode —</em></strong> The compilation proceeds as follows:</p><ul><li>Any command-line options that are relevant to the compilation environment are taken into account.</li><li>No other source files are found and compiled, as if the source path is set to an empty value.</li><li>Annotation processing is disabled, as if -proc:none is in effect.</li><li>If a <em>version</em> is specified, via the --source option, the value is used as the argument for an implicit --release option for the compilation. This sets both the source version accepted by compiler and the system API that may be used by the code in the source file.</li><li>The source file is compiled in the context of an unnamed module.</li><li>The source file should contain one or more top-level classes, the first of which is taken as the class to be executed.</li><li>The compiler does not enforce the optional restriction defined at the end of <a href="https://docs.oracle.com/javase/specs/jls/se9/html/jls-7.html#jls-7.6">JLS §7.6</a>, that a type in a named package should exist in a file whose name is composed from the type name followed by the .java extension.</li><li>If the source file contains errors, appropriate error messages are written to the standard error stream, and the launcher exits with a non-zero exit code.</li></ul><p><strong><em>Execution Mode —</em></strong> The execution proceeds as follows:</p><ul><li>The class to be executed is the first top-level class found in the source file. It must contain a declaration of the standard public static void main(String[]) method.</li><li>The compiled classes are loaded by a custom class loader, that delegates to the application class loader. (This implies that classes appearing on the application class path cannot refer to any classes declared in the source file.)</li><li>The compiled classes are executed in the context of an unnamed module, and as if --add-modules=ALL-DEFAULT is in effect (in addition to any other--add-module options that may be have been specified on the command line.)</li><li>Any arguments appearing after the name of the file on the command line are passed to the standard main method in the obvious way.</li><li>It is an error if there is a class on the application class path whose name is the same as that of the class to be executed.</li></ul><p><strong><em>Acceptable Compromise —</em></strong> A potential minor ambiguity when using a simple command-line like java HelloWorld.java. Previously, HelloWorld.java would have been interpreted as a class called java in a package called HelloWorld, but which is now resolved in favour of a file called HelloWorld.java if such a file exists. Assuming that such a class name and such a package name both violate the nearly-universally-followed naming conventions, and given the unlikeliness of such a class being on the class path and a like-named file being in the current directory.</p><p><strong><em>What’s next ? </em></strong>Apart from the command line execution, executing such Java programs with the mechanism of “Shebang files” is highly desirable on Unix-derived systems, such as macOS and Linux. That’s another aspect of people looking to invoke these program utilities from within the shell.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56c8b887a799" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HTTP/2 Client — Incubation to Standardisation]]></title>
            <link>https://medium.com/@nigamnaman/http-2-client-incubation-to-standardisation-f4a5975e5833?source=rss-27c49ca9b242------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4a5975e5833</guid>
            <category><![CDATA[java10]]></category>
            <category><![CDATA[java11]]></category>
            <category><![CDATA[http2]]></category>
            <category><![CDATA[java9]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Naman Nigam]]></dc:creator>
            <pubDate>Fri, 06 Apr 2018 17:31:01 GMT</pubDate>
            <atom:updated>2018-05-08T18:25:36.687Z</atom:updated>
            <content:encoded><![CDATA[<h3>HTTP/2 Client — Incubation to Standardisation</h3><p>You must be aware that a number of existing HTTP client APIs and implementations exist, e.g. <a href="http://eclipse.org/jetty">Jetty</a> and the <a href="https://hc.apache.org/httpcomponents-client-ga/">Apache HttpClient</a>. But then they are rather heavy-weight in terms of the numbers of packages and classes, and they don’t take advantage of newer language features such as lambda expressions, reactive programming etc.</p><blockquote><a href="https://stackoverflow.com/questions/47446481/using-incubator-http-classes-with-maven-in-java9/47446549#47446549">Most of us have given a try to HTTP/2 introduced with Java-9 release as an incubating feature.</a></blockquote><p>Now that the standardisation of the API is <a href="http://jdk.java.net/11/"><em>available with the early access builds for JDK/11</em></a>, here are few highlights one must be aware of while planning to migrate to the LTS of JDK and continuing to work with the HTTP APIs.</p><h4>1. Find &amp; Replace—</h4><p>Modularized libraries could have made use of the incubated module using a <strong><em>`requires` </em></strong>directive since the release of Java-9 as follows<em>:</em></p><pre>module com.stackoverflow.nullpointer {<br>    requires jdk.incubator.httpclient;<br>}</pre><p>Now, all that these libraries would need to change, while migrating to JDK/11 and continuing to using the HTTP module further is renaming <strong><em>`jdk.incubator.httpclient` </em></strong>to <strong><em>`java.net.http` </em></strong>in their module declarations and the result —</p><pre>module com.stackoverflow.nullpointer {<br>    requires java.net.http;<br>}</pre><h4>2. Wonders happening themselves —</h4><p>Applications, frameworks(like Maven, Gradle etc) or IDEs relying on the classpath would <a href="https://stackoverflow.com/questions/47467663/java-9-httpclient-java-lang-noclassdeffounderror-jdk-incubator-http-httpclient/47468106#47468106"><strong><em>no more need to set</em></strong></a> the:</p><pre>--add-modules jdk.incubator.httpclient</pre><p>command-line option to request the incubator module to be resolved. Being a standard module the <strong><em>`java.net.http`</em></strong> module shall be <em>resolved by</em> <em>default</em>.</p><p>Additionally, the standardisation also <em>throws away the warnings(no more now) issued at compile time, link time, and run time</em> whenever the incubator module was resolved. No wonder all of this automatically solves :</p><ul><li><a href="https://stackoverflow.com/questions/45129397">NoClassDefFoundError while trying to use jdk.incubator.http.HttpClient in java in Eclipse Oxygen</a></li><li><a href="https://stackoverflow.com/questions/47467663">HttpClient at Runtime throws java.lang.NoClassDefFoundError: jdk/incubator/http/HttpClient</a></li><li><a href="https://stackoverflow.com/questions/47446481/">Using Incubator Http Classes with Maven in Java</a>9</li></ul><h4>3. Icing on top of the Cake —</h4><p>Back-pressure and flow-control of request and response bodies in the HTTP module is implemented using the Flow APIs introduced in Java-9 based on the the <a href="http://www.reactive-streams.org/">reactive-streams</a>.</p><blockquote>The final implementation is completely asynchronous while the previous HTTP/1.1 implementation was blocking. Use of the RX Flow concept has been pushed down into the implementation, which eliminated many of the original custom concepts needed to support HTTP/2.</blockquote><blockquote>The flow of data can now be more easily traced, from the user-level request publishers and response subscribers all the way down to the underlying socket. This significantly reduces the number of concepts and complexity in the code, and maximizes the possibility of reuse between HTTP/1.1 and HTTP/2.</blockquote><p>All that looks interesting? Just got to wait for the final release of JDK/11 until 2018/09/25 for its general availability and moving your code to production. Until then keep trying your hands on the Early access builds and make use of the <a href="http://cr.openjdk.java.net/~chegar/httpclient/02/javadoc/api/java.net.http/module-summary.html">`java.net.http` module</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4a5975e5833" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Compiler Interface and Experimentations]]></title>
            <link>https://medium.com/@nigamnaman/compiler-interface-and-experimentations-f511e34b2b6b?source=rss-27c49ca9b242------2</link>
            <guid isPermaLink="false">https://medium.com/p/f511e34b2b6b</guid>
            <category><![CDATA[compilers]]></category>
            <category><![CDATA[java10]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[java9]]></category>
            <dc:creator><![CDATA[Naman Nigam]]></dc:creator>
            <pubDate>Mon, 02 Apr 2018 09:52:27 GMT</pubDate>
            <atom:updated>2018-04-07T15:19:23.530Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="http://mail.openjdk.java.net/pipermail/announce/2017-September/000233.html"><strong><em>Metropolis</em></strong></a><strong><em> </em></strong>was created to explore Java-on-Java technologies and indeed the results of which came along with Java-9 with an introduction to the <a href="http://openjdk.java.net/jeps/243"><strong><em>Java-Level JVM Compiler Interface (JVMCI)</em></strong></a><strong><em> </em></strong>which targeted AOT compilation for improving the start-up time of both small and large Java applications by compiling classes to native code prior to launching the virtual machine.</p><p>Quoting the JEP itself, the JVMCI API is composed of mechanisms for:</p><blockquote>- Accessing VM data structures required by an optimizing bytecode-to-machine-code compiler such as classes, fields, methods, profiling information etc.</blockquote><blockquote>- Installing compiled code along with all the metadata required by the JVM for managing compiled code such as GC maps and information to support deoptimization.</blockquote><blockquote>- Plugging into the JVM’s compilation system to handle servicing JVM requests to produce machine code for methods.</blockquote><p>This would certainly make the JVM compiler easier to maintain and alongwith hopefully improve than the existing solutions.</p><p>One<strong><em> </em></strong>of the immediate provider for the service has evolved with introduction to <a href="https://github.com/oracle/graal"><strong><em>Graal</em></strong></a><strong><em>, </em></strong>with GA release of Java10, where its available within the JDK for systems other than 64 bit Linux systems(to which it was restricted until JDK/9) as well.</p><p>Upfront anyone eager to make use of the JVMCI or ensuring if this is being used by the JVM and selecting a custom compiler would come up asking —</p><blockquote>How do I check and make sure JVMCI is enabled and whether it is being used by the JVM(compiler)?</blockquote><p>As <a href="http://mail.openjdk.java.net/pipermail/graal-dev/2016-June/004434.html">explained by Doug in an OpenJDK thread</a>, one can use the following code block to verify this on their system:</p><pre>private static void JVMCIQueries() {<br>    // Check if the JDK used supports JVMCI?<br>    String vm_version = System.<em>getProperty</em>(&quot;java.vm.version&quot;);<br>    System.<em>out</em>.printf(&quot;java.vm.version = %s%n&quot;, vm_version);</pre><pre>    com.sun.management.HotSpotDiagnosticMXBean bean = java.lang.management.ManagementFactory.<em>getPlatformMXBean</em>(HotSpotDiagnosticMXBean.class);</pre><pre>    // Is JVMCI enabled by default?<br>    com.sun.management.VMOption enableJVMCI = bean.getVMOption(&quot;EnableJVMCI&quot;);<br>    System.<em>out</em>.println(enableJVMCI);</pre><pre>    // Is the system using the JVMCI compiler for normal compilations?<br>    com.sun.management.VMOption useJVMCICompiler = bean.getVMOption(&quot;UseJVMCICompiler&quot;);<br>    System.<em>out</em>.println(useJVMCICompiler);</pre><pre>    // What compiler is selected?<br>    String compiler = System.<em>getProperty</em>(&quot;jvmci.Compiler&quot;);<br>    System.<em>out</em>.printf(&quot;jvmci.Compiler = %s%n&quot;, compiler);<br>}</pre><p>On executing the above on Mac OS(x64) with JDK 10 results into the following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8awENgZ4YQd2CtUAVC1YSQ.png" /><figcaption>Default on MacOS with Java10</figcaption></figure><p>You can thereafter enable the JVMCI(experimental still) using the flag —</p><pre>-XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI</pre><p>In a separate run, it would further transform the existing output to the following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*le0MoGAQvp9DGiPgQE95UQ.png" /><figcaption>EnableJVMCI with Flag</figcaption></figure><p>which means that though the JVMCI is enabled now, yet its still not in use. To use the JVMCI, one would have to add the flag —</p><pre>-XX:+UseJVMCICompiler</pre><p>which would finally mean that the system would be using the JVMCI based compiler for normal compilations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zui3vsvZdvgnDiCwMjpj9Q.png" /><figcaption>JVMCI enabled and used</figcaption></figure><p><em>What about the </em><strong><em>jvmci.Compiler </em></strong><em>value then finally?</em> A step further has to be taken to actually make use of the compiler based out of the interface(the only sample currently being <em>graal</em>). For example, this can be done using the flag —</p><pre>-Djvmci.Compiler=graal</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vvDHQZ42VUGYSjZMS1b3Pg.png" /><figcaption>JVMCI with Graal</figcaption></figure><p>…and that’s it! Now one can compile using the Graal compiler using the above flags.</p><blockquote><a href="https://visualvm.github.io/graal.html">GraalVM</a> is one of the not to distant application making use of the Graal compilation and profiling advantages which would be possible replacement for the existing VisualVM supported until JDK-8.</blockquote><p>One of the other implementation of Graal is within the JDK itself. The module representing this change within the JDK is the <strong><em>`jdk.aot` </em></strong>module.</p><p><strong>Ahead-of-Time Compilation (AOT)</strong> makes use of Graal as the code-generating backend. It actually compiles bytecode to native code (an ELF-format shared-object file) in advance, and can be applied to any bytecode.</p><blockquote>But, is it true that AOT is an Experimental feature ?</blockquote><p>AOT is not fully fledged in terms of compatibility with current Java APIs. Some of its restrictions also listed in the proposal are:</p><ul><li>Users need to use the <em>same JDK for compilation and execution</em>. Version information about `<strong><em>jaotc</em></strong>` to make use of AOT compilation.</li><li>`<strong><em>jaotc</em></strong>` used for compilation is added as a part of the libraries and are checked during load time. If the Java runtime is updated, you need to recompile the AOT compiled modules before executing them. Mismatch in JDK versions used for compilation and execution may result in application crashes.</li><li><em>Lambda expressions and other complex concepts of Java, which uses dynamically generated classes at runtime are not currently supported by AOT compiler.</em></li><li>To generate shared object (.so) files, the system needs `<strong><em>libelf</em></strong>` to be pre-installed.</li><li>The logical compilation mode for `java.base` is tiered AOT since JIT recompilation of `java.base` methods is desired to reach peak performance. Only in certain scenarios does a non-tiered AOT compilation make sense. This includes applications which require predictable behavior, when footprint is more important than peak performance, or for systems where dynamic code generation is not allowed. In these cases, AOT compilation needs to be done on the entire application and is thus experimental in JDK.</li></ul><p>These limitations can be addressed in future releases and that is when I am pretty sure the <em>Experimental</em> tag from the feature would be removed.</p><blockquote>If AOT is experimental, then how can we compile the module using AOT?</blockquote><p>To make use of the AOT compilation, the application code needs to be compiled using `<strong><em>jaotc</em></strong>` tool found within the <em>JDK_HOME/bin</em> folder considering few of the restrictions as listed above.</p><p>As stated in <a href="http://openjdk.java.net/jeps/295"><strong><em>Ahead-of-Time Compilation: AOT Usage</em></strong></a> if an AOT library has been compiled using the tool as:</p><pre>jaotc — output libHelloWorld.so HelloWorld.class</pre><p>it can be used in the execution phase as:</p><pre>java -XX:AOTLibrary=./libHelloWorld.so HelloWorld</pre><p>provided same release JVM configurations are used during both compile time and runtime.</p><p>Once the execution is triggered using the above command, the use of AOT compiled files is <em>by default ON</em>. To toggle whether or not making use of those files a new argument has been introduced that can be used in the execution phase. i.e -</p><pre><strong>-XX:+/-UseAOT</strong></pre><p>To print relevant compilation information one can also toggle the flag -</p><pre><strong>-XX:+/-PrintAOT</strong></pre><p>What’s more important and relates to our use case above and even as clearly mentioned in <em>Risks and Assumption</em> section of the proposal:</p><blockquote>If a user finds that an application starts up more slowly, or doesn’t reach the expected peak performance, or crash, they can just switch AOT off with the `-XX:-UseAOT` flag, or remove any AOT libraries.</blockquote><p>Never did I thought in those early college days that writing and making use of the compiler could sound this easy. The interface exposed certainly would see greater community contributions further once its stable and compatible with the Java APIs(possibly with JDK/11?).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f511e34b2b6b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>