heads-up - argument formatting for assert and friends

John Coomes John.Coomes at oracle.com
Mon May 3 14:59:23 PDT 2010


I recently pushed

	6888954: argument formatting for assert() and friends

to the hotspot-gc repo; it should make it to the main hotspot repo
(http://hg.openjdk.java.net/jdk7/hotspot/hotspot) later today.

The change allows assert(), guarantee(), fatal(), etc., to accept
printf-like format strings in addition to string literals.  The format
strings and arguments are passed to a utility class that does the
formatting; sample usage is:

	int num = foo();
	assert(num == 0, err_msg("expected 0; num = %d", num));

where err_msg() constructs a temporary object with a buffer on the
stack and returns a pointer to the formatted string.

If you use this feature, be careful to avoid null pointer derefs, as
you'll get less information from the assert, rather than more :-(.

-John



More information about the hotspot-dev mailing list