Troubleshooting guide

258
BlackBerry Java Development Environment Development Guide
Run the Coverage tool
1. Set two or more breakpoints in your code.
2. Run the application to the first breakpoint.
3. On the View menu, click Coverage.
4. To reset the information to 0, in the coverage pane, click Clear.
5. Run the application to the next breakpoint.
6. To display the percentage of code that you ran since you clicked Clear, in the coverage pane, click Refresh.
The Coverage pane displays the percentage of code that you ran. It displays a nested view of packages, classes,
and methods, with the percentage of code executed in each.
View source code
> In the coverage pane, double-click a method.
Green bars in the source code indicate that the source code ran, and red bars in the source code indicate that the
source code did not execute.
Approve HTTP connections
The BlackBerry® device includes built-in security features to prevent third-party applications from sending or
receiving data without the knowledge of the BlackBerry device user. When a third-party application attempts to
open a connection, a dialog box prompts the
BlackBerry device user to turn the connection on or off. To test this
functionality on the BlackBerry device simulator, turn on the security feature of the BlackBerry device simulator.
This security feature causes network applications to hang if an application makes an HTTP connection from the
main thread.
When the main thread manages connection requests, the UI cannot initiate a dialog box to prompt the BlackBerry
device user to approve the connection attempt. The application locks because the connection request cannot
complete until the BlackBerry device user approves it.
To resolve this issue, you must put the network connection request on a separate thread from the main thread so
that it does not interfere with the process of the main thread.
Note: When you use the ternary if-else operator, the coverage tool displays accurate but misleading results. For example, your code
might include the following statement:
a ? b : c;
if “a” is always true, then “c” will never execute; however, the coverage tool displays the statement as covered.
You can work around this by rewriting the code to avoid the ternary operator, as shown in the following code:
if( a ) {
b;
} else {
c;
}
The short-circuit logical operators && and || exhibit the same behavior.