public ProxyingInstantiator(Class<T> type) { byte[] classBytes = writeExtendingClass(type, SUFFIX); try { newType = ClassDefinitionUtils.defineClass(type.getName() + SUFFIX, classBytes, type.getClassLoader()); } catch (Exception e) { throw new ObjenesisException(e); } }
private <T> ObjectInstantiator<T> newInstantiatorOf(Class<T> type) { String suffix = type.getSimpleName(); String className = getClass().getName() + "$$$" + suffix; Class<ObjectInstantiator<T>> clazz = getExistingClass(getClass().getClassLoader(), className); if(clazz == null) { byte[] classBytes = writeExtendingClass(type, className); try { clazz = ClassDefinitionUtils.defineClass(className, classBytes, getClass().getClassLoader()); } catch (Exception e) { throw new ObjenesisException(e); } } try { return clazz.newInstance(); } catch (InstantiationException e) { throw new ObjenesisException(e); } catch (IllegalAccessException e) { throw new ObjenesisException(e); } }