001/*
002 *  This file is part of the Jikes RVM project (http://jikesrvm.org).
003 *
004 *  This file is licensed to You under the Eclipse Public License (EPL);
005 *  You may not use this file except in compliance with the License. You
006 *  may obtain a copy of the License at
007 *
008 *      http://www.opensource.org/licenses/eclipse-1.0.php
009 *
010 *  See the COPYRIGHT.txt file distributed with this work for information
011 *  regarding copyright ownership.
012 */
013package org.mmtk.vm;
014
015import org.vmmagic.pragma.Uninterruptible;
016
017@Uninterruptible public abstract class Assert {
018  /**
019   * Logs a message and traceback, then exits.
020   *
021   * @param message the string to log
022   */
023  public abstract void fail(String message);
024
025  /**
026   * Checks that the given condition is true.  If it is not, this
027   * method does a traceback and exits.  All calls to this method
028   * must be guarded by <code>VM.VERIFY_ASSERTIONS</code>.
029   *
030   * @param cond the condition to be checked
031   */
032  public abstract void _assert(boolean cond);
033
034  /**
035   * Checks that the given condition is true.  If it is not, this
036   * method prints a message, does a traceback and exits. All calls
037   * to this method must be guarded by <code>VM.VERIFY_ASSERTIONS</code>.
038   *
039   * @param cond the condition to be checked
040   * @param message the message to print
041   */
042  public abstract void _assert(boolean cond, String message);
043
044  /**
045   * Print a stack trace
046   */
047  public abstract void dumpStack();
048
049  /*
050   * NOTE: The following methods must be implemented by subclasses of this
051   * class, but are internal to the VM<->MM interface glue, so are never
052   * called by MMTk users.
053   */
054   /** @return <code>true</code> if assertions should be verified */
055  protected abstract boolean getVerifyAssertionsConstant();
056
057  /*
058   * NOTE: This method should not be called by anything other than the
059   * reflective mechanisms in org.mmtk.vm.VM, and is not implemented by
060   * subclasses.
061   *
062   * This hack exists only to allow us to declare getVerifyAssertions() as
063   * a protected method.
064   */
065  static boolean verifyAssertionsTrapdoor(Assert a) {
066    return a.getVerifyAssertionsConstant();
067  }
068}