directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lecharny <>
Subject A small hint when using Enum in the codec
Date Thu, 11 Nov 2010 10:28:58 GMT
Hi guys,

yesterday, I was stuck for a couple of hours (it was late, and my brain 
was half sleeping. The only part working was my right half, the one in 
charge of emotion and slang ...), trying to understand why the kerberos 
codec was not accepting my correct hand crafted PDU. At the end, I 
realized that instead of getting the value I affected to a constant, it 
took the ordinal.

Such an enum declaration:

public enum MyEnum {

   private int value;

   private MyEnum( int value ) (
     this.value = value;

   public int getValue() {
     return value;

will return 20 when doing VB.getValue() but *1* when doing 

Don't be as idiot as I was : use getValue instead of getOrdinal, which 
is based on the field order. Also always declare a 'value' field, not an 
'ordinal' field, as it was done in many case...

I should have knew it, but anyway. I hope it can spare you some time...

Emmanuel L├ęcharny

View raw message