Today I find when starting a Java application with the “java -jar” command, it reports the following warning:
WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance
Googling it and this post gives the answer: it’s introduced by the “log4j2” dependency. The original issue can be found here. The fix is:
…, you may need to have Multi-Release set to true in the jar manifest.
So I need to know how to do such configuration in the “build.gradle” of the Java project which creates the jar file.
The final solution comes from this article “Multi-release JARs - Good or bad idea?“, by adding the following content in the “build.gradle” file:
1 | jar { |
The “Multi-release JARs“ is a feature of JDK 9. The article “Multi-release JARs - Good or bad idea?“ not only gives the steps how to create such jar file in Gradle, but also describes why this feature is not a good idea from his perspective.