diff options
author | Carsten Hammer | 2019-05-08 17:43:11 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2019-05-15 06:18:48 +0000 |
commit | 1603715d7ac7f727f9d5dcc537c629e023874ab4 (patch) | |
tree | fef0f7c8e221a365e50ebfc38fc65f0807bfbffe | |
parent | 79b28df3f0c7b68970e2fe6bc9eddddab436df4f (diff) | |
download | rt.equinox.framework-1603715d7ac7f727f9d5dcc537c629e023874ab4.tar.gz rt.equinox.framework-1603715d7ac7f727f9d5dcc537c629e023874ab4.tar.xz rt.equinox.framework-1603715d7ac7f727f9d5dcc537c629e023874ab4.zip |
Join catch sections using multicatch
Change-Id: Id35c9d1f3d70f1ff4c683b88cc054213b1291a17
Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
17 files changed, 27 insertions, 82 deletions
diff --git a/bundles/org.eclipse.equinox.launcher/pom.xml b/bundles/org.eclipse.equinox.launcher/pom.xml index 478cc1a2c..32474b70b 100644 --- a/bundles/org.eclipse.equinox.launcher/pom.xml +++ b/bundles/org.eclipse.equinox.launcher/pom.xml @@ -5,7 +5,7 @@ are made available under the terms of the Eclipse Distribution License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/org/documents/edl-v10.php - + Contributors: Igor Fedorenko - initial implementation --> diff --git a/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java b/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java index 22b0bd520..94cb082f3 100644 --- a/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java +++ b/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java @@ -635,10 +635,9 @@ public class Main { // JavaSE-9's extension path in Java 9-ea+108. The identifier "1.9" could be changed to "9", but "1.9" works just as well. type = PARENT_CLASSLOADER_EXT; } - } catch (SecurityException e) { + } catch (SecurityException | NumberFormatException e) { // If the security manager won't allow us to get the system property, continue for // now and let things fail later on their own if necessary. - } catch (NumberFormatException e) { // If the version string was in a format that we don't understand, continue and // let things fail later on their own if necessary. } @@ -690,11 +689,9 @@ public class Main { System.setProperty(PROP_EXITDATA, "<title>Incompatible JVM</title>Version " + availableVersion + " of the JVM is not suitable for this product. Version: " + requiredVersion + " or greater is required."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } return compatible; - } catch (SecurityException e) { + } catch (SecurityException | NumberFormatException e) { // If the security manager won't allow us to get the system property, continue for // now and let things fail later on their own if necessary. - return true; - } catch (NumberFormatException e) { // If the version string was in a format that we don't understand, continue and // let things fail later on their own if necessary. return true; diff --git a/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/WebStartMain.java b/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/WebStartMain.java index 703c18e74..0ac4a62d9 100644 --- a/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/WebStartMain.java +++ b/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/WebStartMain.java @@ -236,14 +236,11 @@ public class WebStartMain extends Main { try { nameField.setAccessible(true); return (String) nameField.get(jarFile); - } catch (SecurityException e) { + } catch (SecurityException | IllegalArgumentException | IllegalAccessException e) { // Don't have permissions, ignore - } catch (IllegalArgumentException e) { - // Shouldn't happen - } catch (IllegalAccessException e) { + // or // Shouldn't happen } - return null; } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java index b3c75ab5e..a1179ba10 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java @@ -1006,10 +1006,7 @@ public class EclipseStarter { // include basic bundles in case they were not resolved before if ((osgiBundle.getState() & Bundle.INSTALLED) != 0) toRefresh.add(osgiBundle); - } catch (BundleException e) { - FrameworkLogEntry entry = new FrameworkLogEntry(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, 0, NLS.bind(Msg.ECLIPSE_STARTUP_FAILED_INSTALL, initialBundles[i].location), 0, e, null); - log.log(entry); - } catch (IOException e) { + } catch (BundleException | IOException e) { FrameworkLogEntry entry = new FrameworkLogEntry(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, 0, NLS.bind(Msg.ECLIPSE_STARTUP_FAILED_INSTALL, initialBundles[i].location), 0, e, null); log.log(entry); } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/internal/adaptor/DefaultStartupMonitor.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/internal/adaptor/DefaultStartupMonitor.java index 4f6132358..b38cc4d4a 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/internal/adaptor/DefaultStartupMonitor.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/core/runtime/internal/adaptor/DefaultStartupMonitor.java @@ -38,12 +38,11 @@ public class DefaultStartupMonitor implements StartupMonitor { try { updateMethod = splashHandler.getClass().getMethod("updateSplash", (Class[]) null); //$NON-NLS-1$ - } catch (SecurityException e) { - throw new IllegalStateException(e.getMessage(), e); - } catch (NoSuchMethodException e) { + } catch (SecurityException | NoSuchMethodException e) { //TODO maybe we could do something else in the update method in this case, like print something to the console? throw new IllegalStateException(e.getMessage(), e); } + } /* (non-Javadoc) diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainer.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainer.java index 0b63d1a46..319b21f5d 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainer.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainer.java @@ -1758,10 +1758,7 @@ public final class ModuleContainer implements DebugOptionsListener { // of launching or shutting down the framework adaptor.publishContainerEvent(ContainerEvent.START_LEVEL, module, null, listeners); } - } catch (Error e) { - adaptor.publishContainerEvent(ContainerEvent.ERROR, module, e, listeners); - throw e; - } catch (RuntimeException e) { + } catch (Error | RuntimeException e) { adaptor.publishContainerEvent(ContainerEvent.ERROR, module, e, listeners); throw e; } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainer.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainer.java index b3d2b5cba..3965b2832 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainer.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainer.java @@ -70,9 +70,7 @@ public class EquinoxContainer implements ThreadFactory, Runnable { this.equinoxConfig.getHookRegistry().initialize(); try { this.storage = Storage.createStorage(this); - } catch (IOException e) { - throw new RuntimeException("Error initializing storage.", e); //$NON-NLS-1$ - } catch (BundleException e) { + } catch (IOException | BundleException e) { throw new RuntimeException("Error initializing storage.", e); //$NON-NLS-1$ } this.packageAdmin = new PackageAdminImpl(storage.getModuleContainer()); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/FilterImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/FilterImpl.java index aaf5f4009..eb10f3b86 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/FilterImpl.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/FilterImpl.java @@ -1167,9 +1167,7 @@ public class FilterImpl implements Filter /* since Framework 1.1 */ { setAccessible(method); try { return method.invoke(null, value2.trim()); - } catch (IllegalAccessException e) { - return null; - } catch (InvocationTargetException e) { + } catch (IllegalAccessException | InvocationTargetException e) { return null; } } @@ -1185,11 +1183,7 @@ public class FilterImpl implements Filter /* since Framework 1.1 */ { setAccessible(constructor); try { return constructor.newInstance(value2.trim()); - } catch (IllegalAccessException e) { - return null; - } catch (InvocationTargetException e) { - return null; - } catch (InstantiationException e) { + } catch (IllegalAccessException | InvocationTargetException | InstantiationException e) { return null; } } while (false); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/ModuleClassLoader.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/ModuleClassLoader.java index f056a51f9..89eaa42b7 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/ModuleClassLoader.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/ModuleClassLoader.java @@ -155,13 +155,7 @@ public abstract class ModuleClassLoader extends ClassLoader implements BundleRef if (resolve) resolveClass(clazz); return (clazz); - } catch (Error e) { - if (getDebug().DEBUG_LOADER) { - Debug.println("ModuleClassLoader[" + getBundleLoader() + "].loadClass(" + name + ") failed."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - Debug.printStackTrace(e); - } - throw e; - } catch (ClassNotFoundException e) { + } catch (Error | ClassNotFoundException e) { // If the class is not found do not try to look for it locally. // The delegate would have already done that for us. if (getDebug().DEBUG_LOADER) { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminAdapter.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminAdapter.java index 360bd50bf..b07a9a1c5 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminAdapter.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminAdapter.java @@ -66,10 +66,7 @@ public class EventAdminAdapter implements ServiceTrackerCustomizer<Object, Objec if (eventAdmin != null && logEventHandlers > 0 && logListener == null) { try { logListener = new EventAdminLogListener(context.getService(eventAdmin)); - } catch (ClassNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (NoSuchMethodException e) { + } catch (ClassNotFoundException | NoSuchMethodException e) { // TODO Auto-generated catch block e.printStackTrace(); } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminLogListener.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminLogListener.java index 5f20cbc9a..fb752e0be 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminLogListener.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EventAdminLogListener.java @@ -73,10 +73,7 @@ public class EventAdminLogListener implements SynchronousLogListener { throw (Error) t; // unexpected throw new RuntimeException(e); - } catch (IllegalAccessException e) { - // unexpected - throw new RuntimeException(e); - } catch (InstantiationException e) { + } catch (IllegalAccessException | InstantiationException e) { // unexpected throw new RuntimeException(e); } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogReaderServiceFactory.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogReaderServiceFactory.java index de227b7ca..620e31ba1 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogReaderServiceFactory.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogReaderServiceFactory.java @@ -82,12 +82,9 @@ public class ExtendedLogReaderServiceFactory implements ServiceFactory<ExtendedL static boolean safeIsLoggable(LogFilter filter, Bundle bundle, String name, int level) { try { return filter.isLoggable(bundle, name, level); - } catch (RuntimeException e) { + } catch (RuntimeException | LinkageError e) { // "listener.logged" calls user code and might throw an unchecked exception // we catch the error here to gather information on where the problem occurred. - getErrorStream().println("LogFilter.isLoggable threw a non-fatal unchecked exception as follows:"); //$NON-NLS-1$ - e.printStackTrace(getErrorStream()); - } catch (LinkageError e) { // Catch linkage errors as these are generally recoverable but let other Errors propagate (see bug 222001) getErrorStream().println("LogFilter.isLoggable threw a non-fatal unchecked exception as follows:"); //$NON-NLS-1$ e.printStackTrace(getErrorStream()); @@ -109,16 +106,13 @@ public class ExtendedLogReaderServiceFactory implements ServiceFactory<ExtendedL static void safeLogged(LogListener listener, LogEntry logEntry) { try { listener.logged(logEntry); - } catch (RuntimeException e) { + } catch (RuntimeException | LinkageError e) { // "listener.logged" calls user code and might throw an unchecked exception // we catch the error here to gather information on where the problem occurred. - getErrorStream().println("LogListener.logged threw a non-fatal unchecked exception as follows:"); //$NON-NLS-1$ - e.printStackTrace(getErrorStream()); - } catch (LinkageError e) { // Catch linkage errors as these are generally recoverable but let other Errors propagate (see bug 222001) getErrorStream().println("LogListener.logged threw a non-fatal unchecked exception as follows:"); //$NON-NLS-1$ e.printStackTrace(getErrorStream()); - } + } } public ExtendedLogReaderServiceFactory(int maxHistory, LogLevel defaultLevel) { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedBundleHook.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedBundleHook.java index 7d8091c92..913d60a11 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedBundleHook.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedBundleHook.java @@ -173,9 +173,7 @@ public class SignedBundleHook implements ActivatorHookFactory, BundleFileWrapper return new BundleFileWrapper(signedBaseFile); } } - } catch (IOException e) { - log("Bad bundle file: " + bundleFile.getBaseFile(), FrameworkLogEntry.WARNING, e); //$NON-NLS-1$ - } catch (GeneralSecurityException e) { + } catch (IOException | GeneralSecurityException e) { log("Bad bundle file: " + bundleFile.getBaseFile(), FrameworkLogEntry.WARNING, e); //$NON-NLS-1$ } return null; diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java index 66542b93e..70e43c7da 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java @@ -65,13 +65,12 @@ public class FrameworkExtensionInstaller { Method result = clazz.getDeclaredMethod(name, args); result.setAccessible(true); return result; - } catch (NoSuchMethodException e) { - // do nothing look in super class below } catch (SecurityException e) { // if we do not have the permissions then we will not find the method - } catch (RuntimeException e) { + } catch (NoSuchMethodException | RuntimeException e) { + // do nothing look in super class below // have to avoid blowing up <clinit> - } + } return findMethod(clazz.getSuperclass(), name, args); } @@ -129,11 +128,9 @@ public class FrameworkExtensionInstaller { continue; try { callAddURLMethod(StorageUtil.encodeFileURL(files[i])); - } catch (InvocationTargetException e) { + } catch (InvocationTargetException | MalformedURLException e) { throw new BundleException("Error adding extension content.", e); //$NON-NLS-1$ - } catch (MalformedURLException e) { - throw new BundleException("Error adding extension content.", e); //$NON-NLS-1$ - } + } } } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/ZipBundleFile.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/ZipBundleFile.java index db62f0741..b80ed90ef 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/ZipBundleFile.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/ZipBundleFile.java @@ -235,11 +235,7 @@ public class ZipBundleFile extends BundleFile { return nested; } - } catch (IOException e) { - if (debug.DEBUG_BUNDLE_FILE) - Debug.printStackTrace(e); - generation.getBundleInfo().getStorage().getLogServices().log(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, "Unable to extract content: " + generation.getRevision() + ": " + entry, e); //$NON-NLS-1$ //$NON-NLS-2$ - } catch (StorageException e) { + } catch (IOException | StorageException e) { if (debug.DEBUG_BUNDLE_FILE) Debug.printStackTrace(e); generation.getBundleInfo().getStorage().getLogServices().log(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, "Unable to extract content: " + generation.getRevision() + ": " + entry, e); //$NON-NLS-1$ //$NON-NLS-2$ diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/EventManager.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/EventManager.java index 07916e094..22982e794 100644 --- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/EventManager.java +++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/EventManager.java @@ -346,12 +346,7 @@ public class EventManager { // will not automatically clear this variable for each loop iteration. item = null; } - } catch (RuntimeException e) { - if (EventManager.DEBUG) { - e.printStackTrace(); - } - throw e; - } catch (Error e) { + } catch (RuntimeException | Error e) { if (EventManager.DEBUG) { e.printStackTrace(); } diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/LocationHelper.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/LocationHelper.java index 2f5d843fd..fe5267c29 100644 --- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/LocationHelper.java +++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/LocationHelper.java @@ -145,11 +145,9 @@ public class LocationHelper { } try { return URLDecoder.decode(urlString, "UTF-8"); //$NON-NLS-1$ - } catch (UnsupportedEncodingException e) { + } catch (UnsupportedEncodingException | RuntimeException e) { // Tried but failed // TODO should we throw runtime exception here? - return urlString; - } catch (RuntimeException e) { // May have illegal characters for decoding return urlString; } |