Effective Java



Download 2,19 Mb.
Pdf ko'rish
bet308/341
Sana11.07.2022
Hajmi2,19 Mb.
#776765
1   ...   304   305   306   307   308   309   310   311   ...   341
Bog'liq
Effective Java



ITEM 86: IMPLEMENT SERIALIZABLE WITH GREAT CAUTION
345
Classes designed for inheritance that do implement 
Serializable
include
Throwable
and 
Component

Throwable
implements 
Serializable
so RMI can
send exceptions from server to client. 
Component
implements 
Serializable
so
GUIs can be sent, saved, and restored, but even in the heyday of Swing and AWT,
this facility was little-used in practice.
If you implement a class with instance fields that is both serializable and
extendable, there are several risks to be aware of. If there are any invariants on the
instance field values, it is critical to prevent subclasses from overriding the
finalize
method, which the class can do by overriding 
finalize
and declaring it
final. Otherwise, the class will be susceptible to 
finalizer attacks (
Item 8). Finally,
if the class has invariants that would be violated if its instance fields were
initialized to their default values (zero for integral types, 
false
for 
boolean
, and
null
for object reference types), you must add this 
readObjectNoData
method:

Download 2,19 Mb.

Do'stlaringiz bilan baham:
1   ...   304   305   306   307   308   309   310   311   ...   341




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish