85 /* |
85 /* |
86 * Auxiliary functions |
86 * Auxiliary functions |
87 */ |
87 */ |
88 |
88 |
89 void nsk_jvmti_aod_deallocate(jvmtiEnv *jvmti, unsigned char* mem) { |
89 void nsk_jvmti_aod_deallocate(jvmtiEnv *jvmti, unsigned char* mem) { |
90 if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(Deallocate, jvmti, mem))) { |
90 if (!NSK_JVMTI_VERIFY(jvmti->Deallocate(mem))) { |
91 NSK_COMPLAIN0("Deallocate failed\n"); |
91 NSK_COMPLAIN0("Deallocate failed\n"); |
92 |
92 |
93 /* |
93 /* |
94 * if deallocate fails it isn't critical and test execution can continue without problems, |
94 * if deallocate fails it isn't critical and test execution can continue without problems, |
95 * just call nsk_aod_internal_error to inform framework about this error |
95 * just call nsk_aod_internal_error to inform framework about this error |
99 } |
99 } |
100 |
100 |
101 int nsk_jvmti_aod_getClassName(jvmtiEnv *jvmti, jclass klass, char classNameBuffer[]) { |
101 int nsk_jvmti_aod_getClassName(jvmtiEnv *jvmti, jclass klass, char classNameBuffer[]) { |
102 char* className; |
102 char* className; |
103 |
103 |
104 if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(GetClassSignature, jvmti, klass, &className, NULL))) { |
104 if (!NSK_JVMTI_VERIFY(jvmti->GetClassSignature(klass, &className, NULL))) { |
105 NSK_COMPLAIN0("Failed to get class name\n"); |
105 NSK_COMPLAIN0("Failed to get class name\n"); |
106 classNameBuffer[0] = '\0'; |
106 classNameBuffer[0] = '\0'; |
107 return NSK_FALSE; |
107 return NSK_FALSE; |
108 } else { |
108 } else { |
109 strcpy(classNameBuffer, className); |
109 strcpy(classNameBuffer, className); |
114 } |
114 } |
115 } |
115 } |
116 |
116 |
117 int nsk_jvmti_aod_getThreadName(jvmtiEnv * jvmti, jthread thread, char threadNameBuffer[]) { |
117 int nsk_jvmti_aod_getThreadName(jvmtiEnv * jvmti, jthread thread, char threadNameBuffer[]) { |
118 jvmtiThreadInfo info; |
118 jvmtiThreadInfo info; |
119 if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(GetThreadInfo, jvmti, thread, &info))){ |
119 if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(thread, &info))){ |
120 NSK_COMPLAIN0("Failed to get thread info\n"); |
120 NSK_COMPLAIN0("Failed to get thread info\n"); |
121 threadNameBuffer[0] = '\0'; |
121 threadNameBuffer[0] = '\0'; |
122 return NSK_FALSE; |
122 return NSK_FALSE; |
123 } else { |
123 } else { |
124 strcpy(threadNameBuffer, info.name); |
124 strcpy(threadNameBuffer, info.name); |
159 jthread nsk_jvmti_aod_createThread(JNIEnv *jni) { |
159 jthread nsk_jvmti_aod_createThread(JNIEnv *jni) { |
160 jclass klass ; |
160 jclass klass ; |
161 jmethodID threadConstructor; |
161 jmethodID threadConstructor; |
162 jthread thread; |
162 jthread thread; |
163 |
163 |
|
164 if (!NSK_JNI_VERIFY(jni, (klass = jni->FindClass("java/lang/Thread")) != NULL )) { |
|
165 NSK_COMPLAIN0("Failed to get the java.lang.Thread class\n"); |
|
166 return NULL; |
|
167 } |
164 if (!NSK_JNI_VERIFY(jni, |
168 if (!NSK_JNI_VERIFY(jni, |
165 (klass = NSK_CPP_STUB2(FindClass, jni, "java/lang/Thread")) != NULL )) { |
169 (threadConstructor = jni->GetMethodID(klass, "<init>", "()V") ) != NULL )) { |
166 NSK_COMPLAIN0("Failed to get the java.lang.Thread class\n"); |
|
167 return NULL; |
|
168 } |
|
169 if (!NSK_JNI_VERIFY(jni, |
|
170 (threadConstructor = NSK_CPP_STUB4(GetMethodID, jni, klass, "<init>", "()V") ) != NULL )) { |
|
171 NSK_COMPLAIN0("Failed to get java.lang.Thread constructor\n"); |
170 NSK_COMPLAIN0("Failed to get java.lang.Thread constructor\n"); |
172 return NULL; |
171 return NULL; |
173 } |
172 } |
174 |
173 |
175 if (!NSK_JNI_VERIFY (jni, |
174 if (!NSK_JNI_VERIFY (jni, |
176 (thread = NSK_CPP_STUB4(NewObject, jni, klass, threadConstructor, NULL)) != NULL ) ) { |
175 (thread = jni->NewObject(klass, threadConstructor, NULL)) != NULL ) ) { |
177 NSK_COMPLAIN0("Failed to create Thread object\n"); |
176 NSK_COMPLAIN0("Failed to create Thread object\n"); |
178 return NULL; |
177 return NULL; |
179 } |
178 } |
180 |
179 |
181 if (!NSK_JNI_VERIFY(jni, (thread = |
180 if (!NSK_JNI_VERIFY(jni, (thread = jni->NewGlobalRef(thread)) != NULL)) { |
182 NSK_CPP_STUB2(NewGlobalRef, jni, thread)) != NULL)) { |
|
183 NSK_COMPLAIN0("Failed to create global reference\n"); |
181 NSK_COMPLAIN0("Failed to create global reference\n"); |
184 return NULL; |
182 return NULL; |
185 } |
183 } |
186 |
184 |
187 return thread; |
185 return thread; |
191 jclass klass ; |
189 jclass klass ; |
192 jmethodID threadConstructor; |
190 jmethodID threadConstructor; |
193 jthread thread; |
191 jthread thread; |
194 jstring threadNameString; |
192 jstring threadNameString; |
195 |
193 |
196 if (!NSK_JNI_VERIFY(jni, (threadNameString = |
194 if (!NSK_JNI_VERIFY(jni, (threadNameString = jni->NewStringUTF(threadName)) != NULL)) |
197 NSK_CPP_STUB2(NewStringUTF, jni, threadName)) != NULL)) |
195 return NULL; |
198 return NULL; |
196 |
199 |
197 if (!NSK_JNI_VERIFY(jni, (klass = jni->FindClass("java/lang/Thread")) != NULL )) { |
|
198 NSK_COMPLAIN0("Failed to get the java.lang.Thread class\n"); |
|
199 return NULL; |
|
200 } |
200 if (!NSK_JNI_VERIFY(jni, |
201 if (!NSK_JNI_VERIFY(jni, |
201 (klass = NSK_CPP_STUB2(FindClass, jni, "java/lang/Thread")) != NULL )) { |
202 (threadConstructor = jni->GetMethodID(klass, "<init>", "(Ljava/lang/String;)V") ) != NULL )) { |
202 NSK_COMPLAIN0("Failed to get the java.lang.Thread class\n"); |
203 NSK_COMPLAIN0("Failed to get java.lang.Thread constructor\n"); |
203 return NULL; |
204 return NULL; |
204 } |
205 } |
|
206 |
205 if (!NSK_JNI_VERIFY(jni, |
207 if (!NSK_JNI_VERIFY(jni, |
206 (threadConstructor = NSK_CPP_STUB4(GetMethodID, jni, klass, "<init>", "(Ljava/lang/String;)V") ) != NULL )) { |
208 (thread = jni->NewObject(klass, threadConstructor, threadNameString)) != NULL ) ) { |
207 NSK_COMPLAIN0("Failed to get java.lang.Thread constructor\n"); |
|
208 return NULL; |
|
209 } |
|
210 |
|
211 if (!NSK_JNI_VERIFY(jni, |
|
212 (thread = NSK_CPP_STUB4(NewObject, jni, klass, threadConstructor, threadNameString)) != NULL ) ) { |
|
213 NSK_COMPLAIN0("Failed to create Thread object\n"); |
209 NSK_COMPLAIN0("Failed to create Thread object\n"); |
214 return NULL; |
210 return NULL; |
215 } |
211 } |
216 |
212 |
217 if (!NSK_JNI_VERIFY(jni, (thread = |
213 if (!NSK_JNI_VERIFY(jni, (thread = jni->NewGlobalRef(thread)) != NULL)) { |
218 NSK_CPP_STUB2(NewGlobalRef, jni, thread)) != NULL)) { |
|
219 NSK_COMPLAIN0("Failed to create global reference\n"); |
214 NSK_COMPLAIN0("Failed to create global reference\n"); |
220 return NULL; |
215 return NULL; |
221 } |
216 } |
222 |
217 |
223 return thread; |
218 return thread; |