Java Reflection: Getting fields and methods in declaration order

With jdk 6, the reflected fields are in deed in their declaration order. In early jdk that wasn’t the case. Apparently enough people have nagged.

Although not guaranteed by javadoc, I would still take this order as granted, and I assume the order will be kept in future jdks too.

In your app, like in most apps, the dependency on the declaration order is mostly vanity – your app won’t fail if the order screws up, it just become a little uglier.

Leave a Comment