1
|
1 |
/*
|
|
2 |
* Copyright 2003 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 |
//
|
|
26 |
// Serviceability utility functions.
|
|
27 |
// (Shared by MM and JVMTI).
|
|
28 |
//
|
|
29 |
class ServiceUtil : public AllStatic {
|
|
30 |
public:
|
|
31 |
|
|
32 |
// Return true if oop represents an object that is "visible"
|
|
33 |
// to the java world.
|
|
34 |
static inline bool visible_oop(oop o) {
|
|
35 |
// the sentinel for deleted handles isn't visible
|
|
36 |
if (o == JNIHandles::deleted_handle()) {
|
|
37 |
return false;
|
|
38 |
}
|
|
39 |
|
|
40 |
// ignore KlassKlass
|
|
41 |
if (o->is_klass()) {
|
|
42 |
return false;
|
|
43 |
}
|
|
44 |
|
|
45 |
// instance
|
|
46 |
if (o->is_instance()) {
|
|
47 |
// instance objects are visible
|
4571
|
48 |
if (o->klass() != SystemDictionary::Class_klass()) {
|
1
|
49 |
return true;
|
|
50 |
}
|
|
51 |
if (java_lang_Class::is_primitive(o)) {
|
|
52 |
return true;
|
|
53 |
}
|
|
54 |
// java.lang.Classes are visible
|
|
55 |
o = java_lang_Class::as_klassOop(o);
|
|
56 |
if (o->is_klass()) {
|
|
57 |
// if it's a class for an object, an object array, or
|
|
58 |
// primitive (type) array then it's visible.
|
|
59 |
klassOop klass = (klassOop)o;
|
|
60 |
if (Klass::cast(klass)->oop_is_instance()) {
|
|
61 |
return true;
|
|
62 |
}
|
|
63 |
if (Klass::cast(klass)->oop_is_objArray()) {
|
|
64 |
return true;
|
|
65 |
}
|
|
66 |
if (Klass::cast(klass)->oop_is_typeArray()) {
|
|
67 |
return true;
|
|
68 |
}
|
|
69 |
}
|
|
70 |
return false;
|
|
71 |
}
|
|
72 |
// object arrays are visible if they aren't system object arrays
|
|
73 |
if (o->is_objArray()) {
|
|
74 |
objArrayOop array = (objArrayOop)o;
|
|
75 |
if (array->klass() != Universe::systemObjArrayKlassObj()) {
|
|
76 |
return true;
|
|
77 |
} else {
|
|
78 |
return false;
|
|
79 |
}
|
|
80 |
}
|
|
81 |
// type arrays are visible
|
|
82 |
if (o->is_typeArray()) {
|
|
83 |
return true;
|
|
84 |
}
|
|
85 |
// everything else (methodOops, ...) aren't visible
|
|
86 |
return false;
|
|
87 |
}; // end of visible_oop()
|
|
88 |
|
|
89 |
};
|