From cfe8482ae112af657672d8d8638ce6c7959bc391 Mon Sep 17 00:00:00 2001 From: Andrew Auclair Date: Sun, 3 Dec 2023 22:21:55 -0500 Subject: [PATCH] Cleanup. Move NPCAP_DIR to static block. --- .../main/java/pcap/jdk7/internal/NativeMappings.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/jdk7/src/main/java/pcap/jdk7/internal/NativeMappings.java b/jdk7/src/main/java/pcap/jdk7/internal/NativeMappings.java index 486f8723..f2332ffd 100644 --- a/jdk7/src/main/java/pcap/jdk7/internal/NativeMappings.java +++ b/jdk7/src/main/java/pcap/jdk7/internal/NativeMappings.java @@ -61,13 +61,11 @@ class NativeMappings { private static final Map NATIVE_LOAD_LIBRARY_OPTIONS = new HashMap(); - static final File NPCAP_DIR = Paths.get(System.getenv("SystemRoot"), "System32", "Npcap").toFile(); - static { - if (Platform.isWindows() && System.getProperty("jna.library.path") == null) { - if (NPCAP_DIR.exists()) { - NativeLibrary.addSearchPath("wpcap", NPCAP_DIR.getAbsolutePath()); - } + File NPCAP_DIR = Paths.get(System.getenv("SystemRoot"), "System32", "Npcap").toFile(); + + if (Platform.isWindows() && System.getProperty("jna.library.path") == null && NPCAP_DIR.exists()) { + NativeLibrary.addSearchPath("wpcap", NPCAP_DIR.getAbsolutePath()); } }