[m-rev.] diff: workaround standard library initialization problems in the Java grade

Julien Fischer jfischer at opturion.com
Mon Mar 7 13:42:12 AEDT 2016


Hi,

On Mon, 7 Mar 2016, Sebastian Godelet wrote:

> Oh I see now why this is so complicated, I didn't think of ground
> terms, so for a proper fix the compiler would have to honour the
> functional dependencies between the various static initialisation
> blocks.
> One thing that might be successful is using a custom class loader,
> which first loads a class that is responsible for initialising library
> code and then delegates the work to its parent class loader. Although
> now as I understand that might still cause problems with the ground
> terms.

I think the right approach is to essentially use the "mkinit" approach
that the C and Erlang backends use, that is we generate a class that
exports a method that calls the init preds and generate a call to that
method immediately before main/2 (for executables) and use something
like the C backend's standalone interfaces for libraries.

...

> On a related problem I once had a case when the user `:- initialise'
> blocks where in a different order depending which grade was used,

If the ':- initialise' declarations in question were all within the
same module then that's a bug -- within a module they're supposed
to be executed in declaration order.  If they were in different modules
then there is no guaranteed ordering, so different grades are allowed
to use different orderings.

Julien.



More information about the reviews mailing list