As part of debugging an application, I noticed that Field.getDeclaredFields() returns some synthetic fields, including a serialVersionUID field in a class extending an interface, although none extend Serializable.
Why does the compiler add such fields?
UPDATE
In fact, there is also a $VRc synthetic field created.
The Java compiler/runtime will not automatically create a serialVersionUID field. I suspect that you are using some form of bytecode enchancement framework under the hood that is being instructed to add the synthetic fields either at runtime, or during compilation.
The
$VRcfield is produced by the Emma instrumentation framework, so that would be the reason for at least one of the synthetic fields.The
serialVersionUIDfield is also added by Emma, when theinstr.do_suid_compensationproperty is set to true.