[groovy-user] Issue with CompileStatic and Gpars agent

25 views
Skip to first unread message

Paolo Di Tommaso

unread,
Jul 11, 2014, 7:59:09 AM7/11/14
to us...@groovy.codehaus.org, us...@gpars.codehaus.org
Dear all, 

I'm cross-posting this issue because it's hard to understand if it'd Groovy or Gpars problem. 

When running the following piece of code, I'm getting exception below 

import groovyx.gpars.agent.Agent
import groovy.transform.CompileStatic

@CompileStatic
class Dummy {

  def void foo() {
     def x = new Agent<List>( [] )
     x.send { List it -> it.add(1) }
     x.await()
  }

}


new Dummy().foo()


java.lang.IllegalAccessError: tried to access class groovyx.gpars.agent.AgentBase from class Dummy
at Dummy.foo(ConsoleScript15:10)
at Dummy$foo.call(Unknown Source)
at ConsoleScript15.run(ConsoleScript15:16)


The guilty line is "x.await()". If I remove the @CompileStatic it works fine. 


Any clue? 

Cheers,
Paolo

Paolo Di Tommaso

unread,
Jul 12, 2014, 4:40:56 AM7/12/14
to us...@groovy.codehaus.org, us...@gpars.codehaus.org
Just an update on this. I believe the problem is that the class AgentBase is not declared public in GPars. 

I've opened the following issue: 





Cheers,
Paolo

Paolo Di Tommaso

unread,
Jul 12, 2014, 4:59:56 AM7/12/14
to us...@groovy.codehaus.org, us...@gpars.codehaus.org
I've made some other tests and it turns out that Java allows to access a public method inherited from a non-public class.

I'm starting to think that this is a @CompileStatic issue which resolve wrongly the method declaration. In fact the exception trace reports 


java.lang.IllegalAccessError: tried to access class groovyx.gpars.agent.AgentBase from class Dummy
at Dummy.foo(ConsoleScript15:10)
at Dummy$foo.call(Unknown Source)
at ConsoleScript15.run(ConsoleScript15:16)


While the method is inherited the Agent class so it should be accessible. 


Thoughts?


Cheers,
Paolo


Paolo Di Tommaso

unread,
Jul 19, 2014, 6:31:38 PM7/19/14
to us...@gpars.codehaus.org, us...@groovy.codehaus.org
Hi Bob, 

No, is not that. I think it is a @CompilerStatic related problem. 

I've opened an issue for it



Best,
Paolo



On Fri, Jul 11, 2014 at 2:06 PM, Bob Brown <b...@transentia.com.au> wrote:
“””
  def void foo() {
“””

Looks a bit strange to me.

Try with only ONE of ‘void' OR ‘def'?

BOB

On 11 Jul 2014, at 21:57, Paolo Di Tommaso <paolo.d...@gmail.com> wrote:

  def void foo() {

---
Bob Brown
Director, Transentia Pty. Ltd.
Training, consulting, development at the leading edge of technology.

    73 Frasers Rd. Mobile: 0416-078-813
    Ashgrove Email: b...@transentia.com.au
    Brisbane Web: www.transentia.com.au
    Queensland 4060
    Australia

---
"We are all atheists about most of the gods that humanity has ever believed in.
 Some of us just go one god further."
  -- Richard Dawkins

---
NOTE: This email may NOT be taken to constitute an agreement to form a "prior relationship" or to give "prior affirmative consent" for the purposes of opt-in mass marketing.


Reply all
Reply to author
Forward
0 new messages