You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use fury in my projects, in one of the projects i serialize the object of ProductPO.class where fury is created like "furySerializer" in following code, in the other project i deseralize the byte[] using fury like “furyDeSerializer1” in following code.
however,when i deseralize the byte[],an error occurred and made me confused:
java.lang.ClassCastException: class ...RateDetailPO cannot be cast to class ...ProductPO (...RateDetailPO and ...ProductPO are in unnamed module of loader 'app')
at ...FuryTestV2.test1(FuryTestV2.java:73)
at ...main(FuryTestV2.java:63)
yyjyc
changed the title
[Question] <Java>when i deserialize object,error 'A cannot be cast to class B' occurred
[Java] deserialize object,error 'A cannot be cast to class B' occurred
Jan 13, 2025
Hi @yyjyc , you need to make class registration consistent between serialization and deserialization, otherwise you will get class clast exception. With inconsistent class registration order, one class on serialization will be mapped to another class in deserialization
@chaokunyang Thank you for your reply. I register ProductPO.class when serialization, register RateDetailPO.class、PersonRulePO.class、DailyInfoPO.class、DailyInfoList.class、GregorianCalendar.class、com.ctrip.hotel.productsearchfilter.ProductPO.class when deserialization.
ProductPO.class is the same as com.ctrip.hotel.productsearchfilter.ProductPO.class except for the package name.
I serialize a ProductPO object but get a RateDetailPO object, then cause the exception like 'class ...RateDetailPO cannot be cast to class ...ProductPO'.
so,i have two questions:
1.package name must keep same between serialization and deserialization?
2.why i got a RateDetailPO object by deserialization ? I thought i would get a ProductPO object, even though ClassCastException may still occur like 'class ProductPO cannot be cast to class com.ctrip.hotel.productsearchfilter.ProductPO'
Question
I use fury in my projects, in one of the projects i serialize the object of ProductPO.class where fury is created like "furySerializer" in following code, in the other project i deseralize the byte[] using fury like “furyDeSerializer1” in following code.
however,when i deseralize the byte[],an error occurred and made me confused:
my code is like:
The text was updated successfully, but these errors were encountered: