< prev index next >

src/hotspot/share/prims/jvmtiEnv.cpp

Print this page

2678     *source_name_ptr = (char *) jvmtiMalloc(strlen(sfncp)+1);
2679     strcpy(*source_name_ptr, sfncp);
2680   }
2681 
2682   return JVMTI_ERROR_NONE;
2683 } /* end GetSourceFileName */
2684 
2685 
2686 // k_mirror - may be primitive, this must be checked
2687 // modifiers_ptr - pre-checked for null
2688 jvmtiError
2689 JvmtiEnv::GetClassModifiers(oop k_mirror, jint* modifiers_ptr) {
2690   JavaThread* current_thread  = JavaThread::current();
2691   jint result = 0;
2692   if (!java_lang_Class::is_primitive(k_mirror)) {
2693     Klass* k = java_lang_Class::as_Klass(k_mirror);
2694     NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS);
2695     result = k->compute_modifier_flags();
2696 
2697     // Reset the deleted  ACC_SUPER bit (deleted in compute_modifier_flags()).
2698     if (k->is_super()) {
2699       result |= JVM_ACC_SUPER;
2700     }
2701   } else {
2702     result = (JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC);
2703   }
2704   *modifiers_ptr = result;
2705 
2706   return JVMTI_ERROR_NONE;
2707 } /* end GetClassModifiers */
2708 
2709 
2710 // k_mirror - may be primitive, this must be checked
2711 // method_count_ptr - pre-checked for null
2712 // methods_ptr - pre-checked for null
2713 jvmtiError
2714 JvmtiEnv::GetClassMethods(oop k_mirror, jint* method_count_ptr, jmethodID** methods_ptr) {
2715   JavaThread* current_thread  = JavaThread::current();
2716   HandleMark hm(current_thread);
2717 
2718   if (java_lang_Class::is_primitive(k_mirror)) {
2719     *method_count_ptr = 0;
2720     *methods_ptr = (jmethodID*) jvmtiMalloc(0 * sizeof(jmethodID));

2811   if (!(k->jvmti_class_status() & (JVMTI_CLASS_STATUS_PREPARED|JVMTI_CLASS_STATUS_ARRAY) )) {
2812     return JVMTI_ERROR_CLASS_NOT_PREPARED;
2813   }
2814 
2815   if (!k->is_instance_klass()) {
2816     *field_count_ptr = 0;
2817     *fields_ptr = (jfieldID*) jvmtiMalloc(0 * sizeof(jfieldID));
2818     return JVMTI_ERROR_NONE;
2819   }
2820 
2821   InstanceKlass* ik = InstanceKlass::cast(k);
2822 
2823   FilteredJavaFieldStream flds(ik);
2824 
2825   int result_count = flds.field_count();
2826 
2827   // Allocate the result and fill it in.
2828   jfieldID* result_list = (jfieldID*)jvmtiMalloc(result_count * sizeof(jfieldID));
2829   for (int i = 0; i < result_count; i++, flds.next()) {
2830     result_list[i] = jfieldIDWorkaround::to_jfieldID(ik, flds.offset(),
2831                                                      flds.access_flags().is_static());

2832   }
2833   assert(flds.done(), "just checking");
2834 
2835   // Fill in the results
2836   *field_count_ptr = result_count;
2837   *fields_ptr = result_list;
2838 
2839   return JVMTI_ERROR_NONE;
2840 } /* end GetClassFields */
2841 
2842 
2843 // k_mirror - may be primitive, this must be checked
2844 // interface_count_ptr - pre-checked for null
2845 // interfaces_ptr - pre-checked for null
2846 jvmtiError
2847 JvmtiEnv::GetImplementedInterfaces(oop k_mirror, jint* interface_count_ptr, jclass** interfaces_ptr) {
2848   {
2849     if (java_lang_Class::is_primitive(k_mirror)) {
2850       *interface_count_ptr = 0;
2851       *interfaces_ptr = (jclass*) jvmtiMalloc(0 * sizeof(jclass));
2852       return JVMTI_ERROR_NONE;
2853     }
2854     JavaThread* current_thread = JavaThread::current();
2855     HandleMark hm(current_thread);
2856     Klass* k = java_lang_Class::as_Klass(k_mirror);
2857     NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS);
2858 
2859     // Return CLASS_NOT_PREPARED error as per JVMTI spec.
2860     if (!(k->jvmti_class_status() & (JVMTI_CLASS_STATUS_PREPARED|JVMTI_CLASS_STATUS_ARRAY) ))
2861       return JVMTI_ERROR_CLASS_NOT_PREPARED;
2862 
2863     if (!k->is_instance_klass()) {
2864       *interface_count_ptr = 0;
2865       *interfaces_ptr = (jclass*) jvmtiMalloc(0 * sizeof(jclass));
2866       return JVMTI_ERROR_NONE;
2867     }
2868 
2869     Array<InstanceKlass*>* interface_list = InstanceKlass::cast(k)->local_interfaces();
2870     const int result_length = (interface_list == nullptr ? 0 : interface_list->length());

2871     jclass* result_list = (jclass*) jvmtiMalloc(result_length * sizeof(jclass));
2872     for (int i_index = 0; i_index < result_length; i_index += 1) {
2873       InstanceKlass* klass_at = interface_list->at(i_index);
2874       assert(klass_at->is_klass(), "interfaces must be Klass*s");
2875       assert(klass_at->is_interface(), "interfaces must be interfaces");
2876       oop mirror_at = klass_at->java_mirror();
2877       Handle handle_at = Handle(current_thread, mirror_at);
2878       result_list[i_index] = (jclass) jni_reference(handle_at);
2879     }
2880     *interface_count_ptr = result_length;
2881     *interfaces_ptr = result_list;
2882   }
2883 
2884   return JVMTI_ERROR_NONE;
2885 } /* end GetImplementedInterfaces */
2886 
2887 
2888 // k_mirror - may be primitive, this must be checked
2889 // minor_version_ptr - pre-checked for null
2890 // major_version_ptr - pre-checked for null

