RFR: JDK-8374395 : Improve MemoryUsage.toString() and constructor error messages for better clarity
Eunbin Son
duke at openjdk.org
Wed Dec 31 09:40:03 UTC 2025
On Wed, 31 Dec 2025 07:57:18 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> ### Summary
>> MemoryUsage.toString() now displays "N/A" for undefined init and max values (-1) instead of "-1(-1K)".
>>
>> This addresses the first of three issues in JDK-8374395.
>>
>> ### Description
>> When init or max is -1 (undefined), toString() outputs "-1(-1K)". The Javadoc states that -1 means undefined, but the output does not clearly indicate this.
>>
>> toString() checks if init or max equals -1 and outputs "init = N/A" or "max = N/A" respectively. Output format for valid values remains unchanged.
>>
>> Added test cases to the existing jtreg test file. All tests pass.
>>
>> ### Bug-ID : JDK-8374395
>> https://bugs.java.com/bugdatabase/view_bug?bug_id=JDK-8374395
>
>> This addresses the first of three issues in JDK-8374395.
>
> Note that you can't use the same JBS issue for different PRs/commits. If there are other changes proposed then they will need their own JBS issues.
>
> test/jdk/java/lang/management/MemoryUsage would be a better place for unit tests for this API.
@AlanBateman Thanks for the review. Addressed.
This PR covers only the first issue from JDK-8374395.
Should I create separate JBS issues for the remaining two?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/29009#issuecomment-3701837689
More information about the serviceability-dev
mailing list