[m-rev.] diff: workaround standard library initialization problems in the Java grade
sebastian.godelet at outlook.com
Sun Mar 6 12:14:59 AEDT 2016
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:
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 875 bytes
Desc: not available
More information about the reviews