我使用red5和IConnection类来设置/获取属性,但这并不重要。
'L'在java中表示long。因此,0L是类型为Long的0,而不仅仅是类型为Integer的'0'。
以下错误消息中[Ljava.lang.Long
和java.lang.Long
之间有什么区别:
stack trace: java.lang.ClassCastException: [Ljava.lang.Long; cannot be cast to java.lang.Long
更新
代码示例:
static Long getLongAttribute(IConnection conn, String attribute) {
Long result=null;
try {
if (!conn.hasAttribute(attribute))
throw new Exception(attribute + " - Long attribute not found!");
result = conn.getLongAttribute(attribute); // <--- ERRROR ON THIS LINE
} catch (Exception e) {
_handleException(e);
}
return result;
}
conn.getLongAttribute
调用的内部。在问题中提供的代码中没有强制转换,但是如果没有完整的堆栈跟踪,很难确定问题的确切位置。如果result = conn.getLongAttribute
存在类型不匹配,则编译器会捕获它。 - Cameron Skinner