GNOME Bugzilla – Bug 543190
static constructor not called when class is accessed via static methods
Last modified: 2008-07-16 02:21:43 UTC
The static construct block of a class is executed before a new object of that type is created. However I would expect it to be executed when static methods are called. Example: /* * valac test.vala */ using GLib; public class Statico : GLib.Object { public static int test_value; static construct { test_value = 5; } public static int get_test_value() { return test_value; } } public class Test : GLib.Object { public static void main(string[] args) { /* Should print '5', but prints '0' */ stdout.printf("%d\n", Statico.get_test_value()); } }
*** This bug has been marked as a duplicate of 543189 ***