[m-rev.] diff: initialise standard library in standalone Java example

Julien Fischer jfischer at opturion.com
Fri Nov 9 16:47:26 AEDT 2018


Initialise standard library in standalone Java example.

samples/java_interface/standalone_java/JavaMain.java:
      We need to initialise the standard library, otherwise things
      like the stream database won't be set up properly.

Julien.

diff --git a/samples/java_interface/standalone_java/JavaMain.java b/samples/java_interface/standalone_java/JavaMain.java
index c010972..1c3cdfb 100644
--- a/samples/java_interface/standalone_java/JavaMain.java
+++ b/samples/java_interface/standalone_java/JavaMain.java
@@ -6,6 +6,10 @@
  //
  import jmercury.runtime.MercuryRuntime;

+// The library class in the jmercury package contains the initialisation method
+// for Mercury's standard library.
+import jmercury.library;
+
  // The mercury_lib class is generated by the compiler when we build
  // mercury_lib library.
  //
@@ -20,6 +24,12 @@ public class JavaMain {
          // We do not need to do anything to initialise the Java version of the
          // Mercury runtime.  It will be automatically initialised as the
          // relevant classes are loaded by the JVM.
+
+        // Initialise the Java version of Mercury's standard library.
+        //
+        out.println("JavaMain: initialising Mercury standard library");
+        library.ML_std_library_init();
+
          out.println("JavaMain: start main");

          try {
@@ -31,7 +41,7 @@ public class JavaMain {
              // this.  This call is (currently) mandatory otherwise the JVM
              // may not exit cleanly, therefore it should be called in a
              // finally block as in this example.
-            //`
+            //
              // This call will invoke any finalisers specified using
              // ':- finalise' declarations in the set of Mercury libraries we
              // are using.  It also tells the thread pool to shutdown, if the


More information about the reviews mailing list