2114 char tchar = type2char(java_lang_Class::primitive_type(k_mirror)); |
2114 char tchar = type2char(java_lang_Class::primitive_type(k_mirror)); |
2115 result = (char*) jvmtiMalloc(2); |
2115 result = (char*) jvmtiMalloc(2); |
2116 result[0] = tchar; |
2116 result[0] = tchar; |
2117 result[1] = '\0'; |
2117 result[1] = '\0'; |
2118 } else { |
2118 } else { |
2119 const char* class_sig = Klass::cast(k)->signature_name(); |
2119 const char* class_sig = k->signature_name(); |
2120 result = (char *) jvmtiMalloc(strlen(class_sig)+1); |
2120 result = (char *) jvmtiMalloc(strlen(class_sig)+1); |
2121 strcpy(result, class_sig); |
2121 strcpy(result, class_sig); |
2122 } |
2122 } |
2123 *signature_ptr = result; |
2123 *signature_ptr = result; |
2124 } |
2124 } |
2125 if (generic_ptr != NULL) { |
2125 if (generic_ptr != NULL) { |
2126 *generic_ptr = NULL; |
2126 *generic_ptr = NULL; |
2127 if (!isPrimitive && Klass::cast(k)->oop_is_instance()) { |
2127 if (!isPrimitive && k->oop_is_instance()) { |
2128 Symbol* soo = InstanceKlass::cast(k)->generic_signature(); |
2128 Symbol* soo = InstanceKlass::cast(k)->generic_signature(); |
2129 if (soo != NULL) { |
2129 if (soo != NULL) { |
2130 const char *gen_sig = soo->as_C_string(); |
2130 const char *gen_sig = soo->as_C_string(); |
2131 if (gen_sig != NULL) { |
2131 if (gen_sig != NULL) { |
2132 char* gen_result; |
2132 char* gen_result; |
2153 if (java_lang_Class::is_primitive(k_mirror)) { |
2153 if (java_lang_Class::is_primitive(k_mirror)) { |
2154 result |= JVMTI_CLASS_STATUS_PRIMITIVE; |
2154 result |= JVMTI_CLASS_STATUS_PRIMITIVE; |
2155 } else { |
2155 } else { |
2156 Klass* k = java_lang_Class::as_Klass(k_mirror); |
2156 Klass* k = java_lang_Class::as_Klass(k_mirror); |
2157 NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS); |
2157 NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS); |
2158 result = Klass::cast(k)->jvmti_class_status(); |
2158 result = k->jvmti_class_status(); |
2159 } |
2159 } |
2160 *status_ptr = result; |
2160 *status_ptr = result; |
2161 |
2161 |
2162 return JVMTI_ERROR_NONE; |
2162 return JVMTI_ERROR_NONE; |
2163 } /* end GetClassStatus */ |
2163 } /* end GetClassStatus */ |
2171 return JVMTI_ERROR_ABSENT_INFORMATION; |
2171 return JVMTI_ERROR_ABSENT_INFORMATION; |
2172 } |
2172 } |
2173 Klass* k_klass = java_lang_Class::as_Klass(k_mirror); |
2173 Klass* k_klass = java_lang_Class::as_Klass(k_mirror); |
2174 NULL_CHECK(k_klass, JVMTI_ERROR_INVALID_CLASS); |
2174 NULL_CHECK(k_klass, JVMTI_ERROR_INVALID_CLASS); |
2175 |
2175 |
2176 if (!Klass::cast(k_klass)->oop_is_instance()) { |
2176 if (!k_klass->oop_is_instance()) { |
2177 return JVMTI_ERROR_ABSENT_INFORMATION; |
2177 return JVMTI_ERROR_ABSENT_INFORMATION; |
2178 } |
2178 } |
2179 |
2179 |
2180 Symbol* sfnOop = InstanceKlass::cast(k_klass)->source_file_name(); |
2180 Symbol* sfnOop = InstanceKlass::cast(k_klass)->source_file_name(); |
2181 NULL_CHECK(sfnOop, JVMTI_ERROR_ABSENT_INFORMATION); |
2181 NULL_CHECK(sfnOop, JVMTI_ERROR_ABSENT_INFORMATION); |
2198 JavaThread* current_thread = JavaThread::current(); |
2198 JavaThread* current_thread = JavaThread::current(); |
2199 jint result = 0; |
2199 jint result = 0; |
2200 if (!java_lang_Class::is_primitive(k_mirror)) { |
2200 if (!java_lang_Class::is_primitive(k_mirror)) { |
2201 Klass* k = java_lang_Class::as_Klass(k_mirror); |
2201 Klass* k = java_lang_Class::as_Klass(k_mirror); |
2202 NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS); |
2202 NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS); |
2203 result = Klass::cast(k)->compute_modifier_flags(current_thread); |
2203 result = k->compute_modifier_flags(current_thread); |
2204 JavaThread* THREAD = current_thread; // pass to macros |
2204 JavaThread* THREAD = current_thread; // pass to macros |
2205 if (HAS_PENDING_EXCEPTION) { |
2205 if (HAS_PENDING_EXCEPTION) { |
2206 CLEAR_PENDING_EXCEPTION; |
2206 CLEAR_PENDING_EXCEPTION; |
2207 return JVMTI_ERROR_INTERNAL; |
2207 return JVMTI_ERROR_INTERNAL; |
2208 }; |
2208 }; |
2209 |
2209 |
2210 // Reset the deleted ACC_SUPER bit ( deleted in compute_modifier_flags()). |
2210 // Reset the deleted ACC_SUPER bit ( deleted in compute_modifier_flags()). |
2211 if(Klass::cast(k)->is_super()) { |
2211 if(k->is_super()) { |
2212 result |= JVM_ACC_SUPER; |
2212 result |= JVM_ACC_SUPER; |
2213 } |
2213 } |
2214 } else { |
2214 } else { |
2215 result = (JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC); |
2215 result = (JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC); |
2216 } |
2216 } |
2235 } |
2235 } |
2236 Klass* k = java_lang_Class::as_Klass(k_mirror); |
2236 Klass* k = java_lang_Class::as_Klass(k_mirror); |
2237 NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS); |
2237 NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS); |
2238 |
2238 |
2239 // Return CLASS_NOT_PREPARED error as per JVMTI spec. |
2239 // Return CLASS_NOT_PREPARED error as per JVMTI spec. |
2240 if (!(Klass::cast(k)->jvmti_class_status() & (JVMTI_CLASS_STATUS_PREPARED|JVMTI_CLASS_STATUS_ARRAY) )) { |
2240 if (!(k->jvmti_class_status() & (JVMTI_CLASS_STATUS_PREPARED|JVMTI_CLASS_STATUS_ARRAY) )) { |
2241 return JVMTI_ERROR_CLASS_NOT_PREPARED; |
2241 return JVMTI_ERROR_CLASS_NOT_PREPARED; |
2242 } |
2242 } |
2243 |
2243 |
2244 if (!Klass::cast(k)->oop_is_instance()) { |
2244 if (!k->oop_is_instance()) { |
2245 *method_count_ptr = 0; |
2245 *method_count_ptr = 0; |
2246 *methods_ptr = (jmethodID*) jvmtiMalloc(0 * sizeof(jmethodID)); |
2246 *methods_ptr = (jmethodID*) jvmtiMalloc(0 * sizeof(jmethodID)); |
2247 return JVMTI_ERROR_NONE; |
2247 return JVMTI_ERROR_NONE; |
2248 } |
2248 } |
2249 instanceKlassHandle instanceK_h(current_thread, k); |
2249 instanceKlassHandle instanceK_h(current_thread, k); |
2291 HandleMark hm(current_thread); |
2291 HandleMark hm(current_thread); |
2292 Klass* k = java_lang_Class::as_Klass(k_mirror); |
2292 Klass* k = java_lang_Class::as_Klass(k_mirror); |
2293 NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS); |
2293 NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS); |
2294 |
2294 |
2295 // Return CLASS_NOT_PREPARED error as per JVMTI spec. |
2295 // Return CLASS_NOT_PREPARED error as per JVMTI spec. |
2296 if (!(Klass::cast(k)->jvmti_class_status() & (JVMTI_CLASS_STATUS_PREPARED|JVMTI_CLASS_STATUS_ARRAY) )) { |
2296 if (!(k->jvmti_class_status() & (JVMTI_CLASS_STATUS_PREPARED|JVMTI_CLASS_STATUS_ARRAY) )) { |
2297 return JVMTI_ERROR_CLASS_NOT_PREPARED; |
2297 return JVMTI_ERROR_CLASS_NOT_PREPARED; |
2298 } |
2298 } |
2299 |
2299 |
2300 if (!Klass::cast(k)->oop_is_instance()) { |
2300 if (!k->oop_is_instance()) { |
2301 *field_count_ptr = 0; |
2301 *field_count_ptr = 0; |
2302 *fields_ptr = (jfieldID*) jvmtiMalloc(0 * sizeof(jfieldID)); |
2302 *fields_ptr = (jfieldID*) jvmtiMalloc(0 * sizeof(jfieldID)); |
2303 return JVMTI_ERROR_NONE; |
2303 return JVMTI_ERROR_NONE; |
2304 } |
2304 } |
2305 |
2305 |
2346 HandleMark hm(current_thread); |
2346 HandleMark hm(current_thread); |
2347 Klass* k = java_lang_Class::as_Klass(k_mirror); |
2347 Klass* k = java_lang_Class::as_Klass(k_mirror); |
2348 NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS); |
2348 NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS); |
2349 |
2349 |
2350 // Return CLASS_NOT_PREPARED error as per JVMTI spec. |
2350 // Return CLASS_NOT_PREPARED error as per JVMTI spec. |
2351 if (!(Klass::cast(k)->jvmti_class_status() & (JVMTI_CLASS_STATUS_PREPARED|JVMTI_CLASS_STATUS_ARRAY) )) |
2351 if (!(k->jvmti_class_status() & (JVMTI_CLASS_STATUS_PREPARED|JVMTI_CLASS_STATUS_ARRAY) )) |
2352 return JVMTI_ERROR_CLASS_NOT_PREPARED; |
2352 return JVMTI_ERROR_CLASS_NOT_PREPARED; |
2353 |
2353 |
2354 if (!Klass::cast(k)->oop_is_instance()) { |
2354 if (!k->oop_is_instance()) { |
2355 *interface_count_ptr = 0; |
2355 *interface_count_ptr = 0; |
2356 *interfaces_ptr = (jclass*) jvmtiMalloc(0 * sizeof(jclass)); |
2356 *interfaces_ptr = (jclass*) jvmtiMalloc(0 * sizeof(jclass)); |
2357 return JVMTI_ERROR_NONE; |
2357 return JVMTI_ERROR_NONE; |
2358 } |
2358 } |
2359 |
2359 |
2361 const int result_length = (interface_list == NULL ? 0 : interface_list->length()); |
2361 const int result_length = (interface_list == NULL ? 0 : interface_list->length()); |
2362 jclass* result_list = (jclass*) jvmtiMalloc(result_length * sizeof(jclass)); |
2362 jclass* result_list = (jclass*) jvmtiMalloc(result_length * sizeof(jclass)); |
2363 for (int i_index = 0; i_index < result_length; i_index += 1) { |
2363 for (int i_index = 0; i_index < result_length; i_index += 1) { |
2364 Klass* klass_at = interface_list->at(i_index); |
2364 Klass* klass_at = interface_list->at(i_index); |
2365 assert(klass_at->is_klass(), "interfaces must be Klass*s"); |
2365 assert(klass_at->is_klass(), "interfaces must be Klass*s"); |
2366 assert(Klass::cast(klass_at)->is_interface(), "interfaces must be interfaces"); |
2366 assert(klass_at->is_interface(), "interfaces must be interfaces"); |
2367 oop mirror_at = Klass::cast(klass_at)->java_mirror(); |
2367 oop mirror_at = klass_at->java_mirror(); |
2368 Handle handle_at = Handle(current_thread, mirror_at); |
2368 Handle handle_at = Handle(current_thread, mirror_at); |
2369 result_list[i_index] = (jclass) jni_reference(handle_at); |
2369 result_list[i_index] = (jclass) jni_reference(handle_at); |
2370 } |
2370 } |
2371 *interface_count_ptr = result_length; |
2371 *interface_count_ptr = result_length; |
2372 *interfaces_ptr = result_list; |
2372 *interfaces_ptr = result_list; |
2466 JvmtiEnv::IsInterface(oop k_mirror, jboolean* is_interface_ptr) { |
2466 JvmtiEnv::IsInterface(oop k_mirror, jboolean* is_interface_ptr) { |
2467 { |
2467 { |
2468 bool result = false; |
2468 bool result = false; |
2469 if (!java_lang_Class::is_primitive(k_mirror)) { |
2469 if (!java_lang_Class::is_primitive(k_mirror)) { |
2470 Klass* k = java_lang_Class::as_Klass(k_mirror); |
2470 Klass* k = java_lang_Class::as_Klass(k_mirror); |
2471 if (k != NULL && Klass::cast(k)->is_interface()) { |
2471 if (k != NULL && k->is_interface()) { |
2472 result = true; |
2472 result = true; |
2473 } |
2473 } |
2474 } |
2474 } |
2475 *is_interface_ptr = result; |
2475 *is_interface_ptr = result; |
2476 } |
2476 } |
2485 JvmtiEnv::IsArrayClass(oop k_mirror, jboolean* is_array_class_ptr) { |
2485 JvmtiEnv::IsArrayClass(oop k_mirror, jboolean* is_array_class_ptr) { |
2486 { |
2486 { |
2487 bool result = false; |
2487 bool result = false; |
2488 if (!java_lang_Class::is_primitive(k_mirror)) { |
2488 if (!java_lang_Class::is_primitive(k_mirror)) { |
2489 Klass* k = java_lang_Class::as_Klass(k_mirror); |
2489 Klass* k = java_lang_Class::as_Klass(k_mirror); |
2490 if (k != NULL && Klass::cast(k)->oop_is_array()) { |
2490 if (k != NULL && k->oop_is_array()) { |
2491 result = true; |
2491 result = true; |
2492 } |
2492 } |
2493 } |
2493 } |
2494 *is_array_class_ptr = result; |
2494 *is_array_class_ptr = result; |
2495 } |
2495 } |
2510 JavaThread* current_thread = JavaThread::current(); |
2510 JavaThread* current_thread = JavaThread::current(); |
2511 HandleMark hm(current_thread); |
2511 HandleMark hm(current_thread); |
2512 Klass* k = java_lang_Class::as_Klass(k_mirror); |
2512 Klass* k = java_lang_Class::as_Klass(k_mirror); |
2513 NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS); |
2513 NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS); |
2514 |
2514 |
2515 oop result_oop = Klass::cast(k)->class_loader(); |
2515 oop result_oop = k->class_loader(); |
2516 if (result_oop == NULL) { |
2516 if (result_oop == NULL) { |
2517 *classloader_ptr = (jclass) jni_reference(Handle()); |
2517 *classloader_ptr = (jclass) jni_reference(Handle()); |
2518 return JVMTI_ERROR_NONE; |
2518 return JVMTI_ERROR_NONE; |
2519 } |
2519 } |
2520 Handle result_handle = Handle(current_thread, result_oop); |
2520 Handle result_handle = Handle(current_thread, result_oop); |
2533 if (java_lang_Class::is_primitive(k_mirror)) { |
2533 if (java_lang_Class::is_primitive(k_mirror)) { |
2534 return JVMTI_ERROR_ABSENT_INFORMATION; |
2534 return JVMTI_ERROR_ABSENT_INFORMATION; |
2535 } |
2535 } |
2536 Klass* k = java_lang_Class::as_Klass(k_mirror); |
2536 Klass* k = java_lang_Class::as_Klass(k_mirror); |
2537 NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS); |
2537 NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS); |
2538 if (!Klass::cast(k)->oop_is_instance()) { |
2538 if (!k->oop_is_instance()) { |
2539 return JVMTI_ERROR_ABSENT_INFORMATION; |
2539 return JVMTI_ERROR_ABSENT_INFORMATION; |
2540 } |
2540 } |
2541 char* sde = InstanceKlass::cast(k)->source_debug_extension(); |
2541 char* sde = InstanceKlass::cast(k)->source_debug_extension(); |
2542 NULL_CHECK(sde, JVMTI_ERROR_ABSENT_INFORMATION); |
2542 NULL_CHECK(sde, JVMTI_ERROR_ABSENT_INFORMATION); |
2543 |
2543 |