• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ JNU_ThrowByName函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中JNU_ThrowByName函数的典型用法代码示例。如果您正苦于以下问题:C++ JNU_ThrowByName函数的具体用法?C++ JNU_ThrowByName怎么用?C++ JNU_ThrowByName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了JNU_ThrowByName函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: JNU_ThrowByName

JNIEXPORT void JNICALL Java_gov_nasa_worldwind_util_webview_WindowsWebViewJNI_setFrameSize
  (JNIEnv *env, jobject jobj, jlong webViewWindowPtr, jint width, jint height)
{
    if (webViewWindowPtr == NULL)
    {
        JNU_ThrowByName(env, ILLEGAL_ARGUMENT_EXCEPTION, L"nullValue.WebViewIsNull");
        return;
    }
    if (width < 0)
    {
        JNU_ThrowByName(env, ILLEGAL_ARGUMENT_EXCEPTION, L"generic.InvalidWidth");
        return;
    }
    if (height < 0)
    {
        JNU_ThrowByName(env, ILLEGAL_ARGUMENT_EXCEPTION, L"generic.InvalidHeight");
        return;
    }

    WebViewWindow *webViewWnd = reinterpret_cast<WebViewWindow*>(webViewWindowPtr);

    // Get the current position of the window. We want to change the width and height, but maintain the position.
    RECT rect;
    GetWindowRect(webViewWnd->m_hWnd, &rect);

    int x = rect.left;
    int y = rect.top;

    MoveWindow(webViewWnd->m_hWnd, x, y, width, height, TRUE);            
}
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:30,代码来源:WindowsWebViewJNI.cpp


示例2: JNU_ThrowByName

/*
 * return an array of IP_ADAPTER_ADDRESSES containing one element
 * for each adapter on the system. Returned in *adapters.
 * Buffer is malloc'd and must be freed (unless error returned)
 */
IP_ADAPTER_ADDRESSES *getAdapter (JNIEnv *env,  jint index) {
    DWORD flags, val;
    IP_ADAPTER_ADDRESSES *adapterInfo, *ptr, *ret;
    ULONG len;
    adapterInfo = (IP_ADAPTER_ADDRESSES *)malloc (bufsize);
    if (adapterInfo == NULL) {
        JNU_ThrowByName(env, "java/lang/OutOfMemoryError", "Native heap allocation failure");
        return NULL;
    }
    len = bufsize;
    flags = GAA_FLAG_SKIP_DNS_SERVER;
    flags |= GAA_FLAG_SKIP_MULTICAST;
    flags |= GAA_FLAG_INCLUDE_PREFIX;
    val = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, adapterInfo, &len);
    if (val == ERROR_BUFFER_OVERFLOW) {
        IP_ADAPTER_ADDRESSES * newAdapterInfo = (IP_ADAPTER_ADDRESSES *) realloc (adapterInfo, len);
        if (newAdapterInfo == NULL) {
            free(adapterInfo);
            JNU_ThrowByName(env, "java/lang/OutOfMemoryError", "Native heap allocation failure");
            return NULL;
        }

        adapterInfo = newAdapterInfo;

        bufsize = len;
        val = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, adapterInfo, &len);
    }

    if (val != ERROR_SUCCESS) {
        free (adapterInfo);
        JNU_ThrowByName(env, "java/lang/Error",
                "IP Helper Library GetAdaptersAddresses function failed");
        return NULL;
    }
    ptr = adapterInfo;
    ret = NULL;
    while (ptr != NULL) {
      // in theory the IPv4 index and the IPv6 index can be the same
      // where an interface is enabled for v4 and v6
      // IfIndex == 0 IPv4 not available on this interface
      // Ipv6IfIndex == 0 IPv6 not available on this interface
      if (((ptr->IfIndex != 0)&&(ptr->IfIndex == index)) ||
          ((ptr->Ipv6IfIndex !=0) && (ptr->Ipv6IfIndex == index))) {
        ret = (IP_ADAPTER_ADDRESSES *) malloc(sizeof(IP_ADAPTER_ADDRESSES));
        if (ret == NULL) {
            free(adapterInfo);
            JNU_ThrowByName(env, "java/lang/OutOfMemoryError", "Native heap allocation failure");
            return NULL;
        }

        //copy the memory and break out of the while loop.
        memcpy(ret, ptr, sizeof(IP_ADAPTER_ADDRESSES));
        break;

      }
      ptr=ptr->Next;
    }
    free(adapterInfo);
    return ret;
}
开发者ID:Gustfh,项目名称:jdk8u-dev-jdk,代码行数:65,代码来源:NetworkInterface_winXP.c


