@@ -80,10 +80,11 @@ class ParsedJavaContent:
8080 Generic representation of data parsed from the stream
8181 """
8282
83- def __init__ (self , content_type : ContentType ):
84- self .type : ContentType = content_type
85- self .is_exception : bool = False
86- self .handle : int = 0
83+ def __init__ (self , content_type ):
84+ # type: (ContentType) -> None
85+ self .type = content_type # type: ContentType
86+ self .is_exception = False # type: bool
87+ self .handle = 0 # type: int
8788
8889 def __str__ (self ):
8990 return "[ParseJavaObject 0x{0:x} - {1}]" .format (self .handle , self .type )
@@ -109,7 +110,8 @@ class ExceptionState(ParsedJavaContent):
109110 Representation of a failed parsing
110111 """
111112
112- def __init__ (self , exception_object : ParsedJavaContent , data : bytes ):
113+ def __init__ (self , exception_object , data ):
114+ # type: (ParsedJavaContent, bytes) -> None
113115 super ().__init__ (ContentType .EXCEPTIONSTATE )
114116 self .exception_object = exception_object
115117 self .stream_data = data
@@ -128,7 +130,8 @@ class ExceptionRead(Exception):
128130 Exception used to indicate that an exception object has been parsed
129131 """
130132
131- def __init__ (self , content : ParsedJavaContent ):
133+ def __init__ (self , content ):
134+ # type: (ParsedJavaContent) -> None
132135 self .exception_object = content
133136
134137
@@ -137,14 +140,15 @@ class JavaString(ParsedJavaContent):
137140 Represents a Java string
138141 """
139142
140- def __init__ (self , handle : int , data : bytes ):
143+ def __init__ (self , handle , data ):
144+ # type: (int, bytes) -> None
141145 super ().__init__ (ContentType .STRING )
142146 self .handle = handle
143147 value , length = decode_modified_utf8 (data )
144- self .value : str = value
145- self .length : int = length
148+ self .value = value # type: str
149+ self .length = length # type: int
146150
147- def __repr__ (self ) -> str :
151+ def __repr__ (self ):
148152 return repr (self .value )
149153
150154 def __str__ (self ):
@@ -171,21 +175,18 @@ class JavaField:
171175 Represents a field in a Java class description
172176 """
173177
174- def __init__ (
175- self ,
176- field_type : FieldType ,
177- name : str ,
178- class_name : Optional [JavaString ] = None ,
179- ):
178+ def __init__ (self , field_type , name , class_name = None ):
179+ # type: (FieldType, str, Optional[JavaString]) -> None
180180 self .type = field_type
181181 self .name = name
182- self .class_name : JavaString = class_name
182+ self .class_name = class_name # type: JavaString
183183 self .is_inner_class_reference = False
184184
185185 if self .class_name :
186186 self .validate (self .class_name .value )
187187
188- def validate (self , java_type : str ) -> None :
188+ def validate (self , java_type ):
189+ # type: (str) -> None
189190 """
190191 Validates the type given as parameter
191192 """
@@ -204,47 +205,48 @@ class JavaClassDesc(ParsedJavaContent):
204205 Represents the description of a class
205206 """
206207
207- def __init__ (self , class_desc_type : ClassDescType ):
208+ def __init__ (self , class_desc_type ):
209+ # type: (ClassDescType) -> None
208210 super ().__init__ (ContentType .CLASSDESC )
209211
210212 # Type of class description
211- self .class_type : ClassDescType = class_desc_type
213+ self .class_type = class_desc_type # type: ClassDescType
212214
213215 # Class name
214- self .name : Optional [str ] = None
216+ self .name = None # type : Optional[str]
215217
216218 # Serial version UID
217- self .serial_version_uid : int = 0
219+ self .serial_version_uid = 0 # type: int
218220
219221 # Description flags byte
220- self .desc_flags : int = 0
222+ self .desc_flags = 0 # type: int
221223
222224 # Fields in the class
223- self .fields : List [ JavaField ] = [ ]
225+ self .fields = [] # type: List[JavaField ]
224226
225227 # Inner classes
226- self .inner_classes : List [ JavaClassDesc ] = [ ]
228+ self .inner_classes = [] # type: List[JavaClassDesc ]
227229
228230 # List of annotations objects
229- self .annotations : List [ ParsedJavaContent ] = [ ]
231+ self .annotations = [] # type: List[ParsedJavaContent ]
230232
231233 # The super class of this one, if any
232- self .super_class : JavaClassDesc = None
234+ self .super_class = None # type: Optional[JavaClassDesc]
233235
234236 # List of the interfaces of the class
235- self .interfaces : List [ str ] = [ ]
237+ self .interfaces = [] # type: List[str ]
236238
237239 # Set of enum constants
238- self .enum_constants : Set [ str ] = set ()
240+ self .enum_constants = set () # type: Set[str]
239241
240242 # Flag to indicate if this is an inner class
241- self .is_inner_class : bool = False
243+ self .is_inner_class = False # type: bool
242244
243245 # Flag to indicate if this is a local inner class
244- self .is_local_inner_class : bool = False
246+ self .is_local_inner_class = False # type: bool
245247
246248 # Flag to indicate if this is a static member class
247- self .is_static_member_class : bool = False
249+ self .is_static_member_class = False # type: bool
248250
249251 def __str__ (self ):
250252 return "[classdesc 0x{0:x}: name {1}, uid {2}]" .format (
@@ -290,13 +292,15 @@ def fields_types(self):
290292 """
291293 return [field .type for field in self .fields ]
292294
293- def is_array_class (self ) -> bool :
295+ def is_array_class (self ):
296+ # type: () -> bool
294297 """
295298 Determines if this is an array type
296299 """
297300 return self .name .startswith ("[" ) if self .name else False
298301
299- def get_hierarchy (self , classes : List ["JavaClassDesc" ]) -> None :
302+ def get_hierarchy (self , classes ):
303+ # type: (List["JavaClassDesc"]) -> None
300304 """
301305 Generates a list of class descriptions in this class's hierarchy, in
302306 the order described by the Object Stream Serialization Protocol.
@@ -347,9 +351,9 @@ class JavaInstance(ParsedJavaContent):
347351
348352 def __init__ (self ):
349353 super ().__init__ (ContentType .INSTANCE )
350- self .classdesc : JavaClassDesc = None
351- self .field_data : Dict [JavaClassDesc , Dict [JavaField , Any ]] = {}
352- self .annotations : Dict [JavaClassDesc , List [ParsedJavaContent ]] = {}
354+ self .classdesc = None # type: JavaClassDesc
355+ self .field_data = {} # type : Dict[JavaClassDesc, Dict[JavaField, Any]]
356+ self .annotations = {} # type : Dict[JavaClassDesc, List[ParsedJavaContent]]
353357
354358 def __str__ (self ):
355359 return "[instance 0x{0:x}: type {1}]" .format (
@@ -421,17 +425,13 @@ def get_class(self):
421425 """
422426 return self .classdesc
423427
424- def load_from_blockdata (
425- self , parser , reader : DataStreamReader , indent : int = 0
426- ) -> bool :
428+ def load_from_blockdata (self , parser , reader , indent = 0 ):
427429 """
428430 Reads content stored in a block data
429431 """
430432 return False
431433
432- def load_from_instance (
433- self , instance : "JavaInstance" , indent : int = 0
434- ) -> bool :
434+ def load_from_instance (self , instance , indent = 0 ):
435435 """
436436 Load content from a parsed instance object
437437 """
@@ -443,7 +443,8 @@ class JavaClass(ParsedJavaContent):
443443 Represents a stored Java class
444444 """
445445
446- def __init__ (self , handle : int , class_desc : JavaClassDesc ):
446+ def __init__ (self , handle , class_desc ):
447+ # type: (int, JavaClassDesc) -> None
447448 super ().__init__ (ContentType .CLASS )
448449 self .handle = handle
449450 self .classdesc = class_desc
@@ -466,9 +467,8 @@ class JavaEnum(ParsedJavaContent):
466467 Represents an enumeration value
467468 """
468469
469- def __init__ (
470- self , handle : int , class_desc : JavaClassDesc , value : JavaString
471- ):
470+ def __init__ (self , handle , class_desc , value ):
471+ # type: (int, JavaClassDesc, JavaString) -> None
472472 super ().__init__ (ContentType .ENUM )
473473 self .handle = handle
474474 self .classdesc = class_desc
@@ -492,13 +492,8 @@ class JavaArray(ParsedJavaContent, list):
492492 Represents a Java array
493493 """
494494
495- def __init__ (
496- self ,
497- handle : int ,
498- class_desc : JavaClassDesc ,
499- field_type : FieldType ,
500- content : List [Any ],
501- ):
495+ def __init__ (self , handle , class_desc , field_type , content ):
496+ # type: (int, JavaClassDesc, FieldType, List[Any]) -> None
502497 list .__init__ (self , content )
503498 ParsedJavaContent .__init__ (self , ContentType .ARRAY )
504499 self .handle = handle
@@ -545,7 +540,8 @@ class BlockData(ParsedJavaContent):
545540 Represents a data block
546541 """
547542
548- def __init__ (self , data : bytes ):
543+ def __init__ (self , data ):
544+ # type: (bytes) -> None
549545 super ().__init__ (ContentType .BLOCKDATA )
550546 self .data = data
551547
0 commit comments