[英]Why the AKKA TypedActor class has two methods with the same signature?
In using TypedActor.get(system)
intellij spell an error 'ambiguous method call', here system
is of type ActorSystem
.在使用
TypedActor.get(system)
intellij 时会拼写错误“模糊方法调用”,这里的system
是ActorSystem
类型。 I found in the decompiled source code of the TypedActor
class file there are two methods with the same signature:我在
TypedActor
class 文件的反编译源代码中发现有两个签名相同的方法:
To my knowledge it is impossible for two methods to have the same signature in Java, so what is wrong here?据我所知,两种方法不可能在 Java 中具有相同的签名,那么这里有什么问题? What is the proper way to call the
TypedActor.get(ActorSystem system)
method?调用
TypedActor.get(ActorSystem system)
方法的正确方法是什么?
The version of AKKA I'm using is 2.5.11 and the jar file akka-actor_2.13.0-M3.我使用的 AKKA 的版本是 2.5.11 和 jar 文件 akka-actor_2.13.0-M3。
This was a bug caused by an issue in the Scala compiler ( https://github.com/akka/akka/issues/25449 ) it has since been fixed so upgrading to a more recent Akka version should fix it.这是由 Scala 编译器 ( https://github.com/akka/akka/issues/25449 ) 中的问题引起的错误,它已被修复,因此升级到更新的 Z1565C979FF6D525FF3C8 版本应该修复它。
EDIT: According to @johanandren below , this was a bug and it has now been fixed.编辑:根据下面的@johanandren,这是一个错误,现已修复。
You can use TypedActor$.MODULE$.get(system)
.您可以使用
TypedActor$.MODULE$.get(system)
。 This happens because of the way Scala objects get turned into singleton classes.这是因为 Scala 对象变成 singleton 类的方式。
A Scala object TypedActor
actually gets turned into the class TypedActor$
with a singleton instance called MODULE$
.一个 Scala object
TypedActor
实际上变成了 class TypedActor$
和一个名为MODULE$
的 Z2ED500A3529DUL637175E6EZB58 实例。 This is because JVM bytecode doesn't actually support Scala's singleton objects, so lots of Scala names are wrangled and are hard to access from Java. This is because JVM bytecode doesn't actually support Scala's singleton objects, so lots of Scala names are wrangled and are hard to access from Java.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.