Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code Java: Disable serialVersionUID warning

I'm taking a Computer Science class where the assignment boilerplate code is a Java framework where most of the classes (or their superclasses) extend Serializable. What ends up happening then is VSCode complains to me that

The serializable class [insert class name here] does not declare a static final serialVersionUID field of type long"

for nearly all the starting code. I know in other IDEs such as IntelliJ and Eclipse, this specific warning can be suppressed for all Java projects. What would be the equivalent operation in VSCode? I have the Language Support for Java package installed.

The following are reasons why I cannot declare a serialVersionUID or use @SuppressWarnings:

  1. This would force me to modify code which I am not allowed to modify. The prof only wants students to implement certain areas of the framework.

  2. I would need to make these changes to about 30 classes which is less than ideal.

like image 320
Ozymandias Avatar asked Apr 05 '18 08:04

Ozymandias


People also ask

How do I turn off warnings in Vscode?

To disable TypeScript warnings in VS Code, we can set a few options in our VS Code settings to disable them. { //... "typescript. validate. enable": false, "javascript.

How do I ignore a problem in Vscode?

First option: just use // @ts-ignore If it is only place where the error occure just add on previouse line // @ts-ignore . This will disable error only in that place. If further down in the code such error will be found it will be shown as error in problem tab.


1 Answers

Currently Java Support for VSCode reads a file called .settings/org.eclipse.jdt.core.prefs as part of its Eclipse project support. That's a folder called .settings in the root folder of the project, then a file called org.eclipse.jdt.core.prefs in that folder.

In this file, we can suppress the serialVersionUID warning by adding the following line: org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore

Now just restart VS Code, and those warnings will no longer show up.

like image 158
Ozymandias Avatar answered Oct 23 '22 15:10

Ozymandias