From f30bbf65005dacc7f63631e3f15dd08bab3907e2 Mon Sep 17 00:00:00 2001 From: Dawid Weiss Date: Wed, 22 May 2024 20:12:58 +0200 Subject: [PATCH] Moved SuppressForbidden to an internal package (not exposed by the module). Minor cleanups. Add static require on jdk.management for RamUsageEstimator. --- .../com/carrotsearch/hppc/examples/Helpers.java | 2 +- .../main/java/com/carrotsearch/hppc/BitSet.java | 2 +- .../hppc/BufferAllocationException.java | 1 - .../java/com/carrotsearch/hppc/Containers.java | 1 + .../com/carrotsearch/hppc/PgmIndexUtil.java | 2 +- .../carrotsearch/hppc/RamUsageEstimator.java | 17 ++++------------- .../hppc/{ => internals}/SuppressForbidden.java | 2 +- hppc/src/main/java/module-info.java | 2 ++ 8 files changed, 11 insertions(+), 18 deletions(-) rename hppc/src/main/java/com/carrotsearch/hppc/{ => internals}/SuppressForbidden.java (93%) diff --git a/hppc-examples/src/test/java/com/carrotsearch/hppc/examples/Helpers.java b/hppc-examples/src/test/java/com/carrotsearch/hppc/examples/Helpers.java index f8aefb05..64968c15 100644 --- a/hppc-examples/src/test/java/com/carrotsearch/hppc/examples/Helpers.java +++ b/hppc-examples/src/test/java/com/carrotsearch/hppc/examples/Helpers.java @@ -9,7 +9,7 @@ */ package com.carrotsearch.hppc.examples; -import com.carrotsearch.hppc.SuppressForbidden; +import com.carrotsearch.hppc.internals.SuppressForbidden; import java.util.Locale; class Helpers { diff --git a/hppc/src/main/java/com/carrotsearch/hppc/BitSet.java b/hppc/src/main/java/com/carrotsearch/hppc/BitSet.java index 54ee859c..7f8a94bc 100644 --- a/hppc/src/main/java/com/carrotsearch/hppc/BitSet.java +++ b/hppc/src/main/java/com/carrotsearch/hppc/BitSet.java @@ -34,7 +34,7 @@ * @see #asLongLookupContainer() */ public class BitSet implements Cloneable { - /** The initial default number of bits ({@value #DEFAULT_NUM_BITS}). */ + /** The initial default number of bits. */ private static final long DEFAULT_NUM_BITS = 64; /** Internal representation of bits in this bit set. */ diff --git a/hppc/src/main/java/com/carrotsearch/hppc/BufferAllocationException.java b/hppc/src/main/java/com/carrotsearch/hppc/BufferAllocationException.java index 573a4574..f09ef3c8 100644 --- a/hppc/src/main/java/com/carrotsearch/hppc/BufferAllocationException.java +++ b/hppc/src/main/java/com/carrotsearch/hppc/BufferAllocationException.java @@ -12,7 +12,6 @@ import java.util.IllegalFormatException; import java.util.Locale; -@SuppressWarnings("serial") public class BufferAllocationException extends RuntimeException { public BufferAllocationException(String message) { super(message); diff --git a/hppc/src/main/java/com/carrotsearch/hppc/Containers.java b/hppc/src/main/java/com/carrotsearch/hppc/Containers.java index 302a03c5..1d45fda6 100644 --- a/hppc/src/main/java/com/carrotsearch/hppc/Containers.java +++ b/hppc/src/main/java/com/carrotsearch/hppc/Containers.java @@ -9,6 +9,7 @@ */ package com.carrotsearch.hppc; +import com.carrotsearch.hppc.internals.SuppressForbidden; import java.security.PrivilegedAction; import java.util.logging.Level; import java.util.logging.Logger; diff --git a/hppc/src/main/java/com/carrotsearch/hppc/PgmIndexUtil.java b/hppc/src/main/java/com/carrotsearch/hppc/PgmIndexUtil.java index 8b9e632b..9793ab2b 100644 --- a/hppc/src/main/java/com/carrotsearch/hppc/PgmIndexUtil.java +++ b/hppc/src/main/java/com/carrotsearch/hppc/PgmIndexUtil.java @@ -10,7 +10,7 @@ package com.carrotsearch.hppc; /** Utility methods for {@code KTypePgmIndex}. */ -class PgmIndexUtil { +final class PgmIndexUtil { /** Adds the first key of the current segment to the segment data bytes. */ static void addKey(KType key, IntArrayList segmentData) { diff --git a/hppc/src/main/java/com/carrotsearch/hppc/RamUsageEstimator.java b/hppc/src/main/java/com/carrotsearch/hppc/RamUsageEstimator.java index cc75557e..907ea2e9 100644 --- a/hppc/src/main/java/com/carrotsearch/hppc/RamUsageEstimator.java +++ b/hppc/src/main/java/com/carrotsearch/hppc/RamUsageEstimator.java @@ -21,15 +21,6 @@ *

Mostly forked from Lucene tag releases/lucene-solr/8.5.1 */ final class RamUsageEstimator { - /** One kilobyte bytes. */ - static final long ONE_KB = 1024; - - /** One megabyte bytes. */ - static final long ONE_MB = ONE_KB * ONE_KB; - - /** One gigabyte bytes. */ - static final long ONE_GB = ONE_KB * ONE_MB; - /** No instantiation. */ private RamUsageEstimator() {} @@ -84,7 +75,7 @@ private RamUsageEstimator() {} if (datamodel != null) { is64Bit = datamodel.contains("64"); } - } catch (SecurityException ex) { + } catch (SecurityException ignored) { } if (datamodel == null) { is64Bit = OS_ARCH != null && OS_ARCH.contains("64"); @@ -110,17 +101,17 @@ private RamUsageEstimator() {} compressedOops = Boolean.parseBoolean( vmOption.getClass().getMethod("getValue").invoke(vmOption).toString()); - } catch (ReflectiveOperationException | RuntimeException e) { + } catch (ReflectiveOperationException | RuntimeException ignored) { } try { final Object vmOption = getVMOptionMethod.invoke(hotSpotBean, "ObjectAlignmentInBytes"); objectAlignment = Integer.parseInt( vmOption.getClass().getMethod("getValue").invoke(vmOption).toString()); - } catch (ReflectiveOperationException | RuntimeException e) { + } catch (ReflectiveOperationException | RuntimeException ignored) { } } - } catch (ReflectiveOperationException | RuntimeException e) { + } catch (ReflectiveOperationException | RuntimeException ignored) { } COMPRESSED_REFS_ENABLED = compressedOops; NUM_BYTES_OBJECT_ALIGNMENT = objectAlignment; diff --git a/hppc/src/main/java/com/carrotsearch/hppc/SuppressForbidden.java b/hppc/src/main/java/com/carrotsearch/hppc/internals/SuppressForbidden.java similarity index 93% rename from hppc/src/main/java/com/carrotsearch/hppc/SuppressForbidden.java rename to hppc/src/main/java/com/carrotsearch/hppc/internals/SuppressForbidden.java index 00ee8acd..c746e0f7 100644 --- a/hppc/src/main/java/com/carrotsearch/hppc/SuppressForbidden.java +++ b/hppc/src/main/java/com/carrotsearch/hppc/internals/SuppressForbidden.java @@ -7,7 +7,7 @@ * Refer to the full license file "LICENSE.txt": * https://github.com/carrotsearch/hppc/blob/master/LICENSE.txt */ -package com.carrotsearch.hppc; +package com.carrotsearch.hppc.internals; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/hppc/src/main/java/module-info.java b/hppc/src/main/java/module-info.java index 5a84974b..321d6400 100644 --- a/hppc/src/main/java/module-info.java +++ b/hppc/src/main/java/module-info.java @@ -1,5 +1,6 @@ module com.carrotsearch.hppc { requires java.logging; + requires static jdk.management; exports com.carrotsearch.hppc; exports com.carrotsearch.hppc.cursors; @@ -7,4 +8,5 @@ exports com.carrotsearch.hppc.comparators; exports com.carrotsearch.hppc.predicates; exports com.carrotsearch.hppc.sorting; + exports com.carrotsearch.hppc.internals; }