Skip to content

Commit 695d865

Browse files
author
Andrey Turbanov
committed
8284672: Collapse identical catch branches in java.desktop
Reviewed-by: prr, aivanov, serb
1 parent 7acdcc1 commit 695d865

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+130
-297
lines changed

src/java.desktop/macosx/classes/com/apple/laf/AquaSpinnerUI.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -439,9 +439,7 @@ public void actionPerformed(final ActionEvent e) {
439439
spinner.setValue(value);
440440
select(spinner);
441441
}
442-
} catch (final IllegalArgumentException iae) {
443-
UIManager.getLookAndFeel().provideErrorFeedback(spinner);
444-
} catch (final ParseException pe) {
442+
} catch (IllegalArgumentException | ParseException ex) {
445443
UIManager.getLookAndFeel().provideErrorFeedback(spinner);
446444
}
447445
}

src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -3808,12 +3808,8 @@ private void loadIfNecessary() {
38083808
method.invoke(klass, new Object[] { this });
38093809
} catch (final NoSuchMethodException nsme) {
38103810
assert false : "LazyActionMap unable to load actions " + klass;
3811-
} catch (final IllegalAccessException iae) {
3812-
assert false : "LazyActionMap unable to load actions " + iae;
3813-
} catch (final InvocationTargetException ite) {
3814-
assert false : "LazyActionMap unable to load actions " + ite;
3815-
} catch (final IllegalArgumentException iae) {
3816-
assert false : "LazyActionMap unable to load actions " + iae;
3811+
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
3812+
assert false : "LazyActionMap unable to load actions " + e;
38173813
}
38183814
}
38193815
}

src/java.desktop/share/classes/com/sun/beans/decoder/DocumentHandler.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -378,7 +378,7 @@ public Void run() {
378378
try {
379379
SAXParserFactory.newInstance().newSAXParser().parse(input, DocumentHandler.this);
380380
}
381-
catch (ParserConfigurationException exception) {
381+
catch (ParserConfigurationException | IOException exception) {
382382
handleException(exception);
383383
}
384384
catch (SAXException wrapper) {
@@ -388,9 +388,6 @@ public Void run() {
388388
}
389389
handleException(exception);
390390
}
391-
catch (IOException exception) {
392-
handleException(exception);
393-
}
394391
return null;
395392
}
396393
}, stack, this.acc);

src/java.desktop/share/classes/com/sun/beans/finder/ClassFinder.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2006, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -67,9 +67,7 @@ public static Class<?> findClass(String name) throws ClassNotFoundException {
6767
return Class.forName(name, false, loader);
6868
}
6969

70-
} catch (ClassNotFoundException exception) {
71-
// use current class loader instead
72-
} catch (SecurityException exception) {
70+
} catch (ClassNotFoundException | SecurityException exception) {
7371
// use current class loader instead
7472
}
7573
return Class.forName(name);
@@ -101,9 +99,7 @@ public static Class<?> findClass(String name, ClassLoader loader) throws ClassNo
10199
if (loader != null) {
102100
try {
103101
return Class.forName(name, false, loader);
104-
} catch (ClassNotFoundException exception) {
105-
// use default class loader instead
106-
} catch (SecurityException exception) {
102+
} catch (ClassNotFoundException | SecurityException exception) {
107103
// use default class loader instead
108104
}
109105
}

