redhat-developer / redhat-developer/vscode-java

Java compiler problem with enums using windows1252 encoding

Offen
#3,060 14 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

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

Beschreibung

So I'm trying to migrate from eclipse to vs code, all my projects are usually created using windows1252 for java files and utf8 for build/html/xhtml files, but when I try to run some projects that have special characters on enum names the compiler reports Syntax error for every single one of them, but when I open the files all the error messages disappear, if I close the file they return.

erro1

workspace

Workspace Settings
"settings": {
	"files.autoGuessEncoding": true,
	"java.configuration.updateBuildConfiguration": "automatic",
	"explorer.autoReveal": false
	"[java]": {
		"files.encoding": "windows1252"
	}
}
Preferences Settings
"java.jdt.ls.vmargs": "-Dfile.encoding=windows1252 -XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx1G -Xms100m -javaagent:\"c:\\Users\\berna\\.vscode\\extensions\\gabrielbb.vscode-lombok-1.0.1\\server\\lombok.jar\"",
"rsp-ui.rsp.java.home": "C:\\R2DA\\java\\jdk-11.0.10",
"[java]": {
	"files.encoding": "windows1252"
},
"files.encoding": "windows1252",
"sonarlint.ls.javaHome": "C:\\R2DA\\java\\jdk-11.0.10",
"spring-boot.ls.java.home": "C:\\Program Files\\Java\\jdk-17",
"java.import.gradle.java.home": "C:\\R2DA\\java\\jdk-11.0.10",
"java.project.encoding": "setDefault",
"java.jdt.ls.java.home": "C:\\Program Files\\Java\\jdk-17",
"java.configuration.runtimes": [
	{
		"name": "JavaSE-11",
		"path": "C:\\R2DA\\java\\jdk-11.0.10",
		"default": true,
	}
],
"spring-boot.ls.java.vmargs": [
	"-Dfile.encoding=windows1252"
],
"java.debug.settings.vmArgs": "-Dfile.encoding=windows1252",
Spring Dashboard Application Start Log
PS C:\R2DA\recivil\api-sistema-registro>  & 'C:\R2DA\java\jdk-11.0.10\bin\java.exe' '@C:\Users\berna\AppData\Local\Temp\cp_2u4mmuey7f1wwsl3uwa1ds5ug.argfile' 'api.sistema.registro.ApiSistemaRegistroApplication'
...
nested exception is java.lang.IllegalArgumentException: api.entidade.sistema.registro.enums.EnumPermissoes is not an enum type
        at api.sistema.registro.ApiSistemaRegistroApplication.main(ApiSistemaRegistroApplication.java:12) ~[main/:na]
Caused by: java.lang.IllegalArgumentException: api.entidade.sistema.registro.enums.EnumPermissoes is not an enum type
        at java.base/java.lang.Class.enumConstantDirectory(Class.java:3578) ~[na:na]
        at java.base/java.lang.Enum.valueOf(Enum.java:234) ~[na:na]
        at org.springframework.core.type.classreading.MergedAnnotationReadingVisitor.visitEnum(MergedAnnotationReadingVisitor.java:105) ~[spring-core-5.2.12.RELEASE.jar:5.2.12.RELEASE]
        at org.springframework.core.type.classreading.MergedAnnotationReadingVisitor$ArrayVisitor.visitEnum(MergedAnnotationReadingVisitor.java:171) ~[spring-core-5.2.12.RELEASE.jar:5.2.12.RELEASE]
        at org.springframework.asm.ClassReader.readElementValue(ClassReader.java:3056) ~[spring-core-5.2.12.RELEASE.jar:5.2.12.RELEASE]
        at org.springframework.asm.ClassReader.readElementValues(ClassReader.java:2981) ~[spring-core-5.2.12.RELEASE.jar:5.2.12.RELEASE]
        at org.springframework.asm.ClassReader.readElementValue(ClassReader.java:3155) ~[spring-core-5.2.12.RELEASE.jar:5.2.12.RELEASE]
        at org.springframework.asm.ClassReader.readElementValues(ClassReader.java:2975) ~[spring-core-5.2.12.RELEASE.jar:5.2.12.RELEASE]
        at org.springframework.asm.ClassReader.readMethod(ClassReader.java:1393) ~[spring-core-5.2.12.RELEASE.jar:5.2.12.RELEASE]
        at org.springframework.asm.ClassReader.accept(ClassReader.java:718) ~[spring-core-5.2.12.RELEASE.jar:5.2.12.RELEASE]
        at org.springframework.asm.ClassReader.accept(ClassReader.java:401) ~[spring-core-5.2.12.RELEASE.jar:5.2.12.RELEASE]
        at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:49) ~[spring-core-5.2.12.RELEASE.jar:5.2.12.RELEASE]
        at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:103) ~[spring-core-5.2.12.RELEASE.jar:5.2.12.RELEASE]
        at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:123) ~[spring-core-5.2.12.RELEASE.jar:5.2.12.RELEASE]
        at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.scanCandidateComponents(ClassPathScanningCandidateComponentProvider.java:429) ~[spring-context-5.2.12.RELEASE.jar:5.2.12.RELEASE]
        ... 21 common frames omitted
Environment
  • Operating System: Windows 11 22H2
  • JDK version: 17.0.6 and 11.0.10
  • Visual Studio Code version: 1.77.2
  • Java extension version: Project Manager for Java v0.21.2 Debugger for Java v0.49.1 | Language Support for Java(TM) by Red Hat v1.16.0
Project Settings
  • Gradle 6.3
  • Java 11
  • Spring Boot 2.3.8.RELEASE
Steps To Reproduce
  1. Create a enum using windows1252 encoding and characters like ç ã é ú...
  2. Close the file and reload the project

Sample project for testing:
https://github.com/bernardomoraisbh/api-test

VS Code redhat.java/jdt_ws/.metadata/.log file:

https://pastebin.pl/view/e222cc93

Current Result

Compiler not working properly and error when running my spring projects over the Spring Dashboard Extension.

Expected Result

No compile errors and projects inside my workspace should be compiled with windows1252 encoding.

Additional Informations

I tried using the "spring-boot.ls.java.vmargs" settings for passing the encoding arg for the Spring Boot Dashboard extension, but I don't think it's working properly, since when I try to run the application over the dashboard I got only this args " & 'C:\R2DA\java\jdk-11.0.10\bin\java.exe' '@C:\Users\berna\AppData\Local\Temp\cp_2u4mmuey7f1wwsl3uwa1ds5ug.argfile' 'api.sistema.registro.ApiSistemaRegistroApplication'" and as soon as the application fails to start the file cp_2u4mmuey7f1wwsl3uwa1ds5ug.argfile is erased from the file system.

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 mit dem verknüpften api-test-Beispielprojekt und reproduzieren Sie das Problem mit den aufgeführten Windows-, JDK-, Gradle- und VS Code-Einstellungen. Lesen Sie die Ausgabe von redhat.java/jdt_ws/.metadata/.log und vergleichen Sie die Projektkodierung mit der Start-argfile von Spring Dashboard. Erledigt ist die Aufgabe, wenn das Beispielprojekt mit windows1252-kodierten Java-Enums kompiliert und startet, nachdem die Dateien geschlossen wurden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

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

Neue Issues direkt in Ihr Postfach

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