@@ -75,6 +75,14 @@ class JavaObject(object):
7575 def get_class (self ):
7676 return self .classdesc
7777
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
7886
7987class JavaObjectConstants :
8088
@@ -232,21 +240,23 @@ def do_classdesc(self, parent=None, ident=0):
232240 clazz .fields_names = []
233241 clazz .fields_types = []
234242 for fieldId in range (length ):
235- (type , ) = self ._readStruct (">B" )
243+ (typecode , ) = self ._readStruct (">B" )
236244 field_name = self ._readString ()
237245 field_type = None
238- field_type = self ._convert_char_to_type (type )
246+ field_type = self ._convert_char_to_type (typecode )
239247
240248 if field_type == self .TYPE_ARRAY :
241249 field_type = self ._read_and_exec_opcode (ident = ident + 1 , expect = [self .TC_STRING , self .TC_REFERENCE ])
250+ assert type (field_type ) is str
242251# if field_type is not None:
243252# field_type = "array of " + field_type
244253# else:
245254# field_type = "array of None"
246255 elif field_type == self .TYPE_OBJECT :
247256 field_type = self ._read_and_exec_opcode (ident = ident + 1 , expect = [self .TC_STRING , self .TC_REFERENCE ])
257+ assert type (field_type ) is str
248258
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 )
250260 assert field_name is not None
251261 assert field_type is not None
252262
@@ -257,9 +267,9 @@ def do_classdesc(self, parent=None, ident=0):
257267 parent .__types = clazz .fields_types
258268 # classAnnotation
259269 (opid , ) = self ._readStruct (">B" )
270+ log_debug ("OpCode: 0x%X" % opid , ident )
260271 if opid != self .TC_ENDBLOCKDATA :
261272 raise NotImplementedError ("classAnnotation isn't implemented yet" )
262- log_debug ("OpCode: 0x%X" % opid , ident )
263273 # superClassDesc
264274 superclassdesc = self ._read_and_exec_opcode (ident = ident + 1 , expect = [self .TC_CLASSDESC , self .TC_NULL , self .TC_REFERENCE ])
265275 log_debug (str (superclassdesc ), ident )
@@ -310,6 +320,7 @@ def do_object(self, parent=None, ident=0):
310320 megatypes = []
311321 while tempclass :
312322 log_debug (">>> " + str (tempclass .fields_names ) + " " + str (tempclass ), ident )
323+ log_debug (">>> " + str (tempclass .fields_types ), ident )
313324 fieldscopy = tempclass .fields_names [:]
314325 fieldscopy .extend (megalist )
315326 megalist = fieldscopy
@@ -331,12 +342,17 @@ def do_object(self, parent=None, ident=0):
331342 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 :
332343 # objectAnnotation
333344 (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 :
335353 self .object_stream .seek (- 1 , mode = 1 )
336- # print self._create_hexdump(self.object_stream.read())
337354 raise NotImplementedError ("objectAnnotation isn't fully implemented yet" ) # TODO:
338355
339-
340356 return java_object
341357
342358 def do_string (self , parent = None , ident = 0 ):
0 commit comments