mercredi 25 octobre 2017

Java Enums - ENUM$VALUES or $VALUES

How can I determine the logic used for naming the synthetic attribute created inside enums to store the values of it in Java?

I've been trying to find either documentation without luck, I also looked at the source to see if I was able to get some more insight on my own. So far the only thing I've been able to find is this post where apparently the conclusion indicates that the naming for it depends entirely on the compiler, nonetheless I've seen both namings on the same project on the same execution on different classes.

Can anybody shed some light onto how is this synthetic field gets named?

Or how can I determine/dictate if an enum would use the $VALUES or the ENUM$VALUES name? (Of course without testing it first through reflection)





Aucun commentaire:

Enregistrer un commentaire