Skip to content

Commit

Permalink
7903504: JMH: Fix new Sonar warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
shipilev authored Jul 6, 2023
1 parent 47f651b commit d88f901
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ public static List<String> prepare() {

// Need to rename the file to the proper name, otherwise JNA would not discover it
File proper = new File(bootLibraryPath + '/' + System.mapLibraryName("jnidispatch"));
file.renameTo(proper);
if (!file.renameTo(proper)) {
throw new IllegalStateException("Failed to rename " + file + " to " + proper);
}

return Arrays.asList(
"-Djna.nounpack=true", // Should not unpack itself, but use predefined path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ public void test() throws RunnerException {
double cycles = ProfilerTestUtils.checkedGet(sr, "cycles", "cycles:u").getScore();
double branches = ProfilerTestUtils.checkedGet(sr, "branches", "branches:u").getScore();

Assert.assertNotEquals(0, instructions);
Assert.assertNotEquals(0, cycles);
Assert.assertNotEquals(0, branches);
Assert.assertNotEquals(0D, instructions, 0D);
Assert.assertNotEquals(0D, cycles, 0D);
Assert.assertNotEquals(0D, branches, 0D);

if (branches > instructions) {
throw new IllegalStateException(String.format("Branches (%.2f) larger than instructions (%.3f)", branches, instructions));
Expand All @@ -88,8 +88,8 @@ public void test() throws RunnerException {
double ipc = ProfilerTestUtils.checkedGet(sr, "IPC").getScore();
double cpi = ProfilerTestUtils.checkedGet(sr, "CPI").getScore();

Assert.assertNotEquals(0, ipc);
Assert.assertNotEquals(0, cpi);
Assert.assertNotEquals(0D, ipc, 0D);
Assert.assertNotEquals(0D, cpi, 0D);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ public void test() throws RunnerException {
if (sr.containsKey("·ipc")) {
double ipc = ProfilerTestUtils.checkedGet(sr, "·ipc").getScore();
double cpi = ProfilerTestUtils.checkedGet(sr, "·cpi").getScore();
Assert.assertNotEquals(0, ipc);
Assert.assertNotEquals(0, cpi);
Assert.assertNotEquals(0D, ipc, 0D);
Assert.assertNotEquals(0D, cpi, 0D);
}

Assert.assertTrue(msg.contains("cycles"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ public void test() throws RunnerException {
double pauseCount = ProfilerTestUtils.checkedGet(sr, "·safepoints.pause.count").getScore();
double ttspCount = ProfilerTestUtils.checkedGet(sr, "·safepoints.ttsp.count").getScore();

Assert.assertNotEquals(pauseTotal, 0);
Assert.assertNotEquals(ttspTotal, 0);
Assert.assertNotEquals(0D, pauseTotal, 0D);
Assert.assertNotEquals(0D, ttspTotal, 0D);

Assert.assertNotEquals(pauseCount, 0);
Assert.assertNotEquals(ttspCount, 0);
Assert.assertEquals(ttspCount, pauseCount, 0);
Assert.assertNotEquals(0D, pauseCount, 0D);
Assert.assertNotEquals(0D, ttspCount, 0D);
Assert.assertEquals(ttspCount, pauseCount, 0D);

if (interval < 3000) {
throw new IllegalStateException("Interval time is too low. " +
Expand Down

0 comments on commit d88f901

Please sign in to comment.