{"record":{"id":"b7013c49d882187a","repo":"languagetool-org/languagetool","slug":"constructor-of-filter-class-classname-must-no","errorCode":null,"errorMessage":"Constructor of filter class '${className}' must not have arguments: ${constructor}","messagePattern":"Constructor of filter class '(.+?)' must not have arguments: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-core/src/main/java/org/languagetool/rules/patterns/RegexRuleFilterCreator.java","lineNumber":45,"sourceCode":" * @since 5.2\n */\npublic class RegexRuleFilterCreator {\n\n  /**\n   * @param className fully qualified class Name of a class implementing {@link RegexRuleFilter}\n   */\n  public RegexRuleFilter getFilter(String className) {\n    try {\n      Class<?> aClass = JLanguageTool.getClassBroker().forName(className);\n      Constructor<?>[] constructors = aClass.getConstructors();\n      if (constructors.length != 1) {\n        throw new RuntimeException(\"Constructor of filter class '\"\n                + className + \"' must have exactly one constructor, but it has \" + constructors.length);\n      }\n      Constructor<?> constructor = constructors[0];\n      try {\n        if (constructor.getParameterTypes().length != 0) {\n          throw new RuntimeException(\"Constructor of filter class '\" + className + \"' must not have arguments: \" + constructor);\n        }\n        Object filter = constructor.newInstance();\n        if (filter instanceof RegexRuleFilter) {\n          return (RegexRuleFilter) filter;\n        } else {\n          throw new RuntimeException(\"Filter class '\" + className + \"' must implement interface \" + RegexRuleFilter.class.getSimpleName());\n        }\n      } catch (Exception e) {\n        throw new RuntimeException(\"Could not create filter class using constructor \" + constructor, e);\n      }\n    } catch (ClassNotFoundException e) {\n      throw new RuntimeException(\"Could not find filter class: '\"\n              + className + \"' - make sure to use a fully qualified class name like 'org.languagetool.rules.MyFilter'\");\n    }\n  }\n \n}\n","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-core/src/main/java/org/languagetool/rules/patterns/RegexRuleFilterCreator.java#L27-L63","documentation":"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.","triggerScenarios":"Thrown at languagetool-core/src/main/java/org/languagetool/rules/patterns/RegexRuleFilterCreator.java:45 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}