<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JDK 14 &#8211; Pauls Blog</title>
	<atom:link href="https://sterl.org/tag/jdk-14/feed/" rel="self" type="application/rss+xml" />
	<link>https://sterl.org</link>
	<description></description>
	<lastBuildDate>Fri, 19 Feb 2021 21:00:16 +0000</lastBuildDate>
	<language>de</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>
	<item>
		<title>Java language extensions</title>
		<link>https://sterl.org/2021/01/java-updates/</link>
					<comments>https://sterl.org/2021/01/java-updates/#respond</comments>
		
		<dc:creator><![CDATA[Paul Sterl]]></dc:creator>
		<pubDate>Mon, 04 Jan 2021 13:04:10 +0000</pubDate>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Java 14]]></category>
		<category><![CDATA[Java 15]]></category>
		<category><![CDATA[JDK 14]]></category>
		<category><![CDATA[JDK 15]]></category>
		<category><![CDATA[Release Notes]]></category>
		<guid isPermaLink="false">https://sterl.org/?p=622</guid>

					<description><![CDATA[Java 15 https://www.oracle.com/java/technologies/javase/15-relnote-issues.html Records Preview (JEP 384) Example on Github Text Blocks (JEP 378) Example on Github Pattern Matching Type Checks (JEP 375) Example on Github Other Java 15 language changes Nashorn JavaScript Engine removed Java 14 https://www.oracle.com/java/technologies/javase/14-relnote-issues.html Switch Expressions (JEP 361) Helpful&#160;NullPointerExceptions&#160;(JEP 358) example Java 13 https://www.oracle.com/java/technologies/javase/13-relnote-issues.html Java 12 https://www.oracle.com/java/technologies/javase/12-relnote-issues.html]]></description>
										<content:encoded><![CDATA[
<h3 class="wp-block-heading">Java 15</h3>



<p><a href="https://www.oracle.com/java/technologies/javase/15-relnote-issues.html">https://www.oracle.com/java/technologies/javase/15-relnote-issues.html</a></p>



<h3 class="wp-block-heading">Records <span class="badge">Preview</span>  (<a rel="noreferrer noopener" href="https://openjdk.java.net/jeps/359" target="_blank">JEP 384</a>)</h3>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text/x-java&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Java&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;java&quot;}">// old way using Lombok
@Data
public final class Car14 {
    @NotNull
    private final String name;
    private final int hp;
    public Car14(String name, int hp) {
        this.name = name;
        this.hp = hp;
        if (this.hp &lt; 100) {
            throw new IllegalArgumentException(&quot;HP has to be bigger than 100.&quot;);
        }
    }
}

// new Java 15 record preview
@SuppressWarnings(&quot;preview&quot;)
public record Car15(@NotNull String name, int hp) {
    public Car15 {
        if (hp &lt; 100) {
            throw new IllegalArgumentException(&quot;HP has to be bigger than 100.&quot;);
        }
    }
}</pre></div>



<p><a href="https://github.com/sterlp/training/blob/master/java-changes/src/test/java/org/sterl/java/_15/RecordTest.java" data-type="URL" data-id="https://github.com/sterlp/training/blob/master/java-changes/src/test/java/org/sterl/java/_15/RecordTest.java">Example on Github</a></p>



<h3 class="wp-block-heading">Text Blocks (<a href="https://openjdk.java.net/jeps/378" target="_blank" rel="noreferrer noopener">JEP 378</a>)</h3>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text/x-java&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Java&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;java&quot;}">final String textBlockString = 
    &quot;&quot;&quot;
    Hello cool
        text block &lt;b&gt;including&lt;/b&gt; also HTML &quot;tags&quot;.
    Json: {&quot;name&quot;:&quot;F1&quot;,&quot;hp&quot;:100
    &quot;&quot;&quot;;</pre></div>



<p><a href="https://github.com/sterlp/training/blob/master/java-changes/src/test/java/org/sterl/java/_15/TextBlocksTest.java">Example on Github</a></p>



<h3 class="wp-block-heading">Pattern Matching Type Checks (<a href="https://openjdk.java.net/jeps/375" target="_blank" rel="noreferrer noopener">JEP 375</a>)</h3>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text/x-java&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Java&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;java&quot;}">// pre Java 15
final Object type = Long.valueOf(4L);
if (type instanceof Long &amp;&amp; ((Long)type).longValue() &gt; 3) {
    Long longValue = (Long)type;
    System.out.println(longValue);
}

// new Java 15
final Object type = Long.valueOf(4L);
if (type instanceof Long longValue &amp;&amp; longValue.longValue() &gt; 3) {
    System.out.println(longValue);
}</pre></div>



<p><a href="https://github.com/sterlp/training/blob/master/java-changes/src/test/java/org/sterl/java/_15/PatternMatchingTypeChecksTest.java">Example on Github</a></p>



<h4 class="wp-block-heading">Other Java 15 language changes</h4>



<ul class="wp-block-list"><li>Nashorn JavaScript Engine <strong>removed</strong></li></ul>



<h3 class="wp-block-heading">Java 14</h3>



<p><a href="https://www.oracle.com/java/technologies/javase/14-relnote-issues.html">https://www.oracle.com/java/technologies/javase/14-relnote-issues.html</a></p>



<h4 class="wp-block-heading">Switch Expressions (<a rel="noreferrer noopener" href="https://openjdk.java.net/jeps/361" target="_blank">JEP 361</a>)</h4>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text/x-java&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Java&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;java&quot;}">// old
Strategy preJava14;
switch (movement) {
    case &quot;up&quot;:
    case &quot;w&quot;: 
        preJava14 = Strategy.UP;
        break;
    case &quot;down&quot;:
    case &quot;s&quot;:
        preJava14 = Strategy.DOWN;
        break;
    case &quot;d&quot;:
        preJava14 = Strategy.RIGHT;
        break;
    case &quot;left&quot;:
    case &quot;a&quot;: {
            System.out.println(&quot;going left ...&quot;);
            preJava14 = Strategy.LEFT;
        }
        break;
    default: throw new IllegalArgumentException(&quot;Unexpected movement: &quot; + movement);
}
System.out.println(&quot;Java 14: &quot; + preJava14);

// new Java 14
final Strategy movementStrategy = switch (movement) {
    case &quot;up&quot;, &quot;w&quot; -&gt; Strategy.UP;
    case &quot;down&quot;, &quot;s&quot; -&gt; Strategy.DOWN;
    case &quot;d&quot; -&gt; Strategy.RIGHT;
    case &quot;left&quot;, &quot;a&quot; -&gt; {
        System.out.println(&quot;going left ...&quot;);
        yield Strategy.LEFT;
    }
    default -&gt; throw new IllegalArgumentException(&quot;Unexpected movement: &quot; + movement);
};</pre></div>



<ul class="wp-block-list"><li>Helpful&nbsp;<code>NullPointerExceptions</code>&nbsp;(<a href="https://openjdk.java.net/jeps/358">JEP 358</a>) <a href="https://github.com/sterlp/training/blob/master/java-changes/src/test/java/org/sterl/java/_14/HelpfulNullPointerExceptionsTest.java">example</a></li></ul>



<h3 class="wp-block-heading">Java 13</h3>



<p><a href="https://www.oracle.com/java/technologies/javase/13-relnote-issues.html">https://www.oracle.com/java/technologies/javase/13-relnote-issues.html</a></p>



<h3 class="wp-block-heading">Java 12</h3>



<p><a href="https://www.oracle.com/java/technologies/javase/12-relnote-issues.html">https://www.oracle.com/java/technologies/javase/12-relnote-issues.html</a></p>



<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://sterl.org/2021/01/java-updates/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
