-
Bug
-
Resolution: Won't Fix
-
P4
-
None
-
1.3.0
-
sparc
-
solaris_7
Name: dkC59003 Date: 11/01/99
Kestrel 1.3fcs-M (solaris) seems to not send
JVMPI_EVENT_RAW_MONITOR_CONTENDED_EXIT while running the test below.
When running on win32 version, profiling agent receives all
expected notifications.
Logs and the test sources follow:
$ java -classic -version
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-M)
Classic VM (build 1.3.0-M, green threads, nojit)
$ java -classic -Xrunenablev002 enablev002
1: started
1: after rawMonEnt()
2: started
Notification: event_type = 51, name = CPU lock
1: after sleep(500)
1: after rawMonExt()
Notification: event_type = 52, name = CPU lock
2: after rawMonEnt()
2: after sleep(500)
2: after rawMonExt()
Running the test on Windows NT:
$ java -classic -Xrunenablev002 enablev002
Notification: event_type = 51, name = System class loader lock
Notification: event_type = 53, name = System class loader lock
Notification: event_type = 51, name = System class loader lock
Notification: event_type = 52, name = System class loader lock
Notification: event_type = 53, name = System class loader lock
Notification: event_type = 51, name = System class loader lock
Notification: event_type = 52, name = System class loader lock
Notification: event_type = 53, name = System class loader lock
Notification: event_type = 52, name = System class loader lock
Notification: event_type = 51, name = System class loader lock
Notification: event_type = 53, name = System class loader lock
Notification: event_type = 52, name = System class loader lock
1: started
1: after rawMonEnt()
2: started
Notification: event_type = 51, name = CPU lock
1: after sleep(500)
Notification: event_type = 53, name = CPU lock
1: after rawMonExt()
Notification: event_type = 52, name = CPU lock
2: after rawMonEnt()
2: after sleep(500)
2: after rawMonExt()
------------------------------------------------------------- enablev002.java
public class enablev002 {
static {
try {
System.loadLibrary("enablev002");
} catch (UnsatisfiedLinkError ule) {
System.err.println("Could not load enablev002 library");
System.err.println("java.library.path:" +
System.getProperty("java.library.path"));
throw ule;
}
}
native static void rawMonEnt();
native static void rawMonExt();
public static int lock = 0;
public static void main(String[] args) {
(new Thread(new enablev002b(1))).start();
Thread thr2 = new Thread(new enablev002b(2));
thr2.start();
try {
thr2.join();
} catch (InterruptedException e) {}
}
}
class enablev002b implements Runnable {
int num;
enablev002b(int n) {
num = n;
}
public void run() {
System.out.println(num + ": started");
enablev002.lock++;
enablev002.rawMonEnt();
System.out.println(num + ": after rawMonEnt()");
while (enablev002.lock < 2) { // wait for thread #2 started
Thread.yield();
}
try {
Thread.sleep(500); // make sure #2 tried to enter monitor
} catch (InterruptedException e) {}
System.out.println(num + ": after sleep(500)");
enablev002.rawMonExt();
System.out.println(num + ": after rawMonExt()");
}
}
------------------------------------------------------------- enablev002.c
#include <stdio.h>
#include "jvmpi.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef JNI_ENV_ARG
#ifdef __cplusplus
#define JNI_ENV_ARG(x, y) y
#define JNI_ENV_PTR(x) x
#else
#define JNI_ENV_ARG(x,y) x, y
#define JNI_ENV_PTR(x) (*x)
#endif
#endif
#define check(event) res = jvmpi->EnableEvent(event, NULL); if ( res != JVMPI_SUCCESS) { printf("Can not enable event %d\n", event); }
JVMPI_Interface *jvmpi;
JVMPI_RawMonitor cpu_lock;
void eventHook(JVMPI_Event *event) {
switch(event->event_type) {
case JVMPI_EVENT_RAW_MONITOR_CONTENDED_ENTER:
case JVMPI_EVENT_RAW_MONITOR_CONTENDED_ENTERED:
case JVMPI_EVENT_RAW_MONITOR_CONTENDED_EXIT:
printf("Notification: event_type = %d, name = %s\n", event->event_type,
event->u.raw_monitor.name);
return;
default:
printf("Wrong notification, event_type = %d\n", event->event_type);
}
}
void enableEv() {
jint res;
check(JVMPI_EVENT_RAW_MONITOR_CONTENDED_ENTER);
check(JVMPI_EVENT_RAW_MONITOR_CONTENDED_ENTERED);
check(JVMPI_EVENT_RAW_MONITOR_CONTENDED_EXIT);
}
JNIEXPORT jint JNICALL JVM_OnLoad(JavaVM *jvm, char *options, void *reserved) {
jint res;
res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmpi),
JVMPI_VERSION_1);
if ( res < 0 ) {
printf("Wrong result of a valid call to GetEnv!\n");
return JNI_ERR;
}
jvmpi->NotifyEvent = eventHook;
cpu_lock = jvmpi->RawMonitorCreate("CPU lock");
enableEv();
return JNI_OK;
}
JNIEXPORT void JNICALL Java_enablev002_rawMonEnt(JNIEnv *env, jclass cls) {
jvmpi->RawMonitorEnter(cpu_lock);
}
JNIEXPORT void JNICALL Java_enablev002_rawMonExt(JNIEnv *env, jclass cls) {
jvmpi->RawMonitorExit(cpu_lock);
}
#ifdef __cplusplus
}
#endif
======================================================================
- relates to
-
JDK-4288711 JVMPI: raw monitor related events are not sent
-
- Closed
-