Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gradle-build java-formatter fails on unicode character (api->ProgressBar) when build run in non utf-8 system #493

Closed
ebamberg opened this issue Jan 7, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@ebamberg
Copy link
Contributor

ebamberg commented Jan 7, 2021

Description

gradle build fails on Western-European Windows 10 System runnning gradle from the command line.
java-formatter in the api project finds "unclosed character literal" and throws an exception when formatting ai.djl.training.util.ProgressBar.

resaon: ai.djl.training.util.ProgressBar line 150 return ' ' a utf-8 unicode character.

my machine setup

IsSingleByte : True
BodyName : iso-8859-1
EncodingName : Western European (Windows)
HeaderName : Windows-1252
WebName : Windows-1252
WindowsCodePage : 1252
IsBrowserDisplay : True
IsBrowserSave : True
IsMailNewsDisplay : True
IsMailNewsSave : True
EncoderFallback : System.Text.InternalEncoderBestFitFallback
DecoderFallback : System.Text.InternalDecoderBestFitFallback
IsReadOnly : True
CodePage : 1252

This settings are common settings from windows machine in western europe

Expected Behavior

gradle build successful even on a iso-8859-1 machine.

Error Message

Script 'C:\dev\src\awslabs\djl\tools\gradle\java-formatter.gradle' line: 54

  • What went wrong:
    Execution failed for task ':api:verifyJava'.

com.google.googlejavaformat.java.FormatterException: 150:17: error: unclosed character literal

How to Reproduce?

gradle build on an non utf-8 machine.

Steps to reproduce

(Paste the commands you ran that produced the error.)

  1. cmd
  2. gradlew clean build

What have you tried to solve it?

private static char getProgressChar() {
    if (System.getProperty("os.name").startsWith("Win")) {
        return '=';
    } else if (System.getProperty("os.name").startsWith("Linux")) {
        String lang = System.getenv("LANG");
        if (lang == null || !lang.contains("UTF-8")) {
            return '=';
        }
    }
    **return '>';**
}

I exchanged to special character with a ASCII character. Build runs

  1. I tried to find an option in Google-java-formater to force UtF-8 which is not possible.

Environment Info

Please run the command ./gradlew debugEnv from the root directory of DJL (if necessary, clone DJL first). It will output information about your system, environment, and installation that can help us debug your issue. Paste the output of the command below:

