From 46bfb2b885728e44f9798ad87de9d03ee666a3bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=8A?= =?UTF-8?q?=D1=80=20=D0=9A=D1=83=D1=80=D1=82=D0=B0=D0=BA=D0=BE=D0=B2?= Date: Wed, 29 Nov 2023 22:54:14 +0200 Subject: [PATCH] Use pattern matching in ExceptionStash --- .../eclipse/swt/internal/ExceptionStash.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/ExceptionStash.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/ExceptionStash.java index f950d1f8471..aed78473dc5 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/ExceptionStash.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/ExceptionStash.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2021 Syntevo and others. + * Copyright (c) 2021, 2023 Syntevo and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -59,12 +59,12 @@ public void stash(Throwable throwable) { try { Display display = Display.getCurrent (); if (display != null) { - if (throwable instanceof RuntimeException) { - display.getRuntimeExceptionHandler().accept((RuntimeException)throwable); + if (throwable instanceof RuntimeException runtimeEx) { + display.getRuntimeExceptionHandler().accept(runtimeEx); /* If handler doesn't throw then the exception is fully handled */ return; - } else if (throwable instanceof Error) { - display.getErrorHandler().accept((Error)throwable); + } else if (throwable instanceof Error er) { + display.getErrorHandler().accept(er); /* If handler doesn't throw then the exception is fully handled */ return; } @@ -88,10 +88,10 @@ public void close() { Throwable throwable = storedThrowable; storedThrowable = null; - if (throwable instanceof RuntimeException) { - throw (RuntimeException)throwable; - } else if (throwable instanceof Error) { - throw (Error)throwable; + if (throwable instanceof RuntimeException runtimeEx) { + throw runtimeEx; + } else if (throwable instanceof Error er) { + throw er; } }