Harmony/Dalvik IdentityHashMap Issue affecting Berkeley DB Java Edition on Android
By Charles Lamb on Jan 13, 2010
While debugging a failing JE unit test issue on Android, I ran into an interesting bug with the Harmony implementation of IdentityHashMap on Dalvik (the Android runtime).
It seems that if you call IdentityHashMap.entrySet() you get back Map.Entry instances which do not actually allow mutation of the underlying IdentityHashMap. Down in the guts of the Checkpointer code we use IHM to create a mapping from DatabaseImpls (internal database handles) to "the highest level" in the INDirtyList (the list of Internal Nodes in memory). We use that mapping to determine how high in the tree we should flush during a "flushAll" checkpoint. This failure means that there could be potential issues with Internal Nodes not being flushed when we think they are (Android only).
While we can't get the Dalvik runtime fixed for a while (i.e. it will require a new release of Android), we can put in a workaround (the details still TBD) to our code. This will appear in the next release of JE 4.0.x.