java passing a null enum value

jacekjacek Jacek CalaOrganization: Newcastle UniversityProject: A cloud-enabled workflow management systemMember
Hello,

I noticed an issue with null enums that cause NullPointerException when returned by my server. Looking into the generated helper code I can see that enums are treated a little bit different than other types:

This is a relevant part of my slice:
enum SatisfierPropertyKind
    {
        ... 
    };
    class SatisfierProperty extends org::Runes::Any
    {
        string name;
        SatisfierPropertyKind kind;
        bool dynamic;
        //any value;
        org::Runes::Any value;
    };

which generates this write method:
protected void __writeImpl(IceInternal.BasicStream __os)
    {
        __os.startWriteSlice(ice_staticId(), -1, false);
        __os.writeString(name);
        kind.__write(__os);
        __os.writeBool(dynamic);
        __os.writeObject(value);
        __os.endWriteSlice();
        super.__writeImpl(__os);
    }

The method throws the exception when 'kind' has not been set. Are null enums not allowed? Why __writeImpl doesn't use '__os.writeEnum' instead?

Cheers,
Jacek

Comments

  • xdmxdm La Coruña, SpainJose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice DeveloperAdministrators, ZeroC Staff ZeroC Staff
    null ins't a legal value for an enumerated type, you can use a default value to have it always initialized to a legal value.
  • jacekjacek Jacek CalaOrganization: Newcastle UniversityProject: A cloud-enabled workflow management systemMember
    Ok, I see.

    Thank you,
    Jacek
Sign In or Register to comment.