Hoy probando a responder una pregunta en este sitio logré producir un error en el netbeans en un proyecto de tipo maven.
El error dice así:
--- exec-maven-plugin:1.5.0:exec (default-cli) @ respuestas-stackoverflow --- Exception in thread "AWT-EventQueue-0"
java.lang.RuntimeException: Uncompilable source code - Erroneous ctor sym type: javax.swing.Timer.<init>
at com.stackoverflow.es.question363473.AutoDisposable.<init>(AutoDisposable.java:20)
at com.stackoverflow.es.question363473.Autocerrable.<init>(Autocerrable.java:18)
at com.stackoverflow.es.question363473.Autocerrable$1.run(Autocerrable.java:87)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:704)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
El error se produjo al tratar de modernizar el código y remplazar una clase interna anónima por un lambda, en concreto:
Timer timer = new Timer(2000,
new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
dispose();
}
}
);
por
Timer timer = new Timer(2000,()->dispose());
e inmediatamente darle click derecho y run file
lo cual ejecuta al comando
cd C:\Users\RuslanLopez\Documents\CoolBeansProjects\respuestas-stackoverflow; "JAVA_HOME=C:\\Program Files\\AdoptOpenJDK\\jdk-13.0.1.9-openj9" cmd /c "\"C:\\Program Files\\NetBeans-11.3\\netbeans\\java\\maven\\bin\\mvn.cmd\" -Dexec.args=\"-classpath %classpath com.stackoverflow.es.question363473.Autocerrable\" -Dexec.executable=\"C:\\Program Files\\AdoptOpenJDK\\jdk-13.0.1.9-openj9\\bin\\java.exe\" -Dexec.classpathScope=runtime -Dmaven.ext.class.path=\"C:\\Program Files\\NetBeans-11.3\\netbeans\\java\\maven-nblib\\netbeans-eventspy.jar\" -Dfile.encoding=UTF-8 org.codehaus.mojo:exec-maven-plugin:1.5.0:exec"