Hello,
I wrote a midlet that runs fine on most handsets (Motorola T720, i95cl, Siemens M50, etc), but there's a problem with running it on the Nokia 7210: for some reason, the program sometimes gets stuck completely (hangs). This happens quite randomly (but when it does, it always happens when pressing a button), so it's hard to track down, but i found out it has something to do with synchronized methods and the event-dispatching thread.
First, let me ask: is there a regularly updated "known bugs" list available for the Nokia JVM implementations? If not: why not? It would be one of the most useful things on this site, in my opinion.
Ok, now i'll continue with the problem: the problem seems to occur when the event dispatching thread is busy drawing something on the screen, and *while* it's doing that, i press a button (catching it with keyPressed() in FullCanvas) and call a synchronized method. This makes the JVM hang, deadlock. I don't think this is caused by my program, but is a bug in the JVM. I can reasonably consistently reproduce it at some point in my program: it's drawing something on the screen, and i press one of the soft buttons which leads me to a menu (a List). Because i implemented hideNotify(), this method is called, and hideNotify() calls another method that is synchronized. It doesn't seem to matter what object it's synchronized on. Just that it's synchronized. When i remove the synchronized keyword from the method, the problem doesn't occur. It seems to have something to do with the event-dispatching thread, because it only happens while that thread is busy (drawing something, in this case). So the event-dispatching thread is doing something, and at the same time a key event calls (directly, or indirectly through hideNotify()) a synchronized method. I haven't taken it to the point of creating one easy to use example class to demonstrate this, but if Nokia is interested, i will share the code with you. By the way: the paint method isn't synchronized in any way, but in my case the synchronized method does draw something, but only to an offscreen image. I'll check later to see if it also deadlocks when this method is not drawing anything.
I hope you can fix this bug, as well as produce a "known-bugs" list, which i think many developers would find very useful.
Regards,
-- Niek

Reply With Quote

