{"record":{"id":"deed570da2b4d68c","repo":"stanfordnlp/CoreNLP","slug":"something-went-very-very-wrong","errorCode":null,"errorMessage":"Something went very very wrong.","messagePattern":"Something went very very wrong\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/util/Trilean.java","lineNumber":90,"sourceCode":"  public boolean isUnknown() {\n    return value == 2;\n  }\n\n  /**\n   * Convert this Trilean to a boolean, with a specified default value if the truth value is unknown.\n   * @param valueForUnknown The default value to use if the value of this Trilean is unknown.\n   * @return The boolean value of this Trilean.\n   */\n  public boolean toBoolean(boolean valueForUnknown) {\n    switch (value) {\n      case 1:\n        return true;\n      case 0:\n        return false;\n      case 2:\n        return valueForUnknown;\n      default:\n        throw new IllegalStateException(\"Something went very very wrong.\");\n    }\n  }\n\n  /**\n   * Convert this Trilean to a Boolean, or null if the value is not known.\n   * @return Either True, False, or null.\n   */\n  public Boolean toBooleanOrNull() {\n    switch (value) {\n      case 1:\n        return true;\n      case 0:\n        return false;\n      case 2:\n        return null;\n      default:\n        throw new IllegalStateException(\"Something went very very wrong.\");\n    }","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/util/Trilean.java#L72-L108","documentation":"Trilean.toBoolean(Boolean valueForUnknown) throws IllegalStateException when the internal value field holds an integer outside {0,1,2}. Since all constructors confine value to those three states, reaching the default branch means internal corruption — hence 'very very wrong'.","triggerScenarios":"Calling toBoolean on a Trilean whose internal value was corrupted via reflection or deserialization of an object built by a different (incompatible) class version.","commonSituations":"Java serialization of Trilean across library versions where the state encoding changed; tests tampering with the private field via reflection.","solutions":["Do not construct Trilean via reflection or raw deserialization across versions; use fromString/TRUE/FALSE/UNKNOWN.","Catch IllegalStateException as an unrecoverable bug and fail fast.","Recreate the Trilean from a known representation instead of trusting the corrupted one."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  boolean b = t.toBoolean(Boolean.FALSE);\n} catch (IllegalStateException e) {\n  t = Trilean.fromString(t.toString()); // or rebuild; this is an internal bug\n}","preventionTips":["Only build Trilean via public constructors/constants/fromString.","Avoid reflection on the private value field.","Don't Java-serialize Trilean across library versions; use its string form."],"tags":["java","invariant","trilean"],"backgroundTag":"internal-invariant-violation","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}