Issue in combination with JLink/JPackage

Duncan Gittins duncan.gittins at gmail.com
Mon Feb 7 14:24:00 UTC 2022


See my other email on this. I found that the issue in 
RuntimeHelper.lookup() was caused by failed symbol lookups for global 
variables that I did not depend on (and which cannot be found in DLL, 
only static LIB - so won't ever resolve in Panama?)

Because jextract puts multiple definitions per class trying accessing a 
required caused failed lookups to try to access ucrtbase.dll

You may be able to bypass the issue by either:
1) using jextract with "-Djextract.constants.per.class=0". This puts 
every symbol into own class, so when any class is loaded it does not 
trigger any unnecessary symbol lookups
2) use jextract with exact types so jextract only generates the exact 
set of symbols you need:
     --include-macro xyz
     --include-function xyz

The above should help as long as you aren't depending on the actual 
library load of ucrtbase.dll.

Kind regards

Duncan

On 07/02/2022 12:19, Maurizio Cimadamore wrote:
> No problem.
>
> I've filed this:
>
> https://bugs.openjdk.java.net/browse/JDK-8281335
>
> Cheers
> Maurizio
>
> On 07/02/2022 12:15, clemens.lanthaler at itarchitects.at wrote:
>> Hi Maurizio,
>>
>> thanks allot for your help and for the investigation.
>>
>> best regards,
>> Clemens
>>
>>
>>> On 7. Feb 2022, at 13:03, Maurizio Cimadamore 
>>> <maurizio.cimadamore at oracle.com> wrote:
>>>
>>> 
>>>
>>> Hi Clemens (it seems like your message got dropped by the mailing 
>>> list, not sure why).
>>>
>>> Your message seems to point at some bad interaction between jpackage 
>>> and Panama both trying to load ucrtbase.dll (and only one can win). 
>>> Apparently, the Panama code isn't executed early enough in the 
>>> jpackage case.
>>>
>>> We'll need to investigate more.
>>>
>>> Maurizio
>>>
>>> On 05/02/2022 15:31, Clemens Lanthaler wrote:
>>>> Hello everybody,
>>>>
>>>> I am the developer of project librawfx 
>>>> (github.com/lanthale/librawfx) and the app Photoslide 
>>>> (github.com/lanthale/photoslide).
>>>>
>>>> At the begining of Photoslide the whole app was modularized and 
>>>> therefore all was working including librawfx which is using project 
>>>> Panama. After a while I had to change to a mixed (modulepath for 
>>>> jdk+javafx libs and classpath for the rest) environment and 
>>>> deployed my app PhotoSlide again. Under Linux and OSX all is 
>>>> working as expected. The problem exists only under Windows. 
>>>> Furthermore it exists only if I am creating a Jlink/Jpackage 
>>>> distribution. Running the app from maven was working as expected. 
>>>> Only the JPackage launcher have the issue and I have no clue what 
>>>> the root cause is.
>>>>
>>>> The exception I am always seeing is:
>>>> Feb. 03, 2022 7:44:58 PM org.librawfx.RAWImageLoader load
>>>> SCHWERWIEGEND: null
>>>> java.lang.UnsatisfiedLinkError: Native Library 
>>>> C:\Windows\System32\ucrtbase.dll already loaded in another classloader
>>>> (Full stacktrace below)
>>>>
>>>> How can you reproduce the issue:
>>>>
>>>>  1. Git clone project https://github.com/lanthale/JeditFX.git
>>>>  2. Start the app with "mvn javafx:run at default-cli"
>>>>  3. Click on the open icon in the toolbar and select file
>>>> "...\Documents\NetBeansProjects\JeditFX\JeditFX\src\main\resources\RAW-ADOBE_DNG_Sample.dng"
>>>>  4. The app is showing the image below the textarea
>>>>  5. Create the jlink/jpackage app-image with "mvn -Ppackage clean
>>>>     install"
>>>>  6. Start the exe jeditfx.exe in directory ".\target\jeditfx"
>>>>  7. Open the same file again -> No image is shown below the text
>>>>     area and the exception is thrown in the background
>>>>
>>>>
>>>> I have tried many things but it is only happening if I have 
>>>> OpenJFX+JDK Modules on the module path and the rest of the jar 
>>>> files on the classpath. All libs which are not having any Panama 
>>>> code inside of the app are working perfectly and it is only 
>>>> happening on Windows.
>>>>
>>>> Thank you in advance for your help!
>>>>
>>>> best regards,
>>>> Clemens
>>>>
>>>>
>>>>
>>>>
>>>> *Full stacktrace from Photoslide:*
>>>>
>>>> Feb. 03, 2022 7:44:41 PM org.photoslide.search.SearchIndex 
>>>> createSearchIndex
>>>> INFORMATION: Start time create searchDB: 2022-02-03T19:44:41.693455
>>>> Feb. 03, 2022 7:44:42 PM org.photoslide.SoftwareUpdater 
>>>> lambda$checkForSoftwareUpdates$2
>>>> INFORMATION: No new version found!
>>>> Feb. 03, 2022 7:44:43 PM org.photoslide.search.SearchIndex 
>>>> lambda$createSearchIndex$0
>>>> INFORMATION: End time create searchDB: 2022-02-03T19:44:43.186194400
>>>> Feb. 03, 2022 7:44:58 PM org.librawfx.RAWImageLoader load
>>>> SCHWERWIEGEND: null
>>>> java.lang.UnsatisfiedLinkError: Native Library 
>>>> C:\Windows\System32\ucrtbase.dll already loaded in another classloader
>>>> at 
>>>> java.base/jdk.internal.loader.NativeLibraries.loadLibrary(Unknown 
>>>> Source)
>>>> at 
>>>> java.base/jdk.internal.loader.NativeLibraries.loadLibrary(Unknown 
>>>> Source)
>>>> at 
>>>> jdk.incubator.foreign/jdk.internal.foreign.SystemLookup.lambda$makeWindowsLookup$1(Unknown 
>>>> Source)
>>>> at 
>>>> jdk.incubator.foreign/jdk.internal.foreign.SystemLookup.libLookup(Unknown 
>>>> Source)
>>>> at 
>>>> jdk.incubator.foreign/jdk.internal.foreign.SystemLookup.makeWindowsLookup(Unknown 
>>>> Source)
>>>> at jdk.incubator.foreign/jdk.internal.foreign.SystemLookup.(Unknown 
>>>> Source)
>>>> at 
>>>> jdk.incubator.foreign/jdk.incubator.foreign.CLinker.systemLookup(Unknown 
>>>> Source)
>>>> at org.libraw.win.RuntimeHelper.lookup(RuntimeHelper.java:33)
>>>> at org.libraw.win.libraw_h.(libraw_h.java:15)
>>>> at 
>>>> org.librawfx.LibrawImage.readPixelDataFromStream(LibrawImage.java:113)
>>>> at org.librawfx.RAWImageLoader.getImageData(RAWImageLoader.java:168)
>>>> at org.librawfx.RAWImageLoader.load(RAWImageLoader.java:84)
>>>> at 
>>>> javafx.graphics at 18-ea/com.sun.javafx.iio.ImageStorage.loadAll(Unknown 
>>>> Source)
>>>> at 
>>>> javafx.graphics at 18-ea/com.sun.javafx.iio.ImageStorage.loadAll(Unknown 
>>>> Source)
>>>> at 
>>>> javafx.graphics at 18-ea/com.sun.javafx.tk.quantum.PrismImageLoader2.loadAll(Unknown 
>>>> Source)
>>>> at 
>>>> javafx.graphics at 18-ea/com.sun.javafx.tk.quantum.PrismImageLoader2.(Unknown 
>>>> Source)
>>>> at 
>>>> javafx.graphics at 18-ea/com.sun.javafx.tk.quantum.QuantumToolkit.loadImage(Unknown 
>>>> Source)
>>>> at javafx.graphics at 18-ea/javafx.scene.image.Image.loadImage(Unknown 
>>>> Source)
>>>> at 
>>>> javafx.graphics at 18-ea/javafx.scene.image.Image.initialize(Unknown 
>>>> Source)
>>>> at javafx.graphics at 18-ea/javafx.scene.image.Image.(Unknown Source)
>>>> at 
>>>> org.photoslide.datamodel.MediaFileLoader$1.call(MediaFileLoader.java:46) 
>>>>
>>>> at 
>>>> org.photoslide.datamodel.MediaFileLoader$1.call(MediaFileLoader.java:43) 
>>>>
>>>> at 
>>>> javafx.graphics at 18-ea/javafx.concurrent.Task$TaskCallable.call(Unknown 
>>>> Source)
>>>> at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
>>>> at 
>>>> java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown 
>>>> Source)
>>>> at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
>>>> at 
>>>> java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown 
>>>> Source)
>>>> at 
>>>> java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown 
>>>> Source)
>>>> at java.base/java.lang.Thread.run(Unknown Source)




More information about the panama-dev mailing list