@Test public void isDeserializable() throws IOException, ClassNotFoundException { checked = false; class Instantiated {{ checked = true; }} FunkyFunction<Instantiated> original = new FunkyFunction<Instantiated>(Instantiated.class); ByteArrayOutputStream out = serialize(original); FunkyFunction<Instantiated> copy = deserialize(out); copy.execute(); assertTrue(checked); }
public T execute() { try { return constructor.newInstance(constructionArguments); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); if (cause instanceof Error) { throw ((Error) cause); } else { throw ((RuntimeException) cause); } } catch (Exception e) { throw new IllegalStateException("This should never happen. Due to previously checked constraints (see extractConstructor()), no exception may actually be caught here.", e); } }
FunkyFunction implements ClassFunction<T> { public T execute() { try { return constructor.newInstance(constructionArguments); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); if (cause instanceof Error) { throw ((Error) cause); } else { throw ((RuntimeException) cause); } } catch (Exception e) { throw new IllegalStateException("This should never happen. Due to previously checked constraints (see extractConstructor()), no exception may actually be caught here.", e); } } }
FunkyFunction implements ClassFunction<T> { public T execute() { try { return constructor.newInstance(constructionArguments); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); if (cause instanceof Error) { throw ((Error) cause); } else { throw ((RuntimeException) cause); } } catch (Exception e) { throw new IllegalStateException("This should never happen. Due to previously checked constraints (see extractConstructor()), no exception may actually be caught here.", e); } } FunkyFunction(Class<T> applyingClass, Object... constructorArguments); }
FunkyFunction implements ClassFunction<T> { public T execute() { try { return constructor.newInstance(constructionArguments); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); if (cause instanceof Error) { throw ((Error) cause); } else { throw ((RuntimeException) cause); } } catch (Exception e) { throw new IllegalStateException("This should never happen. Due to previously checked constraints (see extractConstructor()), no exception may actually be caught here.", e); } } FunkyFunction(Class<T> applyingClass, Object... constructorArguments); T execute(); @Override String getClassSimpleName(); }
FunkyFunction implements ClassFunction<T> { public T execute() { try { return constructor.newInstance(constructionArguments); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); if (cause instanceof Error) { throw ((Error) cause); } else { throw ((RuntimeException) cause); } } catch (Exception e) { throw new IllegalStateException("This should never happen. Due to previously checked constraints (see extractConstructor()), no exception may actually be caught here.", e); } } FunkyFunction(Class<T> applyingClass, Object... constructorArguments); T execute(); @Override String getClassSimpleName();  }