gpt4 book ai didi

java - android ArrayMap 抛出 java.lang.ClassCastException : java. lang.String 无法转换为 java.lang.Object[]

转载 作者:行者123 更新时间:2023-11-29 19:34:47 29 4
gpt4 key购买 nike

我使用 android.support.v4.util.ArrayMap

像这样

ArrayMap<String, ArrayList<Object>> group = new ArrayMap<>();

但是我调用了ArrayMap.put(key,value)

allocArrays(final int size) 方法中抛出 ClassCastException

 private void allocArrays(final int size) {
if (size == (BASE_SIZE*2)) {
synchronized (ArrayMap.class) {
if (mTwiceBaseCache != null) {
final Object[] array = mTwiceBaseCache;
mArray = array;
mTwiceBaseCache = (Object[])array[0];
mHashes = (int[])array[1];
array[0] = array[1] = null;
mTwiceBaseCacheSize--;
if (DEBUG) Log.d(TAG, "Retrieving 2x cache " + mHashes
+ " now have " + mTwiceBaseCacheSize + " entries");
return;
}
}
} else if (size == BASE_SIZE) {
synchronized (ArrayMap.class) {
if (mBaseCache != null) {
final Object[] array = mBaseCache;
mArray = array;
mBaseCache = (Object[])array[0];
mHashes = (int[])array[1];
array[0] = array[1] = null;
mBaseCacheSize--;
if (DEBUG) Log.d(TAG, "Retrieving 1x cache " + mHashes
+ " now have " + mBaseCacheSize + " entries");
return;
}
}
}

mHashes = new int[size];
mArray = new Object[size<<1];
}

应用程序在这一行崩溃 mBaseCache = (Object[])array[0];

非常感谢!!!

最佳答案

问题的原因是多线程。

此错误已修复 https://issuetracker.google.com/issues/37114373更新支持V25.4.0已修复

关于java - android ArrayMap 抛出 java.lang.ClassCastException : java. lang.String 无法转换为 java.lang.Object[],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39343332/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com