#1499 Singleton actor initialization locks on reflection.

vkuzkokov Tue 19 Apr 2011

Consider following code:

using concurrent

const class Superstar : Actor
{
  static const Superstar instance := Superstar()
  new make() : super(ActorPool())
  {
    send(null).get
  }
  override Obj? receive(Obj? msg)
  {
    B#
  }
  static Void main()
  {
  }
}

class B
{
}

It locks on attempt to run. I guess that it has to do with class locking described in JVMS.

At first, it main thread obtains class lock when starting <clinit>.

The actor thread tries to access static field (lazily initialized type literal) and locks on getstatic opcode.

Workaround is to move out all type and slot literals to another class.

brian Wed 20 Apr 2011

Although not a nice situation, I don't really consider that a lang/framework problem per se. If you make a blocking call to another thread in your static initializer, then that sort of stuff can happen. In this particular case it could be fixed by using a different object for locking type (uri, slot) literals. But I don't think that fixes the fundamental problems.

Login or Signup to reply.