redhat-developer / redhat-developer/vscode-java

Visual Studio Code's Java Compiler Not Showing Certain Errors

Offen
#1,185 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

compile
Vorherrschende Sprache
TypeScript
Sterne
2.3k
Forks
546
Ø Merge
20 Std. 1 Min.
Gemergte PRs (30 T.)
11

Beschreibung

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
  1. 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.

  2. 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.

VSCodeBugReport

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginnen Sie damit, den Konflikt generischer Typen von HashMap in Visual Studio Code mit einer Deklaration eines Klassenmembers zu reproduzieren, und verwenden Sie dabei die aufgeführten Versionen von Java und der Extension. Vergleichen Sie die angezeigte Compiler-Ausgabe mit den erwarteten Diagnosen für Typkonflikte und Methodenargumente; abgeschlossen ist die Aufgabe, wenn diese Fehler und ihre Quellpositionen angezeigt werden, einschließlich der anderen aufgeführten Collection-Fälle.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java, vscode
Bereich
developer-experience, tooling
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.