Switching to getDeclaredConstructor.newInstance as a fallback
This commit is contained in:
parent
1eb6681b3c
commit
6bb1bf6795
1 changed files with 5 additions and 4 deletions
|
|
@ -186,9 +186,10 @@ case class Props(
|
||||||
* able to optimize serialization.
|
* able to optimize serialization.
|
||||||
*/
|
*/
|
||||||
private[akka] case class FromClassCreator(clazz: Class[_ <: Actor]) extends Function0[Actor] {
|
private[akka] case class FromClassCreator(clazz: Class[_ <: Actor]) extends Function0[Actor] {
|
||||||
def apply(): Actor = {
|
def apply(): Actor = try clazz.newInstance catch {
|
||||||
val ctor = clazz.getDeclaredConstructor()
|
case iae: IllegalAccessException ⇒
|
||||||
ctor.setAccessible(true)
|
val ctor = clazz.getDeclaredConstructor()
|
||||||
ctor.newInstance()
|
ctor.setAccessible(true)
|
||||||
|
ctor.newInstance()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue