Invocation Dynamic Libraries - dleskov/excelsior-jet-maven-plugin GitHub Wiki

Contents

Configuration

To create a dynamic library callable from applications written in a non-JVM language instead of a runnable executable, add the following Excelsior JET Maven plugin configuration:

<plugin>
	<groupId>com.excelsiorjet</groupId>
	<artifactId>excelsior-jet-maven-plugin</artifactId>
	<version>1.1.0</version>
	<configuration>
        <appType>dynamic-library</appType>
	</configuration>
</plugin>

Using such libraries is a bit tricky. Like any other JVM, Excelsior JET executes Java code in a special isolated context to correctly support exception handling, garbage collection, and so on. That is why Java methods cannot be directly invoked from a foreign environment. Instead, you have to use the standard Java SE platform APIs, specifically the Invocation API and Java Native Interface (JNI). See samples/Invocation in your Excelsior JET installation directory for detailed examples.

Test Run

To test an invocation dynamic library, you may set a "test" <mainClass> in the plugin configuration. The main method of that class should in turn call methods that are subject for usage from a non-JVM language.

Profiling

To enable PGO for an invocation dynamic library, use the same jet:profile Mojo. However, as a separate client application is likely needed to collect a representative execution profile, the plugin would only create a special profiling image at target/jet/appToProfile. That image contains the natively compiled library and any Excelsior JET Runtime files it requires. You would then need to run an application that would load that library and use it extensively.

⚠️ **GitHub.com Fallback** ⚠️