Repository navigation
Package manifest attributes are missing for nested jars without directory entries - #52244
Merged
philwebb merged 2 commits intoOct 17, 2026
Merged
Conversation
Relax the requirement for a package jar entry to exist when defining a package. See spring-projectsgh-52244 Signed-off-by: Jan Mohr <[email protected]>
philwebb
force-pushed
the
nested-jar-package-manifest
branch
from
October 17, 2026 00:06
30e667e to
48cf3e0
Compare
Member
|
Thanks very much @janwaleed09! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When an application runs as an executable jar, packages from some nested jars are defined without their manifest attributes. For example,
Package.getImplementationVersion()returnsnullfororg.apache.catalina.startup(tomcat-embed-core) andorg.h2(h2). When the same application runs from the IDE or from the extracted layout, the values are there (11.0.27and2.5.252in my sample app).JarUrlClassLoader.definePackageonly uses the manifest of a jar if the jar contains the class entry and a directory entry for the package. Some jars have no directory entries at all (tomcat-embed-core and h2 are examples), so the package is added toundefinablePackagesand later defined byURLClassLoaderwithout any attributes.The class entry check is enough to find the jar that contains the class, so this change removes the directory entry check. I added a test that loads a class from a nested jar without directory entries.
In a sample app with web, JPA, security and actuator (101 nested jars), 125 packages had no manifest attributes before this change. After it, 124 of them match the extracted layout. The last one,
org.slf4j.helpers, has a different cause:log4j-to-slf4jlooks uporg.slf4j.helpers.Log4jLoggerFactory, which does not exist, so the package is marked as undefinable before a real class from it is loaded. I left that out of this PR, but I'm happy to open an issue for it.This looks related to #38996, which fixed the same symptom for the application's own classes.