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 123275 - Unused method hint should ignore Java serialization readObject/writeObject methods
Summary: Unused method hint should ignore Java serialization readObject/writeObject me...
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.2
Hardware: PC Windows 10 x64
: P4 blocker with 3 votes (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-03 17:50 UTC by wrprice
Modified: 2016-07-26 19:37 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Screenshot of IDE hint (10.08 KB, image/jpeg)
2007-12-03 17:51 UTC, wrprice
Details

Note You need to log in before you can comment on or make changes to this bug.
Description wrprice 2007-12-03 17:50:22 UTC
Java serialization specifies two specific, special private method signatures for customizing object serialization
(separate from the Externalizable interface):

    private void readObject(ObjectInputStream in)
        throws IOException, ClassNotFoundException

    private void writeObject(ObjectOutputStream out)
        throws IOException

NB IDE 6.0 is hinting that these methods are unused.  Though technically correct, since application code should not call
these methods directly, the methods might actually be invoked by the JVM if the object implements/inherits the
Serializable interface.
Comment 1 wrprice 2007-12-03 17:51:19 UTC
Created attachment 53793 [details]
Screenshot of IDE hint
Comment 2 tp 2008-12-12 09:04:20 UTC
This is actually a bug. An inexperienced programmer might believe the false information given by the editor and remove
the readObject or writeObject method. The removal would not cause failure in compilation and would only be revealed if
the serialization code in question is properly tested.
Comment 3 Martin Balin 2016-07-07 07:17:26 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss
Comment 4 faramir2 2016-07-26 17:28:57 UTC
The bug (hint about unused readObject/writeObject methods) is still in the 8.2 version of NetBeans. NetBeans should check if class is Serializable and if so, do not generate that hint for these methods:

 private void readObject(java.io.ObjectInputStream stream)
     throws IOException, ClassNotFoundException;
 private void writeObject(java.io.ObjectOutputStream stream)
     throws IOException
 private void readObjectNoData()
     throws ObjectStreamException;

Product Version: NetBeans IDE Dev (Build 201607260002)
Comment 5 Svata Dedic 2016-07-26 19:37:44 UTC
Apologies, I've made a typo in serialization signatures. Thanks for catching the defect! 

Fixed in jet-main#8292dafacc39