src/Pure/General/zstd.scala
changeset 76349 b4daf7577ca0
parent 76348 a15f16e8ad18
child 76353 3698d0f3da18
--- a/src/Pure/General/zstd.scala	Fri Oct 21 11:08:01 2022 +0200
+++ b/src/Pure/General/zstd.scala	Fri Oct 21 13:15:24 2022 +0200
@@ -8,7 +8,12 @@
 
 
 object Zstd {
-  lazy val init_jni: Unit = {
+  def init(): Unit = init_jni
+
+  private lazy val init_jni: Unit = {
+    require(!com.github.luben.zstd.util.Native.isLoaded(),
+      "Zstd library already initialized by other means than isabelle.Zstd.init()")
+
     val lib_dir = Path.explode("$ISABELLE_ZSTD_HOME/" + Platform.jvm_platform)
     val lib_file =
       File.find_files(lib_dir.file) match {
@@ -16,6 +21,7 @@
         case _ => error("Exactly one file expected in directory " + lib_dir.expand)
       }
     System.load(File.platform_path(lib_file.getAbsolutePath))
+
     com.github.luben.zstd.util.Native.assumeLoaded()
     assert(com.github.luben.zstd.util.Native.isLoaded())
     Class.forName("com.github.luben.zstd.Zstd")