I have setup an UncaughtExceptionHandler
in my Swing app which will catch and log any uncaught exceptions in my code and report them to me. The stack traces for most of these errors are helpful in diagnosing the issues. However, sometimes I get a problem like this:
Thread : AWT-EventQueue-2
Thread[AWT-EventQueue-2,6,javawsApplicationThreadGroup]
Error Message:
java.lang.Double cannot be cast to java.lang.Integer
Error String:
java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer
StackTrace: class java.lang.ClassCastException
java.lang.Integer.compareTo(Unknown Source)
javax.swing.table.TableRowSorter$ComparableComparator.compare(Unknown Source)
javax.swing.DefaultRowSorter.compare(Unknown Source)
javax.swing.DefaultRowSorter.access$100(Unknown Source)
javax.swing.DefaultRowSorter$Row.compareTo(Unknown Source)
javax.swing.DefaultRowSorter$Row.compareTo(Unknown Source)
java.util.ComparableTimSort.binarySort(Unknown Source)
java.util.ComparableTimSort.sort(Unknown Source)
java.util.Arrays.sort(Unknown Source)
javax.swing.DefaultRowSorter.sortExistingData(Unknown Source)
javax.swing.DefaultRowSorter.setSortKeys(Unknown Source)
javax.swing.DefaultRowSorter.toggleSortOrder(Unknown Source)
javax.swing.plaf.basic.BasicTableHeaderUI$MouseInputHandler.mouseClicked(Unknown Source)
java.awt.AWTEventMulticaster.mouseClicked(Unknown Source)
java.awt.Component.processMouseEvent(Unknown Source)
javax.swing.JComponent.processMouseEvent(Unknown Source)
java.awt.Component.processEvent(Unknown Source)
java.awt.Container.processEvent(Unknown Source)
java.awt.Component.dispatchEventImpl(Unknown Source)
java.awt.Container.dispatchEventImpl(Unknown Source)
java.awt.Component.dispatchEvent(Unknown Source)
java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
java.awt.Container.dispatchEventImpl(Unknown Source)
java.awt.Window.dispatchEventImpl(Unknown Source)
java.awt.Component.dispatchEvent(Unknown Source)
java.awt.EventQueue.dispatchEventImpl(Unknown Source)
java.awt.EventQueue.access$500(Unknown Source)
java.awt.EventQueue$3.run(Unknown Source)
java.awt.EventQueue$3.run(Unknown Source)
java.security.AccessController.doPrivileged(Native Method)
java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
java.awt.EventQueue$4.run(Unknown Source)
java.awt.EventQueue$4.run(Unknown Source)
java.security.AccessController.doPrivileged(Native Method)
java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
java.awt.EventQueue.dispatchEvent(Unknown Source)
java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
java.awt.EventDispatchThread.pumpEvents(Unknown Source)
java.awt.EventDispatchThread.pumpEvents(Unknown Source)
java.awt.EventDispatchThread.run(Unknown Source)
I don't need help diagnosing this particular problem, the problem is clear (the user is trying to sort a JTable
somewhere in the application, but the values in that column are Double
s, but the table declaration said to expect Integer
s). However, I have no idea by this stack trace which JTable
is the source of the problem (and there are a LOT of tables in my app). Without knowing WHERE the problem is coming from, I have no way of fixing it.
So, is there any more useful debugging information I can obtain to help find the source of this problem and others like it?
Note: it's not just the fact that every line says "Unknown source," because none of the classes listed in the stack trace are my classes, they are all library classes. So even if they gave a line number to the problem, it would be to a class I cannot fix.