summaryrefslogtreecommitdiff
path: root/java/class.c
blob: d4e78ae073e9161afe3cac99bf16452a819caa80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "class.h"
#include "config.h"
#include "misc.h"

void JNICALL class_prepare(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread,
                           jclass klass)
{
   jvmtiError error;
   char *class_sig = NULL, *class_name = NULL;

   if ((error = (*jvmti)->GetClassSignature (jvmti, klass, &class_sig, NULL))
       != JVMTI_ERROR_NONE)
      jvmti_error (jvmti, error, "GetClassSignature");
   else {
      if ((class_name = get_class_name_from_sig (class_sig, TRUE)) &&
          include_class (class_name)) {
         jint field_count;
         jfieldID* fields;
         if ((error = (*jvmti)->GetClassFields (jvmti, klass, &field_count,
                                                &fields))
             != JVMTI_ERROR_NONE)
            jvmti_error (jvmti, error, "GetClassFields");
         else {
            int i;
            for (i = 0; i < field_count; i++) {
               if ((error =
                    (*jvmti)->SetFieldModificationWatch (jvmti, klass,
                                                         fields[i]))
                   != JVMTI_ERROR_NONE)
                  jvmti_error (jvmti, error, "SetFieldModificationWatch");
            }
         }
      }
   }

   jvmti_dealloc (jvmti, class_sig);
   simple_free (class_name);
   
}