109
110 if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
111 return JNI_ERR;
112
113 timeout = nsk_jvmti_getWaitTime() * 60 * 1000;
114
115 if (!NSK_VERIFY((jvmti =
116 nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
117 return JNI_ERR;
118
119 if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
120 return JNI_ERR;
121
122 memset(&callbacks, 0, sizeof(callbacks));
123 callbacks.VMInit = &VMInit;
124 callbacks.ThreadStart = &ThreadStart;
125 callbacks.VMDeath = &VMDeath;
126 if (!NSK_VERIFY(nsk_jvmti_init_MA(&callbacks)))
127 return JNI_ERR;
128
129 if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
130 jvmti, JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL)))
131 return JNI_ERR;
132
133 if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
134 jvmti, JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL)))
135 return JNI_ERR;
136
137 if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
138 jvmti, JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, NULL)))
139 return JNI_ERR;
140
141 return JNI_OK;
142 }
143
144 /* ========================================================================== */
145
146 /* agent library shutdown */
147 JNIEXPORT void JNICALL
148 #ifdef STATIC_BUILD
149 Agent_OnUnload_ma03t001(JavaVM *jvm)
150 #else
151 Agent_OnUnload(JavaVM *jvm)
152 #endif
153 {
154 if (VMDeathEventsCount != VMDeathEventsExpected) {
155 NSK_COMPLAIN2("Wrong number of VM death events: %d, expected: %d\n",
156 VMDeathEventsCount, VMDeathEventsExpected);
157 exit(97);
158 }
|
109
110 if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
111 return JNI_ERR;
112
113 timeout = nsk_jvmti_getWaitTime() * 60 * 1000;
114
115 if (!NSK_VERIFY((jvmti =
116 nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
117 return JNI_ERR;
118
119 if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
120 return JNI_ERR;
121
122 memset(&callbacks, 0, sizeof(callbacks));
123 callbacks.VMInit = &VMInit;
124 callbacks.ThreadStart = &ThreadStart;
125 callbacks.VMDeath = &VMDeath;
126 if (!NSK_VERIFY(nsk_jvmti_init_MA(&callbacks)))
127 return JNI_ERR;
128
129 if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL)))
130 return JNI_ERR;
131
132 if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL)))
133 return JNI_ERR;
134
135 if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, NULL)))
136 return JNI_ERR;
137
138 return JNI_OK;
139 }
140
141 /* ========================================================================== */
142
143 /* agent library shutdown */
144 JNIEXPORT void JNICALL
145 #ifdef STATIC_BUILD
146 Agent_OnUnload_ma03t001(JavaVM *jvm)
147 #else
148 Agent_OnUnload(JavaVM *jvm)
149 #endif
150 {
151 if (VMDeathEventsCount != VMDeathEventsExpected) {
152 NSK_COMPLAIN2("Wrong number of VM death events: %d, expected: %d\n",
153 VMDeathEventsCount, VMDeathEventsExpected);
154 exit(97);
155 }
|