Java Reflection: Getting fields and methods in declaration order

前端 未结 6 964
不知归路
不知归路 2020-11-29 07:27

Is there any way to get a classes declared fields (and methods) in the order of declaration using reflection? According to the documentation, the ordering of Methods and Fie

6条回答
  •  清歌不尽
    2020-11-29 07:57

    You may think about using Javadoc with a custom Doclet, but this requires the source to be available.

    There still is no guarantee about the order in the API (methods, fields, but every javadoc output I've ever seen has them in the right order, so I suppose the doclets get them in declaration order.

提交回复
热议问题