google / jsinterop-annotations

JsInterop java annotations for J2CL and GWT
Apache License 2.0
16 stars 8 forks source link

Clarify non-native @JsType support for Java 16 records #7

Open niloc132 opened 6 months ago

niloc132 commented 6 months ago

Does not attempt to address native support - like enums, if this is to be supported, it will likely require its own annotation and semantics.

Fixes #6

niloc132 commented 4 months ago

I've rewritten this PR to only modify JsProperty, so that they make sense on record accessors.

record Point(@JsProperty int x, @JsProperty int y) {}

In the above example, without this change, the @JsProperty annotation applies both to the private final int x and public int x() {return this.x;} that Java generates for you, which would be wrong for two reasons - the method doesn't follow JavaBean naming conventions (and must not), and both field and method have the same name (which would collide in JS).

niloc132 commented 3 months ago

Any thoughts on this downscoped set of changes to resolve the contradiction presented by annotations on record components?

gkdn commented 3 months ago

For the essence of proposed change: yes we wouldn't let such conflict happen. Being said that talking about record types without supporting them would b e misleading at the moment. I think we should evaluate this all pieces together and update the annotations/documentation etc with the right wording when we actually start working on supporting record types.