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 *
44 // ------------------------------------------------------------------
45 // ciKlass::ciKlass
46 //
47 // Nameless klass variant.
48 ciKlass::ciKlass(KlassHandle h_k, ciSymbol* name) : ciType(h_k) {
49 assert(get_oop()->is_klass(), "wrong type");
50 _name = name;
51 _layout_helper = Klass::_lh_neutral_value;
52 }
53
54 // ------------------------------------------------------------------
55 // ciKlass::ciKlass
56 //
57 // Unloaded klass variant.
58 ciKlass::ciKlass(ciSymbol* name, ciKlass* klass) : ciType(klass) {
59 _name = name;
60 _layout_helper = Klass::_lh_neutral_value;
61 }
62
63 // ------------------------------------------------------------------
64 // ciKlass::is_subtype_of
65 bool ciKlass::is_subtype_of(ciKlass* that) {
66 assert(is_loaded() && that->is_loaded(), "must be loaded");
67 assert(is_java_klass() && that->is_java_klass(), "must be java klasses");
68 // Check to see if the klasses are identical.
69 if (this == that) {
70 return true;
71 }
72
73 VM_ENTRY_MARK;
74 Klass* this_klass = get_Klass();
75 klassOop that_klass = that->get_klassOop();
76 bool result = this_klass->is_subtype_of(that_klass);
77
78 return result;
79 }
80
81 // ------------------------------------------------------------------
82 // ciKlass::is_subclass_of
83 bool ciKlass::is_subclass_of(ciKlass* that) {
|
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 *
44 // ------------------------------------------------------------------
45 // ciKlass::ciKlass
46 //
47 // Nameless klass variant.
48 ciKlass::ciKlass(KlassHandle h_k, ciSymbol* name) : ciType(h_k) {
49 assert(get_oop()->is_klass(), "wrong type");
50 _name = name;
51 _layout_helper = Klass::_lh_neutral_value;
52 }
53
54 // ------------------------------------------------------------------
55 // ciKlass::ciKlass
56 //
57 // Unloaded klass variant.
58 ciKlass::ciKlass(ciSymbol* name, ciKlass* klass) : ciType(klass) {
59 _name = name;
60 _layout_helper = Klass::_lh_neutral_value;
61 }
62
63 // ------------------------------------------------------------------
64 // ciKlass::is_in_package
65 //
66 // Is this klass in the given package?
67 bool ciKlass::is_in_package(const char* packagename) const {
68 ResourceMark rm;
69 Klass* klass = get_klassOop()->klass_part();
70 const char* external_name = klass->external_name();
71 size_t packagename_len = strlen(packagename);
72 return (strncmp(packagename, external_name, packagename_len) == 0);
73 }
74
75 // ------------------------------------------------------------------
76 // ciKlass::is_subtype_of
77 bool ciKlass::is_subtype_of(ciKlass* that) {
78 assert(is_loaded() && that->is_loaded(), "must be loaded");
79 assert(is_java_klass() && that->is_java_klass(), "must be java klasses");
80 // Check to see if the klasses are identical.
81 if (this == that) {
82 return true;
83 }
84
85 VM_ENTRY_MARK;
86 Klass* this_klass = get_Klass();
87 klassOop that_klass = that->get_klassOop();
88 bool result = this_klass->is_subtype_of(that_klass);
89
90 return result;
91 }
92
93 // ------------------------------------------------------------------
94 // ciKlass::is_subclass_of
95 bool ciKlass::is_subclass_of(ciKlass* that) {
|