[chuck-users] NullPointerException

Ge Wang gewang at CS.Princeton.EDU
Tue Aug 7 23:09:43 EDT 2007


Dear all,

Thanks for reporting and getting to the bottom of this issue.  We've  
just tracked down the bug in the code (overly liberal reuse of cached  
arrays when instantiating arrays of objects that contains arrays of  
objects), and it should hopefully be fixed.  The newest version is in  
CVS, and will be part of 1.2.0.9 release.

If you get a chance, please check this out and confirm.  Hopefully no  
new bugs got added!

Thanks again to Eduard, Kassen, Bruce, Drew, and others for the  
extremely helpful discussion.

Best,
Ge!

On Jun 9, 2007, at 7:36 PM, eduard aylon wrote:

> Hi list,
>
> I am trying to make a list of objects where each object has
> references to other objects, but I am not succeeding and I get a
> NullPointerException. The piece of code below may represent what I am
> trying to do.
>
> class object
> {
>      Std.rand2f(0., 1.) => float f_;
> }
>
> class Item extends object
> {
>      2 => int size_;
>      object item_[size_];
>
>      fun void print()
>      {
>          for( 0=>int i; i<size_; i++ )
>              <<< "item [",i,"]", item_[i].f_>>>;
>      }
>      <<<"----------------------------------------------">>>;
>      <<<"calling print from within class definition">>>;
>      <<<"----------------------------------------------">>>;
>      print();
> }
>
> 4 => int n;
> Item l[n];
>
> // no problems up until here
>
> <<<"----------------------------------------------">>>;
> <<<"calling print from outside class definition">>>;
> <<<"----------------------------------------------">>>;
>
> for( 0=>int i; i<n; i++ )
>      l[i].print();   //offending line
>
>
> After execution I get:
> [chuck](VM): NullPointerException: shred[id=1:test.ck], PC=[37]
>
> Excuse me if it's too obvious, but I can't see why it rises the null
> pointer exception. Any ideas?
>
> thanks in advance,
>
> eduard
>
>
>
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users



More information about the chuck-users mailing list