<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" 
  xmlns:content="http://purl.org/rss/1.0/modules/content/" 
  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:media="http://search.yahoo.com/mrss/">
  <channel>
    <title>new-feature on Solid Soft</title>
    <link>https://blog.solidsoft.pl/tags/new-feature/</link>
    <description>Recent content in new-feature on Solid Soft</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <copyright>©{year}, All Rights Reserved</copyright>
    <lastBuildDate>Tue, 03 Mar 2020 10:00:00 +0200</lastBuildDate>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>2</sy:updateFrequency>
    
        <atom:link href="https://blog.solidsoft.pl/tags/new-feature/index.xml" rel="self" type="application/rss+xml" />
    
    
    

      
      <item>
        <title>Improved &#39;instanceof&#39; operator in Java 14</title>
        <link>https://blog.solidsoft.pl/2020/03/03/improved-instanceof-operator-in-java-14/</link>
        <pubDate>Tue, 03 Mar 2020 10:00:00 +0200</pubDate>
        
        <atom:modified>Tue, 03 Mar 2020 10:00:00 +0200</atom:modified>
        <guid>https://blog.solidsoft.pl/2020/03/03/improved-instanceof-operator-in-java-14/</guid>
        <description>Make your code simpler with implicit casting in improved instanceof operator in Java 14.
  The improvements in the instanceof operator (JEP 305 ) are not the most important feature of approaching Java 14. However, it finally implements the syntactic sugar that was available in Groovy for years, so I want to have my readers aware of it and simplify their code (once migrated to Java 14+ :-) ).</description>
        <content:encoded>&lt;blockquote&gt;
&lt;p&gt;Make your code simpler with implicit casting in improved &lt;code&gt;instanceof&lt;/code&gt; operator in Java 14.&lt;/p&gt;
&lt;/blockquote&gt;


&lt;figure &gt;
  
    &lt;img src=&#34;https://blog.solidsoft.pl/images/posts/2020/improved-instanceof-java14.jpg&#34; alt=&#34;Color small blocks with different shapes&#34; style=&#34;width:;height:;&#34;/&gt;
  
  
&lt;/figure&gt;

&lt;br&gt;
&lt;p&gt;The improvements in the &lt;code&gt;instanceof&lt;/code&gt; operator (&lt;a href=&#34;https://openjdk.java.net/jeps/305&#34; target=&#34;_blank&#34;&gt;JEP 305&lt;/a&gt;
) are not the most important feature of approaching Java 14. However, it finally implements the syntactic sugar that was available in Groovy for years, so I want to have my readers aware of it and simplify their code (once migrated to Java 14+ :-) ).&lt;/p&gt;
&lt;p&gt;&amp;ldquo;instance of&amp;rdquo; usually is perceived as a scratch in well designed object oriented system. Nevertheless, there are places where it simplifies the code greatly and/or is the only sensible way to go.&lt;/p&gt;
&lt;h2 id=&#34;the-usual-way&#34;&gt;The usual way&lt;/h2&gt;
&lt;p&gt;Double type checking in Java code is considered as something &amp;ldquo;normal&amp;rdquo; (or better something &amp;ldquo;common&amp;rdquo;):&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;o&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;insteanceof&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
    &lt;span class=&#34;n&#34;&gt;useString&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;((&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;o&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;);&lt;/span&gt;
&lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The same with combined condition checking:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;o&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;instanceof&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;String&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;(((&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;o&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;).&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;lenght&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;10&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
    &lt;span class=&#34;o&#34;&gt;...&lt;/span&gt;
&lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It looks even worse if the class name is longer, e.g. &lt;code&gt;ContentHandlerAlreadyRegisteredException&lt;/code&gt; (while received just &lt;code&gt;Exception&lt;/code&gt; or &lt;code&gt;Throwable&lt;/code&gt;).&lt;/p&gt;
&lt;h2 id=&#34;the-new-way-java-14&#34;&gt;The new way (Java 14+)&lt;/h2&gt;
&lt;p&gt;With fast approaching Java 14 (GA scheduler on 2020-03-17) it becomes much simpler:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;o&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;instanceof&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;String&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;s&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
    &lt;span class=&#34;n&#34;&gt;useString&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;s&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;);&lt;/span&gt;
&lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The new binding variable (of type &lt;code&gt;String&lt;/code&gt;) is available in the &lt;code&gt;if&lt;/code&gt; block.&lt;/p&gt;
&lt;p&gt;It works also for combined condition checking:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;o&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;instanceof&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;String&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;s&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;s&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;length&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;10&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
    &lt;span class=&#34;o&#34;&gt;...&lt;/span&gt;
&lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It can be used also in more complex &lt;code&gt;if..elseif..else&lt;/code&gt; constructions. However, in those cases, the new &lt;code&gt;switch..case&lt;/code&gt; syntax with the pattern matching allowing - still on the &lt;a href=&#34;https://cr.openjdk.java.net/~briangoetz/amber/pattern-match.html&#34; target=&#34;_blank&#34;&gt;work desk&lt;/a&gt;
 - would be even more handy.&lt;/p&gt;
&lt;div class=&#34;alert alert-warning&#34; role=&#34;alert&#34; data-dir=&#34;ltr&#34;&gt;It is worth to remember that as a preview feature it has to explicitly enabled. See my &lt;a href=&#34;https://blog.solidsoft.pl/2020/03/03/improved-instanceof-operator-in-java-14/&#34;&gt;other post&lt;/a&gt; how to do it in Idea, Gradle, Maven and command line.&lt;/div&gt;

&lt;h2 id=&#34;the-groovy-way&#34;&gt;The Groovy way&lt;/h2&gt;
&lt;p&gt;I wouldn&amp;rsquo;t be myself, if I skipped a comparison with Groovy :-). In Groovy that double type checking mitigation has been available for years. Even better, thanks to the AST transformation there is no need to define an extra variable. We can just use the original name which is visible with proper typing inside the block:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-groovy&#34; data-lang=&#34;groovy&#34;&gt;&lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;o&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;instanceof&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
    &lt;span class=&#34;n&#34;&gt;useString&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;o&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;
&lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It is dead simple, but I have to admit that an extra binding variable with a custom name might be perceived as something slightly more readable with bigger block of code (which anyway could be usually moved to a separate method).&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;switch..case&lt;/code&gt; statement is very powerful in Groovy. Checking the instance type is very straightforward:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-groovy&#34; data-lang=&#34;groovy&#34;&gt;&lt;span class=&#34;k&#34;&gt;switch&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;o&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
    &lt;span class=&#34;k&#34;&gt;case&lt;/span&gt; &lt;span class=&#34;nl&#34;&gt;String:&lt;/span&gt;
        &lt;span class=&#34;n&#34;&gt;println&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;String&amp;#34;&lt;/span&gt;
        &lt;span class=&#34;k&#34;&gt;break&lt;/span&gt;
    &lt;span class=&#34;k&#34;&gt;case&lt;/span&gt; &lt;span class=&#34;nl&#34;&gt;Integer:&lt;/span&gt;
        &lt;span class=&#34;n&#34;&gt;println&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;Integer&amp;#34;&lt;/span&gt;
        &lt;span class=&#34;k&#34;&gt;break&lt;/span&gt;
    &lt;span class=&#34;k&#34;&gt;default&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;:&lt;/span&gt;
        &lt;span class=&#34;k&#34;&gt;throw&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;new&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;IllegalArgumentException&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(...)&lt;/span&gt;
&lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;However, even in Groovy 3, there is no type changing withing the scope (available in the &lt;code&gt;if..else&lt;/code&gt;). As a result the following works without code completion with dynamic Groovy and fails with &lt;code&gt;@CompileStatic&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-groovy&#34; data-lang=&#34;groovy&#34;&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;sortItOut&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Object&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;o&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;

    &lt;span class=&#34;k&#34;&gt;switch&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;o&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
      &lt;span class=&#34;k&#34;&gt;case&lt;/span&gt; &lt;span class=&#34;nl&#34;&gt;String:&lt;/span&gt;
        &lt;span class=&#34;n&#34;&gt;println&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;String: ${o.length()}&amp;#34;&lt;/span&gt; &lt;span class=&#34;c1&#34;&gt;//only in dynamic Groovy
&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;        &lt;span class=&#34;k&#34;&gt;break&lt;/span&gt;
      &lt;span class=&#34;k&#34;&gt;case&lt;/span&gt; &lt;span class=&#34;nl&#34;&gt;Integer:&lt;/span&gt;
        &lt;span class=&#34;n&#34;&gt;println&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;Integer: ${o.longValue()}&amp;#34;&lt;/span&gt; &lt;span class=&#34;c1&#34;&gt;//only in dynamic Groovy 
&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;        &lt;span class=&#34;k&#34;&gt;break&lt;/span&gt;
      &lt;span class=&#34;k&#34;&gt;default&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;:&lt;/span&gt;
        &lt;span class=&#34;k&#34;&gt;throw&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;new&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;IllegalArgumentException&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;o&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;toString&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;())&lt;/span&gt;
    &lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
  &lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I have to raise a ticket to support that ;-)&lt;/p&gt;
