|
Another Idea for a Java Feature
|
Posted: Oct 30, 2010 11:19 AM
|
|
More of a Swing feature actually.
As computers become more multi-core, we're encountering more and more thread-related issues with Swing, which, ultimately, are caused by what are, or should be treated as, ConcurrentModificationExceptions. Because data is getting modified on non-AWT threads. Which, of course, is technically a programming mistake, but one that's fairly easy to make.
So, how about changing the paint() method to catch and handle these exceptions. e.g. (with some possible filler code added)
public void paint(Graphics g) {
try {
// existing paint code goes here, or. if we are a subclass:
super.paint(g);
}
catch (ConcurrentModificationException cme) {
if (Boolean.TRUE.equals(getClientProperty("HandleConcurrentModificationException"))) {
doHandleConcurrentModificationException(cme);
}
else
throw cme;
}
}
}
doHandleConcurrentModificationException() is a protected method that, by default, just calls repaint();
Thoughts?
|
|