Path: blob/master/src/hotspot/share/classfile/javaAssertions.hpp
40949 views
/*1* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_CLASSFILE_JAVAASSERTIONS_HPP25#define SHARE_CLASSFILE_JAVAASSERTIONS_HPP2627#include "oops/objArrayOop.hpp"28#include "oops/typeArrayOop.hpp"29#include "runtime/handles.hpp"30#include "utilities/exceptions.hpp"31#include "utilities/ostream.hpp"3233class JavaAssertions: AllStatic {34public:35static inline bool userClassDefault();36static inline void setUserClassDefault(bool enabled);37static inline bool systemClassDefault();38static inline void setSystemClassDefault(bool enabled);3940// Add a command-line option. A name ending in "..." applies to a package and41// any subpackages; other names apply to a single class.42static void addOption(const char* name, bool enable);4344// Return true if command-line options have enabled assertions for the named45// class. Should be called only after all command-line options have been46// processed. Note: this only consults command-line options and does not47// account for any dynamic changes to assertion status.48static bool enabled(const char* classname, bool systemClass);4950// Create an instance of java.lang.AssertionStatusDirectives and fill in the51// fields based on the command-line assertion options.52static oop createAssertionStatusDirectives(TRAPS);5354private:55class OptionList;56static void fillJavaArrays(const OptionList* p, int len, objArrayHandle names,57typeArrayHandle status, TRAPS);5859static inline void trace(const char* name, const char* typefound,60const char* namefound, bool enabled);6162static inline OptionList* match_class(const char* classname);63static OptionList* match_package(const char* classname);6465static bool _userDefault; // User class default (-ea/-da).66static bool _sysDefault; // System class default (-esa/-dsa).67static OptionList* _classes; // Options for classes.68static OptionList* _packages; // Options for package trees.69};7071class JavaAssertions::OptionList: public CHeapObj<mtClass> {72public:73inline OptionList(const char* name, bool enable, OptionList* next);7475inline const char* name() const { return _name; }76inline bool enabled() const { return _enabled; }77inline OptionList* next() const { return _next; }7879static int count(OptionList* p);8081private:82const char* _name;83OptionList* _next;84bool _enabled;85};8687inline bool JavaAssertions::userClassDefault() {88return _userDefault;89}9091inline void JavaAssertions::setUserClassDefault(bool enabled) {92if (TraceJavaAssertions)93tty->print_cr("JavaAssertions::setUserClassDefault(%d)", enabled);94_userDefault = enabled;95}9697inline bool JavaAssertions::systemClassDefault() {98return _sysDefault;99}100101inline void JavaAssertions::setSystemClassDefault(bool enabled) {102if (TraceJavaAssertions)103tty->print_cr("JavaAssertions::setSystemClassDefault(%d)", enabled);104_sysDefault = enabled;105}106107#endif // SHARE_CLASSFILE_JAVAASSERTIONS_HPP108109110