Hi,
I have a program which works fine when compiled without a TRACE statement in it, and which also works fine with a TRACE ALL in it, but when I compile it with a TRACE RESULTS statement, the program crashes with a Java null pointer exception. I can't understand why there should be any difference in behavior because of a variation in the TRACE statement. Any ideas? I'd appreciate any help at all. TIA. The program appears below, along with the two different outputs and the two different generated Java programs: /*** * addCommas.nrx,v 1.1 1997/07/03 02:03:38 * * This is an example program based on a short example from the Camel book. * It demonstrates substitutions by adding commas to a the string * representation of an integer. * ***/ OPTIONS TRACE1 import com.oroinc.text.perl. class addCommas public final trace results /* trace all */ /*** * This program takes a string as an argument and adds commas to all the * integers in the string exceeding 3 digits in length, placing each comma * three digits apart. ***/ method main(args = String[]) public static number = String matchit = Perl5Util if args.length < 1 then do System.err.println("Usage: addCommas integer") exit 1 end number = args[0] matchit = Perl5Util() loop while matchit.match("/[+-]?\\d*\\d{4}/", number) number = matchit.substitute("s/([+-]?\\d*\\d)(\\d{3})/$1,$2/", number) end say number ===================== Output with TRACE ALL ============================= 22 *=* method main(args = String[]) public static >a> args "[Ljava.lang.String;@1cc7ad" 23 *=* number = String 24 *=* matchit = Perl5Util 26 *=* if args.length < 1 31 *=* number = args[0] 32 *=* matchit = Perl5Util() 34 *=* loop while matchit.match("/[+-]?\\d*\\d{4}/", number) 35 *=* number = matchit.substitute("s/([+-]?\\d*\\d)(\\d{3})/$1,$2/", number) 34 *=* loop while matchit.match("/[+-]?\\d*\\d{4}/", number) 35 *=* number = matchit.substitute("s/([+-]?\\d*\\d)(\\d{3})/$1,$2/", number) 34 *=* loop while matchit.match("/[+-]?\\d*\\d{4}/", number) 36 *=* end 38 *=* say number 123,456,789 ===================== Output with TRACE RESULTS ============================= 22 *=* method main(args = String[]) public static >a> args "[Ljava.lang.String;@1cc7ad" 23 *=* number = String 24 *=* matchit = Perl5Util 26 *=* if args.length < 1 >>> "0" 31 *=* number = args[0] >>> "0" >v> number "123456789" 32 *=* matchit = Perl5Util() java.lang.NullPointerException at com.oroinc.text.perl.Perl5Util.toString(Compiled Code) at netrexx.lang.RexxTrace.traceObject(Compiled Code) at addCommas.main(Compiled Code) ===================== Generated Java with TRACE ALL ================== /* Generated from 'addCommas.nrx' 22 Dec 1997 23:16:46 [v1.121] */ /* Options: Crossref Decimal Format Trace1 Verbose3 */ public final class addCommas{ private static final netrexx.lang.RexxTrace $1=new netrexx.lang.RexxTrace(38,System.out); static{$1.newlevel(3);} private static final java.lang.String[] $$2={"method main(args = String[]) public static"}; private static final java.lang.String[] $$3={" number = String"}; private static final java.lang.String[] $$4={" matchit = Perl5Util"}; private static final java.lang.String[] $$5={" if args.length < 1"}; private static final netrexx.lang.Rexx $$6=new netrexx.lang.Rexx(1); private static final java.lang.String[] $$7={" then"}; private static final java.lang.String[] $$9={" do"}; private static final java.lang.String[] $$10={" System.err.println(\"Usage: addCommas integer\")"}; private static final java.lang.String[] $$11={" exit 1"}; private static final java.lang.String[] $$12={" number = args[0]"}; private static final java.lang.String[] $$13={" matchit = Perl5Util()"}; private static final java.lang.String[] $$16={" loop while matchit.match(\"/[+-]?\\\\d*\\\\d{4}/\", number)"}; private static final java.lang.String[] $$17={" number = matchit.substitute(\"s/([+-]?\\\\d*\\\\d)(\\\\d{3})/$1,$2/\", number)"}; private static final java.lang.String[] $$18={" end"}; private static final java.lang.String[] $$19={" say number"}; private static final java.lang.String $0="addCommas.nrx"; public static void main(java.lang.String $args[]){ java.lang.String $number=null; com.oroinc.text.perl.Perl5Util $matchit=null; $1.traceclause(22,$$2,2); $1.traceObject(22,$args,'a',2,"args"); $1.traceclause(23,$$3);$1.traceclause(24,$$4);$1.traceclause(26,$$5);if ((new netrexx.lang.Rexx($args.length)).OpLt(null,$$6)){ $1.traceclause(26,$$7);{$1.traceclause(26,$$9);$8:{ $1.traceclause(27,$$10);java.lang.System.err.println("Usage: addCommas integer"); $1.traceclause(28,$$11);System.exit(((int)1));return; } } } $1.traceclause(31,$$12);$number=$args[((int)0)]; $1.traceclause(32,$$13);$matchit=new com.oroinc.text.perl.Perl5Util(); {$1.traceclause(34,$$16);boolean $15=true;$14:for(;;){if($15){$15=false;}else{$1.traceclause(34,$$16);}if(!($matchit.match("/[+-]?\\d*\\d{4}/",$number)))break; $1.traceclause(35,$$17);$number=$matchit.substitute("s/([+-]?\\d*\\d)(\\d{3})/$1,$2/",$number); } $1.traceclause(36,$$18);} $1.traceclause(38,$$19);netrexx.lang.RexxIO.Say($number); return;} private addCommas(){return;} } ===================== Generated Java with TRACE RESULTS ================== /* Generated from 'addCommas.nrx' 22 Dec 1997 23:18:51 [v1.121] */ /* Options: Crossref Decimal Format Trace1 Verbose3 */ public final class addCommas{ private static final netrexx.lang.RexxTrace $1=new netrexx.lang.RexxTrace(38,System.out); static{$1.newlevel(4);} private static final java.lang.String[] $$2={"method main(args = String[]) public static"}; private static final java.lang.String[] $$3={" number = String"}; private static final java.lang.String[] $$4={" matchit = Perl5Util"}; private static final java.lang.String[] $$5={" if args.length < 1"}; private static final netrexx.lang.Rexx $$6=new netrexx.lang.Rexx(1); private static final java.lang.String[] $$7={" then"}; private static final java.lang.String[] $$9={" do"}; private static final java.lang.String[] $$10={" System.err.println(\"Usage: addCommas integer\")"}; private static final java.lang.String[] $$11={" exit 1"}; private static final java.lang.String[] $$12={" number = args[0]"}; private static final java.lang.String[] $$13={" matchit = Perl5Util()"}; private static final java.lang.String[] $$16={" loop while matchit.match(\"/[+-]?\\\\d*\\\\d{4}/\", number)"}; private static final java.lang.String[] $$17={" number = matchit.substitute(\"s/([+-]?\\\\d*\\\\d)(\\\\d{3})/$1,$2/\", number)"}; private static final java.lang.String[] $$18={" end"}; private static final java.lang.String[] $$19={" say number"}; private static final java.lang.String $0="addCommas.nrx"; public static void main(java.lang.String $args[]){ java.lang.String $number=null; com.oroinc.text.perl.Perl5Util $matchit=null; $1.traceclause(22,$$2,2); $1.traceObject(22,$args,'a',2,"args"); $1.traceclause(23,$$3);$1.traceclause(24,$$4);$1.traceclause(26,$$5);if (($1.traceboolean(26,(boolean)((new netrexx.lang.Rexx($args.length)).OpLt(null,$$6)),'>',4,""))){ $1.traceclause(26,$$7);{$1.traceclause(26,$$9);$8:{ $1.traceclause(27,$$10);java.lang.System.err.println(($1.traceString(27,"Usage: addCommas integer",'>',4,""))); $1.traceclause(28,$$11);System.exit(((int)(($1.tracebyte(28,(byte)((byte)1),'>',4,"")))));return; } } } $1.traceclause(31,$$12);$number=($1.traceString(31,$args[((int)(($1.tracebyte(31,(byte)((byte)0),'>',4,""))))],'v',4,"number")); $1.traceclause(32,$$13);$matchit=((com.oroinc.text.perl.Perl5Util)$1.traceObject(32,new com.oroinc.text.perl.Perl5Util(),'v',4,"matchit")); {$1.traceclause(34,$$16);boolean $15=true;$14:for(;;){if($15){$15=false;}else{$1.traceclause(34,$$16);}if(!(($1.traceboolean(34,(boolean)($matchit.match(($1.traceString(34,"/[+-]?\\d*\\d{4}/",'>',4,"")),($1.traceString(34,$number,'>',4,"")))),'>',4,""))))break; $1.traceclause(35,$$17);$number=($1.traceString(35,$matchit.substitute(($1.traceString(35,"s/([+-]?\\d*\\d)(\\d{3})/$1,$2/",'>',4,"")),($1.traceString(35,$number,'>',4,""))),'v',4,"number")); } $1.traceclause(36,$$18);} $1.traceclause(38,$$19);netrexx.lang.RexxIO.Say(($1.traceString(38,$number,'>',4,""))); return;} private addCommas(){return;} } -- Bernie Schneider: [hidden email] ======================================================================== The individual has always had to struggle to keep from being overwhelmed by the tribe. To be your own man is a hard business. If you try it, you will be lonely often, and sometimes frightened. But no price is too high to pay for the priviledge of owning yourself. << Rudyard Kipling >> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to [hidden email] with the following message in the body of the note unsubscribe ibm-netrexx <e-mail address> |
Free forum by Nabble | Edit this page |