[ANN] JRS gwt-time 1.4.8 release

119 views
Skip to first unread message

foal

unread,
May 10, 2020, 6:35:14 PM5/10/20
to GWT Users
Hi,

JRS gwt-time 1.4.8 was released - details on https://github.com/foal/gwt-time/releases/tag/1.4.8

Best,
Stas

Thomas Broyer

unread,
May 11, 2020, 7:03:08 AM5/11/20
to GWT Users
I see you provide your own version of java.util.Locale; please don't, this is a recipe for disaster (behavior depends on the order of entries in the classpath and/or gwt.xml, will break as soon as GWT's JavaEmul updates its version, etc.)
IMO, because we cannot "polyfill" Java classes, we should use "ponyfills" instead (i.e. helper methods where you pass the target object as argument).

foal

unread,
May 14, 2020, 1:30:11 AM5/14/20
to GWT Users
Hi,

Yes, I have and not happy with it. Can I ask how to emulate some Java methods that required Locale as a parameter? The GWT version is not enough. My version can cause problems. At least I need to describe it correctly on the project page.

Is there any way to correctly extend/replace core GWT emulation?

Best,
Stas

foal

unread,
May 14, 2020, 1:35:49 AM5/14/20
to GWT Users
Hi,

I checked the referred issue. At least I will separate the Locale emulation to the side project. It will allow easying to exclude/replace if necessary.

Best,
Stas

On Monday, May 11, 2020 at 1:03:08 PM UTC+2, Thomas Broyer wrote:

foal

unread,
May 14, 2020, 2:01:41 AM5/14/20
to GWT Users
Do you mean instead of 


java.time.format.SimpleDateTimeFormatStyleProvider.getFormatter(FormatStyle, FormatStyle, Chronology, Locale)

Add 

public class LocaleHelper {
public DateTimeFormatter getFormatter(FormatStyle dateStyle, FormatStyle timeStyle, Chronology chrono, MyLocale locale) {
//bla-bla-bla
return result;
}

}

And ask users to call this method if they want to provide other Locale than ROOT and US?

And do it for ALL methods that take java.util.Locale as an argument?

Best,
Stas.

Jens

unread,
May 14, 2020, 3:33:25 AM5/14/20
to GWT Users

Is there any way to correctly extend/replace core GWT emulation?

You have to contribute it to GWT SDK so there is only a single emulation for everyone of that Java SDK class. As soon as you replace a GWT SDK emulation things can break badly.

-- J.

Thomas Broyer

unread,
May 14, 2020, 5:58:48 AM5/14/20
to GWT Users


On Thursday, May 14, 2020 at 7:30:11 AM UTC+2, foal wrote:
Hi,

Yes, I have and not happy with it. Can I ask how to emulate some Java methods that required Locale as a parameter? The GWT version is not enough. My version can cause problems. At least I need to describe it correctly on the project page.

I don't mean introducing a new kind of Locale.
For example, you've added toLanguageTag as an instance method, and getAvailableLocales as a static method.
Then do:
public class LocaleExt {
 
public static String toLanguageTag(Locale locale) { }
 
public static Locale[] getAvailableLocales() { }
}

(and for performance, maybe cache the computed language tag in a java.util.Map or a JS WeakMap)
and everywhere in your code where you used to call locale.toLanguageTag() or Locale.getAvailableLocales() then replace them with LocaleExt.toLanguageTag(locale) or LocaleExt.getAvailableLocales() respectively.

Then the SimpleDateTimeFormatStyleProvider#getFormatter(FormatStyle,FormatStyle,Chronology,Locale) emulation can keep the exact same signature.

foal

unread,
May 14, 2020, 7:55:32 AM5/14/20
to GWT Users
Hmm,

But the main issue that I have how to create the Locale object to pass it into the methods. The rest is possible to solve somehow.

Stas 

foal

unread,
May 14, 2020, 8:00:16 AM5/14/20
to GWT Users
It is also the way, but with HUGE drawback for me -  I can't work with SNAPSHOT, and there is no schedule for GWT releases. I hope with a new release it will change.

Stas.
Reply all
Reply to author
Forward
0 new messages