&lt;p&gt;Update. It&amp;rsquo;s been already proposed - &lt;a href=&#34;https://issues.apache.org/jira/browse/GROOVY-8411&#34; target=&#34;_blank&#34;&gt;GROOVY-8411&lt;/a&gt;
.&lt;/p&gt;
&lt;h2 id=&#34;summary&#34;&gt;Summary&lt;/h2&gt;
&lt;p&gt;There is a number of small, yet useful changes introduced in Java 12+ (or waiting for implementation in the incoming releases). Multiline string, &lt;code&gt;yield&lt;/code&gt; in &lt;code&gt;switch..case&lt;/code&gt; or smarter &lt;code&gt;NullObjectExcpetion&lt;/code&gt; just to mention a few. Thanks to that Java becomes more and more compact (although Groovy or Kotlin are far ahead on that field).&lt;/p&gt;
&lt;span style=&#34;opacity: 0.6&#34;&gt;Lead photo by &lt;a href=&#34;https://pixabay.com/users/_alicja_-5975425/&#34;&gt;Alicja&lt;/a&gt;, published in &lt;a href=&#34;https://pixabay.com/photos/pads-toy-education-play-colored-4771296/&#34;&gt;Pixabay&lt;/a&gt;, Pixabay License.&lt;/span&gt;
</content:encoded>
        <dc:creator>Marcin Zajączkowski</dc:creator>
        <media:content url="https://blog.solidsoft.pl//images/posts/2020/improved-instanceof-java14-thumbnail.jpg" medium="image"><media:title type="html">featured image</media:title></media:content>
        
        <media:content url="https://blog.solidsoft.pl//images/posts/2020/improved-instanceof-java14.jpg" medium="image"><media:title type="html">meta image</media:title></media:content>
        
          
            
              <category>java</category>
            
          
            
              <category>java14</category>
            
          
            
              <category>new-feature</category>
            
          
        
        
          
            
              <category>Other</category>
            
          
        
        
      </item>
      
      <item>
        <title>Enable Java 14 preview features in Gradle, Maven and Idea</title>
        <link>https://blog.solidsoft.pl/2020/03/02/enable-java-14-preview-features-in-gradle-maven-and-idea/</link>
        <pubDate>Mon, 02 Mar 2020 09:00:00 +0200</pubDate>
        
        <atom:modified>Mon, 02 Mar 2020 09:00:00 +0200</atom:modified>
        <guid>https://blog.solidsoft.pl/2020/03/02/enable-java-14-preview-features-in-gradle-maven-and-idea/</guid>
        <description>Discover how to enable Java 14 preview features in Gradle, Maven, Idea and Command line.
  Writing my next post about the improved instanceof operator in Java 14, I have noticed that enabling the preview features might be a good candidate for a short blog post to reference in other places.
