RFR: 8244853 - The static build of libextnet is missing the JNI_OnLoad_extnet function
Bob Vandette
bob.vandette at oracle.com
Thu May 14 13:32:17 UTC 2020
> On May 14, 2020, at 9:09 AM, Andrew Dinn <adinn at redhat.com> wrote:
>
> Hi Alan,
>
> On 12/05/2020 19:57, Alan Bateman wrote:
>> Looks okay to me.
>
> I am glad to hear that and also to see this fixed quickly (thanks Bob
> for posting the patch). I'd like to see it backported to jdk11u (via
> jdk14u, of course) if possible in order to allow stock jdk14u/11u to be
> used to build GraalVM native images.
>
> I was unaware that this was a spec requirement for static libs. Can you
> point me at any discussion that explains why this is required and what
> the function might be expected to do? or even tell me when it was added
> to the spec? The macro appears to implement an empty function. Is there
> any expectation/requirement that it could/should do something more than
> that?
The static library support was added in JDK 8 under JEP 178 (https://openjdk.java.net/jeps/178 <https://openjdk.java.net/jeps/178>)
and integrated under https://bugs.openjdk.java.net/browse/JDK-8046168 <https://bugs.openjdk.java.net/browse/JDK-8046168>.
The macros that were added to jni_util.h are not part of the specification and were added
for the JDK build to use. There are two forms of the macros. DEF_JNI_OnLoad is used when
the onload function runs initialization logic and DEF_STATIC_JNI_OnLoad that adds
an empty function only when building the library statically. Both macros append the library
name when building static forms of each library.
>
> I am also wondering if this is the only such omission or if other libs
> might require a corresponding JNI_OnLoad_extnet_xxx function.
All JDK native libraries should have this support but I supposed it’s possible that new libraries have
been added since JDK 8 that are missing the DEF_STATIC_JNI_OnLoad. I did a quick scan
of the sources when implementing this fix and did not see any bare JNI_OnLoad functions.
Bob.
>
> regards,
>
>
> Andrew Dinn
> -----------
>
>> On 12/05/2020 19:46, Bob Vandette wrote:
>>> BUG:
>>>
>>> https://bugs.openjdk.java.net/browse/JDK-8244853
>>>
>>> Please review this simple fix for JDK 15 which adds the required
>>> JNI_OnLoad_extnet function to the libextnet.a
>>> static library when it is built.
>>>
>>> the JDK 15 make static-libs-image target currently builds this static
>>> library but it is not spec compliant and
>>> causes the GraalVM native-image utility to fail generating executables
>>> due to the lack of the OnLoad symbol.
>>>
>>>
>>> CHANGE:
>>>
>>> diff --git a/src/jdk.net/linux/native/libextnet/LinuxSocketOptions.c
>>> b/src/jdk.net/linux/native/libextnet/LinuxSocketOptions.c
>>> --- a/src/jdk.net/linux/native/libextnet/LinuxSocketOptions.c
>>> +++ b/src/jdk.net/linux/native/libextnet/LinuxSocketOptions.c
>>> @@ -34,6 +34,11 @@
>>> #include "jdk_net_LinuxSocketOptions.h"
>>> /*
>>> + * Declare library specific JNI_Onload entry if static build
>>> + */
>>> +DEF_STATIC_JNI_OnLoad
>>> +
>>> +/*
>>> * Class: jdk_net_LinuxSocketOptions
>>> * Method: setQuickAck
>>> * Signature: (II)V
>>> diff --git a/src/jdk.net/macosx/native/libextnet/MacOSXSocketOptions.c
>>> b/src/jdk.net/macosx/native/libextnet/MacOSXSocketOptions.c
>>> --- a/src/jdk.net/macosx/native/libextnet/MacOSXSocketOptions.c
>>> +++ b/src/jdk.net/macosx/native/libextnet/MacOSXSocketOptions.c
>>> @@ -32,6 +32,11 @@
>>> #include <netinet/in.h>
>>> #include "jni_util.h"
>>> +/*
>>> + * Declare library specific JNI_Onload entry if static build
>>> + */
>>> +DEF_STATIC_JNI_OnLoad
>>> +
>>> static jint socketOptionSupported(jint sockopt) {
>>> jint one = 1;
>>> jint rv, s;
>>> diff --git
>>> a/src/jdk.net/solaris/native/libextnet/SolarisSocketOptions.c
>>> b/src/jdk.net/solaris/native/libextnet/SolarisSocketOptions.c
>>> --- a/src/jdk.net/solaris/native/libextnet/SolarisSocketOptions.c
>>> +++ b/src/jdk.net/solaris/native/libextnet/SolarisSocketOptions.c
>>> @@ -32,6 +32,11 @@
>>> static int initialized = 0;
>>> /*
>>> + * Declare library specific JNI_Onload entry if static build
>>> + */
>>> +DEF_STATIC_JNI_OnLoad
>>> +
>>> +/*
>>> * Class: jdk_net_SolarisSocketOptions
>>> * Method: init
>>> * Signature: ()V
>>
>
> --
> regards,
>
>
> Andrew Dinn
> -----------
> Senior Principal Software Engineer
> Red Hat UK Ltd
> Registered in England and Wales under Company Registration No. 03798903
> Directors: Michael Cunningham, Michael ("Mike") O'Neill
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/net-dev/attachments/20200514/c0b8c92e/attachment-0001.htm>
More information about the net-dev
mailing list