@@ -75,6 +75,14 @@ class JavaObject(object):
75
75
def get_class (self ):
76
76
return self .classdesc
77
77
78
+ def __str__ (self ):
79
+ return self .__repr__ ()
80
+
81
+ def __repr__ (self ):
82
+ name = "UNKNOWN"
83
+ if self .classdesc :
84
+ name = self .classdesc .name
85
+ return "<javaobj:%s>" % name
78
86
79
87
class JavaObjectConstants :
80
88
@@ -232,21 +240,23 @@ def do_classdesc(self, parent=None, ident=0):
232
240
clazz .fields_names = []
233
241
clazz .fields_types = []
234
242
for fieldId in range (length ):
235
- (type , ) = self ._readStruct (">B" )
243
+ (typecode , ) = self ._readStruct (">B" )
236
244
field_name = self ._readString ()
237
245
field_type = None
238
- field_type = self ._convert_char_to_type (type )
246
+ field_type = self ._convert_char_to_type (typecode )
239
247
240
248
if field_type == self .TYPE_ARRAY :
241
249
field_type = self ._read_and_exec_opcode (ident = ident + 1 , expect = [self .TC_STRING , self .TC_REFERENCE ])
250
+ assert type (field_type ) is str
242
251
# if field_type is not None:
243
252
# field_type = "array of " + field_type
244
253
# else:
245
254
# field_type = "array of None"
246
255
elif field_type == self .TYPE_OBJECT :
247
256
field_type = self ._read_and_exec_opcode (ident = ident + 1 , expect = [self .TC_STRING , self .TC_REFERENCE ])
257
+ assert type (field_type ) is str
248
258
249
- log_debug ("FieldName: 0x%X" % type + " " + str (field_name ) + " " + str (field_type ), ident )
259
+ log_debug ("FieldName: 0x%X" % typecode + " " + str (field_name ) + " " + str (field_type ), ident )
250
260
assert field_name is not None
251
261
assert field_type is not None
252
262
@@ -257,9 +267,9 @@ def do_classdesc(self, parent=None, ident=0):
257
267
parent .__types = clazz .fields_types
258
268
# classAnnotation
259
269
(opid , ) = self ._readStruct (">B" )
270
+ log_debug ("OpCode: 0x%X" % opid , ident )
260
271
if opid != self .TC_ENDBLOCKDATA :
261
272
raise NotImplementedError ("classAnnotation isn't implemented yet" )
262
- log_debug ("OpCode: 0x%X" % opid , ident )
263
273
# superClassDesc
264
274
superclassdesc = self ._read_and_exec_opcode (ident = ident + 1 , expect = [self .TC_CLASSDESC , self .TC_NULL , self .TC_REFERENCE ])
265
275
log_debug (str (superclassdesc ), ident )
@@ -310,6 +320,7 @@ def do_object(self, parent=None, ident=0):
310
320
megatypes = []
311
321
while tempclass :
312
322
log_debug (">>> " + str (tempclass .fields_names ) + " " + str (tempclass ), ident )
323
+ log_debug (">>> " + str (tempclass .fields_types ), ident )
313
324
fieldscopy = tempclass .fields_names [:]
314
325
fieldscopy .extend (megalist )
315
326
megalist = fieldscopy
@@ -331,12 +342,17 @@ def do_object(self, parent=None, ident=0):
331
342
if classdesc .flags & self .SC_SERIALIZABLE and classdesc .flags & self .SC_WRITE_METHOD or classdesc .flags & self .SC_EXTERNALIZABLE and classdesc .flags & self .SC_BLOCK_DATA :
332
343
# objectAnnotation
333
344
(opid , ) = self ._readStruct (">B" )
334
- if opid != self .TC_ENDBLOCKDATA : # 0x78:
345
+ log_debug ("OpCode: 0x%X" % opid , ident )
346
+ if opid == self .TC_ENDBLOCKDATA : # 0x78:
347
+ log_debug ("TC_ENDBLOCKDATA: no object annotation" )
348
+ elif opid == self .TC_OBJECT :
349
+ self .object_stream .seek (- 1 , mode = 1 )
350
+ obj = self ._read_and_exec_opcode (ident = ident + 1 , expect = [self .TC_OBJECT , self .TC_NULL , self .TC_REFERENCE ])
351
+ log_debug ("objectAnnotation: " + str (obj ))
352
+ else :
335
353
self .object_stream .seek (- 1 , mode = 1 )
336
- # print self._create_hexdump(self.object_stream.read())
337
354
raise NotImplementedError ("objectAnnotation isn't fully implemented yet" ) # TODO:
338
355
339
-
340
356
return java_object
341
357
342
358
def do_string (self , parent = None , ident = 0 ):
0 commit comments