src/java.desktop/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -1160,10 +1160,7 @@ public BufferedImage read(int imageIndex, ImageReadParam param)
11601160
cbLock.check();
11611161
try {
11621162
readInternal(imageIndex, param, false);
1163-
} catch (RuntimeException e) {
1164-
resetLibraryState(structPointer);
1165-
throw e;
1166-
} catch (IOException e) {
1163+
} catch (RuntimeException | IOException e) {
11671164
resetLibraryState(structPointer);
11681165
throw e;
11691166
}
@@ -1632,10 +1629,7 @@ public Raster readRaster(int imageIndex, ImageReadParam param)
16321629
target = target.createWritableTranslatedChild(saveDestOffset.x,
16331630
saveDestOffset.y);
16341631
}
1635-
} catch (RuntimeException e) {
1636-
resetLibraryState(structPointer);
1637-
throw e;
1638-
} catch (IOException e) {
1632+
} catch (RuntimeException | IOException e) {
16391633
resetLibraryState(structPointer);
16401634
throw e;
16411635
} finally {

src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageMetadata.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,13 +1473,8 @@ public static TIFFIFD parseIFD(Node node) throws IIOInvalidTreeException {
14731473
Method getInstanceMethod =
14741474
setClass.getMethod("getInstance", (Class[])null);
14751475
o = getInstanceMethod.invoke(null, (Object[])null);
1476-
} catch (NoSuchMethodException e) {
1477-
throw new RuntimeException(e);
1478-
} catch (IllegalAccessException e) {
1479-
throw new RuntimeException(e);
1480-
} catch (InvocationTargetException e) {
1481-
throw new RuntimeException(e);
1482-
} catch (ClassNotFoundException e) {
1476+
} catch (NoSuchMethodException | IllegalAccessException |
1477+
InvocationTargetException | ClassNotFoundException e) {
14831478
throw new RuntimeException(e);
14841479
}
14851480

src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -1357,9 +1357,7 @@ void paintIcon(SynthContext context, Graphics g,
13571357
ENGINE.startPainting(g, x, y, w, h, state, paintMethod);
13581358
try {
13591359
paintMethod.invoke(this, context, g, state, x, y, w, h);
1360-
} catch (IllegalAccessException iae) {
1361-
assert false;
1362-
} catch (InvocationTargetException ite) {
1360+
} catch (IllegalAccessException | InvocationTargetException e) {
13631361
assert false;
13641362
}
13651363
ENGINE.finishPainting();
@@ -1378,9 +1376,7 @@ void paintIcon(SynthContext context, Graphics g,
13781376
try {
13791377
paintMethod.invoke(this, context,
13801378
g, state, x, y, w, h, direction);
1381-
} catch (IllegalAccessException iae) {
1382-
assert false;
1383-
} catch (InvocationTargetException ite) {
1379+
} catch (IllegalAccessException | InvocationTargetException e) {
13841380
assert false;
13851381
}
13861382
ENGINE.finishPainting();

src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -118,11 +118,7 @@ class Metacity implements SynthConstants {
118118
try {
119119
INSTANCE = new Metacity(themeName);
120120
} catch (FileNotFoundException ex) {
121-
} catch (IOException ex) {
122-
logError(themeName, ex);
123-
} catch (ParserConfigurationException ex) {
124-
logError(themeName, ex);
125-
} catch (SAXException ex) {
121+
} catch (IOException | ParserConfigurationException | SAXException ex) {
126122
logError(themeName, ex);
127123
}
128124
}
@@ -606,8 +602,6 @@ public Object run() {
606602
}
607603
}
608604
}
609-
} catch (MalformedURLException ex) {
610-
// OK to just ignore. We'll use a fallback theme.
611605
} catch (IOException ex) {
612606
// OK to just ignore. We'll use a fallback theme.
613607
}

src/java.desktop/share/classes/com/sun/media/sound/AudioFileSoundbankReader.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -51,9 +51,7 @@ public Soundbank getSoundbank(URL url)
5151
try (AudioInputStream ais = AudioSystem.getAudioInputStream(url)) {
5252
Soundbank sbk = getSoundbank(ais);
5353
return sbk;
54-
} catch (UnsupportedAudioFileException e) {
55-
return null;
56-
} catch (IOException e) {
54+
} catch (UnsupportedAudioFileException | IOException e) {
5755
return null;
5856
}
5957
}
@@ -67,8 +65,7 @@ public Soundbank getSoundbank(InputStream stream)
6765
Soundbank sbk = getSoundbank(ais);
6866
if (sbk != null)
6967
return sbk;
70-
} catch (UnsupportedAudioFileException e) {
71-
} catch (IOException e) {
68+
} catch (UnsupportedAudioFileException | IOException e) {
7269
}
7370
stream.reset();
7471
return null;
@@ -136,9 +133,7 @@ public Soundbank getSoundbank(File file)
136133
ins.add(performer);
137134
sbk.addInstrument(ins);
138135
return sbk;
139-
} catch (UnsupportedAudioFileException e1) {
140-
return null;
141-
} catch (IOException e) {
136+
} catch (UnsupportedAudioFileException | IOException e) {
142137
return null;
143138
}
144139
}

src/java.desktop/share/classes/com/sun/media/sound/DLSSoundbankReader.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -47,9 +47,7 @@ public Soundbank getSoundbank(URL url)
4747
throws InvalidMidiDataException, IOException {
4848
try {
4949
return new DLSSoundbank(url);
50-
} catch (RIFFInvalidFormatException e) {
51-
return null;
52-
} catch(IOException ioe) {
50+
} catch (IOException e) {
5351
return null;
5452
}
5553
}

0 commit comments

Comments
 (0)