RFR: 8217389: JTREG: Clean up, remove unused variable warnings

Leonid Mesnik leonid.mesnik at oracle.com
Fri Jan 18 21:24:14 UTC 2019


Leo

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:
> 
> Hi,
> 
> 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
http://cr.openjdk.java.net/~lkorinth/8217389/00/test/hotspot/jtreg/gc/cslocker/TestCSLocker.java <http://cr.openjdk.java.net/~lkorinth/8217389/00/test/hotspot/jtreg/gc/cslocker/TestCSLocker.java>
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:
http://hg.openjdk.java.net/jdk/jdk/file/cb7347310fa1/test/hotspot/jtreg/gc/TestMemoryInitialization.java <http://hg.openjdk.java.net/jdk/jdk/file/cb7347310fa1/test/hotspot/jtreg/gc/TestMemoryInitialization.java>

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.
http://hg.openjdk.java.net/jdk/jdk/file/cb7347310fa1/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp <http://hg.openjdk.java.net/jdk/jdk/file/cb7347310fa1/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp>


Leonid

> 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.
> 
> Enhancement:
> https://bugs.openjdk.java.net/browse/JDK-8217389
> 
> Webrev:
> http://cr.openjdk.java.net/~lkorinth/8217389/00
> 
> Testing:
> passed locally: open/test/hotspot/jtreg/:hotspot_gc
> 
> Thanks,
> Leo

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/hotspot-gc-dev/attachments/20190118/78bb71c1/attachment.html>


More information about the hotspot-gc-dev mailing list