-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[Java] Preserve serialized ATN version 3 compatibility #3583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,10 +20,10 @@ | |
| * @author Sam Harwell | ||
| */ | ||
| public class ATNDeserializer { | ||
| public static final int SERIALIZED_VERSION; | ||
| static { | ||
| SERIALIZED_VERSION = 4; | ||
| } | ||
|
|
||
| static final int LEGACY_SERIALIZED_VERSION = 3; | ||
|
|
||
| public static final int SERIALIZED_VERSION = 4; | ||
|
|
||
| interface UnicodeDeserializer { | ||
| // Wrapper for readInt() or readInt32() | ||
|
|
@@ -90,6 +90,12 @@ public ATN deserialize(char[] data) { | |
|
|
||
| int p = 0; | ||
| int version = toInt(data[p++]); | ||
| if (version == LEGACY_SERIALIZED_VERSION) { | ||
| // Preserve backwards compatibility for version 3. We simply skip over the UUID and assume all | ||
| // features were supported. | ||
| p += 8; | ||
| version = SERIALIZED_VERSION; | ||
| } | ||
|
Comment on lines
+93
to
+98
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use tabs instead of spaces (ANTLR uses tabs formatting).
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah,I am abandoning backward compatibility except for the java target because we have special internal problem to resolve. I'll deal with this when I can look at the 32 bit implementation.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I guess I will do a bit of copy and paste programming for java if I get the 32-bit deserialization going. thanks for pointing this out |
||
| if (version != SERIALIZED_VERSION) { | ||
| String reason = String.format(Locale.getDefault(), "Could not deserialize ATN with version %d (expected %d).", version, SERIALIZED_VERSION); | ||
| throw new UnsupportedOperationException(new InvalidClassException(ATN.class.getName(), reason)); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's unclear what exacly
LEGACY_SERIALIZED_VERSIONis. What ifSERIALIZED_VERSIONwill be incremented?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a loose patch to solve an internal problem we have.