Issue with CompileStatic and Gpars agent

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue with CompileStatic and Gpars agent

Paolo Di Tommaso
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
Reply | Threaded
Open this post in threaded view
|

Re: Issue with CompileStatic and Gpars agent

Bob Brown
“””
  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 <[hidden email]> 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: [hidden email]
    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 | Threaded
Open this post in threaded view
|

Re: Issue with CompileStatic and Gpars agent

Paolo Di Tommaso
In reply to this post by Paolo Di Tommaso
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


  


On Fri, Jul 11, 2014 at 1:57 PM, Paolo Di Tommaso <[hidden email]> wrote:
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

Reply | Threaded
Open this post in threaded view
|

Re: Issue with CompileStatic and Gpars agent

Paolo Di Tommaso
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




On Sat, Jul 12, 2014 at 10:38 AM, Paolo Di Tommaso <[hidden email]> wrote:
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


  


On Fri, Jul 11, 2014 at 1:57 PM, Paolo Di Tommaso <[hidden email]> wrote:
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


Reply | Threaded
Open this post in threaded view
|

Re: Issue with CompileStatic and Gpars agent

Paolo Di Tommaso
In reply to this post by Bob Brown
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 <[hidden email]> 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 <[hidden email]> 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: [hidden email]
    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.