diff -r cc69c7cc3c58 -r 436a5a828d9f jdk/src/share/classes/java/awt/EventDispatchThread.java --- a/jdk/src/share/classes/java/awt/EventDispatchThread.java Wed Sep 10 15:02:06 2008 +0400 +++ b/jdk/src/share/classes/java/awt/EventDispatchThread.java Thu Sep 11 10:38:00 2008 +0400 @@ -286,119 +286,19 @@ } // Can get and throw only unchecked exceptions catch (RuntimeException e) { - processException(e, modalFiltersCount > 0); + processException(e); } catch (Error e) { - processException(e, modalFiltersCount > 0); + processException(e); } return true; } - private void processException(Throwable e, boolean isModal) { + private void processException(Throwable e) { if (eventLog.isLoggable(Level.FINE)) { - eventLog.log(Level.FINE, "Processing exception: " + e + - ", isModal = " + isModal); - } - if (!handleException(e)) { - // See bug ID 4499199. - // If we are in a modal dialog, we cannot throw - // an exception for the ThreadGroup to handle (as added - // in RFE 4063022). If we did, the message pump of - // the modal dialog would be interrupted. - // We instead choose to handle the exception ourselves. - // It may be useful to add either a runtime flag or API - // later if someone would like to instead dispose the - // dialog and allow the thread group to handle it. - if (isModal) { - System.err.println( - "Exception occurred during event dispatching:"); - e.printStackTrace(); - } else if (e instanceof RuntimeException) { - throw (RuntimeException)e; - } else if (e instanceof Error) { - throw (Error)e; - } + eventLog.log(Level.FINE, "Processing exception: " + e); } - } - - private static final String handlerPropName = "sun.awt.exception.handler"; - private static String handlerClassName = null; - private static String NO_HANDLER = new String(); - - /** - * Handles an exception thrown in the event-dispatch thread. - * - *

If the system property "sun.awt.exception.handler" is defined, then - * when this method is invoked it will attempt to do the following: - * - *

    - *
  1. Load the class named by the value of that property, using the - * current thread's context class loader, - *
  2. Instantiate that class using its zero-argument constructor, - *
  3. Find the resulting handler object's public void handle - * method, which should take a single argument of type - * Throwable, and - *
  4. Invoke the handler's handle method, passing it the - * thrown argument that was passed to this method. - *
- * - * If any of the first three steps fail then this method will return - * false and all following invocations of this method will return - * false immediately. An exception thrown by the handler object's - * handle will be caught, and will cause this method to return - * false. If the handler's handle method is successfully - * invoked, then this method will return true. This method will - * never throw any sort of exception. - * - *

Note: This method is a temporary hack to work around the - * absence of a real API that provides the ability to replace the - * event-dispatch thread. The magic "sun.awt.exception.handler" property - * will be removed in a future release. - * - * @param thrown The Throwable that was thrown in the event-dispatch - * thread - * - * @return false if any of the above steps failed, otherwise - * true - */ - private boolean handleException(Throwable thrown) { - - try { - - if (handlerClassName == NO_HANDLER) { - return false; /* Already tried, and failed */ - } - - /* Look up the class name */ - if (handlerClassName == null) { - handlerClassName = ((String) AccessController.doPrivileged( - new GetPropertyAction(handlerPropName))); - if (handlerClassName == null) { - handlerClassName = NO_HANDLER; /* Do not try this again */ - return false; - } - } - - /* Load the class, instantiate it, and find its handle method */ - Method m; - Object h; - try { - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - Class c = Class.forName(handlerClassName, true, cl); - m = c.getMethod("handle", new Class[] { Throwable.class }); - h = c.newInstance(); - } catch (Throwable x) { - handlerClassName = NO_HANDLER; /* Do not try this again */ - return false; - } - - /* Finally, invoke the handler */ - m.invoke(h, new Object[] { thrown }); - - } catch (Throwable x) { - return false; - } - - return true; + getUncaughtExceptionHandler().uncaughtException(this, e); + // don't rethrow the exception to avoid EDT recreation } boolean isDispatching(EventQueue eq) {