-- Map source code, interface method resolution, heap management --
could be anywhere.
(But one thing to beware of is multithreading -- Only HashTable is
thread-safe, and HashMap/HashSet can be tied in a knot if modified
asynchronously.)
But so long as you're not multithreading I don't think it's your bug
(though certainly a bug on your part could be "exercising" an untested
path in the system).
On May 27, 1:11 pm, Emanuel Moecklin <1gravity...@gmail.com> wrote:
> I get the following exception:
>
> java.lang.ArrayStoreException: java.util.LinkedHashMap$LinkedEntry cannot be
> stored in an array of type java.util.HashMap$HashMapEntry[]
> at java.util.LinkedHashMap.addNewEntry(LinkedHashMap.java:193)
> at java.util.HashMap.put(HashMap.java:412)
> at java.util.HashSet.add(HashSet.java:95)
> at com.mycompany.myapp.MyClass.void init()(MyClass.java:135)
>
> Here's the code:
> private LinkedHashSet<Cell> cells;
> protected void init() {
> cells = new LinkedHashSet<Cell>();
> for (int i = 0; i < 20; i++) {
> cells.add(getCell(i)); // <-- that's line 135
> }
> }
>
> getCell() always returns a Cell object. I'm 100% positive about that because
> it returns just values from an array:
> private final Cell[] cells = new Cell[20];
> Even if the Cell objects were Null it would work because HashSet supports
> Null elements.
> Even if it would contain duplicate entries it wouldn't throw
> an ArrayStoreException but one of the other possible exceptions (
> IllegalArgumentException, ClassCastException, IllegalStateException).
>
> I assume the exception occurs because of Honeycomb for the following
> reasons:
>
> - I really can't see a reason why it could/should crash at all
> - the piece of code has run thousands of times on at least 100 different
> devices without ever failing
> - I got the exception on an Acer Iconia A500 running Android 3.0.1.
> The percentage of devices running Honeycomb that the app runs on is still
> too small to even show in the app's statistics.
> If it were a problem in my code it would have shown on pre-Honeycomb
> devices already.
>
> Any ideas?
>
> Emanuel Moecklin
> 1gravity LLC
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
No comments:
Post a Comment