I've added SIMD code to a Java application that uses Maven to build, and now I have to run it like this:
mvn exec:java -Dexec.mainClass="com.path.to.app.MainClass" -Dexec.classpathScope=runtime -Dexec.systemProperties="-da --add-modules=jdk.incubator.vector"
I also created .mvn/jvm.config
file with the following content:
--add-modules=jdk.incubator.vector
Finally, in pom.xml
I added the following under project/build/plugins
:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<compilerArgs>
<arg>--add-modules=jdk.incubator.vector</arg>
</compilerArgs>
</configuration>
</plugin>
The application itself runs from Eclipse and from command-line with Maven as shown above. However, if I run mvn install
, the JUnit tests fail:
java.lang.NoClassDefFoundError: jdk/incubator/vector/Vector
...
Caused by: java.lang.ClassNotFoundException: jdk.incubator.vector.Vector
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
All the above steps were found on the internet. I couldn't find how to fix JUnit. Please, suggest.
OpenJDK 19, Maven 3.8.6, Ubuntu 20.04, JUnit is enabled in pom.xml
as follows:
<junit.version>4.13.2</junit.version>
...
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>