As part of #30241, java 21 classes were added following MR-JAR structure, e.g. org.springframework.core.task.VirtualThreadDelegate
.
While these classes are part of the regular compiled .jar, they are missing from the sources/javadoc jars, making IDEs show the java 17 content, which is confusing.
Comment From: bclozel
Thanks for the suggestion. That's not something we considered at all so far.
Can you share a link to the sources jar format expected by tools? Do you know which IDEs support this feature? Alternatively, pointing to another project that ships sources jars that are supported in your IDE would be a good start.
Comment From: andreiamariei
I'm new to Multi-Release jars, originally I reported this issue as the v21 .java file was missing from sources.jar, but .class file is present in regular .jar under META-INF/versions/21/...
.
I investigated a bit more, and IntelliJ IDEA 2024.1 EAP adds some support for Multi-Release jars. For example, I can open with it the v21 VirtualThreadDelegate
, just that it's showing the decompiled structure because of the missing java file. After manually adding the .java file to the sources.jar, IDEA 2024.1 EAP picked it up.
I think spring sources.jar should contain the .java file in the same directory structure where regular jar stores the classes. It might be limitation of the gradle plugin me.champeau.mrjar
though
Comment From: snicoll
As far as I can see there are no MR-JAR structure for source and/or javadoc that are concepts built on top of the regular archive. Maven doesn't seem to have any support for that, and so isn't Gradle. That said, given you've tested it, it wouldn't hurt to include the source there with the same structure.
Comment From: simonbasle
@andreiamariei can you clarify exactly how and where you manually added the Java 21 source file ?
I was able to quickly produce a -sources.jar
which includes JDK 21-specific sources in META-INF/versions/21/
but IntelliJ 2024.1 EAP doesn't seem to pick it up. It does decompile the correct 21-specific .class
though:
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-projects-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.
Comment From: andreiamariei
I manually added the .java file into the .jar file using Total Commander, you can see the screenshot below how Intellij 2024.1 EAP shows the 21 version for me. Underlined in red is the location of the .java file. The blue selection is how Intellij navigates to it, which looks like a bug in Intellij. Could you update it to the latest version and try again?
Comment From: simonbasle
I still cannot reproduce with version 2024.1 EAP (build 12662.62). I'm really not sure there's any intentional support in IDEA, could be a glitch or perfect circumstances that make it appear to work from your perspective...
In any case, there's no official specification for multi-release source jars so until we can refer to anything documented (on IDEA or Java side), we'll set this issue aside.
Feel free to re-open or create a new issue if some kind of official support is announced and documented in the future.