RFR: 8217389: JTREG: Clean up, remove unused variable warnings
leonid.mesnik at oracle.com
Fri Jan 18 21:24:14 UTC 2019
1. http://cr.openjdk.java.net/~lkorinth/8217389/00/test/hotspot/jtreg/gc/arguments/TestMaxNewSize.java.udiff.html <http://cr.openjdk.java.net/~lkorinth/8217389/00/test/hotspot/jtreg/gc/arguments/TestMaxNewSize.java.udiff.html>
I am not sure how your changes make code clear. Also '128*M' should have spaces.
> On Jan 18, 2019, at 9:23 AM, Leo Korinth <leo.korinth at oracle.com> wrote:
> Here I am removing warnings for unused variables.
> Some variables can not be removed as in the case of creating a new primitive array without assigning it to a variable. It is not allowed, in those cases I use @SuppressWarnings("unused").
I think that it would be better to really use these variables somehow.
The hotspot compilers might also optimize such arrays initialization since results are not used. The tests like this
just silently pass without any memory allocation and actual testing.
I think it would be better to change this variables to be public static and/or be used by some external stuff (print zero/last element as example). It guarantee that compiler can't remove this allocation as a dead code.
See following test as example:
Might be some library helper which produce some amount off garbage is useful.
There are already a lot of methods to produce garbage here but they seems to be overcomplicated. Not sure it make sense to reuse them.
> In some cases the variable is not used at all, and I remove it, but still add the variable name as a comment after the expression, as the variable name might have helped as documentation. I also just commented out "final int CONSTANT_Unicode = 2;" if that information might be useful in the future, it is a constant that we do not expect in the test case.
> Otherwise I just try to remove the code.
> This fix is somewhat based/dependent on the rest of my "JTREG:" webrevs.
> passed locally: open/test/hotspot/jtreg/:hotspot_gc
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the hotspot-gc-dev