# HG changeset patch # User Doug Simon # Date 1366907821 -7200 # Node ID e26191d535a744a5f51b4fb20223cbb8508d2d12 # Parent c78ef1df7b067567ddacda1a9a0d939c1815c451 added guarantee() method to GraalInternalError diff -r c78ef1df7b06 -r e26191d535a7 graal/com.oracle.graal.graph/src/com/oracle/graal/graph/GraalInternalError.java --- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/GraalInternalError.java Thu Apr 25 18:36:23 2013 +0200 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/GraalInternalError.java Thu Apr 25 18:37:01 2013 +0200 @@ -51,6 +51,23 @@ } /** + * Checks a given condition and throws a {@link GraalInternalError} if it is false. Guarantees + * are stronger than assertions in that they are always checked. Error messages for guarantee + * violations should clearly indicate the nature of the problem as well as a suggested solution + * if possible. + * + * @param condition the condition to check + * @param msg the message that will be associated with the error, in + * {@link String#format(String, Object...)} syntax + * @param args arguments to the format string + */ + public static void guarantee(boolean condition, String msg, Object... args) { + if (!condition) { + throw new GraalInternalError("failed guarantee: " + msg, args); + } + } + + /** * This constructor creates a {@link GraalInternalError} with a message assembled via * {@link String#format(String, Object...)}. It always uses the ENGLISH locale in order to * always generate the same output.