简体   繁体   English

为什么 AKKA TypedActor class 有两个签名相同的方法?

[英]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 时会拼写错误“模糊方法调用”,这里的systemActorSystem类型。 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.

相关问题 两种具有相同签名的方法,为什么起作用 - Two methods with the same signature, why it works Java类有两个具有相同函数签名但返回类型不同的方法 - Java class has 2 methods with the same function signature but different return types akka.actor.TypedActor $ MethodCall类无法访问带有修饰符“ public abstract”的JobManager类的成员 - Class akka.actor.TypedActor$MethodCall can not access a member of class JobManager with modifiers “public abstract” 在 Java 中使用相同签名的两个默认方法实现两个接口 8 - Implementing two interfaces with two default methods of the same signature in Java 8 两个接口中具有相同签名但返回类型不同的方法 - Methods with the same signature but different return type in two interfaces 两个接口指定具有相同签名的方法,但指定具有不同的行为? - Two interfaces specify methods with the same signature, but specified to have different behavior? 一个接口有两个具有相同名称但签名不同的方法 - One interface with two methods having same name but different signature 如何在同一个类中调用两个方法? - How to call two methods in same class? 为什么'Arrays类'有重载方法 - Why 'Arrays class' has overloaded methods 如何通过方法创建两个具有相同 class 的 bean? - How to create two beans with the same class by methods?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM