test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass005/redefclass005.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 |
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 STATUS_FAILED 2 |
33 #define STATUS_FAILED 2 |
47 #define PASSED 0 |
34 #define PASSED 0 |
48 |
35 |
49 static jvmtiEnv *jvmti = NULL; |
36 static jvmtiEnv *jvmti = NULL; |
117 #endif |
104 #endif |
118 jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { |
105 jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { |
119 jint res; |
106 jint res; |
120 jvmtiError err; |
107 jvmtiError err; |
121 |
108 |
122 if ((res = JNI_ENV_PTR(vm)->GetEnv(JNI_ENV_ARG(vm, (void **) &jvmti), |
109 if ((res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1)) != JNI_OK) { |
123 JVMTI_VERSION_1_1)) != JNI_OK) { |
|
124 printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res); |
110 printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res); |
125 return JNI_ERR; |
111 return JNI_ERR; |
126 } |
112 } |
127 |
113 |
128 err = jvmti->GetPotentialCapabilities(&caps); |
114 err = jvmti->GetPotentialCapabilities(&caps); |
211 result = STATUS_FAILED; |
197 result = STATUS_FAILED; |
212 } |
198 } |
213 |
199 |
214 /* filling the structure jvmtiClassDefinition */ |
200 /* filling the structure jvmtiClassDefinition */ |
215 classDef.klass = redefCls; |
201 classDef.klass = redefCls; |
216 classDef.class_byte_count = |
202 classDef.class_byte_count = env->GetArrayLength(classBytes); |
217 JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG(env, classBytes)); |
203 classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL); |
218 classDef.class_bytes = (unsigned char *) |
|
219 JNI_ENV_PTR(env)->GetByteArrayElements(JNI_ENV_ARG(env, classBytes), NULL); |
|
220 |
204 |
221 set_watch_ev(1); /* watch JVMTI events */ |
205 set_watch_ev(1); /* watch JVMTI events */ |
222 |
206 |
223 if (vrb == 1) |
207 if (vrb == 1) |
224 printf(">>>>>>>> Invoke RedefineClasses():\n\tnew class byte count=%d\n", |
208 printf(">>>>>>>> Invoke RedefineClasses():\n\tnew class byte count=%d\n", |
248 printf("Check #2 PASSED: No unexpected JVMTI events were generated by the function RedefineClasses()\n"); |
232 printf("Check #2 PASSED: No unexpected JVMTI events were generated by the function RedefineClasses()\n"); |
249 |
233 |
250 return(result); |
234 return(result); |
251 } |
235 } |
252 |
236 |
253 #ifdef __cplusplus |
237 } |
254 } |
|
255 #endif |
|