publicclass ReproducibleJar { privatestaticfinal ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
.orElseThrow(() -> new RuntimeException("jar tool not found")
);
// ZipEntry's mod date has 2 seconds precision: give extra time to // allow for e.g. rounding/truncation and networked/samba drives. privatestaticfinallong PRECISION = 10000L;
/** *ChecktheextractedandoriginalmillissinceEpochfiletimesare *withinthezipprecisiontimeperiod.
*/ staticvoid checkFileTime(long now, long original) { if (isTimeSettingChanged()) { return;
}
if (Math.abs(now - original) > PRECISION) { // If original time is after UNIX 2038 32bit rollover // and the now time is exactly the rollover time, then assume // running on a file system that only supports to 2038 (e.g.XFS) and pass test if (FileTime.fromMillis(original).toInstant().isAfter(UNIX_2038_ROLLOVER) &&
FileTime.fromMillis(now).toInstant().equals(UNIX_2038_ROLLOVER)) {
System.out.println("Checking file time after Unix 2038 rollover," + " and extracted file time is " + UNIX_2038_ROLLOVER_TIME + ", " + " Assuming restricted file system, pass file time check.");
} else { thrownew AssertionError("checkFileTime failed," + " extracted to " + FileTime.fromMillis(now) + ", expected to be close to " + FileTime.fromMillis(original));
}
}
}
/** *HasthetimezoneorDSTchangedduringthetest?
*/ privatestaticboolean isTimeSettingChanged() {
TimeZone currentTZ = TimeZone.getDefault(); boolean currentDST = currentTZ.inDaylightTime(new Date()); if (!currentTZ.equals(TZ) || currentDST != DST) {
System.out.println("Timezone or DST has changed during " + "ReproducibleJar testcase execution. Test skipped"); returntrue;
} else { returnfalse;
}
}
/** *IstheZonecurrentlywithinthetransitionchangeperiod?
*/ privatestaticboolean isInTransition() { var inTransition = false; var date = new Date(); var defZone = ZoneId.systemDefault(); if (defZone.getRules().getTransition(
date.toInstant().atZone(defZone).toLocalDateTime()) != null) {
System.out.println("ReproducibleJar testcase being run during Zone offset transition. Test skipped.");
inTransition = true;
} return inTransition;
}
/** *Removethedirectoryanditscontents
*/ staticvoid cleanup(File dir) {
File[] x = dir.listFiles(); if (x != null) { for (File f : x) {
f.delete();
}
}
dir.delete();
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.