gwtproject / gwt

GWT Open Source Project
http://www.gwtproject.org
1.5k stars 371 forks source link

Explore `@JsEnum` support in GWT #9794

Open niloc132 opened 1 year ago

niloc132 commented 1 year ago

The jsinterop-annotations 2.0 supports the JsEnum annotation, which allows Java enums to be exposed to JS as non-long primitives or strings, and likewise allows a JS namespace with named constants of the same types to be used from within Java code.

The annotation is documented as only being supported in J2CL, but unlike @JsAsync, GWT wouldn't require supporting a new version of ecmascript to handle this feature.

I've put together a preliminary implementation of this, only supporting non-native enums, and skipping a few other design choices that J2CL has made, until I understand those decisions better.

This issue is to track the implementation and design decisions that we adopt for GWT. My aim is to at least match JsEnum's explicit documentation, and evaluate J2CL's specific decisions to decide when to be exactly compatible or not.

niloc132 commented 7 months ago

The work done so far on this could probably be backported to 2.11, but I'm targetting 2.12 for this feature.