javaeclipsecommentsserializableserialversionuid

Getting rid of the comment above Eclipse-generated serialVersionUID


This has become a pet peeve of mine. I write a class, and implement Serializible. Then eclipse warns me that I don't have a serialVersionUID, so I select "Add generated serialVersionUID" or "Add default serialVersionUID" and I end up with something like this:

  /**
   * 
   */
  private static final long serialVersionUID = 4049849541314027178L;

Most of the time I don't want to add a comment, so I have to go and delete the comment. I would rather the default be no comment, but I've looked through the code templates in preferences and haven't figured out how to change this. I simply want it to look like this:

  private static final long serialVersionUID = 4049849541314027178L;

Solution

  • It's using the template for any eclipse-generated field.

    You can change it in

     Preferences -> 
         Java -> 
            Code Style -> 
               Code Templates -> 
                  Comments -> 
                     Fields
    

    ... either globally or per-project.