src/share/vm/prims/jvmtiEnv.cpp

Print this page


   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  *


2524     jclass result_jnihandle = (jclass) jni_reference(result_handle);
2525     *classloader_ptr = result_jnihandle;
2526   }
2527   return JVMTI_ERROR_NONE;
2528 } /* end GetClassLoader */
2529 
2530 
2531 // k_mirror - may be primitive, this must be checked
2532 // source_debug_extension_ptr - pre-checked for NULL
2533 jvmtiError
2534 JvmtiEnv::GetSourceDebugExtension(oop k_mirror, char** source_debug_extension_ptr) {
2535   {
2536     if (java_lang_Class::is_primitive(k_mirror)) {
2537       return JVMTI_ERROR_ABSENT_INFORMATION;
2538     }
2539     klassOop k = java_lang_Class::as_klassOop(k_mirror);
2540     NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS);
2541     if (!Klass::cast(k)->oop_is_instance()) {
2542       return JVMTI_ERROR_ABSENT_INFORMATION;
2543     }
2544     Symbol* sdeOop = instanceKlass::cast(k)->source_debug_extension();
2545     NULL_CHECK(sdeOop, JVMTI_ERROR_ABSENT_INFORMATION);
2546 
2547     {
2548       JavaThread* current_thread  = JavaThread::current();
2549       ResourceMark rm(current_thread);
2550       const char* sdecp = (const char*) sdeOop->as_C_string();
2551       *source_debug_extension_ptr = (char *) jvmtiMalloc(strlen(sdecp)+1);
2552       strcpy(*source_debug_extension_ptr, sdecp);
2553     }
2554   }
2555 
2556   return JVMTI_ERROR_NONE;
2557 } /* end GetSourceDebugExtension */
2558 
2559   //
2560   // Object functions
2561   //
2562 
2563 // hash_code_ptr - pre-checked for NULL
2564 jvmtiError
2565 JvmtiEnv::GetObjectHashCode(jobject object, jint* hash_code_ptr) {
2566   oop mirror = JNIHandles::resolve_external_guard(object);
2567   NULL_CHECK(mirror, JVMTI_ERROR_INVALID_OBJECT);
2568   NULL_CHECK(hash_code_ptr, JVMTI_ERROR_NULL_POINTER);
2569 
2570   {
2571     jint result = (jint) mirror->identity_hash();
2572     *hash_code_ptr = result;


   1 /*
   2  * Copyright (c) 2003, 2012, 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  *


2524     jclass result_jnihandle = (jclass) jni_reference(result_handle);
2525     *classloader_ptr = result_jnihandle;
2526   }
2527   return JVMTI_ERROR_NONE;
2528 } /* end GetClassLoader */
2529 
2530 
2531 // k_mirror - may be primitive, this must be checked
2532 // source_debug_extension_ptr - pre-checked for NULL
2533 jvmtiError
2534 JvmtiEnv::GetSourceDebugExtension(oop k_mirror, char** source_debug_extension_ptr) {
2535   {
2536     if (java_lang_Class::is_primitive(k_mirror)) {
2537       return JVMTI_ERROR_ABSENT_INFORMATION;
2538     }
2539     klassOop k = java_lang_Class::as_klassOop(k_mirror);
2540     NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS);
2541     if (!Klass::cast(k)->oop_is_instance()) {
2542       return JVMTI_ERROR_ABSENT_INFORMATION;
2543     }
2544     char* sde = instanceKlass::cast(k)->source_debug_extension();
2545     NULL_CHECK(sde, JVMTI_ERROR_ABSENT_INFORMATION);
2546 
2547     {
2548       *source_debug_extension_ptr = (char *) jvmtiMalloc(strlen(sde)+1);
2549       strcpy(*source_debug_extension_ptr, sde);



2550     }
2551   }
2552 
2553   return JVMTI_ERROR_NONE;
2554 } /* end GetSourceDebugExtension */
2555 
2556   //
2557   // Object functions
2558   //
2559 
2560 // hash_code_ptr - pre-checked for NULL
2561 jvmtiError
2562 JvmtiEnv::GetObjectHashCode(jobject object, jint* hash_code_ptr) {
2563   oop mirror = JNIHandles::resolve_external_guard(object);
2564   NULL_CHECK(mirror, JVMTI_ERROR_INVALID_OBJECT);
2565   NULL_CHECK(hash_code_ptr, JVMTI_ERROR_NULL_POINTER);
2566 
2567   {
2568     jint result = (jint) mirror->identity_hash();
2569     *hash_code_ptr = result;