Skip to content

Commit 220e9a1

Browse files
Merge pull request #42162 from gayaldassanayake/fix-custom-loader-8.5
[2201.8.5-stage] Exclude cli and picocli from childfirst loading in CustomToolClassLoader
2 parents 478a0ef + fdc9029 commit 220e9a1

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

cli/ballerina-cli/src/main/java/io/ballerina/cli/launcher/CustomToolClassLoader.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,13 @@ protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundE
4646
Class<?> loadedClass = findLoadedClass(name);
4747
if (loadedClass == null) {
4848
try {
49-
// First, try to load the class from the URLs
50-
loadedClass = findClass(name);
49+
// Load from parent if cli or picocli classes. This is to avoid SPI and class loading issues
50+
if (name.startsWith("io.ballerina.cli") || name.startsWith("picocli")) {
51+
loadedClass = super.loadClass(name, resolve);
52+
} else {
53+
// First, try to load the class from the URLs
54+
loadedClass = findClass(name);
55+
}
5156
} catch (ClassNotFoundException e) {
5257
try {
5358
// If not found, delegate to the parent

0 commit comments

Comments
 (0)