{"record":{"id":"c315babbeb275734","repo":"stanfordnlp/CoreNLP","slug":"illegal-value-in-serialized-symbol","errorCode":null,"errorMessage":"ILLEGAL VALUE IN SERIALIZED SYMBOL","messagePattern":"ILLEGAL VALUE IN SERIALIZED SYMBOL","errorType":"exception","errorClass":"InvalidObjectException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/parser/lexparser/ChineseCharacterBasedLexicon.java","lineNumber":516,"sourceCode":"\n    protected Object readResolve() throws ObjectStreamException {\n      switch (type) {\n        case CHAR_TYPE:\n          return intern();\n        case UNK_CLASS_TYPE:\n          return intern();\n        case UNKNOWN_TYPE:\n          return UNKNOWN;\n        case DIGIT_TYPE:\n          return DIGIT;\n        case LETTER_TYPE:\n          return LETTER;\n        case BEGIN_WORD_TYPE:\n          return BEGIN_WORD;\n        case END_WORD_TYPE:\n          return END_WORD;\n        default: // impossible...\n          throw new InvalidObjectException(\"ILLEGAL VALUE IN SERIALIZED SYMBOL\");\n      }\n    }\n\n    @Override\n    public boolean equals(Object o) {\n      if (this == o) {\n        return true;\n      }\n      if (!(o instanceof Symbol)) {\n        return false;\n      }\n\n      final Symbol symbol = (Symbol) o;\n\n      if (ch != symbol.ch) {\n        return false;\n      }\n      if (type != symbol.type) {","sourceCodeStart":498,"sourceCodeEnd":534,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/lexparser/ChineseCharacterBasedLexicon.java#L498-L534","documentation":"Symbol's readResolve/validation switch maps serialized type constants (LETTER_TYPE, BEGIN_WORD_TYPE, END_WORD_TYPE) back to enum-like constants. An unrecognized type value in a deserialized stream triggers InvalidObjectException, protecting against corrupted or version-mismatched serialization.","triggerScenarios":"Deserializing a Symbol whose type byte/int is not one of the defined *_TYPE constants — corrupted .ser file, stream produced by a different (incompatible) class version, or hand-crafted/mutated serialized data.","commonSituations":"Loading a Chinese character lexicon serialized with an older/newer Stanford Parser version whose Symbol encoding changed; truncated or edited serialized grammar files; cross-version model reuse.","solutions":["Reserialize the lexicon/model with the same parser version you use at load time (retrain or re-export the model)","Check Stanford Parser version compatibility between the model file and your classpath jars","Replace the corrupted serialized file with a fresh copy","If intentionally changing the encoding, update all *_TYPE constants and bump serialVersionUID consistently"],"exampleFix":"// before: cross-version model file with parser 3.x code reading a 4.x model\nObjectInputStream in = new ObjectInputStream(new GZIPInputStream(new FileInputStream(model)));\n// after: align versions / rebuild model\n// 1. run training with the SAME parser version as runtime\n// 2. or catch and report:\ntry { sym = (Symbol) in.readObject(); }\ncatch (InvalidObjectException e) { throw new IOException(\"Incompatible model file, retrain with matching parser version\", e); }","handlingStrategy":"try-catch","validationCode":"// verify model file is a non-empty gzip stream from a matching parser version\nif (!modelFile.canRead() || modelFile.length() == 0)\n  throw new IOException(\"Missing/corrupt model: \" + modelFile);","typeGuard":null,"tryCatchPattern":"try { sym = (Symbol) ois.readObject(); } catch (InvalidObjectException e) { throw new IOException(\"Incompatible or corrupt serialized Symbol — reload model from matching parser version\", e); }","preventionTips":["Serialize and deserialize models with the same Stanford Parser version","Keep serialVersionUID-consistent model artifacts","Checksum model files and verify after download"],"tags":["serialization","deserialization","lexicon","version-mismatch"],"backgroundTag":"class-not-found","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"}