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
There was some time since I used Chuck now, so I may be wrong on this
one. But I get the feeling that you're not initializing l, right?
On 10/06/07, eduard aylon
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
>>; } <<<"----------------------------------------------">>>; <<<"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
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@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-- Love. /Bruce Harris -- -----BEGIN 2ROT13 MESSAGE----- Low Bitrate Netlabel: http://f-label.tojt.net/ Blog: http://gameboygenius.8bitcollective.com/ Sätt på ett par flipflops, vippa på rumpan och gör det här till en minnesvärd sommar! -----END 2ROT13 MESSAGE-----
On 6/10/07, Bruce Harris
There was some time since I used Chuck now, so I may be wrong on this one. But I get the feeling that you're not initializing l, right?
Yes, he does, "l" is a array of "Items", 4 Items to be exact, it's right below the definition of the Item class. This looks quite odd, I can't find the issue either. In my experience null-pointers occur if you define things in the wrong order; ie before refering to them, but I think that was supposed to have been fixed last version and the order here looks perfectly corect to me. Kas.
On 10/06/07, Kassen
Yes, he does, "l" is a array of "Items", 4 Items to be exact, it's right below the definition of the Item class. Ok. As I said, it was some time since I used Chuck, and I wasn't sure if defining a symbol also initialized it.
Love. /Bruce Harris -- -----BEGIN 2ROT13 MESSAGE----- Low Bitrate Netlabel: http://f-label.tojt.net/ Blog: http://gameboygenius.8bitcollective.com/ Sätt på ett par flipflops, vippa på rumpan och gör det här till en minnesvärd sommar! -----END 2ROT13 MESSAGE-----
On 6/10/07, Bruce Harris
On 10/06/07, Kassen
wrote: Yes, he does, "l" is a array of "Items", 4 Items to be exact, it's right below the definition of the Item class. Ok. As I said, it was some time since I used Chuck, and I wasn't sure if defining a symbol also initialized it.
Well, wether it actually *does* in all cases is clearly open to speculation at the moment! :¬). I suspected for a moment you might've overlooked that line, at first I overlooked some stuff myself so sorry about that. I can't see what's wrong here, at the moment I'm suspecting ChucK is wrong and Eduard is right. Kas.
There was some time since I used Chuck now, so I may be wrong on this one. But I get the feeling that you're not initializing l, right?
That's what I thought at first with the original code but with the code below every object contained in l is automatically initialised when the list is declared. That's why after Item l[n], print() is called all items and each object's float is printed to stdout.
On 10/06/07, 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
>>; } <<<"----------------------------------------------">>>; <<<"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
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@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-- Love. /Bruce Harris
-- -----BEGIN 2ROT13 MESSAGE----- Low Bitrate Netlabel: http://f-label.tojt.net/ Blog: http://gameboygenius.8bitcollective.com/ Sätt på ett par flipflops, vippa på rumpan och gör det här till en minnesvärd sommar! -----END 2ROT13 MESSAGE----- _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
Just a newbie suggestion, but maybe:
fun void print()
{
for( 0=>int i; i
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
>>; } <<<"----------------------------------------------">>>; <<<"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
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@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
Dear all, Sorry for the delay (currently in Beijing) - just got a chance to check this and was able to reproduce the exception. It indeed looks like a ChucK bug - will definitely look into this for the next release. By the way, there will be a big development round this summer (concurrent with some thesis fabrication) - we have a lot of new stuff on the move! Stay tuned. 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
>>; } <<<"----------------------------------------------">>>; <<<"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
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@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
In a roundabout way I ran into this same thing again.
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.
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.
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'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't in itself crash ChucK, five digits of functions is fine, if slow
(*chough* hit enter and go make coffee *cough*).
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.
Kas.
On 6/23/07, Ge Wang
Dear all,
Sorry for the delay (currently in Beijing) - just got a chance to check this and was able to reproduce the exception. It indeed looks like a ChucK bug - will definitely look into this for the next release.
By the way, there will be a big development round this summer (concurrent with some thesis fabrication) - we have a lot of new stuff on the move! Stay tuned.
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
>>; } <<<"----------------------------------------------">>>; <<<"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
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@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
On 6/10/07, eduard aylon
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.
One more reply to this, it might be obvious by now but I needed a workaround
myself and was happy to find one, if a ugly one. Here's a edited version of
the original demonstration code that gets around the bug. clearly this isn't
going to work if the length of the array isn't defined in the code but is
instead determined by the outcome of some opperation. Right now I don't
think it's possible to have ChucK generate names for class instances as
ChucK can't generate ChucK code, then run it. Somebody kindly corect me if I
overlooked something in that regard. This would get quite anoying if -say-
50 "Items" were needed but if a dozen or so would do this might get people
by untill this is fixed in a future version.
Yours,
kas.
==========================
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
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
>>; } <<<"----------------------------------------------">>>; <<<"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
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@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
participants (5)
-
Bruce Harris
-
Drew Jaworski
-
eduard aylon
-
Ge Wang
-
Kassen