From 87e2284b1ba0e473420abc37438b127b3f95ccef Mon Sep 17 00:00:00 2001 From: Marcus Lagergren <1062473+lagergren@users.noreply.github.com> Date: Wed, 18 Nov 2026 10:09:22 +0100 Subject: [PATCH 1/2] Show a module's timestamp whether or not it has a source directory ModuleStructure.getDescription(), which toString() uses, checked the source directory instead of the timestamp before printing the timestamp. A module with a timestamp but no source directory, such as one compiled from a source with no file, was described as "timestamp=none". A module with a source directory but no timestamp made it throw a NullPointerException. --- .../java/org/xvm/asm/ModuleStructure.java | 2 +- .../java/org/xvm/asm/FileStructureTest.java | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/javatools/src/main/java/org/xvm/asm/ModuleStructure.java b/javatools/src/main/java/org/xvm/asm/ModuleStructure.java index 1637d2363d..8666049738 100644 --- a/javatools/src/main/java/org/xvm/asm/ModuleStructure.java +++ b/javatools/src/main/java/org/xvm/asm/ModuleStructure.java @@ -946,7 +946,7 @@ public String getDescription() { sb.append(", source-dir=") .append(m_constDir == null ? "none" : m_constDir.getValueString()) .append(", timestamp=") - .append(m_constDir == null ? "none" : m_constTimestamp.getValueString()); + .append(m_constTimestamp == null ? "none" : m_constTimestamp.getValueString()); return sb.toString(); } diff --git a/javatools/src/test/java/org/xvm/asm/FileStructureTest.java b/javatools/src/test/java/org/xvm/asm/FileStructureTest.java index 0be432a3bb..51baca7abc 100644 --- a/javatools/src/test/java/org/xvm/asm/FileStructureTest.java +++ b/javatools/src/test/java/org/xvm/asm/FileStructureTest.java @@ -144,6 +144,31 @@ public void testExplicitTimestampMakesGenerationReproducible() assertArrayEquals(outFirst.toByteArray(), outSecond.toByteArray()); } + @Test + public void testDescriptionShowsTimestampOfModuleWithoutSourceDir() { + // a module compiled from a source with no file, or made directly, has a timestamp but no + // source directory + var module = new FileStructure("Described", Instant.parse("2026-01-01T00:00:00Z")).getModule(); + + assertNull(module.getSourceDir()); + assertTrue(module.getDescription().endsWith( + "source-dir=none, timestamp=" + module.getTimestamp().getValueString()), + module.getDescription()); + } + + @Test + public void testDescriptionOfModuleWithSourceDirButNoTimestamp() { + var file = new FileStructure("Described"); + var module = file.getModule(); + var dir = file.getConstantPool().ensureLiteralConstant(Constant.Format.Path, "/src/"); + module.setSourceDir(dir); + module.setTimestamp(null); + + assertTrue(module.getDescription().endsWith( + "source-dir=" + dir.getValueString() + ", timestamp=none"), + module.getDescription()); + } + @Test public void testUnknownFileKindIsRejected() throws IOException { From f6fe3ba0eee833f0d3b372172dbd3f214abd311b Mon Sep 17 00:00:00 2001 From: Marcus Lagergren <1062473+lagergren@users.noreply.github.com> Date: Wed, 18 Nov 2026 13:14:27 +0100 Subject: [PATCH 2/2] Remove the tests for the module description fix --- .../java/org/xvm/asm/FileStructureTest.java | 25 ------------------- 1 file changed, 25 deletions(-) diff --git a/javatools/src/test/java/org/xvm/asm/FileStructureTest.java b/javatools/src/test/java/org/xvm/asm/FileStructureTest.java index 51baca7abc..0be432a3bb 100644 --- a/javatools/src/test/java/org/xvm/asm/FileStructureTest.java +++ b/javatools/src/test/java/org/xvm/asm/FileStructureTest.java @@ -144,31 +144,6 @@ public void testExplicitTimestampMakesGenerationReproducible() assertArrayEquals(outFirst.toByteArray(), outSecond.toByteArray()); } - @Test - public void testDescriptionShowsTimestampOfModuleWithoutSourceDir() { - // a module compiled from a source with no file, or made directly, has a timestamp but no - // source directory - var module = new FileStructure("Described", Instant.parse("2026-01-01T00:00:00Z")).getModule(); - - assertNull(module.getSourceDir()); - assertTrue(module.getDescription().endsWith( - "source-dir=none, timestamp=" + module.getTimestamp().getValueString()), - module.getDescription()); - } - - @Test - public void testDescriptionOfModuleWithSourceDirButNoTimestamp() { - var file = new FileStructure("Described"); - var module = file.getModule(); - var dir = file.getConstantPool().ensureLiteralConstant(Constant.Format.Path, "/src/"); - module.setSourceDir(dir); - module.setTimestamp(null); - - assertTrue(module.getDescription().endsWith( - "source-dir=" + dir.getValueString() + ", timestamp=none"), - module.getDescription()); - } - @Test public void testUnknownFileKindIsRejected() throws IOException {