-
Notifications
You must be signed in to change notification settings - Fork 26
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
String.format with locale option does not work after being jlinked. #154
Comments
Add |
Or, if you don't want to change your module-info.java, add the
|
Serban,
This does the trick. Thank you.
How could I find this missing requires myself?
Regards,
Ronald
From: "Serban Iordache" <[email protected]>
To: "beryx/badass-jlink-plugin"
<[email protected]>
Cc: "RonaldAtWork" <[email protected]>, "Author"
<[email protected]>
Date: 29-09-2020 12:20
Subject: Re: [beryx/badass-jlink-plugin] String.format with locale
option does not work after being jlinked. (#154)
Add requires jdk.localedata; to your module-info.java.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub [github.com], or
unsubscribe [github.com].
Confidentiality & Disclaimer Notice:
This email and any attached files are private and confidential, intended
solely for the use of those to whom it is addressed. If you are not the
intended recipient, you may not copy, forward, use, rely on or distribute
this message or any attachments. Unauthorised disclosure of any
information contained in this communication is prohibited. Please inform
the sender if you have received this email in error.
Nothing in this email amounts to a contractual or other legal commitment
on our part unless confirmed expressly in writing by an authorised Officer
of the Company.
The views expressed in this email may not necessarily reflect the views of
the Company.
WARNING:
The recipient should check this email and any attachments for the
presence of viruses.
We do not accept responsibility for any virus transmitted by this email.
|
I don't have a good answer to this question. Locales other than English are made available via a service, for which an implementation is provided by the jdk.localedata module. This is a rather obscure thing and it's not easy to find that this module is missing because Java silently falls back to the default locale. To avoid similar issues, you can tell jlink to automatically bind all JDK modules that provide a service:
The downside is that you may end up with an image that includes some unused JDK modules. |
Again thank you very much for your help. My applications works now like
expected.
From: "Serban Iordache" <[email protected]>
To: "beryx/badass-jlink-plugin"
<[email protected]>
Cc: "RonaldAtWork" <[email protected]>, "Author"
<[email protected]>
Date: 29-09-2020 16:23
Subject: Re: [beryx/badass-jlink-plugin] String.format with locale
option does not work after being jlinked. (#154)
I don't have a good answer to this question. Locales other than English
are made available via a service, for which an implementation is provided
by the jdk.localedata module. This is a rather obscure thing and it's not
easy to find that this module is missing because Java silently falls back
to the default locale.
To avoid similar issues, you can tell jlink to automatically bind all JDK
modules that provide a service:
options = ['--bind-services', '--strip-debug', '--compress', '2',
'--no-header-files', '--no-man-pages']
The downside is that you may end up with an image that includes some
unused JDK modules.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub [github.com], or
unsubscribe [github.com].
Confidentiality & Disclaimer Notice:
This email and any attached files are private and confidential, intended
solely for the use of those to whom it is addressed. If you are not the
intended recipient, you may not copy, forward, use, rely on or distribute
this message or any attachments. Unauthorised disclosure of any
information contained in this communication is prohibited. Please inform
the sender if you have received this email in error.
Nothing in this email amounts to a contractual or other legal commitment
on our part unless confirmed expressly in writing by an authorised Officer
of the Company.
The views expressed in this email may not necessarily reflect the views of
the Company.
WARNING:
The recipient should check this email and any attachments for the
presence of viruses.
We do not accept responsibility for any virus transmitted by this email.
|
It would be nice to have the plugin understand jlink's --include-locales option to get a bit smaller image with only required locales. |
String.format(locale, "%.1f", 10.1) should produce 10,1 (with a comma) for German or Dutch locale. It does when run in Netbeans IDE or when compiled with javac and run with java from command line.
java TestStringFormatLocale.Main Output:
Not localized: 10.1
en_US: 10.1
de: 10,1
nl_NL: 10,1
But the result is wrongly output as 10.1 (with a point) after being jlinked. This is very strange and a showstopper for distributing my code.
build\image\bin\TestStringFormatLocale Output:
Not localized: 10.1
en_US: 10.1
de: 10.1
nl_NL: 10.1
My code for testing:
//=================================================================
Main.java
//==============================================================
package TestStringFormatLocale;
import java.util.Locale;
public class Main {
public static void main(String[] args) {
double x = 10.1;
Locale locale = Locale.getDefault();
System.out.println("Not localized: " + String.format("%.1f", x));
System.out.println(locale.toString() + ": " + String.format(locale, "%.1f", x));
locale = Locale.GERMAN;
System.out.println(locale.toString() + ": " + String.format(locale, "%.1f", x));
locale = new Locale("nl", "NL");
System.out.println(locale.toString() + ": " + String.format(locale, "%.1f", x));
}
}
//=================================================================
module-info.java
//=================================================================
module TestStringFormatLocale {
exports TestStringFormatLocale;
}
//=================================================================
build.gradle
//=================================================================
plugins {
id 'java'
id 'jacoco'
id 'application'
id 'org.beryx.jlink' version '2.22.0'
}
application {
mainModule = 'TestStringFormatLocale' // name defined in module-info.java
mainClass = "TestStringFormatLocale.Main"
}
repositories {
jcenter()
}
dependencies {
testImplementation 'junit:junit:4.13'
}
jlink {
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
launcher {
name = 'TestStringFormatLocale'
}
}
//=================================================================
The text was updated successfully, but these errors were encountered: