问题
When I define the following class
public class Outer extends Outer.Inner {
public static class Inner { }
}
Netbeans 6.9.1 gives me the "has no definition of serialVersionUID" warning for both Outer and Inner. I'm wondering if there is a legit reason for this warning, or if it's a bug. What about extending an inner class makes the compiler think they are implementing Serializable?
Note: This is more out of curiosity than wanting this unnecessary design pattern.
回答1:
I've wondered the same thing myself. In lieu of an answer, I turned off the warning.
Tools -> Options Menu Hints Tab -> Standard Javac warnings Uncheck the serialization checkbox.
Now you'll have to be careful when extending Serialized Objects, but it stops annoying you about things that aren't serialized.
来源:https://stackoverflow.com/questions/6078806/inexplicable-netbeans-serializable-warning-for-nested-base-class