Let&amp;rsquo;s start with the basics.
Command line Standalone files with preview features of Java 14 can be easily run from the command line (especially as calling javac is no longer needed):</description>
        <content:encoded>&lt;blockquote&gt;
&lt;p&gt;Discover how to enable Java 14 preview features in Gradle, Maven, Idea and Command line.&lt;/p&gt;
&lt;/blockquote&gt;


&lt;figure &gt;
  
    &lt;img src=&#34;https://blog.solidsoft.pl/images/posts/2020/enable-java14-preview-features-ratio.jpg&#34; alt=&#34;Bride undrawing a curtain&#34; style=&#34;width:;height:;&#34;/&gt;
  
  
&lt;/figure&gt;

&lt;br&gt;
&lt;p&gt;Writing my &lt;a href=&#34;https://blog.solidsoft.pl/2020/03/03/improved-instanceof-operator-in-java-14/&#34;&gt;next post&lt;/a&gt;
 about the improved &lt;code&gt;instanceof&lt;/code&gt; operator in Java 14, I have noticed that enabling the preview features might be a good candidate for a short blog post to reference in other places.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s start with the basics.&lt;/p&gt;
&lt;h2 id=&#34;command-line&#34;&gt;Command line&lt;/h2&gt;
&lt;p&gt;Standalone files with preview features of Java 14 can be easily run from the command line (especially as calling &lt;code&gt;javac&lt;/code&gt; is no longer needed):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;java --source 14 --enable-preview J14Instanceof.java
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;idea&#34;&gt;Idea&lt;/h2&gt;
&lt;p&gt;IntelliJ IDEA is known to support the new features and technologies in advance. With Java 14, it is available in Idea 2020.1, which the EAP (Early Access Program) version has been &lt;a href=&#34;https://blog.jetbrains.com/idea/2020/01/intellij-idea-2020-1-eap/#pattern_matching&#34; target=&#34;_blank&#34;&gt;released in January 2020&lt;/a&gt;
.&lt;/p&gt;
&lt;p&gt;It should be enough to just change the Java language settings in a given project to Java 14.&lt;/p&gt;
&lt;h2 id=&#34;maven&#34;&gt;Maven&lt;/h2&gt;
&lt;p&gt;For Maven, just a few lines of XML should be required (I haven&amp;rsquo;t tested, I&amp;rsquo;m a Gradle guy ;-) :&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-xml&#34; data-lang=&#34;xml&#34;&gt;&lt;span class=&#34;nt&#34;&gt;&amp;lt;build&amp;gt;&lt;/span&gt;
    &lt;span class=&#34;nt&#34;&gt;&amp;lt;plugins&amp;gt;&lt;/span&gt;
        &lt;span class=&#34;nt&#34;&gt;&amp;lt;plugin&amp;gt;&lt;/span&gt;
            &lt;span class=&#34;nt&#34;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.apache.maven.plugins&lt;span class=&#34;nt&#34;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
            &lt;span class=&#34;nt&#34;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;maven-compiler-plugin&lt;span class=&#34;nt&#34;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
            &lt;span class=&#34;nt&#34;&gt;&amp;lt;version&amp;gt;&lt;/span&gt;3.8.1&lt;span class=&#34;nt&#34;&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
            &lt;span class=&#34;nt&#34;&gt;&amp;lt;configuration&amp;gt;&lt;/span&gt;
                &lt;span class=&#34;nt&#34;&gt;&amp;lt;release&amp;gt;&lt;/span&gt;14&lt;span class=&#34;nt&#34;&gt;&amp;lt;/release&amp;gt;&lt;/span&gt;
                &lt;span class=&#34;nt&#34;&gt;&amp;lt;compilerArgs&amp;gt;&lt;/span&gt;--enable-preview&lt;span class=&#34;nt&#34;&gt;&amp;lt;/compilerArgs&amp;gt;&lt;/span&gt;
            &lt;span class=&#34;nt&#34;&gt;&amp;lt;/configuration&amp;gt;&lt;/span&gt;
        &lt;span class=&#34;nt&#34;&gt;&amp;lt;/plugin&amp;gt;&lt;/span&gt;
        &lt;span class=&#34;nt&#34;&gt;&amp;lt;plugin&amp;gt;&lt;/span&gt;
            &lt;span class=&#34;nt&#34;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.apache.maven.plugins&lt;span class=&#34;nt&#34;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
            &lt;span class=&#34;nt&#34;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;maven-surefire-plugin&lt;span class=&#34;nt&#34;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
            &lt;span class=&#34;nt&#34;&gt;&amp;lt;version&amp;gt;&lt;/span&gt;3.0.0-M3&lt;span class=&#34;nt&#34;&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
            &lt;span class=&#34;nt&#34;&gt;&amp;lt;configuration&amp;gt;&lt;/span&gt;
                &lt;span class=&#34;nt&#34;&gt;&amp;lt;argLine&amp;gt;&lt;/span&gt;--enable-preview&lt;span class=&#34;nt&#34;&gt;&amp;lt;/argLine&amp;gt;&lt;/span&gt;
            &lt;span class=&#34;nt&#34;&gt;&amp;lt;/configuration&amp;gt;&lt;/span&gt;
        &lt;span class=&#34;nt&#34;&gt;&amp;lt;/plugin&amp;gt;&lt;/span&gt;
    &lt;span class=&#34;nt&#34;&gt;&amp;lt;/plugins&amp;gt;&lt;/span&gt;
 &lt;span class=&#34;nt&#34;&gt;&amp;lt;/build&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;gradle&#34;&gt;Gradle&lt;/h2&gt;
