5151 ClassDataType ,
5252)
5353from .stream import DataStreamReader
54+ from .transformers import DefaultObjectTransformer
5455from ..constants import (
5556 ClassDescFlags ,
5657 StreamConstants ,
@@ -492,6 +493,10 @@ def _do_object(self, type_code=0):
492493 self ._log .debug ("Done reading object handle %x" , handle )
493494 return instance
494495
496+ def _is_default_supported (self , class_name ):
497+ default_transf = [x for x in self .__transformers if isinstance (x , DefaultObjectTransformer )]
498+ return len (default_transf ) and class_name in default_transf [0 ]._type_mapper
499+
495500 def _read_class_data (self , instance ):
496501 # type: (JavaInstance) -> None
497502 """
@@ -508,12 +513,16 @@ def _read_class_data(self, instance):
508513 values = {} # type: Dict[JavaField, Any]
509514 cd .validate ()
510515 if cd .data_type == ClassDataType .NOWRCLASS or cd .data_type == ClassDataType .WRCLASS :
511- if cd .data_type == ClassDataType .NOWRCLASS :
516+ read_custom_data = cd .data_type == ClassDataType .WRCLASS and cd .is_super_class and not self ._is_default_supported (cd .name )
517+ if read_custom_data or cd .data_type == ClassDataType .WRCLASS and instance .is_external_instance :
518+ annotations [cd ] = self ._read_class_annotations (cd )
519+ else :
512520 for field in cd .fields :
513521 values [field ] = self ._read_field_value (field .type )
514522 all_data [cd ] = values
515- else :
516- annotations [cd ] = self ._read_class_annotations (cd )
523+
524+ if cd .data_type == ClassDataType .WRCLASS :
525+ annotations [cd ] = self ._read_class_annotations (cd )
517526 else :
518527 if cd .data_type == ClassDataType .OBJECT_ANNOTATION :
519528 # Call the transformer if possible
0 commit comments