@ListenerList generated fireWhatever() method stops working

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

@ListenerList generated fireWhatever() method stops working

frigo.work
Dear [hidden email],

as described in the question on SO
http://stackoverflow.com/questions/42648766/groovy-listenerlist-generated-firexxx-method-stops-working
and confirmed by @aalmiray the fireWhatever() method generated when
using @ListenerList annotation stops working.

@aalmiray s code as posted in his reply reproduces the problem with
Groovy 2.4.7 and I confirmed it with 2.4.8 running it in groovyConsole

import groovy.beans.ListenerList

interface MessageListener {
  void messageReceived(byte[] msg)
}

class MessageProducer {
  @ListenerList
  List<MessageListener> listeners

  void produce(String msg) {
    fireMessageReceived(msg.getBytes())
  }
}

producer = new MessageProducer()
producer.addMessageListener({ println it } as MessageListener)
producer.produce('Groovy')

The stacktrace is

Exception thrown

java.lang.NoSuchMethodError: MessageProducer.fireMessageReceived([B)V
        at MessageProducer$fireMessageReceived$0.callCurrent(Unknown
Source) at MessageProducer.produce(ConsoleScript0:12)
        at MessageProducer$produce.call(Unknown Source)
        at ConsoleScript0.run(ConsoleScript0:18

Are we doing something wrong or is this a bug?

Thank you
Frigo Pratser
Reply | Threaded
Open this post in threaded view
|

Re: @ListenerList generated fireWhatever() method stops working

paulk_asert
Looks like a bug, I haven't checked the code yet but experimentally,
no array argument (primitive or otherwise) seems to be supported. The
workaround would be to create a holder event class of some kind that
had an array property. Filing a bug issue in Jira would be much
appreciated.

Cheers, Paul.

On Wed, Mar 8, 2017 at 7:49 PM,  <[hidden email]> wrote:

> Dear [hidden email],
>
> as described in the question on SO
> http://stackoverflow.com/questions/42648766/groovy-listenerlist-generated-firexxx-method-stops-working
> and confirmed by @aalmiray the fireWhatever() method generated when
> using @ListenerList annotation stops working.
>
> @aalmiray s code as posted in his reply reproduces the problem with
> Groovy 2.4.7 and I confirmed it with 2.4.8 running it in groovyConsole
>
> import groovy.beans.ListenerList
>
> interface MessageListener {
>   void messageReceived(byte[] msg)
> }
>
> class MessageProducer {
>   @ListenerList
>   List<MessageListener> listeners
>
>   void produce(String msg) {
>     fireMessageReceived(msg.getBytes())
>   }
> }
>
> producer = new MessageProducer()
> producer.addMessageListener({ println it } as MessageListener)
> producer.produce('Groovy')
>
> The stacktrace is
>
> Exception thrown
>
> java.lang.NoSuchMethodError: MessageProducer.fireMessageReceived([B)V
>         at MessageProducer$fireMessageReceived$0.callCurrent(Unknown
> Source) at MessageProducer.produce(ConsoleScript0:12)
>         at MessageProducer$produce.call(Unknown Source)
>         at ConsoleScript0.run(ConsoleScript0:18
>
> Are we doing something wrong or is this a bug?
>
> Thank you
> Frigo Pratser
Reply | Threaded
Open this post in threaded view
|

Re: @ListenerList generated fireWhatever() method stops working

frigo.work
Not sure which components are affected, entered groovy-runtime . https://issues.apache.org/jira/browse/GROOVY-8110

On Wed, Mar 8, 2017 at 11:50 AM, Paul King <[hidden email]> wrote:
Looks like a bug, I haven't checked the code yet but experimentally,
no array argument (primitive or otherwise) seems to be supported. The
workaround would be to create a holder event class of some kind that
had an array property. Filing a bug issue in Jira would be much
appreciated.

Cheers, Paul.

On Wed, Mar 8, 2017 at 7:49 PM,  <[hidden email]> wrote:
> Dear [hidden email],
>
> as described in the question on SO
> http://stackoverflow.com/questions/42648766/groovy-listenerlist-generated-firexxx-method-stops-working
> and confirmed by @aalmiray the fireWhatever() method generated when
> using @ListenerList annotation stops working.
>
> @aalmiray s code as posted in his reply reproduces the problem with
> Groovy 2.4.7 and I confirmed it with 2.4.8 running it in groovyConsole
>
> import groovy.beans.ListenerList
>
> interface MessageListener {
>   void messageReceived(byte[] msg)
> }
>
> class MessageProducer {
>   @ListenerList
>   List<MessageListener> listeners
>
>   void produce(String msg) {
>     fireMessageReceived(msg.getBytes())
>   }
> }
>
> producer = new MessageProducer()
> producer.addMessageListener({ println it } as MessageListener)
> producer.produce('Groovy')
>
> The stacktrace is
>
> Exception thrown
>
> java.lang.NoSuchMethodError: MessageProducer.fireMessageReceived([B)V
>         at MessageProducer$fireMessageReceived$0.callCurrent(Unknown
> Source) at MessageProducer.produce(ConsoleScript0:12)
>         at MessageProducer$produce.call(Unknown Source)
>         at ConsoleScript0.run(ConsoleScript0:18
>
> Are we doing something wrong or is this a bug?
>
> Thank you
> Frigo Pratser