diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/AnalysisSPILoader.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/AnalysisSPILoader.java index 430c0020c72..d0ced5dc065 100644 --- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/AnalysisSPILoader.java +++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/util/AnalysisSPILoader.java @@ -56,9 +56,7 @@ public final class AnalysisSPILoader { // them used instead of others if (!services.containsKey(name)) { assert checkServiceName(name); - @SuppressWarnings("unchecked") - final Class sclazz = (Class) service.getClass(); - services.put(name, sclazz); + services.put(name, service.getClass().asSubclass(clazz)); } } this.services = Collections.unmodifiableMap(services);