简体   繁体   中英

Java: calling super.clone() method, volatile int value not copied in cloned object

I faced one production bug (it happened only once at least in last 1 year). After investigation I can conclude that super.clone() method was unable to copy an "volatile int" value to the new cloned object .

Does anyone faced this problem ever?

clone() method is widely used in jdk libraries and this is a basic thing that clone method guarantees. Can this happen?

It's not safe to clone volatile data. Please see this post for side effects of cloning.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM