From 0c36177fead8b64a4cee9da3c895e3799f8ba231 Mon Sep 17 00:00:00 2001 From: Per Minborg Date: Fri, 13 Sep 2024 08:43:38 +0000 Subject: [PATCH] 8340089: Simplify SegmentBulkOperations::powerOfProperty Reviewed-by: jpai --- .../jdk/internal/foreign/SegmentBulkOperations.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/java.base/share/classes/jdk/internal/foreign/SegmentBulkOperations.java b/src/java.base/share/classes/jdk/internal/foreign/SegmentBulkOperations.java index 9d7b9e120b5..41ae247293d 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/SegmentBulkOperations.java +++ b/src/java.base/share/classes/jdk/internal/foreign/SegmentBulkOperations.java @@ -29,7 +29,7 @@ import jdk.internal.misc.ScopedMemoryAccess; import jdk.internal.util.Architecture; import jdk.internal.util.ArraysSupport; import jdk.internal.vm.annotation.ForceInline; -import sun.security.action.GetPropertyAction; +import sun.security.action.GetIntegerAction; import java.lang.foreign.MemorySegment; @@ -310,15 +310,8 @@ public final class SegmentBulkOperations { // The returned value is in the interval [0, 2^30] static int powerOfPropertyOr(String name, int defaultPower) { - final String property = GetPropertyAction.privilegedGetProperty(PROPERTY_PATH + name); - if (property != null) { - try { - return 1 << Math.clamp(Integer.parseInt(property), 0, Integer.SIZE - 2); - } catch (NumberFormatException _) { - // ignore - } - } - return defaultPower; + final int power = GetIntegerAction.privilegedGetProperty(PROPERTY_PATH + name, defaultPower); + return 1 << Math.clamp(power, 0, Integer.SIZE - 2); } }