Add Instrumentation to the LibreOffice JVM

Noel Grandin noelgrandin at gmail.com
Mon Feb 3 05:55:18 UTC 2025


Sounds quite reasonable to add this to the core product behind an option.

On Sat, 01 Feb 2025 at 21:18, Pierre Vacher <prrvchr at gmail.com> wrote:

> Hi all,
>
> I would like to add the Java Instrumentation
> <https://docs.oracle.com/javase/8/docs/api/java/lang/instrument/Instrumentation.html>
> API to the extensions running under LibreOffice and written in Java.
>
> After some testing, I manage to load the Instrumentation
> <https://docs.oracle.com/javase/8/docs/api/java/lang/instrument/Instrumentation.html>
> 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).
>
> 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. This
> currently allows me to be able to deploy an SPI service type like
> System.LoggerFinder,  and to be able to be the provider for the
> System.Logger
> <https://docs.oracle.com/en/java/javase/19/docs/api/java.base/java/lang/System.Logger.html>
> interface for all running applications on the JVM.
>
> 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. - Add an entry in the LibreOffice configuration (ie:
> xcu file) to enable or disable instrumentation. - Load the JVM with the
> parameters needed for instrumentation depending on the configuration.
>
> Please let me know what you think about this.
>
> Pierre
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice/attachments/20250203/4a0b9aaf/attachment.htm>


More information about the LibreOffice mailing list