languagetool-org/languagetool · error · RuntimeException
Constructor of filter class '${className}' must not have arg
Error message
Constructor of filter class '${className}' must not have arguments: ${constructor} What it means
Reflection-based setup check in RegexRuleFilterCreator.getFilter: the filter class has a single constructor, but that constructor declares parameters, while the creator can only instantiate filters with a no-argument constructor. The input at fault is the filter class referenced from the <filter> element of the rule.
Source
Thrown at languagetool-core/src/main/java/org/languagetool/rules/patterns/RegexRuleFilterCreator.java:45
* @since 5.2
*/
public class RegexRuleFilterCreator {
/**
* @param className fully qualified class Name of a class implementing {@link RegexRuleFilter}
*/
public RegexRuleFilter getFilter(String className) {
try {
Class<?> aClass = JLanguageTool.getClassBroker().forName(className);
Constructor<?>[] constructors = aClass.getConstructors();
if (constructors.length != 1) {
throw new RuntimeException("Constructor of filter class '"
+ className + "' must have exactly one constructor, but it has " + constructors.length);
}
Constructor<?> constructor = constructors[0];
try {
if (constructor.getParameterTypes().length != 0) {
throw new RuntimeException("Constructor of filter class '" + className + "' must not have arguments: " + constructor);
}
Object filter = constructor.newInstance();
if (filter instanceof RegexRuleFilter) {
return (RegexRuleFilter) filter;
} else {
throw new RuntimeException("Filter class '" + className + "' must implement interface " + RegexRuleFilter.class.getSimpleName());
}
} catch (Exception e) {
throw new RuntimeException("Could not create filter class using constructor " + constructor, e);
}
} catch (ClassNotFoundException e) {
throw new RuntimeException("Could not find filter class: '"
+ className + "' - make sure to use a fully qualified class name like 'org.languagetool.rules.MyFilter'");
}
}
}
View on GitHub (pinned to 2e990059ce)
Solutions
- Make the filter class's constructor take no parameters
- Obtain any configuration the filter needs from the filter arguments map passed to acceptRuleMatch instead of constructor parameters
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at languagetool-core/src/main/java/org/languagetool/rules/patterns/RegexRuleFilterCreator.java:45 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/b7013c49d882187a.
Report an issue: GitHub.