Clover Coverage Report - FEST Swing 1.2
Coverage timestamp: Tue Jun 1 2010 15:19:25 PDT
../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
5   58   3   2.5
0   19   0.6   2
2     1.5  
1    
12.5% of code in this file is excluded from these metrics.
 
  AWTExceptionHandlerInstaller       Line # 34 5 12.5% 3 0 100% 1.0
 
No Tests
 
1    /*
2    * Created on Jan 5, 2010
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5    * in compliance with the License. You may obtain a copy of the License at
6    *
7    * http://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software distributed under the License
10    * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11    * or implied. See the License for the specific language governing permissions and limitations under
12    * the License.
13    *
14    * Copyright @2010 the original author or authors.
15    */
16    package org.fest.swing.util;
17   
18    import org.fest.reflect.core.Reflection;
19    import org.fest.util.VisibleForTesting;
20   
21    /**
22    * Understands installation of AWT exception handlers.
23    * <p>
24    * An exception handler is passed to the JVM using the system property "sun.awt.exception.handler" to override the
25    * default exception handling behavior of the event dispatch thread.
26    * </p>
27    * <p>
28    * This is a Sun-specific feature (or "bug".) See <a
29    * href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4714232" target="_blank">bug 4714232</a>.
30    * </p>
31    *
32    * @author Alex Ruiz
33    */
 
34    public final class AWTExceptionHandlerInstaller {
35   
36    private static final SystemPropertyWriter WRITER = new SystemPropertyWriter();
37   
38    /**
39    * Installs the given exception handler type.
40    * @param exceptionHandlerType the type of exception handler to be installed in the current JVM.
41    * @throws IllegalArgumentException if the given type does not have a default constructor.
42    */
 
43  6 toggle public static void installAWTExceptionHandler(Class<?> exceptionHandlerType) {
44  6 installAWTExceptionHandler(exceptionHandlerType, WRITER);
45    }
46   
 
47  8 toggle @VisibleForTesting
48    static void installAWTExceptionHandler(Class<?> exceptionHandlerType, SystemPropertyWriter writer) {
49  8 try {
50  8 Reflection.constructor().in(exceptionHandlerType).info();
51    } catch (RuntimeException e) {
52  1 throw new IllegalArgumentException("The exception handler type should have a default constructor");
53    }
54  7 writer.updateSystemProperty("sun.awt.exception.handler", exceptionHandlerType.getName());
55    }
56   
 
57    toggle private AWTExceptionHandlerInstaller() {}
58    }