google / google/jsinterop-generator
Eliminating <clinit> on Global objects
- Dominant language
- Java
- Stars
- 85
- Forks
- 24
- PR merge metrics
- No merged PRs in 30d
Description
Currently the global object created for each module ends up potentially having a `` if there is variables accessed in scope. For example `elemental2.dom.DomGlobal` has a `elemental2.dom.DomGlobal__Constants`. The `DomGlobal__Constants` class has static fields mapped to javascript and then `DomGlobal` re-esposes those fields by using a static final field. This results in `DomGlobal` having a `` method that simply assigns the `DomGlobal__Constants` fields to the `DomGlobal` fields. It also mandates that most code that accesses these fields must call the clinit method first.
The whole `` dance seems like unnecessary overhead and I am trying to understand why the fields are not moved directly to the `DomGlobal` class. It would result in less code and have practically the same developer experience - the only difference that I am aware is that it does not stop user code re-assigning the variables as can not be final.
Is there any other reason for this approach?
Contributor guide
Assessment
This issue has not been assessed yet.