Include the nested wrapper types in the wrapper jar
Some checks failed
bld-ci / build (./bld, 17, macos-latest, false) (push) Has been cancelled
bld-ci / build (./bld, 21, macos-latest, false) (push) Has been cancelled
bld-ci / build (./bld, 25, macos-latest, false) (push) Has been cancelled
bld-ci / build (./bld, 26, macos-latest, false) (push) Has been cancelled
bld-ci / build (.\bld.bat, 17, windows-latest, false) (push) Has been cancelled
bld-ci / build (.\bld.bat, 21, windows-latest, false) (push) Has been cancelled
bld-ci / build (.\bld.bat, 25, windows-latest, false) (push) Has been cancelled
bld-ci / build (.\bld.bat, 26, windows-latest, false) (push) Has been cancelled
bld-ci / build (unittests, password, unittests, mariadb:10.9, mysql:8, gvenzl/oracle-free:latest, gvenzl/oracle-xe:18-slim, postgres:15, ./bld, 17, ubuntu-latest, true) (push) Has been cancelled
bld-ci / build (unittests, password, unittests, mariadb:10.9, mysql:8, gvenzl/oracle-free:latest, gvenzl/oracle-xe:18-slim, postgres:15, ./bld, 21, ubuntu-latest, true) (push) Has been cancelled
bld-ci / build (unittests, password, unittests, mariadb:10.9, mysql:8, gvenzl/oracle-free:latest, gvenzl/oracle-xe:18-slim, postgres:15, ./bld, 25, ubuntu-latest, true) (push) Has been cancelled
bld-ci / build (unittests, password, unittests, mariadb:10.9, mysql:8, gvenzl/oracle-free:latest, gvenzl/oracle-xe:18-slim, postgres:15, ./bld, 26, ubuntu-latest, true) (push) Has been cancelled
javadocs-pages / deploy (push) Has been cancelled

This commit is contained in:
Geert Bevin 2026-07-27 13:36:33 -04:00
parent 396aa142aa
commit b9f24ebed9
2 changed files with 27 additions and 0 deletions

View file

@ -258,8 +258,11 @@ public class Wrapper {
manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, getClass().getName());
try (var jar = new JarOutputStream(new FileOutputStream(new File(destinationDirectory, WRAPPER_JAR)), manifest)) {
// every nested type of the wrapper has to be added here too,
// the wrapper jar only contains what is listed
addClassToJar(jar, Wrapper.class);
addClassToJar(jar, Wrapper.LaunchMode.class);
addClassToJar(jar, Wrapper.IoAction.class);
addClassToJar(jar, WrapperClassLoader.class);
addClassToJar(jar, FileUtils.class);
addClassToJar(jar, FileUtilsErrorException.class);

View file

@ -18,6 +18,30 @@ import java.util.*;
import static org.junit.jupiter.api.Assertions.*;
public class TestWrapperExtensionResolver {
@Test
void testWrapperJarContainsEveryNestedType()
throws Exception {
// the wrapper jar only contains the classes that are listed
// explicitly, a nested type that isn't listed makes the wrapper
// fail with a NoClassDefFoundError while it bootstraps
var tmp = Files.createTempDirectory("wrapperjar").toFile();
try {
new Wrapper().createWrapperFiles(tmp, "2.4.0-SNAPSHOT");
var entries = new java.util.HashSet<String>();
try (var jar = new java.util.jar.JarFile(new File(tmp, "bld-wrapper.jar"))) {
jar.stream().map(java.util.zip.ZipEntry::getName).forEach(entries::add);
}
for (var nested : Wrapper.class.getDeclaredClasses()) {
assertTrue(entries.contains(nested.getName().replace('.', '/') + ".class"),
"the wrapper jar doesn't contain " + nested.getName());
}
} finally {
FileUtils.deleteDirectory(tmp);
}
}
@Test
void testNoExtensions()
throws Exception {