Skip to content

Suppress Specific Warnings. Ex: "The serializable class [class name] does not declare a static final serialVersionUID field of type long" #493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ozyman42 opened this issue Apr 5, 2018 · 2 comments

Comments

@ozyman42
Copy link

ozyman42 commented Apr 5, 2018

Currently I'm trying to suppress a warning that is appearing all over my project in multiple different classes:

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

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 + Language Support for Java extension.

The following are reasons why I cannot declare a serialVersionUID or use @SuppressWarnings, and instead need to suppress the warning for all files open in the VSCode editor:

  1. Writing the @SuppressWarnings 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.

Environment
  • Operating System: Windows 10
  • JDK version: 1.8
  • Visual Studio Code version: 1.21.1
  • Java extension version: 0.22.0
Steps To Reproduce
  1. Create Java project
  2. Create class which extends Serializable.

Example below of Messages.java, where Message extends Serializable.

package dslabs.pingpong;

import dslabs.framework.Message;
import dslabs.pingpong.PingApplication.Ping;
import dslabs.pingpong.PingApplication.Pong;
import lombok.Data;

@Data
class PingRequest implements Message {
	private final Ping ping;
}

@Data
class PongReply implements Message {
	private final Pong pong;
}

In VSCode, I see that PingRequest and PongReply are both underlined in red.

Current Result

Class name has red underline beneath it. VS Code claims that there is an error because a static final serialVersionUID is not present in the class

Expected Result

There should be a way, such as a setting, where certain particular warnings can be suppressed for all java projects. This feature is available in Eclipse and IntelliJ

Ideally I could modify an extension configuration variable such as:

java.suppressedWarnings = ["serial"]
@ozyman42 ozyman42 changed the title Suppress Specific Warning. Ex: "" Suppress Specific Warnings. Ex: "The serializable class [class name] does not declare a static final serialVersionUID field of type long" Apr 5, 2018
@fbricon
Copy link
Collaborator

fbricon commented Apr 5, 2018

vscode-java doesn't currently expose a way to change messages severity. You need to manually tweak your project's .settings/org.eclipse.jdt.core.prefs as explained in
eclipse-jdtls/eclipse.jdt.ls#581 (comment)

@ozyman42
Copy link
Author

ozyman42 commented Apr 6, 2018

Thanks!

@ozyman42 ozyman42 closed this as completed Apr 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants