[英]ArrayList creation: (some object) cannot be stored in an array of type java.lang.Object[]
Usually, the code block works perfect. 通常,代码块工作得很完美。 On very rare occasions though, the "new ArrayList" throws an Exeption my.namespace.CacheEntry cannot be stored in an array of type java.lang.Object[] .
但是在极少数情况下,“new ArrayList”会抛出一个Exeption my.namespace.CacheEntry,不能存储在java.lang.Object []类型的数组中 。
Checking Google, someone else seemed to get this exception on an Acer A500 with 3.1 (which is the device I got it, too). 检查谷歌,其他人似乎在带有3.1的Acer A500上获得了这个例外(这也是我得到它的设备)。 I don't see any hit for this in generic Java or whatever, so may be some very very Honeycomb special case or even a VM bug?
我在通用Java或其他任何东西中都没有看到任何打击,所以可能是一些非常非常的Honeycomb特殊情况甚至VM错误?
private long expireCache(HashMap<String, CacheEntry> map) {
long count = 0;
// next line will sometimes throw the exception:
ArrayList<CacheEntry> entries = new ArrayList<CacheEntry>(map.values());
Collections.sort(entries);
The CacheEntry class is quite regular, too: CacheEntry类也非常规则:
final class CacheEntry implements Comparable<CacheEntry> {
public File file;
public Long time;
CacheEntry(File cacheFile) {
// retreive the lastModified only once, don't do heavy I/O for sorting,
// keep it desynced from filesystem so nothing bad happens when the
// file gets changed while sorting:
file = cacheFile;
time = cacheFile.lastModified();
}
// "touch" the cached last modified time
public void touch() {
time = System.currentTimeMillis();
}
// return the long comparable of last modified time
public int compareTo(CacheEntry c) {
return time.compareTo(c.time);
}
}
I don't see anything wrong with this code. 我没有看到这段代码有什么问题。 Anyone?
任何人?
may be some very very Honeycomb special case or even a VM bug?
可能是一些非常非常蜂窝的特殊情况甚至VM漏洞?
Yes, looks like it, because according to Java semantics, there isn't anything that "cannot be stored in an array of type java.lang.Object[]" - except primitives, but those can't be values in a HashMap
是的,看起来像它,因为根据Java语义, 没有任何“不能存储在类型java.lang.Object []”的数组中 - 除了原语,但那些不能是
HashMap
值
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.