{"id":947,"date":"2019-08-13T12:10:33","date_gmt":"2019-08-13T10:10:33","guid":{"rendered":"http:\/\/www.loicmathieu.fr\/wordpress\/?p=947"},"modified":"2020-05-06T09:53:37","modified_gmt":"2020-05-06T07:53:37","slug":"java-13-quoi-de-neuf","status":"publish","type":"post","link":"https:\/\/www.loicmathieu.fr\/wordpress\/informatique\/java-13-quoi-de-neuf\/","title":{"rendered":"Java 13 : what&#8217;s new ?"},"content":{"rendered":"<p>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.<\/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=\"http:\/\/www.loicmathieu.fr\/wordpress\/informatique\/java-12-quoi-de-neuf\/\">Java 12<\/a>, <a href=\"http:\/\/www.loicmathieu.fr\/wordpress\/informatique\/java-11-quoi-de-neuf\/\">Java 11<\/a>,\u00a0<a href=\"http:\/\/www.loicmathieu.fr\/wordpress\/informatique\/java-10-quoi-de-neuf\/\">Java 10,<\/a> and <a href=\"http:\/\/www.loicmathieu.fr\/wordpress\/informatique\/les-nouveautes-de-java-9-pour-les-developeurs\/\">Java 9<\/a>.<\/p>\n<p>Force is to note that, again, there is not a lot of new functionalities in this release. Besides the new Text Block that replaces the Raw Strings, there is not a lot of modifications on the JDK.<\/p>\n<h2>JEP-355: Text Blocks (Preview)<\/h2>\n<p>This is the main new functionality in the version 13 of Java, the capability to write <strong>Text Blocks<\/strong> : a new type of String Literal that allow to write them on multiple lines.<\/p>\n<p>Text Blocks don&#8217;t add a lot of new functionalities (they are not raw string, there is no string interpolation, &#8230;), they only allow to write strings on multiple lines, and automatically manage the indentation for us. Instead of using a single escape character, they use an escape sequence: <code>&quot;&quot;&quot;<\/code><\/p>\n<pre>System.out.println(\"\"\"\n\u00a0\u00a0\u00a0\u00a0Hello,\n\u00a0\u00a0\u00a0\u00a0multiline\n\u00a0\u00a0\u00a0\u00a0text blocks!\"\"\")\n<\/pre>\n<p>Speaking of indentation, this is what is the most specific about this new functionality : a complex algorithm has been implemented to keep the indentation<em> as the developer intended to define<\/em> it. Concretely, the indentation is done by deleting the identation before the first letter (so here we delete the indentation before the H of Hello), this is called the incidental indentation.<\/p>\n<p>The main rules of Text Blocks are :<\/p>\n<ul><li>Start by <code>&quot;&quot;&quot;<\/code> and a new line.<\/li>\n\n<li>Delete the incidental indentation and the first line break.<\/li>\n\n<li>Keep the rest of the indentation.<\/li>\n\n<li>End by <code>&quot;&quot;&quot;<\/code> without line break. If there is one it will be added to the end of the string !<\/li>\n\n<li>If there is a new line at the end of the Text Block, it&#8217;s position will define the incidental indentation instead of the Text Block first character.<\/li>\n\n<li>You can use double-quote inside a Text Block.<\/li>\n<\/ul>\n<p>To implement Text Blocks, new methods has been added to the String class. But as this functionality is a preview feature, you need to activate it via <code>--enable-preview<\/code> to be able to use them : JDK-8203444 &#8211; String::formatted, JDK-8223775 &#8211; String::stripIndent et JDK-8223781 &#8211; String::translateEscapes.<\/p>\n<p>More info : <a href=\"https:\/\/openjdk.java.net\/jeps\/355\"><a href=\"https:\/\/openjdk.java.net\/jeps\/355\">https:\/\/openjdk.java.net\/jeps\/355<\/a><\/a> and in this very complete article by Nicolai Parlog : <a href=\"https:\/\/blog.codefx.org\/java\/text-blocks\/\"><a href=\"https:\/\/blog.codefx.org\/java\/text-blocks\/\">https:\/\/blog.codefx.org\/java\/text-blocks\/<\/a><\/a><\/p>\n<p>You can also read the <em>Programmer&#8217;s Guide To Text Blocks <\/em>by Jim Laskey and Stuart Marks : <a href=\"http:\/\/cr.openjdk.java.net\/~jlaskey\/Strings\/TextBlocksGuide_v8.html\"><a href=\"http:\/\/cr.openjdk.java.net\/~jlaskey\/Strings\/TextBlocksGuide_v8.html\">http:\/\/cr.openjdk.java.net\/~jlaskey\/Strings\/TextBlocksGuide_v8.html<\/a><\/a><\/p>\n<h2>JEP 354 &#8211; Switch Expressions (Preview)<\/h2>\n<p>Unfortunately, Switch Expressions stays in preview! Their implementation has been modified, a new keyword <code>yield<\/code> has been created to <em>return <\/em>a value from a switch branch. Before we use <code>break &quot;value&quot;;<\/code> now we need to use <code>yield &quot;value&quot;;<\/code>.<\/p>\n<p>The idea behind this is to be able to reuse this keyword later (for example for if expression ?).<\/p>\n<p>More info in the JEP : <a href=\"https:\/\/openjdk.java.net\/jeps\/354\"><a href=\"https:\/\/openjdk.java.net\/jeps\/354\">https:\/\/openjdk.java.net\/jeps\/354<\/a><\/a><\/p>\n<h2>Shenandoah:<\/h2>\n<p>A lot of news in Shenandoah, the new GC implemented par Red Hat and integrated into OpenJDK.<\/p>\n<p>The more important ones are the support of 32 bits JVM and the elimination of the <em>forwarding pointer word\u00a0<\/em>that allow to reduce the memory footprint of Shenandoah with the addons of l<em>oad reference barriers.<\/em><\/p>\n<p>More info in this series of 3 posts on the Red Hat blog : <a href=\"https:\/\/developers.redhat.com\/blog\/?p=602377\"><a href=\"https:\/\/developers.redhat.com\/blog\/?p=602377\">https:\/\/developers.redhat.com\/blog\/?p=602377<\/a><\/a><\/p>\n<h2>Other<\/h2>\n<p>Via the <a href=\"https:\/\/openjdk.java.net\/jeps\/353\">JEP 353: Reimplement the Legacy Socket API<\/a>, the API <code>java.net.Socket<\/code> and <code>java.net.ServerSocket<\/code> has been totaly rewritten, their implementations dated back to JDK 1.0, and the work in progress on threads, a.k.a. fibers, for the <a href=\"https:\/\/openjdk.java.net\/projects\/loom\">Project Loom<\/a> needed some modifications.<\/p>\n<p>There is also some news around security : <a href=\"https:\/\/seanjmullan.org\/blog\/2019\/08\/05\/jdk13\"><a href=\"https:\/\/seanjmullan.org\/blog\/2019\/08\/05\/jdk13\">https:\/\/seanjmullan.org\/blog\/2019\/08\/05\/jdk13<\/a><\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>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 to read the others, here are the links : Java 12, Java 11,\u00a0Java 10, and Java 9. Force is to note that, again, there is not a lot of new&#8230;<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/www.loicmathieu.fr\/wordpress\/informatique\/java-13-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,175,163],"class_list":["post-947","post","type-post","status-publish","format-standard","hentry","category-informatique","tag-java","tag-java13","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":947,"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":1112,"url":"https:\/\/www.loicmathieu.fr\/wordpress\/informatique\/java-15-quoi-de-neuf\/","url_meta":{"origin":947,"position":1},"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":[]},{"id":652,"url":"https:\/\/www.loicmathieu.fr\/wordpress\/informatique\/les-nouveautes-de-java-9-pour-les-developeurs\/","url_meta":{"origin":947,"position":2},"title":"What&#8217;s new in java 9 for developers","author":"admin","date":"Monday March 27th, 2017","format":false,"excerpt":"Sorry, this entry is only available in Fran\u00e7ais.","rel":"","context":"In &quot;informatique&quot;","block_context":{"text":"informatique","link":"https:\/\/www.loicmathieu.fr\/wordpress\/category\/informatique\/"},"img":{"alt_text":"jshell the Java REPL","src":"https:\/\/i0.wp.com\/loicmathieu.fr\/wordpress\/wp-content\/uploads\/jshell.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":865,"url":"https:\/\/www.loicmathieu.fr\/wordpress\/informatique\/java-12-quoi-de-neuf\/","url_meta":{"origin":947,"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":1375,"url":"https:\/\/www.loicmathieu.fr\/wordpress\/informatique\/java-18-quoi-de-neuf\/","url_meta":{"origin":947,"position":4},"title":"Java 18 : what&#8217;s new ?","author":"admin","date":"Tuesday January  4th, 2022","format":false,"excerpt":"Now that Java 18 is features complete (Rampdown Phase One at the day of writing), it\u2019s time to walk throught all the 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":[]},{"id":1684,"url":"https:\/\/www.loicmathieu.fr\/wordpress\/informatique\/java-21-quoi-de-neuf\/","url_meta":{"origin":947,"position":5},"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":[]}],"_links":{"self":[{"href":"https:\/\/www.loicmathieu.fr\/wordpress\/wp-json\/wp\/v2\/posts\/947","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=947"}],"version-history":[{"count":0,"href":"https:\/\/www.loicmathieu.fr\/wordpress\/wp-json\/wp\/v2\/posts\/947\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.loicmathieu.fr\/wordpress\/wp-json\/wp\/v2\/media?parent=947"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.loicmathieu.fr\/wordpress\/wp-json\/wp\/v2\/categories?post=947"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.loicmathieu.fr\/wordpress\/wp-json\/wp\/v2\/tags?post=947"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}