RFR: 8337143: (fc, fs) Move filesystem-related native objects from libnio to libjava [v4]

Brian Burkhalter bpb at openjdk.org
Fri Aug 9 16:01:32 UTC 2024


On Fri, 9 Aug 2024 15:47:07 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

>> Loading "net" was removed from IOUtil so I am thinking that IOUtil must have been initialized somewhere before constructing Inet6AddressImpl, but I've not identified where just yet.
>
> I see. Inet6AddressImpl and Inet4AddressImpl are symetric classes implementing InetAddressImpl. Both will make native calls to the "net" library - so both require the library to be loaded.
> 
> In the JDK, these two classes are only loaded by InetAddress, after the "net" library has been loaded.
> 
> The test test java/net/InetAddress/NullCharInHostnameDriver.java seems to be an outlier (@AlekseiEfimov ?) which for some reason uses a private API (the test is injected in java.base) and create a new instance of Inet6AddressImpl before InetAddress is loaded. This is why without this change to Inet6AddressImpl we get the UnsatisfiedLinkError. We would have gotten the same from Inet4AddressImpl if the test had first required access to Inet4AddressImpl instead.
> 
> So it seems that we should either add the call to load the "net" library to both Inet6AddressImpl and Inet4AddressImpl for symetry (there doesn't seem to be any reason why Inet6AddressImpl would be preferred in this respect),  or remove this call from Inet6AddressImpl and add it to the test instead. Adding the call to jdk.internal.loader.BootLoader.loadLibrary("net"); in the test should work since the actual test class (NullCharInHostname.java) is injected in java.base.

Thanks. I'll try adding it to the test.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/20317#discussion_r1711723045


More information about the core-libs-dev mailing list