On Wed, 6 Mar 2024 11:33:30 GMT, Magnus Ihse Bursie <i...@openjdk.org> wrote:

> Currently, our symbol visibility handling for tests are sloppy; we only 
> handle it properly on Windows. We need to bring it up to the same levels as 
> product code. This is a prerequisite for 
> [JDK-8327045](https://bugs.openjdk.org/browse/JDK-8327045), which in turn is 
> a building block for Hermetic Java.

Most of these changes is just putting the `EXPORT` define in `export.h` instead 
(where support for `__attribute__((visibility("default")))` is also added). 
However, there are a few other changes worth mentioning:

* `test/jdk/java/lang/Thread/jni/AttachCurrentThread/libImplicitAttach.c` was 
missing an export. This had not been discovered before since that file was not 
compiled on Windows.
* On macOS, the `main` function of a Java launcher needs to be exported, since 
we re-launch the main function when starting a new thread. (This is utterly 
weird behavior driven by how on macOS the main thread is reserved for Cocoa 
events, and I'm not sure this is properly documented by the JNI specification). 
* The `dereference_null` function from `libTestDwarfHelper.h` is looked for in 
the Hotspot hs_err stack trace in 
`test/hotspot/jtreg/runtime/ErrorHandling/TestDwarf.java`. When compiling with 
`-fvisibility=hidden`, it became inline and the test failed. I solved this by 
exporting the function, thus restoring the same situation as was before. I'm 
not sure this is the correct or best solution though, since it depends on what 
you expect `TestDwarf.java` to really achieve. (You can't expect of it to 
perform miracles and show functions that has been inlined in stack traces, 
though...)

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

PR Comment: https://git.openjdk.org/jdk/pull/18135#issuecomment-1980739771

Reply via email to