jira-importer commented on issue #156:
URL: 
https://github.com/apache/maven-jar-plugin/issues/156#issuecomment-2956674145

   **[Jorge 
Solórzano](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=jorsol)**
 commented
   
   This issue as it stands out today is irrelevant, and it actually does the 
correct thing, let me explain:
   
   The `MANIFEST.MF` does not reflect the version of the compiler that built 
the jar because you can compile a class using a higher JDK version that targets 
a lower Java bytecode, so assume that you build a JAR that compiles the classes 
with JDK 17 but targets (–release) Java 11, which version do you use as 
**Build-Jdk** option? you are using Java 17 so it makes sense to set the 
version to {+}17{+}, but at the same time, you are compiling to Java 11 so you 
could argue that it must use {+}11{+}, but that is not true, and even the 
bytecode produced could be different.
   
   But even if we try to use the "same" version in the **Build-Jdk** property 
that compiles the classes, the most important point that this is irrelevant 
now, is that we now have Multi-Release JARs ("MRJAR"), that contain bytecode 
generated for different Java versions in a versioned area of the JAR, so, if 
you build a JAR which compiles the base classes as Java 8, and have versioned 
classes for Java 9, Java 11, and Java 17, which version do you set in the 
**Build-Jdk** property? If you use the lower one (Java 8) that is not correct 
since it contains classes with different bytecode, and if you use the higher 
one (Java 17) that could not be entirely true as you might probably build the 
JAR using JDK 19.
   
   In the end, the **Build-Jdk** should be used more as a property to signal 
which JDK was used to build (or a better term "assemble") the JAR rather than 
to know the compiled bytecode contained, when I mean that it actually does the 
correct thing is because if the JDK used to assemble the JAR is the one that 
Maven uses, then that's the JDK to be used in the property.
   
   NOTE: This has no relation with the issue MJAR-289 since Toolchains handling 
is a different topic and this issue does not duplicate that, and while I agree 
that toolchain support could be improved, the same premise should be done, if 
maven-jar-plugin is aware of the toolchain, and the toolchain of 
maven-compiler-plugin is different from the toolchain used in maven-jar-plugin, 
which version should be used in the property? of course the one that uses 
maven-jar-plugin, yet doesn't need any special treatment since it will use the 
"java.version" property which again is the correct thing to do.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to