(keitai-l) Re: printStackTrace manipulation

From: Ashwin Mathew <Ashwin.Mathew_at_Sun.COM>
Date: 01/07/05
Message-id: <41DE2AFE.1050708@sun.com>
Hi Sam,

I'vw just started looking at J2ME myself, so I won't pretend to be an
expert. However, the following thought occurs - how about having a
try/catch block to catch all Throwables that your application might
generate, and then serializing those and sending them over the wire,
maybe using something like PrintStream's print(Object obj) method.

I'm not sure about binary compatibility issues you might face when
trying to deserialize a CLDC Throwable to a J2SE Throwable, but I would
think this approach is worth a try. Please do let me know if it works,
and what issues you face implementing it - this would be good
information to have.

hth,
Ashwin

Sam Joseph wrote:

>Hi Paul,
>
>Thanks for your mail. Unfortunately CLDC won't let me do any of this.
>The only methods available on CLDC Throwable are: getMessage,
>printStackTrace and toString (apart from inherited Object methods).
>
>I too use various methods to grab the stack trace in J2SE. It's just
>that none of those options are available with CLDC.
>
>You are correct that I can print out debug data to the screen, but the
>printStackTrace won't go there. The printStackTrace also can't be sent
>to the application trace by setting AppTrace in the jam file. The only
>place I can view it is on the command line when I run the emulator, i.e.
>not on the handset.
>
>Anyways I'm not so interested in printing the debug info to the screen,
>I'm more interested in being able to send it over the wire so I can
>batch test/benchmark many different phone types without having to
>tediously view their screens one at a time. As I mentioned I have code
>to do this already, i.e. send debug data back over http from unit-tests
>running on multiple phones. What I'm looking for is some way to send the
>stack trace info as well as the debug/benchmarking info, but it seems
>like it will be impossible to display that in any form outside of the
>emulator.
>
>Many thanks
>
>CHEERS> SAM
>
>
>
>Paul Lester wrote:
>
>  
>
>>   It may not be supported in CLDC but you can get the stack trace from the
>>Throwable object.  I do this in regular java to create custom stack traces.
>>(I don't do much CLDC dev just CLDC testing).
>>----------
>>   Here's an excerpt from a windows program I am working on for fun.
>>
>>   Assume err is an Exception that extends Throwable.
>>   CR is a windows Carriage return (or unix or mac..whatever I feel like)
>>
>>  StackTraceElement[] elements = err.getStackTrace();
>>  String output =err.getClass()+":"+err.getMessage()+CR;
>>  for(int erri=0;erri<elements.length;erri++)
>>   output += elements[erri].getClassName()+":"+elements[erri].getLineNumber() + CR;
>>  UltimaMain.showError(output);
>>-------------
>>   As for debugging with applis... you can print debug data straight on top of your app to the screen.
>>That's the standard method.... (usually before the error occurs and often checking the memory remaining).
>>
>>Sam Joseph wrote:
>>
>> 
>>
>>    
>>
>>>Hi Keitat-l'ers,
>>>
>>>So I'm working on a unit test package for Doja phones and I'm trying to
>>>get the results of the unit-tests sent back over the wire.  I've managed
>>>to do this on the emulator at least, but now I'm trying to send back the
>>>output of the printStackTrace() operations - that most useful of
>>>debugging information.
>>>
>>>However it seems that CLDC 1.0 at least is of no help here since the
>>>printStackTrace() operations cannot point anywhere except System.err and
>>>System.err is final.  CLDC 1.1 looks no different.
>>>
>>>I guess that means there is no way to redirect that output at all ...
>>>
>>>Any ideas on ways round this?
>>>
>>>Many thanks in advance.
>>>
>>>CHEERS> SAM
>>>
>>>This mail was sent to address paul@thetamusic.com
>>>Need archives? How to unsubscribe? http://www.appelsiini.net/keitai-l/
>>>   
>>>
>>>      
>>>
>>--
>>*+*=*+*=*+*=*+*=*+*=*+*=*+*=*+*=*+*=*+*F=m(dv/dt)
>>Paul B. Lester
>>thetamusic.com(有)
>>Chief Engineer
>>
>>EMAIL: paul@thetamusic.com
>>--
>>http://www.thetamusic.com/
>>
>>personal homepage: http://pbl1.tripod.com/
>>personal EMAIL: pbl1@cornell.edu
>>*+*=*+*=*+*=*+*=*+*=*+*=*+*=*+*=*+*=*+*F=m(dv/dt)
>>
>>
>>
>>This mail was sent to address gaijin@yha.att.ne.jp
>>Need archives? How to unsubscribe? http://www.appelsiini.net/keitai-l/ 
>>
>>
>>
>> 
>>
>>    
>>
>
>
>
>This mail was sent to address Ashwin.Mathew@Sun.COM
>Need archives? How to unsubscribe? http://www.appelsiini.net/keitai-l/ 
>
>
>  
>
Received on Fri Jan 7 08:18:32 2005