NullPointerException

in Help Center
Language: Java
I am getting NullPointerException when I am sending a request to the server with a parameter containing uninitialized data structure.
I will get an exception at the on the client-side data structure class __write method.
How can I pass in a null data structure and not get an NullPointerException? Is this a limitation of ICE?
The only other choice is to create a flag to indicate valid/invalid data in the data structure and allocate memory for the data structure.
I am using ICE version 3.0.1.
Thanks for any help.
David T.
Student
Java GUI client communicates to C++ server to pull data to display to user.
I am getting NullPointerException when I am sending a request to the server with a parameter containing uninitialized data structure.
I will get an exception at the on the client-side data structure class __write method.
How can I pass in a null data structure and not get an NullPointerException? Is this a limitation of ICE?
The only other choice is to create a flag to indicate valid/invalid data in the data structure and allocate memory for the data structure.
I am using ICE version 3.0.1.
Thanks for any help.
David T.
Student
Java GUI client communicates to C++ server to pull data to display to user.
0
Comments
Welcome to the forums! We'll be happy to answer your question if you set your signature as you described in this [thread=1697]thread 1697[/thread].
Cheers,
Benoit.
You might post a little code to show what you are doing, but in general, there is no representation of NULL in ICE. You can have a NULL reference (which is what I think what you mean), but you can't have something like a NULL integer. Many languages don't support NULL in this way.
Cheers,
Assuming that I have the following data structures
struct AddressType
{
int streetNum;
string streetName;
....
};
struct PersonType
{
string firstName;
string lastName;
AddressType address;
...
};
Assuming that I send a request with the PersonType as a params with the member field address assigns to null.
I will get an NullPointerException at AddressType.__write()
Since the generated code does not taken into account that the field is null and tries to access __write() method, the Exception occurs.
Hope that help.
__________________
David Tom
Student
Data Validator
Hope I can get some answers!!!
You cannot pass null for structs, since structs have value semantics, not reference semantics. For example, for the Slice-to-C++ mapping, Slice structs are translated to C++ structs which are passed by value.
Instead of structs, you can use classes, which have reference semantics. For a discussion of structs vs. classes, please see the Ice manual, chapter 4.11.6 "Classes Versus Structures".