In a roundabout way I ran into this same thing again.<br><br>I had a array of ugens in a class, instead of home-made class-instances like Eduard had, and adressing those from outside of the class will also yield a nullpointer exception. Actually; even calling a member function that in turn will adress those ugens will create a nullpointer.
<br><br>Aditionally, I suspect that having a array of class-instances that in turn each hold a array of ugens each can cause ChucK to crash outright without warning or saving-roll, however that issue is quite hard to pinpoint as my setup also involves a fairly large amount of sporked functions that get sporked by other functions within this class.
<br><br>It seems to me that there are definately one or more serious issues here but they are hard define as they clearly only manifest after a sertain amount of complexity has been reached and after that it&#39;s hard to find exactly what combintation of factors results in nullpointers and/or crashes... I strongly suspect something is up with sporking member functions from within classes, though seemingly this is no major issue unless the classes are in arrays.. Unlike I previously suspected, simply sporking a awfull lot of functions doesn&#39;t in itself crash ChucK, five digits of functions is fine, if slow (*chough* hit enter and go make coffee *cough*).
<br><br>A possible workaround (for objects) might be instantiating objects or whole arrays outside of the classes and asigning them to instances but that would be asking for more overhead and generally create a mess that woulds defeat most of the purpose of using classes.
<br><br>Kas.<br><br><div><span class="gmail_quote">On 6/23/07, <b class="gmail_sendername">Ge Wang</b> &lt;<a href="mailto:gewang@cs.princeton.edu">gewang@cs.princeton.edu</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Dear all,<br><br>Sorry for the delay (currently in Beijing) - just got a chance to<br>check this and was able to reproduce the exception.&nbsp;&nbsp;It indeed looks<br>like a ChucK bug - will definitely look into this for the next release.
<br><br>By the way, there will be a big development round this summer<br>(concurrent with some thesis fabrication) - we have a lot of new<br>stuff on the move!&nbsp;&nbsp;Stay tuned.<br><br>Best,<br>Ge!<br><br>On Jun 9, 2007, at 7:36 PM, eduard aylon wrote:
<br><br>&gt; Hi list,<br>&gt;<br>&gt; I am trying to make a list of objects where each object has<br>&gt; references to other objects, but I am not succeeding and I get a<br>&gt; NullPointerException. The piece of code below may represent what I am
<br>&gt; trying to do.<br>&gt;<br>&gt; class object<br>&gt; {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Std.rand2f(0., 1.) =&gt; float f_;<br>&gt; }<br>&gt;<br>&gt; class Item extends object<br>&gt; {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2 =&gt; int size_;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;object item_[size_];
<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fun void print()<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for( 0=&gt;int i; i&lt;size_; i++ )<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt;&lt; &quot;item [&quot;,i,&quot;]&quot;, item_[i].f_&gt;&gt;&gt;;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt;&lt;&quot;----------------------------------------------&quot;&gt;&gt;&gt;;
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt;&lt;&quot;calling print from within class definition&quot;&gt;&gt;&gt;;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt;&lt;&quot;----------------------------------------------&quot;&gt;&gt;&gt;;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print();<br>&gt; }
<br>&gt;<br>&gt; 4 =&gt; int n;<br>&gt; Item l[n];<br>&gt;<br>&gt; // no problems up until here<br>&gt;<br>&gt; &lt;&lt;&lt;&quot;----------------------------------------------&quot;&gt;&gt;&gt;;<br>&gt; &lt;&lt;&lt;&quot;calling print from outside class definition&quot;&gt;&gt;&gt;;
<br>&gt; &lt;&lt;&lt;&quot;----------------------------------------------&quot;&gt;&gt;&gt;;<br>&gt;<br>&gt; for( 0=&gt;int i; i&lt;n; i++ )<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;l[i].print();&nbsp;&nbsp; //offending line<br>&gt;<br>&gt;<br>&gt; After execution I get:
<br>&gt; [chuck](VM): NullPointerException: shred[id=1:<a href="http://test.ck">test.ck</a>], PC=[37]<br>&gt;<br>&gt; Excuse me if it&#39;s too obvious, but I can&#39;t see why it rises the null<br>&gt; pointer exception. Any ideas?
<br>&gt;<br>&gt; thanks in advance,<br>&gt;<br>&gt; eduard<br>&gt;<br>&gt;<br>&gt;<br>&gt; _______________________________________________<br>&gt; chuck-users mailing list<br>&gt; <a href="mailto:chuck-users@lists.cs.princeton.edu">
chuck-users@lists.cs.princeton.edu</a><br>&gt; <a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br><br>_______________________________________________
<br>chuck-users mailing list<br><a href="mailto:chuck-users@lists.cs.princeton.edu">chuck-users@lists.cs.princeton.edu</a><br><a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
</a><br></blockquote></div><br>