RFR: JDK-8317635: Improve GetClassFields test to verify correctness of field order

Alex Menkov amenkov at openjdk.org
Thu Oct 12 20:26:15 UTC 2023


On Thu, 12 Oct 2023 01:37:01 GMT, Chris Plummer <cjplummer at openjdk.org> wrote:

>> All test cases in getclfld007 had 1 (or 0) field in test classes/interfaces.
>> The change adds several fields in one of the test classes to verify order of the returned fields (as described by GetClassFields spec).
>> Additionally added "printdump" argument to the test agent to make the test more verbose.
>
> test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetClassFields/getclfld007/TestDescription.java line 36:
> 
>> 34:  *     The test checks if the function returns the expected list of fields:
>> 35:  *         - the list contains only directly declared (not inherited) fields;
>> 36:  *         - fields are returned in the order they occur in the class file.
> 
> Is the order of the fields in the class file guaranteed to be the same as the declaration order?

Good question.
Javac works this way, but looks like this is not a requirement.
Looks like the test should use some class file parser to get actual field order

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/16131#discussion_r1357376623


More information about the serviceability-dev mailing list