Ahhh -- okay. The really key bit is further down in that section, under "Value classes as constructor arguments", 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!
On Thu, Dec 15, 2016 at 9:11 AM, Endre Varga <[email protected]> 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 <[email protected]> > 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 <[email protected]> >> 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 <[email protected]> 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/c >>>> urrent/additional/faq.html >>>> >>>>>>>>>> Search the archives: https://groups.google.com/grou >>>> p/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 [email protected]. >>>> To post to this group, send email to [email protected]. >>>> 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/c >>> urrent/additional/faq.html >>> >>>>>>>>>> Search the archives: https://groups.google.com/grou >>> p/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 [email protected]. >>> To post to this group, send email to [email protected]. >>> 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/c >> urrent/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 [email protected]. >> To post to this group, send email to [email protected]. >> 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 [email protected]. > To post to this group, send email to [email protected]. > 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
