0

Background:

I have an app written in Scala and with the Akka toolkit. Furthermore, it has some Java dependencies, so it uses the Scala Reflection Library to call Java methods/classes when needed.

Problem:

There are cases in which multiple actors with different Java dependencies execute in parallel. It appears that in this case, actors aren't actually executing in parallel. After some investigation, I'm thinking that this is due to the scala.reflect.runtime.universe value being contained in a singleton. Therefore, multiple actors looking for the appropriate methods/classes in the mirrors is bottlenecked here. If Scala reflection can be made to work in a distributed manner, please advise on how.

  • We have run into problems with reflection when using Akka and Play because of the class loader. I wonder if that could be your issue – erip Oct 05 '18 at 00:26
  • @erip please elaborate. What problem did the class loader present? And how did you resolve? – Need Answers Fast Oct 05 '18 at 01:42
  • At least in the case of Play, when running in development mode, Play uses a hot reloader to make response to source change snappy. I can try to find a StackOverflow post about it, but IIRC, we could not rely on `Thread.currentThread().getContextClassLoader()` because the class loading was multithreaded. – erip Oct 05 '18 at 11:22
  • 1
    Why do you need to use reflection to call _Java_ methods, or access it's classes? You can call _any Java_ method directly from _Scala_ without needing to use reflection. – Mike Allen Oct 05 '18 at 20:37

0 Answers0