/*
 * Class:     com_sun_tools_jdi_SharedMemoryTransport
 * Method:    accept0
 * Signature: (J)J
 */
JNIEXPORT jlong JNICALL Java_com_sun_tools_jdi_SharedMemoryTransport_accept0
  (JNIEnv *env, jobject thisObject, jlong id)
{
    SharedMemoryConnection *connection = NULL;
    SharedMemoryTransport *transport = ID_TO_TRANSPORT(id);
    jint rc = shmemBase_accept(transport, &connection);
    if (rc != SYS_OK) {
        throwShmemException(env, "shmemBase_accept failed", rc);
    }
    return CONNECTION_TO_ID(connection);
}
예제 #2
0
/*
 * Class:     com_sun_tools_jdi_SharedMemoryTransport
 * Method:    attach0
 * Signature: (Ljava/lang/String;)J
 */
JNIEXPORT jlong JNICALL Java_com_sun_tools_jdi_SharedMemoryTransportService_attach0
  (JNIEnv *env, jobject thisObject, jstring address, jlong timeout)
{
    SharedMemoryConnection *connection = NULL;
    jint rc;
    const char *addrChars;

    addrChars = (*env)->GetStringUTFChars(env, address, NULL);
    if ((*env)->ExceptionOccurred(env)) {
        return CONNECTION_TO_ID(connection);
    } else if (addrChars == NULL) {
        throwException(env, "java/lang/InternalError", "GetStringUTFChars failed");
        return CONNECTION_TO_ID(connection);
    }

    rc = shmemBase_attach(addrChars, (long)timeout, &connection);
    if (rc != SYS_OK) {
        throwShmemException(env, "shmemBase_attach failed", rc);
    } 

    (*env)->ReleaseStringUTFChars(env, address, addrChars);

    return CONNECTION_TO_ID(connection);
}
예제 #3
0
/*
 * Class:     com_sun_tools_jdi_SharedMemoryTransport
 * Method:    accept0
 * Signature: (J)J
 */
JNIEXPORT jlong JNICALL Java_com_sun_tools_jdi_SharedMemoryTransportService_accept0
  (JNIEnv *env, jobject thisObject, jlong id, jlong timeout)
{
    SharedMemoryConnection *connection = NULL;
    SharedMemoryTransport *transport = ID_TO_TRANSPORT(id);
    jint rc;

    rc = shmemBase_accept(transport, (long)timeout, &connection);
    if (rc != SYS_OK) {
	if (rc == SYS_TIMEOUT) {
	    throwException(env, "com/sun/jdi/connect/spi/TransportTimeoutException", 
		"Timed out waiting for target VM to connect");
	} else {
	    throwShmemException(env, "shmemBase_accept failed", rc);
	}
	return -1;
    }
    return CONNECTION_TO_ID(connection);
}