001 /*
002 * This file is part of the Jikes RVM project (http://jikesrvm.org).
003 *
004 * This file is licensed to You under the Common Public License (CPL);
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/cpl1.0.php
009 *
010 * See the COPYRIGHT.txt file distributed with this work for information
011 * regarding copyright ownership.
012 */
013 package org.mmtk.vm;
014
015 import 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 * Checks if the virtual machine is running. This value changes, so
051 * the call-through to the VM must be a method. In Jikes RVM, just
052 * returns VM.runningVM.
053 *
054 * @return <code>true</code> if the virtual machine is running
055 */
056 public abstract boolean runningVM();
057
058 /*
059 * NOTE: The following methods must be implemented by subclasses of this
060 * class, but are internal to the VM<->MM interface glue, so are never
061 * called by MMTk users.
062 */
063 /** @return true if assertions should be verified */
064 protected abstract boolean getVerifyAssertionsConstant();
065
066 /*
067 * NOTE: This method should not be called by anything other than the
068 * reflective mechanisms in org.mmtk.vm.VM, and is not implemented by
069 * subclasses.
070 *
071 * This hack exists only to allow us to declare getVerifyAssertions() as
072 * a protected method.
073 */
074 static boolean verifyAssertionsTrapdoor(Assert a) {
075 return a.getVerifyAssertionsConstant();
076 }
077 }