So I finally switched to Java 15, and found out that my old code is not compiling anymore.
I use classes from package sun.jvmstat.monitor
and class LocalVmManager
to retrieve the pid of all JVM running in the system: this is working on Java8, but no more on Java15 (I think it doesn't work since Java9).
Thanks to IntelliJ I discovered that I need to pass the following options to javac
: --add-exports jdk.internal.jvmstat/sun.jvmstat.perfdata.monitor.protocol.local=ALL-UNNAMED --add-exports jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED --add-exports jdk.internal.jvmstat/sun.jvmstat.monitor.event=ALL-UNNAMED
And in fact with this options I'm able to compile via command line. But I also wanted to compile my application via mvn compile
. How can I specify options to compiler in the pom.xml ?
I tried the following with no luck:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>15</release>
<compilerArgs>
<arg>--add-exports</arg>
<arg>jdk.internal.jvmstat/sun.jvmstat.perfdata.monitor.protocol.local=ALL-UNNAMED</arg>
<arg>--add-exports</arg>
<arg>jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED</arg>
<arg>--add-exports</arg>
<arg>jdk.internal.jvmstat/sun.jvmstat.monitor.event=ALL-UNNAMED</arg>
</compilerArgs>
<fork>true</fork>
</configuration>
</plugin>
In the meantime I'm going to change my code and read the pid of running JVMs by scanning the /proc/
directory.