Agreed, and Java generics are erased at compile time and offer no run time benefits.

Kind regards,
Ben.

On 07/06/18 08:06, Nuno Oliveira wrote:
Hi Ben,

+1 for the NON generics option, my felling is that usually generics bring more harm than good in the long run :(


On 06/06/2018 03:44 AM, Ben Caradoc-Davies wrote:
Or with generics:


public interface ThrowingDisposable<T extends Exception> extends AutoCloseable {
    /**
     * @see java.lang.AutoCloseable#close()
     */
    @Deprecated
    @Override
    default void close() throws T {
        dispose();
    }
    void dispose() throws T;
}
public interface Disposable extends ThrowingDisposable<Exception> {
    /**
     * @see java.lang.AutoCloseable#close()
     */
    @Deprecated
    @Override
    default void close() {
        dispose();
    }
    @Override
    void dispose();
}


Or just keep it simple and have dispose throw Exception like java.lang.AutoCloseable#close() and let implementers narrow the return type to no exception if they like. Impact will be minimal as client code will likely use an implementer not a bare Disposable:


public interface Disposable extends AutoCloseable{
    /**
     * @throws Exception
     * @see java.lang.AutoCloseable#close()
     */
    @Deprecated
    @Override
    default void close() throws Exception{
        dispose();
    }
    void dispose() throws Exception;
}


Preference?

Kind regards,



--
Ben Caradoc-Davies <b...@transient.nz>
Director
Transient Software Limited <https://transient.nz/>
New Zealand

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
GeoTools-Devel mailing list
GeoTools-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to