Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve shading #2835

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Improve shading #2835

wants to merge 1 commit into from

Conversation

otbutz
Copy link
Contributor

@otbutz otbutz commented May 31, 2023

  • properly handles Multi-Release dependencies
  • removes any module-info.class during shading

@otbutz otbutz mentioned this pull request Jun 6, 2023
@karussell
Copy link
Member

properly handles Multi-Release dependencies

Should these warnings disappear or what is the exact purpose?

[WARNING] javax.activation-api-1.2.0.jar, jakarta.activation-api-1.2.2.jar define 31 overlapping classes: 
[WARNING]   - javax.activation.CommandInfo$Beans$1
[WARNING]   - javax.activation.ObjectDataContentHandler
[WARNING]   - javax.activation.DataContentHandlerFactory
[WARNING]   - javax.activation.DataContentHandler
[WARNING]   - javax.activation.CommandObject
[WARNING]   - javax.activation.SecuritySupport$2
[WARNING]   - javax.activation.FileTypeMap
[WARNING]   - javax.activation.CommandInfo

@otbutz
Copy link
Contributor Author

otbutz commented Jun 9, 2023

That's a different story as we're mixing javax and jakarta in our dependencies. Both provide the same API, so we end up with overlapping classes. (Background: https://www.baeldung.com/java-enterprise-evolution)

My changes enable Multi-Release functionality which allows dependencies to make use of newer Java APIs at runtime. You can extract the shaded jar and check the META-INF/versions directory to see which classes are using this mechanism:

image

I'm also removing any module-info.class files. The strong encapsulation doesn't make sense in a shaded jar hence the previous warning:

[WARNING] Discovered module-info.class. Shading will break its strong encapsulation.

@otbutz
Copy link
Contributor Author

otbutz commented Jun 22, 2023

Any objections?

@karussell
Copy link
Member

My changes enable Multi-Release functionality which allows dependencies to make use of newer Java APIs at runtime.

What does this mean?

I don't want to break something and I do not see an advantage at the moment.

That's a different story as we're mixing javax and jakarta in our dependencies. Both provide the same API, so we end up with overlapping classes. (Background: https://www.baeldung.com/java-enterprise-evolution)

Thanks for this clarification.

@otbutz
Copy link
Contributor Author

otbutz commented Sep 7, 2023

My changes enable Multi-Release functionality which allows dependencies to make use of newer Java APIs at runtime.

What does this mean?

See https://openjdk.org/jeps/238. The JVM is capable since version 9 to load alternative class implementations targeting different Java versions. The is all transparently handled by the JVM.

e.g. you could ship a jar that still works with Java 8 but provides an alternative implementation for a class that uses Java 17 features.

While GH might not use this mechanism itself, we break it for our shaded dependencies that might require it.

@otbutz
Copy link
Contributor Author

otbutz commented Sep 7, 2023

An example where this caused problems in the past: komoot/photon#731

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants