test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass002/redefclass002.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 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; |
62 #endif |
49 #endif |
63 jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { |
50 jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { |
64 jint res; |
51 jint res; |
65 jvmtiError err; |
52 jvmtiError err; |
66 |
53 |
67 if ((res = JNI_ENV_PTR(vm)->GetEnv(JNI_ENV_ARG(vm, (void **) &jvmti), |
54 if ((res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1)) != JNI_OK) { |
68 JVMTI_VERSION_1_1)) != JNI_OK) { |
|
69 printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res); |
55 printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res); |
70 return JNI_ERR; |
56 return JNI_ERR; |
71 } |
57 } |
72 |
58 |
73 err = jvmti->GetPotentialCapabilities(&caps); |
59 err = jvmti->GetPotentialCapabilities(&caps); |
153 return PASSED; |
139 return PASSED; |
154 } |
140 } |
155 |
141 |
156 /* filling the structure jvmtiClassDefinition */ |
142 /* filling the structure jvmtiClassDefinition */ |
157 classDef.klass = redefCls; |
143 classDef.klass = redefCls; |
158 classDef.class_byte_count = |
144 classDef.class_byte_count = env->GetArrayLength(classBytes); |
159 JNI_ENV_PTR(env)->GetArrayLength(JNI_ENV_ARG(env, classBytes)); |
145 classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL); |
160 classDef.class_bytes = (unsigned char *) |
|
161 JNI_ENV_PTR(env)->GetByteArrayElements(JNI_ENV_ARG(env, classBytes), NULL); |
|
162 |
146 |
163 if (vrb == 1) |
147 if (vrb == 1) |
164 printf(">>>>>>>> Invoke RedefineClasses():\n\tnew class byte count=%d\n", |
148 printf(">>>>>>>> Invoke RedefineClasses():\n\tnew class byte count=%d\n", |
165 classDef.class_byte_count); |
149 classDef.class_byte_count); |
166 if ((err = (jvmti->RedefineClasses(1, &classDef))) != JVMTI_ERROR_NONE) { |
150 if ((err = (jvmti->RedefineClasses(1, &classDef))) != JVMTI_ERROR_NONE) { |
173 printf("<<<<<<<< RedefineClasses() is successfully done\n"); |
157 printf("<<<<<<<< RedefineClasses() is successfully done\n"); |
174 |
158 |
175 return PASSED; |
159 return PASSED; |
176 } |
160 } |
177 |
161 |
178 #ifdef __cplusplus |
|
179 } |
162 } |
180 #endif |
|