在scala中初始化com.sun.jna.Structure时的异常

时间:2014-06-14 06:08:28

标签: scala jna

我正在尝试使用scala中的JNA。基本的东西工作,但我偶然发现使用结构。我试图从libc使用localtime(time_t ts)函数,为struct tm定义了以下scala等价物,如下所示

class tm_struct (
  var wYear: Short = 0,
  var wMonth: Short = 0,
  var wDayOfWeek: Short = 0,
  var wDay: Short = 0,
  var wHour: Short = 0,
  var wMinute: Short = 0,
  var wSecond: Short = 0,
  var wMilliseconds: Short = 0) extends com.sun.jna.Structure {
  def getFieldOrder = List(Array("wYear", "wMonth", "wDayOfWeek", "wDay", "wHour", "wMinute", "wSecond", "wMilliseconds")).asJava
}

编译很好,但给我一个运行时错误

[error] (run-main-8) java.lang.ClassCastException: [Ljava.lang.String; cannot be cast to java.lang.Comparable
java.lang.ClassCastException: [Ljava.lang.String; cannot be cast to java.lang.Comparable

尝试初始化类tm_struct的新实例时。 如果有任何提示,我将不胜感激......

0 个答案:

没有答案