diff options
author | Silenio Quarti <silenio> | 2011-03-17 20:25:32 +0000 |
---|---|---|
committer | Silenio Quarti <silenio> | 2011-03-17 20:25:32 +0000 |
commit | 8118a219520737c1105cf243783ef03eda333d7c (patch) | |
tree | bba98830af7ea70fb27a77d477c5a6c425503e11 /bundles/org.eclipse.swt | |
parent | d1c3f57204e67ce1ff35122330fba5286431872b (diff) | |
download | eclipse.platform.swt-8118a219520737c1105cf243783ef03eda333d7c.tar.gz eclipse.platform.swt-8118a219520737c1105cf243783ef03eda333d7c.tar.xz eclipse.platform.swt-8118a219520737c1105cf243783ef03eda333d7c.zip |
Bug 329518 - Need to add some try/exception in some SWT JNI call
Diffstat (limited to 'bundles/org.eclipse.swt')
6 files changed, 40 insertions, 8 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/com.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/com.c index 3050b9437b..026c3f6ecf 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/com.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/com.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -1028,9 +1028,9 @@ JNIEXPORT jint JNICALL COM_NATIVE(OleSetMenuDescriptor) (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jintLong arg2, jintLong arg3, jintLong arg4) { jint rc = 0; - COM_NATIVE_ENTER(env, that, OleSetMenuDescriptor_FUNC); + COM_NATIVE_ENTER_TRY(env, that, OleSetMenuDescriptor_FUNC); rc = (jint)OleSetMenuDescriptor((HOLEMENU)arg0, (HWND)arg1, (HWND)arg2, (LPOLEINPLACEFRAME)arg3, (LPOLEINPLACEACTIVEOBJECT)arg4); - COM_NATIVE_EXIT(env, that, OleSetMenuDescriptor_FUNC); + COM_NATIVE_EXIT_CATCH(env, that, OleSetMenuDescriptor_FUNC); return rc; } #endif diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/com.h b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/com.h index fb3fd91360..27cbe74a41 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/com.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/com.h @@ -15,4 +15,11 @@ #include "os_structs.h" #include "com_custom.h" +#define COM_NATIVE_ENTER_TRY(env, that, func) \ + COM_NATIVE_ENTER(env, that, func); \ + NATIVE_TRY(env, that, func); +#define COM_NATIVE_EXIT_CATCH(env, that, func) \ + NATIVE_CATCH(env, that, func); \ + COM_NATIVE_EXIT(env, that, func); + #endif /* INC_com_H */ diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c index 481871d214..245c7da9f4 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c @@ -17825,15 +17825,15 @@ JNIEXPORT jint JNICALL OS_NATIVE(VtblCall__IJ)(JNIEnv *env, jclass that, jint ar { jint rc = 0; #ifndef JNI64 - OS_NATIVE_ENTER(env, that, VtblCall__II_FUNC); + OS_NATIVE_ENTER_TRY(env, that, VtblCall__II_FUNC); #else - OS_NATIVE_ENTER(env, that, VtblCall__IJ_FUNC); + OS_NATIVE_ENTER_TRY(env, that, VtblCall__IJ_FUNC); #endif rc = (jint)((jint (STDMETHODCALLTYPE *)(jintLong))(*(jintLong **)arg1)[arg0])(arg1); #ifndef JNI64 - OS_NATIVE_EXIT(env, that, VtblCall__II_FUNC); + OS_NATIVE_EXIT_CATCH(env, that, VtblCall__II_FUNC); #else - OS_NATIVE_EXIT(env, that, VtblCall__IJ_FUNC); + OS_NATIVE_EXIT_CATCH(env, that, VtblCall__IJ_FUNC); #endif return rc; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.h b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.h index 36c6f8b753..d3218d1c89 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.h @@ -815,4 +815,28 @@ typedef struct tagGESTURECONFIG { #include "os_custom.h" +#ifdef _WIN32_WCE +#define PRINT_CODE(buf, size, format, code) sprintf(buf, format, code); +#else +#define PRINT_CODE(buf, size, format, code) sprintf_s(buf, size, format, code); +#endif +#define NATIVE_TRY(env, that, func) \ + __try { +#define NATIVE_CATCH(env, that, func) \ + } __except(EXCEPTION_EXECUTE_HANDLER) { \ + jclass expClass = (*env)->FindClass(env, "org/eclipse/swt/SWTError"); \ + if (expClass) { \ + char buffer[256]; \ + PRINT_CODE(buffer, 256, "cought native exception: 0x%x", GetExceptionCode()) \ + (*env)->ThrowNew(env, expClass, buffer); \ + } \ + } + +#define OS_NATIVE_ENTER_TRY(env, that, func) \ + OS_NATIVE_ENTER(env, that, func); \ + NATIVE_TRY(env, that, func); +#define OS_NATIVE_EXIT_CATCH(env, that, func) \ + NATIVE_CATCH(env, that, func); \ + OS_NATIVE_EXIT(env, that, func); + #endif /* INC_os_H */ diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/COM.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/COM.java index 5ceb001b10..51fb54c739 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/COM.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/COM.java @@ -595,6 +595,7 @@ public static final native int OleSetClipboard(int /*long*/ pDataObject); /** @param pUnk cast=(LPUNKNOWN) */ public static final native int OleSetContainedObject(int /*long*/ pUnk, boolean fContained); /** + * @method flags=trycatch * @param holemenu cast=(HOLEMENU) * @param hwndFrame cast=(HWND) * @param hwndActiveObject cast=(HWND) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java index 53aba21505..3db04a36f2 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java @@ -6789,7 +6789,7 @@ public static final native boolean ValidateRect (int /*long*/ hWnd, RECT lpRect) public static final native short VkKeyScanW (short ch); /** @param ch cast=(TCHAR) */ public static final native short VkKeyScanA (short ch); - +/** @method flags=trycatch */ public static final native int VtblCall (int fnNumber, int /*long*/ ppVtbl); public static final native int VtblCall (int fnNumber, int /*long*/ ppVtbl, int arg0); |