### Question:
SmartJniMemoryManager extends JniMemoryManager { @Override @Contract(pure = true) @SuppressWarnings("PMD.DataflowAnomalyAnalysis") public long getHugepageSize() { if (DEBUG >= LOG_TRACE) log.trace("Checking the huge page size."); if (!existsInMtab(MTAB_PATH, "hugetlbfs", DEFAULT_HUGEPAGE_PATH, "hugetlbfs")) return HUGE_PAGE_NOT_SUPPORTED; if (DEBUG >= LOG_DEBUG) log.debug("Parsing file '{}'.", MEMINFO_PATH); try (val meminfo = bufferedReader(new File(MEMINFO_PATH))) { val pattern = Pattern.compile("Hugepagesize:[\\t\\s ]+(\\d+)[\\t\\s ]+([kMG]?B)"); for (var line = meminfo.readLine(); line != null; line = meminfo.readLine()) { val matcher = pattern.matcher(line); if (matcher.find()) { return applyFactor(Long.parseLong(matcher.group(1)), matcher.group(2)); } } } catch (final FileNotFoundException e) { if (DEBUG >= LOG_ERROR) log.error("The file '{}' cannot be found.", MEMINFO_PATH, e); } catch (final IOException e) { if (DEBUG >= LOG_ERROR) log.error("The file '{}' cannot be read or closed.", MEMINFO_PATH, e); } return 0; } private  SmartJniMemoryManager(); @Override @Contract(pure = true) long getPageSize(); @Override @Contract(pure = true) @SuppressWarnings("PMD.DataflowAnomalyAnalysis") long getHugepageSize(); @Override @Contract(pure = true) @SuppressWarnings("PMD.DataflowAnomalyAnalysis") @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE") long virt2phys(final long address);  }### Answer:
@Test @DisplayName("getHugepageSize()") void getHugepageSize() { assumeTrue(mmanager != null); val pageSize = mmanager.getHugepageSize(); assertThat(pageSize).isPositive().withFailMessage("should be a power of two").isEqualTo(pageSize & -pageSize); }
@Test @DisplayName("mmap(File, boolean, boolean)") void mmap_munmap(final @TempDir Path dir) throws IOException { assumeTrue(mmanager != null); for (val huge : Arrays.asList(false)) { for (val lock : Arrays.asList(false, true)) { File file; if (huge) { file = Paths.get(DEFAULT_HUGEPAGE_PATH, "mmap.txt").toFile(); val raf = new RandomAccessFile(file, "rwd"); raf.setLength(30); } else { file = dir.resolve("mmap.txt").toFile(); Files.write(file.toPath(), new byte[1]); } assertThat(file.length()).as("check size").isNotZero(); val map = mmanager.mmap(file, huge, lock); val softly = new SoftAssertions(); softly.assertThat(map).isNotZero(); if (huge) softly.assertThat(map % mmanager.getHugepageSize()).isZero(); if (map != 0) mmanager.munmap(map, file, huge, lock); if (!file.delete()) file.deleteOnExit(); softly.assertAll(); } } }