byte-buddy icon indicating copy to clipboard operation
byte-buddy copied to clipboard

Byte Buddy Multi-Release JAR causes bad IDE experience for viewing source & debugging

Open Marcono1234 opened this issue 7 months ago • 2 comments

Problem

For #1657 the Byte Buddy classes were duplicated under META-INF/versions/9 (= Multi-Release JAR) to use newer compiler features.

The problem is that for IDEs (at least IntelliJ, with a Gradle build setup) this causes a bad user experience because the sources.jar only contains the source files in the main directory:

  • hovering over Byte Buddy classes does not show any documentation
  • opening the Byte Buddy code always opens the IntelliJ-decompiled version first IntelliJ screenshot
    • this also affects debugging, which makes it quite unpleasant

Note: The problem here is not that IntelliJ is not downloading the sources JAR; it does that successfully. The issue is that IntelliJ apparently does not show the source code from it by default because is it only for the main sources, not the multi-release ones[^1].

Potential solution

For the sources.jar copy the main sources to META-INF/versions/9 as well. That seems to solve this problem (please double-check though, if possible) but causes the source JAR to increase quite in size. Might not be a big problem though?

Disadvantage: When clicking on links in stack traces, IntelliJ opens a small pop-up for deciding if you want to open the main or the multi-release source.

[^1]: I think this IntelliJ behavior is reasonable because normally multi-release code would differ from the main code. The Byte Buddy case here might be special because the source is identical (but IntelliJ cannot know that). See also IDEA-341317 which tracked multi-release JAR navigation.

Marcono1234 avatar May 22 '25 11:05 Marcono1234

Good point, I probably have to duplicate the source. I would of course prefer if IntelliJ could fall-back to the base source file, but I also understand that this might not be always right. I will see how I can possibly manipulate the created jar file.

raphw avatar May 22 '25 12:05 raphw

It seems like the source plugin cannot do this by itself, but I think I made this work using the antrun plugin. I will test this more thoroughly when I get a chance, but feel free to build Byte Buddy from master to see if this works for you!

raphw avatar Jun 15 '25 23:06 raphw

but I think I made this work using the antrun plugin

Thanks! You mean 20417280921ae790d85750adafab63f35ebb1b56, right?

I have tested it with Byte Buddy 1.17.6 now and it is already a lot better for IntelliJ. There are some smaller inconveniences with this, for example IntelliJ offers both the regular and multi-release source code now when searching by class name. However, I am not sure if these issues can be solved easily.

If you want, feel free to close this issue.

Marcono1234 avatar Jul 01 '25 16:07 Marcono1234

Thanks. It's gonna be the IDE processing the source jar, nothing to do unfortunately.

raphw avatar Jul 01 '25 20:07 raphw