The runtime version information is provided by VERSION and
getRuntimeVersion(). Detailed information about these values is
provided in the documentation for each member.
The runtime version check is implemented by checkVersion. Detailed
information about incorporating this call into user code, as well as its use
in generated code, is provided in the documentation for the method.
Version strings x.y and x.y.z are considered "compatible" and no error would be generated. Likewise, version strings x.y-SNAPSHOT and x.y.z are considered "compatible" because the major and minor components x.y are the same in each.
To trap any error messages issued by this code, use System.setErr() in your main() startup code.
| Modifier and Type | Field and Description |
|---|---|
| public static final String | VERSION
A compile-time constant containing the current version of the ANTLR 4 runtime library. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static void | checkVersion(String
The version of the tool used to generate a parser.
This value may be null when called from user code that was not generated
by, and does not reference, the ANTLR 4 Tool itself. generatingToolVersion, String The version of the runtime the parser was
compiled against. This should always be passed using a direct reference
to compileTimeVersion)VERSION.This method provides the ability to detect mismatches between the version of ANTLR 4 used to generate a parser, the version of the ANTLR runtime a parser was compiled against, and the version of the ANTLR runtime which is currently executing. |
| public static String | Returns: A string of the form major.minor containing only the major and minor components of the version string.The complete version string. version)Gets the major and minor version numbers from a version string. |
| public static String | Returns: The currently executing version of the ANTLR 4 libraryGets the currently executing version of the ANTLR 4 runtime library. |
| VERSION | back to summary |
|---|---|
| public static final String VERSION A compile-time constant containing the current version of the ANTLR 4 runtime library. This compile-time constant value allows generated parsers and other libraries to include a literal reference to the version of the ANTLR 4 runtime library the code was compiled against. At each release, we change this value. Version numbers are assumed to have the form major.minor.patch.revision-suffix, with the individual components defined as follows.
| |
| RuntimeMetaData | back to summary |
|---|---|
| public RuntimeMetaData() | |
| checkVersion | back to summary |
|---|---|
| public static void checkVersion(String generatingToolVersion, String compileTimeVersion) This method provides the ability to detect mismatches between the version of ANTLR 4 used to generate a parser, the version of the ANTLR runtime a parser was compiled against, and the version of the ANTLR runtime which is currently executing. The version check is designed to detect the following two specific scenarios.
Starting with ANTLR 4.3, the code generator emits a call to this method
using two constants in each generated lexer and parser: a hard-coded
constant indicating the version of the tool used to generate the parser
and a reference to the compile-time constant This method does not perform any detection or filtering of semantic changes between tool and runtime versions. It simply checks for a version match and emits an error to stderr if a difference is detected.
Note that some breaking changes between releases could result in other
types of runtime exceptions, such as a Additional note for target developers: The version check implemented by this class is designed to address specific compatibility concerns that may arise during the execution of Java applications. Other targets should consider the implementation of this method in the context of that target's known execution environment, which may or may not resemble the design provided for the Java target.
| |
| getMajorMinorVersion | back to summary |
|---|---|
| public static String getMajorMinorVersion(String version) Gets the major and minor version numbers from a version string. For
details about the syntax of the input | |
| getRuntimeVersion | back to summary |
|---|---|
| public static String getRuntimeVersion() Gets the currently executing version of the ANTLR 4 runtime library.
This method provides runtime access to the
| |