jsinterop-annotations icon indicating copy to clipboard operation
jsinterop-annotations copied to clipboard

Clarify non-native @JsType support for Java 16 records

Open niloc132 opened this issue 1 year ago • 3 comments

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 avatar Apr 07 '24 19:04 niloc132

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 avatar May 22 '24 16:05 niloc132

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

niloc132 avatar Jun 28 '24 19:06 niloc132

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.

gkdn avatar Jun 28 '24 21:06 gkdn