示例3: JNU_ThrowByName

/*
 * Class:     CFunction
 * Method:    find
 * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)J
 */
JNIEXPORT jlong JNICALL Java_CFunction_find
  (JNIEnv *env, jobject self, jstring lib, jstring fun)
{
    void *handle;
    void *func;
    char *libname;
    char *funname;

    if ((libname = JNU_GetStringNativeChars(env, lib))) {
        if ((funname = JNU_GetStringNativeChars(env, fun))) {
            if ((handle = (void *)LOAD_LIBRARY(libname))) {
                if (!(func = (void *)FIND_ENTRY(handle, funname))) {
                    JNU_ThrowByName(env, 
                        "java/lang/UnsatisfiedLinkError",
                        funname);
                }
            } else {
                JNU_ThrowByName(env, 
                        "java/lang/UnsatisfiedLinkError",
                        libname);
            }
            free(funname);
        }
        free(libname);
    }
    return (jlong)func;
}
开发者ID:daijo,项目名称:jniexamples,代码行数:32,代码来源:dispatch.cpp


示例4: Java_sun_awt_windows_WClipboard_openClipboard

/*
 * Class:     sun_awt_windows_WClipboard
 * Method:    openClipboard
 * Signature: (Lsun/awt/windows/WClipboard;)V
 */
JNIEXPORT void JNICALL
Java_sun_awt_windows_WClipboard_openClipboard(JNIEnv *env, jobject self,
                                              jobject newOwner)
{
    TRY;

    DASSERT(::GetOpenClipboardWindow() != AwtToolkit::GetInstance().GetHWnd());

    if (!::OpenClipboard(AwtToolkit::GetInstance().GetHWnd())) {
        HRESULT hr = HRESULT_FROM_WIN32(::GetLastError());

        if (hr == E_ACCESSDENIED) {
            JNU_ThrowByName(env, "java/lang/IllegalStateException",
                                 "Clipboard is busy");
        } else {
            JNU_ThrowByName(env, "java/lang/IllegalStateException",
                                 "Clipboard problem");
        }

        return;
    }
    if (newOwner != NULL) {
        AwtClipboard::GetOwnership();
        if (AwtClipboard::theCurrentClipboard != NULL) {
            env->DeleteGlobalRef(AwtClipboard::theCurrentClipboard);
        }
        AwtClipboard::theCurrentClipboard = env->NewGlobalRef(newOwner);
    }

    CATCH_BAD_ALLOC;
}
开发者ID:JetBrains,项目名称:jdk8u_jdk,代码行数:36,代码来源:awt_Clipboard.cpp


示例5: sizeof

/*
 * Class:     java_net_DualStackPlainSocketImpl
 * Method:    accept0
 * Signature: (I[Ljava/net/InetSocketAddress;)I
 */
JNIEXPORT jint JNICALL Java_java_net_DualStackPlainSocketImpl_accept0
  (JNIEnv *env, jclass clazz, jint fd, jobjectArray isaa) {
    int newfd, port=0;
    jobject isa;
    jobject ia;
    SOCKETADDRESS sa;
    int len = sizeof(sa);

    memset((char *)&sa, 0, len);
    newfd = accept(fd, (struct sockaddr *)&sa, &len);

    if (newfd == INVALID_SOCKET) {
        if (WSAGetLastError() == -2) {
            JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
                            "operation interrupted");
        } else {
            JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
                            "socket closed");
        }
        return -1;
    }

    ia = NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa, &port);
    isa = (*env)->NewObject(env, isa_class, isa_ctorID, ia, port);
    (*env)->SetObjectArrayElement(env, isaa, 0, isa);

    return newfd;
}
开发者ID:sakeinntojiu,项目名称:openjdk8-jdk,代码行数:33,代码来源:DualStackPlainSocketImpl.c


