{"record":{"id":"c764f7d29300a9ed","repo":"languagetool-org/languagetool","slug":"could-not-create-filter-class-using-constructor","errorCode":null,"errorMessage":"Could not create filter class using constructor ${constructor}","messagePattern":"Could not create filter class using constructor (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-core/src/main/java/org/languagetool/rules/patterns/RegexRuleFilterCreator.java","lineNumber":54,"sourceCode":"      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":36,"sourceCodeEnd":63,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-core/src/main/java/org/languagetool/rules/patterns/RegexRuleFilterCreator.java#L36-L63","documentation":"Instantiation failure inside RegexRuleFilterCreator.getFilter: the no-argument constructor of the filter class was found, but Constructor.newInstance() threw (for example the constructor itself failed or the class is abstract). The original exception is chained; the input at fault is the filter class referenced by the XML rule.","triggerScenarios":"Thrown at languagetool-core/src/main/java/org/languagetool/rules/patterns/RegexRuleFilterCreator.java:54 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the chained cause to see why the constructor threw","Ensure the filter class is concrete (not abstract) and its constructor performs no failing initialization"],"exampleFix":null,"handlingStrategy":"try-catch","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"}