1 /*
2 * Copyright (c) 2003, 2010, 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 *
599 jclass
600 JvmtiEnvBase::get_jni_class_non_null(klassOop k) {
601 assert(k != NULL, "k != NULL");
602 return (jclass)jni_reference(Klass::cast(k)->java_mirror());
603 }
604
605 #ifndef JVMTI_KERNEL
606
607 //
608 // Field Information
609 //
610
611 bool
612 JvmtiEnvBase::get_field_descriptor(klassOop k, jfieldID field, fieldDescriptor* fd) {
613 if (!jfieldIDWorkaround::is_valid_jfieldID(k, field)) {
614 return false;
615 }
616 bool found = false;
617 if (jfieldIDWorkaround::is_static_jfieldID(field)) {
618 JNIid* id = jfieldIDWorkaround::from_static_jfieldID(field);
619 int offset = id->offset();
620 klassOop holder = id->holder();
621 found = instanceKlass::cast(holder)->find_local_field_from_offset(offset, true, fd);
622 } else {
623 // Non-static field. The fieldID is really the offset of the field within the object.
624 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, field);
625 found = instanceKlass::cast(k)->find_field_from_offset(offset, false, fd);
626 }
627 return found;
628 }
629
630 //
631 // Object Monitor Information
632 //
633
634 //
635 // Count the number of objects for a lightweight monitor. The hobj
636 // parameter is object that owns the monitor so this routine will
637 // count the number of times the same object was locked by frames
638 // in java_thread.
639 //
640 jint
641 JvmtiEnvBase::count_locked_objects(JavaThread *java_thread, Handle hobj) {
|
1 /*
2 * Copyright (c) 2003, 2011, 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 *
599 jclass
600 JvmtiEnvBase::get_jni_class_non_null(klassOop k) {
601 assert(k != NULL, "k != NULL");
602 return (jclass)jni_reference(Klass::cast(k)->java_mirror());
603 }
604
605 #ifndef JVMTI_KERNEL
606
607 //
608 // Field Information
609 //
610
611 bool
612 JvmtiEnvBase::get_field_descriptor(klassOop k, jfieldID field, fieldDescriptor* fd) {
613 if (!jfieldIDWorkaround::is_valid_jfieldID(k, field)) {
614 return false;
615 }
616 bool found = false;
617 if (jfieldIDWorkaround::is_static_jfieldID(field)) {
618 JNIid* id = jfieldIDWorkaround::from_static_jfieldID(field);
619 found = id->find_local_field(fd);
620 } else {
621 // Non-static field. The fieldID is really the offset of the field within the object.
622 int offset = jfieldIDWorkaround::from_instance_jfieldID(k, field);
623 found = instanceKlass::cast(k)->find_field_from_offset(offset, false, fd);
624 }
625 return found;
626 }
627
628 //
629 // Object Monitor Information
630 //
631
632 //
633 // Count the number of objects for a lightweight monitor. The hobj
634 // parameter is object that owns the monitor so this routine will
635 // count the number of times the same object was locked by frames
636 // in java_thread.
637 //
638 jint
639 JvmtiEnvBase::count_locked_objects(JavaThread *java_thread, Handle hobj) {
|