示例6: memset

/*
 * Class:     jdk_net_SolarisSocketOptions
 * Method:    setFlowOption0
 * Signature: (IIJ)I
 */
JNIEXPORT jint JNICALL Java_jdk_net_SolarisSocketOptions_setFlowOption
  (JNIEnv *env, jobject unused, jint fd, jint priority, jlong bandwidth)
{
    int rv;
    sock_flow_props_t props;
    memset(&props, 0, sizeof(props));
    props.sfp_version = SOCK_FLOW_PROP_VERSION1;

    if (priority != jdk_net_SocketFlow_UNSET) {
        props.sfp_mask |= SFP_PRIORITY;
        props.sfp_priority = priority;
    }
    if (bandwidth > jdk_net_SocketFlow_UNSET)  {
        props.sfp_mask |= SFP_MAXBW;
        props.sfp_maxbw = (uint64_t) bandwidth;
    }

    rv = setsockopt(fd, SOL_SOCKET, SO_FLOW_SLA, &props, sizeof(props));

    if (rv < 0) {
        if (errno == ENOPROTOOPT) {
            JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
                            "unsupported socket option");
        } else if (errno == EACCES || errno == EPERM) {
            JNU_ThrowByName(env, "java/net/SocketException", "Permission denied");
        } else {
            throwByNameWithLastError(env, "java/net/SocketException",
                                     "set option SO_FLOW_SLA failed");
        }
        return 0;
    }
    return toStatus(props.sfp_status);
}
开发者ID:lmsf,项目名称:jdk9-dev,代码行数:38,代码来源:SolarisSocketOptions.c


示例7: sizeof

/*
 * Class:     jdk_net_SolarisSocketOptions
 * Method:    getFlowOption0
 * Signature: (ILjdk/net/SocketFlow;)I
 */
JNIEXPORT jint JNICALL Java_jdk_net_SolarisSocketOptions_getFlowOption
  (JNIEnv *env, jobject unused, jint fd, jobject flow)
{
    sock_flow_props_t props;
    socklen_t sz = sizeof(props);

    int rv = getsockopt(fd, SOL_SOCKET, SO_FLOW_SLA, &props, &sz);

    if (rv < 0) {
        if (errno == ENOPROTOOPT) {
            JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
                            "unsupported socket option");
        } else if (errno == EACCES || errno == EPERM) {
            JNU_ThrowByName(env, "java/net/SocketException", "Permission denied");
        } else {
            throwByNameWithLastError(env, "java/net/SocketException",
                                     "get option SO_FLOW_SLA failed");
        }
        return -1;
    }
    /* first check status to see if flow exists */
    if (props.sfp_status == 0) { /* OK */
        /* can set the other fields now */
        if (props.sfp_mask & SFP_PRIORITY) {
            (*env)->SetIntField(env, flow, sf_priority, props.sfp_priority);
        }
        if (props.sfp_mask & SFP_MAXBW) {
            (*env)->SetLongField(env, flow, sf_bandwidth,
                                    (jlong)props.sfp_maxbw);
        }
    }
    return toStatus(props.sfp_status);
}
开发者ID:lmsf,项目名称:jdk9-dev,代码行数:38,代码来源:SolarisSocketOptions.c


示例8: NET_Timeout

/*
 * Class:     java_net_DualStackPlainSocketImpl
 * Method:    waitForNewConnection
 * Signature: (II)V
 */
JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_waitForNewConnection
  (JNIEnv *env, jclass clazz, jint fd, jint timeout) {
    int rv;

    rv = NET_Timeout(fd, timeout);
    if (rv == 0) {
        JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
                        "Accept timed out");
    } else if (rv == -1) {
        JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "socket closed");
    } else if (rv == -2) {
        JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
                        "operation interrupted");
    }
}
开发者ID:sakeinntojiu,项目名称:openjdk8-jdk,代码行数:20,代码来源:DualStackPlainSocketImpl.c


