class AutoKryo extends Kryo {
    protected ArrayList<Class<?>> registeredClasses = new ArrayList<Class<?>>(); 
    
    @Override
    protected void handleUnregisteredClass(@SuppressWarnings("rawtypes") Class type) {
        System.err.println("UNREGISTERED FOR KRYO "+type+" in "+registeredClasses.get(0));
        super.handleUnregisteredClass(type);
    }

    public void autoregister(Class<?> type) {
        if (registeredClasses.contains(type)) {
            return;
        }
        registeredClasses.add(type); 
        try {
            invokeStatic(
                "autoregisterTo", 
                type,
                new Class[]{ ((Class<?>)AutoKryo.class), }, 
                new Object[] { this, });
        } catch (Exception e) {
            register(type); 
        }
    }

    protected static final ReflectionFactory REFLECTION_FACTORY = ReflectionFactory.getReflectionFactory();
    protected static final Object[] INITARGS = new Object[0];
    protected static final Map<Class<?>, Constructor<?>> CONSTRUCTOR_CACHE = new ConcurrentHashMap<Class<?>, Constructor<?>>();
    
    @Override
    public <T> T newInstance(Class<T> type) {<FILL_FUNCTION_BODY>}

    protected Object invokeStatic(String method, Class<?> clazz, Class<?>[] types, Object[] args) throws Exception {
        return clazz.getMethod(method, types).invoke(null, args);
    }
}

        SerializationException ex = null; 
        try {
            return super.newInstance(type);
        } catch (SerializationException se) {
            ex = se;
        }
        try {
            Constructor<?> constructor = CONSTRUCTOR_CACHE.get(type);
            if(constructor == null) {
                constructor = REFLECTION_FACTORY.newConstructorForSerialization( 
                        type, Object.class.getDeclaredConstructor( new Class[0] ) );
                constructor.setAccessible( true );
                CONSTRUCTOR_CACHE.put(type, constructor);
            }
            Object inst = constructor.newInstance( INITARGS );
            return (T) inst;
        } catch (SecurityException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
             e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
        throw ex;
    
<no_super_class>