redhat-developer / redhat-developer/vscode-java

Java compiler problem with enums using windows1252 encoding

オープン
#3,060 コメント 14 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
TypeScript
スター
2.3k
フォーク
546
平均マージ
20時間 1分
マージ済み PR(30日)
11

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

リンクされた api-test サンプルプロジェクトから始め、記載された Windows、JDK、Gradle、VS Code の設定を使って問題を再現してください。redhat.java/jdt_ws/.metadata/.log の出力を読み、プロジェクトのエンコーディングと Spring Dashboard の起動 argfile を比較してください。ファイルを閉じた後に、windows1252 でエンコードされた Java enum を含むサンプルプロジェクトがコンパイルおよび起動すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java, typescript, vscode
領域
tooling
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。