1 /* 2 * Copyright 1999-2009 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 // Is this klass in the given package? 75 bool is_in_package(const char* packagename) const; 76 77 // What is its layout helper value? 78 jint layout_helper() { return _layout_helper; } 79 80 bool is_subtype_of(ciKlass* klass); 81 bool is_subclass_of(ciKlass* klass); 82 juint super_depth(); 83 juint super_check_offset(); 84 ciKlass* super_of_depth(juint i); 85 bool can_be_primary_super(); 86 static juint primary_super_limit() { return Klass::primary_super_limit(); } 87 88 // Get the shared parent of two klasses. 89 ciKlass* least_common_ancestor(ciKlass* k); 90 91 virtual bool is_interface() { 92 return false; 93 } 94 95 virtual bool is_abstract() { 96 return false; 97 } 98 99 // Does this type (array, class, interface) have no subtypes? 100 virtual bool is_leaf_type() { 101 return false; 102 } 103 104 // Attempt to get a klass using this ciKlass's loader. 105 ciKlass* find_klass(ciSymbol* klass_name); 106 // Note: To find a class from its name string, use ciSymbol::make, 107 // but consider adding to vmSymbols.hpp instead. 108 109 // Get the instance of java.lang.Class corresponding to this klass. 110 ciInstance* java_mirror(); 111 112 // Fetch Klass::modifier_flags. 113 jint modifier_flags(); 114 115 // Fetch Klass::access_flags. 116 jint access_flags(); 117 118 // What kind of ciObject is this? 119 bool is_klass() { return true; } 120 121 void print_name_on(outputStream* st); 122 };