Skip to content

Commit

Permalink
Fix class-path order when Manifests include "Class-Path" attributes
Browse files Browse the repository at this point in the history
`destination` is the classpath GraalVM creates from parsing the jar
files passed to it. The ordering of the entries in the classpath is
important. Jar files themselves should be added before the entries of
their corresponding "Class-Path" attributes.

At the same time we want to process the contents of
`META-INF/native-image` of the entries in the "Class-Path" before
processing the contents of `META-INF/native-image` of the jar itself.
This is required to ensure that the jar `META-INF/native-image` contents
can override those of the entries in its "Class-Path".

As a result I chose to optimistically add the path to the classpath (aka
`destination`) and remove it afterwards if deemed necessary.

Fixes oracle#7677
  • Loading branch information
zakkak committed Dec 4, 2023
1 parent 645cae4 commit 5c0bfba
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2110,12 +2110,13 @@ private void addImageClasspathEntry(LinkedHashSet<Path> destination, Path classp

Path classpathEntryFinal = useBundle() ? bundleSupport.substituteClassPath(classpathEntry) : classpathEntry;
if (!imageClasspath.contains(classpathEntryFinal) && !customImageClasspath.contains(classpathEntryFinal)) {
boolean added = destination.add(classpathEntryFinal);
if (ClasspathUtils.isJar(classpathEntryFinal)) {
processJarManifestMainAttributes(classpathEntryFinal, (jarFilePath, attributes) -> handleClassPathAttribute(destination, jarFilePath, attributes));
}
boolean ignore = processClasspathNativeImageMetaInf(classpathEntryFinal);
if (!ignore) {
destination.add(classpathEntryFinal);
if (added && ignore) {
destination.remove(classpathEntryFinal);
}
}
}
Expand Down

0 comments on commit 5c0bfba

Please sign in to comment.