This forum has been archived. Please start a new discussion on GitHub.


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.
Java GUI client communicates to C++ server to pull data to display to user.


  • benoit
    benoit Rennes, France

    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].

  • Post Some Code

    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.

  • I am referring to complex data structure and not primitive data type (i.e. int, float, ...)

    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
    Data Validator
  • Can you please update your signature as explained in this thread?
  • Ok!

    Hope I can get some answers!!!
  • Sorry David, but I still have to ask you to update your signature as specified in the thread mentioned before. In particular, please include "The name of your company or organization (such as universities), including a Web address (URL)."
  • Thank you for updating your signature.

    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".
  • Thank you, I will look into the chapter