throw exceptions in jni, GetLastError may have changed by the time it returns to java land
This commit is contained in:
parent
c74f93fdea
commit
1ce84e00fc
|
@ -63,8 +63,8 @@ JNIEXPORT jboolean SIGAR_JNI(win32_Service_CloseServiceHandle)
|
|||
return CloseServiceHandle((SC_HANDLE)handle);
|
||||
}
|
||||
|
||||
JNIEXPORT jint SIGAR_JNI(win32_Service_ControlService)
|
||||
(JNIEnv *, jclass, jlong handle, jint control)
|
||||
JNIEXPORT void SIGAR_JNI(win32_Service_ControlService)
|
||||
(JNIEnv *env, jclass, jlong handle, jint control)
|
||||
{
|
||||
BOOL retval;
|
||||
SERVICE_STATUS status;
|
||||
|
@ -74,11 +74,8 @@ JNIEXPORT jint SIGAR_JNI(win32_Service_ControlService)
|
|||
else {
|
||||
retval = ControlService((SC_HANDLE)handle, control, &status);
|
||||
}
|
||||
if (retval) {
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
else {
|
||||
return GetLastError();
|
||||
if (!retval) {
|
||||
win32_throw_last_error(env);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -172,9 +172,7 @@ public class Service extends Win32 {
|
|||
}
|
||||
|
||||
private void control(int ctl) throws Win32Exception {
|
||||
if (ControlService(this.service, ctl) != SUCCESS) {
|
||||
throw new Win32Exception(GetErrorMessage(ctl));
|
||||
}
|
||||
ControlService(this.service, ctl);
|
||||
}
|
||||
|
||||
private static class Waiter {
|
||||
|
@ -279,8 +277,8 @@ public class Service extends Win32 {
|
|||
String startName,
|
||||
String password) throws Win32Exception;
|
||||
|
||||
private static native int ControlService(long handle,
|
||||
int control);
|
||||
private static native void ControlService(long handle,
|
||||
int control) throws Win32Exception;
|
||||
|
||||
private static native boolean DeleteService(long handle);
|
||||
|
||||
|
|
Loading…
Reference in New Issue