Community
Participate
Working Groups
I'm opening this bug so we don't lose track of a problem I found while implementing @EventListener. I can't fix it right now. Code generated from the program and handler below will not compile. The problem is in the Delegate we create during generation of the line "b.zit = elh.x;". The variable elh is a local variable that's not final, and we're using it within an inner class. That's not allowed in Java. --- File #1 ELHandler.egl package x; handler ELHandler function x( e ActionEvent in ) SysLib.writeStdout( "[Handler] The button was clicked!" ); end end --- File #2 EL.egl package x; program EL function main() b Button = new Button( "Click me" ); b.zit = x; f Frame = new Frame( "Hi!" ); f.addx( b ); f.pack(); f.setLocationByPlatform( true ); f.setVisible( true ); for ( i int from 5 to 1 decrement by 1 ) SysLib.writeStdout( "..." :: i :: "..." ); SysLib.wait( 1 ); end elh ELHandler; b.zit = elh.x; for ( i int from 5 to 1 decrement by 1 ) SysLib.writeStdout( "..." :: i :: "..." ); SysLib.wait( 1 ); end end function x( e ActionEvent in ) SysLib.writeStdout( "[Program] The button was clicked!" ); end end delegate act( e ActionEvent in ) end externalType Button type JavaObject { packageName = "java.awt" } constructor( name String in ); zit act { @EventListener{ addMethod = "addActionListener", listenerType = "java.awt.event.ActionListener", method = "actionPerformed" } }; end externalType ActionEvent type JavaObject { packageName = "java.awt.event" } end externalType Frame type JavaObject { packageName = "java.awt" } constructor( name String in ); function pack(); function setVisible(b boolean in); function addx( b Button in ) { externalName = "add" }; function setLocationByPlatform(b boolean in); end