1 /*
 2  * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved.
 3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 4  *
 5  * This code is free software; you can redistribute it and/or modify it
 6  * under the terms of the GNU General Public License version 2 only, as
 7  * published by the Free Software Foundation.
 8  *
 9  * This code is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12  * version 2 for more details (a copy is included in the LICENSE file that
13  * accompanied this code).
14  *
15  * You should have received a copy of the GNU General Public License version
16  * 2 along with this work; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20  * or visit www.oracle.com if you need additional information or have any
21  * questions.
22  *
23  */
24 
25 #ifndef SHARE_CI_CIFLAGS_HPP
26 #define SHARE_CI_CIFLAGS_HPP
27 
28 #include "ci/ciClassList.hpp"
29 #include "utilities/accessFlags.hpp"
30 #include "utilities/ostream.hpp"
31 
32 // ciFlags
33 //
34 // This class represents klass or method flags.
35 class ciFlags {
36 private:
37   friend class ciInstanceKlass;
38   friend class ciField;
39   friend class ciMethod;
40 
41   AccessFlags _flags;
42   bool _stable;
43   bool _initialized_final_update;
44 
45   ciFlags() :_flags(0), _stable(false), _initialized_final_update(false) { }
46   ciFlags(AccessFlags flags, bool is_stable = false, bool is_initialized_final_update = false) :
47     _flags(flags), _stable(is_stable), _initialized_final_update(is_initialized_final_update) { }
48 
49 public:
50   // Java access flags
51   bool is_public               () const { return _flags.is_public();       }
52   bool is_private              () const { return _flags.is_private();      }
53   bool is_protected            () const { return _flags.is_protected();    }
54   bool is_static               () const { return _flags.is_static();       }
55   bool is_final                () const { return _flags.is_final();        }
56   bool is_synchronized         () const { return _flags.is_synchronized(); }
57   bool is_volatile             () const { return _flags.is_volatile();     }
58   bool is_transient            () const { return _flags.is_transient();    }
59   bool is_native               () const { return _flags.is_native();       }
60   bool is_interface            () const { return _flags.is_interface();    }
61   bool is_abstract             () const { return _flags.is_abstract();     }
62   bool has_vararg              () const { return _flags.has_vararg();      }
63   bool is_identity             () const { return _flags.is_identity_class(); }
64 
65   bool is_stable               () const { return _stable; }
66   // In case the current object represents a field, return true if
67   // the field is modified outside of instance initializer methods
68   // (or class/initializer methods if the field is static) and false
69   // otherwise.
70   bool has_initialized_final_update() const { return _initialized_final_update; };
71 
72   // Conversion
73   jint   as_int()                      { return _flags.as_unsigned_short(); }
74 
75   void print_klass_flags(outputStream* st = tty);
76   void print_member_flags(outputStream* st = tty);
77   void print(outputStream* st = tty);
78 };
79 
80 #endif // SHARE_CI_CIFLAGS_HPP