Functional interface with default behavior with Serializable

When an interface without a method extends Serializable by default, everything works fine. But if the default method is used for this interface, we have a warning saying:

MyInterface.java: the serializable class MyInterface does not have a definition of serialVersionUID

He gained interest when I change this interface to an abstract class. The error will disappear.

To summarize the table, do the following:

|----------------------------|------------------|
|            Type            |      WARNING     |
|----------------------------|------------------|
| interface with no defaults |         NO       |
|----------------------------|------------------|
| interface with defaults    |        YES       |
|----------------------------|------------------|
| abstract class             |         NO       |
|----------------------------|------------------|

Is there a reason for this or is it just a mistake?

+4
source share

Source: https://habr.com/ru/post/1689560/


All Articles