redhat-developer / redhat-developer/vscode-java
Visual Studio Code's Java Compiler Not Showing Certain Errors
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.3k
- Forks
- 546
- Avg merge
- 20h 1m
- Merged PRs (30d)
- 11
Description
Description of the Issue
When running Java code I have noticed that certain compile time errors will not be displayed.
Environment
- Operating System: Windows x64 10
- JDK version: 11.0.4.11
- Visual Studio Code version: 1.41.1
- Java extension version: 0.8.1
- Java Debugger extension version: 0.23.0
Steps To Reproduce
-
Declare the HashMap like,
HashMap<dataTypeA, dataTypeB> name = new HashMap<dataTypeC, dataTypeD>();
Where dataType A - D could be any data type I want it to be. -
The bug only occurs when dataTypeC is different from dataTypeA and or dataTypeD is different from dataTypeB.
Current Result
The compiler displays,
`Exception in thread "main" java.lang.Error: Unresolved compilation problem:
at Test.main(Test.java:10)`
Expected Result
The compiler should display,
Unresolved compilation problems:
Type mismatch: cannot convert from HashMap<dataTypeA,dataTypeB> to HashMap<dataTypeC,dataTypeD>
The method put(dataTypeA,dataTypeB) in the type HashMap<dataTypeC,dataTypeD> is not applicable for the arguments (dataTypeA,dataTypeB)
Additional Informations
If I want to see the error message then I have to read the class file in order to determine what the error is and what line it is on. The bug will only occur if the data structure is declared as a class member. I have been able to reproduce this bug with other data structures such as ArrayList, 1D list, and 2D list.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the HashMap generic-type mismatch in Visual Studio Code with a class-member declaration, using the Java and extension versions listed. Compare the displayed compiler output with the expected type-mismatch and method-argument diagnostics; done means those errors and their source locations are shown, including for the other listed collection cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, vscode
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100