[prev in list] [next in list] [prev in thread] [next in thread]
List: openjdk-serviceability-dev
Subject: Re: RFR: JDK-8200178 Remove mapfiles for JDK native libraries
From: Martin Buchholz <martinrb () google ! com>
Date: 2018-03-29 6:16:18
Message-ID: CA+kOe08bkip2eGy8rn8viwtQ3eDP8GQYqRUBnsN02WWV6MqwcA () mail ! gmail ! com
[Download RAW message or body]
On Wed, Mar 28, 2018 at 3:14 PM, Magnus Ihse Bursie <
magnus.ihse.bursie@oracle.com> wrote:
> On 2018-03-28 23:53, Martin Buchholz wrote:
>
> I can't find any documentation for what JNIEXPORT and friends actually do.
> People including myself have been cargo-culting JNIEXPORT and JNICALL for
> decades.
> Why aren't they in the JNI spec?
>
> That surprises me. I'm quite certain that javah (or rather, java -h
> nowadays) generate header files with JNIEXPORT and JNICALL.
>
> As you can see in the jni.h and jni_md.h files, JNIEXPORT equals
> __attribute__((visibility("default"))) for compilers that support it (gcc
> and friends), and __declspec(dllexport) for Windows. This means, that the
> symbol should be exported. (And it's ignored if you use mapfiles aka linker
> scripts.)
>
> As for JNICALL, it's empty on most compilers, but evaluates to __stdcall
> on Windows. This defines the calling convention to use. This is required
> for JNI calls from Java. (Ask the JVM team why.) While it's not technically
> required for calling from one dll to another, it's good practice to use it
> all time to be consistent. In any way, it doesn't hurt us.
>
Sure, I can see how JNIEXPORT and JNICALL are implemented, but what do they
*mean?*
For example, one might expect from the JNI prefix that these macros are
exclusively for use by JNI linking, i.e. unsupported except in the output
of javac -h. But of course in practice they are used with arbitrary
symbols to communicate between components of user native code, not just to
communicate with the JVM. Is that a bug?
[Attachment #3 (text/html)]
<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar \
28, 2018 at 3:14 PM, Magnus Ihse Bursie <span dir="ltr"><<a \
href="mailto:magnus.ihse.bursie@oracle.com" \
target="_blank">magnus.ihse.bursie@oracle.com</a>></span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF"><span class="">
On 2018-03-28 23:53, Martin Buchholz wrote:<br>
<blockquote type="cite">
<div dir="ltr">
<div class="gmail_extra">I can't find any documentation for what
JNIEXPORT and friends actually do.</div>
<div class="gmail_extra">People including myself have been
cargo-culting <span \
style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:nor \
mal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spac \
ing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;wor \
d-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">JNIEXPORT
and JNICALL for decades.</span></div>
<div class="gmail_extra"><span \
style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:nor \
mal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spac \
ing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;wor \
d-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Why
aren't they in the JNI spec?</span></div>
</div>
</blockquote></span>
That surprises me. I'm quite certain that javah (or rather, java -h
nowadays) generate header files with JNIEXPORT and JNICALL.<br>
<br>
As you can see in the jni.h and jni_md.h files, JNIEXPORT equals
__attribute__((visibility("<wbr>default"))) for compilers that support \
it (gcc and friends), and __declspec(dllexport) for Windows. This
means, that the symbol should be exported. (And it's ignored if you
use mapfiles aka linker scripts.)<br>
<br>
As for JNICALL, it's empty on most compilers, but evaluates to
__stdcall on Windows. This defines the calling convention to use.
This is required for JNI calls from Java. (Ask the JVM team why.)
While it's not technically required for calling from one dll to
another, it's good practice to use it all time to be consistent. In
any way, it doesn't hurt us.<span \
class=""><br></span></div></blockquote><div><br></div><div>Sure, I can see how \
JNIEXPORT and JNICALL are implemented, but what do they <b><i><font \
size="6">mean?</font></i></b></div><div><br></div><div>For example, one might expect \
from the JNI prefix that these macros are exclusively for use by JNI linking, i.e. \
unsupported except in the output of javac -h. But of course in practice they are \
used with arbitrary symbols to communicate between components of user native code, \
not just to communicate with the JVM. Is that a bug?</div><div><br></div><div> \
</div></div></div></div>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic