{"record":{"id":"7cbb5dd6171a95b4","repo":"antlr/antlr4","slug":"the-specified-lexer-action-type-s-is-not-valid","errorCode":null,"errorMessage":"The specified lexer action type %s is not valid.","messagePattern":"The specified lexer action type (.+?) is not valid\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"critical","filePath":"runtime/Java/src/org/antlr/v4/runtime/atn/ATNDeserializer.java","lineNumber":586,"sourceCode":"\t\t\treturn new LexerModeAction(data1);\n\n\t\tcase MORE:\n\t\t\treturn LexerMoreAction.INSTANCE;\n\n\t\tcase POP_MODE:\n\t\t\treturn LexerPopModeAction.INSTANCE;\n\n\t\tcase PUSH_MODE:\n\t\t\treturn new LexerPushModeAction(data1);\n\n\t\tcase SKIP:\n\t\t\treturn LexerSkipAction.INSTANCE;\n\n\t\tcase TYPE:\n\t\t\treturn new LexerTypeAction(data1);\n\n\t\tdefault:\n\t\t\tthrow new IllegalArgumentException(String.format(Locale.getDefault(), \"The specified lexer action type %s is not valid.\", type));\n\t\t}\n\t}\n\n\t/** Given a list of integers representing a serialized ATN, encode values too large to fit into 15 bits\n\t *  as two 16bit values. We use the high bit (0x8000_0000) to indicate values requiring two 16 bit words.\n\t *  If the high bit is set, we grab the next value and combine them to get a 31-bit value. The possible\n\t *  input int values are [-1,0x7FFF_FFFF].\n\t *\n\t * \t\t| compression/encoding                         | uint16 count | type            |\n\t * \t\t| -------------------------------------------- | ------------ | --------------- |\n\t * \t\t| 0xxxxxxx xxxxxxxx                            | 1            | uint (15 bit)   |\n\t * \t\t| 1xxxxxxx xxxxxxxx yyyyyyyy yyyyyyyy          | 2            | uint (16+ bits) |\n\t * \t\t| 11111111 11111111 11111111 11111111          | 2            | int value -1    |\n\t *\n\t * \tThis is only used (other than for testing) by {@link org.antlr.v4.codegen.model.SerializedJavaATN}\n\t * \tto encode ints as char values for the java target, but it is convenient to combine it with the\n\t * \t#decodeIntsEncodedAs16BitWords that follows as they are a pair (I did not want to introduce a new class\n\t * \tinto the runtime). Used only for Java Target.","sourceCodeStart":568,"sourceCodeEnd":604,"githubUrl":"https://github.com/antlr/antlr4/blob/7d5770395bb7b02eb56e7c62662cb1d7c08f42a3/runtime/Java/src/org/antlr/v4/runtime/atn/ATNDeserializer.java#L568-L604","documentation":"For lexer ATNs, lexerActionFactory constructs actions only for the built-in LexerActionType values CHANNEL, CUSTOM, MODE, MORE, POP_MODE, PUSH_MODE, SKIP, and TYPE. An unrecognized action type indicates incompatible or malformed serialized lexer action data. In practice this usually means lexer/runtime classes from different ANTLR versions are mixed.","triggerScenarios":"Deserializing a lexer ATN whose lexer-action ordinal was encoded by a different runtime/ANTLR build; corrupted serialized data causing an invalid enum/action code; or classpath shadowing that loads mismatched LexerActionType and ATNDeserializer classes.","commonSituations":"Multiple antlr4-runtime versions, stale generated lexers, shading conflicts, and custom serialized ATN data.","solutions":["Align the ANTLR tool, generated lexer, and antlr4-runtime on one version.","Regenerate all lexer/parser sources and clean-build.","Inspect dependencies for duplicate or shaded ANTLR runtimes.","Do not manually edit serialized lexer action records."],"exampleFix":"// before: generated lexer from one ANTLR version, runtime from another\nnew MyLexer(input);\n\n// after: regenerate MyLexer with the runtime's ANTLR version and remove duplicate runtime jars\nnew MyLexer(input);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    return new ATNDeserializer(options).deserialize(serialized);\n} catch (IllegalArgumentException e) {\n    throw new IllegalStateException(\"Lexer action data is incompatible with this ANTLR runtime\", e);\n}","preventionTips":["Use one ANTLR runtime version across generated lexers and application.","Regenerate lexer sources when the runtime changes.","Do not hand-edit serialized lexer action ordinals."],"tags":["antlr","java","lexer","lexer-action","serialization","compatibility"],"backgroundTag":null,"analyzedSha":"7d5770395bb7b02eb56e7c62662cb1d7c08f42a3","analyzedAt":"2026-08-14T14:47:56.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}