Uploaded image for project: 'NetBeans'
  1. NetBeans
  2. NETBEANS-5470

Pattern matching marked as error in Java 16 project

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 12.3
    • 13
    • java - Hints
    • None

    Description

      When one has a Java project using JDK 16 and has the source level set to 16, Netbeans still shows the use of pattern matching as an error even though it is no longer a preview feature. The code is question still compiles successfully.

       

      public class Test{
      	private boolean test(Object obj){
      		if (obj instanceof String s){
      			return s.isBlank();
      		}
      		return false;
      	}
      }
      

      15 and 16 aren't listed in the source level drop-down for Netbeans Module projects, so you have to specify 15 or 16 directly in the properties file. That may be related, but I am not sure.

      Attachments

        Activity

          People

            Unassigned Unassigned
            Sir Intellegence Austin Stephens
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: