Skip to content

Commit

Permalink
8284672: Collapse identical catch branches in java.desktop
Browse files Browse the repository at this point in the history
Reviewed-by: prr, aivanov, serb
  • Loading branch information
Andrey Turbanov committed Jun 20, 2022
1 parent 7acdcc1 commit 695d865
Show file tree
Hide file tree
Showing 45 changed files with 130 additions and 297 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -439,9 +439,7 @@ public void actionPerformed(final ActionEvent e) {
spinner.setValue(value);
select(spinner);
}
} catch (final IllegalArgumentException iae) {
UIManager.getLookAndFeel().provideErrorFeedback(spinner);
} catch (final ParseException pe) {
} catch (IllegalArgumentException | ParseException ex) {
UIManager.getLookAndFeel().provideErrorFeedback(spinner);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -3808,12 +3808,8 @@ private void loadIfNecessary() {
method.invoke(klass, new Object[] { this });
} catch (final NoSuchMethodException nsme) {
assert false : "LazyActionMap unable to load actions " + klass;
} catch (final IllegalAccessException iae) {
assert false : "LazyActionMap unable to load actions " + iae;
} catch (final InvocationTargetException ite) {
assert false : "LazyActionMap unable to load actions " + ite;
} catch (final IllegalArgumentException iae) {
assert false : "LazyActionMap unable to load actions " + iae;
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
assert false : "LazyActionMap unable to load actions " + e;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -378,7 +378,7 @@ public Void run() {
try {
SAXParserFactory.newInstance().newSAXParser().parse(input, DocumentHandler.this);
}
catch (ParserConfigurationException exception) {
catch (ParserConfigurationException | IOException exception) {
handleException(exception);
}
catch (SAXException wrapper) {
Expand All @@ -388,9 +388,6 @@ public Void run() {
}
handleException(exception);
}
catch (IOException exception) {
handleException(exception);
}
return null;
}
}, stack, this.acc);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -67,9 +67,7 @@ public static Class<?> findClass(String name) throws ClassNotFoundException {
return Class.forName(name, false, loader);
}

} catch (ClassNotFoundException exception) {
// use current class loader instead
} catch (SecurityException exception) {
} catch (ClassNotFoundException | SecurityException exception) {
// use current class loader instead
}
return Class.forName(name);
Expand Down Expand Up @@ -101,9 +99,7 @@ public static Class<?> findClass(String name, ClassLoader loader) throws ClassNo
if (loader != null) {
try {
return Class.forName(name, false, loader);
} catch (ClassNotFoundException exception) {
// use default class loader instead
} catch (SecurityException exception) {
} catch (ClassNotFoundException | SecurityException exception) {
// use default class loader instead
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -1160,10 +1160,7 @@ public BufferedImage read(int imageIndex, ImageReadParam param)
cbLock.check();
try {
readInternal(imageIndex, param, false);
} catch (RuntimeException e) {
resetLibraryState(structPointer);
throw e;
} catch (IOException e) {
} catch (RuntimeException | IOException e) {
resetLibraryState(structPointer);
throw e;
}
Expand Down Expand Up @@ -1632,10 +1629,7 @@ public Raster readRaster(int imageIndex, ImageReadParam param)
target = target.createWritableTranslatedChild(saveDestOffset.x,
saveDestOffset.y);
}
} catch (RuntimeException e) {
resetLibraryState(structPointer);
throw e;
} catch (IOException e) {
} catch (RuntimeException | IOException e) {
resetLibraryState(structPointer);
throw e;
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1473,13 +1473,8 @@ public static TIFFIFD parseIFD(Node node) throws IIOInvalidTreeException {
Method getInstanceMethod =
setClass.getMethod("getInstance", (Class[])null);
o = getInstanceMethod.invoke(null, (Object[])null);
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
} catch (ClassNotFoundException e) {
} catch (NoSuchMethodException | IllegalAccessException |
InvocationTargetException | ClassNotFoundException e) {
throw new RuntimeException(e);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -1357,9 +1357,7 @@ void paintIcon(SynthContext context, Graphics g,
ENGINE.startPainting(g, x, y, w, h, state, paintMethod);
try {
paintMethod.invoke(this, context, g, state, x, y, w, h);
} catch (IllegalAccessException iae) {
assert false;
} catch (InvocationTargetException ite) {
} catch (IllegalAccessException | InvocationTargetException e) {
assert false;
}
ENGINE.finishPainting();
Expand All @@ -1378,9 +1376,7 @@ void paintIcon(SynthContext context, Graphics g,
try {
paintMethod.invoke(this, context,
g, state, x, y, w, h, direction);
} catch (IllegalAccessException iae) {
assert false;
} catch (InvocationTargetException ite) {
} catch (IllegalAccessException | InvocationTargetException e) {
assert false;
}
ENGINE.finishPainting();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -118,11 +118,7 @@ class Metacity implements SynthConstants {
try {
INSTANCE = new Metacity(themeName);
} catch (FileNotFoundException ex) {
} catch (IOException ex) {
logError(themeName, ex);
} catch (ParserConfigurationException ex) {
logError(themeName, ex);
} catch (SAXException ex) {
} catch (IOException | ParserConfigurationException | SAXException ex) {
logError(themeName, ex);
}
}
Expand Down Expand Up @@ -606,8 +602,6 @@ public Object run() {
}
}
}
} catch (MalformedURLException ex) {
// OK to just ignore. We'll use a fallback theme.
} catch (IOException ex) {
// OK to just ignore. We'll use a fallback theme.
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -51,9 +51,7 @@ public Soundbank getSoundbank(URL url)
try (AudioInputStream ais = AudioSystem.getAudioInputStream(url)) {
Soundbank sbk = getSoundbank(ais);
return sbk;
} catch (UnsupportedAudioFileException e) {
return null;
} catch (IOException e) {
} catch (UnsupportedAudioFileException | IOException e) {
return null;
}
}
Expand All @@ -67,8 +65,7 @@ public Soundbank getSoundbank(InputStream stream)
Soundbank sbk = getSoundbank(ais);
if (sbk != null)
return sbk;
} catch (UnsupportedAudioFileException e) {
} catch (IOException e) {
} catch (UnsupportedAudioFileException | IOException e) {
}
stream.reset();
return null;
Expand Down Expand Up @@ -136,9 +133,7 @@ public Soundbank getSoundbank(File file)
ins.add(performer);
sbk.addInstrument(ins);
return sbk;
} catch (UnsupportedAudioFileException e1) {
return null;
} catch (IOException e) {
} catch (UnsupportedAudioFileException | IOException e) {
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -47,9 +47,7 @@ public Soundbank getSoundbank(URL url)
throws InvalidMidiDataException, IOException {
try {
return new DLSSoundbank(url);
} catch (RIFFInvalidFormatException e) {
return null;
} catch(IOException ioe) {
} catch (IOException e) {
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -1036,12 +1036,9 @@ private void open(AudioFormat format, byte[] data, int frameLength)
try {
// use DirectDL's open method to open it
open(format, (int) Toolkit.millis2bytes(format, CLIP_BUFFER_TIME)); // one second buffer
} catch (LineUnavailableException lue) {
} catch (LineUnavailableException | IllegalArgumentException e) {
audioData = null;
throw lue;
} catch (IllegalArgumentException iae) {
audioData = null;
throw iae;
throw e;
}

// if we got this far, we can instanciate the thread
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -202,10 +202,8 @@ private synchronized void startImpl(boolean loop) {
sequencer.open();
sequencer.setSequence(sequence);

} catch (InvalidMidiDataException e1) {
if (Printer.err) e1.printStackTrace();
} catch (MidiUnavailableException e2) {
if (Printer.err) e2.printStackTrace();
} catch (InvalidMidiDataException | MidiUnavailableException e) {
if (Printer.err) e.printStackTrace();
}
}
sequencer.addMetaEventListener(this);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -47,9 +47,7 @@ public Soundbank getSoundbank(URL url)
throws InvalidMidiDataException, IOException {
try {
return new SF2Soundbank(url);
} catch (RIFFInvalidFormatException e) {
return null;
} catch(IOException ioe) {
} catch (IOException e) {
return null;
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/java.desktop/share/classes/java/awt/AWTKeyStroke.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -545,9 +545,7 @@ private static int getVKValue(String key) {

try {
keyCode = KeyEvent.class.getField(key).getInt(KeyEvent.class);
} catch (NoSuchFieldException nsfe) {
throw new IllegalArgumentException(errmsg);
} catch (IllegalAccessException iae) {
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new IllegalArgumentException(errmsg);
}
value = Integer.valueOf(keyCode);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -2597,10 +2597,8 @@ private static Throwable dispatchAndCatchException(Throwable ex, Component comp,
Throwable retEx = null;
try {
comp.dispatchEvent(event);
} catch (RuntimeException re) {
retEx = re;
} catch (Error er) {
retEx = er;
} catch (RuntimeException | Error e) {
retEx = e;
}
if (retEx != null) {
if (ex != null) {
Expand Down
Loading

1 comment on commit 695d865

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.