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

Sebastian Godelet sebastian.godelet at outlook.com
Sun Mar 6 12:14:59 AEDT 2016


Hi Julien,

Concerning the library initialisation problem, you mention
> this in Java using static initializers we can't guarantee that the order things
> occur in.
But reading the docs and writing a simple test program (c.f. attached Test.java)
the order of static initialisers is guaranteed by the JVM.
If you run my test class like this: `java Test C B A' with any order of A B C,
the output will always be:
A0
A1
B0
B1
C0
C1
This works also for: java Test C C.
So to solve the problem the call to std_library_init/2 must be wrapped into a static block,
maybe in the same class defining the procedure, and each user initialiser
must contain a static reference to the library class (either by accessing a static field or using Class.forName, etc.).
Not sure what must be done for C# though, since there it is a little bit more complicated.

Cheers,

Sebastian.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Test.java
Type: application/octet-stream
Size: 875 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20160306/4bd83646/attachment.obj>


More information about the reviews mailing list