duke@435: /* stefank@2314: * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #ifndef SHARE_VM_CLASSFILE_JAVAASSERTIONS_HPP stefank@2314: #define SHARE_VM_CLASSFILE_JAVAASSERTIONS_HPP stefank@2314: stefank@2314: #include "oops/objArrayOop.hpp" stefank@2314: #include "oops/typeArrayOop.hpp" stefank@2314: #include "utilities/exceptions.hpp" stefank@2314: #include "utilities/ostream.hpp" stefank@2314: duke@435: class JavaAssertions: AllStatic { duke@435: public: duke@435: static inline bool userClassDefault(); duke@435: static inline void setUserClassDefault(bool enabled); duke@435: static inline bool systemClassDefault(); duke@435: static inline void setSystemClassDefault(bool enabled); duke@435: duke@435: // Add a command-line option. A name ending in "..." applies to a package and duke@435: // any subpackages; other names apply to a single class. duke@435: static void addOption(const char* name, bool enable); duke@435: duke@435: // Return true if command-line options have enabled assertions for the named duke@435: // class. Should be called only after all command-line options have been duke@435: // processed. Note: this only consults command-line options and does not duke@435: // account for any dynamic changes to assertion status. duke@435: static bool enabled(const char* classname, bool systemClass); duke@435: duke@435: // Create an instance of java.lang.AssertionStatusDirectives and fill in the duke@435: // fields based on the command-line assertion options. duke@435: static oop createAssertionStatusDirectives(TRAPS); duke@435: duke@435: private: duke@435: class OptionList; duke@435: static void fillJavaArrays(const OptionList* p, int len, objArrayHandle names, duke@435: typeArrayHandle status, TRAPS); duke@435: duke@435: static inline void trace(const char* name, const char* typefound, duke@435: const char* namefound, bool enabled); duke@435: duke@435: static inline OptionList* match_class(const char* classname); duke@435: static OptionList* match_package(const char* classname); duke@435: duke@435: static bool _userDefault; // User class default (-ea/-da). duke@435: static bool _sysDefault; // System class default (-esa/-dsa). duke@435: static OptionList* _classes; // Options for classes. duke@435: static OptionList* _packages; // Options for package trees. duke@435: }; duke@435: zgu@3900: class JavaAssertions::OptionList: public CHeapObj { duke@435: public: duke@435: inline OptionList(const char* name, bool enable, OptionList* next); duke@435: duke@435: inline const char* name() const { return _name; } duke@435: inline bool enabled() const { return _enabled; } duke@435: inline OptionList* next() const { return _next; } duke@435: duke@435: static int count(OptionList* p); duke@435: duke@435: private: duke@435: const char* _name; duke@435: OptionList* _next; duke@435: bool _enabled; duke@435: }; duke@435: duke@435: inline bool JavaAssertions::userClassDefault() { duke@435: return _userDefault; duke@435: } duke@435: duke@435: inline void JavaAssertions::setUserClassDefault(bool enabled) { duke@435: if (TraceJavaAssertions) duke@435: tty->print_cr("JavaAssertions::setUserClassDefault(%d)", enabled); duke@435: _userDefault = enabled; duke@435: } duke@435: duke@435: inline bool JavaAssertions::systemClassDefault() { duke@435: return _sysDefault; duke@435: } duke@435: duke@435: inline void JavaAssertions::setSystemClassDefault(bool enabled) { duke@435: if (TraceJavaAssertions) duke@435: tty->print_cr("JavaAssertions::setSystemClassDefault(%d)", enabled); duke@435: _sysDefault = enabled; duke@435: } stefank@2314: stefank@2314: #endif // SHARE_VM_CLASSFILE_JAVAASSERTIONS_HPP