I am working on a Fantom system which is using a Java library (for evolutionary computing). The system uses a Fantom front-end to drive the Java library, which also consumes Fantom classes.
Although the system is working well, I have run into an issue I don't understand, when accessing a field in a Java class containing an array. (The Java class is used by the library; the array contains Java objects which have references to instances of Fantom classes.)
The object is held in a field individual of the appropriate type (GPIndividual). If I try to access the field directly, using:
individual.trees
I get an exception sys::NullErr: java.lang.NullPointerException
If I access other fields directly, there is no problem.
The field is definitely present and accessible, as shown by the following calls and output:
I don't mind the dynamic access, but I'm puzzled why the non-array fields are directly accessible, but this field is not. The null exception took a while to work out.
This must be something to do with the library, as direct array access works with other simple examples I tried. But I would like to know what !??
peterlane Fri 24 Oct 2014
I am working on a Fantom system which is using a Java library (for evolutionary computing). The system uses a Fantom front-end to drive the Java library, which also consumes Fantom classes.
Although the system is working well, I have run into an issue I don't understand, when accessing a field in a Java class containing an array. (The Java class is used by the library; the array contains Java objects which have references to instances of Fantom classes.)
The object is held in a field
individual
of the appropriate type (GPIndividual
). If I try to access the field directly, using:I get an exception
sys::NullErr: java.lang.NullPointerException
If I access other fields directly, there is no problem.
The field is definitely present and accessible, as shown by the following calls and output:
I can get at the field using either:
or better:
I don't mind the dynamic access, but I'm puzzled why the non-array fields are directly accessible, but this field is not. The null exception took a while to work out.
This must be something to do with the library, as direct array access works with other simple examples I tried. But I would like to know what !??
Any ideas?