Archived
This forum has been archived. Please start a new discussion on GitHub.
java passing a null enum value
in Help Center
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:
which generates this write method:
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
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
0
Comments
-
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.0
-
Ok, I see.
Thank you,
Jacek0