0

I'm using Java in VS Code and am getting warnings in the PROBLEMS tab.

'_' should not be used as an identifier, since it is a reserved keyword from source level 1.8 on
Type safety: The method put(Object, Object) belongs to the raw type Hashtable. References to generic type Hashtable<K,V> should be parameterized

Other ones also.

How can I disable them?

There seems to be an integer identifier at the end of each message - seems to be associated with the message type.

Some people have suggested looking at the .settings file and add something like

org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore

But I haven't found something related to my warnings - is there a complete list somehwer of these eclipse problem strings.

dashman
  • 2,858
  • 3
  • 29
  • 51
  • Are you saying there is not a source file and line number with each warning? – VGR May 11 '20 at 01:43
  • yes there's a reference to a file and line-number. But I'd like to disable the warning. – dashman May 11 '20 at 02:06
  • 3
    Java warnings usually indicate that code is syntactically valid but logically incorrect. Those two warnings, and pretty much every Java warning, are things you’re better off fixing than suppressing. – VGR May 11 '20 at 02:13
  • @greg-449 In VS Code the Java support is headless Eclipse via LSP. That's why this VS Code question is tagged with [eclipse]. – howlger May 11 '20 at 07:51
  • That warning cannot be disabled since it's an compile error indicating invalid Java code. – howlger May 11 '20 at 07:53

1 Answers1

-3

You'd better fix it, instead of suppress it.

The first warning: Through this doc, you'd better not use '_' as an identifier, otherwise you will get an warning even an error. You can also get more information from this page.

The second warning is because you haven't added 'generic parameters', like this one:

HashMap map =newHashMap();
map.put("showOppo", option.isShowOppo());

And you can change like this to avoid it:

HashMap<String,String> map =newHashMap<>();
Steven-MSFT
  • 7,438
  • 1
  • 5
  • 13
  • This does not answer the question asked. The question was very clear, how to suppress warnings, preferably specific warning types. There are legit reasons for wanting to suppress certain warnings, for instance in automatically generated code. – leopignataro Apr 21 '22 at 15:34