[ad_1]
I work on an application that uses a Java library that interfaces with a native library. We’re discovering recently that unit tests (using the spring runner) of this code are consistently failing under specific circumstances, but successful in other circumstances.
We use Java 8 and SpringBoot 2.3.12.
I’m currently running these tests on Windows 10.
When I run the tests from “mvn package” without any special qualifications, the tests run successfully.
When I run any of the tests in Eclipse (2022-03), I get UnsatisfiedLinkError
, and it refers to the first method in a particular class which is defined as “native”. I don’t think there’s anything special about the class or method, it’s likely just the first one that it tries to load.
I also get the exact same error when I add the following properties to my Surefire configuration:
<reuseForks>false</reuseForks>
<forkCount>1</forkCount>
These force each test to run in a separate and new jvm instance.
I also augmented the code that gets run to print out all of the environment variables and system properties. I stored the results for both the “good” test and the “bad” test into separate files, and I compared them. There were no significant differences. The java.class.path system property value was identical to the character. The “good” test had a couple of environment variables that indicated the process id.
I tried running SysInternals ProcMon, and I had it filter on the name of the DLL with the native code. I did this while running both the “good” and “bad” tests. Both of them appeared to open the correct dll.
I could use some ideas of what else to try here.
[ad_2]