@@ -364,7 +364,8 @@ class JavaObjectConstants(object):
364364 TC_LONGSTRING = 0x7C
365365 TC_PROXYCLASSDESC = 0x7D
366366 TC_ENUM = 0x7E
367- TC_MAX = 0x7E
367+ # Ignore TC_MAX: we don't use it and it messes with TC_ENUM
368+ # TC_MAX = 0x7E
368369
369370 # classDescFlags
370371 SC_WRITE_METHOD = 0x01 # if SC_SERIALIZABLE
@@ -1223,8 +1224,23 @@ def write_enum(self, obj):
12231224
12241225 :param obj: A JavaEnum object
12251226 """
1227+ # FIXME: the output doesn't have the same references as the real
1228+ # serializable form
12261229 self ._writeStruct (">B" , 1 , (self .TC_ENUM ,))
1227- self .write_classdesc (obj .get_class ())
1230+
1231+ try :
1232+ idx = self .references .index (obj )
1233+ except ValueError :
1234+ # New reference
1235+ self .references .append (obj )
1236+ logging .debug (
1237+ "*** Adding ref 0x%X for enum: %s" ,
1238+ len (self .references ) - 1 + self .BASE_REFERENCE_IDX , obj )
1239+
1240+ self .write_classdesc (obj .get_class ())
1241+ else :
1242+ self .write_reference (idx )
1243+
12281244 self .write_string (obj .constant )
12291245
12301246 def write_blockdata (self , obj , parent = None ):
@@ -1433,7 +1449,7 @@ def _write_value(self, field_type, value):
14331449 if field_type == self .TYPE_BOOLEAN :
14341450 self ._writeStruct (">B" , 1 , (1 if value else 0 ,))
14351451 elif field_type == self .TYPE_BYTE :
1436- self ._writeStruct (">B " , 1 , (value ,))
1452+ self ._writeStruct (">b " , 1 , (value ,))
14371453 elif field_type == self .TYPE_SHORT :
14381454 self ._writeStruct (">h" , 1 , (value ,))
14391455 elif field_type == self .TYPE_INTEGER :
0 commit comments