[libvirt] [PATCH v3] [libvirt-java] Fix Array IndexOutOfBoundsException for unknown error codes
Eric Blake
eblake at redhat.com
Thu Aug 9 14:39:39 UTC 2012
On 08/09/2012 07:55 AM, Claudio Bley wrote:
>>> + VIR_ERR_UNKNOWN; /* unknown error (must be the last entry!) */
>>
>> ...and this common use of a name among two different enums going to bite
>> us?
>
> No, not at all. Enums are type-safe in Java and enums have their own
> namespace; one always has to specify the enum name when referring to
> an enum constant. (except in case statements where the compiler can
> infer the type of the enum constant)
Good.
>
> Rather, I would /very/ much like these superfluous prefixes of all enum
> constants to be removed from the libvirt-java interface. They're of no
> use really, despite adding to the code bloat.
Indeed - the whole point of bindings in OO languages is to remove the
superfluous prefixes used for namespacing in C when we can instead use
the object oriented namespacing; ErrorDomain.FROM_QEMU reads much better
than ErrorDomain.VIR_FROM_QEMU. A followup patch to alter the
namespacing might be nice (but _then_ you have to worry about
back-compat to existing clients; can you have two enum names, FROM_QEMU
and VIR_FROM_QEMU, that both share the same numeric value?)
> -- >8 --
> Subject: [libvirt-java PATCHv3] Fix IndexOutOfBoundsException for
> unknown error number/domain/level
> codes.
'git am' couldn't parse this properly, and I had to amend the commit to
trim out the rest of your message (not a severe issue, but I'm not sure
why things didn't quite go like normal).
>
> Remove default constructor because it does not init the object properly.
>
> Add a special *_UNKNOWN enum value to each enum which is used when the
> given enum code is out of bounds.
> ---
> src/main/java/org/libvirt/Error.java | 43 +++++++++++++++++++++++++++++-------
> 1 file changed, 35 insertions(+), 8 deletions(-)
ACK and pushed.
--
Eric Blake eblake at redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120809/819f15a2/attachment-0001.sig>
More information about the libvir-list
mailing list