src/windows/native/sun/windows/awt_new.cpp

Print this page




 132 //   3. __declspec(dllexport), or
 133 //   4. extern "C"
 134 // A function which returns an HRESULT (an OLE function) is also an entry
 135 // point.
 136 void
 137 entry_point(void) {
 138     if (jvm != NULL) {
 139         JNIEnv* env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 140         if (env != NULL) {
 141             env->ExceptionClear();
 142         }
 143     }
 144 }
 145 
 146 
 147 // This function is called when a std::bad_alloc exception is caught.
 148 void
 149 handle_bad_alloc(void) {
 150     if (jvm != NULL) {
 151         JNIEnv* env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 152         if (env != NULL) {
 153             JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
 154         }
 155     }
 156 }
 157 
 158 
 159 // This function is called instead of ExceptionOccurred. It throws
 160 // std::bad_alloc if a java.lang.OutOfMemoryError is currently pending
 161 // on the calling thread.
 162 jthrowable
 163 safe_ExceptionOccurred(JNIEnv *env) throw (std::bad_alloc) {
 164     jthrowable xcp = env->ExceptionOccurred();
 165     if (xcp != NULL) {
 166         env->ExceptionClear(); // if we don't do this, isInstanceOf will fail
 167         jint isOutofmem = JNU_IsInstanceOfByName(env, xcp, "java/lang/OutOfMemoryError");
 168         if (isOutofmem > 0) {
 169             env->DeleteLocalRef(xcp);
 170             throw std::bad_alloc();
 171         } else {
 172             env->ExceptionClear();




 132 //   3. __declspec(dllexport), or
 133 //   4. extern "C"
 134 // A function which returns an HRESULT (an OLE function) is also an entry
 135 // point.
 136 void
 137 entry_point(void) {
 138     if (jvm != NULL) {
 139         JNIEnv* env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 140         if (env != NULL) {
 141             env->ExceptionClear();
 142         }
 143     }
 144 }
 145 
 146 
 147 // This function is called when a std::bad_alloc exception is caught.
 148 void
 149 handle_bad_alloc(void) {
 150     if (jvm != NULL) {
 151         JNIEnv* env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 152         if (env != NULL && !env->ExceptionCheck()) {
 153             JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
 154         }
 155     }
 156 }
 157 
 158 
 159 // This function is called instead of ExceptionOccurred. It throws
 160 // std::bad_alloc if a java.lang.OutOfMemoryError is currently pending
 161 // on the calling thread.
 162 jthrowable
 163 safe_ExceptionOccurred(JNIEnv *env) throw (std::bad_alloc) {
 164     jthrowable xcp = env->ExceptionOccurred();
 165     if (xcp != NULL) {
 166         env->ExceptionClear(); // if we don't do this, isInstanceOf will fail
 167         jint isOutofmem = JNU_IsInstanceOfByName(env, xcp, "java/lang/OutOfMemoryError");
 168         if (isOutofmem > 0) {
 169             env->DeleteLocalRef(xcp);
 170             throw std::bad_alloc();
 171         } else {
 172             env->ExceptionClear();