&lt;p&gt;For Gradle, version 6.3 (currently available as &lt;a href=&#34;https://github.com/gradle/gradle/issues/10248#issuecomment-592520906&#34; target=&#34;_blank&#34;&gt;SNAPSHOT only&lt;/a&gt;
) is required for run with Java 14. To cover multiple compile and test tasks in the project the following construction could be used:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-groovy&#34; data-lang=&#34;groovy&#34;&gt;&lt;span class=&#34;n&#34;&gt;sourceCompatibility&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;14&lt;/span&gt;

&lt;span class=&#34;n&#34;&gt;tasks&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;withType&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;JavaCompile&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
    &lt;span class=&#34;n&#34;&gt;options&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;compilerArgs&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+=&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;--enable-preview&amp;#39;&lt;/span&gt;
&lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;span class=&#34;n&#34;&gt;tasks&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;withType&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Test&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
    &lt;span class=&#34;n&#34;&gt;jvmArgs&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+=&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;--enable-preview&amp;#34;&lt;/span&gt;
&lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;summary&#34;&gt;Summary&lt;/h2&gt;
&lt;p&gt;Nothing fancy in this post, but I feel in my bones that I will use it as a reference more than once during my &lt;a href=&#34;https://blog.solidsoft.pl/training/&#34;&gt;Migration to modern Java&lt;/a&gt;
 training :-).&lt;/p&gt;
&lt;span style=&#34;opacity: 0.6&#34;&gt;Lead photo by &lt;a href=&#34;https://pixabay.com/users/stocksnap-894430/&#34;&gt;StockSnap&lt;/a&gt;, published in &lt;a href=&#34;https://pixabay.com/photos/people-woman-bride-wedding-2586426/&#34;&gt;Pixabay&lt;/a&gt;, Pixabay License.&lt;/span&gt;
</content:encoded>
        <dc:creator>Marcin Zajączkowski</dc:creator>
        <media:content url="https://blog.solidsoft.pl//images/posts/2020/enable-java14-preview-features-thumbnail.jpg" medium="image"><media:title type="html">featured image</media:title></media:content>
        
        <media:content url="https://blog.solidsoft.pl//images/posts/2020/enable-java14-preview-features-ratio.jpg" medium="image"><media:title type="html">meta image</media:title></media:content>
        
          
            
              <category>java</category>
            
          
            
              <category>java14</category>
            
          
            
              <category>new-feature</category>
            
          
            
              <category>tutorial</category>
            
          
        
        
          
            
              <category>Other</category>
            
          
        
        
      </item>
      

    
  </channel>
</rss>