redhat-developer / redhat-developer/vscode-java
Java compiler problem with enums using windows1252 encoding
Personne n'a encore pris cette issue.
- Langage dominant
- TypeScript
- Étoiles
- 2.3k
- Forks
- 546
- Merge moyen
- 20 h 1 min
- PR mergées (30 j)
- 11
Description
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.


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
- Create a enum using windows1252 encoding and characters like ç ã é ú...
- 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.
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par le projet d’exemple api-test lié et reproduisez le problème avec les paramètres Windows, JDK, Gradle et VS Code indiqués. Lisez la sortie de redhat.java/jdt_ws/.metadata/.log et comparez l’encodage du projet avec l’argfile de lancement de Spring Dashboard. Le travail est terminé lorsque le projet d’exemple se compile et démarre avec des enums Java encodés en windows1252 après la fermeture des fichiers.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- java, typescript, vscode
- Domaine
- tooling
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100