diff --git a/Source/DafnyCore/Backends/Java/JavaBackend.cs b/Source/DafnyCore/Backends/Java/JavaBackend.cs index 9bcfdde1f3..f0de140c46 100644 --- a/Source/DafnyCore/Backends/Java/JavaBackend.cs +++ b/Source/DafnyCore/Backends/Java/JavaBackend.cs @@ -1,11 +1,14 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.CommandLine; using System.Diagnostics.Contracts; using System.IO; using System.Linq; using System.Text.RegularExpressions; using System.Threading.Tasks; +using DafnyCore; +using DafnyCore.Options; namespace Microsoft.Dafny.Compilers; @@ -26,6 +29,19 @@ public override string TargetBaseDir(string dafnyProgramName) => public override bool SupportsInMemoryCompilation => false; public override bool TextualTargetIsExecutable => false; + public static readonly Option LegacyDataConstructors = new("--legacy-data-constructors", + @" +Generate unsafe, deprecated data constructor methods that do not take type descriptors, +for backwards compatibility with Java code generated with Dafny versions earlier than 4.3.".TrimStart()) { + IsHidden = true + }; + static JavaBackend() { + DafnyOptions.RegisterLegacyUi(LegacyDataConstructors, DafnyOptions.ParseBoolean, "Compilation options", legacyName: "legacyDataConstructors", defaultValue: false); + DooFile.RegisterNoChecksNeeded(LegacyDataConstructors, false); + } + + public override IEnumerable