Wednesday, July 26, 2023

Re: Partial super source? Possible?

I was specifically answering the J2CL part: you cannot use shadowing with J2CL, only with GWT.
More accurately, J2CL itself is rather low-level and will translate any file you give it; the "issue" here is rather the Closure Compiler (IIRC), that will error if it finds more than one file declaring the same Closure module (each Java class is translated to a Closure module).
You should however (IIRC and IIUC) be able to patch the Java Runtime Emulation (JRE) used by J2CL, similar to how you could patch it in GWT by using your own "fork" of the gwt-user.jar.

TL;DR: try hard to avoid using any class or method that's not part of the "built-in" emulation library. Refactor code to use an intermediate class (e.g. MyStringFormatter.format()) that you can then super-source. If compiling a third-party library, it might not be that bad of an idea to patch it (fork it) with that kind of refactoring.

I'll let Colin confirm though, as I've been away from J2CL for some time now.

On Wednesday, July 26, 2023 at 1:09:41 PM UTC+2 Bruno Salmon wrote:
Thanks Thomas. By "shadow" I was actually quoting you when you said: 

you cannot "augment" it, but you can "shadow" it by providing your own super-source version of java.lang.String

In my previous reply, I was saying that I'm happy with this solution for my GWT app (whatever you call this method "shadow" or something else).

But my concern is now with J2CL (as I plan to move my GWT app to J2CL in the future).
I would like to know if this solution will also work with J2CL.
i.e. will I be able to provide my own implementation of String.format() if not emulated by J2CL?

On Tuesday, 25 July 2023 at 15:20:19 UTC+1 Thomas Broyer wrote:
On Tuesday, July 25, 2023 at 2:26:14 PM UTC+2 Bruno Salmon wrote:
The shadow super-source should work in my case, thank you.

 If later I want to move from GWT to J2CL, will I have a similar feature (ex: providing my own implementation of String.format() if not emulated) ?

IIRC, no: each source file must only appear once, so you cannot use shadowing.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/a363da30-f10b-4c47-8b37-bb5761958e78n%40googlegroups.com.

No comments:

Post a Comment