This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 208005 - Add hint for transient with initializer
Summary: Add hint for transient with initializer
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 7.1
Hardware: All All
: P3 normal with 1 vote (vote)
Assignee: Svata Dedic
Depends on:
Reported: 2012-02-02 04:26 UTC by bondolo
Modified: 2013-09-02 14:22 UTC (History)
0 users

See Also:
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description bondolo 2012-02-02 04:26:20 UTC
transient fields are not initialized upon deserialization. This means:

class Foo {
transient int bar = Integer.MIN_VALUE;

will have the value zero rather than Integer.MIN_VALUE upon deserialization unless the field is specifically initialized during the readObject() method.

It's worth pointing out transient fields with initializers as possible errors because users may expect that they will be run for every instance created.