{"record":{"id":"5851c16882e70757","repo":"stanfordnlp/CoreNLP","slug":"unsupported-findtype","errorCode":null,"errorMessage":"Unsupported findType ","messagePattern":"Unsupported findType ","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ling/tokensregex/SequenceMatcher.java","lineNumber":472,"sourceCode":"        throw new UnsupportedOperationException();\n      }\n    };\n    return new IterableIterator<>(iter);\n  }\n\n  /**\n   * Searches for the next occurrence of the pattern\n   * @return true if a match is found (false otherwise)\n   * @see #find(int)\n   */\n  public boolean find() {\n    switch (findType) {\n      case FIND_NONOVERLAPPING:\n        return findNextNonOverlapping();\n      case FIND_ALL:\n        return findNextAll();\n      default:\n        throw new UnsupportedOperationException(\"Unsupported findType \" + findType);\n    }\n  }\n\n  private boolean findMatchStart(int start, boolean matchAllTokens) {\n    switch (findType) {\n      case FIND_NONOVERLAPPING:\n        return findMatchStartBacktracking(start, matchAllTokens);\n      case FIND_ALL:\n        // TODO: Should use backtracking here too, need to keep track of todo stack\n        // so we can recover after finding a match\n        return findMatchStartNoBacktracking(start, matchAllTokens);\n      default:\n        throw new UnsupportedOperationException(\"Unsupported findType \" + findType);\n    }\n  }\n\n  // Does not do backtracking - alternative matches are stored as we go\n  private boolean findMatchStartNoBacktracking(int start, boolean matchAllTokens) {","sourceCodeStart":454,"sourceCodeEnd":490,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ling/tokensregex/SequenceMatcher.java#L454-L490","documentation":"SequenceMatcher.find() dispatches on the matcher's findType, which is set at construction (FIND_NONOVERLAPPING or FIND_ALL). If findType holds any other value, the switch falls through to default and throws UnsupportedOperationException. This guards against invalid or future findType values reaching the find loop.","triggerScenarios":"Calling find() on a SequenceMatcher whose findType field is not one of the two supported constants — typically only possible by constructing the matcher with an invalid FindType or mutating it reflectively, since the public API normally only exposes the two constants.","commonSituations":"Custom code that defines or passes a new FindType constant, or code copied from a newer/older Stanford CoreNLP version where an additional find type exists but the matcher implementation does not support it in find().","solutions":["Only use SequenceMatcher.FindType.FIND_NONOVERLAPPING or FIND_ALL when creating the matcher","If you need a new find mode, add a case to the switch in find() (and findMatchStart) instead of passing an unknown type","Check that no custom subclass or reflection is overwriting the findType field","Upgrade/downgrade CoreNLP so the FindType constants match the SequenceMatcher implementation in use"],"exampleFix":"// before\nmatcher.setFindType(someCustomFindType);\nmatcher.find();\n// after\nmatcher.setFindType(SequenceMatcher.FindType.FIND_NONOVERLAPPING);\nmatcher.find();","handlingStrategy":"validation","validationCode":"if (findType != SequenceMatcher.FindType.FIND_NONOVERLAPPING && findType != SequenceMatcher.FindType.FIND_ALL) {\n  throw new IllegalArgumentException(\"findType must be FIND_NONOVERLAPPING or FIND_ALL: \" + findType);\n}","typeGuard":"boolean isValidFindType(SequenceMatcher.FindType t) {\n  return t == SequenceMatcher.FindType.FIND_NONOVERLAPPING || t == SequenceMatcher.FindType.FIND_ALL;\n}","tryCatchPattern":"try {\n  matcher.find();\n} catch (UnsupportedOperationException e) {\n  log.error(\"Unsupported findType on matcher\", e);\n  // recreate matcher with default FIND_NONOVERLAPPING\n}","preventionTips":["Only assign the two supported FindType constants","Never mutate findType via reflection or subclasses","Keep FindType enum and SequenceMatcher on the same CoreNLP version"],"tags":["java","unsupported-operation","tokensregex"],"backgroundTag":"unsupported-operation","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}