作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
虽然试图找出一些 joda-time
DateTime
(时间戳格式)问题我打开了一个 REPL
scala -cp joda-time-2.3.jar
joda-convert
jar,并最终得到一个
java.lang.AssertionError: assertion failed: org.joda.convert.ToString
> scala -cp joda-time-2.3.jar
Welcome to Scala version 2.11.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_05).
Type in expressions to have them evaluated.
Type :help for more information.
scala> val dt = new org.joda.time.DateTime
warning: Class org.joda.convert.FromString not found - continuing with a stub.
warning: Class org.joda.convert.ToString not found - continuing with a stub.
warning: Class org.joda.convert.FromString not found - continuing with a stub.
warning: Class org.joda.convert.ToString not found - continuing with a stub.
dt: org.joda.time.DateTime = 2014-05-14T17:54:24.511+01:00
scala> scala.runtime.ScalaRunTime.stringOf(dt)
res0: String = 2014-05-14T17:54:24.511+01:00
scala> dt.toString
java.lang.AssertionError: assertion failed: org.joda.convert.ToString
ScalaRunTime.stringOf(dt)
成功在哪里
dt.toString
失败?
最佳答案
您没有发布堆栈跟踪,这是编译器崩溃而不是 joda 的失败断言。
REPL 在编译表达式时崩溃。
它看起来像 AbstractDateTime
有一个过载 toString
方法和重载解析在 @ToString
上崩溃通常的注释 toString()
. (ToString
的符号丢失。)
但是stringOf(x: Any)
只是调用 Object.toString()
, 当然。
有some known issues , 显然。 recent issue是固定的。
在 2.10.4 上:
scala> (dt: Any).toString
res0: String = 2014-05-14T11:56:21.794-07:00
scala> dt.toString
<console>:9: error: ambiguous reference to overloaded definition,
both method toString in class AbstractDateTime of type (x$1: String, x$2: java.util.Locale)String
and method toString in class AbstractDateTime of type (x$1: String)String
match expected type ?
dt.toString
^
scala> dt.toString() // crashes
error while loading DateTime, class file is broken
.
关于scala - 当 x.toString 失败时,ScalaRunTime.stringOf(x) 如何不失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23660990/
虽然试图找出一些 joda-time DateTime (时间戳格式)问题我打开了一个 REPL scala -cp joda-time-2.3.jar 忘记添加 joda-convert jar,并
我是一名优秀的程序员,十分优秀!