RFR: CODETOOLS-7902853: JMH: Fix lint and deprecation warnings

Aleksey Shipilev shade at openjdk.java.net
Tue Mar 23 20:20:54 UTC 2021


On Mon, 15 Mar 2021 10:57:08 GMT, Niels Basjes <github.com+240096+nielsbasjes at openjdk.org> wrote:

> In my projects I always use -Werror as the compiler flag as one of the means to get a high standard for code quality.
> In this project https://github.com/nielsbasjes/yauaa I have a module that does the benchmarks.
> When I update the JMH from 1.26 to 1.28 my build fails with 
> [WARNING] COMPILATION WARNING : 
> [INFO] -------------------------------------------------------------
> [WARNING] /home/nbasjes/workspace/Prive/yauaa_/benchmarks/target/generated-sources/annotations/nl/basjes/parse/useragent/benchmarks/jmh_generated/AnalyzerBenchmarks_android6Chrome46_jmhTest.java:[324,67] redundant cast to long
> [WARNING] /home/nbasjes/workspace/Prive/yauaa_/benchmarks/target/generated-sources/annotations/nl/basjes/parse/useragent/benchmarks/jmh_generated/AnalyzerBenchmarks_android6Chrome46_jmhTest.java:[324,83] redundant cast to long
> [WARNING] /home/nbasjes/workspace/Prive/yauaa_/benchmarks/target/generated-sources/annotations/nl/basjes/parse/useragent/benchmarks/jmh_generated/AnalyzerBenchmarks_androidPhone_jmhTest.java:[324,67] redundant cast to long
> [WARNING] /home/nbasjes/workspace/Prive/yauaa_/benchmarks/target/generated-sources/annotations/nl/basjes/parse/useragent/benchmarks/jmh_generated/AnalyzerBenchmarks_androidPhone_jmhTest.java:[324,83] redundant cast to long
> and at the end it fails
> [ERROR] COMPILATION ERROR : 
> [INFO] -------------------------------------------------------------
> [ERROR] /home/nbasjes/workspace/Prive/yauaa_/benchmarks/target/generated-sources/annotations/nl/basjes/parse/useragent/benchmarks/jmh_generated/AnalyzerBenchmarks_android6Chrome46_jmhTest.java: warnings found and -Werror specified
> [INFO] 1 error
> 
> Turns out this problem is caused by a change in code generated by JMH.
> 
> This pull request fixes this problem.

Right. There are also three other places where these casts happen, grep for `new BenchmarkTaskResult` in the same file. I would also need to check how to regression-test this...

Thanks, this looks good. I edited this PR to get it hooked to bug systems. Please introduce `ACCURACY` constants, and then we are good to go patch-wise. We would need to wait for OCA to clear for integration, though.

Looks good. Once you have OCA approved, bot would lift `oca` tag, and then instruct you to say `/integrate`. We can ping @robilad to see if there are problems with OCA.

jmh-core/src/test/java/org/openjdk/jmh/util/TestListStatistics.java line 253:

> 251:         Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[1], 0.0000001);
> 252:         Assert.assertEquals(Double.NaN, s.getPercentile(0), 0.0000001);
> 253:         Assert.assertEquals(Double.NaN, s.getPercentile(100), 0.0000001);

Please introduce the `static final double ACCURACY = 0.0000001`, and use it?

jmh-core/src/test/java/org/openjdk/jmh/util/TestListStatistics.java line 272:

> 270:         Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[1], 0.0000001);
> 271:         Assert.assertEquals(42.0D, s.getPercentile(0), 0.0000001);
> 272:         Assert.assertEquals(42.0D, s.getPercentile(100), 0.0000001);

Ditto, `ACCURACY` constant.

jmh-core/src/test/java/org/openjdk/jmh/util/TestListStatistics.java line 408:

> 406:             Assert.assertTrue(listIter.hasNext());
> 407:             Map.Entry<Double, Long> entry = listIter.next();
> 408:             Assert.assertEquals(entry.getKey(), item, 0.0000001);

Ditto, `ACCURACY` constant.

jmh-core/src/test/java/org/openjdk/jmh/util/TestMultisetStatistics.java line 237:

> 235: 
> 236:         Assert.assertEquals(0, s.getN());
> 237:         Assert.assertEquals(Double.NaN, s.getSum(), 0.0000001);

Ditto, `ACCURACY`.

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

Changes requested by shade (Committer).

PR: https://git.openjdk.java.net/jmh/pull/31Marked as reviewed by shade (Committer).


More information about the jmh-dev mailing list