Sealed Exception
Remi Forax
forax at univ-mlv.fr
Fri Sep 24 09:45:27 UTC 2021
----- Original Message -----
> From: "Zheka Kozlov" <orionllmain at gmail.com>
> To: "amber-dev" <amber-dev at openjdk.java.net>
> Sent: Vendredi 24 Septembre 2021 10:30:54
> Subject: Sealed Exception
> Hi!
CC amber-spec-experts
>
> Java 17 compiler forces me to insert an unreachable catch block for the
> base Exception:
>
> public static void main(String[] args) {
> try {
> f();
> } catch (Ex1 e) {
> e.printStackTrace();
> } catch (Ex2 e) {
> e.printStackTrace();
> } catch (BaseEx e) {
> // Unreachable
> }
> }
>
> private static void f() throws BaseEx {
> }
>
> sealed abstract class BaseEx extends Exception permits Ex1, Ex2 {
> }
>
> Otherwise it doesn't compile. Was this decision intentional?
I don't think so, it's something we have overlooked.
> If yes, why? If not, can we fix it? I see this as an unfortunate limitation.
I agree, it should be fixed.
>
> With best regards, Zheka Kozlov.
Regards,
Rémi
More information about the amber-spec-experts
mailing list