From david.holmes at oracle.com Tue Feb 18 07:21:11 2020 From: david.holmes at oracle.com (David Holmes) Date: Tue, 18 Feb 2020 17:21:11 +1000 Subject: Understanding -nativepath and how it is applied Message-ID: <4fed1c59-4736-d627-ce89-b456d9c29702@oracle.com> I have a test that uses native code. I specify "@run main/othervm/native" for the main test class I invoke jtreg with -nativepath My test exec's a second VM that needs to load the native library. This is done using ProcessTools.executeTestJvm. When I run the test locally it works fine and if I print out java.library.path it shows that the "nativepath" value has been set in that property. But when I run the test via our testing system it fails because the native library cannot be found! The jtr file shows -Dtest.nativepath being set as expected, but the exec'd VM doesn't have its value in java.library.path! I can obviously fix this by explicitly adding -Djava.library.path=... as an explicit arg to the exec'd VM, but I want to understand how this works in the local case but not otherwise. I'm also wondering whether this is something that should be automatically handled at the ProcessTools level? Thanks, David From jonathan.gibbons at oracle.com Tue Feb 18 19:33:19 2020 From: jonathan.gibbons at oracle.com (Jonathan Gibbons) Date: Tue, 18 Feb 2020 11:33:19 -0800 Subject: Understanding -nativepath and how it is applied In-Reply-To: <4fed1c59-4736-d627-ce89-b456d9c29702@oracle.com> References: <4fed1c59-4736-d627-ce89-b456d9c29702@oracle.com> Message-ID: <5b653dd6-e91f-38c6-aca4-30199dfa86a6@oracle.com> On 02/17/2020 11:21 PM, David Holmes wrote: > I have a test that uses native code. > > I specify "@run main/othervm/native" for the main test class > > I invoke jtreg with -nativepath > > My test exec's a second VM that needs to load the native library. This > is done using ProcessTools.executeTestJvm. > > When I run the test locally it works fine and if I print out > java.library.path it shows that the "nativepath" value has been set in > that property. > > But when I run the test via our testing system it fails because the > native library cannot be found! The jtr file shows -Dtest.nativepath > being set as expected, but the exec'd VM doesn't have its value in > java.library.path! > > I can obviously fix this by explicitly adding -Djava.library.path=... > as an explicit arg to the exec'd VM, but I want to understand how this > works in the local case but not otherwise. > > I'm also wondering whether this is something that should be > automatically handled at the ProcessTools level? > > Thanks, > David David, jtreg has no control over the VMs that a test might itself exec. That is entirely up to the test code, and any library code (such as ProcessTools) that may be involved. The most that jtreg can do is provide the information (i.e. test.* properties) that may be required in order for the test to do what is required in the specific context of the test itself. -- Jon From david.holmes at oracle.com Wed Feb 19 03:38:47 2020 From: david.holmes at oracle.com (David Holmes) Date: Wed, 19 Feb 2020 13:38:47 +1000 Subject: Understanding -nativepath and how it is applied In-Reply-To: <5b653dd6-e91f-38c6-aca4-30199dfa86a6@oracle.com> References: <4fed1c59-4736-d627-ce89-b456d9c29702@oracle.com> <5b653dd6-e91f-38c6-aca4-30199dfa86a6@oracle.com> Message-ID: <4378dc6a-3cc4-2c13-5254-1d681973ecb6@oracle.com> Hi Jon, On 19/02/2020 5:33 am, Jonathan Gibbons wrote: > > > On 02/17/2020 11:21 PM, David Holmes wrote: >> I have a test that uses native code. >> >> I specify "@run main/othervm/native" for the main test class >> >> I invoke jtreg with -nativepath >> >> My test exec's a second VM that needs to load the native library. This >> is done using ProcessTools.executeTestJvm. >> >> When I run the test locally it works fine and if I print out >> java.library.path it shows that the "nativepath" value has been set in >> that property. >> >> But when I run the test via our testing system it fails because the >> native library cannot be found! The jtr file shows -Dtest.nativepath >> being set as expected, but the exec'd VM doesn't have its value in >> java.library.path! >> >> I can obviously fix this by explicitly adding -Djava.library.path=... >> as an explicit arg to the exec'd VM, but I want to understand how this >> works in the local case but not otherwise. >> >> I'm also wondering whether this is something that should be >> automatically handled at the ProcessTools level? >> >> Thanks, >> David > > David, > > jtreg has no control over the VMs that a test might itself exec. That is > entirely up to the test code, and any library code (such as > ProcessTools) that may be involved. The most that jtreg can do is > provide the information (i.e. test.* properties) that may be required in > order for the test to do what is required in the specific context of the > test itself. Okay but somehow we go from -nativepath to -Dtest.nativepath to -Djava.library.path (or equivalent). And somehow when running jtreg locally an exec'd VM gets the same java.library.vm as the VM exec'd by jtreg; but when jtreg is run in other cases it doesn't. I'm trying to understand how we can possibly see differences in behaviour here. Thanks, David > -- Jon