thank you for the detailed answer (as always) 

On Thursday, March 13, 2025 at 3:43:47 AM UTC+1 Colin Alworth wrote:

> Note also that Java itself doesn't serialize records in the same way as 
> other objects, there are a few interesting hiccups there that might impact 
> some use cases. Search for "serializable" at 
> https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Record.html
>  
> for more discussion on this.
>
> This is not to say that GWT-RPC, if it were updated to support this, would 
> also reflect those exact semantics, but that this shouldn't be implemented 
> lightly, and no one has taken the time to consider how it would be done. 
>
> I would also point out that the com.google.gwt.core.ext.typeinfo.JType 
> hierarchy also has not grown past Java 7 (no "default" from Java 8, 
> "module" from Java 9, "sealed" in java 17 etc) so Generators cannot see 
> these flags and react accordingly. This was by design at the time, 
> encouraging any code that needs them to move to annotation processors. 
>
> There is a gwt-rpc annotation processor implementation, and while it is 
> used in production, it isn't used widely, but this feature could be 
> explicitly added there. 
>
> By the same token, if you have a bunch of records, you could generate 
> custom field serializers with an annotation processor as well.
>
> On Wednesday, March 12, 2025 at 8:32:18 PM UTC-5 Jens wrote:
>
>> GWT uses either a CustomFieldSerializer implementation to serialize a 
>> concrete class or it uses bean serialization. Bean serialization requires a 
>> default constructor, serializable fields and final fields are only 
>> supported if you enable it.
>>
>> A CustomFieldSerializer must be written for a concrete class so you 
>> cannot provide a serializer for class Record and then expect to send all 
>> kinds of records. You can write your own TestRecord_CustomFieldSerializer 
>> if you want to send a record via GWT-RPC. It is the same with any other 
>> class that you define in your application that need special treatment 
>> because it does not have a default constructor. Records just allow you to 
>> write a little less code.
>>
>>
>> https://www.gwtproject.org/doc/latest/DevGuideServerCommunication.html#DevGuideCustomSerialization
>>
>> -- J.
>>
>> tekkyru schrieb am Mittwoch, 12. März 2025 um 19:15:06 UTC+1:
>>
>>> Many thanks for supporting Java 17 language features
>>>
>>> But in my setup the Java records (new feature) are supported on client 
>>> side but cannot be passed between server and client:
>>>
>>> public record TestRecord(String name, int age) implements 
>>> IsSerializable {}
>>>
>>>
>>> interface MyService extends RemoteService {
>>>
>>> public TestRecord getTestRecord();
>>>
>>> }
>>>
>>> The GWT Code server displays an error:
>>> [ERROR] 'com.mycompany.TestRecord' has no instantiable subtypes
>>>
>>> Am I doing something wrong or the records cannot be de/serialized yet?
>>>
>>> I know they don't have the default constructors, but creating them in 
>>> javascript should not be affected, and de-serializing a record instance as 
>>> a call parameter can be (probably) done via reflection.
>>>
>>> Best regards
>>> Alex
>>>
>>

-- 
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 [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/google-web-toolkit/de48fc0e-a56c-4103-a47c-20e778a98c05n%40googlegroups.com.

Reply via email to