25 #include <string.h> |
25 #include <string.h> |
26 #include "jvmti.h" |
26 #include "jvmti.h" |
27 #include "agent_common.h" |
27 #include "agent_common.h" |
28 #include "JVMTITools.h" |
28 #include "JVMTITools.h" |
29 |
29 |
30 #ifdef __cplusplus |
|
31 extern "C" { |
30 extern "C" { |
32 #endif |
31 |
33 |
|
34 #ifndef JNI_ENV_ARG |
|
35 |
|
36 #ifdef __cplusplus |
|
37 #define JNI_ENV_ARG(x, y) y |
|
38 #define JNI_ENV_PTR(x) x |
|
39 #else |
|
40 #define JNI_ENV_ARG(x,y) x, y |
|
41 #define JNI_ENV_PTR(x) (*x) |
|
42 #endif |
|
43 |
|
44 #endif |
|
45 |
32 |
46 #define PASSED 0 |
33 #define PASSED 0 |
47 #define STATUS_FAILED 2 |
34 #define STATUS_FAILED 2 |
48 |
35 |
49 typedef struct { |
36 typedef struct { |
314 result = STATUS_FAILED; |
301 result = STATUS_FAILED; |
315 return; |
302 return; |
316 } |
303 } |
317 |
304 |
318 classDef.klass = klass; |
305 classDef.klass = klass; |
319 classDef.class_byte_count = |
306 classDef.class_byte_count = env->GetArrayLength(classBytes); |
320 JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG((JNIEnv *)env, classBytes)); |
|
321 classDef.class_bytes = (unsigned char *) |
307 classDef.class_bytes = (unsigned char *) |
322 JNI_ENV_PTR(env)->GetByteArrayElements(JNI_ENV_ARG((JNIEnv *)env, |
308 env->GetByteArrayElements(classBytes, NULL); |
323 classBytes), NULL); |
|
324 |
309 |
325 if (printdump == JNI_TRUE) { |
310 if (printdump == JNI_TRUE) { |
326 printf(">>> about to call RedefineClasses\n"); |
311 printf(">>> about to call RedefineClasses\n"); |
327 } |
312 } |
328 |
313 |
379 |
364 |
380 if (options != NULL && strcmp(options, "printdump") == 0) { |
365 if (options != NULL && strcmp(options, "printdump") == 0) { |
381 printdump = JNI_TRUE; |
366 printdump = JNI_TRUE; |
382 } |
367 } |
383 |
368 |
384 res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti), |
369 res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); |
385 JVMTI_VERSION_1_1); |
|
386 if (res != JNI_OK || jvmti == NULL) { |
370 if (res != JNI_OK || jvmti == NULL) { |
387 printf("Wrong result of a valid call to GetEnv!\n"); |
371 printf("Wrong result of a valid call to GetEnv!\n"); |
388 return JNI_ERR; |
372 return JNI_ERR; |
389 } |
373 } |
390 |
374 |
453 !caps.can_generate_breakpoint_events || |
437 !caps.can_generate_breakpoint_events || |
454 !caps.can_generate_frame_pop_events || |
438 !caps.can_generate_frame_pop_events || |
455 !caps.can_get_line_numbers || |
439 !caps.can_get_line_numbers || |
456 !caps.can_access_local_variables) return; |
440 !caps.can_access_local_variables) return; |
457 |
441 |
458 classBytes = (jbyteArray) JNI_ENV_PTR(env)->NewGlobalRef(JNI_ENV_ARG(env, bytes)); |
442 classBytes = (jbyteArray) env->NewGlobalRef(bytes); |
459 |
443 |
460 midRun = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, clazz), |
444 midRun = env->GetMethodID(clazz, "run", "()V"); |
461 "run", "()V"); |
|
462 if (midRun == NULL) { |
445 if (midRun == NULL) { |
463 printf("Cannot find Method ID for method run\n"); |
446 printf("Cannot find Method ID for method run\n"); |
464 result = STATUS_FAILED; |
447 result = STATUS_FAILED; |
465 return; |
448 return; |
466 } |
449 } |
467 |
450 |
468 midCheckPoint = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, clazz), |
451 midCheckPoint = env->GetMethodID(clazz, "checkPoint", "()V"); |
469 "checkPoint", "()V"); |
|
470 if (midCheckPoint == NULL) { |
452 if (midCheckPoint == NULL) { |
471 printf("Cannot find Method ID for method checkPoint\n"); |
453 printf("Cannot find Method ID for method checkPoint\n"); |
472 result = STATUS_FAILED; |
454 result = STATUS_FAILED; |
473 return; |
455 return; |
474 } |
456 } |