1
|
1 |
/*
|
|
2 |
* Copyright 1999-2007 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 |
* have any questions.
|
|
22 |
*
|
|
23 |
*/
|
|
24 |
|
|
25 |
// ciKlass
|
|
26 |
//
|
|
27 |
// This class and its subclasses represent klassOops in the
|
|
28 |
// HotSpot virtual machine. In the vm, each klassOop contains an
|
|
29 |
// embedded Klass object. ciKlass is subclassed to explicitly
|
|
30 |
// represent the kind of Klass embedded in the klassOop. For
|
|
31 |
// example, a klassOop with an embedded objArrayKlass object is
|
|
32 |
// represented in the ciObject hierarchy by the class
|
|
33 |
// ciObjArrayKlass.
|
|
34 |
class ciKlass : public ciType {
|
|
35 |
CI_PACKAGE_ACCESS
|
|
36 |
friend class ciEnv;
|
|
37 |
friend class ciField;
|
|
38 |
friend class ciMethod;
|
|
39 |
friend class ciObjArrayKlass;
|
|
40 |
|
|
41 |
private:
|
|
42 |
ciSymbol* _name;
|
|
43 |
jint _layout_helper;
|
|
44 |
|
|
45 |
protected:
|
|
46 |
ciKlass(KlassHandle k_h, ciSymbol* name);
|
|
47 |
ciKlass(ciSymbol* name, ciKlass* klass);
|
|
48 |
|
|
49 |
klassOop get_klassOop() const {
|
|
50 |
klassOop k = (klassOop)get_oop();
|
|
51 |
assert(k != NULL, "illegal use of unloaded klass");
|
|
52 |
return k;
|
|
53 |
}
|
|
54 |
|
|
55 |
Klass* get_Klass() const { return get_klassOop()->klass_part(); }
|
|
56 |
|
|
57 |
// Certain subklasses have an associated class loader.
|
|
58 |
virtual oop loader() { return NULL; }
|
|
59 |
virtual jobject loader_handle() { return NULL; }
|
|
60 |
|
|
61 |
virtual oop protection_domain() { return NULL; }
|
|
62 |
virtual jobject protection_domain_handle() { return NULL; }
|
|
63 |
|
|
64 |
const char* type_string() { return "ciKlass"; }
|
|
65 |
|
|
66 |
void print_impl(outputStream* st);
|
|
67 |
|
|
68 |
public:
|
|
69 |
ciKlass(KlassHandle k_h);
|
|
70 |
|
|
71 |
// What is the name of this klass?
|
|
72 |
ciSymbol* name() { return _name; }
|
|
73 |
|
|
74 |
// What is its layout helper value?
|
|
75 |
jint layout_helper() { return _layout_helper; }
|
|
76 |
|
|
77 |
bool is_subtype_of(ciKlass* klass);
|
|
78 |
bool is_subclass_of(ciKlass* klass);
|
|
79 |
juint super_depth();
|
|
80 |
juint super_check_offset();
|
|
81 |
ciKlass* super_of_depth(juint i);
|
|
82 |
bool can_be_primary_super();
|
|
83 |
static juint primary_super_limit() { return Klass::primary_super_limit(); }
|
|
84 |
|
|
85 |
// Get the shared parent of two klasses.
|
|
86 |
ciKlass* least_common_ancestor(ciKlass* k);
|
|
87 |
|
|
88 |
virtual bool is_interface() {
|
|
89 |
return false;
|
|
90 |
}
|
|
91 |
|
|
92 |
virtual bool is_abstract() {
|
|
93 |
return false;
|
|
94 |
}
|
|
95 |
|
|
96 |
// Does this type (array, class, interface) have no subtypes?
|
|
97 |
virtual bool is_leaf_type() {
|
|
98 |
return false;
|
|
99 |
}
|
|
100 |
|
|
101 |
// Attempt to get a klass using this ciKlass's loader.
|
|
102 |
ciKlass* find_klass(ciSymbol* klass_name);
|
|
103 |
// Note: To find a class from its name string, use ciSymbol::make,
|
|
104 |
// but consider adding to vmSymbols.hpp instead.
|
|
105 |
|
|
106 |
// Get the instance of java.lang.Class corresponding to this klass.
|
|
107 |
ciInstance* java_mirror();
|
|
108 |
|
|
109 |
// Fetch Klass::modifier_flags.
|
|
110 |
jint modifier_flags();
|
|
111 |
|
|
112 |
// Fetch Klass::access_flags.
|
|
113 |
jint access_flags();
|
|
114 |
|
|
115 |
// What kind of ciObject is this?
|
|
116 |
bool is_klass() { return true; }
|
|
117 |
|
|
118 |
void print_name_on(outputStream* st);
|
|
119 |
};
|