我有一段代码在运行时抛出java.lang.NoSuchMethodError我无法解决:
private def saveActivationEvent(event: ActivationEvent) = activationEventService.createIfFirst(event)
实施:
case class ActivationEvent extends Event
class ActivationEventService extends AbstractEventService[ActivationEvent]
abstract class AbstractExalateEventService[E <: Event] {
def createIfFirst(event: E)(implicit reader: BSONDocumentReader[E], writer: BSONDocumentWriter[E]): Future[Option[BSONObjectID]] = ...
}
我以为是由于类型擦除而发生的...有人可以帮我理解问题吗?
答案 0 :(得分:1)
正如我在上面的评论中提到的,每当您看到Address Meaning
0 1st to 4th byte in memory
1 address does not exist
2 address does not exist
3 address does not exist
4 5th to 8th byte in memory
5 address does not exist
...
时,首先要检查的是编译版本和运行时依赖版本是否匹配。对于什么价值,我想不出一种类型擦除可能与NoSuchMethodError
有任何关系的方式-如果某人因擦除而匹配的类型测试很差,那么您可能会看到NoSuchMethodError
,但是即使在那种情况下,问题实际上并没有消除,而是有人试图解决该问题(并忽略了编译器的警告)。