-
Notifications
You must be signed in to change notification settings - Fork 379
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
The types returned by newly added List/Set/Map.of/copyOf() cannot be passed between client and server (=are outside the scope of gwt rpc serialization) #10048
Comments
Although workarounds exist, issues like this force reliance on older language features to avoid runtime type errors, driving GWT adoption in my environment to near zero :,( |
Is it the same underlying issue as #7247 ? |
Even though this issue also involves gwt.rpc, this issue occurs ALWAYS and not just within the limited scope described in #7247:
|
Thanks for the report - there are probably some tricks that could make this possible, but to my knowledge there's nothing identifiable that you can do in user code to cleanly spot that you've received an immutable list like this - Take a look at #3071 for example - this is not a recent departure from how the GWT project has treated this topic in the past, nor is it just an oversight in this release. Keep in mind that when a feature like this is implemented, the costs may be shared among all projects that happen to use List.of(), whether or not they also use GWT-RPC - or vice versa. 45c0555 is the revert commit that removed that feature. @1jkoch I'm sorry this is inconveniencing you and your adoption of new features. Keep in mind that the GWT Project is almost entirely volunteer resourced - that includes triage of issues, development of features and bugfixes, and acceptance testing to decide that a release is "finished". While my company does accept money in exchange for improvements in the compiler and ecosystem at large, we find that (much) less than 5% of our revenue is actually directed at doing such work (but this fact doesn't stop us from continuing to work on GWT with the time we have available). Also note that this does not prevent you from using List.of() and friends, but only from serializing them via GWT-RPC, and these are far from the only types that are serializable by ObjectOutputStream that are not supported by GWT-RPC. @zbynek no - the problem here is that the server has different List implementations (going by FQCN and fields) than the client emulation does, and so needs some custom handling to address this. That issue is an edge case in how to proceed in cases with raw generics. Serializability via Java generics is already undecideable, and raw generics are a great way to let the serializable type list explode, so I have to discourage that from the get go - but going by the history of that patch, it just needs a steward to complete it with tests so we can land it. |
Hi Colin,
thanks for your detailed response. I really appreciate the work you’re doing to keep GWT alive and relevant! I’ve been using GWT in projects since it became open source and have always found that a conservative use of language features works well for me. That said, I just wanted to highlight Andreas’ issue a bit because GWT’s acceptance is important to me.
Thanks again, JörnAm 24.11.2024 um 22:20 schrieb Colin Alworth ***@***.***>:
Thanks for the report - there are probably some tricks that could make this possible, but to my knowledge there's nothing identifiable that you can do in user code to cleanly spot that you've received an immutable list like this - ListN and friends are not public, nor is there some ImmutableList interface nor some isImmutable/isMutable on collections/etc. Arrays.asList is implemented by trying to mirror the internal structure of java.util.Arrays (modifications to the array must be reflected in the List), but in GWT the relative cost of creating new classes is much higher than in Java so when there is no extra features afforded by List.of(item) that Collections.singletonList(item) doesn't grant. Except: the class instances won't match.
Take a look at #3071 for example - this is not a recent departure from how the GWT project has treated this topic in the past, nor is it just an oversight in this release. Keep in mind that when a feature like this is implemented, the costs may be shared among all projects that happen to use List.of(), whether or not they also use GWT-RPC - or vice versa. 45c0555 is the revert commit that removed that feature.
@1jkoch I'm sorry this is inconveniencing you and your adoption of new features. Keep in mind that the GWT Project is almost entirely volunteer resourced - that includes triage of issues, development of features and bugfixes, and acceptance testing to decide that a release is "finished". While my company does accept money in exchange for improvements in the compiler and ecosystem at large, we find that (much) less than 5% of our revenue is actually directed at doing such work (but this fact doesn't stop us from continuing to work on GWT with the time we have available). Also note that this does not prevent you from using List.of() and friends, but only from serializing them via GWT-RPC, and these are far from the only types that are serializable by ObjectOutputStream that are not supported by GWT-RPC.
@zbynek no - the problem here is that the server has different List implementations (going by FQCN and fields) than the client emulation does, and so needs some custom handling to address this. That issue is an edge case in how to proceed in cases with raw generics. Serializability via Java generics is already undecideable, and raw generics are a great way to let the serializable type list explode, so I have to discourage that from the get go - but going by the history of that patch, it just needs a steward to complete it with tests so we can land it.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
**GWT version: 2.12.1
**Browser (with version): any
**Operating System: any
Description
For example, having a GWT service method that returns a
List
instance created usingList.of()
will yield the following at runtime:Steps to reproduce
Create a GWT service like this
with the matching AsyncService (skipped here because it's obvious) and an implementation like this
and call it in your client code like this:
The same happens for
Set.of()
,Map.of()
and the pertinentcopyOf()
methods.Eventually, all these methods create instances of
java.util.ImmutableCollections$ListN
,List12
, etc. which do not partake in gwt rpc serialization as stated in the exception message.Since all those classes explicitly implement
java.io.Serializable
this will startle users who think that they can useList.of()
/List.copyOf()
since 2.11/2.12Known workarounds
Continue using
Arrays.asList()
, etc.Links to further discussions
The text was updated successfully, but these errors were encountered: