<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body style='font-size: 10pt; font-family: Verdana,Geneva,sans-serif'>
<p>Hi Maurizio,<br />thanks for the answer, I really appreciate it.</p>
<p>I agree that "mind reading" is not possible this days but as you mentioned, a custom SymbolLookups would be great.</p>
<p>In the mean time to make it work I removed the --library param when using jextract and<br />I created a static {} block in my class that manually loads the libs.</p>
<p><a href="https://github.com/sblantipodi/firefly_luciferin/blob/271bf8ddf28ae32454efa9bddc2edd30a4556cff/src/main/java/org/dpsoftware/gui/bindings/appindicator/LibAppIndicator.java#L137">https://github.com/sblantipodi/firefly_luciferin/blob/271bf8ddf28ae32454efa9bddc2edd30a4556cff/src/main/java/org/dpsoftware/gui/bindings/appindicator/LibAppIndicator.java#L137</a><br /><br />Thanks again for the answer.</p>
<p>Ciao<br />Davide</p>
<p><br /></p>
<p id="reply-intro">On 2024-11-13 11:50, Maurizio Cimadamore wrote:</p>
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0">
<div class="pre" style="margin: 0; padding: 0; font-family: monospace"><span style="white-space: nowrap;">Hi,</span><br /><span style="white-space: nowrap;">thanks for the feedback, and the positive comments :-)</span><br /><br />I see what you mean - you basically have two possible names for the library, and either one or the other should "match".<br /><br />Now, the jextract code could be updated a little. For instance, jextract could be a bit smarter when creating the library lookup: if an exception is thrown, some kind of "empty lookup" could be used. This would avoid exceptions being thrown.<br /><br />This is doable -- but the question then becomes: what if a user really expects a library to be there? In that case, the exception would be "swallowed" only to pop up later, e.g. when the first downcall is created (at which point the bindings will fail because no symbol for the downcall could be found -- given the library has not been loaded at all).<br /><br />So, doing a change like the one you suggest amounts at attempting to read the user mind (and all tools -- jextract included -- are notoriously bad at that :-) ). Now, it might be that the "exception swallowing" behavior I described above is more generally useful than what we do now, but with things like these I'm always afraid that what's best for some developers might not be best for others. So... we need more feedback from all of you to understand whether such a change would be perceived as beneficial.<br /><br /><span style="white-space: nowrap;">A similar issue was also discussed here:</span><br /><br /><span style="white-space: nowrap;"><a href="https://mail.openjdk.org/pipermail/jextract-dev/2024-September/001949.html" target="_blank" rel="noopener noreferrer">https://mail.openjdk.org/pipermail/jextract-dev/2024-September/001949.html</a></span><br /><br />Note also that, longer term (as mentioned in that discussion) we have plans to allow custom SymbolLookups to be plugged in by users, so that jextract can get away with "less mind reading".<br /><br />Cheers<br />Maurizio<br /><br /><span style="white-space: nowrap;">On 13/11/2024 10:35, Davide Perini wrote:</span>
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0"><br /><span style="white-space: nowrap;">Hi all,</span><br /><span style="white-space: nowrap;">I'm starting to use jextract to workaround some issues I found in AWT.</span><br />AWT uses 20+ years old APIs for notifications and tray icons and it doesn't work well in recent Linux distros and on Windows 11 24H2.<br /><br />I must say that foreign memory API is a massive improvement to the Java ecosystem, wow.<br />I created a binding for the tray icon and for the notification API in minutes, this is awesome.<br /><br /><span style="white-space: nowrap;">To create my bindings I start with jextract with something like this:</span><br /><span style="white-space: nowrap;">jextract \</span><br /><span style="white-space: nowrap;">-l ayatana-appindicator3 \</span><br /><span style="white-space: nowrap;">-l appindicator3 \</span><br /><span style="white-space: nowrap;">....</span><br /><span style="white-space: nowrap;">/usr/include/libayatana-appindicator3-0.1/libayatana-appindicator/app-indicator.h</span><br /><br /><br /><span style="white-space: nowrap;">With this command I would tell to jextract to search for</span><br /><span style="white-space: nowrap;">ayatana-appindicator3</span><br />or<br />appindicator3<br /><br />but when I use the binding it throws an exception if one of the two libs are not present.<br /><br /><br />Libs uses the same interfaces and I don't need two bindings for these two libraries.<br /><br />Is it possible to tell to jextract to create a binding that searches for "multiple lib name" and don't throw and error in the event that one lib is found?<br /><br />Thanks<br />Davide<br /><br /></blockquote>
</div>
</blockquote>
<p><br /></p>
</body></html>