<div dir="auto">Sounds quite reasonable to add this to the core product behind an option. </div><div dir="auto"><br><div class="gmail_quote gmail_quote_container" dir="auto"><div dir="ltr" class="gmail_attr">On Sat, 01 Feb 2025 at 21:18, Pierre Vacher <<a href="mailto:prrvchr@gmail.com">prrvchr@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi all,</div><div><br></div><div><span lang="en"><span><span>I would like to add the <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/instrument/Instrumentation.html" target="_blank">Java Instrumentation</a> API</span></span></span><span lang="en"><span><span> to the extensions running under LibreOffice and written in Java</span></span></span><span lang="en"><span><span>.</span></span></span></div><div><span lang="en"><span><span><br></span></span></span></div><div><span lang="en"><span><span>After some testing, I manage to load the <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/instrument/Instrumentation.html" target="_blank">Instrumentation</a> agent at JVM startup, having taken care to add the necessary startup option (ie: -javaagent:/home/prrvchr/github/jdbcDriverOOo/source/UnoAgent/dist/UnoAgent.jar) and put this archive in the classpath (ie: Tools -> Options -> LibreOffice -> Advanced -> Java Options).</span></span></span></div><div><span lang="en"><span><span><br></span></span></span></div><div><span lang="en"><span><span>UnoAgent.jar is an archive containing only one class which itself contains only two methods and this gives access to code injection and the possibility of modifying the search path of the system bootloader. </span></span></span><span lang="en"><span><span>This currently allows me to be able to deploy an </span></span></span><span lang="en"><span><span>SPI service type like </span></span></span><span lang="en"><span><span><a href="http://System.LoggerFinder" target="_blank">System.LoggerFinder</a></span></span></span><span lang="en"><span><span>,  and to be able to be the provider for the <a href="https://docs.oracle.com/en/java/javase/19/docs/api/java.base/java/lang/System.Logger.html" target="_blank">System.Logger</a> interface for all running applications on the JVM.</span></span></span></div><div><span lang="en"><span><span><br></span></span></span></div><div><span lang="en"><span><span>If we want to make this feature accessible to any extension written in Java, it is necessary to make three modifications:
- Add the UnoAgent.jar archive to the SDK.</span></span><span><span>
- Add an entry in the LibreOffice configuration (ie: xcu file) to enable or disable instrumentation.</span></span><span><span>
- Load the JVM with the parameters needed for instrumentation depending on the configuration.</span></span></span></div><div><span lang="en"><span><span><br></span></span></span></div><div><span lang="en"><span><span>Please let me know what you think about this.</span></span></span></div></div><div dir="ltr"><div><span lang="en"><span><span><br></span></span></span></div><div><span lang="en"><span><span>Pierre<br></span></span></span></div><div><span lang="en"><span><span><br></span></span></span></div></div>
</blockquote></div></div>