示例9: JNU_ThrowByName

 //convert jstring to character string
 char *JNU_GetStringNativeChars(JNIEnv *env, jstring jstr)
  {
      jbyteArray bytes = 0;
      jthrowable exc;
      char *result = 0;
      if ((*env)->EnsureLocalCapacity(env, 2) < 0) {
          return 0; /* out of memory error */
      }
      bytes = (*env)->CallObjectMethod(env, jstr,
                                       MID_String_getBytes);
      exc = (*env)->ExceptionOccurred(env);
      if (!exc) {
          jint len = (*env)->GetArrayLength(env, bytes);
          result = (char *)malloc(len + 1);
          if (result == 0) {
              JNU_ThrowByName(env, "java/lang/OutOfMemoryError",
                              0);
              (*env)->DeleteLocalRef(env, bytes);
              return 0;
          }
          (*env)->GetByteArrayRegion(env, bytes, 0, len,
                                     (jbyte *)result);
          result[len] = 0; /* NULL-terminate */
      } else {
          (*env)->DeleteLocalRef(env, exc);
      }
      (*env)->DeleteLocalRef(env, bytes);
      return result;
  }
开发者ID:josephdada,项目名称:manycell,代码行数:30,代码来源:sim_jnative_CopasiWSClientConnector.c


示例10: Java_sun_nio_ch_IOUtil_randomBytes

JNIEXPORT jboolean JNICALL
Java_sun_nio_ch_IOUtil_randomBytes(JNIEnv *env, jclass clazz,
                                  jbyteArray randArray)
{
    JNU_ThrowByName(env, "java/lang/UnsupportedOperationException", NULL);
    return JNI_FALSE;
}
开发者ID:digideskio,项目名称:openjdk-fontfix,代码行数:7,代码来源:IOUtil.c


示例11: GetStringPlatformChars

/*
 * Class:     sun_tools_attach_VirtualMachineImpl
 * Method:    open
 * Signature: (Ljava/lang/String;)I
 */
JNIEXPORT jint JNICALL Java_sun_tools_attach_VirtualMachineImpl_open
  (JNIEnv *env, jclass cls, jstring path)
{
    jboolean isCopy;
    const char* p = GetStringPlatformChars(env, path, &isCopy);
    if (p == NULL) {
        return 0;
    } else {
        int fd;
        int err = 0;

        fd = open(p, O_RDWR);
        if (fd == -1) {
            err = errno;
        }

        if (isCopy) {
            JNU_ReleaseStringPlatformChars(env, path, p);
        }

        if (fd == -1) {
            if (err == ENOENT) {
                JNU_ThrowByName(env, "java/io/FileNotFoundException", NULL);
            } else {
                char* msg = strdup(strerror(err));
                JNU_ThrowIOException(env, msg);
                if (msg != NULL) {
                    free(msg);
                }
            }
        }
        return fd;
    }
}
开发者ID:krichter722,项目名称:jdk9-jdk9-jdk,代码行数:39,代码来源:VirtualMachineImpl.c


示例12: LOGI

/*
 * Class:     android_pplive_media_subtitle_SimpleSubTitleParser
 * Method:    native_loadSubtitle
 * Signature: (Ljava/lang/String;Z)V
 */
JNIEXPORT void JNICALL
Java_android_pplive_media_subtitle_SimpleSubTitleParser_native_1loadSubtitle
(JNIEnv *env, jobject thiz, jstring jFilePath, jboolean isMediaFile)
{
	LOGI("native_loadSubtitle()");

	ISubtitles* parser = getSubTitleParser(env, thiz);
	if (NULL == parser) {
		JNU_ThrowByName(env, "java/lang/IllegalStateException", "Subtitle parser not found");
		return;
	}

	LOGI("Call native_loadSubtitle");
	const char* filePath = jstr2cstr(env, jFilePath);
	if (NULL == filePath) {
		LOGE("Subtitle file path is null.");
		native_onPrepared(env, thiz, false, "Subtitle file path is null.");
		return;
	}

	bool ret = parser->loadSubtitle(filePath, isMediaFile);
	free((char*)filePath);

	native_onPrepared(env, thiz, ret, ret ? "Load subtitle file succeed." : "Load subtitle file failed.");
}
开发者ID:alexliyu,项目名称:MeetSDK,代码行数:30,代码来源:SimpleSubTitleParser.cpp


