Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 343858 - Missing serialVersionUID warning should not be shown for anonymous inner classes
Summary: Missing serialVersionUID warning should not be shown for anonymous inner classes
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P3 normal with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact: Ayushman Jain CLA
URL:
Whiteboard: stalebug
Keywords:
: 426320 (view as bug list)
Depends on:
Blocks: 426320
  Show dependency tree
 
Reported: 2011-04-26 10:32 EDT by musor102 CLA
Modified: 2019-10-12 11:55 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description musor102 CLA 2011-04-26 10:32:34 EDT
Build Identifier: M20110210-1200

Per Java spec, serialization of inner classes is discouraged. Correct serialization/deserialization of an inner anonymous class is impossible. Sun admitted as much - Java Bug ID 4862448 requesting this feature was closed as "Not a Defect".
Therefore "missing serialVersionUID" warning when such class is derived from a serializable base class is unnecessary. Presence of this superfluous warning, however, discourages, for example, this concise syntax for map init:
Map<String, String> map = new HashMap<String, String>() {{
   put("Harry", "Potter");
   put("Ron", "Weasley");
   put("Hermione", "Granger");
}};
This syntax produces an anonymous inner class derived from HashMap and overrides its default constructor. serialVersionUID is a very useful warning, but in this case it should not be displayed.

Reproducible: Always

Steps to Reproduce:
1. paste above example into code
2. Observe the warning
Comment 1 Sebastian Dietrich CLA 2014-01-22 03:23:59 EST
This warning should not be shown for any kind of inner classes (not only anonymous inner classes)

On the contraty, we should get a warning if we provida a serialVersioNUID for inner classes.
Comment 2 Dani Megert CLA 2014-01-22 06:46:31 EST
*** Bug 426320 has been marked as a duplicate of this bug. ***
Comment 3 Eclipse Genie CLA 2019-10-12 11:55:02 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.