public static <T> T createProxy(final T underlying, final GenericInvocationHandler<T> invocationHandler) {
// TODO refactor - to get rid of endless try - catch
final ClassLoader currentThreadClassLoader = Thread.currentThread().getContextClassLoader();
try {
final Enhancer enhancer = createProxy(underlying, invocationHandler, ProxyNamingPolicy.INSTANCE, currentThreadClassLoader);
return (T) enhancer.create();
} catch (CodeGenerationException e) {
// fallback, as proxied class might implement non-public interfaces
// that have trouble with our ProxyNamingPolicy (for example for SQLite)
try {
final Enhancer enhancer = createProxy(underlying, invocationHandler, null, currentThreadClassLoader);