< prev index next >

test/hotspot/jtreg/serviceability/jvmti/GetOwnedMonitorInfo/libGetOwnedMonitorInfoTest.c

Print this page

  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  */
 23 
 24 #include <stdio.h>

 25 #include <string.h>
 26 #include "jvmti.h"
 27 #include "jni.h"
 28 
 29 #ifdef __cplusplus
 30 extern "C" {
 31 #endif
 32 
 33 #ifndef JNI_ENV_ARG
 34 
 35 #ifdef __cplusplus
 36 #define JNI_ENV_ARG(x, y) y
 37 #define JNI_ENV_PTR(x) x
 38 #else
 39 #define JNI_ENV_ARG(x,y) x, y
 40 #define JNI_ENV_PTR(x) (*x)
 41 #endif
 42 
 43 #endif
 44 

247     }
248 
249     err = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
250                                              JVMTI_EVENT_MONITOR_CONTENDED_ENTER, NULL);
251     if (err != JVMTI_ERROR_NONE) {
252         ShowErrorMessage(jvmti, err,
253                          "Agent_OnLoad: error in JVMTI SetEventNotificationMode #1");
254         return JNI_ERR;
255     }
256     err = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
257                                              JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, NULL);
258     if (err != JVMTI_ERROR_NONE) {
259         ShowErrorMessage(jvmti, err,
260                          "Agent_OnLoad: error in JVMTI SetEventNotificationMode #2");
261         return JNI_ERR;
262     }
263     printf("Agent_OnLoad finished\n");
264     return JNI_OK;
265 }
266 








267 JNIEXPORT jint JNICALL
268 Java_GetOwnedMonitorInfoTest_check(JNIEnv *env, jclass cls) {
269     return status;
270 }
271 
272 JNIEXPORT jboolean JNICALL
273 Java_GetOwnedMonitorInfoTest_hasEventPosted(JNIEnv *env, jclass cls) {
274     return event_has_posted;
275 }
276 
277 #ifdef __cplusplus
278 }
279 #endif

  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  */
 23 
 24 #include <stdio.h>
 25 #include <stdlib.h>
 26 #include <string.h>
 27 #include "jvmti.h"
 28 #include "jni.h"
 29 
 30 #ifdef __cplusplus
 31 extern "C" {
 32 #endif
 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 

248     }
249 
250     err = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
251                                              JVMTI_EVENT_MONITOR_CONTENDED_ENTER, NULL);
252     if (err != JVMTI_ERROR_NONE) {
253         ShowErrorMessage(jvmti, err,
254                          "Agent_OnLoad: error in JVMTI SetEventNotificationMode #1");
255         return JNI_ERR;
256     }
257     err = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
258                                              JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, NULL);
259     if (err != JVMTI_ERROR_NONE) {
260         ShowErrorMessage(jvmti, err,
261                          "Agent_OnLoad: error in JVMTI SetEventNotificationMode #2");
262         return JNI_ERR;
263     }
264     printf("Agent_OnLoad finished\n");
265     return JNI_OK;
266 }
267 
268 JNIEXPORT void JNICALL
269 Java_GetOwnedMonitorInfoTest_jniMonitorEnter(JNIEnv* env, jclass cls, jobject obj) {
270     if ((*env)->MonitorEnter(env, obj) != 0) {
271         fprintf(stderr, "MonitorEnter failed");
272         exit(-1);
273     }
274 }
275 
276 JNIEXPORT jint JNICALL
277 Java_GetOwnedMonitorInfoTest_check(JNIEnv *env, jclass cls) {
278     return status;
279 }
280 
281 JNIEXPORT jboolean JNICALL
282 Java_GetOwnedMonitorInfoTest_hasEventPosted(JNIEnv *env, jclass cls) {
283     return event_has_posted;
284 }
285 
286 #ifdef __cplusplus
287 }
288 #endif
< prev index next >