From b3eb4fe54d161078ebd999b4bcd73f4e0139c013 Mon Sep 17 00:00:00 2001 From: Lars Vogel Date: Tue, 25 Jun 2019 09:53:54 +0200 Subject: Bug 548653 - Use multi-catch in JDT core Combines redundant catch blocks. Change-Id: Icb5de4a390fc4c5af716535ab533c8b865d9904c Signed-off-by: Lars Vogel --- .../org/eclipse/jdt/core/JDTCompilerAdapter.java | 12 +- .../compiler/batch/ClasspathDirectory.java | 4 +- .../jdt/internal/compiler/batch/ClasspathJar.java | 4 +- .../internal/compiler/batch/ClasspathJep247.java | 4 +- .../compiler/batch/ClasspathJep247Jdk12.java | 4 +- .../jdt/internal/compiler/batch/ClasspathJmod.java | 4 +- .../jdt/internal/compiler/batch/ClasspathJrt.java | 4 +- .../eclipse/jdt/internal/compiler/batch/Main.java | 14 +- .../jdt/internal/codeassist/CompletionEngine.java | 34 +--- .../jdt/internal/codeassist/SelectionEngine.java | 7 +- .../eclipse/jdt/internal/compiler/ClassFile.java | 8 +- .../eclipse/jdt/internal/compiler/Compiler.java | 15 +- .../jdt/internal/compiler/ProcessTaskManager.java | 8 +- .../eclipse/jdt/internal/compiler/ReadManager.java | 15 +- .../internal/compiler/lookup/WildcardBinding.java | 8 +- .../jdt/internal/compiler/parser/Scanner.java | 35 +---- .../internal/compiler/parser/ScannerHelper.java | 15 -- .../compiler/problem/DefaultProblemFactory.java | 4 +- .../jdt/internal/compiler/util/JRTUtil.java | 4 +- .../jdt/internal/compiler/util/Messages.java | 4 +- .../dom/org/eclipse/jdt/core/dom/AST.java | 10 +- .../jdt/core/dom/CompilationUnitResolver.java | 15 +- .../formatter/DefaultCodeFormatterOptions.java | 172 ++++++--------------- .../org/eclipse/jdt/core/CorrectionEngine.java | 4 +- .../model/org/eclipse/jdt/core/JavaCore.java | 6 +- .../model/org/eclipse/jdt/core/ToolFactory.java | 12 +- .../org/eclipse/jdt/internal/core/ClassFile.java | 6 +- .../eclipse/jdt/internal/core/ClassFileInfo.java | 6 +- .../eclipse/jdt/internal/core/ClasspathEntry.java | 8 +- .../eclipse/jdt/internal/core/CompilationUnit.java | 4 +- .../org/eclipse/jdt/internal/core/JavaElement.java | 19 +-- .../jdt/internal/core/JavaModelManager.java | 21 +-- .../org/eclipse/jdt/internal/core/JavaProject.java | 23 +-- .../org/eclipse/jdt/internal/core/Member.java | 4 +- .../org/eclipse/jdt/internal/core/UserLibrary.java | 4 +- .../jdt/internal/core/UserLibraryManager.java | 11 +- .../internal/core/builder/ClasspathDirectory.java | 6 +- .../jdt/internal/core/builder/ClasspathJMod.java | 3 +- .../jdt/internal/core/builder/ClasspathJar.java | 3 +- .../jdt/internal/core/builder/ClasspathJrt.java | 3 +- .../builder/ClasspathJrtWithReleaseOption.java | 4 +- .../internal/core/hierarchy/HierarchyBuilder.java | 12 +- .../jdt/internal/core/util/PublicScanner.java | 35 +---- .../org/eclipse/jdt/internal/core/util/Util.java | 10 +- .../core/search/indexing/BinaryIndexer.java | 9 +- .../core/search/indexing/IndexAllProject.java | 9 +- .../core/search/indexing/IndexBinaryFolder.java | 9 +- .../core/search/matching/MatchLocator.java | 6 +- .../search/matching/SuperTypeNamesCollector.java | 4 +- 49 files changed, 124 insertions(+), 521 deletions(-) diff --git a/org.eclipse.jdt.core/antadapter/org/eclipse/jdt/core/JDTCompilerAdapter.java b/org.eclipse.jdt.core/antadapter/org/eclipse/jdt/core/JDTCompilerAdapter.java index 06d3535091..2bf9db3407 100644 --- a/org.eclipse.jdt.core/antadapter/org/eclipse/jdt/core/JDTCompilerAdapter.java +++ b/org.eclipse.jdt.core/antadapter/org/eclipse/jdt/core/JDTCompilerAdapter.java @@ -163,9 +163,7 @@ public class JDTCompilerAdapter extends DefaultCompilerAdapter { if (getSourcepathMethod != null) { try { compileSourcePath = (Path) getSourcepathMethod.invoke(this.attributes, (Object[]) null); - } catch (IllegalAccessException e) { - // should never happen - } catch (InvocationTargetException e) { + } catch (IllegalAccessException | InvocationTargetException e) { // should never happen } } @@ -211,9 +209,7 @@ public class JDTCompilerAdapter extends DefaultCompilerAdapter { if (getDebugLevelMethod != null) { try { debugLevel = (String) getDebugLevelMethod.invoke(this.attributes, (Object[]) null); - } catch (IllegalAccessException e) { - // should never happen - } catch (InvocationTargetException e) { + } catch (IllegalAccessException | InvocationTargetException e) { // should never happen } } @@ -365,9 +361,7 @@ public class JDTCompilerAdapter extends DefaultCompilerAdapter { if (getCurrentCompilerArgsMethod != null) { try { compilerArgs = (String[]) getCurrentCompilerArgsMethod.invoke(this.attributes, (Object[]) null); - } catch (IllegalAccessException e) { - // should never happen - } catch (InvocationTargetException e) { + } catch (IllegalAccessException | InvocationTargetException e) { // should never happen } } diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java index 0d14e13c06..36afb92c65 100644 --- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java +++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java @@ -159,9 +159,7 @@ private NameEnvironmentAnswer findClassInternal(char[] typeName, String qualifie fetchAccessRestriction(qualifiedBinaryFileName), modName); } - } catch (IOException e) { - // treat as if file is missing - } catch (ClassFormatException e) { + } catch (IOException | ClassFormatException e) { // treat as if file is missing } } diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java index 93d48e6ff4..c565187e35 100644 --- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java +++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java @@ -150,9 +150,7 @@ public NameEnvironmentAnswer findClass(char[] typeName, String qualifiedPackageN } return new NameEnvironmentAnswer(reader, fetchAccessRestriction(qualifiedBinaryFileName), modName); } - } catch(ClassFormatException e) { - // treat as if class file is missing - } catch (IOException e) { + } catch (ClassFormatException | IOException e) { // treat as if class file is missing } return null; diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247.java index 0be712927f..a848b11794 100644 --- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247.java +++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247.java @@ -95,9 +95,7 @@ public class ClasspathJep247 extends ClasspathJrt { char[] modName = moduleName != null ? moduleName.toCharArray() : null; return new NameEnvironmentAnswer(reader, fetchAccessRestriction(qualifiedBinaryFileName), modName); } - } catch(ClassFormatException e) { - // Continue - } catch (IOException e) { + } catch (ClassFormatException | IOException e) { // continue } return null; diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247Jdk12.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247Jdk12.java index 48a119ad7b..0709ad5215 100644 --- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247Jdk12.java +++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247Jdk12.java @@ -95,9 +95,7 @@ public class ClasspathJep247Jdk12 extends ClasspathJep247 { char[] modName = moduleName != null ? moduleName.toCharArray() : null; return new NameEnvironmentAnswer(reader, fetchAccessRestriction(qualifiedBinaryFileName), modName); } - } catch(ClassFormatException e) { - // Continue - } catch (IOException e) { + } catch (ClassFormatException | IOException e) { // continue } return null; diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJmod.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJmod.java index 47e284381e..09786d6681 100644 --- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJmod.java +++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJmod.java @@ -89,9 +89,7 @@ public NameEnvironmentAnswer findClass(char[] typeName, String qualifiedPackageN } return new NameEnvironmentAnswer(reader, fetchAccessRestriction(qualifiedBinaryFileName), modName); } - } catch(ClassFormatException e) { - // treat as if class file is missing - } catch (IOException e) { + } catch (ClassFormatException | IOException e) { // treat as if class file is missing } return null; diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJrt.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJrt.java index c34ac10029..03cdb86f23 100644 --- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJrt.java +++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJrt.java @@ -113,9 +113,7 @@ public class ClasspathJrt extends ClasspathLocation implements IMultiModuleEntry answerModuleName = moduleName.toCharArray(); return new NameEnvironmentAnswer(reader, fetchAccessRestriction(qualifiedBinaryFileName), answerModuleName); } - } catch(ClassFormatException e) { - // treat as if class file is missing - } catch (IOException e) { + } catch (ClassFormatException | IOException e) { // treat as if class file is missing } return null; diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java index 8f18585cc7..43131531bc 100644 --- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java +++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java @@ -209,11 +209,7 @@ public class Main implements ProblemSeverities, SuffixConstants { Logger.FIELD_TABLE.put(key2, field.getName()); } } - } catch (SecurityException e) { - e.printStackTrace(); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { + } catch (SecurityException | IllegalArgumentException | IllegalAccessException e) { e.printStackTrace(); } } @@ -1789,14 +1785,6 @@ public boolean compile(String[] argv) { } System.exit(this.globalErrorsCount > 0 ? -1 : 0); } - } catch (IllegalArgumentException e) { - this.logger.logException(e); - if (this.systemExitWhenFinished) { - this.logger.flush(); - this.logger.close(); - System.exit(-1); - } - return false; } catch (Exception e) { // internal compiler failure this.logger.logException(e); if (this.systemExitWhenFinished) { diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java index ba6cc119a2..4b72d13521 100644 --- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java +++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java @@ -2306,22 +2306,7 @@ public final class CompletionEngine // currently have no way to know if extends/implements are possible keywords } */ - } catch (IndexOutOfBoundsException e) { // work-around internal failure - 1GEMF6D - if(DEBUG) { - System.out.println("Exception caught by CompletionEngine:"); //$NON-NLS-1$ - e.printStackTrace(System.out); - } - } catch (InvalidCursorLocation e) { // may eventually report a usefull error - if(DEBUG) { - System.out.println("Exception caught by CompletionEngine:"); //$NON-NLS-1$ - e.printStackTrace(System.out); - } - } catch (AbortCompilation e) { // ignore this exception for now since it typically means we cannot find java.lang.Object - if(DEBUG) { - System.out.println("Exception caught by CompletionEngine:"); //$NON-NLS-1$ - e.printStackTrace(System.out); - } - } catch (CompletionNodeFound e){ // internal failure - bugs 5618 + } catch (IndexOutOfBoundsException | InvalidCursorLocation | AbortCompilation | CompletionNodeFound e){ // internal failure - bugs 5618 if(DEBUG) { System.out.println("Exception caught by CompletionEngine:"); //$NON-NLS-1$ e.printStackTrace(System.out); @@ -2562,22 +2547,7 @@ public final class CompletionEngine } } } - } catch (IndexOutOfBoundsException e) { // work-around internal failure - 1GEMF6D (added with fix of 99629) - if(DEBUG) { - System.out.println("Exception caught by CompletionEngine:"); //$NON-NLS-1$ - e.printStackTrace(System.out); - } - } catch (InvalidCursorLocation e) { // may eventually report a usefull error (added to fix 99629) - if(DEBUG) { - System.out.println("Exception caught by CompletionEngine:"); //$NON-NLS-1$ - e.printStackTrace(System.out); - } - } catch (AbortCompilation e) { // ignore this exception for now since it typically means we cannot find java.lang.Object (added with fix of 99629) - if(DEBUG) { - System.out.println("Exception caught by CompletionEngine:"); //$NON-NLS-1$ - e.printStackTrace(System.out); - } - } catch (CompletionNodeFound e){ // internal failure - bugs 5618 (added with fix of 99629) + } catch (IndexOutOfBoundsException | InvalidCursorLocation | AbortCompilation | CompletionNodeFound e){ // internal failure - bugs 5618 (added with fix of 99629) if(DEBUG) { System.out.println("Exception caught by CompletionEngine:"); //$NON-NLS-1$ e.printStackTrace(System.out); diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java index b9453c197e..b93c595b23 100644 --- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java +++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java @@ -1107,12 +1107,7 @@ public final class SelectionEngine extends Engine implements ISearchRequestor { if(this.noProposal && this.problem != null) { this.requestor.acceptError(this.problem); } - } catch (IndexOutOfBoundsException e) { // work-around internal failure - 1GEMF6D - if(DEBUG) { - System.out.println("Exception caught by SelectionEngine:"); //$NON-NLS-1$ - e.printStackTrace(System.out); - } - } catch (AbortCompilation e) { // ignore this exception for now since it typically means we cannot find java.lang.Object + } catch (IndexOutOfBoundsException | AbortCompilation e) { // ignore this exception for now since it typically means we cannot find java.lang.Object if(DEBUG) { System.out.println("Exception caught by SelectionEngine:"); //$NON-NLS-1$ e.printStackTrace(System.out); diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java index 705e2d4150..808ffc9236 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java @@ -2483,9 +2483,7 @@ public class ClassFile implements TypeConstants, TypeIds { } memberValuePairsCount++; resetPosition = this.contentsOffset; - } catch(ClassCastException e) { - this.contentsOffset = resetPosition; - } catch(ShouldNotImplement e) { + } catch(ClassCastException | ShouldNotImplement e) { this.contentsOffset = resetPosition; } } @@ -2518,9 +2516,7 @@ public class ClassFile implements TypeConstants, TypeIds { // completely remove the annotation as its value is invalid this.contentsOffset = startingContentsOffset; } - } catch(ClassCastException e) { - this.contentsOffset = startingContentsOffset; - } catch(ShouldNotImplement e) { + } catch(ClassCastException | ShouldNotImplement e) { this.contentsOffset = startingContentsOffset; } } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java index 01c7be93b4..363f9c5051 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java @@ -605,10 +605,7 @@ public class Compiler implements ITypeRequestor, ProblemSeverities { while (true) { try { unit = processingTask.removeNextUnit(); // waits if no units are in the processed queue - } catch (Error e) { - unit = processingTask.unitToProcess; - throw e; - } catch (RuntimeException e) { + } catch (Error | RuntimeException e) { unit = processingTask.unitToProcess; throw e; } @@ -640,10 +637,7 @@ public class Compiler implements ITypeRequestor, ProblemSeverities { } } catch (AbortCompilation e) { this.handleInternalException(e, unit); - } catch (Error e) { - this.handleInternalException(e, unit, null); - throw e; // rethrow - } catch (RuntimeException e) { + } catch (Error | RuntimeException e) { this.handleInternalException(e, unit, null); throw e; // rethrow } finally { @@ -1069,10 +1063,7 @@ public class Compiler implements ITypeRequestor, ProblemSeverities { } catch (AbortCompilation e) { this.handleInternalException(e, unit); return unit == null ? this.unitsToProcess[0] : unit; - } catch (Error e) { - this.handleInternalException(e, unit, null); - throw e; // rethrow - } catch (RuntimeException e) { + } catch (Error | RuntimeException e) { this.handleInternalException(e, unit, null); throw e; // rethrow } finally { diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ProcessTaskManager.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ProcessTaskManager.java index a0a3b9d626..a903283d3b 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ProcessTaskManager.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ProcessTaskManager.java @@ -150,13 +150,7 @@ public void run() { } addNextUnit(this.unitToProcess); - } catch (Error e) { - synchronized (this) { - this.processingThread = null; - this.caughtException = e; - } - return; - } catch (RuntimeException e) { + } catch (Error | RuntimeException e) { synchronized (this) { this.processingThread = null; this.caughtException = e; diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ReadManager.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ReadManager.java index 1d6925d452..f00b44ef61 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ReadManager.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ReadManager.java @@ -49,12 +49,7 @@ public ReadManager(ICompilationUnit[] files, int length) { else if (threadCount > CACHE_SIZE) threadCount = CACHE_SIZE; } - } catch (IllegalAccessException ignored) { // ignored - } catch (ClassNotFoundException e) { // ignored - } catch (SecurityException e) { // ignored - } catch (NoSuchMethodException e) { // ignored - } catch (IllegalArgumentException e) { // ignored - } catch (InvocationTargetException e) { // ignored + } catch (IllegalAccessException | ClassNotFoundException | SecurityException | NoSuchMethodException | IllegalArgumentException | InvocationTargetException e) { // ignored } if (threadCount > 0) { @@ -184,13 +179,7 @@ public void run() { } } } - } catch (Error e) { - synchronized (this) { - this.caughtException = e; - shutdown(); - } - return; - } catch (RuntimeException e) { + } catch (Error | RuntimeException e) { synchronized (this) { this.caughtException = e; shutdown(); diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java index ab52c3fa7c..3e5dd9ce51 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java @@ -88,9 +88,7 @@ public class WildcardBinding extends ReferenceBinding { try { allBounds[0] = (ReferenceBinding) this.bound; System.arraycopy(this.otherBounds, 0, allBounds, 1, this.otherBounds.length); - } catch (ClassCastException cce) { - return this.bound; - } catch (ArrayStoreException ase) { + } catch (ClassCastException | ArrayStoreException ase) { return this.bound; } return this.environment.createIntersectionType18(allBounds); @@ -682,9 +680,7 @@ public class WildcardBinding extends ReferenceBinding { try { allBounds[0] = (ReferenceBinding) this.bound; System.arraycopy(this.otherBounds, 0, allBounds, 1, this.otherBounds.length); - } catch (ClassCastException cce) { - return null; - } catch (ArrayStoreException ase) { + } catch (ClassCastException | ArrayStoreException ase) { return null; } return allBounds; diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java index a1f694c10f..ef623abb8a 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java @@ -664,9 +664,7 @@ public final int getNextChar() { } } return this.currentCharacter; - } catch (IndexOutOfBoundsException e) { - return -1; - } catch(InvalidInputException e) { + } catch(IndexOutOfBoundsException | InvalidInputException e) { return -1; } } @@ -734,11 +732,7 @@ public final boolean getNextChar(char testedChar) { unicodeStore(); return true; } - } catch (IndexOutOfBoundsException e) { - this.unicodeAsBackSlash = false; - this.currentPosition = temp; - return false; - } catch(InvalidInputException e) { + } catch(IndexOutOfBoundsException | InvalidInputException e) { this.unicodeAsBackSlash = false; this.currentPosition = temp; return false; @@ -788,10 +782,7 @@ public final int getNextChar(char testedChar1, char testedChar2) { unicodeStore(); return result; } - } catch (IndexOutOfBoundsException e) { - this.currentPosition = temp; - return -1; - } catch(InvalidInputException e) { + } catch(IndexOutOfBoundsException | InvalidInputException e) { this.currentPosition = temp; return -1; } @@ -877,10 +868,7 @@ public final boolean getNextCharAsDigit() throws InvalidInputException { unicodeStore(); return true; } - } catch (IndexOutOfBoundsException e) { - this.currentPosition = temp; - return false; - } catch(InvalidInputException e) { + } catch(IndexOutOfBoundsException | InvalidInputException e) { this.currentPosition = temp; return false; } @@ -918,10 +906,7 @@ public final boolean getNextCharAsDigit(int radix) { unicodeStore(); return true; } - } catch (IndexOutOfBoundsException e) { - this.currentPosition = temp; - return false; - } catch(InvalidInputException e) { + } catch(IndexOutOfBoundsException | InvalidInputException e) { this.currentPosition = temp; return false; } @@ -1062,11 +1047,7 @@ public boolean getNextCharAsJavaIdentifierPart() { unicodeStore(); return true; } - } catch (IndexOutOfBoundsException e) { - this.currentPosition = pos; - this.withoutUnicodePtr = temp2; - return false; - } catch(InvalidInputException e) { + } catch(IndexOutOfBoundsException | InvalidInputException e) { this.currentPosition = pos; this.withoutUnicodePtr = temp2; return false; @@ -2334,9 +2315,7 @@ public final void jumpOverMethodBody() { } } //-----------------end switch while try-------------------- - } catch (IndexOutOfBoundsException e) { - // ignore - } catch (InvalidInputException e) { + } catch (IndexOutOfBoundsException | InvalidInputException e) { // ignore } return; diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ScannerHelper.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ScannerHelper.java index d20a4d224c..d82322ab6b 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ScannerHelper.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ScannerHelper.java @@ -16,7 +16,6 @@ package org.eclipse.jdt.internal.compiler.parser; import java.io.BufferedInputStream; import java.io.DataInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import org.eclipse.jdt.core.compiler.InvalidInputException; @@ -165,8 +164,6 @@ static long[][][] initializeTables(String unicode_path) { readValues[i] = inputStream.readLong(); } tempTable[START_INDEX][0] = readValues; - } catch (FileNotFoundException e) { - e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } @@ -176,8 +173,6 @@ static long[][][] initializeTables(String unicode_path) { readValues[i] = inputStream.readLong(); } tempTable[START_INDEX][1] = readValues; - } catch (FileNotFoundException e) { - e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } @@ -187,8 +182,6 @@ static long[][][] initializeTables(String unicode_path) { readValues[i] = inputStream.readLong(); } tempTable[START_INDEX][2] = readValues; - } catch (FileNotFoundException e) { - e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } @@ -198,8 +191,6 @@ static long[][][] initializeTables(String unicode_path) { readValues[i] = inputStream.readLong(); } tempTable[PART_INDEX][0] = readValues; - } catch (FileNotFoundException e) { - e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } @@ -209,8 +200,6 @@ static long[][][] initializeTables(String unicode_path) { readValues[i] = inputStream.readLong(); } tempTable[PART_INDEX][1] = readValues; - } catch (FileNotFoundException e) { - e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } @@ -220,8 +209,6 @@ static long[][][] initializeTables(String unicode_path) { readValues[i] = inputStream.readLong(); } tempTable[PART_INDEX][2] = readValues; - } catch (FileNotFoundException e) { - e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } @@ -231,8 +218,6 @@ static long[][][] initializeTables(String unicode_path) { readValues[i] = inputStream.readLong(); } tempTable[PART_INDEX][3] = readValues; - } catch (FileNotFoundException e) { - e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblemFactory.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblemFactory.java index 80b30f407a..407968bdfb 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblemFactory.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblemFactory.java @@ -234,9 +234,7 @@ public static HashtableOfInt loadMessageTemplates(Locale loc) { try { int messageID = Integer.parseInt(key); templates.put(keyFromID(messageID), bundle.getString(key)); - } catch(NumberFormatException e) { - // key ill-formed - } catch (MissingResourceException e) { + } catch (NumberFormatException | MissingResourceException e) { // available ID } } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/JRTUtil.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/JRTUtil.java index d243edeb51..5216b5941e 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/JRTUtil.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/JRTUtil.java @@ -200,9 +200,7 @@ public class JRTUtil { public static byte[] safeReadBytes(Path path) throws IOException { try { return Files.readAllBytes(path); - } catch(ClosedByInterruptException e) { - return null; - } catch (NoSuchFileException e) { + } catch (ClosedByInterruptException | NoSuchFileException e) { return null; } } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Messages.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Messages.java index 47dffa66d9..53169bffbb 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Messages.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Messages.java @@ -213,9 +213,7 @@ public final class Messages { String value = "Missing message: " + field.getName() + " in: " + bundleName; //$NON-NLS-1$ //$NON-NLS-2$ field.set(null, value); } - } catch (IllegalArgumentException e) { - // ignore - } catch (IllegalAccessException e) { + } catch (IllegalArgumentException | IllegalAccessException e) { // ignore } } diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java index c4ff0314cd..c41807dc1a 100644 --- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java @@ -992,15 +992,7 @@ public final class AST { Constructor c = nodeClass.getDeclaredConstructor(AST_CLASS); Object result = c.newInstance(this.THIS_AST); return (ASTNode) result; - } catch (NoSuchMethodException e) { - // all AST node classes have a Foo(AST) constructor - // therefore nodeClass is not legit - throw new IllegalArgumentException(e); - } catch (InstantiationException e) { - // all concrete AST node classes can be instantiated - // therefore nodeClass is not legit - throw new IllegalArgumentException(e); - } catch (IllegalAccessException e) { + } catch (NoSuchMethodException | InstantiationException | IllegalAccessException e) { // all AST node classes have an accessible Foo(AST) constructor // therefore nodeClass is not legit throw new IllegalArgumentException(e); diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java index c51b3790dc..0eca446b39 100644 --- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java @@ -979,10 +979,7 @@ class CompilationUnitResolver extends Compiler { throw e; } catch (AbortCompilation e) { this.handleInternalException(e, unit); - } catch (Error e) { - this.handleInternalException(e, unit, null); - throw e; // rethrow - } catch (RuntimeException e) { + } catch (Error | RuntimeException e) { this.handleInternalException(e, unit, null); throw e; // rethrow } finally { @@ -1117,10 +1114,7 @@ class CompilationUnitResolver extends Compiler { throw e; } catch (AbortCompilation e) { this.handleInternalException(e, unit); - } catch (Error e) { - this.handleInternalException(e, unit, null); - throw e; // rethrow - } catch (RuntimeException e) { + } catch (Error | RuntimeException e) { this.handleInternalException(e, unit, null); throw e; // rethrow } finally { @@ -1266,10 +1260,7 @@ class CompilationUnitResolver extends Compiler { } catch (AbortCompilation e) { this.handleInternalException(e, unit); return unit == null ? this.unitsToProcess[0] : unit; - } catch (Error e) { - this.handleInternalException(e, unit, null); - throw e; // rethrow - } catch (RuntimeException e) { + } catch (Error | RuntimeException e) { this.handleInternalException(e, unit, null); throw e; // rethrow } finally { diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java index aa85581a01..38b0b449e9 100644 --- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java +++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java @@ -875,9 +875,7 @@ public class DefaultCodeFormatterOptions { if (alignmentForArgumentsInAllocationExpressionOption != null) { try { this.alignment_for_arguments_in_allocation_expression = Integer.parseInt((String) alignmentForArgumentsInAllocationExpressionOption); - } catch (NumberFormatException e) { - this.alignment_for_arguments_in_allocation_expression = Alignment.M_COMPACT_SPLIT; - } catch (ClassCastException e) { + } catch (NumberFormatException | ClassCastException e) { this.alignment_for_arguments_in_allocation_expression = Alignment.M_COMPACT_SPLIT; } } @@ -885,9 +883,7 @@ public class DefaultCodeFormatterOptions { if (alignmentForArgumentsInAnnotationOption != null) { try { this.alignment_for_arguments_in_annotation = Integer.parseInt((String) alignmentForArgumentsInAnnotationOption); - } catch (NumberFormatException e) { - this.alignment_for_arguments_in_annotation = Alignment.M_NO_ALIGNMENT; - } catch (ClassCastException e) { + } catch (NumberFormatException | ClassCastException e) { this.alignment_for_arguments_in_annotation = Alignment.M_NO_ALIGNMENT; } } @@ -895,9 +891,7 @@ public class DefaultCodeFormatterOptions { if (alignmentForArgumentsInEnumConstantOption != null) { try { this.alignment_for_arguments_in_enum_constant = Integer.parseInt((String) alignmentForArgumentsInEnumConstantOption); - } catch (NumberFormatException e) { - this.alignment_for_arguments_in_enum_constant = Alignment.M_COMPACT_SPLIT; - } catch (ClassCastException e) { + } catch (NumberFormatException | ClassCastException e) { this.alignment_for_arguments_in_enum_constant = Alignment.M_COMPACT_SPLIT; } } @@ -905,9 +899,7 @@ public class DefaultCodeFormatterOptions { if (alignmentForArgumentsInExplicitConstructorCallOption != null) { try { this.alignment_for_arguments_in_explicit_constructor_call = Integer.parseInt((String) alignmentForArgumentsInExplicitConstructorCallOption); - } catch (NumberFormatException e) { - this.alignment_for_arguments_in_explicit_constructor_call = Alignment.M_COMPACT_SPLIT; - } catch (ClassCastException e) { + } catch (NumberFormatException | ClassCastException e) { this.alignment_for_arguments_in_explicit_constructor_call = Alignment.M_COMPACT_SPLIT; } } @@ -915,9 +907,7 @@ public class DefaultCodeFormatterOptions { if (alignmentForArgumentsInMethodInvocationOption != null) { try { this.alignment_for_arguments_in_method_invocation = Integer.parseInt((String) alignmentForArgumentsInMethodInvocationOption); - } catch (NumberFormatException e) { - this.alignment_for_arguments_in_method_invocation = Alignment.M_COMPACT_SPLIT; - } catch (ClassCastException e) { + } catch (NumberFormatException | ClassCastException e) { this.alignment_for_arguments_in_method_invocation = Alignment.M_COMPACT_SPLIT; } } @@ -925,9 +915,7 @@ public class DefaultCodeFormatterOptions { if (alignmentForArgumentsInQualifiedAllocationExpressionOption != null) { try { this.alignment_for_arguments_in_qualified_allocation_expression = Integer.parseInt((String) alignmentForArgumentsInQualifiedAllocationExpressionOption); - } catch (NumberFormatException e) { - this.alignment_for_arguments_in_qualified_allocation_expression = Alignment.M_COMPACT_SPLIT; - } catch (ClassCastException e) { + } catch (NumberFormatException | ClassCastException e) { this.alignment_for_arguments_in_qualified_allocation_expression = Alignment.M_COMPACT_SPLIT; } } @@ -935,9 +923,7 @@ public class DefaultCodeFormatterOptions { if (alignmentForAssignmentOption != null) { try { this.alignment_for_assignment = Integer.parseInt((String) alignmentForAssignmentOption); - } catch (NumberFormatException e) { - this.alignment_for_assignment = Alignment.M_ONE_PER_LINE_SPLIT; - } catch (ClassCastException e) { + } catch (NumberFormatException | ClassCastException e) { this.alignment_for_assignment = Alignment.M_ONE_PER_LINE_SPLIT; } } @@ -959,9 +945,7 @@ public class DefaultCodeFormatterOptions { if (alignmentForCompactIfOption != null) { try { this.alignment_for_compact_if = Integer.parseInt((String) alignmentForCompactIfOption); - } catch (NumberFormatException e) { - this.alignment_for_compact_if = Alignment.M_ONE_PER_LINE_SPLIT | Alignment.M_INDENT_BY_ONE; - } catch (ClassCastException e) { + } catch (NumberFormatException | ClassCastException e) { this.alignment_for_compact_if = Alignment.M_ONE_PER_LINE_SPLIT | Alignment.M_INDENT_BY_ONE; } } @@ -973,9 +957,7 @@ public class DefaultCodeFormatterOptions { if (alignmentForConditionalExpressionOption != null) { try { this.alignment_for_conditional_expression = Integer.parseInt((String) alignmentForConditionalExpressionOption); - } catch (NumberFormatException e) { - this.alignment_for_conditional_expression = Alignment.M_ONE_PER_LINE_SPLIT; - } catch (ClassCastException e) { + } catch (NumberFormatException | ClassCastException e) { this.alignment_for_conditional_expression = Alignment.M_ONE_PER_LINE_SPLIT; } } @@ -985,9 +967,7 @@ public class DefaultCodeFormatterOptions { if (alignmentForEnumConstantsOption != null) { try { this.alignment_for_enum_constants = Integer.parseInt((String) alignmentForEnumConstantsOption); - } catch (NumberFormatException e) { - this.alignment_for_enum_constants = Alignment.M_NO_ALIGNMENT; - } catch (ClassCastException e) { + } catch (NumberFormatException | ClassCastException e) { this.alignment_for_enum_constants = Alignment.M_NO_ALIGNMENT; } } @@ -995,9 +975,7 @@ public class DefaultCodeFormatterOptions { if (alignmentForExpressionsInArrayInitializerOption != null) { try { this.alignment_for_expressions_in_array_initializer = Integer.parseInt((String) alignmentForExpressionsInArrayInitializerOption); - } catch (NumberFormatException e) { - this.alignment_for_expressions_in_array_initializer = Alignment.M_COMPACT_SPLIT; - } catch (ClassCastException e) { + } catch (NumberFormatException | ClassCastException e) { this.alignment_for_expressions_in_array_initializer = Alignment.M_COMPACT_SPLIT; } } @@ -1009,9 +987,7 @@ public class DefaultCodeFormatterOptions { if (alignmentForMethodDeclarationOption != null) { try { this.alignment_for_method_declaration = Integer.parseInt((String) alignmentForMethodDeclarationOption); - } catch (NumberFormatException e) { - this.alignment_for_method_declaration = Alignment.M_COMPACT_SPLIT; - } catch(ClassCastException e) { + } catch(NumberFormatException | ClassCastException e) { this.alignment_for_method_declaration = Alignment.M_COMPACT_SPLIT; } } @@ -1023,9 +999,7 @@ public class DefaultCodeFormatterOptions { if (alignmentForMultipleFieldsOption != null) { try { this.alignment_for_multiple_fields = Integer.parseInt((String) alignmentForMultipleFieldsOption); - } catch (NumberFormatException e) { - this.alignment_for_multiple_fields = Alignment.M_COMPACT_SPLIT; - } catch (ClassCastException e) { + } catch (NumberFormatException | ClassCastException e) { this.alignment_for_multiple_fields = Alignment.M_COMPACT_SPLIT; } } @@ -1037,9 +1011,7 @@ public class DefaultCodeFormatterOptions { if (alignmentForParametersInConstructorDeclarationOption != null) { try { this.alignment_for_parameters_in_constructor_declaration = Integer.parseInt((String) alignmentForParametersInConstructorDeclarationOption); - } catch (NumberFormatException e) { - this.alignment_for_parameters_in_constructor_declaration = Alignment.M_COMPACT_SPLIT; - } catch (ClassCastException e) { + } catch (NumberFormatException | ClassCastException e) { this.alignment_for_parameters_in_constructor_declaration = Alignment.M_COMPACT_SPLIT; } } @@ -1047,9 +1019,7 @@ public class DefaultCodeFormatterOptions { if (alignmentForParametersInMethodDeclarationOption != null) { try { this.alignment_for_parameters_in_method_declaration = Integer.parseInt((String) alignmentForParametersInMethodDeclarationOption); - } catch (NumberFormatException e) { - this.alignment_for_parameters_in_method_declaration = Alignment.M_COMPACT_SPLIT; - } catch(ClassCastException e) { + } catch(NumberFormatException | ClassCastException e) { this.alignment_for_parameters_in_method_declaration = Alignment.M_COMPACT_SPLIT; } } @@ -1057,9 +1027,7 @@ public class DefaultCodeFormatterOptions { if (alignmentForResourcesInTry != null) { try { this.alignment_for_resources_in_try = Integer.parseInt((String) alignmentForResourcesInTry); - } catch (NumberFormatException e) { - this.alignment_for_resources_in_try = Alignment.M_NEXT_PER_LINE_SPLIT; - } catch(ClassCastException e) { + } catch(NumberFormatException | ClassCastException e) { this.alignment_for_resources_in_try = Alignment.M_NEXT_PER_LINE_SPLIT; } } @@ -1067,9 +1035,7 @@ public class DefaultCodeFormatterOptions { if (alignmentForSelectorInMethodInvocationOption != null) { try { this.alignment_for_selector_in_method_invocation = Integer.parseInt((String) alignmentForSelectorInMethodInvocationOption); - } catch (NumberFormatException e) { - this.alignment_for_selector_in_method_invocation = Alignment.M_COMPACT_SPLIT; - } catch(ClassCastException e) { + } catch(NumberFormatException | ClassCastException e) { this.alignment_for_selector_in_method_invocation = Alignment.M_COMPACT_SPLIT; } } @@ -1077,9 +1043,7 @@ public class DefaultCodeFormatterOptions { if (alignmentForSuperclassInTypeDeclarationOption != null) { try { this.alignment_for_superclass_in_type_declaration = Integer.parseInt((String) alignmentForSuperclassInTypeDeclarationOption); - } catch (NumberFormatException e) { - this.alignment_for_superclass_in_type_declaration = Alignment.M_NEXT_SHIFTED_SPLIT; - } catch(ClassCastException e) { + } catch(NumberFormatException | ClassCastException e) { this.alignment_for_superclass_in_type_declaration = Alignment.M_NEXT_SHIFTED_SPLIT; } } @@ -1087,9 +1051,7 @@ public class DefaultCodeFormatterOptions { if (alignmentForSuperinterfacesInEnumDeclarationOption != null) { try { this.alignment_for_superinterfaces_in_enum_declaration = Integer.parseInt((String) alignmentForSuperinterfacesInEnumDeclarationOption); - } catch (NumberFormatException e) { - this.alignment_for_superinterfaces_in_enum_declaration = Alignment.M_NEXT_SHIFTED_SPLIT; - } catch(ClassCastException e) { + } catch(NumberFormatException | ClassCastException e) { this.alignment_for_superinterfaces_in_enum_declaration = Alignment.M_NEXT_SHIFTED_SPLIT; } } @@ -1097,9 +1059,7 @@ public class DefaultCodeFormatterOptions { if (alignmentForSuperinterfacesInTypeDeclarationOption != null) { try { this.alignment_for_superinterfaces_in_type_declaration = Integer.parseInt((String) alignmentForSuperinterfacesInTypeDeclarationOption); - } catch (NumberFormatException e) { - this.alignment_for_superinterfaces_in_type_declaration = Alignment.M_NEXT_SHIFTED_SPLIT; - } catch(ClassCastException e) { + } catch(NumberFormatException | ClassCastException e) { this.alignment_for_superinterfaces_in_type_declaration = Alignment.M_NEXT_SHIFTED_SPLIT; } } @@ -1107,9 +1067,7 @@ public class DefaultCodeFormatterOptions { if (alignmentForThrowsClauseInConstructorDeclarationOption != null) { try { this.alignment_for_throws_clause_in_constructor_declaration = Integer.parseInt((String) alignmentForThrowsClauseInConstructorDeclarationOption); - } catch (NumberFormatException e) { - this.alignment_for_throws_clause_in_constructor_declaration = Alignment.M_COMPACT_SPLIT; - } catch(ClassCastException e) { + } catch(NumberFormatException | ClassCastException e) { this.alignment_for_throws_clause_in_constructor_declaration = Alignment.M_COMPACT_SPLIT; } } @@ -1117,9 +1075,7 @@ public class DefaultCodeFormatterOptions { if (alignmentForThrowsClauseInMethodDeclarationOption != null) { try { this.alignment_for_throws_clause_in_method_declaration = Integer.parseInt((String) alignmentForThrowsClauseInMethodDeclarationOption); - } catch (NumberFormatException e) { - this.alignment_for_throws_clause_in_method_declaration = Alignment.M_COMPACT_SPLIT; - } catch(ClassCastException e) { + } catch(NumberFormatException | ClassCastException e) { this.alignment_for_throws_clause_in_method_declaration = Alignment.M_COMPACT_SPLIT; } } @@ -1135,9 +1091,7 @@ public class DefaultCodeFormatterOptions { if (alignmentForUnionTypeInMulticatch != null) { try { this.alignment_for_union_type_in_multicatch = Integer.parseInt((String) alignmentForUnionTypeInMulticatch); - } catch (NumberFormatException e) { - this.alignment_for_union_type_in_multicatch = Alignment.M_COMPACT_SPLIT; - } catch(ClassCastException e) { + } catch(NumberFormatException | ClassCastException e) { this.alignment_for_union_type_in_multicatch = Alignment.M_COMPACT_SPLIT; } } @@ -1157,9 +1111,7 @@ public class DefaultCodeFormatterOptions { if (alignTypeMembersOnColumnsOption != null) { try { this.align_fields_grouping_blank_lines = Integer.parseInt((String) alignGroupSepartionBlankLinesOption); - } catch (NumberFormatException e) { - this.align_fields_grouping_blank_lines = Integer.MAX_VALUE; - } catch(ClassCastException e) { + } catch(NumberFormatException | ClassCastException e) { this.align_fields_grouping_blank_lines = Integer.MAX_VALUE; } } @@ -1309,9 +1261,7 @@ public class DefaultCodeFormatterOptions { if (continuationIndentationOption != null) { try { this.continuation_indentation = Integer.parseInt((String) continuationIndentationOption); - } catch (NumberFormatException e) { - this.continuation_indentation = 2; - } catch(ClassCastException e) { + } catch(NumberFormatException | ClassCastException e) { this.continuation_indentation = 2; } } @@ -1319,9 +1269,7 @@ public class DefaultCodeFormatterOptions { if (continuationIndentationForArrayInitializerOption != null) { try { this.continuation_indentation_for_array_initializer = Integer.parseInt((String) continuationIndentationForArrayInitializerOption); - } catch (NumberFormatException e) { - this.continuation_indentation_for_array_initializer = 2; - } catch(ClassCastException e) { + } catch(NumberFormatException | ClassCastException e) { this.continuation_indentation_for_array_initializer = 2; } } @@ -1329,9 +1277,7 @@ public class DefaultCodeFormatterOptions { if (blankLinesAfterImportsOption != null) { try { this.blank_lines_after_imports = Integer.parseInt((String) blankLinesAfterImportsOption); - } catch (NumberFormatException e) { - this.blank_lines_after_imports = 0; - } catch(ClassCastException e) { + } catch(NumberFormatException | ClassCastException e) { this.blank_lines_after_imports = 0; } } @@ -1339,9 +1285,7 @@ public class DefaultCodeFormatterOptions { if (blankLinesAfterPackageOption != null) { try { this.blank_lines_after_package = Integer.parseInt((String) blankLinesAfterPackageOption); - } catch (NumberFormatException e) { - this.blank_lines_after_package = 0; - } catch(ClassCastException e) { + } catch(NumberFormatException | ClassCastException e) { this.blank_lines_after_package = 0; } } @@ -1349,9 +1293,7 @@ public class DefaultCodeFormatterOptions { if (blankLinesBeforeFieldOption != null) { try { this.blank_lines_before_field = Integer.parseInt((String) blankLinesBeforeFieldOption); - } catch (NumberFormatException e) { - this.blank_lines_before_field = 0; - } catch(ClassCastException e) { + } catch(NumberFormatException | ClassCastException e) { this.blank_lines_before_field = 0; } } @@ -1359,9 +1301,7 @@ public class DefaultCodeFormatterOptions { if (blankLinesBeforeFirstClassBodyDeclarationOption != null) { try { this.blank_lines_before_first_class_body_declaration = Integer.parseInt((String) blankLinesBeforeFirstClassBodyDeclarationOption); - } catch (NumberFormatException e) { - this.blank_lines_before_first_class_body_declaration = 0; - } catch(ClassCastException e) { + } catch(NumberFormatException | ClassCastException e) { this.blank_lines_before_first_class_body_declaration = 0; } } @@ -1369,9 +1309,7 @@ public class DefaultCodeFormatterOptions { if (blankLinesBeforeImportsOption != null) { try { this.blank_lines_before_imports = Integer.parseInt((String) blankLinesBeforeImportsOption); - } catch (NumberFormatException e) { - this.blank_lines_before_imports = 0; - } catch(ClassCastException e) { + } catch(NumberFormatException | ClassCastException e) { this.blank_lines_before_imports = 0; } } @@ -1379,9 +1317,7 @@ public class DefaultCodeFormatterOptions { if (blankLinesBeforeMemberTypeOption != null) { try { this.blank_lines_before_member_type = Integer.parseInt((String) blankLinesBeforeMemberTypeOption); - } catch (NumberFormatException e) { - this.blank_lines_before_member_type = 0; - } catch(ClassCastException e) { + } catch(NumberFormatException | ClassCastException e) { this.blank_lines_before_member_type = 0; } } @@ -1389,9 +1325,7 @@ public class DefaultCodeFormatterOptions { if (blankLinesBeforeMethodOption != null) { try { this.blank_lines_before_method = Integer.parseInt((String) blankLinesBeforeMethodOption); - } catch (NumberFormatException e) { - this.blank_lines_before_method = 0; - } catch(ClassCastException e) { + } catch(NumberFormatException | ClassCastException e) { this.blank_lines_before_method = 0; } } @@ -1399,9 +1333,7 @@ public class DefaultCodeFormatterOptions { if (blankLinesBeforeNewChunkOption != null) { try { this.blank_lines_before_new_chunk = Integer.parseInt((String) blankLinesBeforeNewChunkOption); - } catch (NumberFormatException e) { - this.blank_lines_before_new_chunk = 0; - } catch(ClassCastException e) { + } catch(NumberFormatException | ClassCastException e) { this.blank_lines_before_new_chunk = 0; } } @@ -1409,9 +1341,7 @@ public class DefaultCodeFormatterOptions { if (blankLinesBeforePackageOption != null) { try { this.blank_lines_before_package = Integer.parseInt((String) blankLinesBeforePackageOption); - } catch (NumberFormatException e) { - this.blank_lines_before_package = 0; - } catch(ClassCastException e) { + } catch(NumberFormatException | ClassCastException e) { this.blank_lines_before_package = 0; } } @@ -1419,9 +1349,7 @@ public class DefaultCodeFormatterOptions { if (blankLinesBetweenImportGroupsOption != null) { try { this.blank_lines_between_import_groups = Integer.parseInt((String) blankLinesBetweenImportGroupsOption); - } catch (NumberFormatException e) { - this.blank_lines_between_import_groups = 1; - } catch(ClassCastException e) { + } catch(NumberFormatException | ClassCastException e) { this.blank_lines_between_import_groups = 1; } } @@ -1429,9 +1357,7 @@ public class DefaultCodeFormatterOptions { if (blankLinesBetweenTypeDeclarationsOption != null) { try { this.blank_lines_between_type_declarations = Integer.parseInt((String) blankLinesBetweenTypeDeclarationsOption); - } catch (NumberFormatException e) { - this.blank_lines_between_type_declarations = 0; - } catch(ClassCastException e) { + } catch(NumberFormatException | ClassCastException e) { this.blank_lines_between_type_declarations = 0; } } @@ -1439,9 +1365,7 @@ public class DefaultCodeFormatterOptions { if (blankLinesAtBeginningOfMethodBodyOption != null) { try { this.blank_lines_at_beginning_of_method_body = Integer.parseInt((String) blankLinesAtBeginningOfMethodBodyOption); - } catch (NumberFormatException e) { - this.blank_lines_at_beginning_of_method_body = 0; - } catch(ClassCastException e) { + } catch(NumberFormatException | ClassCastException e) { this.blank_lines_at_beginning_of_method_body = 0; } } @@ -1512,9 +1436,7 @@ public class DefaultCodeFormatterOptions { if (commentLineLengthOption != null) { try { this.comment_line_length = Integer.parseInt((String) commentLineLengthOption); - } catch (NumberFormatException e) { - this.comment_line_length = 80; - } catch(ClassCastException e) { + } catch(NumberFormatException | ClassCastException e) { this.comment_line_length = 80; } } @@ -1575,9 +1497,7 @@ public class DefaultCodeFormatterOptions { int indentationSize = 4; try { indentationSize = Integer.parseInt((String) indentationSizeOption); - } catch (NumberFormatException e) { - // keep default - } catch(ClassCastException e) { + } catch(NumberFormatException | ClassCastException e) { // keep default } // reverse values swapping performed by IndentationTabPage @@ -2367,9 +2287,7 @@ public class DefaultCodeFormatterOptions { if (numberOfEmptyLinesToPreserveOption != null) { try { this.number_of_empty_lines_to_preserve = Integer.parseInt((String) numberOfEmptyLinesToPreserveOption); - } catch (NumberFormatException e) { - this.number_of_empty_lines_to_preserve = 0; - } catch(ClassCastException e) { + } catch(NumberFormatException | ClassCastException e) { this.number_of_empty_lines_to_preserve = 0; } } @@ -2390,9 +2308,7 @@ public class DefaultCodeFormatterOptions { int tabSize = 4; try { tabSize = Integer.parseInt((String) tabSizeOption); - } catch (NumberFormatException e) { - // keep default - } catch(ClassCastException e) { + } catch(NumberFormatException | ClassCastException e) { // keep default } // reverse values swapping performed by IndentationTabPage @@ -2409,9 +2325,7 @@ public class DefaultCodeFormatterOptions { if (pageWidthOption != null) { try { this.page_width = Integer.parseInt((String) pageWidthOption); - } catch (NumberFormatException e) { - this.page_width = 120; - } catch(ClassCastException e) { + } catch(NumberFormatException | ClassCastException e) { this.page_width = 120; } } diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/CorrectionEngine.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/CorrectionEngine.java index d1caa2ecb8..4628df13a9 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/CorrectionEngine.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/CorrectionEngine.java @@ -306,9 +306,7 @@ public class CorrectionEngine { } finally { JavaCore.setOptions(oldOptions); } - } catch (JavaModelException e) { - return; - } catch (InvalidInputException e) { + } catch (JavaModelException | InvalidInputException e) { return; } } diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java index eccd28957d..48af8a2502 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java @@ -3821,11 +3821,7 @@ public final class JavaCore extends Plugin { verbose_variable_value_after_initialization(variableName, variablePath); manager.variablesWithInitializer.add(variableName); ok = true; - } catch (RuntimeException e) { - if (JavaModelManager.CP_RESOLVE_VERBOSE || JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) - e.printStackTrace(); - throw e; - } catch (Error e) { + } catch (RuntimeException | Error e) { if (JavaModelManager.CP_RESOLVE_VERBOSE || JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) e.printStackTrace(); throw e; diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ToolFactory.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ToolFactory.java index dfe106164a..2b7317085b 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ToolFactory.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ToolFactory.java @@ -312,9 +312,7 @@ public class ToolFactory { public static IClassFileReader createDefaultClassFileReader(InputStream stream, int decodingFlag) { try { return new ClassFileReader(Util.getInputStreamAsByteArray(stream, -1), decodingFlag); - } catch(ClassFormatException e) { - return null; - } catch(IOException e) { + } catch(ClassFormatException | IOException e) { return null; } } @@ -336,9 +334,7 @@ public class ToolFactory { public static IClassFileReader createDefaultClassFileReader(String fileName, int decodingFlag){ try { return new ClassFileReader(Util.getFileByteContent(new File(fileName)), decodingFlag); - } catch(ClassFormatException e) { - return null; - } catch(IOException e) { + } catch(ClassFormatException | IOException e) { return null; } } @@ -374,9 +370,7 @@ public class ToolFactory { } byte classFileBytes[] = Util.getZipEntryByteContent(zipEntry, zipFile); return new ClassFileReader(classFileBytes, decodingFlag); - } catch(ClassFormatException e) { - return null; - } catch(IOException e) { + } catch(ClassFormatException | IOException e) { return null; } finally { if (zipFile != null) { diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFile.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFile.java index c8dbd47dd9..914f6eb2a2 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFile.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFile.java @@ -146,11 +146,7 @@ public boolean existsUsingJarTypeCache() { } try { info = getJarBinaryTypeInfo(); - } catch (CoreException e) { - // leave info null - } catch (IOException e) { - // leave info null - } catch (ClassFormatException e) { + } catch (CoreException | IOException | ClassFormatException e) { // leave info null } manager.putJarTypeInfo(type, info == null ? JavaModelCache.NON_EXISTING_JAR_TYPE_INFO : info); diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileInfo.java index 5d96965664..3990140805 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileInfo.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileInfo.java @@ -310,11 +310,7 @@ private void generateMethodInfos(IType type, IBinaryType typeInfo, HashMap newEl final String[] parameterTypes = Signature.getParameterTypes(new String(descriptor)); pNames[0] = parameterTypes[0]; } - } catch (IllegalArgumentException e) { - // protect against malformed .class file (e.g. com/sun/crypto/provider/SunJCE_b.class has a 'a' generic signature) - signature = methodInfo.getMethodDescriptor(); - pNames = Signature.getParameterTypes(new String(signature)); - } catch (JavaModelException e) { + } catch (IllegalArgumentException | JavaModelException e) { // protect against malformed .class file (e.g. com/sun/crypto/provider/SunJCE_b.class has a 'a' generic signature) signature = methodInfo.getMethodDescriptor(); pNames = Signature.getParameterTypes(new String(signature)); diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathEntry.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathEntry.java index 284fb648f7..dc3de3704c 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathEntry.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathEntry.java @@ -1072,13 +1072,7 @@ public class ClasspathEntry implements IClasspathEntry { } return null; } - } catch (CoreException e) { - // not a zip file - if (JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) { - Util.verbose("Could not read Class-Path header in manifest of jar file: " + jarPath.toOSString()); //$NON-NLS-1$ - e.printStackTrace(); - } - } catch (IOException e) { + } catch (CoreException | IOException e) { // not a zip file if (JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) { Util.verbose("Could not read Class-Path header in manifest of jar file: " + jarPath.toOSString()); //$NON-NLS-1$ diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java index 45303aa290..4c6e552dbc 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java @@ -78,9 +78,7 @@ public UndoEdit applyTextEdit(TextEdit edit, IProgressMonitor monitor) throws Ja try { UndoEdit undoEdit= edit.apply(document); return undoEdit; - } catch (MalformedTreeException e) { - throw new JavaModelException(e, IJavaModelStatusConstants.BAD_TEXT_EDIT_LOCATION); - } catch (BadLocationException e) { + } catch (MalformedTreeException | BadLocationException e) { throw new JavaModelException(e, IJavaModelStatusConstants.BAD_TEXT_EDIT_LOCATION); } } diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java index c43100b2cd..2650b22fc0 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java @@ -922,10 +922,7 @@ public abstract class JavaElement extends PlatformObject implements IJavaElement return new String(contents); } } - } catch (IllegalArgumentException e) { - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=304316 - return null; - } catch (NullPointerException e) { + } catch (IllegalArgumentException | NullPointerException e) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=304316 return null; } catch (SocketTimeoutException e) { @@ -935,15 +932,7 @@ public abstract class JavaElement extends PlatformObject implements IJavaElement } catch (FileNotFoundException e) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=403154 validateAndCache(baseLoc, e); - } catch (SocketException e) { - // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=247845 & - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=400060 - throw new JavaModelException(e, IJavaModelStatusConstants.CANNOT_RETRIEVE_ATTACHED_JAVADOC); - } catch (UnknownHostException e) { - // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=247845 & - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=400060 - throw new JavaModelException(e, IJavaModelStatusConstants.CANNOT_RETRIEVE_ATTACHED_JAVADOC); - } catch (ProtocolException e) { + } catch (SocketException | UnknownHostException | ProtocolException e) { // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=247845 & // https://bugs.eclipse.org/bugs/show_bug.cgi?id=400060 throw new JavaModelException(e, IJavaModelStatusConstants.CANNOT_RETRIEVE_ATTACHED_JAVADOC); @@ -963,9 +952,7 @@ public abstract class JavaElement extends PlatformObject implements IJavaElement if (connection2 != null) { try { connection2.getJarFile().close(); - } catch(IOException e) { - // ignore - } catch(IllegalStateException e) { + } catch(IOException | IllegalStateException e) { /* * ignore. Can happen in case the stream.close() did close the jar file * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=140750 diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java index 704a2437a6..5b727d3952 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java @@ -3218,11 +3218,7 @@ public class JavaModelManager implements ISaveParticipant, IContentTypeChangeLis } else { throw new JavaModelException(e); } - } catch (RuntimeException e) { - if (JavaModelManager.CP_RESOLVE_VERBOSE || CP_RESOLVE_VERBOSE_FAILURE) - e.printStackTrace(); - throw e; - } catch (Error e) { + } catch (RuntimeException | Error e) { if (JavaModelManager.CP_RESOLVE_VERBOSE || CP_RESOLVE_VERBOSE_FAILURE) e.printStackTrace(); throw e; @@ -3617,9 +3613,7 @@ public class JavaModelManager implements ISaveParticipant, IContentTypeChangeLis try { DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); cpElement = parser.parse(new InputSource(reader)).getDocumentElement(); - } catch(SAXException e) { - return; - } catch(ParserConfigurationException e){ + } catch(SAXException | ParserConfigurationException e){ return; } finally { reader.close(); @@ -4401,16 +4395,7 @@ public class JavaModelManager implements ISaveParticipant, IContentTypeChangeLis } finally { out.close(); } - } catch (RuntimeException e) { - try { - file.delete(); - } catch(SecurityException se) { - // could not delete file: cannot do much more - } - throw new CoreException( - new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, Platform.PLUGIN_ERROR, - Messages.bind(Messages.build_cannotSaveState, info.project.getName()), e)); - } catch (IOException e) { + } catch (RuntimeException | IOException e) { try { file.delete(); } catch(SecurityException se) { diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java index b8b07ebd74..1acc6153af 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java @@ -1262,9 +1262,7 @@ public class JavaProject try { DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); cpElement = parser.parse(new InputSource(reader)).getDocumentElement(); - } catch (SAXException e) { - throw new IOException(Messages.file_badFormat, e); - } catch (ParserConfigurationException e) { + } catch (SAXException | ParserConfigurationException e) { throw new IOException(Messages.file_badFormat, e); } finally { reader.close(); @@ -1326,9 +1324,7 @@ public class JavaProject DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); node = parser.parse(new InputSource(reader)).getDocumentElement(); - } catch (SAXException e) { - return null; - } catch (ParserConfigurationException e) { + } catch (SAXException | ParserConfigurationException e) { return null; } finally { reader.close(); @@ -2115,9 +2111,7 @@ public class JavaProject // cache project options perProjectInfo.options = projectOptions; } - } catch (JavaModelException jme) { - projectOptions = new Hashtable(); - } catch (BackingStoreException e) { + } catch (JavaModelException | BackingStoreException e) { projectOptions = new Hashtable(); } @@ -2738,8 +2732,7 @@ public class JavaProject try { in = new BufferedInputStream(new FileInputStream(prefFile)); preferences = Platform.getPreferencesService().readPreferences(in); - } catch (CoreException e) { // problems loading preference store - quietly ignore - } catch (IOException e) { // problems loading preference store - quietly ignore + } catch (CoreException | IOException e) { // problems loading preference store - quietly ignore } finally { if (in != null) { try { @@ -2966,13 +2959,7 @@ public class JavaProject private IClasspathEntry[][] readFileEntries(Map unkwownElements) { try { return readFileEntriesWithException(unkwownElements); - } catch (CoreException e) { - Util.log(e, "Exception while reading " + getPath().append(JavaProject.CLASSPATH_FILENAME)); //$NON-NLS-1$ - return new IClasspathEntry[][]{JavaProject.INVALID_CLASSPATH, ClasspathEntry.NO_ENTRIES}; - } catch (IOException e) { - Util.log(e, "Exception while reading " + getPath().append(JavaProject.CLASSPATH_FILENAME)); //$NON-NLS-1$ - return new IClasspathEntry[][]{JavaProject.INVALID_CLASSPATH, ClasspathEntry.NO_ENTRIES}; - } catch (ClasspathEntry.AssertionFailedException e) { + } catch (CoreException | IOException | ClasspathEntry.AssertionFailedException e) { Util.log(e, "Exception while reading " + getPath().append(JavaProject.CLASSPATH_FILENAME)); //$NON-NLS-1$ return new IClasspathEntry[][]{JavaProject.INVALID_CLASSPATH, ClasspathEntry.NO_ENTRIES}; } diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Member.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Member.java index 36d1011654..1abf0024bf 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Member.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Member.java @@ -339,9 +339,7 @@ public ISourceRange getJavadocRange() throws JavaModelException { if (docOffset != -1) { return new SourceRange(docOffset + start, docEnd - docOffset); } - } catch (InvalidInputException ex) { - // try if there is inherited Javadoc - } catch (IndexOutOfBoundsException e) { + } catch (InvalidInputException | IndexOutOfBoundsException e) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=305001 } } diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/UserLibrary.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/UserLibrary.java index a85dac4947..6666c148b7 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/UserLibrary.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/UserLibrary.java @@ -152,9 +152,7 @@ public class UserLibrary { try { DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); cpElement = parser.parse(new InputSource(reader)).getDocumentElement(); - } catch (SAXException e) { - throw new IOException(Messages.file_badFormat, e); - } catch (ParserConfigurationException e) { + } catch (SAXException | ParserConfigurationException e) { throw new IOException(Messages.file_badFormat, e); } finally { reader.close(); diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/UserLibraryManager.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/UserLibraryManager.java index 301a872a8a..969b6de974 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/UserLibraryManager.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/UserLibraryManager.java @@ -83,12 +83,7 @@ public class UserLibraryManager { UserLibrary library; try { library = UserLibrary.createFromString(reader); - } catch (IOException e) { - Util.log(e, "Exception while initializing user library " + libName); //$NON-NLS-1$ - instancePreferences.remove(propertyName); - preferencesNeedFlush = true; - continue; - } catch (ClasspathEntry.AssertionFailedException e) { + } catch (IOException | ClasspathEntry.AssertionFailedException e) { Util.log(e, "Exception while initializing user library " + libName); //$NON-NLS-1$ instancePreferences.remove(propertyName); preferencesNeedFlush = true; @@ -153,11 +148,9 @@ public class UserLibraryManager { } } JavaCore.setClasspathContainer(containerPath, projects, containers, null); - } catch (IOException e) { - Util.log(e, "Exception while decoding user library '"+ libName +"'."); //$NON-NLS-1$ //$NON-NLS-2$ } catch (JavaModelException e) { Util.log(e, "Exception while setting user library '"+ libName +"'."); //$NON-NLS-1$ //$NON-NLS-2$ - } catch (ClasspathEntry.AssertionFailedException ase) { + } catch (IOException | ClasspathEntry.AssertionFailedException ase) { Util.log(ase, "Exception while decoding user library '"+ libName +"'."); //$NON-NLS-1$ //$NON-NLS-2$ } diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathDirectory.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathDirectory.java index bffce17c78..ba43b14610 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathDirectory.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathDirectory.java @@ -157,11 +157,7 @@ public NameEnvironmentAnswer findClass(String binaryFileName, String qualifiedPa IBinaryType reader = null; try { reader = Util.newClassFileReader(this.binaryFolder.getFile(new Path(qualifiedBinaryFileName))); - } catch (CoreException e) { - return null; - } catch (ClassFormatException e) { - return null; - } catch (IOException e) { + } catch (CoreException | ClassFormatException | IOException e) { return null; } if (reader != null) { diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJMod.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJMod.java index 5e8aeb7619..0d74ebeb67 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJMod.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJMod.java @@ -101,8 +101,7 @@ public class ClasspathJMod extends ClasspathJar { return new NameEnvironmentAnswer(reader, null, modName); return new NameEnvironmentAnswer(reader, this.accessRuleSet.getViolatedRestriction(fileNameWithoutExtension.toCharArray()), modName); } - } catch (IOException e) { // treat as if class file is missing - } catch (ClassFormatException e) { // treat as if class file is missing + } catch (IOException | ClassFormatException e) { // treat as if class file is missing } return null; } diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJar.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJar.java index c03f8a1ffe..449469aaeb 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJar.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJar.java @@ -295,8 +295,7 @@ public NameEnvironmentAnswer findClass(String binaryFileName, String qualifiedPa this.accessRuleSet.getViolatedRestriction(fileNameWithoutExtension.toCharArray()), modName); } - } catch (IOException e) { // treat as if class file is missing - } catch (ClassFormatException e) { // treat as if class file is missing + } catch (IOException | ClassFormatException e) { // treat as if class file is missing } return null; } diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJrt.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJrt.java index b9f19e9cab..197e682e10 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJrt.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJrt.java @@ -215,8 +215,7 @@ public NameEnvironmentAnswer findClass(String binaryFileName, String qualifiedPa String fileNameWithoutExtension = qualifiedBinaryFileName.substring(0, qualifiedBinaryFileName.length() - SuffixConstants.SUFFIX_CLASS.length); IBinaryType reader = ClassFileReader.readFromModule(new File(this.zipFilename), moduleName, qualifiedBinaryFileName, moduleNameFilter); return createAnswer(fileNameWithoutExtension, reader); - } catch (ClassFormatException e) { // treat as if class file is missing - } catch (IOException e) { // treat as if class file is missing + } catch (ClassFormatException | IOException e) { // treat as if class file is missing } return null; } diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJrtWithReleaseOption.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJrtWithReleaseOption.java index fef78d9afb..d507ed14dc 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJrtWithReleaseOption.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJrtWithReleaseOption.java @@ -325,9 +325,7 @@ public class ClasspathJrtWithReleaseOption extends ClasspathJrt { moduleNameFilter); } return createAnswer(fileNameWithoutExtension, reader); - } catch (ClassFormatException e) { - // treat as if class file is missing - } catch (IOException e) { + } catch (ClassFormatException | IOException e) { // treat as if class file is missing } return null; diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyBuilder.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyBuilder.java index b492fa1dc2..1cd98c47f2 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyBuilder.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyBuilder.java @@ -293,17 +293,7 @@ protected IBinaryType createInfoFromClassFile(Openable handle, IResource file) { IBinaryType info = null; try { info = Util.newClassFileReader(file); - } catch (org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException e) { - if (TypeHierarchy.DEBUG) { - e.printStackTrace(); - } - return null; - } catch (java.io.IOException e) { - if (TypeHierarchy.DEBUG) { - e.printStackTrace(); - } - return null; - } catch (CoreException e) { + } catch (org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException | java.io.IOException | CoreException e) { if (TypeHierarchy.DEBUG) { e.printStackTrace(); } diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PublicScanner.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PublicScanner.java index a5c2e8d47d..e22c9ae6af 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PublicScanner.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PublicScanner.java @@ -614,9 +614,7 @@ public final int getNextChar() { } } return this.currentCharacter; - } catch (IndexOutOfBoundsException e) { - return -1; - } catch(InvalidInputException e) { + } catch(IndexOutOfBoundsException | InvalidInputException e) { return -1; } } @@ -684,11 +682,7 @@ public final boolean getNextChar(char testedChar) { unicodeStore(); return true; } - } catch (IndexOutOfBoundsException e) { - this.unicodeAsBackSlash = false; - this.currentPosition = temp; - return false; - } catch(InvalidInputException e) { + } catch(IndexOutOfBoundsException | InvalidInputException e) { this.unicodeAsBackSlash = false; this.currentPosition = temp; return false; @@ -738,10 +732,7 @@ public final int getNextChar(char testedChar1, char testedChar2) { unicodeStore(); return result; } - } catch (IndexOutOfBoundsException e) { - this.currentPosition = temp; - return -1; - } catch(InvalidInputException e) { + } catch(IndexOutOfBoundsException | InvalidInputException e) { this.currentPosition = temp; return -1; } @@ -827,10 +818,7 @@ public final boolean getNextCharAsDigit() throws InvalidInputException { unicodeStore(); return true; } - } catch (IndexOutOfBoundsException e) { - this.currentPosition = temp; - return false; - } catch(InvalidInputException e) { + } catch(IndexOutOfBoundsException | InvalidInputException e) { this.currentPosition = temp; return false; } @@ -868,10 +856,7 @@ public final boolean getNextCharAsDigit(int radix) { unicodeStore(); return true; } - } catch (IndexOutOfBoundsException e) { - this.currentPosition = temp; - return false; - } catch(InvalidInputException e) { + } catch(IndexOutOfBoundsException | InvalidInputException e) { this.currentPosition = temp; return false; } @@ -1012,11 +997,7 @@ public boolean getNextCharAsJavaIdentifierPart() { unicodeStore(); return true; } - } catch (IndexOutOfBoundsException e) { - this.currentPosition = pos; - this.withoutUnicodePtr = temp2; - return false; - } catch(InvalidInputException e) { + } catch(IndexOutOfBoundsException | InvalidInputException e) { this.currentPosition = pos; this.withoutUnicodePtr = temp2; return false; @@ -2239,9 +2220,7 @@ public final void jumpOverMethodBody() { } } //-----------------end switch while try-------------------- - } catch (IndexOutOfBoundsException e) { - // ignore - } catch (InvalidInputException e) { + } catch (IndexOutOfBoundsException | InvalidInputException e) { // ignore } return; diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java index 7cc7eca7d4..cd53f09779 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java @@ -427,9 +427,7 @@ public class Util { try { edit.apply(document, TextEdit.NONE); return document.get(); - } catch (MalformedTreeException e) { - e.printStackTrace(); - } catch (BadLocationException e) { + } catch (MalformedTreeException | BadLocationException e) { e.printStackTrace(); } return original; @@ -881,11 +879,7 @@ public class Util { if (reader != null) { return reader.getVersion(); } - } catch (CoreException e) { - // ignore - } catch(ClassFormatException e) { - // ignore - } catch(IOException e) { + } catch(CoreException | ClassFormatException | IOException e) { // ignore } return 0; diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java index 3018dffdd6..8e1fb397b2 100644 --- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java +++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java @@ -836,14 +836,7 @@ public class BinaryIndexer extends AbstractIndexer implements SuffixConstants { } // record all references found inside the .class file extractReferenceFromConstantPool(contents, reader); - } catch (ClassFormatException e) { - // ignore - this.document.removeAllIndexEntries(); - Util.log(new Status(IStatus.WARNING, - JavaCore.PLUGIN_ID, - "The Java indexing could not index " + this.document.getPath() + ". This .class file doesn't follow the class file format specification. Please report this issue against the .class file vendor", //$NON-NLS-1$ //$NON-NLS-2$ - e)); - } catch (RuntimeException e) { + } catch (ClassFormatException | RuntimeException e) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=182154 // logging the entry that could not be indexed and continue with the next one // we remove all entries relative to the boggus document diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexAllProject.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexAllProject.java index 0afbc25fef..a9417fdcbe 100644 --- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexAllProject.java +++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexAllProject.java @@ -228,14 +228,7 @@ public class IndexAllProject extends IndexRequest { // request to save index when all cus have been indexed... also sets state to SAVED_STATE this.manager.request(new SaveIndex(this.containerPath, this.manager)); - } catch (CoreException e) { - if (JobManager.VERBOSE) { - Util.verbose("-> failed to index " + this.project + " because of the following exception:", System.err); //$NON-NLS-1$ //$NON-NLS-2$ - e.printStackTrace(); - } - this.manager.removeIndex(this.containerPath); - return false; - } catch (IOException e) { + } catch (CoreException | IOException e) { if (JobManager.VERBOSE) { Util.verbose("-> failed to index " + this.project + " because of the following exception:", System.err); //$NON-NLS-1$ //$NON-NLS-2$ e.printStackTrace(); diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexBinaryFolder.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexBinaryFolder.java index 36ef5a9580..7e5633a0e5 100644 --- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexBinaryFolder.java +++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexBinaryFolder.java @@ -135,14 +135,7 @@ public class IndexBinaryFolder extends IndexRequest { // request to save index when all class files have been indexed... also sets state to SAVED_STATE this.manager.request(new SaveIndex(this.containerPath, this.manager)); - } catch (CoreException e) { - if (JobManager.VERBOSE) { - Util.verbose("-> failed to index " + this.folder + " because of the following exception:", System.err); //$NON-NLS-1$ //$NON-NLS-2$ - e.printStackTrace(); - } - this.manager.removeIndex(this.containerPath); - return false; - } catch (IOException e) { + } catch (CoreException | IOException e) { if (JobManager.VERBOSE) { Util.verbose("-> failed to index " + this.folder + " because of the following exception:", System.err); //$NON-NLS-1$ //$NON-NLS-2$ e.printStackTrace(); diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java index cd41fa969f..1c87189b06 100644 --- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java +++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java @@ -1334,11 +1334,7 @@ protected void locateMatches(JavaProject javaProject, PossibleMatch[] possibleMa this.matchesToProcess[i] = null; // release reference to processed possible match try { process(possibleMatch, bindingsWereCreated); - } catch (AbortCompilation e) { - // problem with class path: it could not find base classes - // continue and try next matching openable reporting inaccurate matches (since bindings will be null) - bindingsWereCreated = false; - } catch (JavaModelException e) { + } catch (AbortCompilation | JavaModelException e) { // problem with class path: it could not find base classes // continue and try next matching openable reporting inaccurate matches (since bindings will be null) bindingsWereCreated = false; diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperTypeNamesCollector.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperTypeNamesCollector.java index 6577311201..b8467cc6c4 100644 --- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperTypeNamesCollector.java +++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperTypeNamesCollector.java @@ -222,9 +222,7 @@ public char[][][] collect() throws JavaModelException { if (matches(binding)) collectSuperTypeNames(binding, binding.compoundName); } - } catch (AbortCompilation e) { - // ignore: continue with next element - } catch (JavaModelException e) { + } catch (AbortCompilation | JavaModelException e) { // ignore: continue with next element } } -- cgit v1.2.3