languagetool-org/languagetool · error · RuntimeException

throw new RuntimeException(e)

Error message

throw new RuntimeException(e)

What it means

Inflector.getForms synthesizes word forms via the English synthesizer (enSynth.synthesize), which declares IOException. Since getForms cannot throw a checked exception, any IOException from the synthesizer is rethrown as an unchecked RuntimeException with the original exception as cause.

Source

Thrown at languagetool-language-modules/en/src/main/java/org/languagetool/rules/en/translation/Inflector.java:89

    } else if (dePosTag.matches("PA2:PRD:GRU:VER")) {
      forms.addAll(getForms(enToken, "VBN"));
    } else if (dePosTag.matches("ADJ:PRD:KOM|ADJ:.*:KOM.*")) {
      forms.addAll(getForms(enToken, "JJR"));
    } else if (dePosTag.matches("ADJ:.*:SUP.*")) {
      forms.addAll(getForms(enToken, "JJS"));
    } else {
      forms.add(enToken);
    }
    return forms;
  }

  @SuppressWarnings("ConstantConditions")
  @NotNull
  private List<String> getForms(String enToken, String posTagRegex) {
    try {
      return Arrays.asList(enSynth.synthesize(new AnalyzedToken(enToken, "fake-value", enToken), posTagRegex, true));
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
}

View on GitHub (pinned to 2e990059ce)

Solutions

  1. Inspect the cause RuntimeException to find the underlying IOException and missing resource.
  2. Ensure the English synthesizer dictionary (part of the en language module) is on the classpath.
  3. Wrap calls in try-catch at a higher level if inflection is optional for the workflow.
Defensive patterns

Strategy: try-catch

Validate before calling

if (enToken == null || enToken.isBlank() || posTagRegex == null) return Collections.emptyList();

Try / catch

try {
  List<String> forms = inflector.inflectSingleWord(word, posRegex);
} catch (RuntimeException e) {
  if (e.getCause() instanceof IOException io) { /* degrade gracefully or load synthesizer data */ }
}

Prevention

When it happens

Trigger: Calling getForms (directly or through inflectSingleWord) when enSynth.synthesize throws IOException — typically the synthesis dictionary resource is missing or unreadable.

Common situations: Running inflection utilities outside a fully assembled LanguageTool distribution where the English synthesizer data is absent; corrupt resource files; classpath issues in tests or embedded usage.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06). Data as JSON: /api/errors/e8d25015e1982d1b. Report an issue: GitHub.