Skip to content

Commit 0a005b3

Browse files
committed
refactor: make createTempLibraryFile package-private and simplify test
1 parent c87ce50 commit 0a005b3

2 files changed

Lines changed: 3 additions & 7 deletions

File tree

‎src/main/java/com/uber/h3core/H3CoreLoader.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public static NativeMethods loadNatives() throws IOException {
9393
return loadNatives(os, arch);
9494
}
9595

96-
private static File createTempLibraryFile(OperatingSystem os) throws IOException {
96+
static File createTempLibraryFile(OperatingSystem os) throws IOException {
9797
// Check if the user specified a custom directory for native libraries
9898
String customDir = System.getProperty("h3.native.dir");
9999
File dir = customDir != null ? new File(customDir) : null;

‎src/test/java/com/uber/h3core/TestH3CoreLoader.java‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,8 @@ void testCustomNativeDir() throws Exception {
7878
H3CoreLoader.OperatingSystem currentOs =
7979
H3CoreLoader.detectOs(System.getProperty("java.vendor"), System.getProperty("os.name"));
8080

81-
java.lang.reflect.Method method =
82-
H3CoreLoader.class.getDeclaredMethod(
83-
"createTempLibraryFile", H3CoreLoader.OperatingSystem.class);
84-
method.setAccessible(true);
85-
86-
File tempFile = (File) method.invoke(null, currentOs);
81+
// Call the package-private method directly! No reflection needed.
82+
File tempFile = H3CoreLoader.createTempLibraryFile(currentOs);
8783

8884
org.junit.jupiter.api.Assertions.assertTrue(
8985
tempFile.getAbsolutePath().startsWith(new File(customDir).getAbsolutePath()),

0 commit comments

Comments
 (0)