pedro-w opened a new issue, #5260:
URL: https://github.com/apache/netbeans/issues/5260

   ### Apache NetBeans version
   
   Apache NetBeans 16
   
   ### What happened
   
   Certain projects cause a runtime exception when run or debugged in the IDE, 
when the 'compile on save' option is selected in the project properties. One 
trigger is using the `instanceof` pattern matching, e.g. 
   ```
   private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {       
                                  
           if (evt.getSource() instanceof JButton button) {
               JOptionPane.showMessageDialog(this, String.format("Pressed 
'%s'", button.getText()));
           }
       } 
   ```
   The exception is "Exception in thread "AWT-EventQueue-0" 
java.lang.RuntimeException: Uncompilable code" - see below for more details.
   The problem does not occur if compile on save is not selected, or when 
running the build JAR direct from the command line.
   Clean and build project does not help.
   Clearing the NB cache does not help.
   
   
   ### How to reproduce
   
   I've made a minimal project on github which reproduces always for me: 
https://github.com/pedro-w/UncompilableCodeDemo
   1. Clone this project and open in the IDE
   2. Run and press the button on the form that appears - should be OK
   3. Close app and select 'Compile on Save' in the project properties
   4. Re-run and press the button - the exception should appear
   
   ```
   Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: 
Uncompilable code
        at demo.NewJFrame.jButton1ActionPerformed(NewJFrame.java:47)
        at demo.NewJFrame$1.actionPerformed(NewJFrame.java:39)
        at 
java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1972)
        at 
java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2313)
   ```
   ...
   ```
   at 
java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at 
java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
   BUILD SUCCESSFUL (total time: 4 seconds)
   ```
   
   ### Did this work correctly in an earlier version?
   
   No / Don't know
   
   ### Operating System
   
   Windows 11 Pro 22H2 (x64)
   
   ### JDK
   
   openjdk version "17.0.3" 2022-04-19 OpenJDK Runtime Environment 
Temurin-17.0.3+7 (build 17.0.3+7) OpenJDK 64-Bit Server VM Temurin-17.0.3+7 
(build 17.0.3+7, mixed mode, sharing)
   
   ### Apache NetBeans packaging
   
   Apache NetBeans provided installer
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit a pull request?
   
   Yes
   
   ### Code of Conduct
   
   Yes


-- 
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