示例13: sizeof

/*
 * Class:     sun_java2d_cmm_lcms_LCMS
 * Method:    getTagSize
 * Signature: (JI)I
 */
JNIEXPORT jint JNICALL Java_sun_java2d_cmm_lcms_LCMS_getTagSize
  (JNIEnv *env, jobject obj, jlong id, jint tagSig)
{
    LPLCMSICCPROFILE Icc;
    storeID_t sProf;
    int i;
    jint result;

    sProf.j = id;
    Icc = (LPLCMSICCPROFILE) sProf.pf;

    if (tagSig == SigHead) {
        result = sizeof(icHeader);
    } else {
        i =  _cmsSearchTag(Icc, tagSig, FALSE);
        if (i >= 0) {
            result = Icc->TagSizes[i];
        } else {
            JNU_ThrowByName(env, "java/awt/color/CMMException",
                            "ICC profile tag not found");
            result = -1;
        }
    }

    return result;
}
开发者ID:frohoff,项目名称:jdk6,代码行数:31,代码来源:LCMS.c


示例14: Java_sun_nio_ch_DatagramDispatcher_writev0

JNIEXPORT jlong JNICALL
Java_sun_nio_ch_DatagramDispatcher_writev0(JNIEnv *env, jclass clazz,
                                       jobject fdo, jlong address, jint len)
{
    jint fd = fdval(env, fdo);
    struct iovec *iov = (struct iovec *)jlong_to_ptr(address);
    struct msghdr m;
    ssize_t result = 0;
    if (len > 16) {
        len = 16;
    }

    m.msg_name = NULL;
    m.msg_namelen = 0;
    m.msg_iov = iov;
    m.msg_iovlen = len;
#ifdef __solaris__
    m.msg_accrights = NULL;
    m.msg_accrightslen = 0;
#endif

#ifdef __linux__
    m.msg_control = NULL;
    m.msg_controllen = 0;
#endif

    result = sendmsg(fd, &m, 0);
    if (result < 0 && errno == ECONNREFUSED) {
        JNU_ThrowByName(env, JNU_JAVANETPKG "PortUnreachableException", 0);
        return -2;
    }
    return convertLongReturnVal(env, (jlong)result, JNI_FALSE);
}
开发者ID:fatman2021,项目名称:myforthprocessor,代码行数:33,代码来源:DatagramDispatcher.c


示例15: Seek

/*
 * Class:     sun_java2d_cmm_lcms_LCMS
 * Method:    getTagData
 * Signature: (JI[B)V
 */
JNIEXPORT void JNICALL Java_sun_java2d_cmm_lcms_LCMS_getTagData
  (JNIEnv *env, jobject obj, jlong id, jint tagSig, jbyteArray data)
{
    LPLCMSICCPROFILE Icc;
    storeID_t sProf;
    jbyte* dataArray;
    int i, tagSize;

    sProf.j = id;
    Icc = (LPLCMSICCPROFILE) sProf.pf;

    if (tagSig == SigHead) {
        dataArray = (*env)->GetByteArrayElements (env, data, 0);
        tagSize =(*env)->GetArrayLength(env, data);
        Icc -> Seek(Icc, 0);
        Icc -> Read(dataArray, sizeof(icHeader), 1, Icc);
        (*env)->ReleaseByteArrayElements (env, data, dataArray, 0);
        return;
    }


    i =  _cmsSearchTag(Icc, tagSig, FALSE);
    if (i >=0) {
        tagSize = Icc->TagSizes[i];
        dataArray = (*env)->GetByteArrayElements (env, data, 0);
        Icc->Seek(Icc, Icc->TagOffsets[i]);
        Icc->Read(dataArray, 1, tagSize, Icc);
        (*env)->ReleaseByteArrayElements (env, data, dataArray, 0);
        return;
    }

    JNU_ThrowByName(env, "java/awt/color/CMMException",
                    "ICC profile tag not found");
    return;
}
开发者ID:frohoff,项目名称:jdk6,代码行数:40,代码来源:LCMS.c