2678     *source_name_ptr = (char *) jvmtiMalloc(strlen(sfncp)+1);
2679     strcpy(*source_name_ptr, sfncp);
2680   }
2681 
2682   return JVMTI_ERROR_NONE;
2683 } /* end GetSourceFileName */
2684 
2685 
2686 // k_mirror - may be primitive, this must be checked
2687 // modifiers_ptr - pre-checked for null
2688 jvmtiError
2689 JvmtiEnv::GetClassModifiers(oop k_mirror, jint* modifiers_ptr) {
2690   JavaThread* current_thread  = JavaThread::current();
2691   jint result = 0;
2692   if (!java_lang_Class::is_primitive(k_mirror)) {
2693     Klass* k = java_lang_Class::as_Klass(k_mirror);
2694     NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS);
2695     result = k->compute_modifier_flags();
2696 
2697     // Reset the deleted  ACC_SUPER bit (deleted in compute_modifier_flags()).
2698     // if (k->is_super()) {
2699     //   result |= JVM_ACC_SUPER;
2700     // }
2701   } else {
2702     result = (JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC);
2703   }
2704   *modifiers_ptr = result;
2705 
2706   return JVMTI_ERROR_NONE;
2707 } /* end GetClassModifiers */
2708 
2709 
2710 // k_mirror - may be primitive, this must be checked
2711 // method_count_ptr - pre-checked for null
2712 // methods_ptr - pre-checked for null
2713 jvmtiError
2714 JvmtiEnv::GetClassMethods(oop k_mirror, jint* method_count_ptr, jmethodID** methods_ptr) {
2715   JavaThread* current_thread  = JavaThread::current();
2716   HandleMark hm(current_thread);
2717 
2718   if (java_lang_Class::is_primitive(k_mirror)) {
2719     *method_count_ptr = 0;
2720     *methods_ptr = (jmethodID*) jvmtiMalloc(0 * sizeof(jmethodID));

2811   if (!(k->jvmti_class_status() & (JVMTI_CLASS_STATUS_PREPARED|JVMTI_CLASS_STATUS_ARRAY) )) {
2812     return JVMTI_ERROR_CLASS_NOT_PREPARED;
2813   }
2814 
2815   if (!k->is_instance_klass()) {
2816     *field_count_ptr = 0;
2817     *fields_ptr = (jfieldID*) jvmtiMalloc(0 * sizeof(jfieldID));
2818     return JVMTI_ERROR_NONE;
2819   }
2820 
2821   InstanceKlass* ik = InstanceKlass::cast(k);
2822 
2823   FilteredJavaFieldStream flds(ik);
2824 
2825   int result_count = flds.field_count();
2826 
2827   // Allocate the result and fill it in.
2828   jfieldID* result_list = (jfieldID*)jvmtiMalloc(result_count * sizeof(jfieldID));
2829   for (int i = 0; i < result_count; i++, flds.next()) {
2830     result_list[i] = jfieldIDWorkaround::to_jfieldID(ik, flds.offset(),
2831                                                      flds.access_flags().is_static(),
2832                                                      flds.field_descriptor().is_flat());
2833   }
2834   assert(flds.done(), "just checking");
2835 
2836   // Fill in the results
2837   *field_count_ptr = result_count;
2838   *fields_ptr = result_list;
2839 
2840   return JVMTI_ERROR_NONE;
2841 } /* end GetClassFields */
2842 
2843 
2844 // k_mirror - may be primitive, this must be checked
2845 // interface_count_ptr - pre-checked for null
2846 // interfaces_ptr - pre-checked for null
2847 jvmtiError
2848 JvmtiEnv::GetImplementedInterfaces(oop k_mirror, jint* interface_count_ptr, jclass** interfaces_ptr) {
2849   {
2850     if (java_lang_Class::is_primitive(k_mirror)) {
2851       *interface_count_ptr = 0;
2852       *interfaces_ptr = (jclass*) jvmtiMalloc(0 * sizeof(jclass));
2853       return JVMTI_ERROR_NONE;
2854     }
2855     JavaThread* current_thread = JavaThread::current();
2856     HandleMark hm(current_thread);
2857     Klass* k = java_lang_Class::as_Klass(k_mirror);
2858     NULL_CHECK(k, JVMTI_ERROR_INVALID_CLASS);
2859 
2860     // Return CLASS_NOT_PREPARED error as per JVMTI spec.
2861     if (!(k->jvmti_class_status() & (JVMTI_CLASS_STATUS_PREPARED|JVMTI_CLASS_STATUS_ARRAY) ))
2862       return JVMTI_ERROR_CLASS_NOT_PREPARED;
2863 
2864     if (!k->is_instance_klass()) {
2865       *interface_count_ptr = 0;
2866       *interfaces_ptr = (jclass*) jvmtiMalloc(0 * sizeof(jclass));
2867       return JVMTI_ERROR_NONE;
2868     }
2869 
2870     InstanceKlass* ik = InstanceKlass::cast(k);
2871     Array<InstanceKlass*>* interface_list = ik->local_interfaces();
2872     int result_length = (interface_list == nullptr ? 0 : interface_list->length());
2873     jclass* result_list = (jclass*) jvmtiMalloc(result_length * sizeof(jclass));
2874     for (int i_index = 0; i_index < result_length; i_index += 1) {
2875       InstanceKlass* klass_at = interface_list->at(i_index);
2876       assert(klass_at->is_klass(), "interfaces must be Klass*s");
2877       assert(klass_at->is_interface(), "interfaces must be interfaces");
2878       oop mirror_at = klass_at->java_mirror();
2879       Handle handle_at = Handle(current_thread, mirror_at);
2880       result_list[i_index] = (jclass) jni_reference(handle_at);
2881     }
2882     *interface_count_ptr = result_length;
2883     *interfaces_ptr = result_list;
2884   }
2885 
2886   return JVMTI_ERROR_NONE;
2887 } /* end GetImplementedInterfaces */
2888 
2889 
2890 // k_mirror - may be primitive, this must be checked
2891 // minor_version_ptr - pre-checked for null
2892 // major_version_ptr - pre-checked for null
< prev index next >