Skip to content

Commit 808185a

Browse files
committed
Make LaunchedURLClassLoader Java 6 compatible again
Closes gh-7334
1 parent aafb308 commit 808185a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/LaunchedURLClassLoader.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.jar.JarFile;
2828

2929
import org.springframework.boot.loader.jar.Handler;
30+
import org.springframework.lang.UsesJava7;
3031

3132
/**
3233
* {@link ClassLoader} used by the {@link Launcher}.
@@ -38,7 +39,7 @@
3839
public class LaunchedURLClassLoader extends URLClassLoader {
3940

4041
static {
41-
ClassLoader.registerAsParallelCapable();
42+
performParallelCapableRegistration();
4243
}
4344

4445
/**
@@ -186,4 +187,14 @@ private void clearCache(URLConnection connection) throws IOException {
186187
}
187188
}
188189

190+
@UsesJava7
191+
private static void performParallelCapableRegistration() {
192+
try {
193+
ClassLoader.registerAsParallelCapable();
194+
}
195+
catch (NoSuchMethodError ex) {
196+
// Running on Java 6. Continue.
197+
}
198+
}
199+
189200
}

0 commit comments

Comments
 (0)