High Level

The MINERVA program metagen generates MINERVA predicates for all constructors and methods of a given Java class.

Predicate names correspond one-to-one to their Java counterparts.

Generated comments document the usage of these predicates.

Using metagen there are 3 steps:

  1. Invoke metagen on the class you want to add to MINERVA
  2. Edit the generated MINERVA source file as desired
  3. Compile

For example, let us assume you want to add pseudo random numbers as provided by the Java class java.util.Random.

Then these three steps become

  1. minerva -l $MINERVA_HOME/extender/metagen java.util.Random > random.min
  2. edit random.min -see below for the generated output- to remove unneeded methods and make an independent MINERVA package to become e.g.
  3. minervac random

This produced a MINERVA object program random.mbc with interface description random.mpk .

Additionally, since MINERVA is a higher level language than Java, you may want to define application level predicates that abstract from the system level creation and handling of the opaque Java objects from your application.

Below is the complete source program as generated by metagen for java.util.Random. The comments document the Java and Prolog names and input/output data types.

java_predicates('java.util.Random', [
    % java.util.Random()
    % random_create(-java.util.Random)
    % random_create / 1
  random_create = 'java.util.Random',
    % java.util.Random(long)
    % random_create_0(+long, -java.util.Random)
    % random_create_0 / 2
  random_create_0 = 'java.util.Random'(long),
    % boolean nextBoolean()
    % random_nextBoolean(+java.util.Random, -boolean)
    % random_nextBoolean / 1
  random_nextBoolean = nextBoolean,
    % void nextBytes(byte[])
    % random_nextBytes(+java.util.Random, +byte[])
    % random_nextBytes / 2
  random_nextBytes = nextBytes([byte]),
    % double nextDouble()
    % random_nextDouble(+java.util.Random, -double)
    % random_nextDouble / 2
  random_nextDouble = nextDouble,
    % float nextFloat()
    % random_nextFloat(+java.util.Random, -float)
    % random_nextFloat / 2
  random_nextFloat = nextFloat,
    % double nextGaussian()
    % random_nextGaussian(+java.util.Random, -double)
    % random_nextGaussian / 2
  random_nextGaussian = nextGaussian,
    % int nextInt()
    % random_nextInt(+java.util.Random, -int)
    % random_nextInt / 2
  random_nextInt = nextInt,
    % int nextInt(int)
    % random_nextInt_1(+java.util.Random, +int, -int)
    % random_nextInt_1 / 3
  random_nextInt_1 = nextInt(int),
    % long nextLong()
    % random_nextLong(+java.util.Random, -long)
    % random_nextLong / 2
  random_nextLong = nextLong,
    % void setSeed(long)
    % random_setSeed(+java.util.Random, +long)
    % random_setSeed / 2
  random_setSeed = setSeed(long)]).


Darueber read on...