Maybe recompiling dependencies with Maven? Any performance boost?

I was thinking about dependencies in Maven. Maven downloads them, but it is not known for which target version of the JVM they are compiled and with which compiler. This raises two questions:

  • Will recompilation of dependencies be faster than dependency libraries? I tried to find this, but did not find a sufficient answer. I learned that for 1.6 there is a split bytecode check , which is done when compiling with target 1.6.
    There is also the question Improving the performance of Java 6 in the JDK, JVM, or both? where it is mentioned that newer versions of javac can generate more optimized code.
  • Is it possible to recompile dependent libraries with Maven? Is it possible to configure Maven to download sources, put information about target 1.6 there and run mvn clean install?
    I know the Maven Dependency plugin and the dependency: sources target. This can be used to download the source.
    There is also a Maven Replacer Plugin that allows you to replace text in files. As stated in Issue 58 , XPath support was implemented for it.
    Is it possible to implement it with these plugins for dependency, as well as for its dependencies for its execution? I'm not sure how to do this on the dependencies - perhaps using Maven Replacer Plugin, introducing the configuration into the unpacked pom.xml dependencies?
    Or is there an easier way to configure the target Java version with the build profile in user.xml of the user, which will take precedence for project parameters and, therefore, avoid modifying pom.xml?
+6
source share
2 answers

javac does not perform any optimizations that were there from the earliest days. (And you can even consider it historical). If you have code built by Java 1.0, you can find an improvement, but any of the last decades will probably be as optimal in byte code as it is today.

Most of the optimization is done in the JVM itself, and you should find that updating Java 6 30 is faster than updating Java 6 0 even for exactly the same code.

+3
source

Think for a moment what Maven addiction is. In the most general sense, this is a piece of software developed by someone else, living its own life cycle, which:

  • packed into archive,
  • which exists in the repository
  • under the version descriptor (group, artifact, version).

Which guarantees all Maven. Please note that he does not even say that it is Java (for example, resources or its own libraries). Little. Too few to require automatic recompilation of dependencies.

+1
source

Source: https://habr.com/ru/post/906014/


All Articles