Skip to content

Apache Lucene open-source search software

LUCENE-6193: Use ReflectiveOperationException to simplify catch clauses around reflection errors

Shalin Shekhar Mangar77982fb4e331
diff --git a/lucene/core/src/java/org/apache/lucene/store/LockStressTest.java b/lucene/core/src/java/org/apache/lucene/store/LockStressTest.java
index d4156b2064d..4840ae9ff2a 100644
--- a/lucene/core/src/java/org/apache/lucene/store/LockStressTest.java
+++ b/lucene/core/src/java/org/apache/lucene/store/LockStressTest.java
@@ -139,7 +139,7 @@ public class LockStressTest {
// try to create a new instance
try {
return Class.forName(lockFactoryClassName).asSubclass(FSLockFactory.class).newInstance();
- } catch (IllegalAccessException | InstantiationException | ClassCastException | ClassNotFoundException e) {
+ } catch (ReflectiveOperationException | ClassCastException e) {
// fall-through
}
diff --git a/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java b/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java
index d00df91f665..ef1639cdf17 100644
--- a/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java
+++ b/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java
@@ -565,7 +565,7 @@ public class JavascriptCompiler {
checkFunction(method, JavascriptCompiler.class.getClassLoader());
map.put(call, method);
}
- } catch (NoSuchMethodException | ClassNotFoundException | IOException e) {
+ } catch (ReflectiveOperationException | IOException e) {
throw new Error("Cannot resolve function", e);
}
DEFAULT_FUNCTIONS = Collections.unmodifiableMap(map);