diff --git a/Src/PCompiler/CompilerCore/Backend/PObserve/Constants.cs b/Src/PCompiler/CompilerCore/Backend/PObserve/Constants.cs
index 83d2ce618..fac182781 100644
--- a/Src/PCompiler/CompilerCore/Backend/PObserve/Constants.cs
+++ b/Src/PCompiler/CompilerCore/Backend/PObserve/Constants.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.Linq;
using System.Text;
@@ -13,6 +14,14 @@ namespace Plang.Compiler.Backend.Java
///
internal static class Constants
{
+ ///
+ /// A single UTC timestamp captured at class load time, shared by all generated file headers
+ /// and annotations to ensure consistency across all output files.
+ ///
+ private static readonly DateTime GenerationTimestampUtc = DateTime.UtcNow;
+
+ private static readonly CultureInfo Inv = CultureInfo.InvariantCulture;
+
#region P Java runtime constants
public static readonly string PRTNamespaceName = "pobserve.runtime";
@@ -28,7 +37,8 @@ internal static class Constants
{
"java.io.Serializable",
"java.util.*",
- "java.util.logging.*"
+ "java.util.logging.*",
+ "javax.annotation.processing.Generated"
};
///
@@ -43,6 +53,18 @@ internal static IEnumerable ImportStatements()
return classes.Select(pkg => $"import {pkg};");
}
+ ///
+ /// The value to use in the @Generated annotation, identifying the P compiler as the code generator.
+ ///
+ internal static readonly string GeneratedAnnotationValue = "P Compiler";
+
+ ///
+ /// Returns the @Generated annotation line to emit before generated class declarations.
+ /// Includes the generation timestamp in ISO 8601 format.
+ ///
+ internal static string GeneratedAnnotation =>
+ $"@Generated(value = \"{GeneratedAnnotationValue}\", date = \"{GenerationTimestampUtc.ToString("yyyy-MM-dd'T'HH:mm:ss'Z'", Inv)}\")";
+
public static readonly string MachineNamespaceName = "PMachines";
public static readonly string MachineDefnFileName = $"{MachineNamespaceName}.java";
@@ -71,7 +93,7 @@ internal static IEnumerable ImportStatements()
private static readonly string rawFFIBanner = $@"
P <-> Java Foreign Function Interface Stubs
-This file was auto-generated on {DateTime.Now.ToLongDateString()} at {DateTime.Now.ToLongTimeString()}.
+This file was auto-generated on {GenerationTimestampUtc.ToString("D", Inv)} at {GenerationTimestampUtc.ToString("T", Inv)} UTC.
Please separate each generated class into its own .java file (detailed throughout the file), filling
in the body of each function definition as necessary for your project's business logic.
@@ -105,7 +127,7 @@ internal static string AsFFIComment(string line)
internal static string DoNotEditWarning => $@"
/***************************************************************************
- * This file was auto-generated on {DateTime.Now.ToLongDateString()} at {DateTime.Now.ToLongTimeString()}.
+ * This file was auto-generated on {GenerationTimestampUtc.ToString("D", Inv)} at {GenerationTimestampUtc.ToString("T", Inv)} UTC.
* Please do not edit manually!
**************************************************************************/";
diff --git a/Src/PCompiler/CompilerCore/Backend/PObserve/EventGenerator.cs b/Src/PCompiler/CompilerCore/Backend/PObserve/EventGenerator.cs
index 1ede99701..62ad1216d 100644
--- a/Src/PCompiler/CompilerCore/Backend/PObserve/EventGenerator.cs
+++ b/Src/PCompiler/CompilerCore/Backend/PObserve/EventGenerator.cs
@@ -18,6 +18,7 @@ internal EventGenerator(ICompilerConfiguration job, string filename) : base(job,
///
protected override void GenerateCodeImpl()
{
+ WriteLine(Constants.GeneratedAnnotation);
WriteLine($"public class {Constants.EventNamespaceName} {{");
foreach (var e in monitoredEvents(GlobalScope.Machines))
{
diff --git a/Src/PCompiler/CompilerCore/Backend/PObserve/MachineGenerator.cs b/Src/PCompiler/CompilerCore/Backend/PObserve/MachineGenerator.cs
index 6623b6dc6..366c6e2f1 100644
--- a/Src/PCompiler/CompilerCore/Backend/PObserve/MachineGenerator.cs
+++ b/Src/PCompiler/CompilerCore/Backend/PObserve/MachineGenerator.cs
@@ -35,6 +35,7 @@ internal MachineGenerator(ICompilerConfiguration job, string filename) : base(jo
///
protected override void GenerateCodeImpl()
{
+ WriteLine(Constants.GeneratedAnnotation);
WriteLine($"public class {Constants.MachineNamespaceName} {{");
WriteLine($"private static Logger logger = Logger.getLogger({Constants.MachineNamespaceName}.class.getName());");
if (debug) {
diff --git a/Src/PCompiler/CompilerCore/Backend/PObserve/TypesGenerator.cs b/Src/PCompiler/CompilerCore/Backend/PObserve/TypesGenerator.cs
index 6ec1c71e1..26be34a85 100644
--- a/Src/PCompiler/CompilerCore/Backend/PObserve/TypesGenerator.cs
+++ b/Src/PCompiler/CompilerCore/Backend/PObserve/TypesGenerator.cs
@@ -39,6 +39,7 @@ internal TypesGenerator(ICompilerConfiguration job, string filename) : base(job,
///
protected override void GenerateCodeImpl()
{
+ WriteLine(Constants.GeneratedAnnotation);
WriteLine($"public class {Constants.TypesNamespaceName} {{");
if (GlobalScope.Enums.Any())