Java Reference
In-Depth Information
3.8 Crossing to the Native Land of Symbian OS
We now deal with areas that are part of the native capabilities of Symbian
OS. We first give advice on how to better understand some of the
messages that appear in Java exceptions. Then we discuss how some
mobile applications can use both Java and native capabilities.
3.8.1 Native Error Codes in Java Exception Messages
Error handling in Java ME on Symbian OS remains the same as error
handling anywhere else in Java ME; it is identical to standard Java error
handling. The platform implementation informs you of errors through the
usual mechanism of throwing Java exceptions as specified in the Java
Language Specification. That does not change; what changes is what
appears in the error message.
The thrown exception carries a description, which should provide the
developer with sufficient information about the problem, e.g., 'Connec-
tion not found'. As we discuss in Chapter 11, Java ME on Symbian OS
is tightly integrated on top of the native Symbian OS APIs, therefore an
error which occurs deep down in the native domain eventually triggers a
Java exception to be thrown back in the Java ME run-time environment.
In some cases, the Java exception error message includes the native error
code which has triggered the Java exception. For example, your Java
code might catch an IOException with a description that includes a
native error code such as -36 , which means that a local IPC session was
disconnected (and you might want to restart the device). Naturally, at run
time your application should treat the thrown Java exception in the same
way as on any other Java ME platform. However, during development, if
a native error code is specified, it could provide you with some additional
information that might help you to diagnose the error and track down the
reason it occurred.
In most cases, native error codes should not appear in the Java
exception message. For example, if your application fails to send an SMS
message or a TCP peer connection is dropped, there is no reason to expect
a native Symbian OS error code. When there is a native error code, it might
be related to missing settings on the device. Then it would be worth look-
ing up the native error code in the Symbian OS documentation 10 and using
this additional information to identify or better understand the problem.
3.8.2 Combining MIDlets and Other Run-time Environments
CLDC was not designed to be interoperable with native code or other
run-time environments but when something is possible, a developer
10 As well as the Symbian OS reference, other free online resources, such as www.newlc.
com/Symbian-OS-Error-Codes.html ,mayhelp.
Search WWH ::




Custom Search