Retiring Checked Exceptions Was: Throwing Functions
Archie Cobbs
archie.cobbs at gmail.com
Mon Nov 14 23:09:03 UTC 2022
On Mon, Nov 14, 2022 at 4:52 PM <forax at univ-mlv.fr> wrote:
> I'm proposing to demote checked exceptions to make them second class
> citizen because this practically what they are.
> The problem is that the status quo is pushing people to use runtime
> exceptions instead of exceptions because checked exception do not compose
> well, exactly what we both do not want.
>
I totally agree that the lack of composibility (composibleness?) is a
problem. But I don't agree that ALL of the blame for that problem rests on
checked exceptions. After all, checked exceptions have been around a lot
longer than lambdas.
> What if checked exceptions work like unchecked casts ?
>
This sounds like a much more promising direction to go in.
All we want is a simple way to tell the compiler "I know this lambda can
throw a checked exception, just pass it through instead of making this
impossible to compile".
E.g. something like this??
public <T> void execute(@PassThroughCheckedExceptions Supplier<T> getter) {
return getter.get();
}
public InputStream openFile(File file) throws IOException {
this.execute(FileInputStream::new);
}
-Archie
--
Archie L. Cobbs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20221114/40984699/attachment.htm>
More information about the amber-dev
mailing list