diff --git a/test/unit/org/apache/cassandra/index/sai/SAITester.java b/test/unit/org/apache/cassandra/index/sai/SAITester.java index 4ce8c25f58bd..5fd971c1bfd3 100644 --- a/test/unit/org/apache/cassandra/index/sai/SAITester.java +++ b/test/unit/org/apache/cassandra/index/sai/SAITester.java @@ -92,6 +92,7 @@ import org.apache.cassandra.service.StorageService; import org.apache.cassandra.service.snapshot.TableSnapshot; import org.apache.cassandra.utils.FBUtilities; +import org.apache.cassandra.utils.ReflectionUtils; import org.apache.cassandra.utils.Throwables; import org.apache.lucene.codecs.CodecUtil; import org.awaitility.Awaitility; @@ -898,7 +899,7 @@ protected static void setSegmentWriteBufferSpace(final int segmentSize) throws E NamedMemoryLimiter limiter = (NamedMemoryLimiter) V1OnDiskFormat.class.getDeclaredField("SEGMENT_BUILD_MEMORY_LIMITER").get(null); Field limitBytes = limiter.getClass().getDeclaredField("limitBytes"); limitBytes.setAccessible(true); - Field modifiersField = Field.class.getDeclaredField("modifiers"); + Field modifiersField = ReflectionUtils.getField(Field.class, "modifiers"); modifiersField.setAccessible(true); modifiersField.setInt(limitBytes, limitBytes.getModifiers() & ~Modifier.FINAL); limitBytes.set(limiter, segmentSize); diff --git a/test/unit/org/apache/cassandra/index/sai/SAIUtil.java b/test/unit/org/apache/cassandra/index/sai/SAIUtil.java index 8f56a0f4ca9b..f7580332077c 100644 --- a/test/unit/org/apache/cassandra/index/sai/SAIUtil.java +++ b/test/unit/org/apache/cassandra/index/sai/SAIUtil.java @@ -21,6 +21,7 @@ import java.lang.reflect.Field; import org.apache.cassandra.index.sai.disk.format.Version; +import org.apache.cassandra.utils.ReflectionUtils; public class SAIUtil { @@ -31,7 +32,7 @@ public static void setLatestVersion(Version version) { latest = Version.class.getDeclaredField("LATEST"); latest.setAccessible(true); - Field modifiersField = Field.class.getDeclaredField("modifiers"); + Field modifiersField = ReflectionUtils.getField(Field.class, "modifiers"); modifiersField.setAccessible(true); latest.set(null, version); }