lundi 7 novembre 2022

why does Java not guarantee ordering in Class.getDeclaredFields() and similar methods

The Java documentation is very careful to state that Class.getDeclaredFields() and similar methods make no guarantees about method ordering. There are a few exceptions: it's easy to get declaration order for enums and for record components, and a few other semi-obscure things. But not for methods or fields. My questions is: WHY? It seems to me that it's cheap for Java to guarantee declaration order, and it's obviously sometimes useful, so it seems to be a pure win. Is there a catch I'm missing?





Aucun commentaire:

Enregistrer un commentaire