|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: JNI utils |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef SENSORJNIUTILS_H |
|
20 #define SENSORJNIUTILS_H |
|
21 #include <jni.h> |
|
22 #include "sensornativeconstants.h" |
|
23 |
|
24 /** |
|
25 * Handles JNI exception which may have occured during the previous JNI |
|
26 * invocation or Java function call. |
|
27 * |
|
28 * Prints the pending exception and a backtrace of the stack to the |
|
29 * system error-reporting channel System.out.err.This function has the |
|
30 * side effect of clearing the pending exception. |
|
31 * |
|
32 * @param aJniEnv Reference to valid JNI environment |
|
33 * @return KErrNone if no exceptions are pending. Other system-wide error |
|
34 * code in exception situations |
|
35 */ |
|
36 inline int HandleException(JNIEnv& aJniEnv) |
|
37 { |
|
38 int err = ERROR_NONE; |
|
39 if (aJniEnv.ExceptionCheck()) |
|
40 { |
|
41 // Previous JNI operation caused an exception. Print the stack |
|
42 // trace and clear any pending exceptions from the Java VM |
|
43 aJniEnv.ExceptionDescribe(); |
|
44 aJniEnv.ExceptionClear(); |
|
45 err = ERROR_GENERAL; |
|
46 } |
|
47 return err; |
|
48 } |
|
49 |
|
50 #endif // SENSORJNIUTILS_H |
|
51 |