After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 543190 - static constructor not called when class is accessed via static methods
static constructor not called when class is accessed via static methods
Status: RESOLVED DUPLICATE of bug 543189
Product: vala
Classification: Core
Component: general
0.3.x
Other All
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2008-07-15 22:04 UTC by Stef Walter
Modified: 2008-07-16 02:21 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Stef Walter 2008-07-15 22:04:45 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());
	}
}
Comment 1 Jared Moore 2008-07-16 02:21:43 UTC

*** This bug has been marked as a duplicate of 543189 ***