diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/migration/TryWithIdenticalCatchesInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/migration/TryWithIdenticalCatchesInspection.java index a904e414b16a..84dfad84c6b9 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/migration/TryWithIdenticalCatchesInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/migration/TryWithIdenticalCatchesInspection.java @@ -82,6 +82,10 @@ public class TryWithIdenticalCatchesInspection extends BaseInspection { if (catchSections.length < 2) { return; } + final PsiParameter[] parameters = statement.getCatchBlockParameters(); + if (catchSections.length != parameters.length) { + return; + } final boolean[] duplicates = new boolean[catchSections.length]; for (int i = 0; i < catchSections.length - 1; i++) { final PsiCatchSection catchSection = catchSections[i]; @@ -99,7 +103,6 @@ public class TryWithIdenticalCatchesInspection extends BaseInspection { false); final DuplicatesFinder finder = new DuplicatesFinder(new PsiElement[]{catchBlock}, inputVariables, null, Collections.emptyList()); - final PsiParameter[] parameters = statement.getCatchBlockParameters(); for (int j = i + 1; j < catchSections.length; j++) { if (duplicates[j]) { continue; diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/try_identical_catches/TryIdenticalCatches.after.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/try_identical_catches/TryIdenticalCatches.after.java index 83163330ca7e..032fa0002dea 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/try_identical_catches/TryIdenticalCatches.after.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/try_identical_catches/TryIdenticalCatches.after.java @@ -105,4 +105,16 @@ class TryIdenticalCatches { } catch (E1 e) { } } + + void q() { + try { + Class.forName("bla").newInstance(); + } catch (ClassNotFoundException e) { + e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } catch (InstantiationException ) { + e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } catch (IllegalAccessException e) { + e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } + } } \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/try_identical_catches/TryIdenticalCatches.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/try_identical_catches/TryIdenticalCatches.java index 683d22eef5ba..5d33c50de89e 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/try_identical_catches/TryIdenticalCatches.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/try_identical_catches/TryIdenticalCatches.java @@ -108,4 +108,16 @@ class TryIdenticalCatches { } catch (E1 e) { } } + + void q() { + try { + Class.forName("bla").newInstance(); + } catch (ClassNotFoundException e) { + e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } catch (InstantiationException ) { + e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } catch (IllegalAccessException e) { + e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } + } } \ No newline at end of file