Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/classfile/javaAssertions.hpp
32285 views
/*1* Copyright (c) 2000, 2012, 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_VM_CLASSFILE_JAVAASSERTIONS_HPP25#define SHARE_VM_CLASSFILE_JAVAASSERTIONS_HPP2627#include "oops/objArrayOop.hpp"28#include "oops/typeArrayOop.hpp"29#include "utilities/exceptions.hpp"30#include "utilities/ostream.hpp"3132class JavaAssertions: AllStatic {33public:34static inline bool userClassDefault();35static inline void setUserClassDefault(bool enabled);36static inline bool systemClassDefault();37static inline void setSystemClassDefault(bool enabled);3839// Add a command-line option. A name ending in "..." applies to a package and40// any subpackages; other names apply to a single class.41static void addOption(const char* name, bool enable);4243// Return true if command-line options have enabled assertions for the named44// class. Should be called only after all command-line options have been45// processed. Note: this only consults command-line options and does not46// account for any dynamic changes to assertion status.47static bool enabled(const char* classname, bool systemClass);4849// Create an instance of java.lang.AssertionStatusDirectives and fill in the50// fields based on the command-line assertion options.51static oop createAssertionStatusDirectives(TRAPS);5253private:54class OptionList;55static void fillJavaArrays(const OptionList* p, int len, objArrayHandle names,56typeArrayHandle status, TRAPS);5758static inline void trace(const char* name, const char* typefound,59const char* namefound, bool enabled);6061static inline OptionList* match_class(const char* classname);62static OptionList* match_package(const char* classname);6364static bool _userDefault; // User class default (-ea/-da).65static bool _sysDefault; // System class default (-esa/-dsa).66static OptionList* _classes; // Options for classes.67static OptionList* _packages; // Options for package trees.68};6970class JavaAssertions::OptionList: public CHeapObj<mtClass> {71public:72inline OptionList(const char* name, bool enable, OptionList* next);7374inline const char* name() const { return _name; }75inline bool enabled() const { return _enabled; }76inline OptionList* next() const { return _next; }7778static int count(OptionList* p);7980private:81const char* _name;82OptionList* _next;83bool _enabled;84};8586inline bool JavaAssertions::userClassDefault() {87return _userDefault;88}8990inline void JavaAssertions::setUserClassDefault(bool enabled) {91if (TraceJavaAssertions)92tty->print_cr("JavaAssertions::setUserClassDefault(%d)", enabled);93_userDefault = enabled;94}9596inline bool JavaAssertions::systemClassDefault() {97return _sysDefault;98}99100inline void JavaAssertions::setSystemClassDefault(bool enabled) {101if (TraceJavaAssertions)102tty->print_cr("JavaAssertions::setSystemClassDefault(%d)", enabled);103_sysDefault = enabled;104}105106#endif // SHARE_VM_CLASSFILE_JAVAASSERTIONS_HPP107108109