Java 14 pattern matching instance of not woking

Answered

Hi, 

I create a simple maven  project 

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>tmp</artifactId>
<version>1.0-SNAPSHOT</version>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>14</release>
<!-- <source>${java.version}</source>-->
<!-- <target>${java.version}</target>-->
<failOnError>true</failOnError>
<compilerArgs>--enable-preview</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>

</project>

The other preview features works as expected but pattern mathching instance of will not compile 

0
4 comments

Works here. Have you re-imported project in Maven tool window?

make also sure the 14 JDK is set for the module.

If issue remains, please provide a sample to check. Also specify IDE version you are using.

0

Tried everything 100 times but still won't work.

0

Provide a sample project with steps to reproduce and specify the IDE version you are using. Also attach a screenshot of File | Project Structure | Modules | <module name> -> Dependencies tab.

For uploading you can use ftp://ftp.intellij.net/.uploads / https://uploads.services.jetbrains.com or any file sharing service including Github.

0

I got it. That's a mistake on my site. 

I forgot to extract the variale str :-D

 

0

Please sign in to leave a comment.