juersimon opened a new issue, #5723:
URL: https://github.com/apache/netbeans/issues/5723

   ### Apache NetBeans version
   
   Apache NetBeans 17
   
   ### What happened
   
   When using instanceof with pattern matching a RuntimeException Uncompilable 
code is thrown with JDK 17 if the program is started in Netbeans with run or 
debug . The generated jar runs without errors.
   This behavior is also the case with JDK 18, JDK 19/20 work.
   `
   Number n = Long.valueOf(1);
   if (n instanceof Long l) {
       System.out.println("Long: " + l);
   }
   `
   
   ### How to reproduce
   
   The error occurs when an Ant project is created and Compile on Save is 
activated. JDK 17 (or 18) is selected as the Java platform. The default 
platform is irrelevant. JDK 17 is used as source/binary format.
   The following compiles without errors and the jar produced runs with Java 
17. If the program is started with debog or run in Netbeans, then the exception 
is thrown. If JDK 19 or JDK 20 is selected as platform, run and debug work 
without error.
   `public class Netbeans17Instanceof {
   
       public static void main(String[] args) {
           try {
               Number n = Long.valueOf(1);
               if (n instanceof Long l) {
                   System.out.println("Long: " + l);
               }
           } catch (Exception ex) {
               ex.printStackTrace(System.err);
           }
       }
   }`
   
   ### Did this work correctly in an earlier version?
   
   Apache NetBeans 15
   
   ### Operating System
   
   Windows 10 / Ubuntu 22.04.02
   
   ### JDK
   
   adoptium 17.0.6
   
   ### Apache NetBeans packaging
   
   Apache NetBeans provided installer
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit a pull request?
   
   No


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to