@Test public void properlyBubblesException() { try { converter(TakesSingleStringAndThrows.class).fromString(null); fail(); } catch (RuntimeException e) { assertEquals(PrivateLocalRuntimException.class, e.getClass()); } }
@Override @SuppressWarnings("unchecked") public T fromString(String representation) { try { constructor.setAccessible(true); return (T) constructor.newInstance(representation); } catch (IllegalArgumentException e) { throw new IllegalStateException( "unreachable since we check the number of arguments the " + "constructor takes when building this converter", e); } catch (InstantiationException e) { throw new IllegalStateException( "unreachable since we check that the class is not abstract", e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { try { throw e.getTargetException(); } catch (RuntimeException targetException) { throw targetException; } catch (Throwable targetException) { throw new RuntimeException(e); } } }
StringConstructorConverter implements Converter<T> { @Override @SuppressWarnings("unchecked") public T fromString(String representation) { try { constructor.setAccessible(true); return (T) constructor.newInstance(representation); } catch (IllegalArgumentException e) { throw new IllegalStateException( "unreachable since we check the number of arguments the " + "constructor takes when building this converter", e); } catch (InstantiationException e) { throw new IllegalStateException( "unreachable since we check that the class is not abstract", e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { try { throw e.getTargetException(); } catch (RuntimeException targetException) { throw targetException; } catch (Throwable targetException) { throw new RuntimeException(e); } } } }
StringConstructorConverter implements Converter<T> { @Override @SuppressWarnings("unchecked") public T fromString(String representation) { try { constructor.setAccessible(true); return (T) constructor.newInstance(representation); } catch (IllegalArgumentException e) { throw new IllegalStateException( "unreachable since we check the number of arguments the " + "constructor takes when building this converter", e); } catch (InstantiationException e) { throw new IllegalStateException( "unreachable since we check that the class is not abstract", e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { try { throw e.getTargetException(); } catch (RuntimeException targetException) { throw targetException; } catch (Throwable targetException) { throw new RuntimeException(e); } } } StringConstructorConverter(Constructor<?> constructor); }
StringConstructorConverter implements Converter<T> { @Override @SuppressWarnings("unchecked") public T fromString(String representation) { try { constructor.setAccessible(true); return (T) constructor.newInstance(representation); } catch (IllegalArgumentException e) { throw new IllegalStateException( "unreachable since we check the number of arguments the " + "constructor takes when building this converter", e); } catch (InstantiationException e) { throw new IllegalStateException( "unreachable since we check that the class is not abstract", e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { try { throw e.getTargetException(); } catch (RuntimeException targetException) { throw targetException; } catch (Throwable targetException) { throw new RuntimeException(e); } } } StringConstructorConverter(Constructor<?> constructor); @Override String toString(T value); @Override @SuppressWarnings("unchecked") T fromString(String representation); }
StringConstructorConverter implements Converter<T> { @Override @SuppressWarnings("unchecked") public T fromString(String representation) { try { constructor.setAccessible(true); return (T) constructor.newInstance(representation); } catch (IllegalArgumentException e) { throw new IllegalStateException( "unreachable since we check the number of arguments the " + "constructor takes when building this converter", e); } catch (InstantiationException e) { throw new IllegalStateException( "unreachable since we check that the class is not abstract", e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { try { throw e.getTargetException(); } catch (RuntimeException targetException) { throw targetException; } catch (Throwable targetException) { throw new RuntimeException(e); } } } StringConstructorConverter(Constructor<?> constructor); @Override String toString(T value); @Override @SuppressWarnings("unchecked") T fromString(String representation);  }