1 /*
2 * Copyright (c) 2003, 2017, 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 *
1779 // callbacks - pre-checked for NULL
1780 // user_data - NULL is a valid value, must be checked
1781 jvmtiError
1782 JvmtiEnv::FollowReferences(jint heap_filter, jclass klass, jobject initial_object, const jvmtiHeapCallbacks* callbacks, const void* user_data) {
1783 // check klass if provided
1784 Klass* k_oop = NULL;
1785 if (klass != NULL) {
1786 oop k_mirror = JNIHandles::resolve_external_guard(klass);
1787 if (k_mirror == NULL) {
1788 return JVMTI_ERROR_INVALID_CLASS;
1789 }
1790 if (java_lang_Class::is_primitive(k_mirror)) {
1791 return JVMTI_ERROR_NONE;
1792 }
1793 k_oop = java_lang_Class::as_Klass(k_mirror);
1794 if (k_oop == NULL) {
1795 return JVMTI_ERROR_INVALID_CLASS;
1796 }
1797 }
1798
1799 if (initial_object != NULL) {
1800 oop init_obj = JNIHandles::resolve_external_guard(initial_object);
1801 if (init_obj == NULL) {
1802 return JVMTI_ERROR_INVALID_OBJECT;
1803 }
1804 }
1805
1806 Thread *thread = Thread::current();
1807 HandleMark hm(thread);
1808 KlassHandle kh (thread, k_oop);
1809
1810 TraceTime t("FollowReferences", TRACETIME_LOG(Debug, jvmti, objecttagging));
1811 JvmtiTagMap::tag_map_for(this)->follow_references(heap_filter, kh, initial_object, callbacks, user_data);
1812 return JVMTI_ERROR_NONE;
1813 } /* end FollowReferences */
1814
1815
1816 // klass - NULL is a valid value, must be checked
1817 // callbacks - pre-checked for NULL
1818 // user_data - NULL is a valid value, must be checked
1819 jvmtiError
1820 JvmtiEnv::IterateThroughHeap(jint heap_filter, jclass klass, const jvmtiHeapCallbacks* callbacks, const void* user_data) {
1821 // check klass if provided
1822 Klass* k_oop = NULL;
1823 if (klass != NULL) {
1824 oop k_mirror = JNIHandles::resolve_external_guard(klass);
1825 if (k_mirror == NULL) {
|
1 /*
2 * Copyright (c) 2003, 2016, 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 *
1779 // callbacks - pre-checked for NULL
1780 // user_data - NULL is a valid value, must be checked
1781 jvmtiError
1782 JvmtiEnv::FollowReferences(jint heap_filter, jclass klass, jobject initial_object, const jvmtiHeapCallbacks* callbacks, const void* user_data) {
1783 // check klass if provided
1784 Klass* k_oop = NULL;
1785 if (klass != NULL) {
1786 oop k_mirror = JNIHandles::resolve_external_guard(klass);
1787 if (k_mirror == NULL) {
1788 return JVMTI_ERROR_INVALID_CLASS;
1789 }
1790 if (java_lang_Class::is_primitive(k_mirror)) {
1791 return JVMTI_ERROR_NONE;
1792 }
1793 k_oop = java_lang_Class::as_Klass(k_mirror);
1794 if (k_oop == NULL) {
1795 return JVMTI_ERROR_INVALID_CLASS;
1796 }
1797 }
1798
1799 Thread *thread = Thread::current();
1800 HandleMark hm(thread);
1801 KlassHandle kh (thread, k_oop);
1802
1803 TraceTime t("FollowReferences", TRACETIME_LOG(Debug, jvmti, objecttagging));
1804 JvmtiTagMap::tag_map_for(this)->follow_references(heap_filter, kh, initial_object, callbacks, user_data);
1805 return JVMTI_ERROR_NONE;
1806 } /* end FollowReferences */
1807
1808
1809 // klass - NULL is a valid value, must be checked
1810 // callbacks - pre-checked for NULL
1811 // user_data - NULL is a valid value, must be checked
1812 jvmtiError
1813 JvmtiEnv::IterateThroughHeap(jint heap_filter, jclass klass, const jvmtiHeapCallbacks* callbacks, const void* user_data) {
1814 // check klass if provided
1815 Klass* k_oop = NULL;
1816 if (klass != NULL) {
1817 oop k_mirror = JNIHandles::resolve_external_guard(klass);
1818 if (k_mirror == NULL) {
|