示例16: JNU_GetStringNativeChars

char* JNU_GetStringNativeChars(JNIEnv* env, jstring jstr) {
  if (jstr == NULL) {
    return NULL;
  }
  jbyteArray bytes = 0;
  jthrowable exc;
  char* result = 0;
  if (env->EnsureLocalCapacity(2) < 0) {
    return 0; /* out of memory error */
  }
  jclass Class_java_lang_String = env->FindClass("java/lang/String");
  jmethodID MID_String_getBytes = env->GetMethodID(
      Class_java_lang_String, "getBytes", "()[B");
  bytes = (jbyteArray) env->CallObjectMethod(jstr, MID_String_getBytes);
  exc = env->ExceptionOccurred();
  if (!exc) {
    jint len = env->GetArrayLength(bytes);
    result = (char*) malloc(len + 1);
    if (result == 0) {
      JNU_ThrowByName(env, "java/lang/OutOfMemoryError", 0);
      env->DeleteLocalRef(bytes);
      return 0;
    }
    env->GetByteArrayRegion(bytes, 0, len, (jbyte*) result);
    result[len] = 0; /* NULL-terminate */
  } else {
    env->DeleteLocalRef(exc);
  }
  env->DeleteLocalRef(bytes);
  return result;
}
开发者ID:FkinH,项目名称:connectbot,代码行数:31,代码来源:com_google_ase_Exec.cpp


示例17: field_ctoj_perm

static bool field_ctoj_perm(JNIEnv *env, jclass cls, const char *field, jobject obj,
  struct ipc_perm *perm)
{
	jfieldID fid;
	jclass clsperm = (*env)->FindClass(env, "jtux/USysVIPC$s_ipc_perm");
	jobject objperm;

	if (cls == NULL || clsperm == NULL)
		return false;
	if ((fid = (*env)->GetFieldID(env, cls, field, "Ljtux/USysVIPC$s_ipc_perm;")) == NULL)
		return false;
	if ((objperm = (*env)->GetObjectField(env, obj, fid)) == NULL) {
		JNU_ThrowByName(env, "NullPointerException", "s_ipc_perm field not initialized");
		return false;
	}
	if (!field_ctoj_long(env, clsperm, "uid", objperm, perm->uid))
		return false;
	if (!field_ctoj_long(env, clsperm, "gid", objperm, perm->gid))
		return false;
	if (!field_ctoj_long(env, clsperm, "cuid", objperm, perm->cuid))
		return false;
	if (!field_ctoj_long(env, clsperm, "cgid", objperm, perm->cgid))
		return false;
	if (!field_ctoj_int(env, clsperm, "mode", objperm, perm->mode))
		return false;
	return true;
}
开发者ID:bionoren,项目名称:jtux,代码行数:27,代码来源:jtux_sysvipc.c


示例18: Java_sun_awt_X11_XRobotPeer_setup

// this should be called from XRobotPeer constructor
JNIEXPORT void JNICALL
Java_sun_awt_X11_XRobotPeer_setup (JNIEnv * env, jclass cls, jint numberOfButtons, jintArray buttonDownMasks)
{
    int32_t xtestAvailable;
    jint *tmp;
    int i;

    DTRACE_PRINTLN("RobotPeer: setup()");

    num_buttons = numberOfButtons;
    tmp = (*env)->GetIntArrayElements(env, buttonDownMasks, JNI_FALSE);
    masks = (jint *)malloc(sizeof(jint) * num_buttons);
    if (masks == (jint *) NULL) {
        JNU_ThrowOutOfMemoryError((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2), NULL);
        (*env)->ReleaseIntArrayElements(env, buttonDownMasks, tmp, 0);
        return;
    }
    for (i = 0; i < num_buttons; i++) {
        masks[i] = tmp[i];
    }
    (*env)->ReleaseIntArrayElements(env, buttonDownMasks, tmp, 0);

    AWT_LOCK();
    xtestAvailable = isXTestAvailable();
    DTRACE_PRINTLN1("RobotPeer: XTest available = %d", xtestAvailable);
    if (!xtestAvailable) {
        JNU_ThrowByName(env, "java/awt/AWTException", "java.awt.Robot requires your X server support the XTEST extension version 2.2");
    }

    AWT_UNLOCK();
}
开发者ID:ChenYao,项目名称:jdk7u-jdk,代码行数:32,代码来源:awt_Robot.c


