diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/ATNDeserializationOptions.java b/runtime/Java/src/org/antlr/v4/runtime/atn/ATNDeserializationOptions.java index 42deadb0e..123199b65 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/ATNDeserializationOptions.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ATNDeserializationOptions.java @@ -44,11 +44,14 @@ public class ATNDeserializationOptions { } private boolean readOnly; + private boolean verifyATN; public ATNDeserializationOptions() { + this.verifyATN = true; } public ATNDeserializationOptions(ATNDeserializationOptions options) { + this.verifyATN = options.verifyATN; } @NotNull @@ -64,6 +67,15 @@ public class ATNDeserializationOptions { readOnly = true; } + public final boolean isVerifyATN() { + return verifyATN; + } + + public final void setVerifyATN(boolean verifyATN) { + throwIfReadOnly(); + this.verifyATN = verifyATN; + } + protected void throwIfReadOnly() { if (isReadOnly()) { throw new IllegalStateException("The object is read only."); diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/ATNDeserializer.java b/runtime/Java/src/org/antlr/v4/runtime/atn/ATNDeserializer.java index 4945a5134..0814974a0 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/ATNDeserializer.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ATNDeserializer.java @@ -358,7 +358,10 @@ public class ATNDeserializer { decState.decision = i-1; } - verifyATN(atn); + if (deserializationOptions.isVerifyATN()) { + verifyATN(atn); + } + return atn; }