test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass011/redefclass011.cpp
equal
deleted
inserted
replaced
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 |
|
33 |
31 |
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 static jvmtiEnv *jvmti = NULL; |
36 static jvmtiEnv *jvmti = NULL; |
68 |
55 |
69 if (options != NULL && strcmp(options, "printdump") == 0) { |
56 if (options != NULL && strcmp(options, "printdump") == 0) { |
70 printdump = JNI_TRUE; |
57 printdump = JNI_TRUE; |
71 } |
58 } |
72 |
59 |
73 res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti), |
60 res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); |
74 JVMTI_VERSION_1_1); |
|
75 if (res != JNI_OK || jvmti == NULL) { |
61 if (res != JNI_OK || jvmti == NULL) { |
76 printf("Wrong result of a valid call to GetEnv!\n"); |
62 printf("Wrong result of a valid call to GetEnv!\n"); |
77 return JNI_ERR; |
63 return JNI_ERR; |
78 } |
64 } |
79 |
65 |
115 printf("JVMTI client was not properly loaded!\n"); |
101 printf("JVMTI client was not properly loaded!\n"); |
116 return STATUS_FAILED; |
102 return STATUS_FAILED; |
117 } |
103 } |
118 |
104 |
119 classDef.klass = NULL; |
105 classDef.klass = NULL; |
120 classDef.class_byte_count = |
106 classDef.class_byte_count = env->GetArrayLength(bytes); |
121 JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG(env, bytes)); |
107 classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(bytes, NULL); |
122 classDef.class_bytes = (unsigned char *) |
|
123 JNI_ENV_PTR(env)->GetByteArrayElements(JNI_ENV_ARG(env, bytes), NULL); |
|
124 |
108 |
125 if (printdump == JNI_TRUE) { |
109 if (printdump == JNI_TRUE) { |
126 printf(">>> invalid class check ...\n"); |
110 printf(">>> invalid class check ...\n"); |
127 } |
111 } |
128 err = jvmti->RedefineClasses(1, &classDef); |
112 err = jvmti->RedefineClasses(1, &classDef); |
140 } |
124 } |
141 |
125 |
142 return result; |
126 return result; |
143 } |
127 } |
144 |
128 |
145 #ifdef __cplusplus |
|
146 } |
129 } |
147 #endif |
|