示例19: JNU_GetStringNativeChars

/* Translates a Java string to a C string using the String.getBytes 
 * method, which uses default local encoding.
 */
static char *
JNU_GetStringNativeChars(JNIEnv *env, jstring jstr)
{
    jbyteArray hab = 0;
    jthrowable exc;
    char *result = 0;

    hab = (jbyteArray)env->CallObjectMethod(jstr, MID_String_getBytes);
    exc = env->ExceptionOccurred();
    if (!exc) {
        jint len = env->GetArrayLength(hab);
        result = (char *)malloc(len + 1);
	if (result == 0) {
	    JNU_ThrowByName(env, "java/lang/OutOfMemoryError", 0);
	    env->DeleteLocalRef(hab);
	    return 0;
	}
	env->GetByteArrayRegion(hab, 0, len, (jbyte *)result);
	result[len] = 0; /* NULL-terminate */
    } else {
        env->DeleteLocalRef(exc);
    }
    env->DeleteLocalRef(hab);
    return result;
}
开发者ID:daijo,项目名称:jniexamples,代码行数:28,代码来源:dispatch.cpp


示例20: OpenProcess

/*
 * Class:     sun_tools_attach_WindowsVirtualMachine
 * Method:    openProcess
 * Signature: (I)J
 */
JNIEXPORT jlong JNICALL Java_sun_tools_attach_WindowsVirtualMachine_openProcess
  (JNIEnv *env, jclass cls, jint pid)
{
    HANDLE hProcess;

    /*
     * Attempt to open process. If it fails then we try to enable the
     * SE_DEBUG_NAME privilege and retry.
     */
    hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, (DWORD)pid);
    if (hProcess == NULL && GetLastError() == ERROR_ACCESS_DENIED) {
        hProcess = doPrivilegedOpenProcess(PROCESS_ALL_ACCESS, FALSE, (DWORD)pid);
    }

    if (hProcess == NULL) {
        if (GetLastError() == ERROR_INVALID_PARAMETER) {
            JNU_ThrowIOException(env, "no such process");
        } else {
            JNU_ThrowIOExceptionWithLastError(env, "OpenProcess failed");
        }
        return (jlong)0;
    }

    /*
     * On Windows 64-bit we need to handle 32-bit tools trying to attach to 64-bit
     * processes (and visa versa). X-architecture attaching is currently not supported
     * by this implementation.
     */
    if (_IsWow64Process != NULL) {
        BOOL isCurrent32bit, isTarget32bit;
        (*_IsWow64Process)(GetCurrentProcess(), &isCurrent32bit);
        (*_IsWow64Process)(hProcess, &isTarget32bit);

        if (isCurrent32bit != isTarget32bit) {
            CloseHandle(hProcess);
            #ifdef _WIN64
              JNU_ThrowByName(env, "com/sun/tools/attach/AttachNotSupportedException",
                  "Unable to attach to 32-bit process running under WOW64");
            #else
              JNU_ThrowByName(env, "com/sun/tools/attach/AttachNotSupportedException",
                  "Unable to attach to 64-bit process");
            #endif
        }
    }

    return (jlong)hProcess;
}
开发者ID:michalwarecki,项目名称:ManagedRuntimeInitiative,代码行数:52,代码来源:WindowsVirtualMachine.c



注:本文中的JNU_ThrowByName函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ JNU_ThrowIOExceptionWithLastError函数代码示例发布时间:2022-05-30
下一篇:
C++ JNU_ReleaseStringPlatformChars函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap