提交 6e3b273a 编写于 作者: P pchelko

8035332: [parfait] JNI exception pending in jdk/src/windows/native/sun/windows/awt_Window.cpp

Reviewed-by: anthony, serb
上级 fc1f55c7
...@@ -49,6 +49,7 @@ typedef AwtObject* PDATA; ...@@ -49,6 +49,7 @@ typedef AwtObject* PDATA;
#define JNI_CHECK_NULL_GOTO(obj, msg, where) { \ #define JNI_CHECK_NULL_GOTO(obj, msg, where) { \
if (obj == NULL) { \ if (obj == NULL) { \
env->ExceptionClear(); \
JNU_ThrowNullPointerException(env, msg); \ JNU_ThrowNullPointerException(env, msg); \
goto where; \ goto where; \
} \ } \
...@@ -65,6 +66,7 @@ typedef AwtObject* PDATA; ...@@ -65,6 +66,7 @@ typedef AwtObject* PDATA;
#define JNI_CHECK_NULL_RETURN(obj, msg) { \ #define JNI_CHECK_NULL_RETURN(obj, msg) { \
if (obj == NULL) { \ if (obj == NULL) { \
env->ExceptionClear(); \
JNU_ThrowNullPointerException(env, msg); \ JNU_ThrowNullPointerException(env, msg); \
return; \ return; \
} \ } \
...@@ -91,6 +93,7 @@ typedef AwtObject* PDATA; ...@@ -91,6 +93,7 @@ typedef AwtObject* PDATA;
#define JNI_CHECK_NULL_RETURN_NULL(obj, msg) { \ #define JNI_CHECK_NULL_RETURN_NULL(obj, msg) { \
if (obj == NULL) { \ if (obj == NULL) { \
env->ExceptionClear(); \
JNU_ThrowNullPointerException(env, msg); \ JNU_ThrowNullPointerException(env, msg); \
return 0; \ return 0; \
} \ } \
...@@ -98,6 +101,7 @@ typedef AwtObject* PDATA; ...@@ -98,6 +101,7 @@ typedef AwtObject* PDATA;
#define JNI_CHECK_NULL_RETURN_VAL(obj, msg, val) { \ #define JNI_CHECK_NULL_RETURN_VAL(obj, msg, val) { \
if (obj == NULL) { \ if (obj == NULL) { \
env->ExceptionClear(); \
JNU_ThrowNullPointerException(env, msg); \ JNU_ThrowNullPointerException(env, msg); \
return val; \ return val; \
} \ } \
...@@ -124,6 +128,7 @@ typedef AwtObject* PDATA; ...@@ -124,6 +128,7 @@ typedef AwtObject* PDATA;
#define THROW_NULL_PDATA_IF_NOT_DESTROYED(peer) { \ #define THROW_NULL_PDATA_IF_NOT_DESTROYED(peer) { \
jboolean destroyed = JNI_GET_DESTROYED(peer); \ jboolean destroyed = JNI_GET_DESTROYED(peer); \
if (destroyed != JNI_TRUE) { \ if (destroyed != JNI_TRUE) { \
env->ExceptionClear(); \
JNU_ThrowNullPointerException(env, "null pData"); \ JNU_ThrowNullPointerException(env, "null pData"); \
} \ } \
} }
......
...@@ -483,6 +483,8 @@ void AwtWindow::CreateHWnd(JNIEnv *env, LPCWSTR title, ...@@ -483,6 +483,8 @@ void AwtWindow::CreateHWnd(JNIEnv *env, LPCWSTR title,
env->DeleteLocalRef(target); env->DeleteLocalRef(target);
InitType(env, peer); InitType(env, peer);
JNU_CHECK_EXCEPTION(env);
TweakStyle(windowStyle, windowExStyle); TweakStyle(windowStyle, windowExStyle);
AwtCanvas::CreateHWnd(env, title, AwtCanvas::CreateHWnd(env, title,
...@@ -684,15 +686,27 @@ void AwtWindow::CalculateWarningWindowBounds(JNIEnv *env, LPRECT rect) ...@@ -684,15 +686,27 @@ void AwtWindow::CalculateWarningWindowBounds(JNIEnv *env, LPRECT rect)
if (point2DClassID == NULL) { if (point2DClassID == NULL) {
jclass point2DClassIDLocal = env->FindClass("java/awt/geom/Point2D"); jclass point2DClassIDLocal = env->FindClass("java/awt/geom/Point2D");
if (point2DClassIDLocal == NULL) {
env->DeleteLocalRef(point2D);
return;
}
point2DClassID = (jclass)env->NewGlobalRef(point2DClassIDLocal); point2DClassID = (jclass)env->NewGlobalRef(point2DClassIDLocal);
env->DeleteLocalRef(point2DClassIDLocal); env->DeleteLocalRef(point2DClassIDLocal);
} }
if (point2DGetXMID == NULL) { if (point2DGetXMID == NULL) {
point2DGetXMID = env->GetMethodID(point2DClassID, "getX", "()D"); point2DGetXMID = env->GetMethodID(point2DClassID, "getX", "()D");
if (point2DGetXMID == NULL) {
env->DeleteLocalRef(point2D);
return;
}
} }
if (point2DGetYMID == NULL) { if (point2DGetYMID == NULL) {
point2DGetYMID = env->GetMethodID(point2DClassID, "getY", "()D"); point2DGetYMID = env->GetMethodID(point2DClassID, "getY", "()D");
if (point2DGetYMID == NULL) {
env->DeleteLocalRef(point2D);
return;
}
} }
...@@ -1071,6 +1085,7 @@ AwtWindow* AwtWindow::Create(jobject self, jobject parent) ...@@ -1071,6 +1085,7 @@ AwtWindow* AwtWindow::Create(jobject self, jobject parent)
if (JNU_IsInstanceOfByName(env, target, "javax/swing/Popup$HeavyWeightWindow") > 0) { if (JNU_IsInstanceOfByName(env, target, "javax/swing/Popup$HeavyWeightWindow") > 0) {
window->m_isRetainingHierarchyZOrder = TRUE; window->m_isRetainingHierarchyZOrder = TRUE;
} }
if (env->ExceptionCheck()) goto done;
DWORD style = WS_CLIPCHILDREN | WS_POPUP; DWORD style = WS_CLIPCHILDREN | WS_POPUP;
DWORD exStyle = WS_EX_NOACTIVATE; DWORD exStyle = WS_EX_NOACTIVATE;
if (GetRTL()) { if (GetRTL()) {
...@@ -1378,6 +1393,10 @@ BOOL AwtWindow::UpdateInsets(jobject insets) ...@@ -1378,6 +1393,10 @@ BOOL AwtWindow::UpdateInsets(jobject insets)
((AwtFrame*)this)->GetMenuBar()) { ((AwtFrame*)this)->GetMenuBar()) {
m_insets.top += ::GetSystemMetrics(SM_CYMENU); m_insets.top += ::GetSystemMetrics(SM_CYMENU);
} }
if (env->ExceptionCheck()) {
env->DeleteLocalRef(target);
return FALSE;
}
m_insets.bottom += extraBottomInsets; m_insets.bottom += extraBottomInsets;
env->DeleteLocalRef(target); env->DeleteLocalRef(target);
} }
...@@ -1445,14 +1464,13 @@ void AwtWindow::SendComponentEvent(jint eventId) ...@@ -1445,14 +1464,13 @@ void AwtWindow::SendComponentEvent(jint eventId)
classEvent = (jclass)env->NewGlobalRef(classEvent); classEvent = (jclass)env->NewGlobalRef(classEvent);
} }
env->PopLocalFrame(0); env->PopLocalFrame(0);
CHECK_NULL(classEvent);
} }
static jmethodID eventInitMID = NULL; static jmethodID eventInitMID = NULL;
if (eventInitMID == NULL) { if (eventInitMID == NULL) {
eventInitMID = env->GetMethodID(classEvent, "<init>", eventInitMID = env->GetMethodID(classEvent, "<init>",
"(Ljava/awt/Component;I)V"); "(Ljava/awt/Component;I)V");
if (eventInitMID == NULL) { CHECK_NULL(eventInitMID);
return;
}
} }
if (env->EnsureLocalCapacity(2) < 0) { if (env->EnsureLocalCapacity(2) < 0) {
return; return;
...@@ -1462,6 +1480,10 @@ void AwtWindow::SendComponentEvent(jint eventId) ...@@ -1462,6 +1480,10 @@ void AwtWindow::SendComponentEvent(jint eventId)
target, eventId); target, eventId);
DASSERT(!safe_ExceptionOccurred(env)); DASSERT(!safe_ExceptionOccurred(env));
DASSERT(event != NULL); DASSERT(event != NULL);
if (event == NULL) {
env->DeleteLocalRef(target);
return;
}
SendEvent(event); SendEvent(event);
env->DeleteLocalRef(target); env->DeleteLocalRef(target);
...@@ -1503,10 +1525,7 @@ void AwtWindow::SendWindowEvent(jint id, HWND opposite, ...@@ -1503,10 +1525,7 @@ void AwtWindow::SendWindowEvent(jint id, HWND opposite,
jclass sequencedEventClsLocal jclass sequencedEventClsLocal
= env->FindClass("java/awt/SequencedEvent"); = env->FindClass("java/awt/SequencedEvent");
DASSERT(sequencedEventClsLocal); DASSERT(sequencedEventClsLocal);
if (sequencedEventClsLocal == NULL) { CHECK_NULL(sequencedEventClsLocal);
/* exception already thrown */
return;
}
sequencedEventCls = sequencedEventCls =
(jclass)env->NewGlobalRef(sequencedEventClsLocal); (jclass)env->NewGlobalRef(sequencedEventClsLocal);
env->DeleteLocalRef(sequencedEventClsLocal); env->DeleteLocalRef(sequencedEventClsLocal);
...@@ -1517,6 +1536,7 @@ void AwtWindow::SendWindowEvent(jint id, HWND opposite, ...@@ -1517,6 +1536,7 @@ void AwtWindow::SendWindowEvent(jint id, HWND opposite,
sequencedEventConst = sequencedEventConst =
env->GetMethodID(sequencedEventCls, "<init>", env->GetMethodID(sequencedEventCls, "<init>",
"(Ljava/awt/AWTEvent;)V"); "(Ljava/awt/AWTEvent;)V");
CHECK_NULL(sequencedEventConst);
} }
if (env->EnsureLocalCapacity(3) < 0) { if (env->EnsureLocalCapacity(3) < 0) {
...@@ -1539,6 +1559,7 @@ void AwtWindow::SendWindowEvent(jint id, HWND opposite, ...@@ -1539,6 +1559,7 @@ void AwtWindow::SendWindowEvent(jint id, HWND opposite,
env->DeleteLocalRef(jOpposite); jOpposite = NULL; env->DeleteLocalRef(jOpposite); jOpposite = NULL;
} }
env->DeleteLocalRef(target); target = NULL; env->DeleteLocalRef(target); target = NULL;
CHECK_NULL(event);
if (id == java_awt_event_WindowEvent_WINDOW_GAINED_FOCUS || if (id == java_awt_event_WindowEvent_WINDOW_GAINED_FOCUS ||
id == java_awt_event_WindowEvent_WINDOW_LOST_FOCUS) id == java_awt_event_WindowEvent_WINDOW_LOST_FOCUS)
...@@ -2024,10 +2045,15 @@ void AwtWindow::CheckIfOnNewScreen() { ...@@ -2024,10 +2045,15 @@ void AwtWindow::CheckIfOnNewScreen() {
jclass peerCls = env->GetObjectClass(m_peerObject); jclass peerCls = env->GetObjectClass(m_peerObject);
DASSERT(peerCls); DASSERT(peerCls);
CHECK_NULL(peerCls);
jmethodID draggedID = env->GetMethodID(peerCls, "draggedToNewScreen", jmethodID draggedID = env->GetMethodID(peerCls, "draggedToNewScreen",
"()V"); "()V");
DASSERT(draggedID); DASSERT(draggedID);
if (draggedID == NULL) {
env->DeleteLocalRef(peerCls);
return;
}
env->CallVoidMethod(m_peerObject, draggedID); env->CallVoidMethod(m_peerObject, draggedID);
m_screenNum = curScrn; m_screenNum = curScrn;
...@@ -2505,6 +2531,7 @@ void AwtWindow::SetIconData(JNIEnv* env, jintArray iconRaster, jint w, jint h, ...@@ -2505,6 +2531,7 @@ void AwtWindow::SetIconData(JNIEnv* env, jintArray iconRaster, jint w, jint h,
} }
m_hIconSm = NULL; m_hIconSm = NULL;
m_hIcon = CreateIconFromRaster(env, iconRaster, w, h); m_hIcon = CreateIconFromRaster(env, iconRaster, w, h);
JNU_CHECK_EXCEPTION(env);
m_hIconSm = CreateIconFromRaster(env, smallIconRaster, smw, smh); m_hIconSm = CreateIconFromRaster(env, smallIconRaster, smw, smh);
m_iconInherited = (m_hIcon == NULL); m_iconInherited = (m_hIcon == NULL);
...@@ -3057,22 +3084,23 @@ Java_java_awt_Window_initIDs(JNIEnv *env, jclass cls) ...@@ -3057,22 +3084,23 @@ Java_java_awt_Window_initIDs(JNIEnv *env, jclass cls)
{ {
TRY; TRY;
AwtWindow::warningStringID = CHECK_NULL(AwtWindow::warningStringID =
env->GetFieldID(cls, "warningString", "Ljava/lang/String;"); env->GetFieldID(cls, "warningString", "Ljava/lang/String;"));
AwtWindow::locationByPlatformID = CHECK_NULL(AwtWindow::locationByPlatformID =
env->GetFieldID(cls, "locationByPlatform", "Z"); env->GetFieldID(cls, "locationByPlatform", "Z"));
AwtWindow::securityWarningWidthID = CHECK_NULL(AwtWindow::securityWarningWidthID =
env->GetFieldID(cls, "securityWarningWidth", "I"); env->GetFieldID(cls, "securityWarningWidth", "I"));
AwtWindow::securityWarningHeightID = CHECK_NULL(AwtWindow::securityWarningHeightID =
env->GetFieldID(cls, "securityWarningHeight", "I"); env->GetFieldID(cls, "securityWarningHeight", "I"));
AwtWindow::getWarningStringMID = CHECK_NULL(AwtWindow::getWarningStringMID =
env->GetMethodID(cls, "getWarningString", "()Ljava/lang/String;"); env->GetMethodID(cls, "getWarningString", "()Ljava/lang/String;"));
AwtWindow::autoRequestFocusID = CHECK_NULL(AwtWindow::autoRequestFocusID =
env->GetFieldID(cls, "autoRequestFocus", "Z"); env->GetFieldID(cls, "autoRequestFocus", "Z"));
AwtWindow::calculateSecurityWarningPositionMID = CHECK_NULL(AwtWindow::calculateSecurityWarningPositionMID =
env->GetMethodID(cls, "calculateSecurityWarningPosition", "(DDDD)Ljava/awt/geom/Point2D;"); env->GetMethodID(cls, "calculateSecurityWarningPosition", "(DDDD)Ljava/awt/geom/Point2D;"));
jclass windowTypeClass = env->FindClass("java/awt/Window$Type"); jclass windowTypeClass = env->FindClass("java/awt/Window$Type");
CHECK_NULL(windowTypeClass);
AwtWindow::windowTypeNameMID = AwtWindow::windowTypeNameMID =
env->GetMethodID(windowTypeClass, "name", "()Ljava/lang/String;"); env->GetMethodID(windowTypeClass, "name", "()Ljava/lang/String;");
env->DeleteLocalRef(windowTypeClass); env->DeleteLocalRef(windowTypeClass);
...@@ -3099,10 +3127,10 @@ Java_sun_awt_windows_WWindowPeer_initIDs(JNIEnv *env, jclass cls) ...@@ -3099,10 +3127,10 @@ Java_sun_awt_windows_WWindowPeer_initIDs(JNIEnv *env, jclass cls)
{ {
TRY; TRY;
AwtWindow::sysXID = env->GetFieldID(cls, "sysX", "I"); CHECK_NULL(AwtWindow::sysXID = env->GetFieldID(cls, "sysX", "I"));
AwtWindow::sysYID = env->GetFieldID(cls, "sysY", "I"); CHECK_NULL(AwtWindow::sysYID = env->GetFieldID(cls, "sysY", "I"));
AwtWindow::sysWID = env->GetFieldID(cls, "sysW", "I"); CHECK_NULL(AwtWindow::sysWID = env->GetFieldID(cls, "sysW", "I"));
AwtWindow::sysHID = env->GetFieldID(cls, "sysH", "I"); CHECK_NULL(AwtWindow::sysHID = env->GetFieldID(cls, "sysH", "I"));
AwtWindow::windowTypeID = env->GetFieldID(cls, "windowType", AwtWindow::windowTypeID = env->GetFieldID(cls, "windowType",
"Ljava/awt/Window$Type;"); "Ljava/awt/Window$Type;");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册