Doesn't it work if you use the ordinary constructor: Props(new ValueActor(MyValue(10))) ?
tors 15 dec. 2016 kl. 15:22 skrev Endre Varga <endre.va...@lightbend.com>: > On Thu, Dec 15, 2016 at 3:21 PM, Justin du coeur <jduco...@gmail.com> > wrote: > > Ahhh -- okay. The really key bit is further down in that section, under > "Value classes as constructor arguments", > > > Eh, sorry, I meant to link to that, yes. > > > > and that explains I was missing: that it's using reflection to puzzle out > the constructors, and that doesn't work right with value classes. So it's > not actually as much a Scala-language question, but more about how Props > and reflection work. Not an immediate issue for me, but I like to > understand these nooks and crannies -- thanks for clearing it up! > > > No problem :) > > -Endre > > > > > On Thu, Dec 15, 2016 at 9:11 AM, Endre Varga <endre.va...@lightbend.com> > wrote: > > I also recommend this section in the doc: > http://doc.akka.io/docs/akka/2.4/scala/actors.html#Edge_cases > > On Thu, Dec 15, 2016 at 3:08 PM, Justin du coeur <jduco...@gmail.com> > wrote: > > Huh -- actually, this one surprises me, so I'd like to poke at it. I > understand why your response works, but not why the OP's doesn't. Since > it's a value class, I would have expected the OP's version to result in the > same bytecode, and I do think his version makes more sense semantically. > > Granted, this is more a Scala-language question than an Akka one, but can > you give a little insight into why that doesn't work at runtime? > > On Thu, Dec 15, 2016 at 3:57 AM, Viktor Klang <viktor.kl...@gmail.com> > wrote: > > You missed that they are value classes. ;) > > Try: > > val valueRef = system.actorOf { > Props(classOf[ValueActor], 10) > } > > > On Thu, Dec 15, 2016 at 8:28 AM, Dmb <bunadmit...@gmail.com> wrote: > > I'm reading the documentation > <http://doc.akka.io/docs/akka/2.4/scala/actors.html#Edge_cases> about > actors and now I'm at the section about actor creation. This is an example > I tried: > > > case class MyValueClass(v: Int) extends AnyVal > > class ValueActor(v: MyValueClass) extends Actor { > override def receive: Receive = { > case _ => println("Received message") > } > } > > > When creating the actor as following: > > val valueRef = system.actorOf { > Props(classOf[ValueActor], MyValueClass(10)) > } > > > I actually got the *IllegalArgumentException*. But what's wrong with > that? To me, creating actors with value classes as parameters seems > completely innocent. What did I miss? > > -- > >>>>>>>>>> Read the docs: http://akka.io/docs/ > >>>>>>>>>> Check the FAQ: > http://doc.akka.io/docs/akka/current/additional/faq.html > >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user > --- > You received this message because you are subscribed to the Google Groups > "Akka User List" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to akka-user+unsubscr...@googlegroups.com. > To post to this group, send email to akka-user@googlegroups.com. > Visit this group at https://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/d/optout. > > > > > -- > Cheers, > √ > > -- > >>>>>>>>>> Read the docs: http://akka.io/docs/ > >>>>>>>>>> Check the FAQ: > http://doc.akka.io/docs/akka/current/additional/faq.html > >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user > --- > You received this message because you are subscribed to the Google Groups > "Akka User List" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to akka-user+unsubscr...@googlegroups.com. > To post to this group, send email to akka-user@googlegroups.com. > Visit this group at https://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/d/optout. > > > -- > >>>>>>>>>> Read the docs: http://akka.io/docs/ > >>>>>>>>>> Check the FAQ: > http://doc.akka.io/docs/akka/current/additional/faq.html > >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user > --- > You received this message because you are subscribed to the Google Groups > "Akka User List" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to akka-user+unsubscr...@googlegroups.com. > To post to this group, send email to akka-user@googlegroups.com. > Visit this group at https://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/d/optout. > > > -- > >>>>>>>>>> Read the docs: http://akka.io/docs/ > >>>>>>>>>> Check the FAQ: > http://doc.akka.io/docs/akka/current/additional/faq.html > >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user > --- > You received this message because you are subscribed to the Google Groups > "Akka User List" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to akka-user+unsubscr...@googlegroups.com. > To post to this group, send email to akka-user@googlegroups.com. > Visit this group at https://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/d/optout. > > > -- > >>>>>>>>>> Read the docs: http://akka.io/docs/ > >>>>>>>>>> Check the FAQ: > http://doc.akka.io/docs/akka/current/additional/faq.html > >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user > --- > You received this message because you are subscribed to the Google Groups > "Akka User List" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to akka-user+unsubscr...@googlegroups.com. > To post to this group, send email to akka-user@googlegroups.com. > Visit this group at https://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/d/optout. > > -- > >>>>>>>>>> Read the docs: http://akka.io/docs/ > >>>>>>>>>> Check the FAQ: > http://doc.akka.io/docs/akka/current/additional/faq.html > >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user > --- > You received this message because you are subscribed to the Google Groups > "Akka User List" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to akka-user+unsubscr...@googlegroups.com. > To post to this group, send email to akka-user@googlegroups.com. > Visit this group at https://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/d/optout. > -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.