{"id":652,"date":"2017-03-27T15:29:29","date_gmt":"2017-03-27T13:29:29","guid":{"rendered":"http:\/\/www.loicmathieu.fr\/wordpress\/?p=652"},"modified":"2020-05-06T10:15:03","modified_gmt":"2020-05-06T08:15:03","slug":"les-nouveautes-de-java-9-pour-les-developeurs","status":"publish","type":"post","link":"https:\/\/www.loicmathieu.fr\/wordpress\/informatique\/les-nouveautes-de-java-9-pour-les-developeurs\/","title":{"rendered":"What&#8217;s new in java 9 for developers"},"content":{"rendered":"<p>Now that Java 9 is Features Complete, it&#8217;s time to look at all the new stuff that this new version will bring us, developers using java.<\/p>\n<p>Of course, everybody have heard about the modularization of the JDK (project Jigsaw), a long awaiting project. Well, I&#8217;m not going to talk about it here! I will only speak about the new functionalities that target common developers, not the ones that target framework authors or advanced users.<\/p>\n<p>First of all, the development of Java 9 was mainly made via a set of JEP (Java Enhancement Proposal, more info here) : <a href=\"http:\/\/openjdk.java.net\/jeps\/1\"><a href=\"http:\/\/openjdk.java.net\/jeps\/1\">http:\/\/openjdk.java.net\/jeps\/1<\/a><\/a>) that we can found the list here : <a href=\"http:\/\/openjdk.java.net\/projects\/jdk9\/\"><a href=\"http:\/\/openjdk.java.net\/projects\/jdk9\/\">http:\/\/openjdk.java.net\/projects\/jdk9\/<\/a><\/a>. Of all these JEPs, I will talk about the ones that contains changes visible and usable in the everyday life of a developer.<\/p>\n<h2>JEP 102: Process API Updates<\/h2>\n<p>Managing from java the call to an external process has always been complicated. Especially if we want to do some operations that seems basic but not foreseen in the actual implementation (getting the PID, killing a process, gathering the command lines, &#8230;)<\/p>\n<p>Via the <a href=\"http:\/\/openjdk.java.net\/jeps\/102\">JEP 102 : Process API Updates<\/a>, the Process API have been greatly enhanced to allow all these information, on the process of the JVM (ProcessHandle.current()), or on a child process created by Runtime.getRuntime().exec(&#8220;your_cmd&#8221;). Moreover, like always with java, it&#8217;s compatible will all the supported OS (so with Windows AND Linux!).<\/p>\n<p>Here are some usage examples in Java 9:<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\n\/\/ Get PIDs of own processes\nSystem.out.println(\"Your pid is \" + ProcessHandle.current().getPid());\n\n\/\/start a new process and get PID\nProcess p = Runtime.getRuntime().exec(\"sleep 1h\");\nProcessHandle h = ProcessHandle.of(p.getPid()).orElseThrow(IllegalStateException::new);\n\n\/\/ Do things on exiting process : CompletableFuture !\nh.onExit().thenRun( () -&gt; System.out.println(\"Sleeper exited\") );\n\n\/\/ Get info on process : return Optional!\nSystem.out.printf(\"[%d] %s - %s\\n\", h.getPid(), h.info().user().orElse(\"unknown\"), \nh.info().commandLine().orElse(\"none\"));\n\n\/\/ Kill a process\nh.destroy();\n<\/pre>\n<h2>JEP 110: HTTP\/2 Client (Incubator)<\/h2>\n<p>HTTP\/2 is already out and a lot of websites already use it. So it is time for Java to offer a client implementation. In the mean time, the API has been revisited to offer a simpler implementation that the really old <a href=\"https:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/net\/HttpURLConnection.html\">HttpURLConnection<\/a> that was the only way to make HTTP request in Java in the JDK (and the reason why developers used third-party library like Apache HttpClient or OKHttp). With the <a href=\"http:\/\/openjdk.java.net\/jeps\/110\">JEP 110: HTTP\/2 Client (Incubator)<\/a> Java get an up-to-date HTTP client, synchronous or asynchronous (in this case, it is based on <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/util\/concurrent\/CompletableFuture.html\">CompletableFuture<\/a>).<\/p>\n<p>Here is an example of an asynchronous usage :<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\n\/**\n * The HTTP API functions asynchronously and synchronously. In asynchronous mode, work is done in threads (ExecutorService).\n *\/\npublic static void main(String[] args) throws Exception {\n  HttpClient.getDefault()\n    .request(URI.create(\"http:\/\/www.loicmathieu.fr\"))\n    .GET()\n    .responseAsync() \/\/ CompletableFuture\n    .thenAccept(httpResponse -&gt;\n        System.out.println(httpResponse.body(HttpResponse.asString()))\n    );\n  Thread.sleep(999); \/\/ Give worker thread some time.\n}\n<\/pre>\n<h2>JEP 259: Stack-Walking API<\/h2>\n<p>Going through an execution stack in Java has never been an easy task &#8230; now it is one, thanks to the Stack-Walking API : <a href=\"http:\/\/openjdk.java.net\/jeps\/259\"><a href=\"http:\/\/openjdk.java.net\/jeps\/259\">http:\/\/openjdk.java.net\/jeps\/259<\/a><\/a><\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\n\/\/ return class\/method only for our classes.\nprivate static List walkAndFilterStackframe() {\n  return StackWalker.getInstance().walk(s -&gt;\n    s.map( frame -&gt; frame.getClassName() + \"\/\" + frame.getMethodName())\n           .filter(name -&gt; name.startsWith(\"fr.loicmathieu\"))\n           .limit(10)\n           .collect(Collectors.toList()) );\n}\n<\/pre>\n<h2>JEP 269: Convenience Factory Methods for Collections<\/h2>\n<p>The JEP 256 brings one of the biggest API change in Java 9 : static methods on the interfaces of the Collection API for easily create immutable collections. More info here : <a href=\"http:\/\/openjdk.java.net\/jeps\/269\"><a href=\"http:\/\/openjdk.java.net\/jeps\/269\">http:\/\/openjdk.java.net\/jeps\/269<\/a><\/a>. This API targets the creation of small collections (list, set, map). Performance and memory utilization has been on the center of the implementation of these collections.<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\nList listOfNumbers = List.of(1, 2, 3, 4, 5);\n\nSet setOfNumbers = Set.of(1, 2, 3, 4, 5);\n\nMap mapOfString =\n    Map.of(\"key1\", \"value1\", \"key2\", \"value2\");\n\nMap moreMapOfString =\n    Map.ofEntries(\n        Map.entry(\"key1\", \"value1\"),\n        Map.entry(\"key2\", \"value2\"),\n        Map.entry(\"key1\", \"value3\")\n);\n<\/pre>\n<h2>JEP 266: More Concurrency Updates<\/h2>\n<p>The <a href=\"http:\/\/openjdk.java.net\/jeps\/266\">JEP 266: More Concurrency Updates<\/a> as it&#8217;s name didn&#8217;t indicate, contains one of the major evolution of Java 9 : an implementation of the <a href=\"http:\/\/www.reactive-streams.org\/\">Reactive Streams<\/a> in Java via the Flow class. Java will then join the very hype group of reactive languages!<\/p>\n<p>The class <a href=\"http:\/\/download.java.net\/java\/jdk9\/docs\/api\/java\/util\/concurrent\/Flow.html\">Flow<\/a> contains three interfaces for the implementation of your reactive streams :<\/p>\n<ul><li><code>Publisher : <\/code>Publish messages that the subscribers will consume. The only method is\u00a0<code>subscribe(Subscriber).<\/code><\/li>\n\n<li><code>Subscriber :&nbsp;<\/code>Subscribe to a publisher for receiving messages (via the method\u00a0<code>onNext(T)<\/code>), error messages  (<code>onError(Throwable)<\/code>), or a signal that there will be no more messages\u00a0(<code>onComplete()<\/code>). Before anything else, the publisher needs to call \u00a0<code>onSubscription(Subscription)<\/code>.<\/li>\n\n<li><code>Subscription :&nbsp;<\/code>The connection between a publisher and a subscriber. The subscriber will use it for asking for messages (<code>request(long)<\/code>) or cutting the connection\u00a0(<code>cancel()<\/code>).<\/li>\n<\/ul>\n<p>Here is an example from the tutorial available <a href=\"https:\/\/community.oracle.com\/docs\/DOC-1006738\">here<\/a> :<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\npublic class MySubscriber implements Subscriber {  \n  private Subscription subscription;  \n\n  @Override  \n  public void onSubscribe(Subscription subscription) {  \n    this.subscription = subscription;  \n    subscription.request(1); \/\/a value of Long.MAX_VALUE may be considered as effectively unbounded  \n  }  \n\n  @Override  \n  public void onNext(T item) {  \n    System.out.println(\"Got : \" + item);  \n    subscription.request(1); \/\/a value of Long.MAX_VALUE may be considered as effectively unbounded  \n  }  \n\n  @Override  \n  public void onError(Throwable t) {  \n    t.printStackTrace();  \n  }  \n\n  @Override  \n  public void onComplete() {  \n    System.out.println(\"Done\");  \n  }  \n}  \n<\/pre>\n<p>And now the Publisher example :<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\n    \/\/Create Publisher  \n    SubmissionPublisher publisher = new SubmissionPublisher();  \n\n    \/\/Register Subscriber  \n    MySubscriber subscriber = new MySubscriber();  \n    publisher.subscribe(subscriber);  \n\n    \/\/Publish items  \n    System.out.println(\"Publishing Items...\");  \n    String[] items = {\"1\", \"x\", \"2\", \"x\", \"3\", \"x\"};  \n    Arrays.asList(items).stream().forEach(i -&gt; publisher.submit(i));  \n    publisher.close();  \n<\/pre>\n<p>Moreover, there as been some changes on the CompletabeFuture API (it&#8217;s more or less an equivalent to the JavaScript promises in Java) that allow, among other things, a better composition of the CompletableFuture between them :<\/p>\n<ul><li>copy():CompletableFuture<\/li>\n\n<li>completeAsync\u200b(Supplier supplier):CompletableFuture<\/li>\n\n<li>orTimeout\u200b(long timeout,TimeUnit unit):CompletableFuture<\/li>\n\n<li>completeOnTimeout\u200b(T value, long timeout, TimeUnit unit):CompletableFuture<\/li>\n\n<li>failedFuture\u200b(Throwable ex):CompletableFuture<\/li>\n<\/ul>\n<p>For a complete list of these new methods, see the once with <strong><em>Since 9<\/em><\/strong>&#8221; in the  javadoc : <a href=\"http:\/\/download.java.net\/java\/jdk9\/docs\/api\/java\/util\/concurrent\/CompletableFuture.html\"><a href=\"http:\/\/download.java.net\/java\/jdk9\/docs\/api\/java\/util\/concurrent\/CompletableFuture.html\">http:\/\/download.java.net\/java\/jdk9\/docs\/api\/java\/util\/concurrent\/CompletableFuture.html<\/a><\/a><\/p>\n<h2>JEP 277: Enhanced Deprecation<\/h2>\n<p>The <a href=\"http:\/\/openjdk.java.net\/jeps\/277\">JEP 277: Enhanced Deprecation<\/a> allow to give extra information on the deprecation via the annotation <a>@Deprecated<\/strong>strong&gt;@Deprecated&lt;\/strong<\/a>, two new attributes that allow developers to know if the deprecated API used is intended to be deleted some day and when the deprecation occurs. The purpose is to facilitate the lifecycle of applications and allow, maybe more easily, to delete some API on the JDK itself in the future.<\/p>\n<p>Here is a small example that said that the MyDeprecatedClass is deprecated since version 9 and will be deprecated some days :<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\n@Deprecated(since=\"9\", forRemoval=true)\npublic class MyDeprecatedClass {\n    \/\/deprecated stuff\n}\n<\/pre>\n<h2>JEP 222: jshell: The Java Shell (Read-Eval-Print Loop)<\/h2>\n<p>A lot of languages (ruby, scala, python, &#8230;) have a Read-Evaluate-Print-Loop (REPL), a shell. This allow an easy learning of the language and give a direct access to the language from a simple shell. Whether it was for introducing the language, prototyping or testing, it&#8217;s always a good thing to have a shell and avoid the ceremonial of editing, compiling and packaging code.<\/p>\n<p>With Java 9, born <strong>jshell<\/strong>, the java REPL! More info on the JEP : <a href=\"http:\/\/openjdk.java.net\/jeps\/222\"><a href=\"http:\/\/openjdk.java.net\/jeps\/222\">http:\/\/openjdk.java.net\/jeps\/222<\/a><\/a><\/p>\n<p>From the command line, execute <strong>\/bin\/jshell<\/strong> and let you guide with the hep (\/help). Example below :<\/p>\n<figure id=\"attachment_678\" aria-describedby=\"caption-attachment-678\" style=\"width: 502px\" class=\"wp-caption alignnone\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-678\" src=\"https:\/\/i0.wp.com\/loicmathieu.fr\/wordpress\/wp-content\/uploads\/jshell.png?resize=502%2C353\" alt=\"jshell the Java REPL\" width=\"502\" height=\"353\" srcset=\"https:\/\/i0.wp.com\/loicmathieu.fr\/wordpress\/wp-content\/uploads\/jshell.png?w=502&amp;ssl=1 502w, https:\/\/i0.wp.com\/loicmathieu.fr\/wordpress\/wp-content\/uploads\/jshell.png?resize=300%2C211&amp;ssl=1 300w\" sizes=\"auto, (max-width: 502px) 100vw, 502px\" \/><figcaption id=\"caption-attachment-678\" class=\"wp-caption-text\">jshell the Java REPL<\/figcaption><\/figure>\n<p>An article that goes into more details : <a href=\"http:\/\/jakubdziworski.github.io\/java\/2016\/07\/31\/jshell-getting-started-examples.html\"><a href=\"http:\/\/jakubdziworski.github.io\/java\/2016\/07\/31\/jshell-getting-started-examples.html\">http:\/\/jakubdziworski.github.io\/java\/2016\/07\/31\/jshell-getting-started-examples.html<\/a><\/a><\/p>\n<h2>JEP 213: Milling Project Coin<\/h2>\n<p>The Project Coin is a project of evolution of the language, started with Java 7, with the purpose of simplification of the usage of the language for the developers, by bringing small modifications in the order of &#8220;syntactic sugar&#8221;. The <a href=\"http:\/\/openjdk.java.net\/jeps\/213\">JEP213 : Milling Project Coin<\/a> contains the implementation in Java 9 of the last parts of the project.<\/p>\n<ul><li><strong>@SafeVarargs<\/strong> allowed on private method (previously only on static or final ones)<\/li>\n\n<li>Allow the operator  for abstract class (when the type is denotable)<\/li>\n\n<li>Disallow &#8216;_&#8217; as a valid identifier to allow it&#8217;s reuse in Java 10 (traditionally used to name an unused parameter that we don&#8217;t want to use when overloading a method)<\/li>\n\n<li>Private methods in interfaces : allow code factorization in static methods (factorization of codes between two static methods in the same interface)<\/li>\n\n<li>Allow final variables (or effectively final) in a try-with-resource (example bellow) :<\/li>\n<\/ul>\n<p><strong>Before Java 9:&nbsp;<\/strong><\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\nfinal Resource r = new Resource(); \ntry (Resource r2 = r) { \u2026 }\n<\/pre>\n<p><strong>In Java 9&nbsp;:<\/strong><\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\nfinal Resource r = new Resource(); \ntry (r) { \u2026 \/\/ Cannot mutate r }\n<\/pre>\n<h2>JEP 211 : Elide Deprecation Warnings on Import Statements<\/h2>\n<p>Before : importing a deprecated class generate a warning at compile time, after &#8230; no more warning. More info here : <a href=\"http:\/\/openjdk.java.net\/jeps\/211\"><a href=\"http:\/\/openjdk.java.net\/jeps\/211\">http:\/\/openjdk.java.net\/jeps\/211<\/a><\/a><\/p>\n<h2>A lot of other changes, outside any JEP :<\/h2>\n<h3>Stream &amp; Collectors:<\/h3>\n<ul><li><strong>Stream.takeWhile(Predicate predicate):Stream<\/strong> : build a stream that contains the element of the first one while the predicate is true, as soone as the predicate becomes false, the stream is stopped.<\/li>\n\n<li><strong>Stream.dropWhile(Predicate predicate):Stream<\/strong> : the opposite of takeWhile, build a stream that contains the first false elements then all the others. While the predicate is false : drop the elements, then, include them in the stream.<\/li>\n\n<li><strong>Stream.ofNullable(T element):Stream<\/strong> : return a stream with the element or an empty one if the element is null. Avoid using Optional with the streams.<\/li>\n\n<li><strong>Stream.iterate\u200b(T, Predicate, UnaryOperator)<\/strong> : r\u00e9plique une boucle for standard : Stream.iterate(0; i -&gt; i i+1) <\/li>\n\n<li><strong>Collectors.filtering(Predicate,Collector)<\/strong> : execute a filter prior to the collector (see an example in the Javadoc that explain the differences between Stream.filter() before a collector)<\/li>\n\n<li><strong>Collectors.flatMapping\u200b(Function&gt;,Collector)<\/strong> : execute a flatMap operation prior to the collector (see an example in the Javadoc)<\/li>\n<\/ul>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\n\/\/iterate\n\/java 8 style : using for loop\nfor (int i = 0; i  i  i + 1).forEach(System.out::println);\n\n\/\/takeWhile and dropWhile\nStream stream = Stream.iterate(\"\", s -&gt; s + \"s\")\nstream.takeWhile(s -&gt; s.length()  !s.contains(\"sssss\"));\n\n\/\/ofNullable : returning Stream.empty() for null element\n\/\/java 8 style : we need to make a check to know if it's null or not\ncollection.stream()\n  .flatMap(s -&gt; {\n      Integer temp = map.get(s);\n      return temp != null ? Stream.of(temp) : Stream.empty();\n  })\n  .collect(Collectors.toList());\n\n\/\/java 9 style\ncollection.stream().flatMap(s -&gt; Stream.ofNullable(map.get(s))).collect(Collectors.toList());\n<\/pre>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\nList numbers = List.of(1, 2, 3, 5, 5);\n\nMap result = numbers.stream()\n    .filter(val -&gt; val &gt; 3)\n    .collect(Collectors.groupingBy(i -&gt;; i, Collectors.counting()));\n\nresult = numbers.stream()\n    .collect(Collectors.groupingBy(i -&gt; i, \n        Collectors.filtering(val -&gt; val &gt; 3, Collectors.counting())\n    ));\n<\/pre>\n<p>An article on this suject : <a href=\"http:\/\/www.baeldung.com\/java-9-stream-api\"><a href=\"http:\/\/www.baeldung.com\/java-9-stream-api\">http:\/\/www.baeldung.com\/java-9-stream-api<\/a><\/a><\/p>\n<h3>Optional<\/h3>\n<p>4 new methodes have been added to the Optional class :<\/p>\n<ul><li><strong>or(Supplier):Optional<\/strong> : return the same Optional or one build with the Supplier in parameter if there is no value. This allow a lazy construct of the other Optional is no value is provided.<\/li>\n\n<li><strong>ifPresent(Consumer):void<\/strong> : execute the Consumer in parameter if there is a value.<\/li>\n\n<li><strong>ifPresentOrElse(Consumer, Runnable):void<\/strong> : execute the Consumer in parameter if there is a value or execute the Runnable<\/li>\n\n<li><strong>stream():Stream<\/strong> : return a Stream of one element if there is a value or an empty Stream. This allow to use the power of the Stream API with Optional<\/li>\n<\/ul>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\n\/\/Optional.or : a lazy version of orElse\nOptional value = ...;\nOptional defaultValue = Optional.of(() -&gt; bigComputation());\nreturn value.or(defaultValue);\/\/bigComputation will be called only if value is empty\n\n\/\/Optional.ifPresent : \nOptional value = ...;\nAtomicInteger successCounter = new AtomicInteger(0);\nvalue.ifPresent(\n      v -&gt; successCounter.incrementAndGet());\n\n\/\/Optional.ifPresentOrElse : \nOptional value = ...;\nAtomicInteger successCounter = new AtomicInteger(0);\nAtomicInteger onEmptyOptionalCounter = new AtomicInteger(0);\nvalue.ifPresentOrElse(\n      v -&gt; successCounter.incrementAndGet(), \n      onEmptyOptionalCounter::incrementAndGet);\n\n\/\/Optional.stream : unify the stream and Optional API\nOptional value = Optional.of(\"a\");\nList collect = value.stream().map(String::toUpperCase).collect(Collectors.toList()); \/\/[\"A\"]\n<\/pre>\n<p>An article on this subject : <a href=\"http:\/\/www.baeldung.com\/java-9-optional\"><a href=\"http:\/\/www.baeldung.com\/java-9-optional\">http:\/\/www.baeldung.com\/java-9-optional<\/a><\/a><\/p>\n<h3>Java Time :<\/h3>\n<p>Multiple addons on the Java Time API, among other things the possibility to create streams of dates with <strong>LocalDate.datesUntil(LocalDate)<\/strong> and<strong> LocalDate.datesUntil(LocalDate, Period)<\/strong>.<\/p>\n<p>More info here : <a href=\"http:\/\/blog.joda.org\/2017\/02\/java-time-jsr-310-enhancements-java-9.html\"><a href=\"http:\/\/blog.joda.org\/2017\/02\/java-time-jsr-310-enhancements-java-9.html\">http:\/\/blog.joda.org\/2017\/02\/java-time-jsr-310-enhancements-java-9.html<\/a><\/a><\/p>\n<h3>Others :<\/h3>\n<ul><li><strong>InputStream.readAllBytes():byte[]<\/strong> : read in one time an input stream in a byte array<\/li>\n\n<li><strong>InputStream.readNBytes(byte[] b, int off, int len):int<\/strong> : read in one time an input stream in a byte array with offset and limit.<\/li>\n\n<li><strong>Objects.requireNonNullElse(T obj, T defaultObj)<\/strong> : return the first element if not null, otherwise the second. If both are null : NullPointerException !<\/li>\n\n<li><strong>Objects.requireNonNullElseGet(T obj, Supplier supplier)<\/strong> \u00a0: return the first element if not null, otherwise call supplier.get().<\/li>\n\n<li><strong>int Objects.checkIndex(int index, int length)<\/strong> : check the index : generate an IndexOutOfBoundsException if the index is less than 0 or more or equals to the size. This method might be optimized by the JVM.<\/li>\n\n<li><strong>int Objects.checkFromToIndex(int fromIndex, int toIndex, int length)<\/strong> : the same but for the sub-range fromIndex\/toIndex<\/li>\n\n<li><strong>int Objects.checkFromIndexSize(int fromIndex, int size, int length)<\/strong> : the same but for the sub-range fromIndex\/fromIndex + size<\/li>\n\n<li><strong>{Math, StrictMath}.fma()<\/strong> : implementation of a fused-multiply-accumulate (fma)<\/li>\n\n<li><strong>{Math, StrictMath}.{multiplyExact, floorDiv, floorMod}<\/strong><\/li>\n\n<li><strong>{BigDecimal, BigInteger}. sqrt()<\/strong> : square root<\/li>\n\n<li><strong>Arrays.equals(), Arrays.compare(), Arrays.compareUnsigned(), Arrays.mismatch(<\/strong> : a lot of new methods to compare arrays with a lot variations : signed, unsigned,\n equality, mismatch, with from\/to index, &#8230;<\/li>\n<\/ul>\n<h2>Performance\u00a0:<\/h2>\n<p>The following JEPs are focused on the performance of the JVM, I will not introduce them in details here (but probably in a next article), here is the list :<\/p>\n<ul><li><a href=\"http:\/\/openjdk.java.net\/jeps\/143\">JEP 143: Improve Contended Locking<\/a> : optimization of Java monitors (locks).<\/li>\n\n<li><a href=\"http:\/\/openjdk.java.net\/jeps\/193\">JEP 193: Variable Handles<\/a>\u00a0: C++ atomics &#8230;<\/li>\n\n<li><a href=\"http:\/\/openjdk.java.net\/jeps\/197\">JEP 197: Segmented Code Cache<\/a>\u00a0: the code cache (a part of the Metaspace) has been segmented to optimize the performances.<\/li>\n\n<li><a href=\"http:\/\/openjdk.java.net\/jeps\/254\">JEP 254: Compact Strings<\/a>\u00a0: enhancement of the String implementation in Java to allow a more compact version in case of  ISO-8859-1 (or Latin-1) strings. String in Java was stored by defaults in UTF-16 : each character was stored on two bytes. Now, when the string will be created, if it&#8217;s compatible with ISO-8859-1 it will be stored on one byte only.<\/li>\n\n<li><a href=\"http:\/\/openjdk.java.net\/jeps\/274\">JEP 274: Enhanced Method Handles<\/a>\u00a0: several addons to the MethodHandle API<\/li>\n\n<li><a href=\"http:\/\/openjdk.java.net\/jeps\/280\">JEP 280: Indify String Concatenation<\/a>\u00a0: <strong><em>intrasification<\/em><\/strong> of the concatenation of the strings on the JVM. Multiple concatenation strategies has been implemented, including one based on Method Handles (with StringBuilder or inline), this is the default one.<\/li>\n\n<li><a href=\"http:\/\/openjdk.java.net\/jeps\/285\">JEP 285: Spin-Wait Hints<\/a>\u00a0: for low level (power) users only : this ability to give a hint to the JVM that the application is in a spin-wait-loop &#8230;<\/li>\n<\/ul>\n<h2>Links :<\/h2>\n<p>Here are the articles that inspires me to write this one :<\/p>\n<p><a href=\"https:\/\/blogs.oracle.com\/darcy\/resource\/Devoxx\/DevoxxUS-2017-jdk9-lang-tools-libs.pdf\"><a href=\"https:\/\/blogs.oracle.com\/darcy\/resource\/Devoxx\/DevoxxUS-2017-jdk9-lang-tools-libs.pdf\">https:\/\/blogs.oracle.com\/darcy\/resource\/Devoxx\/DevoxxUS-2017-jdk9-lang-tools-libs.pdf<\/a><\/a>\n<a href=\"http:\/\/docs.oracle.com\/javase\/9\/whatsnew\/toc.htm#JSNEW-GUID-BA9D8AF6-E706-4327-8909-F6747B8F35C5\"><a href=\"http:\/\/docs.oracle.com\/javase\/9\/whatsnew\/toc.htm#JSNEW-GUID-BA9D8AF6-E706-4327-8909-F6747B8F35C5\">http:\/\/docs.oracle.com\/javase\/9\/whatsnew\/toc.htm#JSNEW-GUID-BA9D8AF6-E706-4327-8909-F6747B8F35C5<\/a><\/a>\n<a href=\"http:\/\/blog.takipi.com\/5-features-in-java-9-that-will-change-how-you-develop-software-and-2-that-wont\/\"><a href=\"http:\/\/blog.takipi.com\/5-features-in-java-9-that-will-change-how-you-develop-software-and-2-that-wont\/\">http:\/\/blog.takipi.com\/5-features-in-java-9-that-will-change-how-you-develop-software-and-2-that-wont\/<\/a><\/a>\n<a href=\"https:\/\/bentolor.github.io\/java9-in-action\"><a href=\"https:\/\/bentolor.github.io\/java9-in-action\">https:\/\/bentolor.github.io\/java9-in-action<\/a><\/a>\n<a href=\"http:\/\/www.javaworld.com\/article\/2598480\/core-java\/why-developers-should-get-excited-about-java-9.html\"><a href=\"http:\/\/www.javaworld.com\/article\/2598480\/core-java\/why-developers-should-get-excited-about-java-9.html\">http:\/\/www.javaworld.com\/article\/2598480\/core-java\/why-developers-should-get-excited-about-java-9.html<\/a><\/a>\n<a href=\"https:\/\/www.sitepoint.com\/ultimate-guide-to-java-9\/\"><a href=\"https:\/\/www.sitepoint.com\/ultimate-guide-to-java-9\/\">https:\/\/www.sitepoint.com\/ultimate-guide-to-java-9\/<\/a><\/a>\n<a href=\"http:\/\/www.javamagazine.mozaicreader.com\/JulyAug2017\"><a href=\"http:\/\/www.javamagazine.mozaicreader.com\/JulyAug2017\">http:\/\/www.javamagazine.mozaicreader.com\/JulyAug2017<\/a><\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>Now that Java 9 is Features Complete, it&#8217;s time to look at all the new stuff that this new version will bring us, developers using java. Of course, everybody have heard about the modularization of the JDK (project Jigsaw), a long awaiting project. Well, I&#8217;m not going to talk about it here! I will only speak about the new functionalities that target common developers, not the ones that target framework authors or advanced users. First of all, the development of&#8230;<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/www.loicmathieu.fr\/wordpress\/informatique\/les-nouveautes-de-java-9-pour-les-developeurs\/\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p><\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[9],"tags":[151,11,158,163],"class_list":["post-652","post","type-post","status-publish","format-standard","hentry","category-informatique","tag-informatique","tag-java","tag-java9","tag-whatsnew"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":739,"url":"https:\/\/www.loicmathieu.fr\/wordpress\/informatique\/les-optimisations-de-performances-de-java-9\/","url_meta":{"origin":652,"position":0},"title":"Java 9 performance optimizations","author":"admin","date":"Friday January 26th, 2018","format":false,"excerpt":"In a previous article on Java 9, I listed all the main new features for the developers : http:\/\/www.loicmathieu.fr\/wordpress\/en\/informatique\/les-nouveautes-de-java-9-pour-les-developeurs. Here, I will list all the main performance optimizations of Java 9. I will again go through the main JEP : JEP 143: Improve Contended Locking Optimization of Java monitors (lock\u2026","rel":"","context":"In &quot;informatique&quot;","block_context":{"text":"informatique","link":"https:\/\/www.loicmathieu.fr\/wordpress\/category\/informatique\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":722,"url":"https:\/\/www.loicmathieu.fr\/wordpress\/informatique\/java-10-quoi-de-neuf\/","url_meta":{"origin":652,"position":1},"title":"Java 10 : what&#8217;s new ?","author":"admin","date":"Monday March 26th, 2018","format":false,"excerpt":"Now that java 10 is out, it's time to look at all the new functionalities of this version. Like my previous article on Java 9, I will focus on the changes that will impact developers that uses Java leaving aside the changes that are internal\/very small\/on rarely used API. The\u2026","rel":"","context":"In &quot;informatique&quot;","block_context":{"text":"informatique","link":"https:\/\/www.loicmathieu.fr\/wordpress\/category\/informatique\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":947,"url":"https:\/\/www.loicmathieu.fr\/wordpress\/informatique\/java-13-quoi-de-neuf\/","url_meta":{"origin":652,"position":2},"title":"Java 13 : what&#8217;s new ?","author":"admin","date":"Tuesday August 13th, 2019","format":false,"excerpt":"Now that Java 13 is features complete (Release Candidate at the day of writing), it\u2019s time to walk throught all it\u2019s functionalities that brings to us, developers, this new version. This article is part of a series on what\u2019s new on the last versions of Java, for those who wants\u2026","rel":"","context":"In &quot;informatique&quot;","block_context":{"text":"informatique","link":"https:\/\/www.loicmathieu.fr\/wordpress\/category\/informatique\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":865,"url":"https:\/\/www.loicmathieu.fr\/wordpress\/informatique\/java-12-quoi-de-neuf\/","url_meta":{"origin":652,"position":3},"title":"Java 12 : what&#8217;s new","author":"admin","date":"Wednesday January 23rd, 2019","format":false,"excerpt":"Now that Java 12 is features complete (Rampdown Phase 2 at the day of writing), it's time to walk throught all it's fonctionalities that brings to us, developers, this new version. This article is part of a serie on what's new on the last versions of Java, for those who\u2026","rel":"","context":"In &quot;informatique&quot;","block_context":{"text":"informatique","link":"https:\/\/www.loicmathieu.fr\/wordpress\/category\/informatique\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":829,"url":"https:\/\/www.loicmathieu.fr\/wordpress\/informatique\/java-11-quoi-de-neuf\/","url_meta":{"origin":652,"position":4},"title":"Java 11  : what\u2019s new ?","author":"admin","date":"Monday October  1st, 2018","format":false,"excerpt":"Now that Java 11 is out, it is time to look at the new features that this version brings to us, developers. This article is part of a series on what\u2019s new on the last versions of Java, for those who wants to read the others, here are the links\u2026","rel":"","context":"In &quot;informatique&quot;","block_context":{"text":"informatique","link":"https:\/\/www.loicmathieu.fr\/wordpress\/category\/informatique\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":979,"url":"https:\/\/www.loicmathieu.fr\/wordpress\/informatique\/java-14-quoi-de-neuf\/","url_meta":{"origin":652,"position":5},"title":"Java 14 : what&#8217;s new ?","author":"admin","date":"Thursday January 16th, 2020","format":false,"excerpt":"Now that Java 14 is features complete (Rampdown Phase One at the day of writing), it\u2019s time to walk throught all it\u2019s functionalities that brings to us, developers, this new version. This article is part of a series on what\u2019s new on the last versions of Java, for those who\u2026","rel":"","context":"In &quot;informatique&quot;","block_context":{"text":"informatique","link":"https:\/\/www.loicmathieu.fr\/wordpress\/category\/informatique\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.loicmathieu.fr\/wordpress\/wp-json\/wp\/v2\/posts\/652","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.loicmathieu.fr\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.loicmathieu.fr\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.loicmathieu.fr\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.loicmathieu.fr\/wordpress\/wp-json\/wp\/v2\/comments?post=652"}],"version-history":[{"count":0,"href":"https:\/\/www.loicmathieu.fr\/wordpress\/wp-json\/wp\/v2\/posts\/652\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.loicmathieu.fr\/wordpress\/wp-json\/wp\/v2\/media?parent=652"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.loicmathieu.fr\/wordpress\/wp-json\/wp\/v2\/categories?post=652"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.loicmathieu.fr\/wordpress\/wp-json\/wp\/v2\/tags?post=652"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}