To explain it further from the first answer, the auto-generated comments for the serialVersionUID
is simply a comment template generation that applies to all fields, including this one. It runs when you generate element comment (Alt+Shift+J) for that field from the Source section of the Toolbar.
The important fact is that the generation of field comments also runs automatically when you quick-fix
The serializable class [ClassName]
does not declare a static final serialVersionUID field of type long"
Disabling/changing generated comments for all fields
You can prevent the generation of comments for all fields by clicking edit and blanking the comment after performing what the original answerer @slim answered, as in
Toolbar -> Window -> Preferences -> Java -> Code Style -> Code Templates -> Comments -> Fields
After quick-fixing the serializable warning, note that the comment is no longer auto-generated.
Disabling/changing the automatic generation of the comment just for SerialVersionUID
Unfortunately, there is no option to prevent the auto-generation of comments for the SerialVersionUID
through quick-fixing without blanking the comment generation template for all fields. There is no such option when searching for "Comment" or "Serial" in Preferences.
Fortunately, it doesn't matter much since for other fields, it generates only when you generate element comment for that field. And you can also prefer to comment or Javadoc fields manually.
Example
This code excerpt (only fields shown) shows that warning about serialization.
public class SomePanel extends JPanel {
private String name;
/* ... */
}
You quick-fix this warning, and you generate element comment the name
field. Without blanking the template, you get this, which you do not want for serialVersionUID
:
public class SomePanel extends JPanel {
/**
*
*/
private static final long serialVersionUID = -5173652620102412871L;
/**
*
*/
private String name;
/* ... */
}
After blanking the template for comment generation of fields, you get, as expected:
public class SomePanel extends JPanel {
private static final long serialVersionUID = 1L;
private String name;
/* ... */
}