----------- System Properties -----------
sun.desktop: windows
awt.toolkit: sun.awt.windows.WToolkit
java.specification.version: 11
sun.cpu.isalist: amd64
sun.jnu.encoding: Cp1252
java.class.path: C:\dev\src\awslabs\djl\integration\build\classes\java\main;C:\dev\src\awslabs\djl\integration\build\resources\main;C:\Users\erikb.gradle\caches\modules-2\files-2.1\commons-cli\commons-cli\1.4\c51c00206bb913cd8612b24abd9fa98ae89719b1\commons-cli-1.4.jar;C:\Users\erikb.gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-slf4j-impl\2.13.3\7cca27a921a18645139cf651c04b83b1a19cfd76\log4j-slf4j-impl-2.13.3.jar;C:\dev\src\awslabs\djl\basicdataset\build\libs\basicdataset-0.10.0-SNAPSHOT.jar;C:\dev\src\awslabs\djl\model-zoo\build\libs\model-zoo-0.10.0-SNAPSHOT.jar;C:\dev\src\awslabs\djl\testing\build\libs\testing-0.10.0-SNAPSHOT.jar;C:\Users\erikb.gradle\caches\modules-2\files-2.1\org.testng\testng\7.1.0\b0bcea778fb2899aeb4014c558babea8833d180a\testng-7.1.0.jar;C:\dev\src\awslabs\djl\mxnet\mxnet-model-zoo\build\libs\mxnet-model-zoo-0.10.0-SNAPSHOT.jar;C:\dev\src\awslabs\djl\mxnet\mxnet-engine\build\libs\mxnet-engine-0.10.0-SNAPSHOT.jar;C:\Users\erikb.gradle\caches\modules-2\files-2.1\ai.djl.mxnet\mxnet-native-auto\1.7.0-backport\ee5b368ef94c1fcec4ade4a6edacffb420fefce7\mxnet-native-auto-1.7.0-backport.jar;C:\dev\src\awslabs\djl\api\build\libs\api-0.10.0-SNAPSHOT.jar;C:\Users\erikb.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-api\1.7.30\b5a4b6d16ab13e34a88fae84c35cd5d68cac922c\slf4j-api-1.7.30.jar;C:\Users\erikb.gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-core\2.13.3\4e857439fc4fe974d212adaaaa3b118b8b50e3ec\log4j-core-2.13.3.jar;C:\Users\erikb.gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-api\2.13.3\ec1508160b93d274b1add34419b897bae84c6ca9\log4j-api-2.13.3.jar;C:\Users\erikb.gradle\caches\modules-2\files-2.1\org.apache.commons\commons-csv\1.8\37ca9a9aa2d4be2599e55506a6d3170dd7a3df4\commons-csv-1.8.jar;C:\Users\erikb.gradle\caches\modules-2\files-2.1\com.beust\jcommander\1.72\6375e521c1e11d6563d4f25a07ce124ccf8cd171\jcommander-1.72.jar;C:\Users\erikb.gradle\caches\modules-2\files-2.1\com.google.inject\guice\4.1.0\faf9ee8ac09eafd1128091426dd367a8c0085d55\guice-4.1.0-no_aop.jar;C:\Users\erikb.gradle\caches\modules-2\files-2.1\org.yaml\snakeyaml\1.21\18775fdda48574784f40b47bf478ab0593f92e4d\snakeyaml-1.21.jar;C:\Users\erikb.gradle\caches\modules-2\files-2.1\com.google.code.gson\gson\2.8.6\9180733b7df8542621dc12e21e87557e8c99b8cb\gson-2.8.6.jar;C:\Users\erikb.gradle\caches\modules-2\files-2.1\net.java.dev.jna\jna\5.3.0\4654d1da02e4173ba7b64f7166378847db55448a\jna-5.3.0.jar;C:\Users\erikb.gradle\caches\modules-2\files-2.1\org.apache.commons\commons-compress\1.20\b8df472b31e1f17c232d2ad78ceb1c84e00c641b\commons-compress-1.20.jar;C:\Users\erikb.gradle\caches\modules-2\files-2.1\javax.inject\javax.inject\1\6975da39a7040257bd51d21a231b76c915872d38\javax.inject-1.jar;C:\Users\erikb.gradle\caches\modules-2\files-2.1\aopalliance\aopalliance\1.0\235ba8b489512805ac13a8f9ea77a1ca5ebe3e8\aopalliance-1.0.jar;C:\Users\erikb.gradle\caches\modules-2\files-2.1\com.google.guava\guava\19.0\6ce200f6b23222af3d8abb6b6459e6c44f4bb0e9\guava-19.0.jar
java.vm.vendor: Oracle Corporation
sun.arch.data.model: 64
user.variant:
java.vendor.url: https://openjdk.java.net/
user.timezone: Europe/London
os.name: Windows 10
java.vm.specification.version: 11
sun.java.launcher: SUN_STANDARD
user.country: GB
sun.boot.library.path: C:\dev\apps\jdk-11\bin;C:\dev\apps\jdk-11\bin
sun.java.command: ai.djl.integration.util.DebugEnvironment
jdk.debug: release
sun.cpu.endian: little
user.home: C:\Users\erikb
org.gradle.appname: gradlew
user.language: en
java.specification.vendor: Oracle Corporation
java.version.date: 2020-10-20
java.home: C:\dev\apps\jdk-11
ai.djl.logging.level: debug
org.gradle.internal.http.connectionTimeout: 60000
file.separator:
java.vm.compressedOopsMode: Zero based
line.separator:

java.specification.name: Java Platform API Specification
java.vm.specification.vendor: Oracle Corporation
java.awt.graphicsenv: sun.awt.Win32GraphicsEnvironment
user.script:
sun.management.compiler: HotSpot 64-Bit Tiered Compilers
java.runtime.version: 11.0.9+7-LTS
user.name: erikb
path.separator: ;
os.version: 10.0
java.runtime.name: Java(TM) SE Runtime Environment
file.encoding: Cp1252
jnidispatch.path: C:\Users\erikb\AppData\Local\Temp\jna-96776115\jna10506132894072617231.dll
java.vm.name: Java HotSpot(TM) 64-Bit Server VM
java.vendor.version: 18.9
jna.loaded: true
java.vendor.url.bug: https://bugreport.java.com/bugreport/
java.io.tmpdir: C:\Users\erikb\AppData\Local\Temp
org.gradle.internal.http.socketTimeout: 120000
java.version: 11.0.9
user.dir: C:\dev\src\awslabs\djl\integration
os.arch: amd64
java.vm.specification.name: Java Virtual Machine Specification
java.awt.printerjob: sun.awt.windows.WPrinterJob
sun.os.patch.level:
java.library.path: C:\dev\apps\jdk-11\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\dev\apps\jdk-11\bin;C:\dev\apps\python3;C:\dev\apps\python3\Scripts;C:\dev\apps\gradle\bin;C:\dev\apps\maven\apache-maven-3.6.3\bin;C:\dev\apps\git;C:\dev\apps\git\bin;C:\Users\erikb\AppData\Local\Microsoft\WindowsApps;C:\dev\apps\node-v14.15.3-win-x64;;.
java.vendor: Oracle Corporation
java.vm.info: mixed mode
java.vm.version: 11.0.9+7-LTS
sun.io.unicode.encoding: UnicodeLittle
library.jansi.path: C:\Users\erikb.gradle\native\jansi\1.18\windows64
java.class.version: 55.0
org.gradle.internal.publish.checksums.insecure: true

