Skip to content

Commit 82959da

Browse files
author
ed
committed
fix(jdk21): for jdk21 springboot, the jar is under: jar:nested instead of jar:file.
1 parent 6fc2c23 commit 82959da

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ compileTestJava.options.encoding = "UTF-8"
3030
apply plugin: 'maven-publish'
3131

3232
group 'io.gitee.gaoxingliang:dbupgrader'
33-
version '0.1.5'
33+
version '0.1.6'
3434
sourceCompatibility = '1.8'
3535
targetCompatibility = '1.8'
3636

dbupgrader-starter/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ compileTestJava.options.encoding = "UTF-8"
3030
apply plugin: 'maven-publish'
3131

3232
group 'io.gitee.gaoxingliang:dbupgrader-starter'
33-
version '0.1.5'
33+
version '0.1.6'
3434
sourceCompatibility = '1.8'
3535
targetCompatibility = '1.8'
3636

src/main/java/io/github/gaoxingliang/dbupgrader/utils/ReflectionUtils.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ private static void findClassesInDir(File directory, String packageName, List<Cl
5252

5353
private static void findClassesInJar(URL resource, String path, String packageName, List<Class> classes) throws IOException,
5454
ClassNotFoundException {
55-
String jarPath = resource.getPath().substring(5, resource.getPath().indexOf("!"));
55+
// two cases: (note: "jar" is in the protocol. path is like: file://xxxx or nested://xxx)
56+
// 1. jar:file:/path/to/jar!/
57+
// 2. jar:nested:/path/to/jar!/BOOT-INF/classes!/
58+
int realPathStartIndex = resource.getPath().indexOf(":");
59+
String jarPath = resource.getPath().substring(realPathStartIndex + 1, resource.getPath().indexOf("!"));
5660
JarFile jar = new JarFile(URLDecoder.decode(jarPath, StandardCharsets.UTF_8.name()));
5761

5862
Enumeration<JarEntry> entries = jar.entries();

0 commit comments

Comments
 (0)