{"id":829,"date":"2018-10-01T17:50:22","date_gmt":"2018-10-01T15:50:22","guid":{"rendered":"http:\/\/www.loicmathieu.fr\/wordpress\/?p=829"},"modified":"2020-05-06T10:10:15","modified_gmt":"2020-05-06T08:10:15","slug":"java-11-quoi-de-neuf","status":"publish","type":"post","link":"https:\/\/www.loicmathieu.fr\/wordpress\/informatique\/java-11-quoi-de-neuf\/","title":{"rendered":"Java 11  : what\u2019s new ?"},"content":{"rendered":"<p>Now that Java 11 is out, it is time to look at the new features that this version brings to us, developers.<\/p>\n<p>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 : <a href=\"https:\/\/www.loicmathieu.fr\/wordpress\/en\/informatique\/java-10-quoi-de-neuf\/\" rel=\"noopener noreferrer\" target=\"_blank\">Java 10<\/a>, et <a href=\"https:\/\/www.loicmathieu.fr\/wordpress\/en\/informatique\/les-nouveautes-de-java-9-pour-les-developeurs\/\" rel=\"noopener noreferrer\" target=\"_blank\">Java 9<\/a>.<\/p>\n<h3>Long Term Support<\/h3>\n<p>Java 11 is the first Java version that will be Long Term Support &#8211; LTS, so with a three years support, until the next LTS that will be Java 17. The rhythm of the LTS is one version each 3 years. Java 8 is still supported until January 2019 for a commercial use and December 2020 for a personal use (or you need to pay Oracle support that is rather affordable : 25$\/month\/cpu core).<\/p>\n<p>With Java 11, Java 10 will not be supported anymore, this is the new Java support model of Oracle. But good news for us, Oracle JDK and OpenJDK are now identical builds, other vendors are free to deliver Java version with an enhanced supported if they want to &#8230;<\/p>\n<p>Moreover, the OpenJDK build is a simple archive, it is more simple to use, so I advise you to use it. It can be found here :\u00a0\u00a0<a href=\"http:\/\/jdk.java.net\/11\"><a href=\"http:\/\/jdk.java.net\/11\">http:\/\/jdk.java.net\/11<\/a><\/a><\/p>\n<p>There&#8217;s been a lot of noise around the different Java builds and the new support mode, for more information please refer to the response done by community experts\u00a0: <a href=\"https:\/\/itnext.io\/java-is-still-free-c02aef8c9e04\">Java is still free<\/a>.<\/p>\n<h3>The JEP<\/h3>\n<p>The JEP (Java Enhancement Process) that have been included in Java 11 can be found here :\u00a0<a href=\"http:\/\/openjdk.java.net\/projects\/jdk\/11\/\" target=\"_blank\" rel=\"noopener noreferrer\"><a href=\"http:\/\/openjdk.java.net\/projects\/jdk\/11\/\">http:\/\/openjdk.java.net\/projects\/jdk\/11\/<\/a><\/a>\u00a0, when you look at them, there is not a lot of new things for the developers, and a lot of technical JEP in which you can found two new Garbage Collectors (Epsilon and ZGC), that adds to the 4 already existing ones (serial, parallel, CMS and G1). I will go back to these new GC later.<\/p>\n<p>Three JEPs are still worth mentioning :<\/p>\n<ul><li>JEP 323 :\u00a0<strong>Local-Variable Syntax for Lambda Parameters<\/strong> : allow the use of the <strong>var<\/strong> keyword, new since Java 10, in the lambda signature. It is interesting when using visibility modifiers and annotations. You can omit the parameters types of lambas when the compiler can infer them, there is no interest in using <strong>var<\/strong> in this case, but when you need to add modifiers and annotations you previously need to add the type of the parameter, you can now use <strong>var<\/strong> instead.<\/li>\n\n<li>JEP 321 :<strong>\u00a0HTTP Client (Standard)<\/strong> : the new HTTP client developed in Java 9 is no longer an incubator API but a stable one in it&#8217;s own package (java.net.http). It&#8217;s implementation has been totally reworked. It support HTTP\/2 and offers a new API totally asynchronous.<\/li>\n\n<li>JEP 330 : <strong>Launch Single-File Source-Code Programs<\/strong> : after JShell that introduce a shell for Java, here are the JEP 330 that allow to launch a simple Java program (in one file only) without compilation. The purpose is to lower the ceremonial needed to launch a Java program. The java command allows to directly launch a java program (a file with the java extension), it will then compile it on memory and launch it. On Linux, you can use shebang to make a Java file executable using for example : #!\/usr\/bin\/java<\/li>\n<\/ul>\n<p><strong>The GCs<\/strong><\/p>\n<p>Two new GCs have been integrated into Java 11:<\/p>\n<ul><li>JEP 318 :\u00a0<strong>Epsilon<\/strong>: A No-Op Garbage Collector : this GC has been developed by\u00a0Aleksey Shipilev <em>in a few hours<\/em> in the purpose of prototyping a GC that does nothing : it didn&#8217;t manage the heap, it just allocate in memory each object at creation time and when there is no more memory, it shutdown the VM! This GC has been designed for experienced people that works in the field of GC.<\/li>\n\n<li>JEP 333 : <strong>ZGC<\/strong>: A Scalable Low-Latency Garbage Collector : this GC has been developed by Oracle Labs, it aims to be a new generation of GC that can achieve very high performance with very big heaps (10ms max pause with heaps that can be TB) by sacrificing some memory and CPU. Still experimental it didn&#8217;t aims to be the replacement of G1 but target applications that need a lot of memory.<\/li>\n<\/ul>\n<p>In addition to these two new GC, there as been a lot of optimizations done for G1, that is the GC by default since Java 9. From the author of these changes, by switching to Java 11 from Java 8, we will have <strong>60% lower pauses &#8220;for free&#8221; with a reduced memory footprint<\/strong>.<\/p>\n<p>More information on these changes here : <a href=\"http:\/\/mail.openjdk.java.net\/pipermail\/hotspot-gc-use\/2018-June\/002759.html\" target=\"_blank\" rel=\"noopener noreferrer\"><a href=\"http:\/\/mail.openjdk.java.net\/pipermail\/hotspot-gc-use\/2018-June\/002759.html\">http:\/\/mail.openjdk.java.net\/pipermail\/hotspot-gc-use\/2018-June\/002759.html<\/a><\/a><\/p>\n<h3>The changes on the Java API\u00a0 :<\/h3>\n<p>Despite the lack of big API changes in Java 11, and not a lot of JEP for developers, we can find a lot of small changes that will simplified our lives :<\/p>\n<ul><li><a href=\"https:\/\/bugs.openjdk.java.net\/browse\/JDK-8137326\" target=\"_blank\" rel=\"noopener noreferrer\">JDK-8137326<\/a> : Method to compare CharSequence, StringBuilder, and StringBuffer :\u00a0 compareTo().<\/li>\n\n<li><a href=\"https:\/\/bugs.openjdk.java.net\/browse\/JDK-8196298\" target=\"_blank\" rel=\"noopener noreferrer\">JDK-8196298<\/a> : Add a no-op implementation to Reader and Writer : Reader.nullReader() and Writer.nullWriter().<\/li>\n\n<li><a href=\"https:\/\/bugs.openjdk.java.net\/browse\/JDK-8139206\" target=\"_blank\" rel=\"noopener noreferrer\">JDK-8139206<\/a> : InputStream.readNBytes(int len).<\/li>\n\n<li><a href=\"https:\/\/bugs.openjdk.java.net\/browse\/JDK-8184692\" target=\"_blank\" rel=\"noopener noreferrer\">JDK-8184692<\/a> : Pattern.asMatchPredicate : create a predicate which test if the pattern match the String in parameter.<\/li>\n\n<li><a href=\"https:\/\/bugs.openjdk.java.net\/browse\/JDK-8184693\" target=\"_blank\" rel=\"noopener noreferrer\">JDK-8184693<\/a> : Optional.isEmpty() : return true if the value is not present.<\/li>\n\n<li><a href=\"https:\/\/bugs.openjdk.java.net\/browse\/JDK-8201276\" target=\"_blank\" rel=\"noopener noreferrer\">JDK-8201276<\/a> : New method in Files to read\/write from\/to a String.<\/li>\n\n<li><a href=\"https:\/\/bugs.openjdk.java.net\/browse\/JDK-8202385\" target=\"_blank\" rel=\"noopener noreferrer\">JDK-8202385<\/a>\u00a0: New annotation java.io.Serial that allow to mark a method relative to the serialization mechanism.<\/li>\n\n<li><a href=\"https:\/\/bugs.openjdk.java.net\/browse\/JDK-8050818\" target=\"_blank\" rel=\"noopener noreferrer\">JDK-8050818<\/a> : Predicate.not() : negate a predicate.<\/li>\n\n<li><a href=\"https:\/\/bugs.openjdk.java.net\/browse\/JDK-8204375\" target=\"_blank\" rel=\"noopener noreferrer\">JDK-8204375<\/a> : TimeUnit.convert(Duration) : conversion from a Duration to a TimeUnit.<\/li>\n\n<li><a href=\"https:\/\/bugs.openjdk.java.net\/browse\/JDK-8202216\" target=\"_blank\" rel=\"noopener noreferrer\">JDK-8202216<\/a> :\u00a0New methods compareToUnsigned (buffer mismatch) to java.nio.*Buffer.<\/li>\n\n<li><a href=\"https:\/\/bugs.openjdk.java.net\/browse\/JDK-8201593\" target=\"_blank\" rel=\"noopener noreferrer\">JDK-8201593<\/a> : Display the size of the array in the message of the exception ArrayIndexOutOfBoundsException.<\/li>\n\n<li><a href=\"https:\/\/bugs.openjdk.java.net\/browse\/JDK-8060192\" target=\"_blank\" rel=\"noopener noreferrer\">JDK-8060192<\/a>\u00a0: New method Collection.toArray(). To remove a possible compatibility issue, a default method has been provided.<\/li>\n<\/ul>\n<p>The String API have a lot of new methods, others are in development for Java 12 and the support of the Raw String :<\/p>\n<ul><li><a href=\"https:\/\/bugs.openjdk.java.net\/browse\/JDK-8197594\" target=\"_blank\" rel=\"noopener noreferrer\">JDK-8197594<\/a> : String::repeat : create a String that is the repetition of the ones from which the method has been called.<\/li>\n\n<li><a href=\"https:\/\/bugs.openjdk.java.net\/browse\/JDK-8198837\" target=\"_blank\" rel=\"noopener noreferrer\">JDK-8198837<\/a> : Character::toString(int) : create a String from the character defined by the int (a code point).<\/li>\n\n<li><a href=\"https:\/\/bugs.openjdk.java.net\/browse\/JDK-8200377\" target=\"_blank\" rel=\"noopener noreferrer\">JDK-8200377<\/a> : String::strip, String::stripLeading, String::stripTrailing : create a String by removing white spaces (as defined by\u00a0 Character.isWhitespace).<\/li>\n\n<li><a href=\"https:\/\/bugs.openjdk.java.net\/browse\/JDK-8200436\" target=\"_blank\" rel=\"noopener noreferrer\">JDK-8200436<\/a>\u00a0: String::isBlank : return true if the String is empty or only include white spaces (as defined by Character.isWhitespace).<\/li>\n\n<li><a href=\"https:\/\/bugs.openjdk.java.net\/browse\/JDK-8200380\" target=\"_blank\" rel=\"noopener noreferrer\">JDK-8200380<\/a>\u00a0: String::lines : return a Stream with the lines of the String. More performance than String.split because the split is done lazy.<\/li>\n<\/ul>\n<p>To go further, an article almost exhaustive of all the changes\u00a0 :\u00a0<a href=\"https:\/\/www.azul.com\/90-new-features-and-apis-in-jdk-11\/\"><a href=\"https:\/\/www.azul.com\/90-new-features-and-apis-in-jdk-11\/\">https:\/\/www.azul.com\/90-new-features-and-apis-in-jdk-11\/<\/a>\u00a0<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>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 : Java 10, et Java 9. Long Term Support Java 11 is the first Java version that will be Long Term Support &#8211; LTS, so with a three years support,&#8230;<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/www.loicmathieu.fr\/wordpress\/informatique\/java-11-quoi-de-neuf\/\"> 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":false,"_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":[11,162,163],"class_list":["post-829","post","type-post","status-publish","format-standard","hentry","category-informatique","tag-java","tag-java11","tag-whatsnew"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":722,"url":"https:\/\/www.loicmathieu.fr\/wordpress\/informatique\/java-10-quoi-de-neuf\/","url_meta":{"origin":829,"position":0},"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":1877,"url":"https:\/\/www.loicmathieu.fr\/wordpress\/informatique\/java-24-quoi-de-neuf\/","url_meta":{"origin":829,"position":1},"title":"Java 24 : what&#8217;s new?","author":"admin","date":"Friday January 10th, 2025","format":false,"excerpt":"Now that Java 24 is features complete (Rampdown Phase One at the day of writing), it\u2019s time to walk through all the functionalities that bring 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":[]},{"id":1684,"url":"https:\/\/www.loicmathieu.fr\/wordpress\/informatique\/java-21-quoi-de-neuf\/","url_meta":{"origin":829,"position":2},"title":"Java 21: what&#8217;s new ?","author":"admin","date":"Tuesday August  8th, 2023","format":false,"excerpt":"Now that Java 21 is features complete (Rampdown Phase Two at the day of writing), it\u2019s time to walk through all the functionalities that bring 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":"Java Collection API hierarchy","src":"https:\/\/i0.wp.com\/cr.openjdk.org\/~smarks\/collections\/SequencedCollectionDiagram20220216.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/cr.openjdk.org\/~smarks\/collections\/SequencedCollectionDiagram20220216.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/cr.openjdk.org\/~smarks\/collections\/SequencedCollectionDiagram20220216.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/cr.openjdk.org\/~smarks\/collections\/SequencedCollectionDiagram20220216.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/cr.openjdk.org\/~smarks\/collections\/SequencedCollectionDiagram20220216.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/cr.openjdk.org\/~smarks\/collections\/SequencedCollectionDiagram20220216.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":1572,"url":"https:\/\/www.loicmathieu.fr\/wordpress\/informatique\/java-20-quoi-de-neuf\/","url_meta":{"origin":829,"position":3},"title":"Java 20: what&#8217;s new ?","author":"admin","date":"Wednesday December 14th, 2022","format":false,"excerpt":"Now that Java 20 is features complete (Rampdown Phase One at the day of writing), it\u2019s time to walk through all the functionalities that bring 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":[]},{"id":1839,"url":"https:\/\/www.loicmathieu.fr\/wordpress\/informatique\/java-vers-une-integrite-par-defaut-de-la-jvm\/","url_meta":{"origin":829,"position":4},"title":"Java: towards JVM integrity by default","author":"admin","date":"Tuesday February  4th, 2025","format":false,"excerpt":"This article first appeared in Programmez! Hors s\u00e9rie #16 (in french only). The Java Virtual Machine (JVM) is an execution environment that enables programs written in Java (or other languages compiled into Java bytecode) to run on different operating systems and hardware architectures. From the begining, the JVM was designed\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":1112,"url":"https:\/\/www.loicmathieu.fr\/wordpress\/informatique\/java-15-quoi-de-neuf\/","url_meta":{"origin":829,"position":5},"title":"Java 15 : what&#8217;s new ?","author":"admin","date":"Thursday July  2nd, 2020","format":false,"excerpt":"Now that Java 15 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\/829","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=829"}],"version-history":[{"count":0,"href":"https:\/\/www.loicmathieu.fr\/wordpress\/wp-json\/wp\/v2\/posts\/829\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.loicmathieu.fr\/wordpress\/wp-json\/wp\/v2\/media?parent=829"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.loicmathieu.fr\/wordpress\/wp-json\/wp\/v2\/categories?post=829"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.loicmathieu.fr\/wordpress\/wp-json\/wp\/v2\/tags?post=829"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}