--------- Environment Variables ---------
USERDOMAIN_ROAMINGPROFILE: SILENTBOB
PROCESSOR_LEVEL: 6
SESSIONNAME: Console
ALLUSERSPROFILE: C:\ProgramData
PROCESSOR_ARCHITECTURE: AMD64
PSModulePath: C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
SystemDrive: C:
=ExitCode: 00000000
DIRNAME: C:\dev\src\awslabs\djl
USERNAME: erikb
CMD_LINE_ARGS: debugEnv
ProgramFiles(x86): C:\Program Files (x86)
FPS_BROWSER_USER_PROFILE_STRING: Default
APP_HOME: C:\dev\src\awslabs\djl
PATHEXT: .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
DriverData: C:\Windows\System32\Drivers\DriverData
OneDriveConsumer: C:\Users\erikb\OneDrive
ProgramData: C:\ProgramData
ProgramW6432: C:\Program Files
HOMEPATH: \Users\erikb
PROCESSOR_IDENTIFIER: Intel64 Family 6 Model 126 Stepping 5, GenuineIntel
M2_HOME: C:\dev\apps\maven\apache-maven-3.6.3
ProgramFiles: C:\Program Files
PUBLIC: C:\Users\Public
windir: C:\WINDOWS
=::: ::
_SKIP: 2
LOCALAPPDATA: C:\Users\erikb\AppData\Local
USERDOMAIN: SILENTBOB
FPS_BROWSER_APP_PROFILE_STRING: Internet Explorer
LOGONSERVER: \SILENTBOB
JAVA_HOME: C:\dev\apps\jdk-11
PROMPT: $P$G
OneDrive: C:\Users\erikb\OneDrive
=C:: C:\dev\src\awslabs\djl
APPDATA: C:\Users\erikb\AppData\Roaming
DOWNLOAD_URL: "https://raw.githubusercontent.com/gradle/gradle/master/gradle/wrapper/gradle-wrapper.jar"
JAVA_EXE: C:\dev\apps\jdk-11/bin/java.exe
VBOX_MSI_INSTALL_PATH: C:\Program Files\Oracle\VirtualBox
CommonProgramFiles: C:\Program Files\Common Files
Path: C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\dev\apps\jdk-11\bin;C:\dev\apps\python3;C:\dev\apps\python3\Scripts;C:\dev\apps\gradle\bin;C:\dev\apps\maven\apache-maven-3.6.3\bin;C:\dev\apps\git;C:\dev\apps\git\bin;C:\Users\erikb\AppData\Local\Microsoft\WindowsApps;C:\dev\apps\node-v14.15.3-win-x64;
OS: Windows_NT
NODE_HOME: C:\dev\apps\node-v14.15.3-win-x64
COMPUTERNAME: SILENTBOB
PROCESSOR_REVISION: 7e05
CLASSPATH: C:\dev\src\awslabs\djl\gradle\wrapper\gradle-wrapper.jar
CommonProgramW6432: C:\Program Files\Common Files
ComSpec: C:\WINDOWS\system32\cmd.exe
APP_BASE_NAME: gradlew
SystemRoot: C:\WINDOWS
TEMP: C:\Users\erikb\AppData\Local\Temp
HOMEDRIVE: C:
USERPROFILE: C:\Users\erikb
TMP: C:\Users\erikb\AppData\Local\Temp
CommonProgramFiles(x86): C:\Program Files (x86)\Common Files
NUMBER_OF_PROCESSORS: 8

-------------- Directories --------------
temp directory: C:\Users\erikb\AppData\Local\Temp
Engine cache directory: C:\Users\erikb.djl.ai

------------------ CUDA -----------------
GPU Count: 0
Default Device: cpu()

----------------- Engines ---------------
Default Engine: MXNet
[DEBUG] - Using cache dir: C:\Users\erikb.djl.ai\mxnet
MXNet:1.7.0, capabilities: [
SIGNAL_HANDLER,
LAPACK,
BLAS_OPEN,
OPENMP,
OPENCV,
MKLDNN,
]
MXNet Library: C:\Users\erikb.djl.ai\mxnet\1.7.0-backport-mkl-win-x86_64\mxnet.dll

--------------- Hardware --------------
Available processors (cores): 8
Byte Order: LITTLE_ENDIAN
Free memory (bytes): 220673040
Maximum memory (bytes): 4217372672
Total memory available to JVM (bytes): 264241152
Heap committed: 264241152
Heap nonCommitted: 31326208

@ebamberg ebamberg added the bug Something isn't working label Jan 7, 2021
@lanking520
Copy link
Contributor

We tried to fixed here: #479, @frankfliu Should we consider just make it ascii?

@frankfliu
Copy link
Contributor

@lanking520 This is a bug in format-java plugin. I will take a look.

frankfliu added a commit to frankfliu/djl that referenced this issue Jan 7, 2021
Change-Id: I22aeed521566832c522c3baf190517dd9fde63d5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants