From faaaec7825b59097162edb2059d681fb21cd45f9 Mon Sep 17 00:00:00 2001 From: Soumya Smruti Mishra Date: Wed, 20 Sep 2023 16:23:52 -0700 Subject: [PATCH] add serializable to the Supplier in generated Java code. --- Src/PCompiler/CompilerCore/Backend/Java/Constants.cs | 1 + Src/PCompiler/CompilerCore/Backend/Java/MachineGenerator.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Src/PCompiler/CompilerCore/Backend/Java/Constants.cs b/Src/PCompiler/CompilerCore/Backend/Java/Constants.cs index b21d20ad1..636487481 100644 --- a/Src/PCompiler/CompilerCore/Backend/Java/Constants.cs +++ b/Src/PCompiler/CompilerCore/Backend/Java/Constants.cs @@ -26,6 +26,7 @@ internal static class Constants private static readonly string[] JreDefaultImports = { + "java.io.Serializable" "java.util.*", }; diff --git a/Src/PCompiler/CompilerCore/Backend/Java/MachineGenerator.cs b/Src/PCompiler/CompilerCore/Backend/Java/MachineGenerator.cs index b05a576a2..f44072f89 100644 --- a/Src/PCompiler/CompilerCore/Backend/Java/MachineGenerator.cs +++ b/Src/PCompiler/CompilerCore/Backend/Java/MachineGenerator.cs @@ -116,7 +116,7 @@ private void WriteMonitorDecl() private void WriteSupplierCDef(string cname) { - WriteLine($"public static class Supplier implements java.util.function.Supplier<{cname}> {{"); + WriteLine($"public static class Supplier implements java.util.function.Supplier<{cname}>, Serializable {{"); WriteLine($"public {cname} get() {{"); WriteLine($"{cname} ret = new {cname}();"); WriteLine("ret.ready();"); // TODO: at this point, we may as well ready() within the monitor's constructor?